From 371603a0eb9f3a279cf77073734e991b5851b792 Mon Sep 17 00:00:00 2001
From: sinake <sinake1@qq.com>
Date: 星期五, 05 九月 2025 16:21:01 +0800
Subject: [PATCH] 市一短信接口同步服务对接
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 194 +++++++++++++++++++++++++++++------------------
1 files changed, 119 insertions(+), 75 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 f9ba7d0..010442c 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -15,7 +15,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.ListOperations;
@@ -24,6 +23,7 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.Duration;
@@ -292,7 +292,7 @@
Integer dsf = 0;
for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
if (serviceSubtask.getSendstate() == 4L) wzx = wzx + 1;
- else if (serviceSubtask.getSendstate() != 4L) ysf = ysf + 1;
+ else if (serviceSubtask.getSendstate() != 4L && serviceSubtask.getSendstate() != 2L) ysf = ysf + 1;
if (serviceSubtask.getSendstate() == 5L) fssb = fssb + 1;
if (serviceSubtask.getSendstate() >= 3L || serviceSubtask.getSendstate() == 1L) yfs = yfs + 1;
if (serviceSubtask.getSendstate() == 2L) dsf = dsf + 1;
@@ -854,7 +854,7 @@
//鏈変笅涓�棰�
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
IvrTaskTemplateScriptVO nextQuestion = getNextQuestion(IvrTaskTemplateScriptVOs, nowQuestion);
- // 闂锛� 鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+ // 闂锛� 鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
String date = simpleDateFormat1.format(new Date());
log.info("鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
phoneUtils.ttsPlayback(nowQuestion.getIvrtext(), phoneCallBackVO.getUuid());
@@ -863,7 +863,7 @@
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
//璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
String slienceText = nowQuestion.getSlienceText();
- //闈欓粯璇濇湳 + 闂锛� 鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+ //闈欓粯璇濇湳 + 闂锛� 鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
String date = simpleDateFormat1.format(new Date());
log.info("闈欓粯璇濇湳 + 闂,鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
phoneUtils.ttsPlayback(slienceText + nowQuestion.getIvrtext(), phoneCallBackVO.getUuid());
@@ -1028,9 +1028,9 @@
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
}
- //璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback鈥濆皢缁撴灉浼犲洖
+ //璋冪敤"15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback"灏嗙粨鏋滀紶鍥�
String date = simpleDateFormat1.format(new Date());
- log.info("璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀�------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
+ log.info("璋冪敤tts鍚堟垚鍜屾挱鏀�------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
phoneUtils.ttsPlayback(nowQuestion.getIvrtext() + ivrTaskTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid());
}
break;
@@ -1061,7 +1061,7 @@
if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
//澶勭悊鎸傛柇
if (phoneCallReqYQVO.getAsrtext().contains("鎷ㄥ彨鐨勭敤鎴锋蹇�")) {
- //鍒ゆ柇 recordAccept-hungup 鏄惁鏈夊�硷紝濡傛灉鏈夛紝鍒欒鏄庝笉鐢ㄥ鐞嗕簡锛屼箣鍓嶅凡缁忓鐞嗚繃浜嗭紙recordAccept-hungup杩欎釜涓昏鏄粰鈥滈�氳瘽璁板綍鐢ㄧ殑锛屸�濓級
+ //鍒ゆ柇 recordAccept-hungup 鏄惁鏈夊�硷紝濡傛灉鏈夛紝鍒欒鏄庝笉鐢ㄥ鐞嗕簡锛屼箣鍓嶅凡缁忓鐞嗚繃浜嗭紙recordAccept-hungup杩欎釜涓昏鏄粰"閫氳瘽璁板綍鐢ㄧ殑锛�"锛�
Object cacheObject = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup");
if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) {
return new PhoneCallBackYQVO();
@@ -1243,6 +1243,7 @@
}
break;
}
+ log.info("鏄惁闇�瑕佹寕鏈猴細{}", les);
if (ObjectUtils.isNotEmpty(les)) {
//瀵瑰尮閰嶇殑缁撴灉澶勭悊涓�涓�(鐪嬬湅鏄笉鏄渶瑕佹寕鏈�)
if (les.getIsEnd() != null && les.getIsEnd() == 1) {
@@ -1301,6 +1302,7 @@
if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
//璇存槑鍖归厤姝g‘浜�
//杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
+ log.info("鍖归厤姝g‘浜嗗悧--------------");
ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1);
serviceTaskScriptTargetoptionMapper.updateIvrTaskTemplateTargetoption(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j));
@@ -1389,8 +1391,9 @@
if (script.getSort() == nextQuestion.intValue()) {
phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
- String scriptContent = script.getIvrtext();
+ String scriptContent = StringUtils.isNotEmpty(script.getIvrtext()) ? script.getIvrtext() : script.getScriptContent();
log.error("涓嬩竴棰橀棶棰橈細{}", scriptContent);
+ log.error("涓嬩竴棰樼殑瀛愪换鍔℃槸锛歿}", serviceSubtask);
phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
//灏嗚鎮h�呯殑Redis涓殑棰樼洰ID锛岃繘琛屼慨鏀�
redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
@@ -1429,6 +1432,7 @@
}
} else {
+ log.info("娌℃湁鍖归厤涓�----------------------------");
//flag=0,璇存槑娌� 鍖归厤涓婏紝涔熻鎶婃偅鑰呰鐨勮瘽璁板綍涓嬫潵
if (j == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1 && flag == 0) {
ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
@@ -1456,6 +1460,7 @@
}
//閮芥病鏈夊尮閰嶅埌
if (StringUtils.isEmpty(phoneCallBackYQVO.getValue())) {
+ log.info("閮芥病鏈夊尮閰嶅埌-------------------------");
Integer count = null;
Object countObj = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
if (ObjectUtils.isNotEmpty(countObj)) count = (Integer) countObj;
@@ -1486,9 +1491,11 @@
//鍘籸edis涓紝鎶婅瀛愪换鍔D鍒犻櫎
Long id = serviceSubtask.getId();
Map<String, String> map = delRedisValue(null, id.toString());
- redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
- redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
- redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ if (ObjectUtils.isNotEmpty(map)) {
+ redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
+ redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ }
// return phoneCallBackYQVO;
} else {
//鏍规嵁ivrTaskTemplateScriptVO.getNextScriptno()鑾峰彇涓嬩竴棰樿繘琛屾彁闂�
@@ -1496,7 +1503,7 @@
if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) {
phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
- String scriptContent = script.getIvrtext();
+ String scriptContent = StringUtils.isNotEmpty(script.getIvrtext()) ? script.getIvrtext() : script.getScriptContent();
phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
//灏嗚鎮h�呯殑Redis涓殑棰樼洰ID锛岃繘琛屼慨鏀�
redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
@@ -1550,7 +1557,8 @@
if (ivrTaskTemplateScriptVO.getNextScriptno().intValue() == ivrTaskTemplateScript1.getSort()) {
phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
- String scriptContent = ivrTaskTemplateScript1.getIvrtext();
+ String scriptContent = StringUtils.isNotEmpty(ivrTaskTemplateScript1.getIvrtext()) ? ivrTaskTemplateScript1.getIvrtext() : ivrTaskTemplateScript1.getScriptContent();
+
phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
redisCache.setCacheObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone(), ivrTaskTemplateScript1.getId().toString());
@@ -1603,6 +1611,9 @@
for (String key : map.keySet()) {
scriptContent = scriptContent.replace(key, StringUtils.isNotEmpty(map.get(key)) ? map.get(key) : "");
}
+ }
+ if (StringUtils.isEmpty(scriptContent)) {
+ return scriptContent;
}
scriptContent = scriptContent.replace("${name}", StringUtils.isNotEmpty(serviceSubtask.getSendname()) ? serviceSubtask.getSendname() : "");
scriptContent = scriptContent.replace("${dzz}", StringUtils.isNotEmpty(serviceSubtask.getAddr()) ? serviceSubtask.getAddr() : "");
@@ -1676,10 +1687,9 @@
//蹇呴』绛塧che-exist鍏ㄩ儴鎵撳畬鎵嶈兘鎷夊彇涓嬩竴鎵癸紙涓昏鏄�曟墍鏈夌殑鏁版嵁閮藉爢鍦ㄧ數璇濈殑缂撳瓨閲岋紝鍦ㄨ瀹氱殑鏃堕棿鎵撲笉瀹岋級
long existSize = listOps.size("cache-exist");
if (existSize > 0) return pullTaskVOList;
-
+ int count = 0;
long size = listOps.size("cache-0");
log.error("---------鎵撶數璇濅箣鍓嶇紦瀛樹腑鐨勬暟鎹噺锛歿}", size);
- int count = 0;
if (size > 0) {
//phoneCount() 閫氳繃缁欏嚭鐨勬瘡涓皬鏃堕渶瑕佹墦鍑虹殑鐢佃瘽閲忥紝绠楀嚭鍒版櫄涓�8鐐逛竴鐐硅兘鎵撳嚭澶氬皯涓數璇濓紝鑾峰彇鍒版�婚噺
//濡傛灉闇�瑕佺珛鍗虫墽琛岀殑鏁版嵁閲忓ぇ浜庝竴澶╄鎵ц鐨勪笂闄愶紝鍒欏彧鍙栦笂闄愮殑鏁伴噺锛屽叾瀹冪殑鍒欐斁鍥瀝edis涓�
@@ -1688,6 +1698,7 @@
cacheList = listOps.range("cache-0", 0, count - 1);
}
}
+
log.error("浠诲姟鎷夊彇cache-0鐨勫�兼槸澶氬皯锛歿}", cacheList);
// cache-0涓虹珛鍗冲彂璧风殑,鍏跺畠鐨勫厛鎺ㄨ繜
@@ -1699,17 +1710,21 @@
} else {
for (int i = 1; i < 6; i++) {
//鍙栧嚭浠巆ache-1 鍒� cache-5鐨勭涓�涓瓙浠诲姟淇℃伅
- Long size1 = listOps.size("cache-" + i);
- if (size1 == null || size1 == 0) continue;
- int count1 = Math.min(phoneCount(), size1.intValue());
- List<String> value = listOps.range("cache-0" + i, 0, count1 - 1);
+ try {
+ Long size1 = listOps.size("cache-" + i);
+ if (size1 == null || size1 == 0) continue;
+ int count1 = Math.min(phoneCount(), size1.intValue());
+ List<String> value = listOps.range("cache-0" + i, 0, count1 - 1);
- List<PullTaskVO> pullTaskVOList2 = getPullTaskList(value, "cache-" + i);
- if (CollectionUtils.isNotEmpty(pullTaskVOList2) && pullTaskVOList2.size() > 0) {
- pullTaskVOList.addAll(pullTaskVOList2);
+ List<PullTaskVO> pullTaskVOList2 = getPullTaskList(value, "cache-" + i);
+ if (CollectionUtils.isNotEmpty(pullTaskVOList2) && pullTaskVOList2.size() > 0) {
+ pullTaskVOList.addAll(pullTaskVOList2);
+ }
+ //灏嗗鐞嗚繃鐨勬暟鎹垹闄�
+ listOps.trim("cache-0" + i, count1, -1);
+ } catch (Exception e) {
+// log.error("鐪嬬潃鐑�");
}
- //灏嗗鐞嗚繃鐨勬暟鎹垹闄�
- listOps.trim("cache-0" + i, count1, -1);
}
}
//existList鐢ㄦ潵璁板綍鎺ヤ笅鏉ラ渶瑕佹墽琛岀殑瀛愪换鍔D
@@ -1903,14 +1918,14 @@
// //鏈変笅涓�棰�
// redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
// IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
-// // 闂锛� 鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+// // 闂锛� 鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
// phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
// }
// } else {
// redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
// //璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
// String slienceText = nowQuestion.getSlienceText();
-// //闈欓粯璇濇湳 + 闂锛� 鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+// //闈欓粯璇濇湳 + 闂锛� 鍘昏皟鐢�"tts鍚堟垚鍜屾挱鏀�"鎺ュ彛
// phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
// return new PhoneCallBackVO();
// }
@@ -2020,7 +2035,7 @@
// redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
// }
//
-// //璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback鈥濆皢缁撴灉浼犲洖
+// //璋冪敤"15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback"灏嗙粨鏋滀紶鍥�
//
//
// }
@@ -2068,7 +2083,7 @@
ServiceSubtaskDetail ssd = new ServiceSubtaskDetail();
ssd.setSubId(serviceSubtaskDetail.getSubId());
ssd.setTaskid(serviceSubtaskDetail.getTaskid());
- ssd.setTemplatequestionnum(serviceSubtaskDetail.getTemplatequestionnum());
+ ssd.setScriptid(serviceSubtaskDetail.getScriptid());
if (serviceSubtaskDetail.getSubId() != null) {
ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(serviceSubtaskDetail.getSubId());
ssd.setGuid(serviceSubtask.getGuid());
@@ -2172,6 +2187,37 @@
}
/**
+ * 鏈嶅姟缁熻鏌ヨ - 鎸夋椂闂寸淮搴︾粺璁″嚭闄�/闂ㄨ瘖闅忚鏁版嵁
+ *
+ * @param request 缁熻璇锋眰鍙傛暟
+ * @return 缁熻缁撴灉鍒楄〃
+ */
+ @Override
+ public List<ServiceStatisticsResponse> getServiceStatistics(ServiceStatisticsRequest request) {
+ log.info("getServiceStatistics鐨勫叆鍙備负锛歿}", request);
+
+ // 鍙傛暟鏍¢獙
+ if (request.getStartDate() == null || request.getEndDate() == null) {
+ throw new IllegalArgumentException("寮�濮嬫棩鏈熷拰缁撴潫鏃ユ湡涓嶈兘涓虹┖");
+ }
+
+ if (request.getStartDate().after(request.getEndDate())) {
+ throw new IllegalArgumentException("寮�濮嬫棩鏈熶笉鑳芥櫄浜庣粨鏉熸棩鏈�");
+ }
+
+ // 濡傛灉timeType涓虹┖锛岄粯璁ゆ寜澶╃粺璁�
+ if (StringUtils.isEmpty(request.getTimeType())) {
+ request.setTimeType("day");
+ }
+
+ List<ServiceStatisticsResponse> result = serviceSubtaskMapper.getServiceStatistics(request);
+
+
+ log.info("getServiceStatistics杩斿洖缁撴灉鏁伴噺锛歿}", result.size());
+ return result;
+ }
+
+ /**
* 鑾峰彇闅忚缁熻姣斾緥
*
* @param serviceSubtaskCountReq
@@ -2181,19 +2227,54 @@
public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) {
log.error("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
List<ServiceSubtaskStatistic> serviceSubtaskStatistics = new ArrayList<>();
- //Map<String, List<ServiceSubtask>> collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown")));
+ List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq);
+
+ // 鏍规嵁鏉′欢杩涜鍒嗙粍
Map<String, List<ServiceSubtask>> collect = new HashMap<>();
+
if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) {
- collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown")));
-
+ if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
+ collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown")));
+ } else {
+ collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown")));
+ }
} else if (serviceSubtaskCountReq.getDeptcodes() != null && serviceSubtaskCountReq.getDeptcodes().size() > 0) {
- collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown")));
+ if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
+ collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown")));
+ } else {
+ collect = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq).stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown")));
+ }
}
+
for (List<ServiceSubtask> serviceSubtaskList : collect.values()) {
if (CollectionUtils.isEmpty(serviceSubtaskList)) {
continue;
}
ServiceSubtaskStatistic statistic = getStatistic(serviceSubtaskList);
+
+ //鍙婃椂鐜�
+ ServiceSubtask ss = new ServiceSubtask();
+ ss.setOrgid(serviceSubtaskList.get(0).getOrgid());
+
+ // 濡傛灉鏈夊尰鐢熺紪鐮侊紝璁剧疆鍖荤敓缂栫爜鐢ㄤ簬鍙婃椂鐜囨煡璇�
+ if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
+ ss.setDrcode(serviceSubtaskList.get(0).getDrcode());
+ }else {
+ if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getLeavehospitaldistrictcodes())) {
+ ss.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode());
+ } else if (CollectionUtils.isNotEmpty(serviceSubtaskCountReq.getDeptcodes())) {
+ ss.setDeptcode(serviceSubtaskList.get(0).getDeptcode());
+ }
+ }
+
+ ss.setStarttime(serviceSubtaskCountReq.getStartTime());
+ ss.setEndtime(serviceSubtaskCountReq.getEndTime());
+ if (serviceSubtaskCountReq.getEndTime() != null && new Date().before(serviceSubtaskCountReq.getEndTime())) {
+ ss.setEndtime(new Date());
+ }
+ Double jsRate = serviceSubtaskMapper.selectTimelyRate(ss);
+ statistic.setRate(jsRate);
+
if (ObjectUtils.isNotEmpty(statistic)) {
serviceSubtaskStatistics.add(statistic);
}
@@ -2209,6 +2290,8 @@
serviceSubtaskStatistic.setDeptcode(serviceSubtaskList.get(0).getDeptcode());
serviceSubtaskStatistic.setLeavehospitaldistrictname(serviceSubtaskList.get(0).getLeavehospitaldistrictname());
serviceSubtaskStatistic.setLeavehospitaldistrictcode(serviceSubtaskList.get(0).getLeavehospitaldistrictcode());
+ serviceSubtaskStatistic.setDrcode(serviceSubtaskList.get(0).getDrcode());
+ serviceSubtaskStatistic.setDrname(serviceSubtaskList.get(0).getDrname());
//鍑洪櫌浜烘
serviceSubtaskStatistic.setDischargeCount(serviceSubtaskList.size());
for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
@@ -2220,6 +2303,7 @@
if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
serviceSubtaskStatistic.setFollowUpNeeded(serviceSubtaskStatistic.getFollowUpNeeded() + 1L);
}
+
//棣栨鍑洪櫌闅忚
if (serviceSubtask.getVisitCount() != null && serviceSubtask.getVisitCount() == 1) {
if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
@@ -2288,48 +2372,6 @@
}
- /*serviceSubtaskStatistic.setServiceCount(serviceSubtaskList.size());
- for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
- //涓嶉殢璁挎暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 4) {
- serviceSubtaskStatistic.setBzxCount(serviceSubtaskStatistic.getBzxCount() + 1L);
- }
- //搴旈殢璁挎暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() != 4) {
- serviceSubtaskStatistic.setYsfCount(serviceSubtaskStatistic.getYsfCount() + 1L);
- }
- //鍙戦�佸け璐ユ暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 5) {
- serviceSubtaskStatistic.setFssbCount(serviceSubtaskStatistic.getFssbCount() + 1L);
- }
- //寰呭彂閫佹暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 2) {
- serviceSubtaskStatistic.setDfsCount(serviceSubtaskStatistic.getDfsCount() + 1L);
- }
- //宸插彂閫佹暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 3) {
- serviceSubtaskStatistic.setYfsCount(serviceSubtaskStatistic.getYfsCount() + 1L);
- }
- //宸插畬鎴愭暟閲�
- if (serviceSubtask.getSendstate() != null && serviceSubtask.getSendstate() == 6) {
- //宸插彂閫侊紝鍖呭惈宸插畬鎴�
- serviceSubtaskStatistic.setYfsCount(serviceSubtaskStatistic.getYfsCount() + 1L);
- serviceSubtaskStatistic.setYwcCount(serviceSubtaskStatistic.getYwcCount() + 1L);
- }
-
- if (StringUtils.isNotEmpty(serviceSubtask.getExcep()) && serviceSubtask.getExcep().equals("1")) {
- //寮傚父鏍囪瘑
- serviceSubtaskStatistic.setYczs(serviceSubtaskStatistic.getYczs() + 1L);
- }
- }
- //闅忚瀹屾垚鐜�=宸插畬鎴�/搴旈殢璁块噺
- if (serviceSubtaskStatistic.getYwcCount() == 0 || CollectionUtils.isEmpty(serviceSubtaskList)) {
- serviceSubtaskStatistic.setSfwcl("0");
- } else {
-// BigDecimal multiply = BigDecimal.valueOf(serviceSubtaskStatistic.getYfsCount()).divide(BigDecimal.valueOf(serviceSubtaskList.size()), 2, BigDecimal.ROUND_HALF_UP);
- BigDecimal multiply = new BigDecimal(serviceSubtaskStatistic.getYwcCount().toString()).divide(new BigDecimal(serviceSubtaskStatistic.getYsfCount().toString()), 2, BigDecimal.ROUND_HALF_UP);
- serviceSubtaskStatistic.setSfwcl(multiply.toString());
- }*/
return serviceSubtaskStatistic;
@@ -2347,6 +2389,8 @@
}
private ServiceSubtaskDetail getServiceSubtaskDetail(PhoneCallReqYQVO phoneCallReqYQVO, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate) {
+ log.info("-----------------phoneCallReqYQVO鐨勫�间负锛歿}", phoneCallReqYQVO);
+
ServiceSubtaskDetail serviceSubtaskDetail = new ServiceSubtaskDetail();
serviceSubtaskDetail.setSubId(Long.valueOf(phoneCallReqYQVO.getTaskid()));
ServiceSubtask serviceSubtask1 = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(phoneCallReqYQVO.getTaskid()));
@@ -2370,7 +2414,7 @@
serviceSubtaskDetail.setSentEnd(1L);
serviceSubtaskDetail.setTemplateid(ivrTaskTemplate.getId().toString());
serviceSubtaskDetail.setTemplatequestionnum(ivrTaskTemplateScriptVO.getScriptno());
- serviceSubtaskDetail.setQuestiontext(ivrTaskTemplateScriptVO.getIvrtext());
+ serviceSubtaskDetail.setQuestiontext(StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrtext()) ? ivrTaskTemplateScriptVO.getIvrtext() : ivrTaskTemplateScriptVO.getScriptContent());
serviceSubtaskDetail.setQuestionvoice(phoneCallReqYQVO.getRecordpath());
serviceSubtaskDetail.setCategoryname(ivrTaskTemplateScriptVO.getScriptType());
serviceSubtaskDetail.setTargetoptions(ivrTaskTemplateScriptVO.getTargetOptions());
--
Gitblit v1.9.3