From 8107dedd85ceec29491293d8ebf69f7d7213aa6b Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期一, 21 九月 2026 15:24:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 806 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 749 insertions(+), 57 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 06ffc4c..5640854 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -12,7 +12,6 @@
import com.ruoyi.common.dx.MessageSend;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
-import com.ruoyi.common.core.service.IConfigService;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysConfig;
@@ -22,11 +21,11 @@
import com.smartor.common.MtSubmitSmUtil;
import com.smartor.common.ScheduleSubtaskBuilder;
import com.smartor.config.PhoneUtils;
+import com.smartor.domain.DTO.MydTrendReqDTO;
+import com.smartor.domain.DTO.QuestionCountKsOrBqDTO;
import com.smartor.domain.DTO.ServiceSubtaskDetailDTO;
import com.smartor.domain.*;
-import com.smartor.domain.VO.HeLibraryCountVO;
-import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO;
-import com.smartor.domain.VO.TransferDeptVO;
+import com.smartor.domain.VO.*;
import com.smartor.domain.entity.ServiceSubtaskEntity;
import com.smartor.mapper.*;
import com.smartor.service.*;
@@ -34,7 +33,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
-import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -43,10 +41,8 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@@ -206,12 +202,13 @@
@Value("${spring.profiles.active}")
private String active;
- @Autowired
- private PatMedOperationMapper patMedOperationMapper;
- @Autowired
- private PatMedOperationItemMapper patMedOperationItemMapper;
+
@Autowired
private ServiceOutPathMapper serviceOutPathMapper;
+
+ private static final String KEY_SEP = "\u0001";
+ @Autowired
+ private PatMedOperationItemMapper patMedOperationItemMapper;
/**
* 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級
@@ -414,26 +411,7 @@
@Override
public List<ServiceSubtaskRes> patItem(ServiceSubtaskEntity serviceSubtaskEntity) {
- if (serviceSubtaskEntity.getSendstateView() != null) {
- // 1锛氬緟闅忚锛�1 琚鍙栥��2 寰呭彂閫併��3 宸插彂閫併��5 鍙戦�佸け璐ャ��7銆佽秴鏃讹級锛�2锛氬凡瀹屾垚锛� 6 宸插畬鎴愶級銆�3锛氭棤闇�闅忚锛�4 涓嶆墽琛岋級
- if (serviceSubtaskEntity.getSendstateView() == 1)
- serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L)));
- if (serviceSubtaskEntity.getSendstateView() == 2)
- serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L)));
- if (serviceSubtaskEntity.getSendstateView() == 3)
- serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(4L)));
- }
- //鎮h�呰幏鍙栭殢璁夸换鍔�-闇�瑕佹煡璇㈠悓涓偅鑰咃紙韬唤璇侊級鎵�鏈夌殑浠诲姟 鏅畞
- if (StringUtils.isNotEmpty(serviceSubtaskEntity.getOrgid()) && serviceSubtaskEntity.getOrgid().equals("47255004333112711A1001")) {
- if (ObjectUtils.isNotEmpty(serviceSubtaskEntity.getPatid())) {
- PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtaskEntity.getPatid());
- if (ObjectUtils.isNotEmpty(patArchive) && StringUtils.isNotEmpty(patArchive.getIdcardno())) {
- serviceSubtaskEntity.setPatid(null);
- serviceSubtaskEntity.setSfzh(patArchive.getIdcardno());
- }
- }
- }
- List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskEntity);
+ List<ServiceSubtask> selectServiceSubtaskList = getServiceSubtasks(serviceSubtaskEntity);
List<ServiceSubtaskRes> serviceSubtaskResList = new ArrayList<>();
for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
@@ -469,6 +447,30 @@
serviceSubtaskResList.add(serviceSubtaskRes);
}
return serviceSubtaskResList;
+ }
+
+ public List<ServiceSubtask> getServiceSubtasks(ServiceSubtaskEntity serviceSubtaskEntity) {
+ if (serviceSubtaskEntity.getSendstateView() != null) {
+ // 1锛氬緟闅忚锛�1 琚鍙栥��2 寰呭彂閫併��3 宸插彂閫併��5 鍙戦�佸け璐ャ��7銆佽秴鏃讹級锛�2锛氬凡瀹屾垚锛� 6 宸插畬鎴愶級銆�3锛氭棤闇�闅忚锛�4 涓嶆墽琛岋級
+ if (serviceSubtaskEntity.getSendstateView() == 1)
+ serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L)));
+ if (serviceSubtaskEntity.getSendstateView() == 2)
+ serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L)));
+ if (serviceSubtaskEntity.getSendstateView() == 3)
+ serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(4L)));
+ }
+ //鎮h�呰幏鍙栭殢璁夸换鍔�-闇�瑕佹煡璇㈠悓涓偅鑰咃紙韬唤璇侊級鎵�鏈夌殑浠诲姟 鏅畞
+ if (StringUtils.isNotEmpty(serviceSubtaskEntity.getOrgid()) && serviceSubtaskEntity.getOrgid().equals("47255004333112711A1001")) {
+ if (ObjectUtils.isNotEmpty(serviceSubtaskEntity.getPatid())) {
+ PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(serviceSubtaskEntity.getPatid());
+ if (ObjectUtils.isNotEmpty(patArchive) && StringUtils.isNotEmpty(patArchive.getIdcardno())) {
+ serviceSubtaskEntity.setPatid(null);
+ serviceSubtaskEntity.setSfzh(patArchive.getIdcardno());
+ }
+ }
+ }
+ List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskEntity);
+ return selectServiceSubtaskList;
}
@Override
@@ -636,14 +638,19 @@
*/
@Override
public Map<String, Object> insertServiceSubtask(ServiceSubtask serviceSubtask) {
+ List<ServiceSubtask> serviceSubtasks = null;
//鍏堟煡璇竴涓嬭鎮h�呮槸鍚﹀凡缁忓垱寤烘牴鎹畇erviceType,sendstate,inhospid,patid,orgid
- ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
- serviceSubtaskVO.setServiceType(serviceSubtask.getServiceType());
- serviceSubtaskVO.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L)));
- serviceSubtaskVO.setPatid(serviceSubtask.getPatid());
- serviceSubtaskVO.setOrgid(serviceSubtask.getOrgid());
- serviceSubtaskVO.setCampusid(serviceSubtask.getCampusid());
- List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
+ //杩欐牱鍒ゆ柇涓昏鏄负浜嗘兂璁╂柊鍗庡尰闄㈢殑澶栭儴瀵煎叆鎮h�呭垱寤轰换鍔★紝涔熻兘鐢ㄨ繖涓帴鍙�
+ if (StringUtils.isEmpty(serviceSubtask.getPatfrom()) || !serviceSubtask.getPatfrom().equals("2")) {
+ ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
+ serviceSubtaskVO.setServiceType(serviceSubtask.getServiceType());
+ serviceSubtaskVO.setInhospid(serviceSubtask.getInhospid());
+ serviceSubtaskVO.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L)));
+ serviceSubtaskVO.setPatid(serviceSubtask.getPatid());
+ serviceSubtaskVO.setOrgid(serviceSubtask.getOrgid());
+ serviceSubtaskVO.setCampusid(serviceSubtask.getCampusid());
+ serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
+ }
RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
String format = null;
if (CollectionUtils.isNotEmpty(serviceSubtasks)) {
@@ -657,8 +664,25 @@
serviceSubtask = serviceSubtask1;
} else {
//濡傛灉涓嶅瓨鍦紝鍒欐柊澧�
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ if (ObjectUtils.isNotEmpty(serviceTask)) {
+ serviceSubtask.setTaskDesc(serviceTask.getTaskDesc());
+ serviceSubtask.setTaskName(serviceTask.getTaskName());
+ serviceSubtask.setTemplatename(serviceTask.getTemplatename());
+ }
+
serviceSubtask.setCreateTime(DateUtils.getNowDate());
serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
+ //淇敼浣忛櫌婊℃剰搴︾姸鎬侊紙閬垮厤閲嶅鏌ヨ锛�
+ if (serviceSubtask.getServiceType() != null && "6".equals(serviceSubtask.getServiceType())) {
+ Long inhospid = serviceSubtask.getInhospid();
+ if (inhospid != null) {
+ PatMedInhosp patMedInhosp = new PatMedInhosp();
+ patMedInhosp.setInhospMydFlag("1");
+ patMedInhosp.setInhospid(inhospid);
+ patMedInhospMapper.updatePatMedInhosp(patMedInhosp);
+ }
+ }
format = getOutPath(serviceSubtask, rsaPublicKeyExample);
}
@@ -762,6 +786,7 @@
serviceSubtask.setUpdateTime(DateUtils.getNowDate());
if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 6)
serviceSubtask.setFinishtime(new Date());
+
return serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
}
@@ -1142,7 +1167,7 @@
redisCache.removeElementFromList("cache-3", serviceSubtask.getId().toString());
redisCache.removeElementFromList("cache-4", serviceSubtask.getId().toString());
//灏嗗嚭鍏ラ櫌琛ㄧ殑鏁版嵁锛岃繕鍘熸垚杩樻湭澶勭悊鐨勭姸鎬�
- if (serviceSubtask.getServiceType().equals("2")) {
+ if (serviceSubtask.getServiceType().equals("2") || serviceSubtask.getServiceType().equals("13")) {
ServiceTask st = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
//濡傛灉浠诲姟鏄暱鏈熶换鍔★紝闇�瑕佸皢璇ユ偅鑰呯殑鍑哄叆闄㈡暟鎹繕鍘熸垚杩樻湭澶勭悊鐨勭姸鎬�
if (st != null && st.getLongTask() == 1) {
@@ -1163,6 +1188,16 @@
patMedOuthosp.setServerState("0");
patMedOuthospService.updatePatMedOuthosp(patMedOuthosp);
}
+ }
+ } else if (serviceSubtask.getServiceType().equals("19")) {
+ ServiceTask st = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ //濡傛灉浠诲姟鏄暱鏈熶换鍔★紝闇�瑕佸皢璇ユ偅鑰呯殑鍑洪櫌璇︽儏鐘舵�佽繕鍘熸垚杩樻湭澶勭悊鐨勭姸鎬�
+ if (st != null && st.getLongTask() == 1
+ && ObjectUtils.isNotEmpty(serviceSubtask.getOperationItemId())) {
+ PatMedOperationItem patMedOperationItem = new PatMedOperationItem();
+ patMedOperationItem.setOpercheckFlag("0");
+ patMedOperationItem.setId(serviceSubtask.getOperationItemId());
+ patMedOperationItemMapper.updatePatMedOperationItem(patMedOperationItem);
}
}
}
@@ -2891,12 +2926,10 @@
collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
break;
case "management_doctor_code":
- rawData = rawData.stream()
- .peek(item -> {
- item.setDrname(item.getManagementDoctor());
- item.setDrcode(item.getManagementDoctorCode());
- })
- .collect(Collectors.toList());
+ rawData = rawData.stream().peek(item -> {
+ item.setDrname(item.getManagementDoctor());
+ item.setDrcode(item.getManagementDoctorCode());
+ }).collect(Collectors.toList());
collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown")));
break;
case "deptcode":
@@ -3319,6 +3352,24 @@
serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L);
}
}
+
+ //棣栨闅忚浜哄伐鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
+ serviceSubtaskStatistic.setManualSuccess(serviceSubtaskStatistic.getManualSuccess() + 1L);
+ }
+ //棣栨闅忚璇煶鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) {
+ serviceSubtaskStatistic.setVoiceSuccess(serviceSubtaskStatistic.getVoiceSuccess() + 1L);
+ }
+ //棣栨闅忚鐭俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) {
+ serviceSubtaskStatistic.setSmsSuccess(serviceSubtaskStatistic.getSmsSuccess() + 1L);
+ }
+ //棣栨闅忚寰俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) {
+ serviceSubtaskStatistic.setWeChatSuccess(serviceSubtaskStatistic.getWeChatSuccess() + 1L);
+ }
+
if (serviceSubtaskStatistic.getNeedFollowUp() > 0) {
double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp();
serviceSubtaskStatistic.setFollowUpRate(percentFormat.format(rate));
@@ -3414,6 +3465,24 @@
serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L);
}
}
+
+ //鍐嶆闅忚浜哄伐鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
+ serviceSubtaskStatistic.setManualAgainSuccess(serviceSubtaskStatistic.getManualAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚璇煶鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) {
+ serviceSubtaskStatistic.setVoiceAgainSuccess(serviceSubtaskStatistic.getVoiceAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚鐭俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) {
+ serviceSubtaskStatistic.setSmsAgainSuccess(serviceSubtaskStatistic.getSmsAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚寰俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) {
+ serviceSubtaskStatistic.setWeChatAgainSuccess(serviceSubtaskStatistic.getWeChatAgainSuccess() + 1L);
+ }
+
if (serviceSubtaskStatistic.getNeedFollowUp() > 0) {
double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccessAgain() + serviceSubtaskStatistic.getFollowUpFailAgain()) / serviceSubtaskStatistic.getNeedFollowUpAgain();
serviceSubtaskStatistic.setFollowUpRateAgain(percentFormat.format(rate));
@@ -3568,6 +3637,24 @@
serviceSubtaskStatistic.setWeChat(serviceSubtaskStatistic.getWeChat() + 1L);
}
}
+
+ //棣栨闅忚浜哄伐鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
+ serviceSubtaskStatistic.setManualSuccess(serviceSubtaskStatistic.getManualSuccess() + 1L);
+ }
+ //棣栨闅忚璇煶鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) {
+ serviceSubtaskStatistic.setVoiceSuccess(serviceSubtaskStatistic.getVoiceSuccess() + 1L);
+ }
+ //棣栨闅忚鐭俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) {
+ serviceSubtaskStatistic.setSmsSuccess(serviceSubtaskStatistic.getSmsSuccess() + 1L);
+ }
+ //棣栨闅忚寰俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) {
+ serviceSubtaskStatistic.setWeChatSuccess(serviceSubtaskStatistic.getWeChatSuccess() + 1L);
+ }
+
if (serviceSubtaskStatistic.getNeedFollowUp() > 0) {
double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccess() + serviceSubtaskStatistic.getFollowUpFail()) / serviceSubtaskStatistic.getNeedFollowUp();
serviceSubtaskStatistic.setFollowUpRate(percentFormat.format(rate));
@@ -3719,6 +3806,24 @@
serviceSubtaskStatistic.setWeChatAgain(serviceSubtaskStatistic.getWeChatAgain() + 1L);
}
}
+
+ //鍐嶆闅忚浜哄伐鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("1")) {
+ serviceSubtaskStatistic.setManualAgainSuccess(serviceSubtaskStatistic.getManualAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚璇煶鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("3")) {
+ serviceSubtaskStatistic.setVoiceAgainSuccess(serviceSubtaskStatistic.getVoiceAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚鐭俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("4")) {
+ serviceSubtaskStatistic.setSmsAgainSuccess(serviceSubtaskStatistic.getSmsAgainSuccess() + 1L);
+ }
+ //鍐嶆闅忚寰俊鎴愬姛
+ if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate().equals(6L) && ObjectUtils.isNotEmpty(serviceSubtask.getCurrentPreachform()) && serviceSubtask.getCurrentPreachform().equals("5")) {
+ serviceSubtaskStatistic.setWeChatAgainSuccess(serviceSubtaskStatistic.getWeChatAgainSuccess() + 1L);
+ }
+
if (serviceSubtaskStatistic.getNeedFollowUp() > 0) {
double rate = (double) (serviceSubtaskStatistic.getFollowUpSuccessAgain() + serviceSubtaskStatistic.getFollowUpFailAgain()) / serviceSubtaskStatistic.getNeedFollowUpAgain();
serviceSubtaskStatistic.setFollowUpRateAgain(percentFormat.format(rate));
@@ -4056,12 +4161,15 @@
iServiceOutPathService.insertServiceOutPath(serviceOutPath);
//杞垚16杩涘埗
String format = String.format("%03X", serviceOutPath.getId());
+ String url = "";
+ SendMagParam sendMagParam = new SendMagParam();
+ url = localIP + ":" + req_path + "/sf?p=" + format;
+ sendMagParam.setUrl(url);
+ sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
serviceOutPath.setRadix(format);
serviceOutPath.setUpdateTime(new Date());
+ serviceOutPath.setUrl(url);
iServiceOutPathService.updateServiceOutPath(serviceOutPath);
- SendMagParam sendMagParam = new SendMagParam();
- sendMagParam.setUrl(localIP + ":" + req_path + "/sf?p=" + format);
- sendMagParam.setContent("銆愭柊鍗庡尰闄€�戞偍濂斤紝閭�璇锋偍濉啓鍑洪櫌闅忚璋冩煡琛紝璇风偣鍑�" + sendMagParam.getUrl() + "濉啓銆傛劅璋㈡偍閰嶅悎锛�");
Map<String, String> map = new HashMap<>();
map.put("phone", serviceSubtask.getPhone());
map.put("content", sendMagParam.getContent());
@@ -4146,6 +4254,10 @@
* voiceInfo - visitCount = 1 && currentPreachForm = "3"
* smsInfo - visitCount = 1 && currentPreachForm = "4"
* wechatInfo - visitCount = 1 && currentPreachForm = "5"
+ * manualSuccessInfo - visitCount = 1 && currentPreachForm = "1" && sendstate = 6
+ * voiceSuccessInfo - visitCount = 1 && currentPreachForm = "3" && sendstate = 6
+ * smsSuccessInfo - visitCount = 1 && currentPreachForm = "4" && sendstate = 6
+ * wechatSuccessInfo - visitCount = 1 && currentPreachForm = "5" && sendstate = 6
* abnormalInfo - visitCount = 1 && excep = "1"
* needFollowUpAgainInfo - visitCount > 1 && sendstate != 4
* pendingFollowUpAgainInfo - visitCount > 1 && sendstate = 2
@@ -4155,6 +4267,10 @@
* voiceAgainInfo - visitCount > 1 && currentPreachForm = "3"
* smsAgainInfo - visitCount > 1 && currentPreachForm = "4"
* wechatAgainInfo - visitCount > 1 && currentPreachForm = "5"
+ * manualAgainSuccessInfo - visitCount > 1 && currentPreachForm = "1" && sendstate = 6
+ * voiceAgainSuccessInfo - visitCount > 1 && currentPreachForm = "3" && sendstate = 6
+ * smsAgainSuccessInfo - visitCount > 1 && currentPreachForm = "4" && sendstate = 6
+ * wechatAgainSuccessInfo - visitCount > 1&& currentPreachForm = "5" && sendstate = 6
* abnormalAgainInfo- visitCount = 1 && excep = "1"
* taskSituation1Info - taskSituation = 1
* taskSituation2Info - taskSituation = 2
@@ -4238,6 +4354,26 @@
serviceSubtaskCountReq.setVisitCount(1);
serviceSubtaskCountReq.setCurrentPreachform("5");
break;
+ case "manualSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(1);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("1");
+ break;
+ case "voiceSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(1);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("3");
+ break;
+ case "smsSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(1);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("4");
+ break;
+ case "wechatSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(1);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("5");
+ break;
case "abnormalInfo":
serviceSubtaskCountReq.setVisitCount(1);
serviceSubtaskCountReq.setExcep("1");
@@ -4272,6 +4408,26 @@
break;
case "wechatAgainInfo":
serviceSubtaskCountReq.setVisitCount(2);
+ serviceSubtaskCountReq.setCurrentPreachform("5");
+ break;
+ case "manualAgainSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(1);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("1");
+ break;
+ case "voiceAgainSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(2);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("3");
+ break;
+ case "smsAgainSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(2);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
+ serviceSubtaskCountReq.setCurrentPreachform("4");
+ break;
+ case "wechatAgainSuccessInfo":
+ serviceSubtaskCountReq.setVisitCount(2);
+ serviceSubtaskCountReq.setSendstates(new ArrayList<>(Collections.singletonList(6L)));
serviceSubtaskCountReq.setCurrentPreachform("5");
break;
case "abnormalAgainInfo":
@@ -4947,15 +5103,17 @@
serviceOutPath.setOrgid(serviceSubtask.getOrgid());
iServiceOutPathService.insertServiceOutPath(serviceOutPath);
String format = String.format("%03X", serviceOutPath.getId());
- serviceOutPath.setRadix(format);
- serviceOutPath.setUpdateTime(new Date());
- iServiceOutPathService.updateServiceOutPath(serviceOutPath);
-
+ String url = "";
SendMagParam sendMagParam = new SendMagParam();
sendMagParam.setType("4");
sendMagParam.setPhone(serviceSubtask.getPhone());
- sendMagParam.setUrl(StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format);
+ url = StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format;
+ sendMagParam.setUrl(url);
+ serviceOutPath.setRadix(format);
+ serviceOutPath.setUpdateTime(new Date());
+ serviceOutPath.setUrl(url);
+ iServiceOutPathService.updateServiceOutPath(serviceOutPath);
SysConfig sysConfig = new SysConfig();
sysConfig = sysConfigMapper.checkConfigKeyUnique("wj.sms.template");
@@ -4980,23 +5138,232 @@
}
@Override
- public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startOutHospTime, Date endOutHospTime) {
+ public List<ServiceSubtaskDetailRatioExport> statQuestionOption(List<Long> taskIds, Date startFinishTime, Date endFinishTime, Date startOutHospTime, Date endOutHospTime, String scriptContent, Double scoreStart, Double scoreEnd, String valueType) {
//鍏堟竻鐞嗕竴涓嬮噸澶嶆暟鎹�
List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds();
if (!CollectionUtils.isEmpty(repeatIds)) {
serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds);
}
- return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime);
+ List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime, startFinishTime, endFinishTime, scoreStart, scoreEnd, scriptContent, valueType);
+
+ // 澶勭悊 targetvalue锛氭寜 & 鍒嗗壊鎴愬鏉¤褰�
+ List<ServiceSubtaskDetailRatioExport> result = new ArrayList<>();
+ for (ServiceSubtaskDetailRatioExport export : serviceSubtaskDetailRatioExports) {
+ if (StringUtils.isNotEmpty(export.getTargetvalue()) && export.getTargetvalue().contains("&")) {
+ String[] values = export.getTargetvalue().split("&");
+ // 濡傛灉鏈夊鏉$洰鏍囧�硷紝鎷嗗垎鎴愬琛�
+ for (String value : values) {
+ //鍏堝幓 result 涓煡涓�涓嬶紝鏈夋病鏈夎繖涓� questiontext 鍜屽搴旂殑 targetvalue
+ ServiceSubtaskDetailRatioExport existingExport = result.stream().filter(e -> e.getQuestiontext().equals(export.getQuestiontext()) && value.trim().equals(e.getTargetvalue())).findFirst().orElse(null);
+ if (existingExport != null && existingExport.getRatio().equals("0") && existingExport.getCount().equals("0")) {
+ //濡傛灉瀛樺湪锛屽垯灏� result 閲岀殑杩欎釜闂鎵�瀵瑰簲鐨� Targetvalue=value 杩欐潯鏁版嵁鏇存柊鎴愬綋鍓嶈繖鏉℃暟鎹�
+ if (value.equals(export.getOptionresult())) {
+ existingExport.setRatio(export.getRatio());
+ existingExport.setScore(export.getScore());
+ existingExport.setCount(export.getCount());
+ existingExport.setOptionresult(export.getOptionresult());
+ }
+ } else if (existingExport != null && !existingExport.getRatio().equals("0")) {
+ continue;
+ } else {
+ ServiceSubtaskDetailRatioExport newExport = DtoConversionUtils.sourceToTarget(export, ServiceSubtaskDetailRatioExport.class);
+ newExport.setTargetvalue(value.trim()); // targetvalue 鏄剧ず鍗曚釜閫夐」
+ if (!value.equals(export.getOptionresult())) {
+ newExport.setOptionresult(null);
+ newExport.setCount("0");
+ newExport.setRatio("0");
+ }
+ result.add(newExport);
+ }
+ }
+ } else {
+ // targetvalue 涓嶅寘鍚� &锛岀洿鎺ユ坊鍔犲埌缁撴灉
+ result.add(export);
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * 鏍规嵁绉戝鎴栫梾鍖虹粺璁¢棶鍗烽�夐」(绉戝銆侀鐩煡璇㈢殑绉戝璇勫垎琛�)
+ */
+ @Override
+ public Map<String, Map<String, List<QuestionCountKsOrBqDTO>>> statQuestionOptionByKsOrBq(QuestionCountKsOrBqVO vo) {
+
+ // 1. 鏌ユ槑缁�
+ List<QuestionCountKsOrBqDTO> sourceList = serviceSubtaskMapper.statQuestionOptionByKsOrBq(vo);
+ if (CollectionUtils.isEmpty(sourceList)) {
+ return Collections.emptyMap();
+ }
+
+ // 2. 鍒ゆ柇鎸夌瀹よ繕鏄寜鐥呭尯
+ boolean byDept = vo.getLeaveldeptcodes() != null;
+ boolean byDistrict = !byDept && vo.getLeavehospitaldistrictcodes() != null;
+ if (!byDept && !byDistrict) {
+ return Collections.emptyMap();
+ }
+
+ // 3. key = 绉戝/鐥呭尯 + 棰樼洰 + 閫夐」
+ Map<String, QuestionCountKsOrBqDTO> map = new LinkedHashMap<>();
+
+ for (QuestionCountKsOrBqDTO dto : sourceList) {
+
+ if (StringUtils.isEmpty(dto.getTargetvalue())) {
+ continue;
+ }
+
+ // 鍒嗙粍鍚嶏細绉戝 鎴� 鐥呭尯
+ String groupName = byDept ? dto.getDeptname() : dto.getLeavehospitaldistrictname();
+ if (StringUtils.isEmpty(groupName)) {
+ continue;
+ }
+
+ String asrtext = trimAll(dto.getAsrtext()); // 鐢ㄦ埛瀹為檯閫変腑鐨勯�夐」
+ String questionText = trimAll(dto.getQuestionText()); // 棰樼洰
+ if (StringUtils.isEmpty(questionText)) {
+ continue;
+ }
+
+ // 鎷嗗垎 targetvalue锛屾瘡涓�夐」閮借鏈変竴鏉¤褰�
+ for (String raw : dto.getTargetvalue().split("&")) {
+
+ String option = trimAll(raw);
+ if (option.isEmpty()) {
+ continue;
+ }
+
+ // key = 绉戝/鐥呭尯 + 棰樼洰 + 閫夐」
+ String key = buildKey(groupName, questionText, option);
+
+ QuestionCountKsOrBqDTO item = map.get(key);
+ if (item == null) {
+ item = DtoConversionUtils.sourceToTarget(dto, QuestionCountKsOrBqDTO.class);
+ item.setTargetvalue(option);
+ item.setAsrtext(option);
+ item.setQuestionText(dto.getQuestionText());
+ item.setAnswerCount("0");
+ item.setSingleScore("0");
+ map.put(key, item);
+ }
+
+ // 鍙湁褰撳墠閫夐」 == 鐢ㄦ埛瀹為檯閫変腑鐨勯�夐」锛屾墠绱姞
+ if (option.equals(asrtext)) {
+ int count = parseCount(item.getAnswerCount()) + 1;
+ item.setAnswerCount(String.valueOf(count));
+
+ BigDecimal totalScore = new BigDecimal(item.getSingleScore())
+ .add(new BigDecimal(dto.getSingleScore() == null ? "0" : dto.getSingleScore()));
+ item.setSingleScore(totalScore.toPlainString());
+ }
+ }
+ }
+
+ // 4. 璁$畻骞冲潎鍒�
+ for (QuestionCountKsOrBqDTO dto : map.values()) {
+ String answerCount = dto.getAnswerCount();
+ String singleScore = dto.getSingleScore();
+
+ BigDecimal avg;
+ if (StringUtils.isEmpty(answerCount)
+ || BigDecimal.ZERO.compareTo(new BigDecimal(answerCount.trim())) == 0) {
+ avg = BigDecimal.ZERO;
+ } else {
+ avg = new BigDecimal(singleScore == null ? "0" : singleScore)
+ .divide(new BigDecimal(answerCount.trim()), 2, RoundingMode.HALF_UP);
+ }
+ dto.setAvgScore(avg.toPlainString());
+ }
+
+ // 5. 杞垚 Map<String, Map<String, List<QuestionCountKsOrBqDTO>>>
+ // 绗竴灞� key锛氱瀹�/鐥呭尯
+ // 绗簩灞� key锛氶鐩�
+ // 绗簩灞� value锛氳棰樼洰涓嬬殑鎵�鏈夐�夐」鍒楄〃
+ Map<String, Map<String, List<QuestionCountKsOrBqDTO>>> result = new LinkedHashMap<>();
+
+ for (QuestionCountKsOrBqDTO dto : map.values()) {
+
+ // 鍒嗙粍鍚�
+ String groupName = byDept ? dto.getDeptname() : dto.getLeavehospitaldistrictname();
+ if (StringUtils.isEmpty(groupName)) {
+ continue;
+ }
+
+ // 棰樼洰鍚�
+ String questionText = dto.getQuestionText();
+ if (StringUtils.isEmpty(questionText)) {
+ continue;
+ }
+
+ // 绗竴灞傦細绉戝/鐥呭尯
+ Map<String, List<QuestionCountKsOrBqDTO>> questionMap =
+ result.computeIfAbsent(groupName, k -> new LinkedHashMap<>());
+
+ // 绗簩灞傦細棰樼洰
+ List<QuestionCountKsOrBqDTO> optionList =
+ questionMap.computeIfAbsent(questionText, k -> new ArrayList<>());
+
+ optionList.add(dto);
+ }
+
+ return result;
}
@Override
- public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime) {
+ public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime, Date startFinishTime, Date endFinishTime, String scriptContent, Double scoreStart, Double scoreEnd, String valueType) {
//鍏堟竻鐞嗕竴涓嬮噸澶嶆暟鎹�
List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds();
if (!CollectionUtils.isEmpty(repeatIds)) {
serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds);
}
- return serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime);
+
+ List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime, startFinishTime, endFinishTime, scoreStart, scoreEnd, scriptContent, valueType);
+ // 澶勭悊 targetvalue锛氭寜 & 鍒嗗壊鎴愬鏉¤褰�
+ List<ServiceSubtaskDetailRatioExport> result = new ArrayList<>();
+ for (ServiceSubtaskDetailRatioExport export : serviceSubtaskDetailRatioExports) {
+ if (StringUtils.isNotEmpty(export.getTargetvalue()) && export.getTargetvalue().contains("&")) {
+ String[] values = export.getTargetvalue().split("&");
+ // 濡傛灉鏈夊鏉$洰鏍囧�硷紝鎷嗗垎鎴愬琛�
+ for (String value : values) {
+ //鍏堝幓 result 涓煡涓�涓嬶紝鏈夋病鏈夎繖涓� questiontext 鍜屽搴旂殑 targetvalue
+ ServiceSubtaskDetailRatioExport existingExport = result.stream().filter(e -> {
+ if (e == null || export == null) {
+ return false;
+ }
+ String q1 = e.getQuestiontext() != null ? e.getQuestiontext() : "";
+ String q2 = export.getQuestiontext() != null ? export.getQuestiontext() : "";
+ String t1 = value.trim();
+ String t2 = e.getTargetvalue() != null ? e.getTargetvalue() : "";
+ return q1.equals(q2) && t1.equals(t2);
+ }).findFirst().orElse(null);
+ if (existingExport != null && "0".equals(existingExport.getRatio()) && "0".equals(existingExport.getCount())) {
+ //濡傛灉瀛樺湪锛屽垯灏� result 閲岀殑杩欎釜闂鎵�瀵瑰簲鐨� Targetvalue=value 杩欐潯鏁版嵁鏇存柊鎴愬綋鍓嶈繖鏉℃暟鎹�
+ if (value.equals(export.getOptionresult())) {
+ existingExport.setRatio(export.getRatio());
+ existingExport.setScore(export.getScore());
+ existingExport.setCount(export.getCount());
+ existingExport.setOptionresult(export.getOptionresult());
+ }
+ } else if (existingExport != null && !"0".equals(existingExport.getRatio())) {
+ continue;
+ } else {
+ ServiceSubtaskDetailRatioExport newExport = DtoConversionUtils.sourceToTarget(export, ServiceSubtaskDetailRatioExport.class);
+ newExport.setTargetvalue(value.trim()); // targetvalue 鏄剧ず鍗曚釜閫夐」
+ if (!value.equals(export.getOptionresult())) {
+ newExport.setOptionresult(null);
+ newExport.setCount("0");
+ newExport.setRatio("0");
+ }
+ result.add(newExport);
+ }
+ }
+ } else {
+ // targetvalue 涓嶅寘鍚� &锛岀洿鎺ユ坊鍔犲埌缁撴灉
+ result.add(export);
+ }
+ }
+
+ return result;
}
/**
@@ -5219,6 +5586,34 @@
}
return content;
}
+
+ /**
+ * 婊℃剰搴﹁秼鍔挎煡璇�
+ *
+ * @param mydTrendReqVO
+ * @return
+ */
+ @Override
+ public List<MydTrendReqDTO> mydTrend(MydTrendReqVO mydTrendReqVO) {
+ List<MydTrendReqDTO> list = serviceSubtaskMapper.mydTrend(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType());
+ if (mydTrendReqVO.getType().equals("week")) list = getWeekDate(mydTrendReqVO, list);
+ if (mydTrendReqVO.getType().equals("year")) list = getYearDate(mydTrendReqVO, list);
+ if (mydTrendReqVO.getType().equals("month")) list = getMonthDate(mydTrendReqVO, list);
+ if (mydTrendReqVO.getType().equals("day")) list = getDayDate(mydTrendReqVO, list);
+ return list;
+ }
+
+ @Override
+ public List<MydTrendReqDTO> sltdMydTotalByDimension(MydTrendReqVO mydTrendReqVO) {
+ List<MydTrendReqDTO> list = null;
+ if (mydTrendReqVO.getDimensionType().equals("1"))
+ list = serviceSubtaskMapper.sltdMydTotalByDimension(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType());
+ else if (mydTrendReqVO.getDimensionType().equals("2"))
+ list = serviceSubtaskMapper.sltdMydTotalByYQ(mydTrendReqVO.getStartFinishTime(), mydTrendReqVO.getEndFinishTime(), mydTrendReqVO.getType());
+
+ return list;
+ }
+
public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, ServiceTaskdept serviceTaskdept, PatArchive patArchive) {
ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class);
@@ -5684,6 +6079,31 @@
return back;
}
+
+ /**
+ * 闂缁撴灉鍗犳瘮
+ *
+ * @param sltdMydTotalVO
+ * @param serviceSubtaskRes
+ * @return
+ */
+ public List<ServiceSubtaskDetailRatioExport> getDetailRatio(SltdMydTotalVO sltdMydTotalVO, List<ServiceSubtaskRes> serviceSubtaskRes) {
+ List<ServiceSubtaskDetailRatioExport> serviceSubtaskDetailRatioExports = null;
+ if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("2") && (sltdMydTotalVO.getServiceTypeList().contains("6") || sltdMydTotalVO.getServiceTypeList().contains("14"))) {
+ //serviceType锛屽嵆鏈夐殢璁垮張鏈夋弧鎰忓害锛屾殏鏃舵病娉曠粺璁�
+ return serviceSubtaskDetailRatioExports;
+ } else if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("2")) {
+ //鑾峰彇serviceSubtaskList涓殑鎵�鏈塼askid
+ List<Long> taskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getTaskid).filter(ObjectUtils::isNotEmpty).distinct().collect(Collectors.toList());
+ serviceSubtaskDetailRatioExports = statQuestionOption(taskIds, sltdMydTotalVO.getStartFinishTime(), sltdMydTotalVO.getEndFinishTime(), sltdMydTotalVO.getStartOutHospTime(), sltdMydTotalVO.getEndOutHospTime(), sltdMydTotalVO.getQuestionContent(), sltdMydTotalVO.getStartScore(), sltdMydTotalVO.getEndScore(), sltdMydTotalVO.getValueType());
+ } else if (CollectionUtils.isNotEmpty(sltdMydTotalVO.getServiceTypeList()) && sltdMydTotalVO.getServiceTypeList().contains("6") || sltdMydTotalVO.getServiceTypeList().contains("14")) {
+ //婊℃剰搴︾粺璁� 锛堥�氳繃 subtask 鐨� id 鍘荤粺璁★級
+ List<Long> subtaskIds = serviceSubtaskRes.stream().map(ServiceSubtaskRes::getId).collect(Collectors.toList());
+ serviceSubtaskDetailRatioExports = statQuestionOptionBySubtaskIds(subtaskIds, sltdMydTotalVO.getStartOutHospTime(), sltdMydTotalVO.getEndOutHospTime(), sltdMydTotalVO.getStartFinishTime(), sltdMydTotalVO.getEndFinishTime(), sltdMydTotalVO.getQuestionContent(), sltdMydTotalVO.getStartScore(), sltdMydTotalVO.getEndScore(), sltdMydTotalVO.getValueType());
+ }
+ return serviceSubtaskDetailRatioExports;
+ }
+
//鑾峰彇浠诲姟缁勪俊鎭�
private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO) {
if (StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")) {
@@ -5723,4 +6143,276 @@
}
log.info("ai鍖归厤鎴愬姛锛屽尮閰嶇粨鏋滄槸:" + matchedText);
}
+
+ private static String trimAll(String s) {
+ if (s == null) {
+ return "";
+ }
+ int start = 0;
+ int end = s.length();
+ while (start < end && isBlankChar(s.charAt(start))) {
+ start++;
+ }
+ while (end > start && isBlankChar(s.charAt(end - 1))) {
+ end--;
+ }
+ return s.substring(start, end);
+ }
+
+ private static Boolean isBlankChar(char c) {
+ return c == '\u3000' // 鍏ㄨ绌烘牸
+ || c == ' ' // 鍗婅绌烘牸
+ || c == '\t' || c == '\n' || c == '\r' || c == '\f' || Character.isWhitespace(c);
+ }
+
+
+ private String buildKey(String groupName, String questionText, String option) {
+ return groupName + "\u0001" + questionText + "\u0001" + option;
+ }
+
+ private static int parseCount(String s) {
+ if (StringUtils.isEmpty(s)) {
+ return 0;
+ }
+ try {
+ return Integer.parseInt(s.trim());
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ private List<MydTrendReqDTO> getWeekDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) {
+ // 1. 璁$畻鎬诲懆鏁帮紙鍜� SQL 閲岀殑鍏紡淇濇寔涓�鑷达級
+ long days = (mydTrendReqVO.getEndFinishTime().getTime() - mydTrendReqVO.getStartFinishTime().getTime()) / (1000L * 60 * 60 * 24);
+ int totalWeeks = (int) (days / 7) + 1;
+
+ // 2. 宸叉湁鏁版嵁锛歱eriod -> totalScore
+ Map<Integer, String> exist = new HashMap<>();
+ for (MydTrendReqDTO row : list) {
+ // period 鏄暟瀛楋紝鍙兘鏄� Integer / Long / BigDecimal锛岀粺涓�杞� int
+ int p = Integer.parseInt(StringUtils.isNotEmpty(row.getPeriod()) ? row.getPeriod() : "0");
+ exist.put(p, row.getTotalScore() != null ? row.getTotalScore() : "0");
+ // 涓嬮潰杩欒鎸変綘鐨勫師閫昏緫淇濈暀锛堣櫧鐒剁湅璧锋潵鏈夌偣澶氫綑锛�
+ exist.put(p, String.valueOf(row.getTotalScore() != null ? row.getTotalScore() : 0));
+ }
+
+ // 3. 琛ュ叏 1..totalWeeks
+ List<MydTrendReqDTO> result = new ArrayList<>(totalWeeks);
+
+ // 鑾峰彇鏁翠綋鐨勫紑濮嬫椂闂�
+ long startTimeMillis = mydTrendReqVO.getStartFinishTime().getTime();
+ long endTimeMillis = mydTrendReqVO.getEndFinishTime().getTime();
+ long oneWeekMillis = 7L * 24 * 60 * 60 * 1000; // 涓�鍛ㄧ殑姣鏁�
+
+ for (int i = 1; i <= totalWeeks; i++) {
+ MydTrendReqDTO row = new MydTrendReqDTO();
+ row.setPeriod(String.valueOf(i));
+ row.setTotalScore(exist.getOrDefault(i, "0"));
+
+ // -------- 鏂板锛氳缃瘡鍛ㄧ殑 startDate 鍜� endDate --------
+ // 褰撳墠鍛ㄥ紑濮嬫椂闂� = 鏁翠綋寮�濮嬫椂闂� + (i - 1) * 7澶�
+ long currentStartMillis = startTimeMillis + (long) (i - 1) * oneWeekMillis;
+
+ // 褰撳墠鍛ㄧ粨鏉熸椂闂� = 褰撳墠鍛ㄥ紑濮嬫椂闂� + 7澶� - 1姣锛堜繚璇佹槸杩欎竴鍛ㄧ殑鏈�鍚庝竴鍒伙級
+ long currentEndMillis = currentStartMillis + oneWeekMillis - 1;
+
+ // 濡傛灉鏄渶鍚庝竴鍛紝缁撴潫鏃堕棿涓嶈兘瓒呰繃鏁翠綋鐨� endTime
+ if (i == totalWeeks) {
+ currentEndMillis = endTimeMillis;
+ }
+
+ row.setStartDate(new Date(currentStartMillis));
+ row.setEndDate(new Date(currentEndMillis));
+ // ----------------------------------------------------
+
+ result.add(row);
+ }
+
+ return result;
+ }
+
+ private List<MydTrendReqDTO> getYearDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) {
+ // 鑾峰彇鏁翠綋寮�濮嬪拰缁撴潫鏃堕棿
+ Date startTime = mydTrendReqVO.getStartFinishTime();
+ Date endTime = mydTrendReqVO.getEndFinishTime();
+
+ // 1. 璁$畻骞翠唤鑼冨洿
+ // 浣跨敤 Calendar 鑾峰彇璧峰骞翠唤鍜岀粨鏉熷勾浠�
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(startTime);
+ int startYear = cal.get(Calendar.YEAR);
+
+ cal.setTime(endTime);
+ int endYear = cal.get(Calendar.YEAR);
+
+ // 鎬诲勾鏁� (鍖呭惈棣栧熬)
+ int totalYears = endYear - startYear + 1;
+
+ // 2. 宸叉湁鏁版嵁锛歱eriod -> totalScore (鍋囪 period 瀛樼殑鏄勾浠藉瓧绗︿覆锛屽 "2024")
+ Map<String, String> exist = new HashMap<>();
+ for (MydTrendReqDTO row : list) {
+ String period = row.getPeriod() != null ? row.getPeriod() : "";
+ exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0");
+ }
+
+ // 3. 琛ュ叏鎵�鏈夊勾浠�
+ List<MydTrendReqDTO> result = new ArrayList<>(totalYears);
+
+ for (int i = 0; i < totalYears; i++) {
+ int currentYear = startYear + i;
+ String periodKey = String.valueOf(currentYear);
+
+ MydTrendReqDTO row = new MydTrendReqDTO();
+ row.setPeriod(periodKey);
+ // 濡傛灉娌℃湁璇ュ勾浠界殑鏁版嵁锛岄粯璁ょ粰 "0"
+ row.setTotalScore(exist.getOrDefault(periodKey, "0"));
+
+ // -------- 璁剧疆璇ュ勾浠界殑 startDate 鍜� endDate --------
+ Calendar yearCal = Calendar.getInstance();
+ // 璁剧疆涓鸿骞寸殑 1鏈�1鏃� 00:00:00
+ yearCal.set(currentYear, Calendar.JANUARY, 1, 0, 0, 0);
+ yearCal.set(Calendar.MILLISECOND, 0);
+ row.setStartDate(yearCal.getTime());
+
+ // 璁剧疆涓鸿骞寸殑 12鏈�31鏃� 23:59:59
+ yearCal.set(currentYear, Calendar.DECEMBER, 31, 23, 59, 59);
+ yearCal.set(Calendar.MILLISECOND, 999);
+ row.setEndDate(yearCal.getTime());
+ // ----------------------------------------------------
+
+ result.add(row);
+ }
+
+ return result;
+ }
+
+ private List<MydTrendReqDTO> getMonthDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) {
+ // 鑾峰彇鏁翠綋寮�濮嬪拰缁撴潫鏃堕棿
+ Date startTime = mydTrendReqVO.getStartFinishTime();
+ Date endTime = mydTrendReqVO.getEndFinishTime();
+
+ // 1. 璁$畻鏈堜唤鑼冨洿
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(startTime);
+ int startYear = cal.get(Calendar.YEAR);
+ int startMonth = cal.get(Calendar.MONTH); // 娉ㄦ剰锛欳alendar.MONTH 浠� 0 寮�濮�
+
+ cal.setTime(endTime);
+ int endYear = cal.get(Calendar.YEAR);
+ int endMonth = cal.get(Calendar.MONTH);
+
+ // 鎬绘湀鏁� = (缁撴潫骞� - 寮�濮嬪勾) * 12 + (缁撴潫鏈� - 寮�濮嬫湀) + 1
+ int totalMonths = (endYear - startYear) * 12 + (endMonth - startMonth) + 1;
+
+ // 2. 宸叉湁鏁版嵁锛歱eriod -> totalScore (period 瀛樼殑鏄湀浠藉瓧绗︿覆锛屽 "2024-06")
+ Map<String, String> exist = new HashMap<>();
+ for (MydTrendReqDTO row : list) {
+ String period = row.getPeriod() != null ? row.getPeriod() : "";
+ exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0");
+ }
+
+ // 3. 琛ュ叏鎵�鏈夋湀浠�
+ List<MydTrendReqDTO> result = new ArrayList<>(totalMonths);
+
+ Calendar monthCal = Calendar.getInstance();
+ monthCal.set(startYear, startMonth, 1, 0, 0, 0);
+ monthCal.set(Calendar.MILLISECOND, 0);
+
+ for (int i = 0; i < totalMonths; i++) {
+ int currentYear = monthCal.get(Calendar.YEAR);
+ int currentMonth = monthCal.get(Calendar.MONTH) + 1; // 杞垚 1-12 鏈�
+
+ // 鎷兼帴 period锛屾牸寮忥細yyyy-MM锛屾瘮濡� "2024-06"
+ // 濡傛灉浣犲笇鏈涙槸 "2024-6"锛屽彲浠ユ妸 String.format 鏀规垚 currentMonth
+ String periodKey = String.format("%04d-%02d", currentYear, currentMonth);
+
+ MydTrendReqDTO row = new MydTrendReqDTO();
+ row.setPeriod(periodKey);
+ row.setTotalScore(exist.getOrDefault(periodKey, "0"));
+
+ // -------- 璁剧疆璇ユ湀鐨� startDate 鍜� endDate --------
+ // 褰撴湀寮�濮嬫椂闂达細1鍙� 00:00:00.000
+ Calendar startCal = (Calendar) monthCal.clone();
+ row.setStartDate(startCal.getTime());
+
+ // 褰撴湀缁撴潫鏃堕棿锛氫笅涓湀1鍙� 00:00:00.000 鍑� 1 姣
+ Calendar endCal = (Calendar) monthCal.clone();
+ endCal.add(Calendar.MONTH, 1);
+ endCal.add(Calendar.MILLISECOND, -1);
+ row.setEndDate(endCal.getTime());
+ // ----------------------------------------------------
+
+ result.add(row);
+
+ // 杩涘叆涓嬩竴涓湀
+ monthCal.add(Calendar.MONTH, 1);
+ }
+
+ return result;
+ }
+
+ private List<MydTrendReqDTO> getDayDate(MydTrendReqVO mydTrendReqVO, List<MydTrendReqDTO> list) {
+ // 鑾峰彇鏁翠綋寮�濮嬪拰缁撴潫鏃堕棿
+ Date startTime = mydTrendReqVO.getStartFinishTime();
+ Date endTime = mydTrendReqVO.getEndFinishTime();
+
+ // 1. 璁$畻鎬诲ぉ鏁�
+ long oneDayMillis = 24L * 60 * 60 * 1000;
+ // 娉ㄦ剰锛氳繖閲屽彧绠楁棩鏈熷樊锛屼笉鑰冭檻鏃跺垎绉掞紝鍚﹀垯鍙兘宸竴澶�
+ Calendar startCal = Calendar.getInstance();
+ startCal.setTime(startTime);
+ startCal.set(Calendar.HOUR_OF_DAY, 0);
+ startCal.set(Calendar.MINUTE, 0);
+ startCal.set(Calendar.SECOND, 0);
+ startCal.set(Calendar.MILLISECOND, 0);
+
+ Calendar endCal = Calendar.getInstance();
+ endCal.setTime(endTime);
+ endCal.set(Calendar.HOUR_OF_DAY, 0);
+ endCal.set(Calendar.MINUTE, 0);
+ endCal.set(Calendar.SECOND, 0);
+ endCal.set(Calendar.MILLISECOND, 0);
+
+ long days = (endCal.getTimeInMillis() - startCal.getTimeInMillis()) / oneDayMillis;
+ int totalDays = (int) days + 1;
+
+ // 2. 宸叉湁鏁版嵁锛歱eriod -> totalScore (period 瀛樼殑鏄棩鏈熷瓧绗︿覆锛屽 "2024-06-01")
+ Map<String, String> exist = new HashMap<>();
+ for (MydTrendReqDTO row : list) {
+ String period = row.getPeriod() != null ? row.getPeriod() : "";
+ exist.put(period, row.getTotalScore() != null ? row.getTotalScore() : "0");
+ }
+
+ // 3. 琛ュ叏鎵�鏈夋棩鏈�
+ List<MydTrendReqDTO> result = new ArrayList<>(totalDays);
+
+ Calendar dayCal = (Calendar) startCal.clone();
+ for (int i = 0; i < totalDays; i++) {
+ // 鎷兼帴 period锛屾牸寮忥細yyyy-MM-dd
+ String periodKey = String.format("%04d-%02d-%02d", dayCal.get(Calendar.YEAR), dayCal.get(Calendar.MONTH) + 1, dayCal.get(Calendar.DAY_OF_MONTH));
+
+ MydTrendReqDTO row = new MydTrendReqDTO();
+ row.setPeriod(periodKey);
+ row.setTotalScore(exist.getOrDefault(periodKey, "0"));
+
+ // -------- 璁剧疆璇ュぉ鐨� startDate 鍜� endDate --------
+ Calendar startOfDay = (Calendar) dayCal.clone();
+ row.setStartDate(startOfDay.getTime());
+
+ Calendar endOfDay = (Calendar) dayCal.clone();
+ endOfDay.set(Calendar.HOUR_OF_DAY, 23);
+ endOfDay.set(Calendar.MINUTE, 59);
+ endOfDay.set(Calendar.SECOND, 59);
+ endOfDay.set(Calendar.MILLISECOND, 999);
+ row.setEndDate(endOfDay.getTime());
+ // ----------------------------------------------------
+
+ result.add(row);
+
+ // 杩涘叆涓嬩竴澶�
+ dayCal.add(Calendar.DAY_OF_MONTH, 1);
+ }
+
+ return result;
+ }
}
--
Gitblit v1.9.3