Browse Source

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

zdm 5 years ago
parent
commit
5f7245b632

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

@ -1866,7 +1866,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
@ -1948,20 +1948,133 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return result;
    }
    
    public List<Map<String,Object>> findClinicRoomList(String dept) {
    public List<JSONObject> findClinicRoomList(String dept,String date) {
        if(StringUtils.isBlank(date)){
            date = DateUtil.getStringDateShort();
        }
        
        String sql ="SELECT " +
                "id," +
                "doctor_name," +
                "clinic_status AS visit_status," +
                "patient_name AS patient_name," +
                "waiting_count AS waiting_count," +
                "room_name AS room_name " +
                "FROM wlyy_doctor_clinic_room ";
        //获取今天的排班列表
        String doctorsql ="SELECT doctor,doctor_name FROM wlyy_doctor_work_time WHERE date='"+date+"' GROUP BY doctor";
    
        List<Map<String,Object>> doctorlist = jdbcTemplate.queryForList(doctorsql);
    
        HashMap<String ,JSONObject> result = new HashMap<>();
    
        for (int i = 0; i < doctorlist.size(); i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id",(String)doctorlist.get(0).get("doctor"));
    
            if(StringUtils.isNoneBlank((String)doctorlist.get(0).get("doctor_name"))){
                jsonObject.put("doctor_name",(String)doctorlist.get(0).get("doctor_name"));
            }else{
                jsonObject.put("doctor_name","");
            }
            jsonObject.put("visit_status",0);
            jsonObject.put("waiting_count",0);
            jsonObject.put("patient_name","");
            jsonObject.put("time_cost",0);
            result.put((String)doctorlist.get(0).get("doctor"),jsonObject);
        }
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        //获取预约了今天的候诊居民
        String waitingSql ="SELECT count(op.id) AS waitCount," +
                "room.doctor AS doctor, " +
                "room.doctor_name AS doctorName " +
                "FROM wlyy_outpatient op,wlyy_hospital_waiting_room room " +
                "WHERE op.`status`=0 AND room.outpatient_id=op.id AND room.consult_type=2 " +
                "AND room.doctor IS NOT NULL " +
                "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' GROUP BY room.doctor; ";
    
        List<Map<String,Object>> waitinglist = jdbcTemplate.queryForList(waitingSql);
        if(waitinglist!=null&&waitinglist.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> waitObj :waitinglist){
                String doctor = (String) waitObj.get("doctor");
                if(StringUtils.isNoneBlank(doctor)){
                    Long waitCount = (Long) waitObj.get("waitCount");
                    if(result.keySet().contains(doctor)){
                        result.get(doctor).put("waiting_count",waitCount);
                    }else{
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id",doctor);
                        jsonObject.put("visit_status",0);
                        jsonObject.put("waiting_count",waitCount);
                        if(StringUtils.isNoneBlank((String)waitObj.get("doctorName"))){
                            jsonObject.put("doctor_name",(String)waitObj.get("doctorName"));
                        }else{
                            jsonObject.put("doctor_name","");
                        }
                        jsonObject.put("patient_name","");
                        jsonObject.put("time_cost",0);
                        result.put(doctor,jsonObject);
                    }
                }
            }
        }
        
        return list;
        //获取进行中的居民
        String onlineSql ="SELECT " +
                "room.outpatient_id AS id," +
                "room.patient_id AS patient_id," +
                "room.patient_name AS patient_name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," +
                "TIMESTAMPDIFF(MINUTE, room.reservation_time,NOW()) AS time_cost," +
                "room.doctor AS doctor, " +
                "room.doctor_name AS doctorName " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient," +
                "wlyy_consult_team consult " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND consult.status=0 " +
                "AND room.consult_type=2 " +
                "AND room.reservation_time>='"+date+" 00:00:00' AND room.reservation_time<='"+date+" 23:59:59' " +
                "GROUP BY room.doctor";
        List<Map<String,Object>> onlinelist = jdbcTemplate.queryForList(onlineSql);
        if(waitinglist!=null&&waitinglist.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> onlineObj :onlinelist){
                String doctor = (String) onlineObj.get("doctor");
                if(StringUtils.isNoneBlank(doctor)){
                    if(result.keySet().contains(doctor)){
                        result.get(doctor).put("visit_status",1);
                        result.get(doctor).put("patient_name",(String) onlineObj.get("patient_name"));
                        result.get(doctor).put("time_cost",(Long) onlineObj.get("time_cost"));
                    }else{
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id",doctor);
    
                        if(StringUtils.isNoneBlank((String) onlineObj.get("doctorName"))){
                            jsonObject.put("doctor_name",(String) onlineObj.get("doctorName"));
                        }else{
                            jsonObject.put("doctor_name","");
                        }
                        jsonObject.put("visit_status",1);
                        jsonObject.put("waiting_count",0);
                        jsonObject.put("patient_name",(String) onlineObj.get("patient_name"));
                        jsonObject.put("time_cost",(Long) onlineObj.get("time_cost"));
                        result.put(doctor,jsonObject);
                    }
                }
            }
        }
        
        List<JSONObject> finalresult  = new ArrayList<>();
    
        for (JSONObject jsonObject : result.values()) {
            finalresult.add(jsonObject);
        }
        
        return finalresult;
    }
    
    public WlyyDoctorClinicRoomDO findClinicRoomStatus(String id) {
@ -2029,7 +2142,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+
                " Left join ( select count(id) as total,doctor from wlyy_consult_team GROUP BY doctor ) a on a.doctor = d.id ";
                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 2 GROUP BY doctor ) a on a.doctor = d.id ";
                
        if(StringUtils.isNotBlank(workingTime)){
            sql+=" JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
@ -2331,7 +2444,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," +
                "room.reservation_type AS reservation_type," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
@ -2346,7 +2459,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND outpatient.status = 1 " +
                "AND consult.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.consult_type= 2";
    
@ -2377,7 +2490,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "date_format(room.reservation_time ,'%Y-%m-%d %H:%i:%S' ) AS time," +
                "date_format(room.reservation_time ,'%Y-%m-%d' ) AS group_date," +
                "room.reservation_type AS reservation_type," +
                "outpatient.disease_img AS disease_img," +
@ -2450,7 +2563,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        List<WlyyHospitalWaitingRoomDO> roomDOs =hospitalWaitingRoomDao.findByOutpatientId(outpatientCode);
        if(roomDOs!=null&&roomDOs.size()>0){
            for(WlyyHospitalWaitingRoomDO roomDO:roomDOs){
                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
                    roomDO.setDoctor(doctor);
                    roomDO.setDoctorName(baseDoctorDO.getName());
                    hospitalWaitingRoomDao.save(roomDO);
            }
        }
@ -2461,43 +2576,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param doctor
     * @return
     */
    public JSONObject doctorIndexConsultCount(String doctor) {
    public Long doctorIndexConsultCount(String doctor) {
    
        //医生问诊量
        List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByDoctor(doctor);
        
        Integer imgCount = 0;
        
        Integer videoCount = 0;
        
        for(WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOs){
            //1.图文 2.视频
            if("1".equals(wlyyOutpatientDO.getType())){
                imgCount ++;
            }else if("2".equals(wlyyOutpatientDO.getType())){
                videoCount ++;
            }else{
                continue;
            }
        }
    
        String totalSql = "SELECT count(a.id) AS total " +
                "FROM wlyy_consult a,wlyy_consult_team b " +
                "WHERE a.id=b.consult AND b.doctor='"+doctor+"' AND a.type=1 AND b.`status`=0";
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        String sql ="SELECT " +
                "count(room.outpatient_id) AS total " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient, " +
                "wlyy_consult_team consult " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND consult.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.consult_type= 2";
    
        Long zjCount = 0L;
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
    
        Long videoOnlineCount = 0l;
        if (rstotal != null && rstotal.size() > 0) {
            zjCount = (Long) rstotal.get(0).get("total");
            videoOnlineCount = (Long) rstotal.get(0).get("total");
        }
        
        JSONObject result = new JSONObject();
        result.put("imgCount",imgCount);
        result.put("videoCount",videoCount);
        result.put("zjCount",zjCount);
        
        return result;
    
        return videoOnlineCount;
        
    }
    
@ -2566,4 +2670,34 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return result;
    }
    
    /**
     * 获取候诊居民数量
     * @param doctor
     * @return
     */
    public Long getWaitVideoCount(String doctor) {
        String sql ="SELECT " +
                "count(room.outpatient_id) AS total " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND outpatient.status = 0 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.reservation_time is not null " +
                "AND room.consult_type= 2 ";
    
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
    
        Long waitVideoCount = 0l;
        if (rstotal != null && rstotal.size() > 0) {
            waitVideoCount = (Long) rstotal.get(0).get("total");
        }
    
        return waitVideoCount;
    }
}

