| 
					
				 | 
			
			
				@ -7,12 +7,12 @@ import com.alibaba.fastjson.serializer.SerializerFeature; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.pushLog.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.MessageUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.service.BaseCopywritingService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.log.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -60,6 +60,8 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ZhaohuiDailyEmeDao zhaohuiDailyEmeDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ZhaohuifireGasSecDao zhaohuifireGasSecDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseCopywritingService dictService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void allRound() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -74,7 +76,7 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                          //  AND id = '808080eb78d3ce030178edeb4346002b' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //获取所有老人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private List<BasePatientDO> olds() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT * FROM base_patient WHERE archive_type =1 AND sign_status =1  AND del = 1 NOT IN (SELECT dict_code FROM wlyy_hospital_sys_dict WHERE `dict_name` = 'jkzl_older')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT * FROM base_patient WHERE archive_type =1 AND sign_status =1  AND del = 1 and id NOT IN (SELECT dict_code FROM wlyy_hospital_sys_dict WHERE `dict_name` = 'jkzl_older')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BasePatientDO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return query; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -91,10 +93,6 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String messageDict(String dictCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select * from base_yujing_dict where dict_name = 'zhaohui' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -110,12 +108,15 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhaohuiDailyEmeEntity> zhaohuiDailyEmeList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhaohuifireGasSecEntity> zhaohuifireGasSecEntityList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String message = dictService.findCopywriting("zhaohui_dailyReport", "family_zhaohui_daily1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String oldId = old.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String date = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String stateDate = date + " 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endDate = date + " 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer deviceTotal = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sex = old.getSex()==1?"爷爷":"奶奶"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -125,39 +126,41 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setPhoto(old.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setFamilyCode(familyCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setUserType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String orgCodeSql = "SELECT d.org_code as orgCode FROM base_patient p INNER JOIN base_service_package_sign_record r ON p.id = r.patient INNER JOIN base_doctor_hospital d ON r.sign_doctor = d.doctor_code WHERE d.del =1 and = p.id = '"+oldId+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String orgCodeSql = "SELECT t.id as orgId FROM base_service_package_sign_record r INNER JOIN base_team t ON r.sign_doctor= t.leader_code WHERE r.patient = '"+oldId+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> orgCodeList = jdbcTemplate.queryForList(orgCodeSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (orgCodeList.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhaohuiDailyEntity.setOrgCode(orgCodeList.get(0).get("orgCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            zhaohuiDailyEntity.setOrgCode(orgCodeList.get(0).get("orgId").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String message = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String emeSql = "select count(id) from base_emergency_assistance_order where patient='"+oldId+"'  and create_time>='"+stateDate+"' and create_time<='"+endDate+"' and status <> -1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer emeTotal = jdbcTemplate.queryForObject(emeSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (emeTotal>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*if (emeTotal>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            message += old.getName()+sex+"今日发起"+emeTotal+"次紧急呼叫"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String secSql ="select count(id) total,serve_desc from  base_security_monitoring_order where patient= '"+oldId+"' and create_time>='"+stateDate+"' and create_time<='"+endDate+"' and status <> -1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(secSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list.size()>0&&0>Integer.parseInt(list.get(0).get("total").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*if (list.size()>0&&0>Integer.parseInt(list.get(0).get("total").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(message)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message += "\n 监护到"+old.getName()+sex+"今日存在安全预警:【"+list.get(0).get("serve_desc")+"】"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message = "监护到"+old.getName()+sex+"今日存在安全预警:【"+list.get(0).get("serve_desc")+"】"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setEmeNum(emeTotal+(list.size()>0?Integer.parseInt(list.get(0).get("total").toString()):0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isBlank(message)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*if (StringUtils.isBlank(message)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            message = old.getName()+sex+"今日状态正常,未发生异常情况,今日家中设备工作正常"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setMessage(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setMessage(old.getName()+sex+","+message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String lifeSql = "select count(id) from base_life_care_order where patient = '" + oldId + "' and status = 1 and create_time>= '" + stateDate + "' and create_time<= '" + endDate + "' and status <> -1"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -194,7 +197,7 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity = zhaohuiDailyDao.save(zhaohuiDailyEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT pd.device_sn,pd.category_code FROM base.wlyy_patient_device pd  where pd.del=0 AND  category_code in ('7','12','4','13') AND user = '" + oldId + "'  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT pd.device_sn,pd.category_code FROM base.wlyy_patient_device pd  where pd.del=0 AND  category_code in ('7','12','4','13','14','15') AND user = '" + oldId + "'  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> oldDeviceList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String zhaohuiID = zhaohuiDailyEntity.getId().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -225,11 +228,15 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //在线状态实时获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!aqgDeviceInfo2.getBoolean("online")) {//设备在线状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailyEmeEntity.setOnline(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceTotal+=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceName +=",居家报警器离线"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailyEmeEntity.setOnline(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        zhaohuiDailyEmeEntity.setOnline(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        deviceTotal +=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        deviceName +=",居家报警器离线"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEmeList.add(zhaohuiDailyEmeEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    break; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -253,6 +260,8 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //在线状态实时获取 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!response.getBoolean("online")) {//设备在线状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceTotal+=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceName+=",手表离线"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailyWatchEntity.setOnline(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailyWatchEntity.setOnline(1); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -332,6 +341,8 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        response = objs.getJSONObject(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!response.getBoolean("online")) {//设备在线状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailySleep.setStatus("0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceTotal+=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            deviceName+=",睡眠带离线"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            zhaohuiDailySleep.setStatus("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -420,7 +431,30 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        wxPush(old.getName(),familyCode, zhaohuiDailyEntity.getService(), emeTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String secMessage = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceMessage = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断是否存在预警 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        secSql = "select serve_desc,status total,serve_desc from  base_security_monitoring_order where patient= '" + oldId + "' and create_time>='" + stateDate + "' and create_time<='" + endDate + "' and status <> -1 order by create_time DESC  "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        list = jdbcTemplate.queryForList(secSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            secMessage = dictService.findCopywriting("zhaohui_dailyReport", "family_eme1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            secMessage = secMessage.replace("<serve>",list.get(0).get("serve_desc").toString()).replace("<status>",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            secMessage = dictService.findCopywriting("zhaohui_dailyReport", "family_eme2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (deviceTotal>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceMessage = dictService.findCopywriting("zhaohui_dailyReport", "family_device1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceMessage.replace("<deviceName>",deviceName.replace(",","")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deviceMessage = dictService.findCopywriting("zhaohui_dailyReport", "family_device2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyEntity.setMessage(old.getName()+sex+secMessage+deviceMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyDao.save(zhaohuiDailyEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -433,6 +467,7 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        messageUtil.putTemplateWxMessage(wxId,"template_zhrb","zhrb","123456",first,null,null,1,null,"",key2+"",liftOlderTotal+"","【推送完成】",DateUtil.getStringDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        wxPush(old.getName(),familyCode, zhaohuiDailyEntity.getService(), emeTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailySleepDao.save(zhaohuiDailySleepList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyWatchDao.save(zhaohuiDailyWatchList); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -451,7 +486,7 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String content = "紧急预警:" + eme + "\r\n生活照料:" + lift + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String url = "https://zhyzh.gongshu.gov.cn/medical-care-patient/message/daily"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //o_DJs59V7MKJ5ea-YW__LoccEn50 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageUtil.putTemplateWxMessage(wxId, "template_system_family", "jsxtxx", "o_DJs59V7MKJ5ea-YW__LoccEn50", first, url, null, 1, null, content, "【推送完成】", com.yihu.jw.util.date.DateUtil.getStringDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageUtil.putTemplateWxMessage(wxId, "template_system_family", "jsxtxx", list.get(0).get("openid").toString(), first, url, null, 1, null, content, "【推送完成】", com.yihu.jw.util.date.DateUtil.getStringDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -468,6 +503,123 @@ public class ZhaohuiDailyService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void doctorDaily(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorSql ="select id from base_team where org_code = 'zdjsylfwyxgszhfgs' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String date = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String stateDate = date + " 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endDate = date + " 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> orgList = jdbcTemplate.queryForList(doctorSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhaohuiDailyEntity> zhaohuiDailyEntityList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (Map<String, Object> map : orgList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ZhaohuiDailyEntity zhaohuiDailyEntity = new ZhaohuiDailyEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String dailySql = "SELECT count(d.id) as total ,GROUP_CONCAT(patient_name) as patientName,sum(eme_num) as  emeNum,SUM(service) as serviceNum FROM base_zhaohui_daily d INNER JOIN base_team t ON d.org_code = t.id where d.org_code = '"+map.get("id")+"' and d.user_type = 1  and d.create_time >= '"+stateDate+"' and d.create_time<= '"+endDate+"' GROUP BY d.org_code "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> list = jdbcTemplate.queryForList(dailySql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (list.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String message = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Integer emeNum = Integer.parseInt(list.get(0).get("emeNum").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String oldNUm = list.get(0).get("total").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Boolean flag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (0<emeNum){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String oldNumMessage = dictService.findCopywriting("zhaohui_dailyReport", "doctor_oldnum"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message +=oldNumMessage.replace("<num>",oldNUm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message += ","+dictService.findCopywriting("zhaohui_dailyReport", "doctor_emeNum").replace("<num>",emeNum.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    flag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    message = dictService.findCopywriting("zhaohui_dailyReport", "doctor_zhaohui_daily1").replace("<num>",oldNUm); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String doctorInfoSql ="SELECT d.id,d.`name`,d.photo FROM base_team t INNER JOIN base_doctor d ON t.leader_code = d.id  WHERE t.id = '"+map.get("id")+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Map<String, Object>> doctorInfoList = jdbcTemplate.queryForList(doctorInfoSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setUserType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setEmeNum(Integer.parseInt(list.get(0).get("emeNum").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setService(Integer.parseInt(list.get(0).get("serviceNum").toString())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setPatient(doctorInfoList.get(0).get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setPatientName(doctorInfoList.get(0).get("name").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setFamilyCode(list.get(0).get("patientName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setOrgCode(map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setPhoto(doctorInfoList.get(0).get("photo").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setServiceTime(stateDate+","+endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (flag) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String emeSecstatusSql = "SELECT count(a.total) total, a.`status` FROM (\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "SELECT count(o.id) total ,o.`status` AS `status` FROM base_team t INNER JOIN base_service_package_sign_record r ON t.leader_code = r.sign_doctor INNER JOIN base_emergency_assistance_order o ON o.patient = r.patient WHERE t.id = '" + map.get("id") + "' and o.status <> -1 AND o.create_time >='" + stateDate + "' AND o.create_time<='" + endDate + "' GROUP BY o.`status`\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "UNION ALL\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            "SELECT count(o.id) total ,o.`status` AS `status` FROM base_team t INNER JOIN base_service_package_sign_record r ON t.leader_code = r.sign_doctor INNER JOIN base_security_monitoring_order o ON o.patient = r.patient WHERE t.id = '" + map.get("id") + "' and o.status <> -1 AND o.create_time >='" + stateDate + "' AND o.create_time<='" + endDate + "'  GROUP BY o.`status`\n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            ") a  GROUP BY a.`status`"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<Map<String, Object>> emeSecStatusList = jdbcTemplate.queryForList(emeSecstatusSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer statusNUm = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (emeSecStatusList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        for (Map<String, Object> stringObjectMap : emeSecStatusList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            Integer.parseInt(stringObjectMap.get("status").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (0 == Integer.parseInt(stringObjectMap.get("status").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                statusNUm = Integer.parseInt(stringObjectMap.get("total").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (statusNUm == emeNum||statusNUm<emeNum) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message += ","+dictService.findCopywriting("zhaohui_dailyReport", "doctor_emeStatus2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        message += ","+dictService.findCopywriting("zhaohui_dailyReport", "doctor_emeStatus1").replace("<num>",(emeNum-statusNUm)+""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntity.setMessage(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                zhaohuiDailyEntityList.add(zhaohuiDailyEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyDao.save(zhaohuiDailyEntityList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void child(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select * from base_patient where archive_type = 2 and id not in (SELECT dict_code FROM wlyy_hospital_sys_dict WHERE `dict_name` = 'jkzl_child')"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BasePatientDO> childEntityList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<ZhaohuiDailyEntity> zhaohuiDailyEntityList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (BasePatientDO child : childEntityList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = "select p.id from base_patient_family_member m inner join base_patient p on m.family_member = p.id where m.patient = '"+child.getId()+"' and p.del = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> familyList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (familyList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> map : familyList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    ZhaohuiDailyEntity zhaohuiDailyEntity = new ZhaohuiDailyEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setPhoto(child.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setPatientName(child.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setPatient(child.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setUserType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //上门辅导 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String upDoorSql = "select count(id) from base_door_coach_order where patient = '" + child.getId() + "' and status<> -1 and create_time >= '' and create_time >= '' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Integer num = jdbcTemplate.queryForObject(upDoorSql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setService(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String activitySql = "select count(id) from base_child_activity_registration where patient = '" + child.getId() + "' and create_time >= '' and create_time >= '' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    num = jdbcTemplate.queryForObject(activitySql, Integer.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setEmeNum(num); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntity.setFamilyCode(map.get("id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    zhaohuiDailyEntityList.add(zhaohuiDailyEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (ZhaohuiDailyEntity zhaohuiDailyEntity : zhaohuiDailyEntityList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sql = "select openid from base_patient where id = '" + zhaohuiDailyEntity.getFamilyCode() + "' and openid is not null "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Map<String, Object>> openidList = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (openidList.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                openidList.get(0).get("openid"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String first = "您好,您的亲属【" + zhaohuiDailyEntity.getPatientName() + "】今日照护日报已生成"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String content = "上门辅导:" + zhaohuiDailyEntity.getService() + "\r\n在线教育:" + zhaohuiDailyEntity.getEmeNum() + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String url = "https://zhyzh.gongshu.gov.cn/medical-care-patient/message/daily?type=2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //o_DJs59V7MKJ5ea-YW__LoccEn50 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messageUtil.putTemplateWxMessage(wxId, "template_system_family", "jsxtxx", "o_DJs59V7MKJ5ea-YW__LoccEn50", first, url, null, 1, null, content, "【推送完成】", com.yihu.jw.util.date.DateUtil.getStringDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        zhaohuiDailyDao.save(zhaohuiDailyEntityList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static void main(String[] args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String abc = "[\"12:30-14:09\",\"22:00-04:06\",\"05:09-05:24\"]"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String[] split = abc.split(","); 
			 |