From 10aaa035f5be0312304d20f022bdb714a8f4900a Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 11 十二月 2024 22:16:23 +0800
Subject: [PATCH] 代码提交
---
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 488 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 335 insertions(+), 153 deletions(-)
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 89d4236..dd4509f 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -2,6 +2,9 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -9,29 +12,40 @@
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 com.smartor.common.SendService;
import com.smartor.domain.*;
+import com.smartor.mapper.ServiceSubtaskMapper;
import com.smartor.mapper.ServiceTaskMapper;
+import com.smartor.mapper.SysUserImportMapper;
import com.smartor.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
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;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -47,6 +61,9 @@
private IServiceThirdDataService iServiceThirdDataService;
@Autowired
+ private IServiceOutPathService iServiceOutPathService;
+
+ @Autowired
private IServiceSubtaskAnswerService serviceSubtaskAnswerService;
@Autowired
@@ -56,10 +73,19 @@
private IServiceSubtaskService iServiceSubtaskService;
@Autowired
+ private IServicePatientTempService iServicePatientTempService;
+
+ @Autowired
private PlatformTransactionManager transactionManager;
+
+ @Autowired
+ private SysUserImportMapper sysUserImportMapper;
@Value("${localIP}")
private String localIP;
+
+ @Value("${xhsmsPath}")
+ private String xhsmsPath;
@Value("${pub_key}")
private String pub_key;
@@ -74,7 +100,7 @@
private ServiceTaskMapper serviceTaskMapper;
@Autowired
- private SendService sendService;
+ private ServiceSubtaskMapper serviceSubtaskMapper;
@Autowired
private RedisCache redisCache;
@@ -97,6 +123,9 @@
@Autowired
ISvyTaskTemplateService svyTaskTemplateService;
+ @Autowired
+ IIvrTaskTemplateService iIvrTaskTemplateService;
+
@Value("${hosp_info_url}")
private String hospInfoUrl;
@@ -110,6 +139,34 @@
public void ryNoParams() {
System.out.println("鎵ц鏃犲弬鏂规硶");
+ }
+
+ public void importData() {
+ String filePath = "C:\\Users\\86176\\Desktop\\鏂板缓鏂囨湰鏂囨。 4.txt"; // 鏇挎崲涓轰綘鐨勬枃浠惰矾寰�
+
+ try {
+ // 璇诲彇鏂囦欢鍐呭
+ String jsonContent = new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8);
+
+ // 鍒涘缓ObjectMapper瀵硅薄
+ ObjectMapper objectMapper = new ObjectMapper();
+ // 瑙f瀽JSON涓篔sonNode
+ JsonNode rootNode = objectMapper.readTree(jsonContent);
+ // 鑾峰彇resultList
+ JsonNode resultListNode = rootNode.path("results").path("resultList");
+ // 閬嶅巻resultList涓殑姣忎釜瀵硅薄
+ for (JsonNode item : resultListNode) {
+
+ SysUserImport person = objectMapper.treeToValue(item, SysUserImport.class);
+ person.setStaffPhoto("");
+ sysUserImportMapper.insertSysUserImport(person);
+
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
}
public void analysisData() {
@@ -138,8 +195,13 @@
//灏嗘偅鑰呬俊鎭�佸嚭闄€�侀棬璇婃暟鎹叏閮ㄩ噰闆�
// 鑾峰彇褰撳墠鏃ユ湡鍜屾椂闂�
LocalDateTime endTime = LocalDateTime.now();
+ endTime = endTime.with(LocalTime.MIN);
+// String dateStr = "2024/11/30 00:00:00";
+// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
+// LocalDateTime endTime = LocalDateTime.parse(dateStr, formatter);
// 鑾峰彇鍓嶄竴澶╃殑鏃ユ湡鍜屾椂闂�
LocalDateTime startTime = endTime.minusDays(1);
+ startTime = startTime.with(LocalTime.MIN);
getInHospInfo("0", startTime, endTime);
getInHospInfo("1", startTime, endTime);
@@ -176,7 +238,18 @@
}
/**
- * 闀挎湡浠诲姟鎵ц
+ * 澶勭悊鎮h�呬俊鎭紝杩涘叆瀛愪换鍔¤〃(寰俊灏忕▼搴�)
+ */
+ public void dealOutHospInfoXHC() {
+ PatMedInhosp patMedInhosp = new PatMedInhosp();
+ //鑾峰彇鏈鐞嗙殑鏁版嵁
+ List<ServicePatientTemp> servicePatientTemps = iServicePatientTempService.selectServicePatientTempList(new ServicePatientTemp());
+
+ }
+
+
+ /**
+ * 闀挎湡浠诲姟鎵ц锛堢數璇濓級
*/
public void longTaskSend() {
//鑾峰彇浠诲姟淇℃伅
@@ -186,60 +259,11 @@
List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st);
log.error("serviceTasks杩涙潵浜嗗悧锛焮}", serviceTasks);
for (ServiceTask serviceTask : serviceTasks) {
-
- //閫氳繃taskId,鑾峰彇鏈墽琛岀殑瀛愪换鍔′俊鎭�
- ServiceSubtaskVO serviceSubtask = new ServiceSubtaskVO();
- serviceSubtask.setTaskid(serviceTask.getTaskid());
- serviceSubtask.setSendstate(2L);
- List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask);
- log.error("selectServiceSubtaskList杩涙潵浜嗗悧锛焮}", selectServiceSubtaskList);
- if (CollectionUtils.isNotEmpty(selectServiceSubtaskList)) {
- for (ServiceSubtask serviceSubtask1 : selectServiceSubtaskList) {
- //濡傛灉鎮h�呯殑鍙戦�佹棩鏈熸槸浠婂ぉ锛屽垯杩涜鍙戦��
- try {
- boolean dateToday = isDateToday(serviceSubtask1.getLongSendTime());
- if (dateToday) {
- //鍏堝垽鏂偅鑰呮槸涓嶆槸杩樿鍙戦��
- PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtask1.getPatid());
- if (!Objects.isNull(patArchive) && patArchive.getNotrequiredFlag() == "1") {
- //涓嶉渶瑕佸彂閫�
- serviceSubtask1.setResult("error");
- serviceSubtask1.setRemark(patArchive.getNotrequiredreason());
- serviceSubtask1.setSendstate(4L);
- serviceSubtask1.setFinishtime(new Date());
- iServiceSubtaskService.insertServiceSubtask(serviceSubtask1);
- continue;
- }
-
- log.error("dateToday杩涙潵浜嗗悧锛焮}", dateToday);
- CommonTaskcallMQ commonTaskcallMQ = new CommonTaskcallMQ();
- commonTaskcallMQ.setTaskid(serviceTask.getTaskid());
- commonTaskcallMQ.setPreachform(serviceSubtask1.getServiceform());
- commonTaskcallMQ.setSendType("2");
- Map<String, Object> map = sfHandlle(commonTaskcallMQ, localIP);
- //鍙戦�佸畬鎴愬悗锛屼慨鏀圭姸鎬�
- serviceSubtask1.setSendstate(3L);
- if ((Boolean) map.get("succ") == false) {
- serviceSubtask1.setResult("success");
- } else {
- serviceSubtask1.setResult("error");
- serviceSubtask1.setRemark(map.get("msg").toString());
- }
- iServiceSubtaskService.updateServiceSubtask(serviceSubtask1);
- }
- } catch (Exception e) {
- String guid = UUID.randomUUID().toString();
- log.error("闀挎湡浠诲姟锛屽彂閫佸け璐ュ師鍥狅細{},{}", e.getMessage(), guid);
- serviceSubtask1.setResult("error");
- serviceSubtask1.setRemark("绯荤粺閿欒");
- serviceSubtask1.setSendstate(5L);
- serviceSubtask1.setFinishtime(new Date());
- serviceSubtask1.setGuid(guid);
- iServiceSubtaskService.insertServiceSubtask(serviceSubtask1);
- }
- }
- }
-
+ CommonTaskcallMQ commonTaskcallMQ = new CommonTaskcallMQ();
+ commonTaskcallMQ.setTaskid(serviceTask.getTaskid());
+ commonTaskcallMQ.setPreachform(serviceTask.getPreachform());
+ commonTaskcallMQ.setSendType("2");
+ sfHandlle(commonTaskcallMQ, localIP);
}
}
@@ -250,6 +274,11 @@
* @return
*/
public boolean isDateToday(Date date) {
+ //濡傛灉缁欑殑鏃ユ湡灏忎簬褰撳墠鏃ユ湡锛屼篃鐩存帴鍙戦��
+ LocalDateTime localDateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+ if (localDateTime.isBefore(LocalDateTime.now())) {
+ return true;
+ }
// 鑾峰彇褰撳墠鏃ユ湡
Calendar calendarNow = Calendar.getInstance();
int todayYear = calendarNow.get(Calendar.YEAR);
@@ -264,7 +293,7 @@
return (calendarToCheck.get(Calendar.YEAR) == todayYear && calendarToCheck.get(Calendar.MONTH) == todayMonth && calendarToCheck.get(Calendar.DAY_OF_MONTH) == todayDay);
}
- public Map<String, Object> sfHandlle(CommonTaskcallMQ commonTaskcallMQ, String ip) {
+ public void sfHandlle(CommonTaskcallMQ commonTaskcallMQ, String ip) {
log.error("sfHandlle杩涙潵浜嗗悧锛焮}", commonTaskcallMQ);
//鍒ゆ柇涓�涓媍ommonTaskcallMQ涓殑stopstate鏄惁涓巌vr_task涓殑涓�鑷达紝涓嶄竴鑷达紝鍒欒鏄庢槸鏆傚仠浜�
ServiceTask ivrTask1 = serviceTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid());
@@ -279,89 +308,157 @@
//閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭�
ServiceSubtaskVO ivrTaskcall = new ServiceSubtaskVO();
ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid());
+ ivrTaskcall.setSendstate(2L);
List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(ivrTaskcall);
if (descByCode.equals("鐢佃瘽")) {
+ String value = "";
for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
ServiceTask ivrTask = serviceTaskMapper.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) {
//濡備綍浠诲姟琚�滄殏鍋溾�濇垨鈥滅粓姝⑩��
break;
}
- //鑾峰彇鍒皏alue鍊兼渶灏戠殑key
- String key = getKey();
- if (commonTaskcallMQ.getSendType().equals("2")) {
- //璇存槑鏄珛鍗冲彂閫�
- String value = redisCache.getCacheObject("cache-0");
- ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO();
- serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid());
- List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1);
- for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) {
+ boolean dateToday = isDateToday(serviceSubtask.getLongSendTime());
+ //璇存槑鏄珛鍗冲彂閫�(鍏堟妸娑堟伅鏀惧埌cache-0涓紝 displayNo涓嶇煡閬撴�庝箞閰嶇疆)
+ if (dateToday) {
+ try {
+// ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO();
+// serviceSubtask1.setTaskid(ivrTask.getTaskid());
+// List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1);
+// for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) {
if (StringUtils.isEmpty(value)) {
- value = "," + serviceSubtask2.getId().toString() + ",";
+ value = "," + serviceSubtask.getId().toString() + ",";
} else {
- value = value + "," + serviceSubtask2.getId().toString() + ",";
+ if (!value.contains("," + serviceSubtask.getId().toString()))
+ value = value + "," + serviceSubtask.getId().toString() + ",";
}
+// }
+ } catch (Exception e) {
+ String guid = UUID.randomUUID().toString();
+ log.error("闀挎湡浠诲姟锛岀數璇濆彂閫佸け璐ュ師鍥狅細{},{}", e.getMessage(), guid);
+ serviceSubtask.setResult("error");
+ serviceSubtask.setRemark("绯荤粺閿欒");
+ serviceSubtask.setSendstate(3L);
+ serviceSubtask.setFinishtime(new Date());
+ serviceSubtask.setGuid(guid);
+ iServiceSubtaskService.updateServiceSubtask(serviceSubtask);
}
- redisCache.setCacheObject("cache-0", value);
- } else {
- //闈炵珛鍗冲彂閫�
- String value = redisCache.getCacheObject(key);
- ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO();
- serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid());
- List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1);
- for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) {
- if (StringUtils.isEmpty(value)) {
- value = "," + serviceSubtask2.getId().toString() + ",";
- } else {
- value = value + "," + serviceSubtask2.getId().toString() + ",";
- }
- }
- redisCache.setCacheObject(key, value);
+
+ //鍦ㄥ瓙浠诲姟琛ㄩ噷璁板綍涓�涓�
+ String uuid = UUID.randomUUID().toString();
+ serviceSubtask.setResult("success");
+ serviceSubtask.setRemark("闀挎湡浠诲姟锛岀數璇濊繘鍏ラ槦鍒楁垚鍔�");
+ serviceSubtask.setGuid(uuid);
+ serviceSubtask.setSendstate(3L);
+ serviceSubtask.setFinishtime(new Date());
+ serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+
+ //浠诲姟鍙戦�佽褰�
+ ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
+ serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
+ serviceSubtaskRecord.setSubtaskId(serviceSubtask.getId());
+ serviceSubtaskRecord.setUuid(uuid);
+ serviceSubtaskRecord.setTasktype(serviceSubtask.getType());
+ serviceSubtaskRecord.setPreachform("3");
+ serviceSubtaskRecord.setStartTime(System.currentTimeMillis());
+ serviceSubtaskRecord.setRemark("闀挎湡浠诲姟锛岀數璇濊繘鍏ラ槦鍒楁垚鍔�");
+ serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
+
}
-
- //浠诲姟鍙戦�佽褰曪紙杩欎釜浠g爜搴旇鍐欏湪phoneTask涓紝鍏堝啓鍦ㄨ繖锛屽悗闈㈠啀鏀癸級
- ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord();
- serviceSubtaskRecord.setTaskid(serviceSubtask.getTaskid().toString());
- serviceSubtaskRecord.setUuid(UUID.randomUUID().toString());
- serviceSubtaskRecord.setTasktype(serviceSubtask.getType());
- serviceSubtaskRecord.setPreachform("3");
- serviceSubtaskRecord.setStartTime(System.currentTimeMillis());
- serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
-
-// //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽
+// //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽锛堣繖涓槸涓婃捣鐨勬柟娉曪級
// executorService.submit(new PhoneTask(serviceSubtask, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils));
+ }
+ //灏嗚鎵ц鐨勬斁鍒扮紦瀛樹腑
+ String cache0 = redisCache.getCacheObject("cache-0");
+ if (StringUtils.isNotEmpty(cache0)) {
+ redisCache.setCacheObject("cache-0", cache0 + value);
+ } else if (StringUtils.isEmpty(cache0) && StringUtils.isNotEmpty(value)) {
+ redisCache.setCacheObject("cache-0", value);
}
} else if (descByCode.equals("澶氬獟浣�")) {
//澶氬獟浣�
- return null;
} else if (descByCode.equals("绾歌川")) {
//绾歌川
- return null;
+ } else if (descByCode.equals("寰俊灏忕▼搴�")) {
+ //寰俊灏忕▼搴�
+ for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
+ log.error("寰俊灏忕▼搴忔湡浠诲姟鍙戦��---------杩涙潵浜嗗悧锛焮}", serviceSubtask);
+
+
+ }
} else if (descByCode.equals("鐭俊")) {
- //鐭俊
-// http://localhost:8099/followvisit/particty?param1=3¶m2=348
- //瀵箄rl涓袱涓弬鏁板姞瀵�
RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
-
for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
- 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);
+ 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);
- //浠诲姟鍙戦�佽褰�
- 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);
- return null;
+ //鍙戦�佸畬鎴愬悗锛屼慨鏀圭姸鎬�
+ serviceSubtask.setSendstate(3L);
+ if (StringUtils.isNotEmpty(isSuccess) && !isSuccess.equals("true")) {
+ serviceSubtask.setResult("success");
+ serviceSubtask.setRemark("鐭俊鍙戦�佹垚鍔�");
+ } 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("鍏紬鍙�")) {
log.error("鍏紬鍙疯繘鏉ヤ簡鍚楋紵{}", descByCode);
@@ -370,34 +467,64 @@
String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
log.error("serviceSubtask---------杩涙潵浜嗗悧锛焮}", serviceSubtask);
- String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
- String url = null;
- try {
- url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false";
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "鏃�");
- Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class);
+ 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);
+ String url = null;
+ url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "¶m2=" + patid + "¶m3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "¶m5=false";
+ String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "鏃�");
+ Map<String, Object> map = JSONObject.parseObject(wxCode, Map.class);
- //浠诲姟鍙戦�佽褰�
- 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 (!map.isEmpty() && (Boolean) map.get("succ") == false)
- serviceSubtaskRecord.setResult("error");
- serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
- return map;
+ //浠诲姟鍙戦�佽褰�
+ 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 (!map.isEmpty() && (Boolean) map.get("succ") == false)
+ serviceSubtaskRecord.setResult("error");
+ serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord);
+
+ //鍙戦�佸畬鎴愬悗锛屼慨鏀圭姸鎬�
+ serviceSubtask.setSendstate(3L);
+ if ((Boolean) map.get("succ") == true) {
+ serviceSubtask.setResult("success");
+ } else {
+ serviceSubtask.setResult("error");
+ serviceSubtask.setSendstate(5L);
+ serviceSubtask.setRemark(map.get("msg").toString());
+ }
+ 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);
+ }
+ }
}
}
//閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛�
}
}
- return null;
}
@@ -407,16 +534,12 @@
*/
@Transactional
public void getInHospInfo(String cry, LocalDateTime startTime, LocalDateTime endTime) {
- // 鑾峰彇褰撳墠鏃ユ湡鍜屾椂闂�
- LocalDateTime currentDateTime = LocalDateTime.now();
- // 鑾峰彇鍓嶄竴澶╃殑鏃ユ湡鍜屾椂闂�
- LocalDateTime previousDateTime = currentDateTime.minusDays(1);
// 瀹氫箟鏃ユ湡鏃堕棿鏍煎紡
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
Map<String, String> req = new HashMap<>();
if (cry.equals("1")) {
- req.put("startTime", startTime.format(formatter));
- req.put("endTime", endTime.format(formatter));
+ req.put("cashStartDate", startTime.format(formatter));
+ req.put("cashEndDate", endTime.format(formatter));
req.put("currStatus", "4");
} else if (cry.equals("0")) {
req.put("admissStartDate", startTime.format(formatter));
@@ -428,7 +551,7 @@
header.put("x-hcsb-version", "2.0");
header.put("x-hcsb-sourcesyscode", "14");
header.put("x-hcsb-token", "ArGE2JnHtxG/Zx5nrnGY4eOfMUJGGJokAJHigG1BrCY=");
- header.put("x-hcsb-msgdate", currentDateTime.format(formatter));
+ header.put("x-hcsb-msgdate", startTime.format(formatter));
String result = HttpUtils.sendPostByHeader(hospInfoUrl, new Gson().toJson(req), header);
//鏁版嵁瑙f瀽
Gson gson = new Gson();
@@ -437,6 +560,32 @@
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) {
//閫氳繃韬唤璇佸彿鏌ヨ璇ユ偅鑰呭湪鎮h�呰〃鏄惁瀛樺湪
@@ -453,10 +602,15 @@
patArchive.setPatientno(thiedInhospInfo.getPatiMediaNo());
patArchive.setSourcefrom(2);
patArchive.setPattype("2");
- if (thiedInhospInfo.getOutWayId().equals("4")) {
+ if (StringUtils.isNotEmpty(thiedInhospInfo.getOutWayId()) && thiedInhospInfo.getOutWayId().equals("4")) {
//濡傛灉涓�4灏辨槸姝讳骸
patArchive.setNotrequiredFlag("1");
patArchive.setNotrequiredreason(thiedInhospInfo.getOutWayName());
+ }
+ if (cry.equals("1") && StringUtils.isEmpty(thiedInhospInfo.getOutWayId())) {
+ //鍑洪櫌鏂瑰紡涓虹┖
+ patArchive.setNotrequiredFlag("1");
+ patArchive.setNotrequiredreason("鍑洪櫌鏂瑰紡涓虹┖");
}
patArchive.setSex(thiedInhospInfo.getPatiRecordGender().equals("鐢�") ? 1L : 2L);
patArchive.setNation(thiedInhospInfo.getPatiNation());
@@ -468,7 +622,11 @@
} catch (ParseException e) {
e.printStackTrace();
}
- patArchive.setAge(Long.valueOf(thiedInhospInfo.getTreateAge()));
+ if (thiedInhospInfo.getTreateAge() != null) {
+ patArchive.setAge(Long.valueOf(thiedInhospInfo.getTreateAge()));
+ } else {
+ patArchive.setAge(null);
+ }
patArchive.setAgeUnit(thiedInhospInfo.getTreatAgeunit());
patArchive.setTelcode(thiedInhospInfo.getCompanyTelNum());
patArchive.setRelativetelcode(thiedInhospInfo.getContactPersonPhone());
@@ -478,8 +636,11 @@
patArchive.setName(thiedInhospInfo.getPatiRecordName());
patArchiveService.insertPatArchive(patArchive);
} else {
- patArchive = patArchives.get(0);
+ patArchive.setId(patArchives.get(0).getId());
+ patArchiveService.update(patArchive);
+// patArchive = patArchives.get(0);
}
+
log.error("鍏ュ弬鐨刾atArchive锛歿}", patArchive);
PatMedInhosp patMedInhosp = new PatMedInhosp();
patMedInhosp.setPatid(patArchive.getId());
@@ -503,8 +664,8 @@
e.printStackTrace();
}
try {
- if (StringUtils.isNotEmpty(thiedInhospInfo.getOutDate()))
- patMedInhosp.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getOutDate()));
+ if (StringUtils.isNotEmpty(thiedInhospInfo.getCashDate()))
+ patMedInhosp.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getCashDate()));
} catch (ParseException e) {
e.printStackTrace();
}
@@ -531,7 +692,20 @@
patMedInhosp.setLeavehospitaldistrictcode(thiedInhospInfo.getCurrWardId());
patMedInhosp.setLeavehospitaldistrictname(thiedInhospInfo.getCurrWardName());
patMedInhosp.setLeaveldeptid(thiedInhospInfo.getCurrDeptCode());
- patMedInhospService.insertPatMedInhosp(patMedInhosp);
+ //濡傛灉鏄嚭闄紝鍏堥�氳繃鎮h�呯紪鍙峰拰娴佹按鍙峰幓鏌ヤ竴涓嬶紝鎮h�呮槸鍚﹀瓨鍦紝濡傛灉瀛樺湪锛屽垯杩涜淇敼
+ PatMedInhosp inhosp = new PatMedInhosp();
+ 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());
+ log.error("------鎮h�呭嚭鍏ラ櫌淇敼淇℃伅锛歿}", patMedInhosp);
+ patMedInhospService.updatePatMedInhosp(patMedInhosp);
+ } else {
+ log.error("----鎮h�呭嚭鍏ラ櫌鏂板淇℃伅锛歿}", patMedInhosp);
+ patMedInhospService.insertPatMedInhosp(patMedInhosp);
+ }
}
}
@@ -577,7 +751,15 @@
String result = HttpUtils.sendPost(thirdWXUrl, new Gson().toJson(xinHuaWXReq));
JSONObject jsonObject = JSONObject.parseObject(result);
- String code = (String) jsonObject.get("code");
- return code;
+ log.error("jsonObject鐨勬暟鎹负锛歿}", jsonObject.toString());
+// String code = (String) jsonObject.get("code");
+ return jsonObject.toString();
}
+
+// public static void main(String[] args) {
+// LocalDateTime originalDateTime = LocalDateTime.now();
+// LocalDateTime startOfDay = originalDateTime.with(LocalTime.MIN);
+// System.out.println("Original DateTime: " + originalDateTime);
+// System.out.println("Start of Day: " + startOfDay);
+// }
}
--
Gitblit v1.9.3