From 38955eba4ef0e86bac6b1993b6b03abbbec2a929 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 25 十一月 2026 17:55:06 +0800
Subject: [PATCH] Merge branch '20261118市一随访' into smartor_ls_merge
---
ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java | 205 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 163 insertions(+), 42 deletions(-)
diff --git a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
index d716385..2491df4 100644
--- a/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
+++ b/ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -280,6 +280,9 @@
private static final String AGAIN_LOCK_KEY_PREFIX = "smartor:again:lock:";
private static final long AGAIN_LOCK_SECONDS = 30L;
+ /** 缂欎簯鍘夸汉姘戝尰闄㈡満鏋勭紪鐮� */
+ private static final String JINYUN_PEOPLES_HOSPITAL_ORGID = "47246116333112211A1001";
+
/**
* 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級
*
@@ -2586,7 +2589,8 @@
log.info("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
String drcode = "drcode";
//缂欎簯浜烘皯 鏍规嵁缁忕鍖荤敓鍒嗙粍
- if (serviceSubtaskCountReq.getOrgid().equals("47246116333112211A1001")) {
+ boolean jinyunHospital = JINYUN_PEOPLES_HOSPITAL_ORGID.equals(serviceSubtaskCountReq.getOrgid());
+ if (jinyunHospital) {
drcode = "management_doctor_code";
}
String groupKey = drcode;
@@ -2652,18 +2656,30 @@
collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
break;
}
- //鑾峰彇鍙婃椂鐜囩粺璁″悎闆�
- Map<String, Map<String, Object>> jsRates = getSsRateForSfStatistics(serviceSubtaskCountReq, collect);
+ /*
+ * 缂欎簯鍘夸汉姘戝尰闄㈢殑鈥滃強鏃剁巼鈥濆彛寰勬槸鈥滃強鏃堕殢璁夸汉娆� / 搴旈殢璁夸汉娆♀�濓紝
+ * 蹇呴』鍜屽悓涓�鎵圭粺璁¤閲岀殑 timelyFollowUp / followUpNeeded 淇濇寔涓�鑷淬��
+ * 涓嶈兘鍐嶈蛋 selectTimelyRateBatch锛氳 SQL 鍦ㄦ湭浼犲簲闅忚鏃堕棿鑼冨洿鏃惰繕浼氳拷鍔�
+ * visit_time < NOW()锛屽彧鎸夊嚭闄㈡椂闂寸粺璁℃椂浼氭妸鏈埌鏈熶换鍔℃帓闄ゅ湪鍒嗘瘝澶栵紝
+ * 瀵艰嚧椤甸潰涓婄殑鍙婃椂鐜囧拰鈥滃強鏃堕殢璁夸汉娆�/搴旈殢璁夸汉娆♀�濆涓嶄笂銆�
+ */
+ Map<String, Map<String, Object>> jsRates = jinyunHospital
+ ? Collections.emptyMap()
+ : getSsRateForSfStatistics(serviceSubtaskCountReq, collect);
for (String collectKey : collect.keySet()) {
List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey);
if (CollectionUtils.isEmpty(serviceSubtaskList)) {
continue;
}
ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList, serviceSubtaskCountReq.getFollowUpCountStyle(), serviceSubtaskCountReq.getVisitCount());
+ // hzszlyy锛氬墠绔笉鏀瑰瓧娈碉紝鐩存帴鎶婄疮璁″�煎洖濉埌鍘� manual/voice/sms/weChat 鍙� Again 瀛楁
+ applySiteCumulativeOverride(statistic);
if ("taskid".equals(groupKey)) {
applyTaskGroupInfo(statistic, serviceSubtaskList);
}
- if (ObjectUtils.isNotEmpty(jsRates)) {
+ if (jinyunHospital) {
+ statistic.setRate(calculateJinyunTimelyRate(statistic));
+ } else if (ObjectUtils.isNotEmpty(jsRates)) {
Map<String, Object> jsRateMap = jsRates.get(collectKey);
BigDecimal jsRate = new BigDecimal("0");
if (ObjectUtils.isNotEmpty(jsRateMap) && ObjectUtils.isNotEmpty(jsRateMap.get("rate"))) {
@@ -2768,6 +2784,23 @@
*/
private long nvlLong(Long value) {
return value == null ? 0L : value;
+ }
+
+ /**
+ * 缂欎簯鍘夸汉姘戝尰闄㈠強鏃剁巼锛氬強鏃堕殢璁夸汉娆� / 搴旈殢璁夸汉娆°��
+ * <p>
+ * 涓よ�呴兘鍙栬嚜鍚屼竴鏉$粺璁$粨鏋滐紝淇濊瘉椤甸潰涓婄殑鍙婃椂鐜囦笌杩欎袱鍒楀彲浠ヤ簰鐩搁獙绠椼��
+ * 搴旈殢璁夸汉娆′负 0 鏃惰繑鍥� 0锛屽墠绔寜 0.00% 灞曠ず銆�
+ */
+ private double calculateJinyunTimelyRate(ServiceSubtaskStatistic statistic) {
+ long followUpNeeded = nvlLong(statistic.getFollowUpNeeded());
+ if (followUpNeeded <= 0) {
+ return 0D;
+ }
+ long timelyFollowUp = nvlLong(statistic.getTimelyFollowUp());
+ return BigDecimal.valueOf(timelyFollowUp)
+ .divide(BigDecimal.valueOf(followUpNeeded), 4, RoundingMode.HALF_UP)
+ .doubleValue();
}
/**
@@ -3081,6 +3114,7 @@
}//浜屾鍑洪櫌闅忚
else if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
applyAgainFollowUpExtraStatistics(serviceSubtaskStatistic, serviceSubtask);
+ applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
//鍐嶆搴旈殢璁�
if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -3301,6 +3335,17 @@
/** 鍙戦�佹柟寮忕紪鐮侊細寰俊 */
private static final String PREACHFORM_WECHAT = "5";
+ /** 绱浣嶅浘锛氳闊� */
+ private static final int CUMULATIVE_MASK_VOICE = 1;
+ /** 绱浣嶅浘锛氬井淇� */
+ private static final int CUMULATIVE_MASK_WECHAT = 1 << 1;
+ /** 绱浣嶅浘锛氱煭淇� */
+ private static final int CUMULATIVE_MASK_SMS = 1 << 2;
+ /** 绱浣嶅浘锛氫汉宸� */
+ private static final int CUMULATIVE_MASK_MANUAL = 1 << 3;
+ /** 闇�瑕佹妸绱鍊煎洖濉埌鍘熷瓧娈电殑绔欑偣 */
+ private static final String SITE_HZSZLYY = "hzszlyy";
+
/**
* 棣栨闅忚銆岀疮璁″彂閫佹柟寮忋�嶇粺璁°��
* <p>
@@ -3330,42 +3375,101 @@
if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
return;
}
+ int mask = resolveCumulativePreachformMask(serviceSubtask);
+ if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
+ statistic.setVoiceCumulative(statistic.getVoiceCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
+ statistic.setWeChatCumulative(statistic.getWeChatCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_SMS) != 0) {
+ statistic.setSmsCumulative(statistic.getSmsCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
+ statistic.setManualCumulative(statistic.getManualCumulative() + 1L);
+ }
+ }
+
+ /**
+ * 鍐嶆闅忚銆岀疮璁″彂閫佹柟寮忋�嶇粺璁★紝鍙e緞涓� {@link #applyFirstCumulativePreachformStatistics} 涓�鑷淬��
+ */
+ private void applyAgainCumulativePreachformStatistics(ServiceSubtaskStatistic statistic,
+ ServiceSubtask serviceSubtask,
+ String followUpCountStyle) {
+ if (serviceSubtask.getVisitCount() == null || serviceSubtask.getVisitCount() <= 1) {
+ return;
+ }
+ if (!isCumulativePreachformCountable(serviceSubtask, followUpCountStyle)) {
+ return;
+ }
+ int mask = resolveCumulativePreachformMask(serviceSubtask);
+ if ((mask & CUMULATIVE_MASK_VOICE) != 0) {
+ statistic.setVoiceAgainCumulative(statistic.getVoiceAgainCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_WECHAT) != 0) {
+ statistic.setWeChatAgainCumulative(statistic.getWeChatAgainCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_SMS) != 0) {
+ statistic.setSmsAgainCumulative(statistic.getSmsAgainCumulative() + 1L);
+ }
+ if ((mask & CUMULATIVE_MASK_MANUAL) != 0) {
+ statistic.setManualAgainCumulative(statistic.getManualAgainCumulative() + 1L);
+ }
+ }
+
+ /**
+ * 璁$畻鏌愭潯瀛愪换鍔♀�滃凡杩涘叆杩団�濈殑鍙戦�佹柟寮忎綅鍥俱��
+ * <p>
+ * current_preachform 涓虹┖鍙栫涓�涓紱= -1 瑙嗕负鍏ㄩ儴閬嶅巻瀹岋紱涓嶅湪椤哄簭閲屾椂閫�鍖栦负绮剧‘鍖归厤銆�
+ */
+ private int resolveCumulativePreachformMask(ServiceSubtask serviceSubtask) {
List<String> order = splitPreachformOrder(serviceSubtask.getPreachform());
String current = StringUtils.isNotBlank(serviceSubtask.getCurrentPreachform())
? serviceSubtask.getCurrentPreachform().trim()
: (order.isEmpty() ? null : order.get(0));
if (order.isEmpty()) {
- // 娌℃湁椤哄簭鏃堕��鍖栦负鈥滃綋鍓嶆柟寮忕簿纭尮閰嶁�濓紝涓� SQL 鐨� normalizedPreachformExpr = '' 鍒嗘敮涓�鑷�
- if (current != null) {
- increaseExactCumulative(statistic, current);
- }
- return;
+ return exactCumulativeMask(current);
}
int currentPosition;
if ("-1".equals(current)) {
- // -1 琛ㄧず鎵�鏈夊彂閫佹柟寮忛兘宸查亶鍘嗗畬锛岀浉褰撲簬鍋滃湪鏈�鍚庝竴涓綅缃�
currentPosition = order.size();
} else {
int currentIndex = order.indexOf(current);
if (currentIndex < 0) {
- // 鍘嗗彶寮傚父鍊间笉鍦ㄩ厤缃『搴忛噷锛氬彧鎸夌簿纭尮閰嶅厹搴曪紝閬垮厤鎶婂墠鍚庢柟寮忛兘绠楄繘鍘�
- increaseExactCumulative(statistic, current);
- return;
+ return exactCumulativeMask(current);
}
currentPosition = currentIndex + 1;
}
+ int mask = 0;
if (reachedPreachform(order, PREACHFORM_VOICE, currentPosition)) {
- statistic.setVoiceCumulative(statistic.getVoiceCumulative() + 1L);
+ mask |= CUMULATIVE_MASK_VOICE;
}
if (reachedPreachform(order, PREACHFORM_WECHAT, currentPosition)) {
- statistic.setWeChatCumulative(statistic.getWeChatCumulative() + 1L);
+ mask |= CUMULATIVE_MASK_WECHAT;
}
if (reachedPreachform(order, PREACHFORM_SMS, currentPosition)) {
- statistic.setSmsCumulative(statistic.getSmsCumulative() + 1L);
+ mask |= CUMULATIVE_MASK_SMS;
}
if (reachedPreachform(order, PREACHFORM_MANUAL, currentPosition)) {
- statistic.setManualCumulative(statistic.getManualCumulative() + 1L);
+ mask |= CUMULATIVE_MASK_MANUAL;
}
+ return mask;
+ }
+
+ private int exactCumulativeMask(String current) {
+ if (PREACHFORM_MANUAL.equals(current)) {
+ return CUMULATIVE_MASK_MANUAL;
+ }
+ if (PREACHFORM_VOICE.equals(current)) {
+ return CUMULATIVE_MASK_VOICE;
+ }
+ if (PREACHFORM_SMS.equals(current)) {
+ return CUMULATIVE_MASK_SMS;
+ }
+ if (PREACHFORM_WECHAT.equals(current)) {
+ return CUMULATIVE_MASK_WECHAT;
+ }
+ return 0;
}
private boolean isCumulativePreachformCountable(ServiceSubtask serviceSubtask, String followUpCountStyle) {
@@ -3400,15 +3504,39 @@
return position >= 0 && currentPosition >= position + 1;
}
- private void increaseExactCumulative(ServiceSubtaskStatistic statistic, String current) {
- if (PREACHFORM_MANUAL.equals(current)) {
- statistic.setManualCumulative(statistic.getManualCumulative() + 1L);
- } else if (PREACHFORM_VOICE.equals(current)) {
- statistic.setVoiceCumulative(statistic.getVoiceCumulative() + 1L);
- } else if (PREACHFORM_SMS.equals(current)) {
- statistic.setSmsCumulative(statistic.getSmsCumulative() + 1L);
- } else if (PREACHFORM_WECHAT.equals(current)) {
- statistic.setWeChatCumulative(statistic.getWeChatCumulative() + 1L);
+ /**
+ * hzszlyy 绔欑偣淇濇寔鍓嶇瀛楁涓嶅彉锛氭妸绱鍊煎洖濉埌鍘� manual/voice/sms/weChat 鍙� Again 瀛楁銆�
+ * <p>
+ * 鍏跺畠绔欑偣涓嶈鐩栵紝缁х画浣跨敤鍘熸潵鐨勨�滃綋鍓嶆柟寮忕簿纭尮閰嶁�濆彛寰勩��
+ */
+ private void applySiteCumulativeOverride(ServiceSubtaskStatistic statistic) {
+ if (!SITE_HZSZLYY.equals(active)) {
+ return;
+ }
+ statistic.setManual(nvlLong(statistic.getManualCumulative()));
+ statistic.setVoice(nvlLong(statistic.getVoiceCumulative()));
+ statistic.setSms(nvlLong(statistic.getSmsCumulative()));
+ statistic.setWeChat(nvlLong(statistic.getWeChatCumulative()));
+ statistic.setManualAgain(nvlLong(statistic.getManualAgainCumulative()));
+ statistic.setVoiceAgain(nvlLong(statistic.getVoiceAgainCumulative()));
+ statistic.setSmsAgain(nvlLong(statistic.getSmsAgainCumulative()));
+ statistic.setWeChatAgain(nvlLong(statistic.getWeChatAgainCumulative()));
+ }
+
+ /**
+ * 瓒呴摼鎺ヤ笅閽荤殑鍙戦�佹柟寮忔潯浠躲��
+ * <p>
+ * hzszlyy 绔欑偣鐨勫墠绔笉鏀瑰瓧娈碉紝浠嶇偣鍘熸潵鐨� manualInfo/voiceInfo/...锛�
+ * 鍚庣鏀圭敤绱鍙e緞锛涘叾瀹冪珯鐐逛繚鎸� current_preachform 绮剧‘鍖归厤銆�
+ */
+ private void applyPreachformInfoCondition(ServiceSubtaskCountReq serviceSubtaskCountReq,
+ int visitCount,
+ String preachform) {
+ serviceSubtaskCountReq.setVisitCount(visitCount);
+ if (SITE_HZSZLYY.equals(active)) {
+ serviceSubtaskCountReq.setCumulativePreachform(preachform);
+ } else {
+ serviceSubtaskCountReq.setCurrentPreachform(preachform);
}
}
@@ -3627,6 +3755,7 @@
//鍐嶆鍑洪櫌闅忚
if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() > 1) {
+ applyAgainCumulativePreachformStatistics(serviceSubtaskStatistic, serviceSubtask, followUpCountStyle);
//鍐嶆搴旈殢璁�
if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
serviceSubtaskStatistic.setNeedFollowUpAgain(serviceSubtaskStatistic.getNeedFollowUpAgain() + 1L);
@@ -4131,20 +4260,16 @@
serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
break;
case "manualInfo":
- serviceSubtaskCountReq.setVisitCount(1);
- serviceSubtaskCountReq.setCurrentPreachform("1");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_MANUAL);
break;
case "voiceInfo":
- serviceSubtaskCountReq.setVisitCount(1);
- serviceSubtaskCountReq.setCurrentPreachform("3");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_VOICE);
break;
case "smsInfo":
- serviceSubtaskCountReq.setVisitCount(1);
- serviceSubtaskCountReq.setCurrentPreachform("4");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_SMS);
break;
case "weChatInfo":
- serviceSubtaskCountReq.setVisitCount(1);
- serviceSubtaskCountReq.setCurrentPreachform("5");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 1, PREACHFORM_WECHAT);
break;
// 绱鍙e緞锛氭寜 preachform 鐨勬墽琛岄『搴忥紝current_preachform 浣嶄簬璇ユ柟寮忓強涔嬪悗鍗宠鍏�
case "voiceCumulativeInfo":
@@ -4204,20 +4329,16 @@
serviceSubtaskCountReq.setSendstates(new ArrayList<>(Arrays.asList(5L, 7L)));
break;
case "manualAgainInfo":
- serviceSubtaskCountReq.setVisitCount(2);
- serviceSubtaskCountReq.setCurrentPreachform("1");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_MANUAL);
break;
case "voiceAgainInfo":
- serviceSubtaskCountReq.setVisitCount(2);
- serviceSubtaskCountReq.setCurrentPreachform("3");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_VOICE);
break;
case "smsAgainInfo":
- serviceSubtaskCountReq.setVisitCount(2);
- serviceSubtaskCountReq.setCurrentPreachform("4");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_SMS);
break;
case "weChatAgainInfo":
- serviceSubtaskCountReq.setVisitCount(2);
- serviceSubtaskCountReq.setCurrentPreachform("5");
+ applyPreachformInfoCondition(serviceSubtaskCountReq, 2, PREACHFORM_WECHAT);
break;
case "manualAgainSuccessInfo":
serviceSubtaskCountReq.setVisitCount(1);
--
Gitblit v1.9.3