陈昶聿
2 天以前 933846091c0b8f06158fcab23cfa0b59e8514f9b
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -17,7 +17,7 @@
import com.ruoyi.common.enums.WxGZHEnum;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.sms.smsUtils;
import com.ruoyi.common.utils.sms.SmsUtils;
import com.ruoyi.quartz.service.ICollectHISService;
import com.ruoyi.quartz.util.CreateDataTable;
import com.ruoyi.system.domain.SysConfig;
@@ -1003,6 +1003,24 @@
    }
    /**
     * 按机构查询配置值(同一 key 在不同机构下可配置不同值)
     *
     * @param configKey 配置key
     * @param orgid     机构ID
     * @return 配置值,未配置返回 null
     */
    private String getConfigValue(String configKey, String orgid) {
        SysConfig query = new SysConfig();
        query.setConfigKey(configKey);
        query.setOrgid(orgid);
        List<SysConfig> sysConfigs = configService.selectConfigList(query);
        if (CollectionUtils.isNotEmpty(sysConfigs)) {
            return sysConfigs.get(0).getConfigValue();
        }
        return null;
    }
    /**
     * 随访-补偿处理
     *
     * @param serviceSubtask
@@ -1210,33 +1228,48 @@
//                        String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid());
//                        //丽水的短信发送方式
//                        Map<String, String> map = MsgLSEnum.getAddressByCode(serviceSubtask.getOrgid());
                        SysConfig config = new SysConfig();
                        config.setConfigKey("ls.msg.info");
                        config.setOrgid(serviceSubtask.getOrgid());
                        List<SysConfig> sysConfigs = configService.selectConfigList(config);
                        Map<String, String> msgInfo = new HashMap<>();
                        if (CollectionUtils.isNotEmpty(sysConfigs)) {
                            String configValue = sysConfigs.get(0).getConfigValue();
                        if ("47226079133110211G1001".equals(serviceSubtask.getOrgid())) {
                            // 妇幼中国移动云MAS,不依赖 ls.msg.info 与 token
                            SmsUtils.YunMasConfig yunMasConfig = SmsUtils.YunMasConfig.of(getConfigValue("ls.msg.yunmas", serviceSubtask.getOrgid()));
                            SmsUtils.SmsResult smsResult = SmsUtils.sendYunMasSms(yunMasConfig, sendMagParam.getPhone(), sendMagParam.getContent());
                            log.info("【sfHandlle】云MAS短信发送结果:ok={},rspcod={},msgGroup={},message={}",
                                    smsResult.isOk(), smsResult.getRspcod(), smsResult.getMsgGroup(), smsResult.getMessage());
                            if (smsResult.isOk()) {
                                isSuccess = "true";
                            } else {
                                log.error("【sfHandlle】云MAS短信发送失败,subid:{},手机号:{},原因:{}",
                                        serviceSubtask.getId(), sendMagParam.getPhone(), smsResult.getMessage());
                            }
                        } else {
                            SysConfig config = new SysConfig();
                            config.setConfigKey("ls.msg.info");
                            config.setOrgid(serviceSubtask.getOrgid());
                            List<SysConfig> sysConfigs = configService.selectConfigList(config);
                            Map<String, String> msgInfo = new HashMap<>();
                            if (CollectionUtils.isNotEmpty(sysConfigs)) {
                                String configValue = sysConfigs.get(0).getConfigValue();
                                ObjectMapper objectMapper = new ObjectMapper();
                                if (StringUtils.isNotEmpty(configValue)) {
                                    msgInfo = objectMapper.readValue(configValue, Map.class);
                                }
                            }
                            log.info("-----------map的值为:{}", msgInfo);
                            if (ObjectUtils.isEmpty(msgInfo) || StringUtils.isEmpty(msgInfo.get("address"))) {
                                setSuccessPreachForm(serviceSubtask, sendPreachform, "短信发送失败,该机构没有配置短信地址, 时间:" + now, "5");
                                return;
                            }
                            String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
                            log.info("【sfHandlle】丽水短信发送,地址:{},参数:{},机构ID:{}", msgInfo.get("address"), sendMagParam, serviceSubtask.getOrgid());
                            String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
                            log.info("【sfHandlle】丽水短信发送结果:{}", dxCode);
                            ObjectMapper objectMapper = new ObjectMapper();
                            if (StringUtils.isNotEmpty(configValue)) {
                                msgInfo = objectMapper.readValue(configValue, Map.class);
                            Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
                            String code = textParam.get("Code").toString();
                            if (code.equals("0")) {
                                isSuccess = "true";
                            }
                        }
                        log.info("-----------map的值为:{}", msgInfo);
                        String token = LSHospTokenUtil.getToken(serviceSubtask.getOrgid(), msgInfo.get("tokenUrl"));
                        if (ObjectUtils.isNotEmpty(msgInfo) && StringUtils.isEmpty(msgInfo.get("address"))) {
                            setSuccessPreachForm(serviceSubtask, sendPreachform, "短信发送失败,该机构没有配置短信地址, 时间:" + now, "5");
                            return;
                        }
                        log.info("【sfHandlle】丽水短信发送,地址:{},参数:{},机构ID:{}", msgInfo.get("address"), sendMagParam, serviceSubtask.getOrgid());
                        String dxCode = getDXCode(msgInfo.get("address"), sendMagParam.getPhone(), sendMagParam.getContent(), msgInfo.get("sendPersonId"), msgInfo.get("sendPersonName"), MsgLSEnum.getHeaderByCode(msgInfo), token);
                        log.info("【sfHandlle】丽水短信发送结果:{}", dxCode);
                        ObjectMapper objectMapper = new ObjectMapper();
                        Map<String, Object> textParam = objectMapper.readValue(dxCode, Map.class);
                        String code = textParam.get("Code").toString();
                        if (code.equals("0")) {
                            isSuccess = "true";
                        }
                    } else if (active.equals("sltd") || active.equals("nhfy")) {
                        log.info("sltd进来了吗?{}   ,---sendMagParam.getContent()的参数为:{}", active, sendMagParam.getContent());
                        if (active.equals("sltd")) {
@@ -1284,13 +1317,13 @@
                        String campusid = ObjectUtils.isNotEmpty(sysDept) ? sysDept.getCampusid() : "2";
                        //湖滨单独发送方式
                        if ("1".equals(campusid)) {
                            String result = smsUtils.sendSms1(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
                            String result = SmsUtils.sendSms1(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
                            //这里需要根据result返回的值去判断,是否成功,然后将值赋值给isSuccess
                            if (StringUtils.isNotEmpty(result) && result.contains("处理成功")) {
                                isSuccess = "true";
                            }
                        } else {
                            String result = smsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
                            String result = SmsUtils.sendSms(xhsmsPath, xhsmsAccount, xhsmsPwd, sendMagParam.getPhone(), content);
                            //这里需要根据result返回的值去判断,是否成功,然后将值赋值给isSuccess
                            if (StringUtils.isNotEmpty(result) && result.contains("处理成功")) {
                                isSuccess = "true";
@@ -1372,7 +1405,7 @@
                    //市一医院
                    if (active.equals("hzszlyy")) {
                        //处理中文乱码问题
                        wxCode = smsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
                        wxCode = SmsUtils.sendChat(url, patArchive.getTelcode(), serviceSubtask.getSfzh());
                    } else {
                        wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), patArchive.getTelcode(), serviceSubtask.getSendname(), patArchive.getPatidHis(), wxqqxx);
                    }
@@ -1884,6 +1917,22 @@
        st.setNexttaskflag("1");
        st.setOrgid(orgid);
        List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st);
        // 随访中心科室
        String centerDept = configService.selectConfigByKey("sys.smartor.center.dept", orgid);
        SysDept sysDeptVo = new SysDept();
        SysDept centerSysDept = null;
        if(StringUtils.isNotEmpty(centerDept)){
            sysDeptVo.setDeptType("1");
            sysDeptVo.setOrgid(orgid);
            sysDeptVo.setDeptCode(centerDept);
            List<SysDept> sysDepts = sysDeptService.selectDeptList(sysDeptVo);
            if (CollectionUtils.isNotEmpty(sysDepts)) {
                centerSysDept = sysDepts.get(0);
            }
        }
        String config = configService.selectConfigByKey("visit.early.day");
        for (ServiceTask serviceTask : serviceTasks) {
            deadlineDay = -deadlineDay;
            Date deadline = DateUtils.addDays(new Date(), deadlineDay);
@@ -1895,6 +1944,7 @@
            serviceSubtaskVO.setVisitCount(1);
            serviceSubtaskVO.setTaskid(serviceTask.getTaskid());
            serviceSubtaskVO.setEndOutHospTime(deadline);
            List<ServiceSubtask> serviceSubtaskList
                    = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
            log.info("【dealSubtaskDeadline】获取到{}个超时任务, taskid={}", serviceSubtaskList.size(), serviceTask.getTaskid());
@@ -1915,7 +1965,6 @@
                }
                ServiceTask nextServiceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceTask.getNexttaskid());
                PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtask.getPatid());
                String config = configService.selectConfigByKey("visit.early.day");
                Integer type = 1;
                //新增再次随访任务
@@ -1928,8 +1977,13 @@
                serviceSubtaskAgain.setCreateTime(new Date());
                serviceSubtaskAgain.setUpdateTime(new Date());
                serviceSubtaskAgain.setVisitType(serviceSubtask.getVisitType());
                serviceSubtaskAgain.setVisitDeptCode(serviceSubtask.getVisitDeptCode());
                serviceSubtaskAgain.setVisitDeptName(serviceSubtask.getVisitDeptName());
                if(ObjectUtils.isNotEmpty(centerSysDept)){
                    serviceSubtaskAgain.setVisitDeptCode(centerSysDept.getDeptCode());
                    serviceSubtaskAgain.setVisitDeptName(centerSysDept.getDeptName());
                }else {
                    serviceSubtaskAgain.setVisitDeptCode(serviceSubtask.getVisitDeptCode());
                    serviceSubtaskAgain.setVisitDeptName(serviceSubtask.getVisitDeptName());
                }
                int i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtaskAgain);
                if (i == 1) {
                    //再次随访任务创建成功后,原任务改为失败状态