|
@ -1,15 +1,18 @@
|
|
|
package com.yihu.jw.care.service.message;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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;
|
|
@ -55,6 +58,10 @@ public class ZhaohuiDailyService {
|
|
|
private ZhaohuiDailySleepDao zhaohuiDailySleepDao;
|
|
|
@Autowired
|
|
|
private ZhaohuiDailyEmeDao zhaohuiDailyEmeDao;
|
|
|
@Autowired
|
|
|
private ZhaohuifireGasSecDao zhaohuifireGasSecDao;
|
|
|
@Autowired
|
|
|
private BaseCopywritingService dictService;
|
|
|
|
|
|
|
|
|
public void allRound() {
|
|
@ -69,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;
|
|
|
}
|
|
@ -87,6 +94,8 @@ public class ZhaohuiDailyService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private PadUseTimeDao padUseTimeDao;
|
|
|
|
|
@ -97,13 +106,17 @@ public class ZhaohuiDailyService {
|
|
|
List<ZhaohuiDailySleepEntity> zhaohuiDailySleepList = new ArrayList<>();
|
|
|
List<ZhaohuiDailyVideoEntity> zhaohuiDailyVideoList = new ArrayList<>();
|
|
|
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?"爷爷":"奶奶";
|
|
|
|
|
@ -113,36 +126,44 @@ public class ZhaohuiDailyService {
|
|
|
zhaohuiDailyEntity.setPhoto(old.getPhoto());
|
|
|
zhaohuiDailyEntity.setCreateTime(new Date());
|
|
|
zhaohuiDailyEntity.setFamilyCode(familyCode);
|
|
|
zhaohuiDailyEntity.setUserType(1);
|
|
|
|
|
|
String message = "";
|
|
|
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("orgId").toString());
|
|
|
}
|
|
|
|
|
|
|
|
|
String emeSql = "select count(id) from base_emergency_assistance_order where patient='"+oldId+"' and create_time>='"+stateDate+"' and create_time<='"+endDate+"'";
|
|
|
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+"' ";
|
|
|
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)) {
|
|
|
message = old.getName()+sex+"今日状态正常,未发生异常情况";
|
|
|
}
|
|
|
/*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 + "'";
|
|
|
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";
|
|
|
String lifeInfoSql = "select d.name,d.create_time create_time from base_life_care_order o INNER JOIN base_life_care_fee_detail d ON o.id=d.order_id where o.patient = '" + oldId + "' and o.status = 1 and o.create_time>= '" + stateDate + "' and o.create_time<= '" + endDate + "' order by o.create_time DESC limit 1";
|
|
|
List<Map<String, Object>> lifeList = jdbcTemplate.queryForList(lifeInfoSql);
|
|
|
Integer lifeTotal = jdbcTemplate.queryForObject(lifeSql, Integer.class);
|
|
@ -176,9 +197,9 @@ 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();
|
|
|
|
|
|
for (Map<String, Object> device : oldDeviceList) {
|
|
|
String deviceSn = device.get("device_sn").toString();
|
|
@ -187,7 +208,7 @@ public class ZhaohuiDailyService {
|
|
|
case 7: //居家报警器
|
|
|
|
|
|
ZhaohuiDailyEmeEntity zhaohuiDailyEmeEntity = new ZhaohuiDailyEmeEntity();
|
|
|
zhaohuiDailyEmeEntity.setDailyId(zhaohuiDailyEntity.getId().toString());
|
|
|
zhaohuiDailyEmeEntity.setDailyId(zhaohuiID);
|
|
|
|
|
|
sql = " select o.id,o.create_time from base_emergency_assistance_order o " +
|
|
|
" INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 and o.create_time >= '"+stateDate+"' and o.create_time <= '"+endDate+"' ORDER BY create_time desc limit 1 ";
|
|
@ -207,18 +228,22 @@ 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;
|
|
|
case 4: //智能手表
|
|
|
|
|
|
ZhaohuiDailyWatchEntity zhaohuiDailyWatchEntity = new ZhaohuiDailyWatchEntity();
|
|
|
zhaohuiDailyWatchEntity.setDailyId(zhaohuiDailyEntity.getId().toString());
|
|
|
zhaohuiDailyWatchEntity.setDailyId(zhaohuiID);
|
|
|
JSONObject response = patientDeviceService.getAqgDeviceInfo2(deviceSn);
|
|
|
|
|
|
if (null != response) {
|
|
@ -235,6 +260,8 @@ public class ZhaohuiDailyService {
|
|
|
}
|
|
|
//在线状态实时获取
|
|
|
if (!response.getBoolean("online")) {//设备在线状态
|
|
|
deviceTotal+=1;
|
|
|
deviceName+=",手表离线";
|
|
|
zhaohuiDailyWatchEntity.setOnline(0);
|
|
|
} else {
|
|
|
zhaohuiDailyWatchEntity.setOnline(1);
|
|
@ -277,6 +304,11 @@ public class ZhaohuiDailyService {
|
|
|
zhaohuiDailyWatchEntity.setServeDesc("无");
|
|
|
}
|
|
|
|
|
|
JSONArray x1Locations = getX1Locations(oldId, stateDate);
|
|
|
if (null!=x1Locations&&x1Locations.size()>0) {
|
|
|
zhaohuiDailyWatchEntity.setLocations(x1Locations.toJSONString());
|
|
|
}
|
|
|
|
|
|
zhaohuiDailyWatchList.add(zhaohuiDailyWatchEntity);
|
|
|
break;
|
|
|
case 12: //防跌倒视频监测
|
|
@ -296,19 +328,21 @@ public class ZhaohuiDailyService {
|
|
|
}
|
|
|
|
|
|
zhaohuiDailyVideoEntity.setDeviceSn(deviceSn);
|
|
|
zhaohuiDailyVideoEntity.setDailyId(zhaohuiDailyEntity.getId().toString());
|
|
|
zhaohuiDailyVideoEntity.setDailyId(zhaohuiID);
|
|
|
zhaohuiDailyVideoEntity.setTime(stateDate + "," + endDate);
|
|
|
zhaohuiDailyVideoList.add(zhaohuiDailyVideoEntity);
|
|
|
break;
|
|
|
case 13: //睡眠带
|
|
|
ZhaohuiDailySleepEntity zhaohuiDailySleep = new ZhaohuiDailySleepEntity();
|
|
|
zhaohuiDailySleep.setDailyId(zhaohuiDailyEntity.getId().toString());
|
|
|
zhaohuiDailySleep.setDailyId(zhaohuiID);
|
|
|
JSONObject sleepDeviceInfo = patientDeviceService.getSleepDeviceInfo(deviceSn);
|
|
|
if (sleepDeviceInfo.getBooleanValue("success")) {
|
|
|
JSONArray objs = sleepDeviceInfo.getJSONArray("objs");
|
|
|
response = objs.getJSONObject(0);
|
|
|
if (!response.getBoolean("online")) {//设备在线状态
|
|
|
zhaohuiDailySleep.setStatus("0");
|
|
|
deviceTotal+=1;
|
|
|
deviceName+=",睡眠带离线";
|
|
|
} else {
|
|
|
zhaohuiDailySleep.setStatus("1");
|
|
|
}
|
|
@ -351,11 +385,76 @@ public class ZhaohuiDailyService {
|
|
|
}
|
|
|
zhaohuiDailySleepList.add(zhaohuiDailySleep);
|
|
|
break;
|
|
|
case 14: //烟感
|
|
|
ZhaohuifireGasSecEntity yg = new ZhaohuifireGasSecEntity();
|
|
|
sql = " select count(o.id) as total from base_security_monitoring_order o " +
|
|
|
" INNER JOIN base_patient p on p.id = o.patient where device_sn='" + deviceSn + "' and o.status=1 and o.create_time >= '" + stateDate + "' and o.create_time <= '" + endDate + "' ORDER BY create_time desc ";
|
|
|
Integer ygTotal = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
|
|
|
sql = " select value, DATE_FORMAT( record_time, '%H:%i:%S' ) as record_time from base_device_health_index where device_sn='" + deviceSn + "' and record_time >= '" + stateDate + "' and record_time <= '" + endDate + "' ORDER BY record_time desc";
|
|
|
List<Map<String, Object>> ygList = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray ygJsonArray = JSONArray.parseArray(ygList.toString());
|
|
|
|
|
|
yg.setDailyId(zhaohuiID);
|
|
|
yg.setOnline(1);
|
|
|
yg.setType(1);
|
|
|
if (ygTotal>0) {
|
|
|
yg.setSecStatus(1);
|
|
|
}else {
|
|
|
yg.setSecStatus(0);
|
|
|
}
|
|
|
yg.setFireCurve(ygJsonArray.toJSONString());
|
|
|
|
|
|
zhaohuifireGasSecEntityList.add(yg);
|
|
|
break;
|
|
|
case 15: //气感
|
|
|
sql = " select count(o.id) as total from base_security_monitoring_order o " +
|
|
|
" INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 and o.create_time >= '"+stateDate+"' and o.create_time <= '"+endDate+"' ORDER BY create_time desc limit 1 ";
|
|
|
Integer qgTotal = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
|
|
|
ZhaohuifireGasSecEntity qg = new ZhaohuifireGasSecEntity();
|
|
|
qg.setDailyId(zhaohuiID);
|
|
|
qg.setOnline(1);
|
|
|
qg.setType(2);
|
|
|
if (qgTotal>0) {
|
|
|
qg.setSecStatus(1);
|
|
|
}else {
|
|
|
qg.setSecStatus(0);
|
|
|
}
|
|
|
sql = " select value,DATE_FORMAT( record_time, '%H:%i:%S' ) as record_time from base_device_health_index where device_sn='"+deviceSn+"' and record_time >='"+stateDate+"' and record_time <= '"+endDate+"' ORDER BY record_time desc limit 1 ";
|
|
|
List<Map<String, Object>> qgList = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray qgJsonArray = JSONArray.parseArray(qgList.toString());
|
|
|
qg.setFireCurve(qgJsonArray.toJSONString());
|
|
|
zhaohuifireGasSecEntityList.add(qg);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -368,11 +467,13 @@ 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);
|
|
|
zhaohuiDailyVideoDao.save(zhaohuiDailyVideoList);
|
|
|
zhaohuiDailyEmeDao.save(zhaohuiDailyEmeList);
|
|
|
zhaohuifireGasSecDao.save(zhaohuifireGasSecEntityList);
|
|
|
}
|
|
|
|
|
|
|
|
@ -385,11 +486,140 @@ 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());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//行动轨迹
|
|
|
public JSONArray getX1Locations(String patient, String date){
|
|
|
String sql = "select * from wlyy_patient_device where user = '"+patient+"' and category_code = '4' and del = 0";
|
|
|
List<DevicePatientDevice> byUserAndCategoryCode = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DevicePatientDevice.class));
|
|
|
if (byUserAndCategoryCode.size()==0){
|
|
|
return null;
|
|
|
}
|
|
|
JSONArray x1Locations = JSON.parseArray(JSON.toJSONString(patientDeviceService.getX1Locations(byUserAndCategoryCode.get(0).getDeviceSn(), date), SerializerFeature.WriteMapNullValue));
|
|
|
return x1Locations;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(",");
|
|
@ -401,4 +631,6 @@ public class ZhaohuiDailyService {
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|