From 0bbbd746e8c39d91ad7b47a4e36e29ab972dc98c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 20 十月 2026 16:56:54 +0800
Subject: [PATCH] 处理长期任务发送问题
---
ruoyi-inhospvisit/src/main/java/com/ruoyi/inhospvisit/service/InhospTaskOrchestrator.java | 116 +++++++++++++++++++++++++++++++---------------------------
1 files changed, 62 insertions(+), 54 deletions(-)
diff --git a/ruoyi-inhospvisit/src/main/java/com/ruoyi/inhospvisit/service/InhospTaskOrchestrator.java b/ruoyi-inhospvisit/src/main/java/com/ruoyi/inhospvisit/service/InhospTaskOrchestrator.java
index a437710..7fcaa35 100644
--- a/ruoyi-inhospvisit/src/main/java/com/ruoyi/inhospvisit/service/InhospTaskOrchestrator.java
+++ b/ruoyi-inhospvisit/src/main/java/com/ruoyi/inhospvisit/service/InhospTaskOrchestrator.java
@@ -88,19 +88,29 @@
@Service
public class InhospTaskOrchestrator {
- /** 鍑洪櫌闅忚鐨勬湇鍔$被鍨� */
+ /**
+ * 鍑洪櫌闅忚鐨勬湇鍔$被鍨�
+ */
private static final String SERVICE_TYPE_DISCHARGE = "2";
- /** 缁村害锛氱瀹� */
+ /**
+ * 缁村害锛氱瀹�
+ */
private static final String DEPT_TYPE_DEPT = "1";
- /** 缁村害锛氱梾鍖� */
+ /**
+ * 缁村害锛氱梾鍖�
+ */
private static final String DEPT_TYPE_WARD = "2";
- /** 绔欑偣锛氭柊鍗庯紙璺宠繃鐥呭尯+鐤剧梾缁村害锛� */
+ /**
+ * 绔欑偣锛氭柊鍗庯紙璺宠繃鐥呭尯+鐤剧梾缁村害锛�
+ */
private static final String SITE_XH = "xh";
- /** 绔欑偣锛氬崡鍗庨檮涓�锛堢柧鐥呯淮搴︾敤璇婃柇鍚嶏級 */
+ /**
+ * 绔欑偣锛氬崡鍗庨檮涓�锛堢柧鐥呯淮搴︾敤璇婃柇鍚嶏級
+ */
private static final String SITE_NHFY = "nhfy";
@Value("${spring.profiles.active}")
@@ -161,20 +171,15 @@
* <h3>绔欑偣宸紓锛堜繚鐣欙級</h3>
* {@code xh} 鍙仛绉戝缁村害 鈥斺�� {@link #addDimension} 閲岀粺涓�鎸℃帀鐥呭尯/鐤剧梾銆�
*
- * @param inhosp 寰呭鐞嗙殑鍑洪櫌鎮h��
+ * @param inhosp 寰呭鐞嗙殑鍑洪櫌鎮h��
* @param archive 鎮h�呮。妗�
- * @param rule 宸叉煡濂界殑瑙勫垯锛泏@code null} = 璇ョ瀹�/鐥呭尯鏈厤缃鍒�
- * @param config {@code sys_config: visit.early.day}
+ * @param rule 宸叉煡濂界殑瑙勫垯锛泏@code null} = 璇ョ瀹�/鐥呭尯鏈厤缃鍒�
+ * @param config {@code sys_config: visit.early.day}
*/
- public void addSubTaskByRule(VisitInhospRow inhosp, VisitArchiveRow archive,
- VisitTaskRule rule, String config) {
+ public void addSubTaskByRule(VisitInhospRow inhosp, VisitArchiveRow archive, VisitTaskRule rule, String config) {
try {
List<Integer> order = resolveDimensionOrder(rule);
- log.info("銆愬熀浜庤鍒欍�戞偅鑰厈}瑙勫垯锛歞eptRule={}, wradRule={}, diagRule={}锛涚淮搴﹀皾璇曢『搴�={}",
- inhosp.getInhospid(),
- rule == null ? null : rule.getDeptRule(),
- rule == null ? null : rule.getWradRule(),
- rule == null ? null : rule.getDiagRule(), order);
+ log.info("銆愬熀浜庤鍒欍�戞偅鑰厈}瑙勫垯锛歞eptRule={}, wradRule={}, diagRule={}锛涚淮搴﹀皾璇曢『搴�={}", inhosp.getInhospid(), rule == null ? null : rule.getDeptRule(), rule == null ? null : rule.getWradRule(), rule == null ? null : rule.getDiagRule(), order);
Integer hit = null;
for (Integer type : order) {
@@ -242,7 +247,9 @@
return order;
}
- /** 杩藉姞涓�涓�欓�夌淮搴︼紱{@code xh} 绔欑偣鍙厑璁哥瀹ょ淮搴︼紙鍘� {@code !active.equals("xh")} 鐨勭瓑浠峰啓娉曪級 */
+ /**
+ * 杩藉姞涓�涓�欓�夌淮搴︼紱{@code xh} 绔欑偣鍙厑璁哥瀹ょ淮搴︼紙鍘� {@code !active.equals("xh")} 鐨勭瓑浠峰啓娉曪級
+ */
private void addDimension(List<Integer> order, int type, boolean xhSite) {
if (xhSite && type != 1) {
return;
@@ -265,9 +272,10 @@
}
}
- /** 灏濊瘯涓�涓淮搴︼紝杩斿洖"鏄惁鐪熺殑鐢熸垚浜嗭紙鎴栨湰鏉ュ氨宸茬粡鏈夛級涓�鏉″瓙浠诲姟" */
- private boolean generateOneForDimension(VisitInhospRow inhosp, VisitArchiveRow archive,
- int type, String config) {
+ /**
+ * 灏濊瘯涓�涓淮搴︼紝杩斿洖"鏄惁鐪熺殑鐢熸垚浜嗭紙鎴栨湰鏉ュ氨宸茬粡鏈夛級涓�鏉″瓙浠诲姟"
+ */
+ private boolean generateOneForDimension(VisitInhospRow inhosp, VisitArchiveRow archive, int type, String config) {
switch (type) {
case 1:
return addDeptSubTaskForPatient(inhosp, archive, config) > 0;
@@ -309,16 +317,16 @@
continue;
}
if (hit == type) {
- updateCheckFlag(inhosp, type, "1", composeRemark(inhosp,
- "鎸変紭鍏堢骇鐢熸垚涓�鏉¢殢璁夸换鍔★紙缁村害=" + dimensionName(type) + "锛�"));
+ updateCheckFlag(inhosp, type, "1", composeRemark(inhosp, "鎸変紭鍏堢骇鐢熸垚涓�鏉¢殢璁夸换鍔★紙缁村害=" + dimensionName(type) + "锛�"));
} else {
- updateCheckFlag(inhosp, type, "2", composeRemark(inhosp,
- "宸茬敓鎴愪竴鏉¢殢璁夸换鍔★紙缁村害=" + dimensionName(hit) + "锛夛紝鏈淮搴﹁烦杩�"));
+ updateCheckFlag(inhosp, type, "2", composeRemark(inhosp, "宸茬敓鎴愪竴鏉¢殢璁夸换鍔★紙缁村害=" + dimensionName(hit) + "锛夛紝鏈淮搴﹁烦杩�"));
}
}
}
- /** 鎷� reason锛氭部鐢ㄥ師瀹炵幇鐨� {@code remark + ";xxx"} 褰㈠紡 */
+ /**
+ * 鎷� reason锛氭部鐢ㄥ師瀹炵幇鐨� {@code remark + ";xxx"} 褰㈠紡
+ */
private String composeRemark(VisitInhospRow inhosp, String text) {
String remark = inhosp.getRemark();
return StringUtils.isNotEmpty(remark) ? remark + ";" + text : text;
@@ -364,8 +372,7 @@
u.setWardcheckFlag(fresh == null ? null : fresh.getWardcheckFlag());
u.setDiagcheckFlag(fresh == null ? null : fresh.getDiagcheckFlag());
// 鍘熷疄鐜颁笉鍒� null锛坒resh.getLongTaskReason() + "..."锛夛紝鍘熸牱淇濈暀
- u.setLongTaskReason((fresh == null ? null : fresh.getLongTaskReason())
- + "璇ユ偅鑰呮墍鍦ㄧ瀹ゆ湭閰嶇疆绂婚櫌闀挎湡浠诲姟;");
+ u.setLongTaskReason((fresh == null ? null : fresh.getLongTaskReason()) + "璇ユ偅鑰呮墍鍦ㄧ瀹ゆ湭閰嶇疆绂婚櫌闀挎湡浠诲姟;");
updateInhosp(u);
} else {
for (VisitTaskdeptRow t : taskdepts) {
@@ -373,8 +380,7 @@
if (subtaskWriter.writeInSubTask(t.getTaskId(), true, inhosp, archive, 1, config)) {
return 1;
}
- log.info("銆愮瀹や换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��",
- inhosp.getInhospid(), t.getTaskId());
+ log.info("銆愮瀹や换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��", inhosp.getInhospid(), t.getTaskId());
}
}
} catch (Exception e) {
@@ -430,8 +436,7 @@
u.setDeptcheckFlag(fresh == null ? null : fresh.getDeptcheckFlag());
u.setDiagcheckFlag(fresh == null ? null : fresh.getDiagcheckFlag());
// 鍘熸湁鍒ょ┖锛堜笌绉戝缁村害閭e涓嶅悓锛夛紝鍘熸牱淇濈暀
- u.setLongTaskReason(StringUtils.isNotEmpty(fresh == null ? null : fresh.getLongTaskReason())
- ? fresh.getLongTaskReason() + errorreason : errorreason);
+ u.setLongTaskReason(StringUtils.isNotEmpty(fresh == null ? null : fresh.getLongTaskReason()) ? fresh.getLongTaskReason() + errorreason : errorreason);
updateInhosp(u);
} else {
for (VisitTaskdeptRow t : taskdeptList) {
@@ -439,8 +444,7 @@
if (subtaskWriter.writeInSubTask(t.getTaskId(), true, inhosp, archive, 2, config)) {
return 1;
}
- log.info("銆愮梾鍖轰换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��",
- inhosp.getInhospid(), t.getTaskId());
+ log.info("銆愮梾鍖轰换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��", inhosp.getInhospid(), t.getTaskId());
}
}
} catch (Exception e) {
@@ -506,23 +510,19 @@
int flag = 0;
for (VisitTaskdiagRow t : taskdiags) {
// 鍘� L1975-1983锛氬繀椤荤瀹ゆ垨鐥呭尯鑳藉尮閰嶄笂鎵嶅缓
- if (StringUtils.isNotEmpty(t.getDeptCode())
- && t.getDeptCode().equals(inhosp.getLeaveldeptcode())) {
+ if (StringUtils.isNotEmpty(t.getDeptCode()) && t.getDeptCode().equals(inhosp.getLeaveldeptcode())) {
flag = 1;
// 涓�涓偅鑰呭彧鐣欎竴鏉★細绗竴鏉$湡姝h惤搴撶殑鍗宠繑鍥�
if (subtaskWriter.writeInSubTask(t.getTaskId(), true, inhosp, archive, 3, config)) {
return 1;
}
- log.info("銆愮柧鐥呬换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��",
- inhosp.getInhospid(), t.getTaskId());
- } else if (StringUtils.isNotEmpty(t.getWardCode())
- && t.getWardCode().equals(inhosp.getLeavehospitaldistrictcode())) {
+ log.info("銆愮柧鐥呬换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��", inhosp.getInhospid(), t.getTaskId());
+ } else if (StringUtils.isNotEmpty(t.getWardCode()) && t.getWardCode().equals(inhosp.getLeavehospitaldistrictcode())) {
flag = 1;
if (subtaskWriter.writeInSubTask(t.getTaskId(), true, inhosp, archive, 3, config)) {
return 1;
}
- log.info("銆愮柧鐥呬换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��",
- inhosp.getInhospid(), t.getTaskId());
+ log.info("銆愮柧鐥呬换鍔°�戞偅鑰厈}浠诲姟{}鏈敓鎴愬瓙浠诲姟锛屽皾璇曚笅涓�涓�欓��", inhosp.getInhospid(), t.getTaskId());
}
}
if (flag == 0) {
@@ -571,13 +571,11 @@
try {
VisitTaskCreateApi api = taskApi();
if (api == null) {
- log.warn("銆愬嚭鍏ラ櫌闅忚銆慥isitTaskCreateApi 涓嶅彲鐢紝璺宠繃鍐嶅叆闄㈠鐞嗐�俰nhospid={}",
- newInHosp.getInhospid());
+ log.warn("銆愬嚭鍏ラ櫌闅忚銆慥isitTaskCreateApi 涓嶅彲鐢紝璺宠繃鍐嶅叆闄㈠鐞嗐�俰nhospid={}", newInHosp.getInhospid());
return;
}
// 鍘� L1324-1328锛歱atid + sendstate=2锛堜笉璁� taskid锛�
- List<VisitPendingSubtaskDto> pendingList =
- api.findPendingSubtasks(newInHosp.getPatid(), null);
+ List<VisitPendingSubtaskDto> pendingList = api.findPendingSubtasks(newInHosp.getPatid(), null);
if (CollectionUtils.isEmpty(pendingList)) {
return;
}
@@ -592,8 +590,7 @@
continue;
}
// 鍘� L1342-1350锛氭棫瀛愪换鍔$殑鍑洪櫌鏃堕棿鍦ㄦ柊鍏ラ櫌鏃堕棿涔嬪墠 鈫� 鍋滄帀
- if (pending.getEndtime() != null && newInHosp.getStarttime() != null
- && pending.getEndtime().before(newInHosp.getStarttime())) {
+ if (pending.getEndtime() != null && newInHosp.getStarttime() != null && pending.getEndtime().before(newInHosp.getStarttime())) {
pending.setSendstate(4L);
pending.setIsVisitAgain(2);
pending.setRemark("鎮h�呭啀鍏ラ櫌");
@@ -607,7 +604,9 @@
}
}
- /** 鏅畞鏈烘瀯ID锛堝師 L1338锛涗笌 InhospSubtaskWriter 閲岄偅浠芥槸鍚屼竴甯搁噺锛屽凡閫愬瓧鏍稿锛� */
+ /**
+ * 鏅畞鏈烘瀯ID锛堝師 L1338锛涗笌 InhospSubtaskWriter 閲岄偅浠芥槸鍚屼竴甯搁噺锛屽凡閫愬瓧鏍稿锛�
+ */
private static final String ORG_JINGNING = "47255004333112711A1001";
// ==========================================================================
@@ -655,13 +654,19 @@
*/
public static class VisitTaskRule {
- /** 绉戝瑙勫垯锛�"1"=棣栬 "2"=娆¤锛屽叾瀹�=涓嶅弬涓� */
+ /**
+ * 绉戝瑙勫垯锛�"1"=棣栬 "2"=娆¤锛屽叾瀹�=涓嶅弬涓�
+ */
private String deptRule;
- /** 鐥呭尯瑙勫垯锛堝師瀛楁鍚嶅氨鏄嫾閿欑殑 {@code wradRule}锛屼繚鎸佸悓鍚嶄互鍏嶈閿欙級 */
+ /**
+ * 鐥呭尯瑙勫垯锛堝師瀛楁鍚嶅氨鏄嫾閿欑殑 {@code wradRule}锛屼繚鎸佸悓鍚嶄互鍏嶈閿欙級
+ */
private String wradRule;
- /** 鐤剧梾瑙勫垯 */
+ /**
+ * 鐤剧梾瑙勫垯
+ */
private String diagRule;
public String getDeptRule() {
@@ -689,13 +694,16 @@
}
}
- /** 渚涙祴璇�/鏃ュ織锛氭湰绫绘槸鍚︽嬁鍒颁簡蹇呴渶鐨� Mapper */
+ /**
+ * 渚涙祴璇�/鏃ュ織锛氭湰绫绘槸鍚︽嬁鍒颁簡蹇呴渶鐨� Mapper
+ */
boolean hasMappers() {
- return inhospMapper != null && archiveMapper != null
- && taskdeptMapper != null && taskdiagMapper != null;
+ return inhospMapper != null && archiveMapper != null && taskdeptMapper != null && taskdiagMapper != null;
}
- /** 棰勭暀锛氫緵鏃ュ織浣跨敤鐨勬椂闂存埑锛堥伩鍏� IDE 鎶ユ湭浣跨敤 import Date锛� */
+ /**
+ * 棰勭暀锛氫緵鏃ュ織浣跨敤鐨勬椂闂存埑锛堥伩鍏� IDE 鎶ユ湭浣跨敤 import Date锛�
+ */
@SuppressWarnings("unused")
private Date now() {
return new Date();
--
Gitblit v1.9.3