From d92193cb2ece5a34b910571fc830a1401abe8eef Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 22 一月 2026 14:56:41 +0800
Subject: [PATCH] 【丽水】getSfStatistics 优化
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 83 ++++++++++++++++++++++++++---------------
1 files changed, 52 insertions(+), 31 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 f98f258..05c8767 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -2235,50 +2235,71 @@
// 鏍规嵁鏉′欢杩涜鍒嗙粍
Map<String, List<ServiceSubtask>> collect = new HashMap<>();
- if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && serviceSubtaskCountReq.getLeavehospitaldistrictcodes().size() > 0) {
+ String groupKeyType = "";
+
+ if (serviceSubtaskCountReq.getLeavehospitaldistrictcodes() != null && !serviceSubtaskCountReq.getLeavehospitaldistrictcodes().isEmpty()) {
if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
- collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown")));
+ groupKeyType = "drCode";
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
} else {
- collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictname()).orElse("Unknown")));
+ groupKeyType = "leaveHospitalDistrictCode";
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown")));
}
- } else if (serviceSubtaskCountReq.getDeptcodes() != null && serviceSubtaskCountReq.getDeptcodes().size() > 0) {
+ } else if (serviceSubtaskCountReq.getDeptcodes() != null && !serviceSubtaskCountReq.getDeptcodes().isEmpty()) {
if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
- collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrname()).orElse("Unknown")));
+ groupKeyType = "drCode";
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
} else {
- collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptname()).orElse("Unknown")));
+ groupKeyType = "deptCode";
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown")));
}
}
+ List<String> groupKeyList = new ArrayList<>(collect.keySet());
+ //鍙婃椂鐜囩粺璁�
+ ServiceSubtaskVO ssRate = new ServiceSubtaskVO();
+ ssRate.setOrgid(serviceSubtaskCountReq.getOrgid());
+ ssRate.setStarttime(serviceSubtaskCountReq.getStartTime());
+ ssRate.setEndtime(serviceSubtaskCountReq.getEndTime());
+ if (serviceSubtaskCountReq.getEndTime() != null && new Date().before(serviceSubtaskCountReq.getEndTime())) {
+ ssRate.setEndtime(new Date());
+ }
+ switch (groupKeyType)
+ {
+ case "deptCode":
+ ssRate.setGroupKey("deptcode");
+ ssRate.setGroupKeyList(groupKeyList);
+ break;
+ case "drCode":
+ ssRate.setGroupKey("drcode");
+ ssRate.setGroupKeyList(groupKeyList);
+ break;
+ case "leaveHospitalDistrictCode":
+ ssRate.setGroupKey("leavehospitaldistrictcode");
+ ssRate.setGroupKeyList(groupKeyList);
+ break;
+ default:
+ ssRate.setGroupKey("drcode");
+ ssRate.setGroupKeyList(groupKeyList);
+ break;
+ }
+ Map<String, Map<String, Object>> jsRates = new HashMap<>();
+ if(!collect.isEmpty()){
+ jsRates = serviceSubtaskMapper.selectTimelyRateBatch(ssRate);
+ }
-
- for (List<ServiceSubtask> serviceSubtaskList : collect.values()) {
+ for (String collectKey : collect.keySet()) {
+ List<ServiceSubtask> serviceSubtaskList = collect.get(collectKey);
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());
- }
+ Map<String, Object> jsRateMap = jsRates.get(collectKey);
+ BigDecimal jsRate = new BigDecimal("0");
+ if(ObjectUtils.isNotEmpty(jsRateMap) && ObjectUtils.isNotEmpty(jsRateMap.get("rate"))){
+ jsRate = new BigDecimal(jsRateMap.get("rate").toString());
}
-
- 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);
-
+ Double jsRateDouble = (jsRate.setScale(4, RoundingMode.HALF_UP)).doubleValue();
+ statistic.setRate(jsRateDouble);
if (ObjectUtils.isNotEmpty(statistic)) {
serviceSubtaskStatistics.add(statistic);
}
--
Gitblit v1.9.3