| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.ServiceFromEnum; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.HttpUtil; |
| | | import com.ruoyi.common.utils.RSAPublicKeyExample; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | |
| | | import org.springframework.transaction.PlatformTransactionManager; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.lang.reflect.Type; |
| | |
| | | private IServiceThirdDataService iServiceThirdDataService; |
| | | |
| | | @Autowired |
| | | private IServiceOutPathService iServiceOutPathService; |
| | | |
| | | @Autowired |
| | | private IServiceSubtaskAnswerService serviceSubtaskAnswerService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Value("${localIP}") |
| | | private String localIP; |
| | | |
| | | @Value("${xhsmsPath}") |
| | | private String xhsmsPath; |
| | | |
| | | @Value("${pub_key}") |
| | | private String pub_key; |
| | |
| | | } else if (descByCode.equals("纸质")) { |
| | | //纸质 |
| | | } else if (descByCode.equals("短信")) { |
| | | //短信 |
| | | // http://localhost:8099/followvisit/particty?param1=3¶m2=348 |
| | | //对url中两个参数加密 |
| | | RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); |
| | | String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); |
| | | |
| | | for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) { |
| | | try { |
| | | log.error("短信长期任务发送---------进来了吗?{}", serviceSubtask); |
| | | boolean dateToday = isDateToday(serviceSubtask.getLongSendTime()); |
| | | if (dateToday) { |
| | | try { |
| | | //先判断患者是不是还要发送 |
| | | PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtask.getPatid()); |
| | | if (!Objects.isNull(patArchive) && patArchive.getNotrequiredFlag() == "1") { |
| | | //不需要发送 |
| | | serviceSubtask.setResult("error"); |
| | | serviceSubtask.setRemark(patArchive.getNotrequiredreason()); |
| | | serviceSubtask.setSendstate(4L); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | iServiceSubtaskService.insertServiceSubtask(serviceSubtask); |
| | | continue; |
| | | } |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | ServiceOutPath serviceOutPath = new ServiceOutPath(); |
| | | serviceOutPath.setParam1(taskId); |
| | | serviceOutPath.setParam2(patid); |
| | | serviceOutPath.setParam3(ivrTask1.getTaskName()); |
| | | serviceOutPath.setCreateTime(new Date()); |
| | | iServiceOutPathService.insertServiceOutPath(serviceOutPath); |
| | | String format = String.format("%03X", serviceOutPath.getId()); |
| | | serviceOutPath.setRadix(format); |
| | | serviceOutPath.setUpdateTime(new Date()); |
| | | iServiceOutPathService.updateServiceOutPath(serviceOutPath); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/wt?p=" + format); |
| | | sendMagParam.setContent("【新华医院】您好,邀请您填写出院调查表,请点击" + sendMagParam.getUrl() + "填写。感谢您配合!"); |
| | | Map<String, String> req = new HashMap<>(); |
| | | req.put("phone", sendMagParam.getPhone()); |
| | | req.put("content", sendMagParam.getContent()); |
| | | String isSuccess = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(req)); |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult("success"); |
| | | if (StringUtils.isNotEmpty(isSuccess) && !isSuccess.equals("true")) |
| | | serviceSubtaskRecord.setResult("error"); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | |
| | | |
| | | String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key); |
| | | SendMagParam sendMagParam = new SendMagParam(); |
| | | sendMagParam.setType("4"); |
| | | sendMagParam.setPhone(serviceSubtask.getPhone()); |
| | | sendMagParam.setUrl(ip + ":" + req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid + "¶m5=false"); |
| | | Boolean aBoolean = sendService.sendMsg(sendMagParam); |
| | | |
| | | //任务发送记录 |
| | | ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); |
| | | serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString()); |
| | | serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); |
| | | serviceSubtaskRecord.setTasktype(serviceSubtask.getType()); |
| | | serviceSubtaskRecord.setPreachform("4"); |
| | | serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); |
| | | serviceSubtaskRecord.setResult(aBoolean == true ? "成功" : "失败"); |
| | | serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); |
| | | } catch (Exception e) { |
| | | continue; |
| | | //发送完成后,修改状态 |
| | | serviceSubtask.setSendstate(3L); |
| | | if (StringUtils.isNotEmpty(isSuccess) && !isSuccess.equals("true")) { |
| | | serviceSubtask.setResult("success"); |
| | | } else { |
| | | serviceSubtask.setResult("error"); |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtask.setRemark("短信发送失败"); |
| | | } |
| | | iServiceSubtaskService.updateServiceSubtask(serviceSubtask); |
| | | } catch (Exception e) { |
| | | String guid = UUID.randomUUID().toString(); |
| | | log.error("长期任务,发送失败原因:{},{}", e.getMessage(), guid); |
| | | serviceSubtask.setResult("error"); |
| | | serviceSubtask.setRemark("系统错误"); |
| | | serviceSubtask.setSendstate(5L); |
| | | serviceSubtask.setFinishtime(new Date()); |
| | | serviceSubtask.setGuid(guid); |
| | | iServiceSubtaskService.updateServiceSubtask(serviceSubtask); |
| | | } |
| | | } |
| | | } |
| | | } else if (descByCode.equals("公众号")) { |
| | |
| | | Type resultType = new TypeToken<List<ThiedInhospInfo>>() { |
| | | }.getType(); |
| | | List<ThiedInhospInfo> thiedInhospInfoList = gson.fromJson(resultArray, resultType); |
| | | |
| | | // 创建一个新文件 |
| | | String filename = null; |
| | | if (cry.equals("0")) filename = "入院信息" + System.currentTimeMillis(); |
| | | if (cry.equals("1")) filename = "出院信息" + System.currentTimeMillis(); |
| | | File file = new File("D:\\public\\华卓集成平台数据\\" + filename); |
| | | if (!file.exists()) { |
| | | // 如果文件不存在,则创建新文件 |
| | | try { |
| | | if (file.createNewFile()) { |
| | | System.out.println("成功创建了新文件!"); |
| | | } else { |
| | | System.out.println("失败!文件无法创建!"); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | // 将数据写入到文件中 |
| | | try { |
| | | FileWriter writer = new FileWriter(file); |
| | | writer.write(result); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(thiedInhospInfoList)) { |
| | | for (ThiedInhospInfo thiedInhospInfo : thiedInhospInfoList) { |
| | | //通过身份证号查询该患者在患者表是否存在 |
| | |
| | | inhosp.setPatno(patArchive.getPatientno()); |
| | | inhosp.setSerialnum(patMedInhosp.getSerialnum()); |
| | | List<PatMedInhosp> patMedInhosps = patMedInhospService.selectPatMedInhospList(inhosp); |
| | | log.error("是否需要更新:{}", patMedInhosps.size()); |
| | | if (CollectionUtils.isNotEmpty(patMedInhosps)) { |
| | | patMedInhosp.setInhospid(patMedInhosps.get(0).getInhospid()); |
| | | patMedInhospService.updatePatMedInhosp(patMedInhosp); |
| | | } else { |
| | | patMedInhospService.insertPatMedInhosp(patMedInhosp); |