From c24d16a37523a49080392610357872ce580cbc38 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 26 十月 2026 14:03:33 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 96 insertions(+), 17 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
index 41cb800..19130e6 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
@@ -11,9 +11,7 @@
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.StringUtils;
import com.smartor.domain.*;
-import com.smartor.domain.DTO.ServiceSubtaskDetailDTO;
-import com.smartor.domain.VO.ServiceSubtaskDetailTraceVO;
-import com.smartor.domain.entity.ServiceSubtaskEntity;
+import com.ruoyi.task.domain.VO.ServiceSubtaskDetailTraceVO;
import com.smartor.mapper.*;
import com.smartor.service.*;
import lombok.extern.slf4j.Slf4j;
@@ -29,6 +27,42 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+import com.ruoyi.template.domain.HeLibrary;
+import com.ruoyi.template.domain.IvrLibaScriptAssort;
+import com.ruoyi.inhospvisit.domain.PatMedInhosp;
+import com.ruoyi.outpatientvisit.domain.PatMedOuthosp;
+import com.ruoyi.outpatientvisit.domain.PatMedOuthospQueryReq;
+import com.ruoyi.inhospvisit.api.InhospVisitFacade;
+import com.ruoyi.outpatientvisit.api.OuthospDataFacade;
+import com.ruoyi.template.domain.IvrTaskTemplate;
+import com.ruoyi.template.domain.IvrTaskTemplateScriptVO;
+import com.ruoyi.template.domain.IvrTaskTemplateTargetoption;
+import com.ruoyi.template.service.IIvrTaskTemplateService;
+import com.ruoyi.template.domain.IvrLibaTemplateScript;
+import com.ruoyi.template.mapper.IvrLibaScriptAssortMapper;
+import com.ruoyi.template.service.IIvrLibaTemplateScriptService;
+import com.ruoyi.template.domain.SvyLibScriptCategory;
+import com.ruoyi.template.domain.SvyLibTemplateScript;
+import com.ruoyi.template.domain.SvyTaskTemplate;
+import com.ruoyi.template.domain.SvyTaskTemplateScriptVO;
+import com.ruoyi.template.domain.SvyTaskTemplateTargetoption;
+import com.ruoyi.template.mapper.SvyLibScriptCategoryMapper;
+import com.ruoyi.template.service.ISvyTaskTemplateService;
+import com.ruoyi.common.core.domain.entity.PatArchive;
+import com.ruoyi.task.domain.DTO.ServiceSubtaskDetailDTO;
+import com.ruoyi.task.domain.entity.ServiceSubtaskEntity;
+import com.ruoyi.task.domain.ServiceSubtask;
+import com.ruoyi.task.domain.ServiceSubtaskDetail;
+import com.ruoyi.task.domain.ServiceSubtaskDetailVO;
+import com.ruoyi.task.domain.ServiceTask;
+import com.ruoyi.task.domain.TaskSendTimeVO;
+import com.ruoyi.task.mapper.ServiceSubtaskDetailMapper;
+import com.ruoyi.task.mapper.ServiceSubtaskMapper;
+import com.ruoyi.task.domain.ServiceSubtaskDetailTrace;
+import com.ruoyi.task.domain.VO.ServiceSubtaskDetailTraceVO;
+import com.ruoyi.task.service.IServiceSubtaskDetailTraceService;
+import com.ruoyi.task.domain.ServiceSubtaskPreachform;
+import com.ruoyi.task.service.IServiceTaskService;
/**
* 浠诲姟闂嵎闂閫夐」Service涓氬姟灞傚鐞�
*
@@ -40,6 +74,18 @@
public class ServiceSubtaskAnswerServiceImpl implements IServiceSubtaskAnswerService {
@Autowired
private ServiceSubtaskAnswerMapper serviceSubtaskAnswerMapper;
+
+ /**
+ * 璺ㄦā鍧楄闂竴寰嬬粡妯″潡闂ㄩ潰锛堢姝㈢洿杩炲凡鎼蛋鐨� Mapper锛夈��
+ */
+ @Autowired
+ private OuthospDataFacade outhospDataFacade;
+
+ /**
+ * 璺ㄦā鍧楄闂竴寰嬬粡妯″潡闂ㄩ潰锛堢姝㈢洿杩炲凡鎼蛋鐨� Mapper锛夈��
+ */
+ @Autowired
+ private InhospVisitFacade inhospVisitFacade;
@Autowired
private ServiceSubtaskMapper serviceSubtaskMapper;
@@ -66,11 +112,7 @@
private PatArchiveMapper patArchiveMapper;
- @Autowired
- private PatMedInhospMapper patMedInhospMapper;
- @Autowired
- private PatMedOuthospMapper patMedOuthospMapper;
@Autowired
private IServiceSubtaskDetailTraceService traceService;
@@ -81,8 +123,6 @@
@Autowired
private ISvyLibTemplateScriptService svyLibTemplateScriptService;
- @Autowired
- private ISvyTaskTemplateTargetoptionService svyTaskTemplateTargetoptionService;
@Autowired
private IIvrTaskTemplateService ivrTaskTemplateService;
@@ -236,6 +276,8 @@
public Integer saveQuestionAnswer(ServiceSubTaskAnswerReq serviceSubTaskAnswerReq, Long flag) {
String threadName = Thread.currentThread().getName();
log.info("[{}] 寮�濮嬪紓姝ュ鐞嗕繚瀛橀棶鍗风瓟妗�", threadName);
+ // 骞傜瓑鍗犱綅閿細澶辫触鏃惰閲婃斁锛屽厑璁告偅鑰呴噸璇�
+ String idemKey = null;
try {
//鍙傛暟瑙e瘑
Long tid = null;
@@ -259,6 +301,17 @@
//鏍规嵁 PID銆乀ID銆丼UBID 鏋勫缓闇�瑕佸鐞嗙殑 cache key
String scriptCacheKeyPrefix = pid + "-" + tid + "-" + subid;
Set<String> targetKeys = new HashSet<>();
+
+ // ---------------- 骞傜瓑锛氬悓涓�浠介棶鍗� 60 绉掑唴鍙鐞嗕竴娆� ----------------
+ // 鏈柟娉曟槸 @Async 寮傛鎵ц锛屾偅鑰呯閲嶅鐐瑰嚮/缃戠粶閲嶈瘯浼氳瀹冨苟鍙戣窇澶氭锛�
+ // 姣忔閮戒細 upsert 涓�閬嶆槑缁嗭紱骞跺彂鏃跺郊姝ょ湅涓嶅埌瀵规柟杩樻病鎻愪氦鐨勮 -> 鎻掑叆閲嶅鍓湰
+ // 锛坣hfy 2026-09-08 灏辨槸杩欐牱鍫嗗嚭 2~6 浠斤紝骞朵笖鎶� del_flag 涓�璧峰啓鍧忥級銆�
+ idemKey = "subtaskAnswer:submit:" + scriptCacheKeyPrefix + ":"
+ + (serviceSubTaskAnswerReq == null || serviceSubTaskAnswerReq.getType() == null ? "all" : serviceSubTaskAnswerReq.getType());
+ if (!redisCache.setCacheObjectIfAbsent(idemKey, "1", 60, TimeUnit.SECONDS)) {
+ log.warn("[{}] 妫�娴嬪埌閲嶅鎻愪氦锛屾湰娆″拷鐣ワ細{}", threadName, idemKey);
+ return 0;
+ }
if (serviceSubTaskAnswerReq != null && serviceSubTaskAnswerReq.getType() != null) {
if (serviceSubTaskAnswerReq.getType() == 2) {
@@ -451,6 +504,14 @@
return 1;
} catch (Exception e) {
log.error("[{}] 寮傛澶勭悊淇濆瓨闂嵎绛旀鍙戠敓寮傚父 : {},璇锋眰鐨勫璞′负锛歿}", Thread.currentThread().getName(), e.getMessage(), e, serviceSubTaskAnswerReq);
+ // 澶勭悊澶辫触鏃堕噴鏀惧箓绛夐敭锛屽厑璁告偅鑰呴噸鏂版彁浜�
+ if (idemKey != null) {
+ try {
+ redisCache.deleteObject(idemKey);
+ } catch (Exception ignore) {
+ log.warn("[{}] 閲婃斁骞傜瓑閿け璐ワ細{}", Thread.currentThread().getName(), idemKey);
+ }
+ }
throw new RuntimeException("淇濆瓨闂嵎绛旀澶辫触", e);
}
}
@@ -613,13 +674,13 @@
//浣忛櫌
PatMedInhosp patMedInhosp = new PatMedInhosp();
patMedInhosp.setSerialnum(serviceSubTaskMYDAnswerReq.getSerialnum());
- patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
+ patMedInhospList = inhospVisitFacade.selectPatMedInhospList(patMedInhosp);
if (CollectionUtils.isNotEmpty(patMedInhospList)) patid = patMedInhospList.get(0).getPatid();
} else if (serviceSubTaskMYDAnswerReq.getMzzy().equals("2")) {
//闂ㄨ瘖
PatMedOuthospQueryReq patMedOuthosp = new PatMedOuthospQueryReq();
patMedOuthosp.setSerialnum(serviceSubTaskMYDAnswerReq.getSerialnum());
- patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthosp);
+ patMedOuthosps = outhospDataFacade.callSpQueryOuthosp(patMedOuthosp);
if (CollectionUtils.isNotEmpty(patMedOuthosps)) patid = patMedOuthosps.get(0).getPatid();
} else if (serviceSubTaskMYDAnswerReq.getMzzy().equals("3")) {
//鎸囧畾涓�涓儴闂紝鐢ㄦ潵澶勭悊鎶曡瘔寤鸿
@@ -688,8 +749,8 @@
serviceSubtask.setLibtemplateid(Long.valueOf(serviceTask.getLibtemplateid()));
if (CollectionUtils.isNotEmpty(patMedInhospList)) {
serviceSubtask.setHospType("2");
- serviceSubtask.setDeptname(patMedInhospList.get(0).getDeptname());
- serviceSubtask.setDeptcode(patMedInhospList.get(0).getDeptcode());
+ serviceSubtask.setLeaveldeptname(patMedInhospList.get(0).getDeptname());
+ serviceSubtask.setLeaveldeptcode(patMedInhospList.get(0).getDeptcode());
serviceSubtask.setLeavehospitaldistrictcode(patMedInhospList.get(0).getLeavehospitaldistrictcode());
serviceSubtask.setLeavehospitaldistrictname(patMedInhospList.get(0).getLeavehospitaldistrictname());
serviceSubtask.setDrname(patMedInhospList.get(0).getDrname());
@@ -697,15 +758,17 @@
serviceSubtask.setNurseName(patMedInhospList.get(0).getNurseName());
serviceSubtask.setNurseId(patMedInhospList.get(0).getNurseId());
serviceSubtask.setInhospid(patMedInhospList.get(0).getInhospid());
+ serviceSubtask.setCampusid(patMedInhospList.get(0).getCampusid());
serviceSubtask.setServiceType("6");
} else if (CollectionUtils.isNotEmpty(patMedOuthosps)) {
serviceSubtask.setHospType("1");
serviceSubtask.setAdmindate(patMedOuthosps.get(0).getAdmitdate());
serviceSubtask.setHospno(patMedOuthosps.get(0).getOuthospno());
- serviceSubtask.setDeptname(patMedOuthosps.get(0).getDeptname());
- serviceSubtask.setDeptcode(patMedOuthosps.get(0).getDeptcode());
+ serviceSubtask.setLeaveldeptname(patMedOuthosps.get(0).getDeptname());
+ serviceSubtask.setLeaveldeptcode(patMedOuthosps.get(0).getDeptcode());
serviceSubtask.setDrname(patMedOuthosps.get(0).getDrname());
serviceSubtask.setDrcode(patMedOuthosps.get(0).getDrcode());
+ serviceSubtask.setCampusid(patMedOuthosps.get(0).getCampusid());
serviceSubtask.setServiceType("14");
}
if (!Objects.isNull(patArchive)) {
@@ -716,10 +779,15 @@
serviceSubtask.setSfzh(patArchive.getIdcardno());
serviceSubtask.setAddr(patArchive.getPlaceOfResidence());
serviceSubtask.setOrgid(patArchive.getOrgid());
+ // 闄㈠尯鍏滃簳锛氫綇闄�/闂ㄦ�ヨ瘖璁板綍鐨勯櫌鍖哄湪鏈簱甯镐负绌猴紝鐢ㄦ偅鑰呮。妗堢殑闄㈠尯琛ヤ笂锛�
+ // 鍚﹀垯缁熻鎺ュ彛锛園AddOrgId 鎸夌櫥褰曠敤鎴烽櫌鍖鸿繃婊� service_subtask.campusid锛変細鎶婅繖浜涘瓙浠诲姟鏁存壒涓㈡帀
+ if (StringUtils.isEmpty(serviceSubtask.getCampusid())) {
+ serviceSubtask.setCampusid(patArchive.getCampusid());
+ }
}
if (StringUtils.isNotEmpty(dealDept)) {
//鎶曡瘔寤鸿鐨勫鐞嗛儴闂�
- serviceSubtask.setDeptcode(dealDept);
+ serviceSubtask.setLeaveldeptcode(dealDept);
serviceSubtask.setServiceType("15");
}
serviceSubtask.setSubmit(1L);
@@ -978,6 +1046,11 @@
/**
* 鎵归噺鏌ヨ宸插瓨鍦ㄧ殑鏄庣粏璁板綍ID锛屾寜scriptid鍒嗙粍锛堥伩鍏嶅惊鐜腑閫愭潯鏌ヨ锛�
+ * <p>
+ * 鈿狅笍 2026-10-21锛�<b>涓嶅啀杩囨护 del_flag</b>锛屽悓涓� scriptid 鍙� id 鏈�澶э紙鏈�鏂帮級鐨勯偅涓�琛屻��
+ * 鍘熸潵鍙 del_flag=0锛屾槑缁嗚閫昏緫鍒犻櫎鍚庡氨鏌ヤ笉鍒� 鈫� 涓嬩竴娆′繚瀛樺繀鐒� INSERT 鏂板壇鏈紝
+ * 鍚屼竴鎮h�呭悓涓�棰樹細鍫嗗嚭 2~6 鏉¢噸澶嶆槑缁嗭紙nhfy 2026-09-08锛夈��
+ * 鍛戒腑琚垹鍓湰鏃剁敱璋冪敤鏂瑰啀璋� {@code reviveServiceSubtaskDetail} 缃洖 '0'銆�
*/
private Map<Long, Long> getExistingDetailIdMap(Long subid) {
if (subid == null) return Collections.emptyMap();
@@ -987,7 +1060,9 @@
if (CollectionUtils.isEmpty(details)) return Collections.emptyMap();
Map<Long, Long> map = new HashMap<>();
for (ServiceSubtaskDetail d : details) {
- if ((d.getDelFlag() == null || "0".equals(d.getDelFlag())) && d.getScriptid() != null && !map.containsKey(d.getScriptid())) {
+ if (d.getScriptid() == null || d.getId() == null) continue;
+ Long existId = map.get(d.getScriptid());
+ if (existId == null || d.getId() > existId) {
map.put(d.getScriptid(), d.getId());
}
}
@@ -1084,6 +1159,8 @@
serviceSubtaskDetail.setId(existDetailId);
serviceSubtaskDetail.setUpdateTime(new Date());
serviceSubtaskDetailMapper.updateServiceSubtaskDetail(serviceSubtaskDetail);
+ //鍛戒腑鍘嗗彶琚�昏緫鍒犻櫎鐨勫壇鏈椂缃洖 del_flag='0'锛堝惁鍒欑瓟妗堝啓杩涘幓浜嗗嵈鏌ヤ笉鍒帮紝涓斾笅娆″張浼氭柊澧炲壇鏈級
+ serviceSubtaskDetailMapper.reviveServiceSubtaskDetail(existDetailId);
} else {
serviceSubtaskDetailMapper.insertServiceSubtaskDetail(serviceSubtaskDetail);
}
@@ -1383,6 +1460,8 @@
serviceSubtaskDetail.setId(existServiceSubtaskDetail.getId());
serviceSubtaskDetail.setUpdateTime(new Date());
serviceSubtaskDetailMapper.updateServiceSubtaskDetail(serviceSubtaskDetail);
+ //鍛戒腑鍘嗗彶琚�昏緫鍒犻櫎鐨勫壇鏈椂缃洖 del_flag='0'锛岄伩鍏嶉噸澶嶅壇鏈�
+ serviceSubtaskDetailMapper.reviveServiceSubtaskDetail(existServiceSubtaskDetail.getId());
} else {
serviceSubtaskDetailMapper.insertServiceSubtaskDetail(serviceSubtaskDetail);
}
--
Gitblit v1.9.3