|  | @ -0,0 +1,948 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.healthUpload.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictHospitalDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.healthUpload.BasePatientHealthUploadDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.healthUpload.HealthReportingFrequencyDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthUpload.dao.BaseDoctorMemberDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthUpload.dao.BasePatientHealthUploadDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.healthUpload.dao.HealthReportingFrequencyDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.message.service.WxMessageUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.PageRequest;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
		
			
				|  |  | import javax.transaction.Transactional;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
		
			
				|  |  | public class BasePatientHealthUploadService extends BaseJpaService<BasePatientHealthUploadDO, BasePatientHealthUploadDao> {
 | 
	
		
			
				|  |  |     private static Logger logger = LoggerFactory.getLogger(BasePatientHealthUploadService.class);
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorMemberDao doctorMemberDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao patientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientHealthUploadDao basePatientHealthUploadDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DictHospitalDeptDao dictHospitalDeptDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HibenateUtils hibenateUtils;
 | 
	
		
			
				|  |  |     @Value("${wechat.id}")
 | 
	
		
			
				|  |  |     private String wechatId;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHospitalSysDictDao hospitalSysDictDao;
 | 
	
		
			
				|  |  |     @Resource
 | 
	
		
			
				|  |  |     private WxMessageUtil wxMessageUtil;
 | 
	
		
			
				|  |  |     @Resource
 | 
	
		
			
				|  |  |     private HealthReportingFrequencyDao healthReportingFrequencyDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 判断居民是否上传健康上报(住院陪护)
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public boolean isUploadType3(String patient){
 | 
	
		
			
				|  |  |         //查找最近一次核酸记录
 | 
	
		
			
				|  |  |         BasePatientHealthUploadDO uploadDO =  basePatientHealthUploadDao.findByPatientIdRecently(patient);
 | 
	
		
			
				|  |  |         if(uploadDO==null){
 | 
	
		
			
				|  |  |             return false;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<HealthReportingFrequencyDO> frequencyDOS = healthReportingFrequencyDao.findByType(3);
 | 
	
		
			
				|  |  |         if(frequencyDOS.size()>0){
 | 
	
		
			
				|  |  |             //计算是否上传
 | 
	
		
			
				|  |  |             HealthReportingFrequencyDO frequencyDO = frequencyDOS.get(0);
 | 
	
		
			
				|  |  |             if(frequencyDO.getDay().equals(frequencyDO.getChecks())){
 | 
	
		
			
				|  |  |                 // 1天1检 直接判断今天是否上传
 | 
	
		
			
				|  |  |                 return DateUtil.getStringDateShort().compareTo(DateUtil.dateToStrShort(uploadDO.getCreateTime()))==0;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 Double seconds = Double.parseDouble(frequencyDO.getDay())/Double.parseDouble(frequencyDO.getChecks())*24*60*60;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 long difSeconds = seconds.longValue() - DateUtil.getDifferenceOfSeconds(new Date(),uploadDO.getCreateTime());
 | 
	
		
			
				|  |  |                 return difSeconds>0;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return false;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static void main(String[] args) {
 | 
	
		
			
				|  |  |         String date = "2022-12-06 12:25:20";
 | 
	
		
			
				|  |  |         Date d = DateUtil.strToDate(date);
 | 
	
		
			
				|  |  |         System.out.println(DateUtil.getStringDateShort().compareTo(DateUtil.dateToStrShort(d)));
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public MixEnvelop selectHealthUploadInfoByPatientId(String patientId, String startDate, String endDate, Integer page, Integer pageSize) {
 | 
	
		
			
				|  |  |         PageRequest pageRequest = PageRequest.of(page - 1, pageSize);
 | 
	
		
			
				|  |  |         MixEnvelop mixEnvelop = new MixEnvelop();
 | 
	
		
			
				|  |  |         List<BasePatientHealthUploadDO> list = new ArrayList<>();
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {
 | 
	
		
			
				|  |  |             Date startTime = DateUtil.strToDateLong(startDate);
 | 
	
		
			
				|  |  |             Date endTime = DateUtil.strToDateLong(endDate);
 | 
	
		
			
				|  |  |             list = basePatientHealthUploadDao.selectHealthUploadInfoByPatientIdAndDate(patientId, startTime, endTime, pageRequest);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             list = basePatientHealthUploadDao.selectHealthUploadInfoByPatientId(patientId, pageRequest);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         mixEnvelop.setCurrPage(page);
 | 
	
		
			
				|  |  |         mixEnvelop.setPageSize(pageSize);
 | 
	
		
			
				|  |  |         mixEnvelop.setDetailModelList(list);
 | 
	
		
			
				|  |  |         mixEnvelop.setTotalCount(list == null ? 0 : list.size());
 | 
	
		
			
				|  |  |         return mixEnvelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 提交健康信息
 | 
	
		
			
				|  |  |      * 健康信息实体类
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public BasePatientHealthUploadDO createHealthUploadInfo(BasePatientHealthUploadDO basePatientHealthUploadDO) {
 | 
	
		
			
				|  |  |         basePatientHealthUploadDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         basePatientHealthUploadDO = basePatientHealthUploadDao.save(basePatientHealthUploadDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return basePatientHealthUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public BasePatientHealthUploadDO selectHealthInfoById(String id) {
 | 
	
		
			
				|  |  |         BasePatientHealthUploadDO basePatientHealthUploadDO = basePatientHealthUploadDao.findById(id).orElse(null);
 | 
	
		
			
				|  |  |         return basePatientHealthUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查下最新一次记录
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public BasePatientHealthUploadDO selectRecordByPatientIdAndConsumer(String patientId, String consumer) {
 | 
	
		
			
				|  |  |         BasePatientHealthUploadDO basePatientHealthUploadDO = null;
 | 
	
		
			
				|  |  |         List<BasePatientHealthUploadDO> patientHealthUploadDOList = basePatientHealthUploadDao.findByPatientIdAndConsumer(patientId, consumer);
 | 
	
		
			
				|  |  |         if (patientHealthUploadDOList != null && patientHealthUploadDOList.size() != 0) {
 | 
	
		
			
				|  |  |             basePatientHealthUploadDO = patientHealthUploadDOList.get(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return basePatientHealthUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param orgCode
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @param key
 | 
	
		
			
				|  |  |      * @param flag 是否异常1是0否
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByHospitalAndDept(String orgCode, String dept, String doctorCode,String key, Integer flag) {
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " d.id AS \"id\", " +
 | 
	
		
			
				|  |  |                 " d.photo AS \"photo\", " +
 | 
	
		
			
				|  |  |                 " d.name AS \"name\", " +
 | 
	
		
			
				|  |  |                 " d.expertise AS \"expertise\"," +
 | 
	
		
			
				|  |  |                 " d.introduce AS \"introduce\"," +
 | 
	
		
			
				|  |  |                 " d.job_title_code AS \"jobTitleCode\", " +
 | 
	
		
			
				|  |  |                 " d.job_title_name AS \"jobTitleName\"," +
 | 
	
		
			
				|  |  |                 " d.charge_type AS \"chargeType\"," +
 | 
	
		
			
				|  |  |                 " d.outpatient_type AS \"outpatientType\"," +
 | 
	
		
			
				|  |  |                 " d.consult_status AS \"consultStatus\"," +
 | 
	
		
			
				|  |  |                 " h.dept_code AS \"deptCode\","+
 | 
	
		
			
				|  |  |                 " h.dept_name AS \"deptName\","+
 | 
	
		
			
				|  |  |                 " h.org_code AS \"orgCode\","+
 | 
	
		
			
				|  |  |                 " h.org_name AS \"orgName\","+
 | 
	
		
			
				|  |  |                 " t.photo AS \"hosptialphoto\","+
 | 
	
		
			
				|  |  |                 " d.id_type AS \"idType\","+
 | 
	
		
			
				|  |  |                 " d.id_card_type AS \"idCardType\" "+
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " left join base_org t on t.id = h.org_code" +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " 1=1 and d.del=1 ";
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(dept)) {
 | 
	
		
			
				|  |  |             sql += " AND h.dept_code = '" + dept + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(orgCode)) {
 | 
	
		
			
				|  |  |             sql += " AND h.org_code = '" + orgCode + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(key)) {
 | 
	
		
			
				|  |  |             sql += " AND (h.dept_name like '%" + key + "%' OR d.name like '%" + key + "%' OR d.expertise like '%" + key + "%') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String id = map.get("id").toString();
 | 
	
		
			
				|  |  |             Date startTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 00:00:00");
 | 
	
		
			
				|  |  |             Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 23:59:59");
 | 
	
		
			
				|  |  |             List<BasePatientHealthUploadDO> healthUploadDOS = basePatientHealthUploadDao.selectHealthUploadInfoByPatientIdAndStartAndEnd(id,startTime,endTime);
 | 
	
		
			
				|  |  |             if (healthUploadDOS!=null&&healthUploadDOS.size()!=0){
 | 
	
		
			
				|  |  |                 BasePatientHealthUploadDO healthUploadDO = healthUploadDOS.get(0);
 | 
	
		
			
				|  |  |                 String healthStateName = "";
 | 
	
		
			
				|  |  |                 if (healthUploadDO.getHealthCode()==2 ||healthUploadDO.getHealthCode()==3||Double.parseDouble(healthUploadDO.getTemperature())>=37.3
 | 
	
		
			
				|  |  |                         || healthUploadDO.getIsSymptoms()==1 || healthUploadDO.getIsEpidemic()==1) {
 | 
	
		
			
				|  |  |                     healthStateName = "异常";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     healthStateName = "正常";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 map.put("healthStateName",healthStateName);
 | 
	
		
			
				|  |  |                 map.put("healthUpload",healthUploadDO);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 map.put("healthUpload",null);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0 && StringUtils.isNotBlank(doctorCode)) {
 | 
	
		
			
				|  |  |             //排序
 | 
	
		
			
				|  |  |             for (int i = 0; i < list.size(); i++) {
 | 
	
		
			
				|  |  |                 String id = (String) list.get(i).get("id");
 | 
	
		
			
				|  |  |                 if (doctorCode.equals(id)) {
 | 
	
		
			
				|  |  |                     Collections.swap(list, 0, i);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页头部统计
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject selectIndexHeader(String dept, int level) {
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         String day = "0";
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |         Integer total = 0;//总人次
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             doctorSql +=" and d.id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> map = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |         String doctorTotal = "";
 | 
	
		
			
				|  |  |         if (map != null) {
 | 
	
		
			
				|  |  |             doctorTotal = map.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctorTotal)) {
 | 
	
		
			
				|  |  |             //总人次
 | 
	
		
			
				|  |  |             if (!day.equalsIgnoreCase("0")) {
 | 
	
		
			
				|  |  |                 total = Integer.parseInt(doctorTotal) * Integer.parseInt(day);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 total = Integer.parseInt(doctorTotal);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d ";
 | 
	
		
			
				|  |  |         String highSql = sql +" where d.is_high=1 ";
 | 
	
		
			
				|  |  |         String redSql = sql +" where d.health_code=2 ";
 | 
	
		
			
				|  |  |         String yellowSql = sql +" where d.health_code=3 ";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             highSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |             redSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |             yellowSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> highMap = jdbcTemplate.queryForMap(highSql);
 | 
	
		
			
				|  |  |         String highTotals = "";
 | 
	
		
			
				|  |  |         Integer highTotal = 0;//中高风险统计
 | 
	
		
			
				|  |  |         if (highMap != null) {
 | 
	
		
			
				|  |  |             highTotals = highMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(highTotals)) {
 | 
	
		
			
				|  |  |             //中高风险统计
 | 
	
		
			
				|  |  |             highTotal = Integer.parseInt(highTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> redMap = jdbcTemplate.queryForMap(redSql);
 | 
	
		
			
				|  |  |         String redTotals = "";
 | 
	
		
			
				|  |  |         Integer redTotal = 0;//红码统计
 | 
	
		
			
				|  |  |         if (redMap != null) {
 | 
	
		
			
				|  |  |             redTotals = redMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(redTotals)) {
 | 
	
		
			
				|  |  |             //红码统计
 | 
	
		
			
				|  |  |             redTotal = Integer.parseInt(redTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> yellowMap = jdbcTemplate.queryForMap(yellowSql);
 | 
	
		
			
				|  |  |         String yellowTotals = "";
 | 
	
		
			
				|  |  |         Integer yellowTotal = 0;//黄码统计
 | 
	
		
			
				|  |  |         if (yellowMap != null) {
 | 
	
		
			
				|  |  |             yellowTotals = yellowMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(yellowTotals)) {
 | 
	
		
			
				|  |  |             //黄码统计
 | 
	
		
			
				|  |  |             yellowTotal = Integer.parseInt(yellowTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         object.put("total", total);//总人次
 | 
	
		
			
				|  |  |         object.put("highTotal", highTotal);//中高风险统计
 | 
	
		
			
				|  |  |         object.put("redTotal", redTotal);//红码统计
 | 
	
		
			
				|  |  |         object.put("yellowTotal", yellowTotal);//黄码统计
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页出差科室统计
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> selectIndexScheduleDept(String dept, int level) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\thd.name as deptName,\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN dict_hospital_dept hd ON dh.dept_code = hd.code "+
 | 
	
		
			
				|  |  |                 "where d.schedule_status IN(2,3)  "+condition +
 | 
	
		
			
				|  |  |                 "GROUP BY dh.dept_code \n" +
 | 
	
		
			
				|  |  |                 "ORDER BY COUNT(DISTINCT d.doctor_id) DESC  ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页出差分布统计
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> selectIndexScheduleCityName(String dept, int level) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\td.city_name  as cityName,\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN dict_hospital_dept hd ON dh.dept_code = hd.code "+
 | 
	
		
			
				|  |  |                 "where  d.schedule_status IN(2,3)\n" +condition+
 | 
	
		
			
				|  |  |                 "GROUP BY d.city_name \n" +
 | 
	
		
			
				|  |  |                 "ORDER BY COUNT(DISTINCT d.doctor_id) DESC ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页本地分布统计
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> selectIndexScheduleTown(String dept, int level) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\td.town_name  as townName,\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 " LEFT JOIN dict_hospital_dept hd ON dh.dept_code = hd.code "+
 | 
	
		
			
				|  |  |                 "where  hd.name IS NOT NULL and d.schedule_status = 1 and d.town_name  !=''\n" + condition +
 | 
	
		
			
				|  |  |                 "GROUP BY d.town_name \n" +
 | 
	
		
			
				|  |  |                 "ORDER BY COUNT(DISTINCT d.doctor_id) DESC ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页异常实时情况
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> selectIndexYichangList(String dept, int level,String startDate,String endDate,String doctorName) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)){
 | 
	
		
			
				|  |  |             condition +=" and d.create_time >= '"+startDate+" 00:00:00'";
 | 
	
		
			
				|  |  |             condition +=" and d.create_time <= '"+endDate+" 23:59:59'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctorName)){
 | 
	
		
			
				|  |  |             condition +=" and d.doctor_name like '%"+doctorName+"%'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tdh.dept_name AS deptName,\n" +
 | 
	
		
			
				|  |  |                 "\td.doctor_name AS doctorName,\n" +
 | 
	
		
			
				|  |  |                 "\tbd.photo AS photo,\n" +
 | 
	
		
			
				|  |  |                 "\td.id AS id,\n" +
 | 
	
		
			
				|  |  |                 "\td.doctor_id AS doctorId,\n" +
 | 
	
		
			
				|  |  |                 "\td.schedule_status AS scheduleStatus,\n" +
 | 
	
		
			
				|  |  |                 "\td.province_name AS provinceName,\n" +
 | 
	
		
			
				|  |  |                 "\td.city_name AS cityName,\n" +
 | 
	
		
			
				|  |  |                 "\td.town_name AS townName,\n" +
 | 
	
		
			
				|  |  |                 "\td.tour_code AS tourCode,\n" +
 | 
	
		
			
				|  |  |                 "\td.health_code AS healthCode,\n" +
 | 
	
		
			
				|  |  |                 "\td.temperature AS temperature,\n" +
 | 
	
		
			
				|  |  |                 "\td.is_symptoms AS isSymptoms,\n" +
 | 
	
		
			
				|  |  |                 "\td.is_epidemic AS isEpidemic,\n" +
 | 
	
		
			
				|  |  |                 "\td.abnormal_symptoms AS abnormalSymptoms,\n" +
 | 
	
		
			
				|  |  |                 "\td.abnormal_symptoms_other AS abnormalSymptomsOther,\n" +
 | 
	
		
			
				|  |  |                 "\td.epidemic_person AS epidemicPerson,\n" +
 | 
	
		
			
				|  |  |                 "\tdate_format(\n" +
 | 
	
		
			
				|  |  |                 "\t\td.create_time,\n" +
 | 
	
		
			
				|  |  |                 "\t\t'%Y-%m-%d %H:%i:%S'\n" +
 | 
	
		
			
				|  |  |                 "\t) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor bd ON bd.id=dh.doctor_code "+
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\td.health_code IN (2, 3)\n" +
 | 
	
		
			
				|  |  |                 "\t\tOR CAST(d.temperature AS DECIMAL) >= 37.3\n" +
 | 
	
		
			
				|  |  |                 "\t\tOR d.is_symptoms = 1\n" +
 | 
	
		
			
				|  |  |                 "\t\tOR d.is_epidemic = 1\n" +
 | 
	
		
			
				|  |  |                 "\t)\n" +
 | 
	
		
			
				|  |  |                 "AND dh.dept_code IS NOT NULL\n" + condition+
 | 
	
		
			
				|  |  |                 "ORDER BY\n" +
 | 
	
		
			
				|  |  |                 "\td.create_time DESC ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页核酸检测情况
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject selectIndexNucleicTotal(String dept, int level) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //已做核酸
 | 
	
		
			
				|  |  |         String yizuohesuanSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) as total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" + condition+
 | 
	
		
			
				|  |  |                 "where d.is_nucleate !=1 and dh.dept_code is not null ";
 | 
	
		
			
				|  |  |         Map<String,Object> yizuoMap = jdbcTemplate.queryForMap(yizuohesuanSql);
 | 
	
		
			
				|  |  |         String yizuoTotals = "";
 | 
	
		
			
				|  |  |         Integer yizuoTotal = 0;//已做核酸统计
 | 
	
		
			
				|  |  |         if (yizuoMap != null) {
 | 
	
		
			
				|  |  |             yizuoTotals = yizuoMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(yizuoTotals)) {
 | 
	
		
			
				|  |  |             //已做核酸统计
 | 
	
		
			
				|  |  |             yizuoTotal = Integer.parseInt(yizuoTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //未做核酸
 | 
	
		
			
				|  |  |         String weizuohesuanSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) as total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +condition+
 | 
	
		
			
				|  |  |                 "where d.is_nucleate =1 and dh.dept_code is not null \n";
 | 
	
		
			
				|  |  |         Map<String,Object> weizuoMap = jdbcTemplate.queryForMap(weizuohesuanSql);
 | 
	
		
			
				|  |  |         String weizuoTotals = "";
 | 
	
		
			
				|  |  |         Integer weizuoTotal = 0;//未做核酸统计
 | 
	
		
			
				|  |  |         if (weizuoMap != null) {
 | 
	
		
			
				|  |  |             weizuoTotals = weizuoMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(weizuoTotals)) {
 | 
	
		
			
				|  |  |             //未做核酸统计
 | 
	
		
			
				|  |  |             weizuoTotal = Integer.parseInt(weizuoTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         object.put("weizuoTotal",weizuoTotal);//未做核酸统计
 | 
	
		
			
				|  |  |         object.put("yizuoTotal",yizuoTotal);//已做核酸统计
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页当日新增统计
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject selectIndexNewAdd(String dept, int level) {
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             condition +=" and dh.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String startDate = DateUtil.getStringDateShort()+" 00:00:00";
 | 
	
		
			
				|  |  |         String endDate = DateUtil.getStringDateShort()+" 23:59:59";
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\td3.*\n" +
 | 
	
		
			
				|  |  |                 "\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t(\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\t*, MAX(d1.create_time) AS createTime\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\tbase_doctor_health_upload d1\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t\t\td1.doctor_id\n" +
 | 
	
		
			
				|  |  |                 "\t\t\t) d2\n" +
 | 
	
		
			
				|  |  |                 "\t\tLEFT JOIN base_doctor_health_upload d3 ON d2.doctor_id = d3.doctor_id \n" +
 | 
	
		
			
				|  |  |                 "\t\tAND d2.createTime = d3.create_time\n" +
 | 
	
		
			
				|  |  |                 "\t) d "+
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n where 1=1 and dh.dept_code is not null  "+condition+" ";
 | 
	
		
			
				|  |  |         String highSql = sql +" AND d.is_high=1 and d.create_time >='"+startDate+"' and d.create_time <='"+endDate+"'";
 | 
	
		
			
				|  |  |         String redSql = sql +" AND d.health_code=2 and d.create_time >='"+startDate+"' and d.create_time <='"+endDate+"'";
 | 
	
		
			
				|  |  |         String yellowSql = sql +" AND d.health_code=3 and d.create_time >='"+startDate+"' and d.create_time <='"+endDate+"'";
 | 
	
		
			
				|  |  |         String greenSql = sql +" AND d.health_code=1 and d.create_time >='"+startDate+"' and d.create_time <='"+endDate+"'";
 | 
	
		
			
				|  |  |         Map<String, Object> highMap = jdbcTemplate.queryForMap(highSql);
 | 
	
		
			
				|  |  |         String highTotals = "";
 | 
	
		
			
				|  |  |         Integer highTotal = 0;//中高风险统计
 | 
	
		
			
				|  |  |         if (highMap != null) {
 | 
	
		
			
				|  |  |             highTotals = highMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(highTotals)) {
 | 
	
		
			
				|  |  |             //中高风险统计
 | 
	
		
			
				|  |  |             highTotal = Integer.parseInt(highTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> redMap = jdbcTemplate.queryForMap(redSql);
 | 
	
		
			
				|  |  |         String redTotals = "";
 | 
	
		
			
				|  |  |         Integer redTotal = 0;//红码统计
 | 
	
		
			
				|  |  |         if (redMap != null) {
 | 
	
		
			
				|  |  |             redTotals = redMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(redTotals)) {
 | 
	
		
			
				|  |  |             //红码统计
 | 
	
		
			
				|  |  |             redTotal = Integer.parseInt(redTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> yellowMap = jdbcTemplate.queryForMap(yellowSql);
 | 
	
		
			
				|  |  |         String yellowTotals = "";
 | 
	
		
			
				|  |  |         Integer yellowTotal = 0;//黄码统计
 | 
	
		
			
				|  |  |         if (yellowMap != null) {
 | 
	
		
			
				|  |  |             yellowTotals = yellowMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(yellowTotals)) {
 | 
	
		
			
				|  |  |             //黄码统计
 | 
	
		
			
				|  |  |             yellowTotal = Integer.parseInt(yellowTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> greenMap = jdbcTemplate.queryForMap(greenSql);
 | 
	
		
			
				|  |  |         String greenTotals = "";
 | 
	
		
			
				|  |  |         Integer greenTotal = 0;//中高风险统计
 | 
	
		
			
				|  |  |         if (greenMap != null) {
 | 
	
		
			
				|  |  |             greenTotals = greenMap.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(greenTotals)) {
 | 
	
		
			
				|  |  |             //中高风险统计
 | 
	
		
			
				|  |  |             greenTotal = Integer.parseInt(greenTotals);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         object.put("highTotal", highTotal);//中高风险统计
 | 
	
		
			
				|  |  |         object.put("redTotal", redTotal);//红码统计
 | 
	
		
			
				|  |  |         object.put("yellowTotal", yellowTotal);//黄码统计
 | 
	
		
			
				|  |  |         object.put("greenTotal", greenTotal);//绿码统计
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页上报分析
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param flag 1周2月
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject selectIndexTotalCircle(Integer flag,String dept, int level) {
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         String startDate="";
 | 
	
		
			
				|  |  |         String endDate="";
 | 
	
		
			
				|  |  |         if (flag==1){
 | 
	
		
			
				|  |  |             startDate = DateUtil.getMondayOfThisWeek();
 | 
	
		
			
				|  |  |             endDate = DateUtil.getSundayOfThisWeek();
 | 
	
		
			
				|  |  |         }else if (flag==2){
 | 
	
		
			
				|  |  |             startDate = DateUtil.getFristDayOfMonth();
 | 
	
		
			
				|  |  |             endDate = DateUtil.getLastDayOfMonth();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String day = DateUtil.getTwoDay(endDate, startDate);
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |         Integer total = 0;//总人次
 | 
	
		
			
				|  |  |         String sqlCondition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             sqlCondition =" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sql = "SELECT SUM(d1.total) as total from (select COUNT(DISTINCT d.doctor_id) as \"total\",date_format(d.create_time ,'%Y-%m-%d' ) from base_doctor_health_upload d where 1=1 "+sqlCondition+" and  d.create_time >='" + startDate + " 00:00:00' and d.create_time<='" + endDate + " 23:59:59' GROUP BY date_format(d.create_time ,'%Y-%m-%d' ))d1 ";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             doctorSql +=" and d.id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> map = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |         String doctorTotal = "";
 | 
	
		
			
				|  |  |         if (map != null) {
 | 
	
		
			
				|  |  |             doctorTotal = map.get("total").toString();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctorTotal)) {
 | 
	
		
			
				|  |  |             //总人次
 | 
	
		
			
				|  |  |             if (!day.equalsIgnoreCase("0")) {
 | 
	
		
			
				|  |  |                 total = Integer.parseInt(doctorTotal) * Integer.parseInt(day);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 total = Integer.parseInt(doctorTotal);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Integer yishangbaoTotal = 0;
 | 
	
		
			
				|  |  |         Integer weishangbaoTotal = 0;
 | 
	
		
			
				|  |  |         Integer zhengchangTotal = 0;
 | 
	
		
			
				|  |  |         Integer yichangTotal = 0;
 | 
	
		
			
				|  |  |         //已上传
 | 
	
		
			
				|  |  |         Map<String, Object> yishangchaungMap = jdbcTemplate.queryForMap(sql);
 | 
	
		
			
				|  |  |         if (yishangchaungMap != null) {
 | 
	
		
			
				|  |  |             if (yishangchaungMap.get("total") != null) {
 | 
	
		
			
				|  |  |                 yishangbaoTotal = Integer.parseInt(yishangchaungMap.get("total").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //未上报
 | 
	
		
			
				|  |  |         weishangbaoTotal = total - yishangbaoTotal;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //上传总次数
 | 
	
		
			
				|  |  |         Integer shangchuanTotal = 0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String shangchuanTotalSql = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1  ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {
 | 
	
		
			
				|  |  |             shangchuanTotalSql += " and d.create_time >='" + startDate + " 00:00:00' and d.create_time<='" + endDate + " 23:59:59' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             shangchuanTotalSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Object> shangchuanMap = jdbcTemplate.queryForMap(shangchuanTotalSql);
 | 
	
		
			
				|  |  |         if (shangchuanMap != null) {
 | 
	
		
			
				|  |  |             if (shangchuanMap.get("total") != null) {
 | 
	
		
			
				|  |  |                 shangchuanTotal = Integer.parseInt(shangchuanMap.get("total").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //正常、异常
 | 
	
		
			
				|  |  |         String sqlZhengchang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code not in(2,3) AND CAST(d.temperature as DECIMAL)<37.3 AND  d.is_symptoms=2 and  d.is_epidemic=2) ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {
 | 
	
		
			
				|  |  |             sqlZhengchang += " and d.create_time >='" + startDate + " 00:00:00' and d.create_time<='" + endDate + " 23:59:59' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             sqlZhengchang +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //正常
 | 
	
		
			
				|  |  |         Map<String, Object> zhengchangMap = jdbcTemplate.queryForMap(sqlZhengchang);
 | 
	
		
			
				|  |  |         if (zhengchangMap != null) {
 | 
	
		
			
				|  |  |             if (zhengchangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                 zhengchangTotal = Integer.parseInt(zhengchangMap.get("total").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sqlYichang = "select COUNT(1) as \"total\" from base_doctor_health_upload d where 1=1 and (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)  ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {
 | 
	
		
			
				|  |  |             sqlYichang += " and d.create_time >='" + startDate + " 00:00:00' and d.create_time<='" + endDate + " 23:59:59' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
		
			
				|  |  |             sqlYichang +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //正常
 | 
	
		
			
				|  |  |         Map<String, Object> yichangMap = jdbcTemplate.queryForMap(sqlYichang);
 | 
	
		
			
				|  |  |         if (yichangMap != null) {
 | 
	
		
			
				|  |  |             if (yichangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                 yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         object.put("total", total);//总人次
 | 
	
		
			
				|  |  |         object.put("yishangbaoTotal", yishangbaoTotal);//已上报
 | 
	
		
			
				|  |  |         object.put("weishangbaoTotal", weishangbaoTotal);//未上报
 | 
	
		
			
				|  |  |         object.put("zhengchangTotal", zhengchangTotal);//上报正常
 | 
	
		
			
				|  |  |         object.put("yichangTotal", yichangTotal);//上报异常
 | 
	
		
			
				|  |  |         object.put("shangchuanTotal", shangchuanTotal);//上传总次数
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页未报科室统计
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param level  1院级管理员,2科室管理员
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> selectIndexDeptList(String dept, int level) {
 | 
	
		
			
				|  |  |         String startDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |         String condition = "";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {
 | 
	
		
			
				|  |  |             condition = "  and d.create_time >='" + startDate + " 00:00:00' and d.create_time<='" + startDate + " 23:59:59'  ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String deptSql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tcode,\n" +
 | 
	
		
			
				|  |  |                 "\tname,\n" +
 | 
	
		
			
				|  |  |                 "\tdh1.total,\n" +
 | 
	
		
			
				|  |  |                 "\tdh2.total as yishangbaoTotal,\n" +
 | 
	
		
			
				|  |  |                 "\tdh3.total as shangchuanTotal,\n" +
 | 
	
		
			
				|  |  |                 "\tdh4.total as zhengchangTotal,\n" +
 | 
	
		
			
				|  |  |                 "\tdh5.total as yichangTotal,\n" +
 | 
	
		
			
				|  |  |                 "\tdh6.total as yichangPersonTotal\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tdict_hospital_dept hd\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(1) AS \"total\"\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id\n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\td.del = 1\n" +
 | 
	
		
			
				|  |  |                 "\tAND dh.del = 1\n" +
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ") dh1 ON hd. CODE = dh1.dept_code\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor_health_upload d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\t1 = 1\n" +
 | 
	
		
			
				|  |  |                 condition+
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ")dh2 ON dh2.dept_code=hd.code\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(1) AS total\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor_health_upload d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\t1 = 1\n" +
 | 
	
		
			
				|  |  |                 condition+
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ")dh3 ON dh3.dept_code=hd.code\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(1) AS total\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor_health_upload d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\t1 = 1\n" +
 | 
	
		
			
				|  |  |                 condition+
 | 
	
		
			
				|  |  |                 "\tand (d.health_code not in(2,3) AND CAST(d.temperature as DECIMAL)<37.3 AND  d.is_symptoms=2 and  d.is_epidemic=2)\n" +
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ")dh4 ON dh4.dept_code=hd.code\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(1) AS total\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor_health_upload d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\t1 = 1\n" +
 | 
	
		
			
				|  |  |                 condition+
 | 
	
		
			
				|  |  |                 "\tand (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)\n" +
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ")dh5 ON dh5.dept_code=hd.code\n" +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (\n" +
 | 
	
		
			
				|  |  |                 "\tSELECT\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code,\n" +
 | 
	
		
			
				|  |  |                 "\t\tCOUNT(DISTINCT d.doctor_id) AS total\n" +
 | 
	
		
			
				|  |  |                 "\tFROM\n" +
 | 
	
		
			
				|  |  |                 "\t\tbase_doctor_health_upload d\n" +
 | 
	
		
			
				|  |  |                 "\tLEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.doctor_id and dh.del=1 \n" +
 | 
	
		
			
				|  |  |                 "\tWHERE\n" +
 | 
	
		
			
				|  |  |                 "\t\t1 = 1\n" +
 | 
	
		
			
				|  |  |                 condition+
 | 
	
		
			
				|  |  |                 "\tand (d.health_code in(2,3) OR CAST(d.temperature as DECIMAL)>=37.3 OR  d.is_symptoms=1 OR d.is_epidemic=1)\n" +
 | 
	
		
			
				|  |  |                 "\tGROUP BY\n" +
 | 
	
		
			
				|  |  |                 "\t\tdh.dept_code\n" +
 | 
	
		
			
				|  |  |                 ")dh6 ON dh6.dept_code=hd.code\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\thd.consult_dept_flag = 1 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level==2) {
 | 
	
		
			
				|  |  |             deptSql += " and hd.code = '" + dept + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         deptSql +=" ORDER BY (IF(ISNULL(dh1.total),0,dh1.total)-IF(ISNULL(dh2.total),0,dh2.total)) DESC ";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = jdbcTemplate.queryForList(deptSql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> deptMap:mapList){
 | 
	
		
			
				|  |  |             String day = DateUtil.getTwoDay(startDate, startDate);
 | 
	
		
			
				|  |  |             Integer total = 0;
 | 
	
		
			
				|  |  |             Integer yishangbaoTotal = 0;
 | 
	
		
			
				|  |  |             Integer weishangbaoTotal = 0;
 | 
	
		
			
				|  |  |             Integer zhengchangTotal = 0;
 | 
	
		
			
				|  |  |             Integer yichangTotal = 0;
 | 
	
		
			
				|  |  |             Integer shangchuanTotal = 0;
 | 
	
		
			
				|  |  |             Integer yichangPersonTotal = 0;
 | 
	
		
			
				|  |  |             if (deptMap.get("total")!=null){
 | 
	
		
			
				|  |  |                 String doctorTotal = deptMap.get("total").toString();
 | 
	
		
			
				|  |  |                 //总人次
 | 
	
		
			
				|  |  |                 if (!day.equalsIgnoreCase("0")) {
 | 
	
		
			
				|  |  |                     total = Integer.parseInt(doctorTotal) * Integer.parseInt(day);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     total = Integer.parseInt(doctorTotal);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("yishangbaoTotal")!=null){
 | 
	
		
			
				|  |  |                 yishangbaoTotal = Integer.parseInt(deptMap.get("yishangbaoTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //未上报
 | 
	
		
			
				|  |  |             weishangbaoTotal = total - yishangbaoTotal;
 | 
	
		
			
				|  |  |             if (deptMap.get("zhengchangTotal")!=null){
 | 
	
		
			
				|  |  |                 zhengchangTotal = Integer.parseInt(deptMap.get("zhengchangTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("yichangTotal")!=null){
 | 
	
		
			
				|  |  |                 yichangTotal = Integer.parseInt(deptMap.get("yichangTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (deptMap.get("yichangPersonTotal")!=null){
 | 
	
		
			
				|  |  |                 yichangPersonTotal = Integer.parseInt(deptMap.get("yichangPersonTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("shangchuanTotal")!=null){
 | 
	
		
			
				|  |  |                 shangchuanTotal = Integer.parseInt(deptMap.get("shangchuanTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |             object.put("total", total);//总人次
 | 
	
		
			
				|  |  |             object.put("yishangbaoTotal", yishangbaoTotal);//已上报
 | 
	
		
			
				|  |  |             object.put("weishangbaoTotal", weishangbaoTotal);//未上报
 | 
	
		
			
				|  |  |             object.put("zhengchangTotal", zhengchangTotal);//上报正常
 | 
	
		
			
				|  |  |             object.put("yichangTotal", yichangTotal);//上报异常
 | 
	
		
			
				|  |  |             object.put("yichangPersonTotal", yichangPersonTotal);//上报人异常
 | 
	
		
			
				|  |  |             object.put("shangchuanTotal", shangchuanTotal);//上传总次数
 | 
	
		
			
				|  |  |             deptMap.put("tongyishuju", object);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |