Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangjun 4 years ago
parent
commit
ad1809eae9

+ 118 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -3091,7 +3091,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs.size();
    }
    public Map<String, Object> findDoctorInfo(String doctor, String withWork) {
    public Map<String, Object> findDoctorInfo(String doctor, String withWork,String patient) {
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        Map<String, Object> rs = new HashedMap();
@ -3185,7 +3185,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
//            Integer coordinationCout = outpatientDao.countByDoctorAndStatusAndOutpatientType(doctor,"2","2");
//            rs.put("coordinationCout",coordinationCout);
            //医生关注
            List<BaseDoctorPatientFollowDO> doctorPatientFollowDOS = baseOrgPatientDao.findByDoctor(doctor);
            List<BaseDoctorPatientFollowDO> doctorPatientFollowDOS = baseOrgPatientDao.findByDoctorAndPatient(doctor,patient);
            if (doctorPatientFollowDOS != null && doctorPatientFollowDOS.size() > 0) {
                rs.put("attention", "1");
            } else {
@ -4200,7 +4200,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                jsonObject.put("dept_code", "");
            }
            jsonObject.put("visit_status", 1);
            jsonObject.put("waiting_count", 0);
            jsonObject.put("visit_count", 0);
            jsonObject.put("offline_count",0);
            jsonObject.put("ending_count",0);
            jsonObject.put("patient_name", "");
            jsonObject.put("time_cost", 0);
@ -4239,12 +4241,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if (StringUtils.isNoneBlank(doctor)) {
                    Long waitCount = Long.parseLong(waitObj.get("waitCount").toString());
                    if (result.keySet().contains(doctor)) {
                        result.get(doctor).put("waiting_count", waitCount);
                        result.get(doctor).put("visit_count", waitCount);
                    } else {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", doctor);
                        jsonObject.put("visit_status", 1);
                        jsonObject.put("waiting_count", waitCount);
                        jsonObject.put("visit_count", waitCount);
                        jsonObject.put("offline_count", 0);
                        jsonObject.put("ending_count", 0);
                        if (StringUtils.isNoneBlank((String) waitObj.get("doctorName"))) {
                            jsonObject.put("doctor_name", (String) waitObj.get("doctorName"));
                        } else {
@ -4258,6 +4262,115 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
        }
        //已结束
        String endSql = "SELECT count(op.id) AS \"endCount\"," +
                "room.doctor AS \"doctor\", " +
                "room.doctor_name AS \"doctorName\" " +
                "FROM wlyy_outpatient op,wlyy_hospital_waiting_room room " +
                "WHERE op.status=3 AND room.outpatient_id=op.id AND room.consult_type=2 " +
                "AND room.doctor IS NOT NULL ";
        if (StringUtils.isNoneBlank(dept)) {
            endSql = endSql + " and op.dept = '" + dept + "' ";
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                endSql += " AND room.reservation_time >= str_to_date('" + date + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                endSql += " AND room.reservation_time <= str_to_date('" + date + " 23:59:59','YYYY-MM-DD HH24:MI:SS') GROUP BY room.doctor,room.doctor_name";
            }else {
                endSql += " AND room.reservation_time >= to_date('" + date + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                endSql += " AND room.reservation_time <= to_date('" + date + " 23:59:59','YYYY-MM-DD HH24:MI:SS') GROUP BY room.doctor,room.doctor_name";
            }
        } else {
            endSql = endSql + "AND room.reservation_time>='" + date + " 00:00:00' AND room.reservation_time<='" + date + " 23:59:59' GROUP BY room.doctor,room.doctor_name; ";
        }
        List<Map<String, Object>> endlist = jdbcTemplate.queryForList(endSql);
        if (endlist != null && endlist.size() > 0) {
            //根据身份证计算年龄
            for (Map<String, Object> endObj : endlist) {
                String doctor = (String) endObj.get("doctor");
                if (StringUtils.isNoneBlank(doctor)) {
                    Long endCount = Long.parseLong(endObj.get("endCount").toString());
                    if (result.keySet().contains(doctor)) {
                        result.get(doctor).put("ending_count", endCount);
                    } else {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", doctor);
                        jsonObject.put("visit_status", 1);
                        jsonObject.put("visit_count",0);
                        jsonObject.put("offline_count", 0);
                        jsonObject.put("ending_count", endCount);
                        if (StringUtils.isNoneBlank((String) endObj.get("doctorName"))) {
                            jsonObject.put("doctor_name", (String) endObj.get("doctorName"));
                        } else {
                            jsonObject.put("doctor_name", "");
                        }
                        jsonObject.put("patient_name", "");
                        jsonObject.put("time_cost", 0);
                        result.put(doctor, jsonObject);
                    }
                }
            }
        }
        //离线
        String disconnectSql = "SELECT count(op.id) AS \"disconnectCount\"," +
                "room.doctor AS \"doctor\", " +
                "room.doctor_name AS \"doctorName\" " +
                "FROM wlyy_outpatient op,wlyy_hospital_waiting_room room ," +
                "base_patient p " +
                "WHERE  room.outpatient_id=op.id AND room.consult_type=2  AND p.id = op.patient" +
                " AND room.doctor IS NOT NULL and (p.online=0 OR P.online IS NULL) ";
        if (StringUtils.isNoneBlank(dept)) {
            disconnectSql = disconnectSql + " and op.dept = '" + dept + "' ";
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            if (flag){
                disconnectSql += " AND room.reservation_time >= str_to_date('" + date + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                disconnectSql += " AND room.reservation_time <= str_to_date('" + date + " 23:59:59','YYYY-MM-DD HH24:MI:SS') GROUP BY room.doctor,room.doctor_name";
            }else {
                disconnectSql += " AND room.reservation_time >= to_date('" + date + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
                disconnectSql += " AND room.reservation_time <= to_date('" + date + " 23:59:59','YYYY-MM-DD HH24:MI:SS') GROUP BY room.doctor,room.doctor_name";
            }
        } else {
            disconnectSql = disconnectSql + "AND room.reservation_time>='" + date + " 00:00:00' AND room.reservation_time<='" + date + " 23:59:59' GROUP BY room.doctor,room.doctor_name; ";
        }
        List<Map<String, Object>> disconnectlist = jdbcTemplate.queryForList(disconnectSql);
        if (disconnectlist != null && disconnectlist.size() > 0) {
            //根据身份证计算年龄
            for (Map<String, Object> endObj : endlist) {
                String doctor = (String) endObj.get("doctor");
                if (StringUtils.isNoneBlank(doctor)) {
                    Long disconnectCount = Long.parseLong(endObj.get("disconnectCount").toString());
                    if (result.keySet().contains(doctor)) {
                        result.get(doctor).put("offline_count", disconnectCount);
                    } else {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", doctor);
                        jsonObject.put("visit_status", 1);
                        jsonObject.put("ending_count",0);
                        jsonObject.put("visit_count",0);
                        jsonObject.put("offline_count", disconnectCount);
                        if (StringUtils.isNoneBlank((String) endObj.get("doctorName"))) {
                            jsonObject.put("doctor_name", (String) endObj.get("doctorName"));
                        } else {
                            jsonObject.put("doctor_name", "");
                        }
                        jsonObject.put("patient_name", "");
                        jsonObject.put("time_cost", 0);
                        result.put(doctor, jsonObject);
                    }
                }
            }
        }
        //获取进行中的居民
        String onlineSql = "SELECT " +
                "room.outpatient_id AS \"id\"," +

+ 16 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -239,6 +239,12 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     * 人气值
     */
    private Integer popularity;
    /**
     * 上线下线状态
     */
    private String online;//1上线0下线
    @Column(name = "popularity")
    public Integer getPopularity() {
        return popularity;
@ -603,4 +609,14 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    public void setLearning(String learning) {
        this.learning = learning;
    }
    @Column(name = "online")
    public String getOnline() {
        return online;
    }
    public void setOnline(String online) {
        this.online = online;
    }
}

+ 15 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -243,6 +243,11 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String phone;
    /**
     * 上线下线状态
     */
    private String online;//1上线0下线
    @Column(name = "register")
    public String getRegister() {
        return register;
@ -645,4 +650,14 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setYktId(String yktId) {
        this.yktId = yktId;
    }
    @Column(name = "online")
    public String getOnline() {
        return online;
    }
    public void setOnline(String online) {
        this.online = online;
    }
}

+ 15 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/doctor/BaseDoctorVO.java

@ -196,6 +196,12 @@ public class BaseDoctorVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty("医生归属科室")
    private List<String> department;
    /**
     * 上线下线状态
     */
    @ApiModelProperty("上线状态")
    private String online;//1上线0下线
    public String getPassword() {
        return password;
    }
@ -409,4 +415,13 @@ public class BaseDoctorVO extends UuidIdentityVOWithOperator {
    public void setDepartment(List<String> department) {
        this.department = department;
    }
    public String getOnline() {
        return online;
    }
    public void setOnline(String online) {
        this.online = online;
    }
}

+ 14 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/patient/BasePatientVO.java

@ -313,6 +313,11 @@ public class BasePatientVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "备注", example = "某某备注")
    private String remark;
    /**
     * 上线下线状态
     */
    @ApiModelProperty("上线状态")
    private String online;//1上线0下线
    public String getSaasId() {
        return saasId;
@ -665,4 +670,13 @@ public class BasePatientVO extends UuidIdentityVOWithOperator {
    public void setAddress(String address) {
        this.address = address;
    }
    public String getOnline() {
        return online;
    }
    public void setOnline(String online) {
        this.online = online;
    }
}

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -230,8 +230,10 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    public ObjEnvelop findDoctorInfo(@ApiParam(name = "doctor", value = "医生code")
                                     @RequestParam(value = "doctor", required = true)String doctor,
                                     @ApiParam(name = "withWork", value = "传1带排班,其他不带")
                                     @RequestParam(value = "withWork", required = false)String withWork){
        return success(prescriptionService.findDoctorInfo(doctor,withWork));
                                     @RequestParam(value = "withWork", required = false)String withWork,
                                     @ApiParam(name = "patient", value = "患者code")
                                         @RequestParam(value = "patient", required = false)String patient){
        return success(prescriptionService.findDoctorInfo(doctor,withWork,patient));
    }

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -567,8 +567,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop findDoctorInfo(@ApiParam(name = "doctor", value = "医生code")
                                     @RequestParam(value = "doctor", required = true)String doctor,
                                     @ApiParam(name = "withWork", value = "传1带排班,其他不带")
                                     @RequestParam(value = "withWork", required = false)String withWork){
        return success(prescriptionService.findDoctorInfo(doctor,withWork));
                                     @RequestParam(value = "withWork", required = false)String withWork,
                                     @ApiParam(name = "patient", value = "患者code")
                                         @RequestParam(value = "patient", required = false)String patient){
        return success(prescriptionService.findDoctorInfo(doctor,withWork,patient));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateDoctorInfo)

+ 52 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/common/OrgUserService.java

@ -0,0 +1,52 @@
package com.yihu.iot.service.common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by yeshijie on 2020/7/29.
 */
@Service
public class OrgUserService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取当前登录者的机构权限
     * @param userId
     * @return
     */
    public List<String> getUserOrgNameById(String userId){
        String sql = "SELECT h.name from `iot-base`.base_org_user o,iot_hospital h WHERE o.org_code = h.saas_id and o.user_id = '"+userId+"' ";
        return jdbcTemplate.queryForList(sql,String.class);
    }
    /**
     * 获取当前登录者的机构权限
     * @param userId
     * @return
     */
    public List<String> getUserOrgById(String userId){
        String sql = "SELECT org_code from `iot-base`.base_org_user WHERE user_id = '"+userId+"' ";
        return jdbcTemplate.queryForList(sql,String.class);
    }
    /**
     *
     * @param list
     * @return
     */
    public String getUserOrg(List<String> list){
        String res = "'";
        for (String s:list){
            res +=s+"'";
        }
        if(res.length()==1){
            res +="'";
        }
        return res;
    }
}

+ 11 - 8
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -9,6 +9,7 @@ import com.yihu.iot.dao.device.IotDeviceSimDao;
import com.yihu.iot.dao.device.IotPatientDeviceDao;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.common.ElasticSearchQueryGenerator;
import com.yihu.iot.service.common.OrgUserService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.iot.util.excel.HibenateUtils;
@ -31,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.provider.HibernateUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -69,6 +69,9 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    private IotCompanyDao iotCompanyDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private OrgUserService orgUserService;
    /**
     * 新增
@ -296,18 +299,12 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
                String snCoed = locationDataVO.getDeviceSn();
                List<Map<String,Object>> nameList = new ArrayList<>();
                List<Map<String,Object>> deviceList = new ArrayList<>();
                System.out.println("idCard:="+idCard);
                System.out.println("snCode:="+snCoed);
                if (StringUtils.isNotEmpty(idCard)){
                    sql = sql +" and t.idcard = '"+idCard+"'";
                    System.out.println("查询患者name和code开始");
                    nameList = jdbcTempalte.queryForList(sql);
                    System.out.println("查询患者name和code结束:"+nameList);
                }if (StringUtils.isNotEmpty(snCoed)){
                    sqlEqt = sqlEqt +" and t.device_code = '"+snCoed+"'";
                    System.out.println("查询设备名称开始");
                    deviceList = jdbcTempalte.queryForList(sqlEqt);
                    System.out.println("查询设备名称结束:"+deviceList);
                }
                if(nameList.size()>0){
                    String code = null==nameList.get(0).get("code")?"":nameList.get(0).get("code").toString();
@ -530,7 +527,8 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        }
    }
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getPatientDeviceList(String deviceSn, String deviceName, String categoryCode, String patientName, String hospitalName, Integer isDel, Integer page, Integer pageSize) {
    public MixEnvelop<IotPatientDeviceVO,IotPatientDeviceVO> getPatientDeviceList(String deviceSn, String deviceName,
        String categoryCode, String patientName, String hospitalName, Integer isDel, Integer page, Integer pageSize) {
        String sql = "SELECT DISTINCT d.* FROM `iot_patient_device` d  where 1=1  ";
        if(isDel != null &&isDel == 1){
            sql += "and d.del != 1 ";
@ -550,6 +548,11 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
        if(StringUtils.isNotBlank(hospitalName)){
            sql += "and d.hospital_name like '%" + hospitalName + "%' ";
        }
        //数据权限过滤
        List<String> list = orgUserService.getUserOrgById(userAgent.getUID());
        if(!list.contains(userAgent.commonHospital)){
            sql += " and d.hospital in ("+orgUserService.getUserOrg(list)+") ";
        }
        sql += "order by d.update_time desc ";
        //判断是否需要分页
        if (page != null && pageSize != null) {

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

@ -16,6 +16,9 @@ import javax.servlet.http.HttpServletRequest;
@Component
public class UserAgent {
    public String commonHospital = "iot-hospital";
    public String commonHospitalName = "物联网通用机构";
    /**
     * 获取当前登录人ID
     * @return

+ 3 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -610,13 +610,13 @@ public class SpecialistService{
                " r.team_code,r.sign_date , " +
                " t.`name` AS name," +
                " d.photo," +
                " d.code AS doctor," +
                " d.name AS doctorName,d.hospital,d.hospital_name " +
                " md.code AS doctor," +
                " md.name AS doctorName,d.hospital,d.hospital_name " +
                " FROM " +
                " wlyy_specialist_patient_relation r  " +
                " JOIN "+basedb+".wlyy_admin_team t ON t.id = r.team_code " +
                " JOIN "+basedb+".wlyy_doctor d ON t.leader_code = d.`code` " +
//                " JOIN "+basedb+".wlyy_doctor md ON md.code = r.doctor " +
                " JOIN "+basedb+".wlyy_doctor md ON md.code = r.doctor " +
                " WHERE " +
                " r.patient = '"+patient+"' " +
                " AND r.`status` >=0  " +