| | |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | | import com.ruoyi.common.enums.WxGZHEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.HttpUtil; |
| | | import com.ruoyi.common.utils.OkHttpExample; |
| | | import com.ruoyi.common.utils.RSAPublicKeyExample; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.sign.Md5Utils; |
| | | import com.ruoyi.common.utils.sms.smsUtils; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.security.MessageDigest; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | @Value("${xhsmsPwd}") |
| | | private String xhsmsPwd; |
| | | // 虚拟接入码 |
| | | @Value("${xhsmsjrm}") |
| | | private String xhsmsjrm; |
| | | |
| | | @Value("${server.port}") |
| | | private String port; |
| | |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | //转成16进制 |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(ip + ":" + req_path + "/sf?p=" + format); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/sf?p=" + format); |
| | | SysConfig sysConfig = new SysConfig(); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("6")) { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("zymyd.sms.template"); |
| | | }else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) { |
| | | } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template"); |
| | | }else { |
| | | } else { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template"); |
| | | } |
| | | if (!Objects.isNull(sysConfig)) { |
| | |
| | | // serviceOutPath.setParam3(URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString())); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | serviceOutPath.setUrl(StringUtils.isNotEmpty(req_path) ? ip + ":" + req_path + "/wt?p=" + format : ip + "/wt?p=" + format); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | // sendMagParam.setUrl(ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false"); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | |
| | | SysConfig sysConfig = new SysConfig(); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("6")) { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("zymyd.sms.template"); |
| | | }else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) { |
| | | } else if (StringUtils.isNotEmpty(serviceSubtask.getServiceType()) && serviceSubtask.getServiceType().equals("14")) { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("mzmyd.sms.template"); |
| | | }else { |
| | | } else { |
| | | sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template"); |
| | | } |
| | | if (!Objects.isNull(sysConfig)) { |
| | |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | |
| | | String s = null; |
| | | if (active.equals("xh")) { |
| | | //新华的短信发送方式 |
| | | Map<String, String> req = new HashMap<>(); |
| | | req.put("phone", sendMagParam.getPhone()); |
| | | req.put("content", sendMagParam.getContent()); |
| | | log.info("content返回值的内容是:{}", sendMagParam.getContent()); |
| | | s = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req)); |
| | | } else if (active.equals("ls")) { |
| | | // String url = configService.selectConfigByKey("token.360", serviceSubtask.getOrgid()); |
| | | // log.info("-------00token.360的URL为:{}", url); |
| | | Map<String, String> map2 = new HashMap<String, String>(); |
| | | map2.put("action", "send"); |
| | | map2.put("account", xhsmsAccount); |
| | | map2.put("password", xhsmsPwd); |
| | | map2.put("mobile", sendMagParam.getPhone()); |
| | | map2.put("content", sendMagParam.getContent()); |
| | | map2.put("extno", xhsmsjrm); |
| | | map2.put("rt", "json"); |
| | | StringBuilder encodedParams = new StringBuilder(); |
| | | |
| | | for (Map.Entry<String, String> entry : map2.entrySet()) { |
| | | if (encodedParams.length() > 0) { |
| | | encodedParams.append("&"); |
| | | } |
| | | // 对键和值进行URL编码 |
| | | String encodedKey = URLEncoder.encode(entry.getKey(), "UTF-8"); |
| | | String encodedValue = URLEncoder.encode(entry.getValue(), "UTF-8"); |
| | | encodedParams.append(encodedKey).append("=").append(encodedValue); |
| | | } |
| | | Boolean isSuccess = HttpUtil.postJsonRequest(xhsmsPath, encodedParams.toString()); |
| | | if (isSuccess) s = "true"; |
| | | } else if (active.equals("ls")) { |
| | | //丽水的短信发送方式 |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey("ls.msg.info"); |
| | |
| | | if (active.equals("sltd")) { |
| | | data = MessageSend.sendMsg(sendMagParam.getContent(), "6", sendMagParam.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); |
| | | if (StringUtils.isNotEmpty(data)) { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | JsonNode root = mapper.readTree(data); |
| | | String status = root.get("result").get(0).get("status").asText(); |
| | | if (status.equals("00000")) { |
| | | s = "true"; |
| | | } else { |
| | | setFailPreachForm(serviceSubtask, sendPreachform, "短信发送失败: " + data, "5"); |
| | | throw new BaseException("短信发送失败"); |
| | | String[] pairs = data.split("&"); |
| | | String resultVal = null; |
| | | for (String pair : pairs) { |
| | | String[] kv = pair.split("=", 2); |
| | | if ("result".equals(kv[0])) { |
| | | resultVal = kv.length > 1 ? kv[1] : null; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ("0".equals(resultVal)) { |
| | | s = "true"; |
| | | } |
| | | } else { |
| | | setFailPreachForm(serviceSubtask, sendPreachform, "短信发送失败: " + data, "5"); |
| | | throw new BaseException("短信发送失败"); |
| | |
| | | String sign = Md5Utils.hash(xhsmsAccount + timestamp + Md5Utils.hash(xhsmsPwd)); |
| | | String content = sendMagParam.getContent(); |
| | | String jsonMsg = "{" + "\"userName\": \"" + xhsmsAccount + "\"," + "\"content\": \"" + content + "\"," + "\"phoneList\": [" + sendMagParam.getPhone() + "]," + "\"timestamp\": " + timestamp + "," + "\"sign\": \"" + sign + "\"" + "}"; |
| | | s = HttpUtil.postJsonRequest(xhsmsPath, jsonMsg); |
| | | Boolean b = HttpUtil.postJsonRequest(xhsmsPath, jsonMsg); |
| | | if (b) s = "true"; |
| | | log.info("------市一短信发送的值为:{}", s); |
| | | if (StringUtils.isNotEmpty(s)) { |
| | | JSONObject jsonObject = JSONObject.parseObject(s); |
| | |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | |
| | | String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key); |
| | | try { |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("5"); |
| | |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setParam6(subId); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | serviceOutPath.setDeptCode(serviceSubtask.getDeptcode()); |
| | | serviceOutPath.setWardCode(serviceSubtask.getLeavehospitaldistrictcode()); |
| | | serviceOutPath.setDeptName(serviceSubtask.getDeptname()); |
| | | serviceOutPath.setWardName(serviceSubtask.getLeavehospitaldistrictname()); |
| | | serviceOutPath.setOrgid(serviceSubtask.getOrgid()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | |
| | | serviceSubtaskPreachform1.setRemark(remark); |
| | | serviceSubtaskPreachformMapper.updateServiceSubtaskPreachform(serviceSubtaskPreachform1); |
| | | //如果当前的preachform已经是最后一个了,并且本次还是发送失败,那直接将serviceSubtask的sendstate状态改成5就行了(全失败了) |
| | | if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size()) { |
| | | if (CollectionUtils.isNotEmpty(spSize) && serviceSubtaskPreachform1.getSort() == spSize.size() |
| | | && isSubtaskDeadline(serviceSubtask, serviceSubtaskPreachforms)) { |
| | | if (serviceSubtaskPreachform1.getSort() == spSize.size()) { |
| | | if (failSendstate.equals("4") || failSendstate.equals("5")) { |
| | | serviceSubtask.setCurrentPreachform(preachform); |
| | |
| | | } |
| | | return toHex(md5.digest()); |
| | | } |
| | | |
| | | /** |
| | | * 随访任务是否超时 |
| | | * @param serviceSubtask |
| | | * @param serviceSubtaskPreachforms |
| | | * @return |
| | | */ |
| | | public boolean isSubtaskDeadline(ServiceSubtask serviceSubtask, List<ServiceSubtaskPreachform> serviceSubtaskPreachforms){ |
| | | if (Objects.isNull(serviceSubtask) || CollectionUtils.isEmpty(serviceSubtaskPreachforms)) { |
| | | return false; |
| | | } |
| | | // 基准时刻:出院时间 + 发送日(sendDay 缺省按 1),并兜底避免 NPE/脏数据 |
| | | ServiceTask serviceTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid()); |
| | | int sendDay = serviceTask != null && serviceTask.getSendDay() != null ? serviceTask.getSendDay().intValue() : 1; |
| | | Date deadline = DateUtils.addDays(serviceSubtask.getEndtime(), sendDay); |
| | | int sumCompensateTime = CollectionUtils.isEmpty(serviceSubtaskPreachforms) ? 0 : serviceSubtaskPreachforms.stream() |
| | | .mapToInt(x -> x.getCompensateTime() == null ? 0 : Integer.parseInt(x.getCompensateTime())) |
| | | .sum(); |
| | | sumCompensateTime = sumCompensateTime + 1; |
| | | // 只补偿最后一步自身的补偿时间(天),脏值一律按 0 兜底 |
| | | deadline = DateUtils.addDays(deadline, sumCompensateTime); |
| | | // 出院(发送)时间 + 本步补偿时间 小于当前时间 -> 超时 |
| | | return deadline.getTime() < new Date().getTime(); |
| | | } |
| | | } |