+ 14 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -986,6 +986,8 @@ public class ImService {
			
			wlyyOutpatientDO.setStatus("1");//修改就诊记录为就诊中
			wlyyOutpatientDO.setConDate(new Date());
			wlyyOutpatientDO.setDoctor(doctorCode);
			wlyyOutpatientDO.setDoctorName(doctor.getName());
			outpatientDao.save(wlyyOutpatientDO);
			
			//修改候诊室状态为已诊
@ -993,6 +995,8 @@ public class ImService {
			if(roomDOs!=null&&roomDOs.size()>0){
				for(WlyyHospitalWaitingRoomDO roomDO:roomDOs){
					roomDO.setVisitStatus(2);//修改候诊室状态为已诊
					roomDO.setDoctor(doctorCode);
					roomDO.setDoctorName(doctor.getName());
					hospitalWaitingRoomDao.save(roomDO);
				}
			}
@ -1311,4 +1315,14 @@ public class ImService {
			return scoreList;
		}
	}
	
	/**
	 *按会话类型获取会话总数
	 * @param userid
	 * @param type
	 * @return
	 */
	public Integer sessionCountByType(String userid,Integer type){
		return imUtil.sessionCountByType(userid,type);
	}
}

+ 19 - 1
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -524,7 +524,6 @@ public class ImUtil {
		} catch (Exception e) {
			return null;
		}
		
	}
	
	/**
@ -630,6 +629,7 @@ public class ImUtil {
		}
	}
	
	
	/**
	 * 根据session和userid获取单个会话
	 * @param sessionId
@ -677,4 +677,22 @@ public class ImUtil {
	public static final String SESSION_STATUS_END = "1";
	
	public static final String CONTENT_TYPE_TEXT = "1";
	
	
	/**
	 *按会话类型获取会话总数
	 * @param userid
	 * @param type
	 * @return
	 */
	public Integer sessionCountByType(String userid,Integer type){
		String url = im_host + "api/v2/sessions/sessionCountByType?user_id="+userid+"&type="+type;
		String ret = HttpClientUtil.get(url,"utf-8");
		JSONObject obj = JSON.parseObject(ret);
		if(obj.getInteger("status") ==200){
			return obj.getInteger("count");
		}else{
			return 0;
		}
	}
}

