|  | @ -4,12 +4,17 @@ import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.im.ConsultTeamDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.*;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.healthUpload.BaseDoctorHealthUploadDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseUserDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
 | 
	
	
		
			
				|  | @ -48,6 +53,8 @@ import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxPushLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxTemplateDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.enterprise.EnterpriseService;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseUserDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.WxAccessTokenService;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
	
		
			
				|  | @ -55,6 +62,7 @@ import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.net.URLEncoder;
 | 
	
	
		
			
				|  | @ -87,6 +95,16 @@ public class HealthUploadService {
 | 
	
		
			
				|  |  |     private BaseDoctorHealthUploadDao doctorHealthUploadDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WxPushLogDao wxPushLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WxEnterpriseUserDao wxEnterpriseUserDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private EnterpriseService enterpriseService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorRoleDao doctorRoleDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void waitingItem(){
 | 
	
		
			
				|  |  |         List<BaseDoctorDO> doctorDOList = doctorDao.findByDel();
 | 
	
	
		
			
				|  | @ -119,5 +137,242 @@ public class HealthUploadService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 健康上报填写提醒
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void healthUploadRemind() throws Exception {
 | 
	
		
			
				|  |  |         List<BaseDoctorDO> doctorDOList = doctorDao.findByDel();
 | 
	
		
			
				|  |  |         Date startDate = DateUtil.strToDate(DateUtil.getStringDateShort()+" 00:00:00");
 | 
	
		
			
				|  |  |         Date endDate = DateUtil.strToDate(DateUtil.getStringDateShort()+" 23:59:59");
 | 
	
		
			
				|  |  |         for (BaseDoctorDO doctorDO:doctorDOList){
 | 
	
		
			
				|  |  |             List<BaseDoctorHealthUploadDO> healthUploadDOS = doctorHealthUploadDao.selectHealthUploadInfoByDoctorIdAndStartAndEnd(doctorDO.getId(),startDate,endDate);
 | 
	
		
			
				|  |  |             if (healthUploadDOS==null||healthUploadDOS.size()==0){
 | 
	
		
			
				|  |  |                 WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,doctorDO.getMobile());
 | 
	
		
			
				|  |  |                 if(enterpriseUserDO==null){
 | 
	
		
			
				|  |  |                     logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     String title = "待办事项";
 | 
	
		
			
				|  |  |                     String des = "您好,系统检测到您今日尚未提交健康信息,请及时提交!";
 | 
	
		
			
				|  |  |                     String url = "https://ehr.yihu.com/hlwyy/zjxl/healthMonitoring/#/health/commit";
 | 
	
		
			
				|  |  |                     String res = enterpriseService.sendTWMesByDoctor(wechatId,doctorDO.getId(),title,des,url);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void healthUploadWsbTotalRemind() throws Exception {
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> adminRoleList = doctorRoleDao.findByRoleCode("admin");
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> deptAdminRoleList = doctorRoleDao.findByRoleCode("deptAdmin");
 | 
	
		
			
				|  |  |         //管理员
 | 
	
		
			
				|  |  |         for (BaseDoctorRoleDO adminRole:adminRoleList){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctorDO = doctorDao.findById(adminRole.getDoctorCode());
 | 
	
		
			
				|  |  |             WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,doctorDO.getMobile());
 | 
	
		
			
				|  |  |             if(enterpriseUserDO==null){
 | 
	
		
			
				|  |  |                 logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //总人数
 | 
	
		
			
				|  |  |                 Integer doctorTotal=0;
 | 
	
		
			
				|  |  |                 String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |                 Map<String, Object> doctorMap = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |                 if (doctorMap != null) {
 | 
	
		
			
				|  |  |                     if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (doctorMap != null) {
 | 
	
		
			
				|  |  |                     if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String nowDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |                 //已上报人数
 | 
	
		
			
				|  |  |                 Integer sqlTotal = 0;
 | 
	
		
			
				|  |  |                 String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' ";
 | 
	
		
			
				|  |  |                 Map<String, Object> sqlMap = jdbcTemplate.queryForMap(sql);
 | 
	
		
			
				|  |  |                 if (sqlMap != null) {
 | 
	
		
			
				|  |  |                     if (sqlMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         sqlTotal = Integer.parseInt(sqlMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //异常人数
 | 
	
		
			
				|  |  |                 //今日异常人次
 | 
	
		
			
				|  |  |                 String yichangSql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' 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)";
 | 
	
		
			
				|  |  |                 Integer yichangTotal=0;
 | 
	
		
			
				|  |  |                 Map<String, Object> yichangMap = jdbcTemplate.queryForMap(yichangSql);
 | 
	
		
			
				|  |  |                 if (yichangMap != null) {
 | 
	
		
			
				|  |  |                     if (yichangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 Integer weishangbaoTotal = doctorTotal-sqlTotal;
 | 
	
		
			
				|  |  |                 String title = "健康上报未上报汇总";
 | 
	
		
			
				|  |  |                 String des = "今日还有"+weishangbaoTotal+"人未提交健康信息,点击查看。";
 | 
	
		
			
				|  |  |                 String url = "https://ehr.yihu.com/hlwyy/zjxl/healthMonitoring/#/home/index";
 | 
	
		
			
				|  |  |                 String res = enterpriseService.sendTWMesByDoctor(wechatId,doctorDO.getId(),title,des,url);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //科室管理员
 | 
	
		
			
				|  |  |         for (BaseDoctorRoleDO deptRole:deptAdminRoleList){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctorDO = doctorDao.findById(deptRole.getDoctorCode());
 | 
	
		
			
				|  |  |             WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,doctorDO.getMobile());
 | 
	
		
			
				|  |  |             if(enterpriseUserDO==null){
 | 
	
		
			
				|  |  |                 logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(deptRole.getDoctorCode());
 | 
	
		
			
				|  |  |                 if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
 | 
	
		
			
				|  |  |                     String dept = doctorHospitalDOS.get(0).getDeptCode();
 | 
	
		
			
				|  |  |                     //总人数
 | 
	
		
			
				|  |  |                     Integer doctorTotal=0;
 | 
	
		
			
				|  |  |                     String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 and id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
 | 
	
		
			
				|  |  |                     Map<String, Object> doctorMap = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |                     if (doctorMap != null) {
 | 
	
		
			
				|  |  |                         if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (doctorMap != null) {
 | 
	
		
			
				|  |  |                         if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     String nowDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |                     //已上报人数
 | 
	
		
			
				|  |  |                     Integer sqlTotal = 0;
 | 
	
		
			
				|  |  |                     String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59'";
 | 
	
		
			
				|  |  |                     Map<String, Object> sqlMap = jdbcTemplate.queryForMap(sql);
 | 
	
		
			
				|  |  |                     if (sqlMap != null) {
 | 
	
		
			
				|  |  |                         if (sqlMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             sqlTotal = Integer.parseInt(sqlMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //异常人数
 | 
	
		
			
				|  |  |                     //今日异常人次
 | 
	
		
			
				|  |  |                     String yichangSql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' 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)";
 | 
	
		
			
				|  |  |                     Integer yichangTotal=0;
 | 
	
		
			
				|  |  |                     Map<String, Object> yichangMap = jdbcTemplate.queryForMap(yichangSql);
 | 
	
		
			
				|  |  |                     if (yichangMap != null) {
 | 
	
		
			
				|  |  |                         if (yichangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     Integer weishangbaoTotal = doctorTotal-sqlTotal;
 | 
	
		
			
				|  |  |                     String title = "健康上报未上报汇总";
 | 
	
		
			
				|  |  |                     String des = "今日还有"+weishangbaoTotal+"人未提交健康信息,点击查看。";
 | 
	
		
			
				|  |  |                     String url = "https://ehr.yihu.com/hlwyy/zjxl/healthMonitoring/#/home/index";
 | 
	
		
			
				|  |  |                     String res = enterpriseService.sendTWMesByDoctor(wechatId,doctorDO.getId(),title,des,url);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void healthUploadTotalRemind() throws Exception {
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> adminRoleList = doctorRoleDao.findByRoleCode("admin");
 | 
	
		
			
				|  |  |         List<BaseDoctorRoleDO> deptAdminRoleList = doctorRoleDao.findByRoleCode("deptAdmin");
 | 
	
		
			
				|  |  |         //管理员
 | 
	
		
			
				|  |  |         for (BaseDoctorRoleDO adminRole:adminRoleList){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctorDO = doctorDao.findById(adminRole.getDoctorCode());
 | 
	
		
			
				|  |  |             WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,doctorDO.getMobile());
 | 
	
		
			
				|  |  |             if(enterpriseUserDO==null){
 | 
	
		
			
				|  |  |                 logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //总人数
 | 
	
		
			
				|  |  |                 Integer doctorTotal=0;
 | 
	
		
			
				|  |  |                 String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |                 Map<String, Object> doctorMap = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |                 if (doctorMap != null) {
 | 
	
		
			
				|  |  |                     if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (doctorMap != null) {
 | 
	
		
			
				|  |  |                     if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String nowDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |                 //已上报人数
 | 
	
		
			
				|  |  |                 Integer sqlTotal = 0;
 | 
	
		
			
				|  |  |                 String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' ";
 | 
	
		
			
				|  |  |                 Map<String, Object> sqlMap = jdbcTemplate.queryForMap(sql);
 | 
	
		
			
				|  |  |                 if (sqlMap != null) {
 | 
	
		
			
				|  |  |                     if (sqlMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         sqlTotal = Integer.parseInt(sqlMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //异常人数
 | 
	
		
			
				|  |  |                 //今日异常人次
 | 
	
		
			
				|  |  |                 String yichangSql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' 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)";
 | 
	
		
			
				|  |  |                 Integer yichangTotal=0;
 | 
	
		
			
				|  |  |                 Map<String, Object> yichangMap = jdbcTemplate.queryForMap(yichangSql);
 | 
	
		
			
				|  |  |                 if (yichangMap != null) {
 | 
	
		
			
				|  |  |                     if (yichangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                         yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 Integer weishangbaoTotal = doctorTotal-sqlTotal;
 | 
	
		
			
				|  |  |                 String title = "每日健康上报汇总";
 | 
	
		
			
				|  |  |                 String des = "今日上报情况:已上报:"+sqlTotal+",未上报:"+weishangbaoTotal+",异常:"+yichangTotal+";点击查看。";
 | 
	
		
			
				|  |  |                 String url = "https://ehr.yihu.com/hlwyy/zjxl/healthMonitoring/#/home/index";
 | 
	
		
			
				|  |  |                 String res = enterpriseService.sendTWMesByDoctor(wechatId,doctorDO.getId(),title,des,url);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //科室管理员
 | 
	
		
			
				|  |  |         for (BaseDoctorRoleDO deptRole:deptAdminRoleList){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctorDO = doctorDao.findById(deptRole.getDoctorCode());
 | 
	
		
			
				|  |  |             WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,doctorDO.getMobile());
 | 
	
		
			
				|  |  |             if(enterpriseUserDO==null){
 | 
	
		
			
				|  |  |                 logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(deptRole.getDoctorCode());
 | 
	
		
			
				|  |  |                 if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
 | 
	
		
			
				|  |  |                     String dept = doctorHospitalDOS.get(0).getDeptCode();
 | 
	
		
			
				|  |  |                     //总人数
 | 
	
		
			
				|  |  |                     Integer doctorTotal=0;
 | 
	
		
			
				|  |  |                     String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 and id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
 | 
	
		
			
				|  |  |                     Map<String, Object> doctorMap = jdbcTemplate.queryForMap(doctorSql);
 | 
	
		
			
				|  |  |                     if (doctorMap != null) {
 | 
	
		
			
				|  |  |                         if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (doctorMap != null) {
 | 
	
		
			
				|  |  |                         if (doctorMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             doctorTotal = Integer.parseInt(doctorMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     String nowDate = DateUtil.getStringDateShort();
 | 
	
		
			
				|  |  |                     //已上报人数
 | 
	
		
			
				|  |  |                     Integer sqlTotal = 0;
 | 
	
		
			
				|  |  |                     String sql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59'";
 | 
	
		
			
				|  |  |                     Map<String, Object> sqlMap = jdbcTemplate.queryForMap(sql);
 | 
	
		
			
				|  |  |                     if (sqlMap != null) {
 | 
	
		
			
				|  |  |                         if (sqlMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             sqlTotal = Integer.parseInt(sqlMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //异常人数
 | 
	
		
			
				|  |  |                     //今日异常人次
 | 
	
		
			
				|  |  |                     String yichangSql = "select COUNT(DISTINCT d.doctor_id) as \"total\" from base_doctor_health_upload d where 1=1 and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) and d.create_time >='" + nowDate + " 00:00:00' and d.create_time<='" + nowDate + " 23:59:59' 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)";
 | 
	
		
			
				|  |  |                     Integer yichangTotal=0;
 | 
	
		
			
				|  |  |                     Map<String, Object> yichangMap = jdbcTemplate.queryForMap(yichangSql);
 | 
	
		
			
				|  |  |                     if (yichangMap != null) {
 | 
	
		
			
				|  |  |                         if (yichangMap.get("total") != null) {
 | 
	
		
			
				|  |  |                             yichangTotal = Integer.parseInt(yichangMap.get("total").toString());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     Integer weishangbaoTotal = doctorTotal-sqlTotal;
 | 
	
		
			
				|  |  |                     String title = "每日健康上报汇总";
 | 
	
		
			
				|  |  |                     String des = "今日上报情况:已上报:"+sqlTotal+",未上报:"+weishangbaoTotal+",异常:"+yichangTotal+";点击查看。";
 | 
	
		
			
				|  |  |                     String url = "https://ehr.yihu.com/hlwyy/zjxl/healthMonitoring/#/home/index";
 | 
	
		
			
				|  |  |                     String res = enterpriseService.sendTWMesByDoctor(wechatId,doctorDO.getId(),title,des,url);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |