From 0afac42fb2e9d6e5291304dd0044ce3042b45d2b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期六, 10 十月 2026 15:09:14 +0800
Subject: [PATCH] 短信模块提交
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskDetailController.java | 64 +++++++++++++++++++++++---------
1 files changed, 46 insertions(+), 18 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 d29f168..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
@@ -207,9 +207,9 @@
/**
* 鐪佺珛鍚屽痉婊℃剰搴︽暟鎹粺璁★紙鎸夐鐩粺璁¢�夐」鏁伴噺/鍗犳瘮锛屽苟缁欏嚭璇ラ鐨勭患鍚堝緱鍒嗭級
* <p>
- * 缁煎悎婊℃剰搴� = 危(閫夐」鍒嗗�� 脳 椤规暟) / 危椤规暟 / 鏈鏈�楂樺垎鍊� 脳 100%锛�
- * 鍒嗗�煎彇 1銆�0.8銆�0.6銆�0.4銆�0.2 浜旀。锛堝緢婊℃剰銆佹弧鎰忋�佷竴鑸�佷笉婊℃剰銆佸緢涓嶆弧鎰忥級锛�
- * 銆屼笉閫傜敤銆嶃��0 鍒嗐�佺┖鍊肩瓑鏃笉杩涘垎瀛愪篃涓嶈繘鍒嗘瘝銆�
+ * 缁煎悎婊℃剰搴� = (寰堟弧鎰忛」鏁懊�1 + 婊℃剰椤规暟脳0.8 + 涓�鑸」鏁懊�0.6 + 涓嶆弧鎰忛」鏁懊�0.4 + 寰堜笉婊℃剰椤规暟脳0.2)
+ * / (寰堟弧鎰忛」鏁� + 婊℃剰椤规暟 + 涓�鑸」鏁� + 涓嶆弧鎰忛」鏁� + 寰堜笉婊℃剰椤规暟) 脳 100%锛�
+ * 銆屾湭缁忓巻銆嶃�屼笉閫傜敤銆嶇瓑涓嶅湪浜旀。閲岀殑閫夐」鏃笉杩涘垎瀛愪篃涓嶈繘鍒嗘瘝銆�
*/
@ApiOperation("鐪佺珛鍚屽痉婊℃剰搴︽暟鎹粺璁�")
@AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
@@ -256,7 +256,7 @@
QuestionResultDTO questionResultDTO = new QuestionResultDTO();
questionResultDTO.setQeustionText(questionText);
questionResultDTO.setSubtaskDetailRatioExportList(exportList);
- //缁煎悎寰楀垎锛毼�(鍒嗗�济楅」鏁�) / 危椤规暟 / 鏈鏈�楂樺垎鍊� 脳 100%锛屼笉閫傜敤/0鍒�/绌哄�间笉杩涘垎瀛愪篃涓嶈繘鍒嗘瘝
+ //缁煎悎寰楀垎锛�(寰堟弧鎰徝�1 + 婊℃剰脳0.8 + 涓�鑸�0.6 + 涓嶆弧鎰徝�0.4 + 寰堜笉婊℃剰脳0.2) / 浜旀。椤规暟涔嬪拰 脳 100%
questionResultDTO.setAvgScore(calcMydScore(exportList));
result.add(questionResultDTO);
});
@@ -297,11 +297,25 @@
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>
- * 缁煎悎婊℃剰搴� = 危(閫夐」鍒嗗�� 脳 椤规暟) / 危椤规暟 / 鏈鏈�楂樺垎鍊� 脳 100%
- * 绛変环浜� 危(寰堟弧鎰徝�1 + 婊℃剰脳0.8 + 涓�鑸�0.6 + 涓嶆弧鎰徝�0.4 + 寰堜笉婊℃剰脳0.2) / 危(浜旀。椤规暟) 脳 100%銆�
- * 鐢ㄦ湰棰樻渶楂樺垎鍊煎綊涓�鍖栵紝鍏煎鏄庣粏鍒嗗�煎瓨 0-1 鏉冮噸锛�1銆�0.8鈥︼級鍜屽瓨 5 鍒嗗埗锛�5銆�4鈥︼級涓ょ鍙e緞銆�
+ * 缁煎悎婊℃剰搴� = (寰堟弧鎰忛」鏁懊�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"
@@ -309,9 +323,8 @@
private String calcMydScore(List<ServiceSubtaskDetailRatioExport> exportList) {
if (CollectionUtils.isEmpty(exportList)) return "0.00";
- BigDecimal scoreSum = BigDecimal.ZERO; //鍒嗗瓙锛毼�(閫夐」鍒嗗�� 脳 椤规暟)
- BigDecimal countSum = BigDecimal.ZERO; //鍒嗘瘝锛毼i」鏁�
- BigDecimal maxScore = null; //鏈鏈�楂樺垎鍊硷紝鐢ㄤ簬褰掍竴鍖�
+ BigDecimal scoreSum = BigDecimal.ZERO; //鍒嗗瓙锛毼�(妗d綅鏉冮噸 脳 椤规暟)
+ BigDecimal countSum = BigDecimal.ZERO; //鍒嗘瘝锛氫簲妗i」鏁颁箣鍜�
for (ServiceSubtaskDetailRatioExport detail : exportList) {
//澶氶�夐涓�琛屾槸澶氫釜閫夐」鐨勫垎鍊间箣鍜岋紝鍒嗘瘝鍙畻 1 椤癸紝浼氭妸寰楀垎绠楅珮锛屼笉璁″叆缁煎悎寰楀垎
@@ -319,27 +332,42 @@
//銆屼笉閫傜敤銆嶄笉鍦ㄥ叕寮忕殑浜旀。閲岋紝涓嶈鍏ョ患鍚堝緱鍒�
if (isNotApplicable(detail)) continue;
- BigDecimal score = parseDecimal(detail.getScore());
+ int optionIndex = mydScoreOptionIndex(detail.getOptionresult());
BigDecimal count = parseDecimal(detail.getCount());
- if (score == null || count == null) continue;
- //0 鍒嗭紙鏈瓟/绌虹瓟锛夈�佺┖鏁伴噺锛氭棦涓嶈繘鍒嗗瓙涔熶笉杩涘垎姣�
- if (score.signum() <= 0 || count.signum() <= 0) continue;
+ if (optionIndex < 0 || count == null || count.signum() <= 0) continue;
- if (maxScore == null || score.compareTo(maxScore) > 0) maxScore = score;
- scoreSum = scoreSum.add(score.multiply(count));
+ scoreSum = scoreSum.add(MYD_SCORE_WEIGHTS[optionIndex].multiply(count));
countSum = countSum.add(count);
}
- if (maxScore == null || countSum.signum() <= 0) return "0.00";
+ if (countSum.signum() <= 0) return "0.00";
return scoreSum.divide(countSum, 6, RoundingMode.HALF_UP)
- .divide(maxScore, 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) {
--
Gitblit v1.9.3