wsl 2 anos atrás
pai
commit
05babdbfce

+ 13 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/log/ZhaohuiDailyEntity.java

@ -80,6 +80,19 @@ public class ZhaohuiDailyEntity extends IdEntity {
    private String orgCode;
    //用户类型 1 居民 2幼儿  3社工 4 管理员
    private Integer userType;
    @Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;

+ 53 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -7,6 +7,7 @@ import com.yihu.jw.care.service.message.DoctorMessageService;
import com.yihu.jw.care.service.message.PatientMessageService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -224,4 +225,56 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getZhaoHuiRiBaoList")
    @ApiOperation(value = "获取朝晖日报列表")
    public ListEnvelop getZhaoHuiRiBaoList(@ApiParam(name = "startTime", required = false)
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                           @ApiParam(name = "endTime", required = false)
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                           @ApiParam(name = "orgCode", required = false)
                                           @RequestParam(value = "orgCode", required = false) String orgCode,
                                           @ApiParam(name = "userType", required = false)
                                           @RequestParam(value = "userType", required = false) String userType
    ) {
        try {
            return success("获取成功", 200, patientMessageService.getZhaoHuiRiBaoList(userType,startTime,null,endTime,orgCode));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getZHaohuiRiBaoInfo")
    @ApiOperation(value = "获取朝晖日报信息")
    public ObjEnvelop getZHaohuiRiBaoInfo(
                                           @ApiParam(name = "orgId", required = false)
                                           @RequestParam(value = "orgId", required = false) String orgId,
                                           @ApiParam(name = "dailyId", required = false)
                                           @RequestParam(value = "dailyId", required = false) String dailyId
    ) {
        try {
            return success("获取成功", 200, patientMessageService.getZhaohuiDailyDoctor(dailyId,orgId));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getDoctorOrgId")
    @ApiOperation(value = "获取社区id")
    public ObjEnvelop getDoctorOrgId(
            @ApiParam(name = "id", required = false)
            @RequestParam(value = "id", required = false) String id
    ) {
        try {
            return success("获取成功", 200, patientMessageService.getDoctorOrgId(id));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
}

+ 9 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -259,18 +259,18 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "/getZhaoHuiRiBaoList")
    @ApiOperation(value = "获取朝晖日报")
    @ApiOperation(value = "获取朝晖日报列表")
    public ListEnvelop getZhaoHuiRiBaoList(@ApiParam(name = "startTime", required = false)
                                          @RequestParam(value = "startTime",required = false) String startTime,
                                          @ApiParam(name = "endTime", required = false)
                                          @RequestParam(value = "endTime",required = false) String endTime,
                                          @ApiParam(name = "patient", required = true)
                                          @RequestParam(value = "patient") String patient,
                                          @ApiParam(name = "dailyId", required = false)
                                          @RequestParam(value = "dailyId",required = false) String dailyId
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                           @ApiParam(name = "endTime", required = false)
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                           @ApiParam(name = "patient", required = false)
                                           @RequestParam(value = "patient",required = false) String patient,
                                           @ApiParam(name = "userType", required = false)
                                           @RequestParam(value = "userType", required = false) String userType
    ) {
        try {
            return success("获取成功", 200, patientMessageService.getZhaoHuiRiBaoList(startTime, endTime, patient));
            return success("获取成功", 200, patientMessageService.getZhaoHuiRiBaoList(userType,startTime, endTime, patient,null));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);

+ 57 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -328,6 +328,43 @@ public class PatientMessageService {
    }
    public String getDoctorOrgId(String id){
        String sql = "select id from base_team where leader_code = '"+id+"' and del = 1 and org_code = 'zdjsylfwyxgszhfgs' ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list.get(0).get("id").toString();
    }
    public JSONObject getZhaohuiDailyDoctor(String dailyId, String orgId) {
        JSONObject resultObj = new JSONObject();
        ZhaohuiDailyEntity zhaohuiDailyEntity = zhaohuiDailyDao.findById(Long.parseLong(dailyId));
        String[] data = zhaohuiDailyEntity.getServiceTime().split(",");
        data[0] = "1999-01-01 00:00:00";
        data[1] = "2022-11-29 23:59:59";
        String sql = "select * from base_zhaohui_daily where org_code='" + orgId + "' and create_time>= '" + data[0] + "' and create_time<='" + data[1] + "' and user_type = 1 ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<JSONObject> patientBasInfoList = new ArrayList<>();
        if (list.size()>0) {
            for (Map<String, Object> map : list) {
                JSONObject zHaohuiRiBaoInfo = getZHaohuiRiBaoInfo(map.get("patient").toString(), map.get("id").toString());
                sql = "SELECT SUM(a.total) as total FROM (\n" +
                        "SELECT count(o.id) total FROM base_emergency_assistance_order o  WHERE o.patient ='"+map.get("patient").toString()+"' and o.status NOT IN (-1,0) AND o.create_time >='" + data[0] + "' AND o.create_time<='" + data[1] + "' \n" +
                        "UNION ALL \n" +
                        "SELECT count(o.id) total FROM base_security_monitoring_order o  WHERE o.patient = '"+map.get("patient").toString()+"'  and o.status NOT IN (-1,0) AND o.create_time >='" + data[0] + "' AND o.create_time<='" + data[1] + "' \n" +
                        ") a";
                Integer emeNum = jdbcTemplate.queryForObject(sql, Integer.class);
                zHaohuiRiBaoInfo.put("redDot",emeNum);
                patientBasInfoList.add(zHaohuiRiBaoInfo);
            }
        }
        resultObj.put("doctorBaseInfo", zhaohuiDailyEntity);
        resultObj.put("patientBaseInfo", patientBasInfoList);
        return resultObj;
    }
    public JSONObject getZHaohuiRiBaoInfo(String patient, String dailyId){
@ -403,20 +440,29 @@ public class PatientMessageService {
        return result;
    }
    public List<Map<String, Object>> getZhaoHuiRiBaoList(String start, String end, String patient) {
    //userType   1 家属   2 幼儿  3 社工
    public List<Map<String, Object>> getZhaoHuiRiBaoList(String userType, String start, String end, String patient,String orgCode) {
        StringBuffer sql = new StringBuffer("SELECT id,eme_num,service,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') as create_time,patient_name,user_type,family_code FROM base_zhaohui_daily WHERE 1=1  ");
            StringBuffer sql = new StringBuffer("SELECT  id,eme_num,service,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') as create_time,patient_name FROM base_zhaohui_daily WHERE family_code = '" + patient + "' ");
            if (StringUtils.isNotBlank(start)) {
                start+=" 00:00:00";
                sql.append(" and create_time >='" + start + "' ");
            }
        if (StringUtils.isBlank(userType) || "1".equals(userType)) {
            sql.append(" and family_code = '" + patient + "' and user_type = 1");
            if (StringUtils.isNotBlank(end)) {
                end +=" 23:59:59";
                sql.append(" and create_time <= '" + end + "' ");
            }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
        } else if ("2".equals(userType)) {
            sql.append(" and family_code = '" + patient + "' and user_type = 2");
        } else if ("3".equals(userType)) {
            sql.append(" and org_code = '" + orgCode + "' and user_type = 3");
        }
        if (StringUtils.isNotBlank(start)) {
            start += " 00:00:00";
            sql.append(" and create_time >='" + start + "' ");
        }
        if (StringUtils.isNotBlank(end)) {
            end += " 23:59:59";
            sql.append(" and create_time <= '" + end + "' ");
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
        return list;
    }

+ 2 - 3
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java

@ -7,7 +7,6 @@ import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.data.SaveDataPushJob;
import com.yihu.jw.care.job.device.*;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.job.order.*;
import com.yihu.jw.care.job.pushRecord.*;
import com.yihu.jw.care.job.sim.GetSimsVoiceFlowDayJob;
@ -56,13 +55,13 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            }
            //#每天的早上9:00,给所有居民发送未读消息微信模板
            if (!quartzHelper.isExistJob("PATIENT_SEND_UNREAD_MES_JOB")) {
            /*if (!quartzHelper.isExistJob("PATIENT_SEND_UNREAD_MES_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("PATIENT_SEND_UNREAD_MES_JOB");
                quartzHelper.addJob(PatientSendUnreadJob.class, trigger, "PATIENT_SEND_UNREAD_MES_JOB", new HashMap<String, Object>());
                logger.info("PATIENT_SEND_UNREAD_MES_JOB success");
            } else {
                logger.info("PATIENT_SEND_UNREAD_MES_JOB exist");
            }
            }*/
            //#每天的早上9:00,生日祝福提醒短信
            if (!quartzHelper.isExistJob("BIRTHDAY_REMINDER_JOB")) {

+ 5 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/PushZhaohuiRoundJob.java

@ -28,6 +28,11 @@ public class PushZhaohuiRoundJob implements Job {
            zhaohuiDailyService.allRound();
            logger.info("PushZhaohuiRoundJob end");
            System.out.println("====================朝晖日报end==================");
            zhaohuiDailyService.doctorDaily();
            zhaohuiDailyService.child();
            System.out.println("====================朝晖日报end==================");
        } catch (Exception e) {
            logger.info("PushZhaohuiRoundJob --ERROR MSG:" + e.getMessage());
            e.printStackTrace();

+ 172 - 20
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/message/ZhaohuiDailyService.java

@ -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(",");

+ 30 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java

@ -13,6 +13,7 @@ import com.yihu.jw.care.service.WlyysimFlowVoiceService;
import com.yihu.jw.care.service.device.InitializeDataJobService;
import com.yihu.jw.care.service.device.WechatPushService;
import com.yihu.jw.care.service.hz.HzInterfaceService;
import com.yihu.jw.care.service.message.ZhaohuiDailyService;
import com.yihu.jw.care.util.SystemConf;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import io.swagger.annotations.Api;
@ -53,6 +54,35 @@ public class JobController extends BaseController {
    @Autowired
    private HzInterfaceService hzInterfaceService;
    @Autowired
    private ZhaohuiDailyService zhaohuiDailyService;
    @RequestMapping(value = "ZhaohuiDailyService", method = RequestMethod.GET)
    @ApiOperation("123")
    public String abc() {
        try {
            zhaohuiDailyService.doctorDaily();
            return success("更新成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败:" + e.getMessage());
        }
    }
    @RequestMapping(value = "child", method = RequestMethod.GET)
    @ApiOperation("456")
    public String child() {
        try {
            zhaohuiDailyService.child();
            return success("更新成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败:" + e.getMessage());
        }
    }
    @RequestMapping(value = "electricityTable", method = RequestMethod.GET)
    @ApiOperation("收到更新居民电表数据")
    public String electricityTable(String queryDate) {