+ 34 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -14,6 +14,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author huangwenjie
 */
@ -64,9 +65,11 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "导诊台诊室列表", notes = "导诊台诊室列表")
	public Envelop findClinicRoomList(
			@ApiParam(name = "dept", value = "部门CODE")
			@RequestParam(value = "dept",required = false) String dept){
			@RequestParam(value = "dept",required = false) String dept,
			@ApiParam(name = "date", value = "日期")
			@RequestParam(value = "date",required = false) String date){
//		String result = "[{\"id\":\"XXD2019887711\",\"doctor_name\":\"蔡建春\",\"visit_status\":0,\"patient_name\":\"张三\",\"visit_time\":\"2019-06-21 08:30:00\",\"time_cost\":50,\"waiting_count\":26,\"room_name\":\"01诊室\"},{\"id\":\"XXD2019887712\",\"doctor_name\":\"蔡阿梅\",\"visit_status\":1,\"patient_name\":\"李四\",\"visit_time\":\"2019-06-21 09:30:00\",\"time_cost\":60,\"waiting_count\":33,\"room_name\":\"02诊室\"}]";
		return success("请求成功",prescriptionService.findClinicRoomList(dept));
		return success("请求成功",prescriptionService.findClinicRoomList(dept,date));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.findClinicRoomStatus)
@ -220,7 +223,35 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "复诊图文咨询人数,视频咨询人数", notes = "复诊图文咨询人数,视频咨询人数")
	public Envelop doctorIndexConsultCount(@ApiParam(name = "doctor", value = "医生CODE")
	                                           @RequestParam(value = "doctor",required = true) String doctor){
		return success("请求成功",prescriptionService.doctorIndexConsultCount(doctor));
		
		//专家咨询
		Integer zjCount = imService.sessionCountByType(doctor,1);
		
		//复诊咨询
		Integer imgCount = imService.sessionCountByType(doctor,9);
		//正在进行中的视频复诊
		Long _videoOnlineCount = prescriptionService.doctorIndexConsultCount(doctor);
		Integer videoCount = _videoOnlineCount.intValue();
		
		//获取候诊居民数量(包含进行中的)
		Long _waitVideoCount = prescriptionService.getWaitVideoCount(doctor);
		Integer waitVideoCount = _waitVideoCount.intValue();
		
		JSONObject result = new JSONObject();
		result.put("zjCount",zjCount);
		
		imgCount = imgCount - videoCount;
		if(imgCount <=0){
			imgCount = 0;
		}
		
		result.put("zjCount",zjCount);
		result.put("imgCount",imgCount);
		result.put("videoCount",waitVideoCount+_videoOnlineCount);
		
		
		return success("请求成功",result);
	}
	
	

+ 1 - 1
svr/svr-internet-hospital/src/main/resources/application.yml

@ -232,7 +232,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.105:3000/
  im_list_get: http://172.16.1.42:3000/
  data_base_name: im
# 上传文件临时路径配置