|  | @ -3,7 +3,12 @@ package com.yihu.jw.hospital.endpoint.statistics;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.es.service.StatisticsEsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.im.service.ImService;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.statistics.ScreenQvo;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.Envelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.ListEnvelop;
 | 
	
	
		
			
				|  | @ -13,6 +18,7 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
 | 
	
		
			
				|  |  | import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiParam;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @ -39,6 +45,12 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private StatisticsEsService statisticsEsService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ImService imService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorDao baseDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -1264,8 +1276,8 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取【科室、医生】的接诊量接诊率排名
 | 
	
		
			
				|  |  |      * 参数:
 | 
	
		
			
				|  |  |      * 科室参数:strJson={"startDate":"2023-07-01","endDate":"2023-07-20","area":"350211A1002","level":4,"deptCode":"1190000","flag":"1"}
 | 
	
		
			
				|  |  |      * 医生参数:strJson={"startDate":"2023-07-17","endDate":"2023-07-20","area":"","level":5,"flag":"1"}
 | 
	
		
			
				|  |  |      * 科室参数:strJson={"startDate":"2020-07-01","endDate":"2023-07-20","area":"350211A1002","level":4,"deptCode":"1190000","flag":"1"}
 | 
	
		
			
				|  |  |      * 医生参数:strJson={"startDate":"2020-07-17","endDate":"2023-07-20","area":"","level":5,"flag":"1"}
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @GetMapping(value = BaseHospitalRequestMapping.Statistics.getDeptOrDoctorVolumeList)
 | 
	
		
			
				|  |  |     @ApiOperation(value = " 获取【科室、医生】的接诊量接诊率排名")
 | 
	
	
		
			
				|  | @ -1619,7 +1631,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  |     public Envelop getDoctorSeverScopeDetail(@RequestParam(required = true) String strJson) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
 | 
	
		
			
				|  |  |             List<Map<String, Object>> result = statisticsEsService.getDoctorSeverScopeDetail(qvo);
 | 
	
		
			
				|  |  |             Map<String, Object> result = statisticsEsService.getDoctorSeverScopeDetail(qvo);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
	
		
			
				|  | @ -1637,7 +1649,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  |     public Envelop getDoctorFreeDetail(@RequestParam(required = true) String strJson) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
 | 
	
		
			
				|  |  |             List<Map<String, Object>> result = statisticsEsService.getDoctorFreeDetail(qvo);
 | 
	
		
			
				|  |  |             Map<String, Object>  result = statisticsEsService.getDoctorFreeDetail(qvo);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
	
		
			
				|  | @ -1731,4 +1743,63 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @GetMapping(value = BaseHospitalRequestMapping.DodtorIM.records2)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "医生咨询记录查询")
 | 
	
		
			
				|  |  |     public Envelop records2(
 | 
	
		
			
				|  |  |             @ApiParam(name = "doctor", value = "医生id")
 | 
	
		
			
				|  |  |             @RequestParam(value = "doctor",required = false) String doctor,
 | 
	
		
			
				|  |  |             @ApiParam(name = "title", value = "咨询标题关键字")
 | 
	
		
			
				|  |  |             @RequestParam(value = "title",required = false) String title,
 | 
	
		
			
				|  |  |             @ApiParam(name = "patient", value = "患者id")
 | 
	
		
			
				|  |  |             @RequestParam(value = "patient",required = false) String patient,
 | 
	
		
			
				|  |  |             @ApiParam(name = "id", value = "咨询ID")
 | 
	
		
			
				|  |  |             @RequestParam(value = "id",required = false) String id,
 | 
	
		
			
				|  |  |             @ApiParam(name = "type", value = "咨询类型")
 | 
	
		
			
				|  |  |             @RequestParam(value = "type",required = true) String type,
 | 
	
		
			
				|  |  |             @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
 | 
	
		
			
				|  |  |             @RequestParam(value = "status",required = true) Integer status,
 | 
	
		
			
				|  |  |             @ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
 | 
	
		
			
				|  |  |             @RequestParam(value = "start_time",required = false) String start_time,
 | 
	
		
			
				|  |  |             @ApiParam(name = "end_time", value = "结束时间 YYYY-MM-DD HH:MM:SS")
 | 
	
		
			
				|  |  |             @RequestParam(value = "end_time",required = false) String end_time,
 | 
	
		
			
				|  |  |             @ApiParam(name = "page", value = "第几页")
 | 
	
		
			
				|  |  |             @RequestParam(value = "page",required = false) int page,
 | 
	
		
			
				|  |  |             @ApiParam(name = "pagesize", value = "分页大小")
 | 
	
		
			
				|  |  |             @RequestParam(value = "pagesize",required = false) int pagesize
 | 
	
		
			
				|  |  |     )throws Exception{
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             List<Map<String,Object>>  data = imService.findConsultRecordByDoctorNew(doctor, id,type,status, page,pagesize, title,start_time,end_time,patient);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (data != null) {
 | 
	
		
			
				|  |  |                 for(Map<String,Object> consult :data){
 | 
	
		
			
				|  |  |                     //如果是协同门诊,多返回全科医生的详细信息
 | 
	
		
			
				|  |  |                     if(12 == Integer.parseInt(consult.get("type").toString()) && StringUtils.isNoneBlank((String)consult.get("generalDoctor"))){
 | 
	
		
			
				|  |  |                         BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel((String)consult.get("generalDoctor"));
 | 
	
		
			
				|  |  |                         List<BaseDoctorHospitalDO> baseDoctorHospitalDOList = baseDoctorHospitalDao.findByDoctorCode((String)consult.get("generalDoctor"));
 | 
	
		
			
				|  |  |                         if(baseDoctorDO!=null){
 | 
	
		
			
				|  |  |                             consult.put("generalDoctorName", baseDoctorDO.getName());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if (baseDoctorHospitalDOList!=null&&baseDoctorHospitalDOList.size()!=0){
 | 
	
		
			
				|  |  |                             BaseDoctorHospitalDO baseDoctorHospitalDO = baseDoctorHospitalDOList.get(0);
 | 
	
		
			
				|  |  |                             consult.put("generalOrgName",baseDoctorHospitalDO.getOrgName());
 | 
	
		
			
				|  |  |                             consult.put("generalDeptName",baseDoctorHospitalDO.getDeptName());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Long total = imService.countConsultRecordByDoctor2(doctor, id,type,status,title,start_time,end_time);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |             result.put("total",total);
 | 
	
		
			
				|  |  |             result.put("list",data);
 | 
	
		
			
				|  |  |             return success(result);
 | 
	
		
			
				|  |  |         } catch (Exception e){
 | 
	
		
			
				|  |  |             return failedException(e);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |