From 60ade5154522a042c816abaa1840751011ae0371 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 29 九月 2026 19:15:03 +0800
Subject: [PATCH] 1.省立同德满度问题处理 2.门急诊数据采集优化
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java | 129 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 117 insertions(+), 12 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java
index 85ceebe..ca2cba4 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java
@@ -26,6 +26,7 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@@ -204,9 +205,14 @@
/**
- * 鏌ヨ鎮h�呴殢璁夸俊鎭�
+ * 鐪佺珛鍚屽痉婊℃剰搴︽暟鎹粺璁★紙鎸夐鐩粺璁¢�夐」鏁伴噺/鍗犳瘮锛屽苟缁欏嚭璇ラ鐨勭患鍚堝緱鍒嗭級
+ * <p>
+ * 缁煎悎婊℃剰搴� = (寰堟弧鎰忛」鏁懊�1 + 婊℃剰椤规暟脳0.8 + 涓�鑸」鏁懊�0.6 + 涓嶆弧鎰忛」鏁懊�0.4 + 寰堜笉婊℃剰椤规暟脳0.2)
+ * / (寰堟弧鎰忛」鏁� + 婊℃剰椤规暟 + 涓�鑸」鏁� + 涓嶆弧鎰忛」鏁� + 寰堜笉婊℃剰椤规暟) 脳 100%锛�
+ * 銆屾湭缁忓巻銆嶃�屼笉閫傜敤銆嶇瓑涓嶅湪浜旀。閲岀殑閫夐」鏃笉杩涘垎瀛愪篃涓嶈繘鍒嗘瘝銆�
*/
@ApiOperation("鐪佺珛鍚屽痉婊℃剰搴︽暟鎹粺璁�")
+ @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
@PostMapping("/sltdMydTotalByScore")
public Map<String, Object> sltdMydTotalByScore(@RequestBody SltdMydTotalVO sltdMydTotalVO) {
List<ServiceSubtaskRes> serviceSubtaskResList = null;
@@ -220,6 +226,9 @@
serviceSubtaskEntity.setDeptOrDistrict(sltdMydTotalVO.getDeptOrDistrict());
serviceSubtaskEntity.setLeavehospitaldistrictcodes(sltdMydTotalVO.getLeavehospitaldistrictcodes());
serviceSubtaskEntity.setLeaveldeptcodes(sltdMydTotalVO.getLeaveldeptcodes());
+ //鏈烘瀯/闄㈠尯鐢� @AddOrgId 娉ㄥ叆锛岃惤鍒版煡璇㈡潯浠朵笂锛岄伩鍏嶈法鏈烘瀯鍙栨暟
+ serviceSubtaskEntity.setOrgid(sltdMydTotalVO.getOrgid());
+ serviceSubtaskEntity.setCampusid(sltdMydTotalVO.getCampusid());
if (serviceSubtaskEntity != null) {
List<ServiceSubtask> serviceSubtasks = serviceSubtaskService.getServiceSubtasks(serviceSubtaskEntity);
List<ServiceSubtaskRes> serviceSubtaskRes = DtoConversionUtils.sourceToTarget(serviceSubtasks, ServiceSubtaskRes.class);
@@ -236,6 +245,10 @@
if (CollectionUtils.isNotEmpty(serviceSubtaskResList)) {
List<ServiceSubtaskDetailRatioExport> detailList = serviceSubtaskService.getDetailRatio(sltdMydTotalVO, serviceSubtaskResList);
+ if (detailList == null) {
+ //serviceType 缁勫悎涓嶅湪鏀寔鑼冨洿鍐咃紙濡傚悓鏃跺惈闅忚 2 鍜屾弧鎰忓害 6/14锛夛紝缁欐槑纭彁绀鸿�屼笉鏄倓鎮勮繑鍥炵┖鏁扮粍
+ return error("褰撳墠 serviceType 缁勫悎鏆備笉鏀寔缁熻闂鍗犳瘮锛岃鍒嗗紑鏌ヨ锛堜粎鏀寔闅忚 2 鎴栨弧鎰忓害 6/14锛�");
+ }
if (CollectionUtils.isNotEmpty(detailList)) {
Map<String, List<ServiceSubtaskDetailRatioExport>> groupedMap = detailList.stream().collect(Collectors.groupingBy(ServiceSubtaskDetailRatioExport::getQuestiontext));
@@ -243,17 +256,8 @@
QuestionResultDTO questionResultDTO = new QuestionResultDTO();
questionResultDTO.setQeustionText(questionText);
questionResultDTO.setSubtaskDetailRatioExportList(exportList);
- BigDecimal allCount = new BigDecimal("0");
- BigDecimal allScore = new BigDecimal("0.00");
-
- for (ServiceSubtaskDetailRatioExport ssdre : exportList) {
- if (StringUtils.isNotEmpty(ssdre.getCount()))
- allCount.add(BigDecimal.valueOf(Long.valueOf(ssdre.getCount())));
- allScore.add(BigDecimal.valueOf(Double.valueOf(ssdre.getScore())));
- }
-
- if (allCount.compareTo(BigDecimal.ZERO) > 0)
- questionResultDTO.setAvgScore(allScore.divide(allCount, 2).toString());
+ //缁煎悎寰楀垎锛�(寰堟弧鎰徝�1 + 婊℃剰脳0.8 + 涓�鑸�0.6 + 涓嶆弧鎰徝�0.4 + 寰堜笉婊℃剰脳0.2) / 浜旀。椤规暟涔嬪拰 脳 100%
+ questionResultDTO.setAvgScore(calcMydScore(exportList));
result.add(questionResultDTO);
});
}
@@ -287,4 +291,105 @@
return success(serviceSubtaskService.mzMydScoreRank(mzMydScoreRankVO));
}
+ /**
+ * 澶氶�夐鐨勯棶棰樼被鍨�
+ */
+ private static final String VALUE_TYPE_MULTIPLE = "2";
+
+ /**
+ * 婊℃剰搴︿簲妗i�夐」锛堥『搴忎笌鏉冮噸椤哄簭涓�鑷达級
+ */
+ private static final String[] MYD_SCORE_OPTIONS = {"寰堟弧鎰�", "婊℃剰", "涓�鑸�", "涓嶆弧鎰�", "寰堜笉婊℃剰"};
+
+ /**
+ * 婊℃剰搴︿簲妗f潈閲嶏細寰堟弧鎰� 1銆佹弧鎰� 0.8銆佷竴鑸� 0.6銆佷笉婊℃剰 0.4銆佸緢涓嶆弧鎰� 0.2
+ */
+ private static final BigDecimal[] MYD_SCORE_WEIGHTS = {
+ new BigDecimal("1"), new BigDecimal("0.8"), new BigDecimal("0.6"), new BigDecimal("0.4"), new BigDecimal("0.2")};
+
+ /**
+ * 璁$畻涓�閬撻鐨勬弧鎰忓害缁煎悎寰楀垎锛堢櫨鍒嗗埗锛屼繚鐣欎袱浣嶅皬鏁帮級
+ * <p>
+ * 缁煎悎婊℃剰搴� = (寰堟弧鎰忛」鏁懊�1 + 婊℃剰椤规暟脳0.8 + 涓�鑸」鏁懊�0.6 + 涓嶆弧鎰忛」鏁懊�0.4 + 寰堜笉婊℃剰椤规暟脳0.2)
+ * / (寰堟弧鎰忛」鏁� + 婊℃剰椤规暟 + 涓�鑸」鏁� + 涓嶆弧鎰忛」鏁� + 寰堜笉婊℃剰椤规暟) 脳 100%
+ * <p>
+ * 鏉冮噸鎸夐�夐」鏂囨鍒ゅ畾锛堣 {@link #mydScoreOptionIndex(String)}锛夛紝涓嶅啀渚濊禆鏄庣粏鐨� score 瀛楁锛�
+ * 鍘嗗彶鏁版嵁閲� score 鏈� 0銆併��0000000001銆嶈繖绫昏剰鍊硷紝鎸� score 绠椾細鎶婂緱鍒嗗浐瀹氭垚 0 鎴� 100銆�
+ * 銆屾湭缁忓巻銆嶃�屼笉閫傜敤銆嶇瓑涓嶅湪浜旀。閲岀殑閫夐」鏃笉杩涘垎瀛愪篃涓嶈繘鍒嗘瘝銆�
+ *
+ * @param exportList 鍚屼竴閬撻鐩殑閫夐」缁熻鏄庣粏
+ * @return 鐧惧垎鍒剁患鍚堝緱鍒嗭紝鏃犳湁鏁堥」鏁版椂杩斿洖 "0.00"
+ */
+ private String calcMydScore(List<ServiceSubtaskDetailRatioExport> exportList) {
+ if (CollectionUtils.isEmpty(exportList)) return "0.00";
+
+ BigDecimal scoreSum = BigDecimal.ZERO; //鍒嗗瓙锛毼�(妗d綅鏉冮噸 脳 椤规暟)
+ BigDecimal countSum = BigDecimal.ZERO; //鍒嗘瘝锛氫簲妗i」鏁颁箣鍜�
+
+ for (ServiceSubtaskDetailRatioExport detail : exportList) {
+ //澶氶�夐涓�琛屾槸澶氫釜閫夐」鐨勫垎鍊间箣鍜岋紝鍒嗘瘝鍙畻 1 椤癸紝浼氭妸寰楀垎绠楅珮锛屼笉璁″叆缁煎悎寰楀垎
+ if (VALUE_TYPE_MULTIPLE.equals(detail.getValueType())) continue;
+ //銆屼笉閫傜敤銆嶄笉鍦ㄥ叕寮忕殑浜旀。閲岋紝涓嶈鍏ョ患鍚堝緱鍒�
+ if (isNotApplicable(detail)) continue;
+
+ int optionIndex = mydScoreOptionIndex(detail.getOptionresult());
+ BigDecimal count = parseDecimal(detail.getCount());
+ if (optionIndex < 0 || count == null || count.signum() <= 0) continue;
+
+ scoreSum = scoreSum.add(MYD_SCORE_WEIGHTS[optionIndex].multiply(count));
+ countSum = countSum.add(count);
+ }
+
+ if (countSum.signum() <= 0) return "0.00";
+
+ return scoreSum.divide(countSum, 6, RoundingMode.HALF_UP)
+ .multiply(BigDecimal.valueOf(100))
+ .setScale(2, RoundingMode.HALF_UP)
+ .toPlainString();
+ }
+
+ /**
+ * 閫夐」鏂囨 鈫� 婊℃剰搴︿簲妗d笅鏍囷紙寰堟弧鎰� 0銆佹弧鎰� 1銆佷竴鑸� 2銆佷笉婊℃剰 3銆佸緢涓嶆弧鎰� 4锛夛紝涓嶅湪浜旀。閲岃繑鍥� -1
+ */
+ private int mydScoreOptionIndex(String optionresult) {
+ if (StringUtils.isEmpty(optionresult)) return -1;
+ String text = optionresult.trim();
+ for (int i = 0; i < MYD_SCORE_OPTIONS.length; i++) {
+ if (MYD_SCORE_OPTIONS[i].equals(text)) return i;
+ }
+ //鍏煎銆孉 寰堟弧鎰忋�嶃�孊.婊℃剰銆嶈繖绫诲甫閫夐」搴忓彿鍓嶇紑鐨勫巻鍙叉暟鎹�
+ if (text.length() > 2 && (text.charAt(1) == ' ' || text.charAt(1) == '.' || text.charAt(1) == '銆�')) {
+ String stripped = text.substring(2).trim();
+ for (int i = 0; i < MYD_SCORE_OPTIONS.length; i++) {
+ if (MYD_SCORE_OPTIONS[i].equals(stripped)) return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * 鏄惁銆屼笉閫傜敤銆嶉�夐」
+ */
+ private boolean isNotApplicable(ServiceSubtaskDetailRatioExport detail) {
+ return containsNotApplicable(detail.getOptionresult()) || containsNotApplicable(detail.getTargetvalue());
+ }
+
+ private boolean containsNotApplicable(String optionText) {
+ if (StringUtils.isEmpty(optionText)) return false;
+ String text = optionText.trim();
+ return text.contains("涓嶉�傜敤") || text.contains("鏈瓟") || text.contains("鎷掔瓟");
+ }
+
+ /**
+ * 瀛楃涓茶浆 BigDecimal锛岀┖鍊�/闈炴硶鍊艰繑鍥� null
+ */
+ private BigDecimal parseDecimal(String value) {
+ if (StringUtils.isEmpty(value)) return null;
+ try {
+ return new BigDecimal(value.trim());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
}
--
Gitblit v1.9.3