From c24d16a37523a49080392610357872ce580cbc38 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 26 十月 2026 14:03:33 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-satisfaction/src/main/java/com/ruoyi/satisfaction/config/SatisfactionSwitch.java |   74 +++++++++++++++++++++++++++++++++++--
 1 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/ruoyi-satisfaction/src/main/java/com/ruoyi/satisfaction/config/SatisfactionSwitch.java b/ruoyi-satisfaction/src/main/java/com/ruoyi/satisfaction/config/SatisfactionSwitch.java
index 6603274..cb326b7 100644
--- a/ruoyi-satisfaction/src/main/java/com/ruoyi/satisfaction/config/SatisfactionSwitch.java
+++ b/ruoyi-satisfaction/src/main/java/com/ruoyi/satisfaction/config/SatisfactionSwitch.java
@@ -52,6 +52,24 @@
     public static final String CONFIG_KEY = "satisfaction.enabled";
 
     /**
+     * 婊℃剰搴︺�岀患鍚堝緱鍒嗗彛寰勩�嶇珯鐐瑰弬鏁伴敭鍚嶃��
+     * <p>
+     * 鍊煎彇 {@link com.ruoyi.satisfaction.service.strategy.SatisfactionSites} 鐨勬爣璇嗭細
+     * <ul>
+     *   <li>{@code sltd}锛堥粯璁わ級鈥斺�� 鐪佺珛鍚屽痉鍙e緞锛氭寜閫夐」鏂囨鍒や簲妗e姞鏉冿紱</li>
+     *   <li>{@code common}锛堝埆鍚� {@code nanhua}锛夆�斺�� 閫氱敤/鍗楀崕鍙e緞锛氭寜鏄庣粏 score 姹傚钩鍧囥��</li>
+     * </ul>
+     * 鏈弬鏁版槸 2026-10-21 鏂板鐨勶細{@code /smartor/serviceSubtaskDetail/sltdMydTotalByScore}
+     * 鍘熸潵鎶婂彛寰勫啓姝绘垚 SLTD锛屽崡鍗庤皟鐢ㄦ椂浜旀。鏂囨涓�鏉¢兘鍖归厤涓嶄笂锛岀患鍚堝緱鍒嗘亽涓� 0.00銆�
+     */
+    public static final String SITE_CONFIG_KEY = "satisfaction.site";
+
+    /**
+     * 鏈厤缃珯鐐规椂鐨勯粯璁ゅ彛寰勶細淇濇寔鍘嗗彶琛屼负锛圫LTD 鍙e緞锛�
+     */
+    private static final String DEFAULT_SITE = com.ruoyi.satisfaction.service.strategy.SatisfactionSites.SLTD;
+
+    /**
      * 杩涚▼鍐呯紦瀛樻湁鏁堟湡锛堟绉掞級
      */
     private static final long CACHE_TTL_MILLIS = 10_000L;
@@ -77,6 +95,16 @@
     private volatile long cachedAt;
 
     /**
+     * 鏈�杩戜竴娆¤В鏋愬埌鐨勩�岀患鍚堝緱鍒嗗彛寰勩�嶇珯鐐�
+     */
+    private volatile String cachedSite;
+
+    /**
+     * 鏈�杩戜竴娆¤В鏋愮珯鐐圭殑鏃堕棿鎴�
+     */
+    private volatile long cachedSiteAt;
+
+    /**
      * Spring 浣跨敤鐨勬瀯閫犲櫒銆�
      * <p>
      * 鈿狅笍 <b>蹇呴』鏄惧紡鏍囨敞 {@code @Autowired}</b>锛氭湰绫绘湁涓や釜鍏紑鏋勯�犲櫒
@@ -99,6 +127,9 @@
         // 闈� Spring 鐜涓嬫病鏈�"鏀归厤缃悗绛� 10 绉�"鐨勬蹇碉紝鐩存帴绂佺敤缂撳瓨锛屼繚璇佹柇瑷�鍗虫椂鍙
         this.cachedEnabled = resolve();
         this.cachedAt = System.currentTimeMillis() + CACHE_TTL_MILLIS * 1000L;
+        // 娴嬭瘯鐢ㄧ殑 FixedProvider 瀵逛换浣� key 閮借繑鍥炲悓涓�涓�硷紝杩欓噷涓嶈璇妸瀹冨綋鎴愮珯鐐归厤缃�
+        this.cachedSite = DEFAULT_SITE;
+        this.cachedSiteAt = System.currentTimeMillis() + CACHE_TTL_MILLIS * 1000L;
     }
 
     /**
@@ -121,13 +152,48 @@
      */
     public void invalidateCache() {
         this.cachedEnabled = null;
+        this.cachedSite = null;
+    }
+
+    /**
+     * 褰撳墠鐨�<b>缁煎悎寰楀垎鍙e緞绔欑偣</b>锛坽@code sys_config: satisfaction.site}锛岃繍琛屾椂鐑锛屾渶澶� 10 绉掑欢杩燂級
+     * <p>
+     * 鏈厤缃椂杩斿洖 {@link #DEFAULT_SITE}锛坽@code sltd}锛夛紝淇濇寔鍘嗗彶琛屼负涓嶅彉锛�
+     * 鍗楀崕閮ㄧ讲璇锋妸璇ュ弬鏁伴厤鎴� {@code common}锛堝埆鍚� {@code nanhua}锛夈��
+     *
+     * @return 褰掍竴鍖栧悗鐨勭珯鐐规爣璇嗭紙瑙� {@link com.ruoyi.satisfaction.service.strategy.SatisfactionSites}锛�
+     */
+    public String site() {
+        long now = System.currentTimeMillis();
+        String cached = this.cachedSite;
+        if (cached != null && now - this.cachedSiteAt < CACHE_TTL_MILLIS) {
+            return cached;
+        }
+        String site = resolveSite();
+        this.cachedSite = site;
+        this.cachedSiteAt = now;
+        return site;
+    }
+
+    /**
+     * 瑙f瀽绔欑偣鍙e緞锛歴ys_config 浼樺厛锛岀己鐪佺敤 {@link #DEFAULT_SITE}
+     */
+    private String resolveSite() {
+        String value = readConfig(SITE_CONFIG_KEY);
+        if (value != null) {
+            String site = com.ruoyi.satisfaction.service.strategy.SatisfactionSites.normalize(value);
+            log.debug("銆愭弧鎰忓害銆戠患鍚堝緱鍒嗗彛寰勫彇鑷� sys_config锛歿}={} -> site={}", SITE_CONFIG_KEY, value, site);
+            return site;
+        }
+        log.debug("銆愭弧鎰忓害銆憇ys_config 涓湭閰嶇疆 {}锛屽洖钀介粯璁ょ珯鐐� {}锛堝悓寰峰彛寰勶級", SITE_CONFIG_KEY, DEFAULT_SITE);
+        return DEFAULT_SITE;
     }
 
     /**
      * 瑙f瀽褰撳墠寮�鍏冲�硷細sys_config 浼樺厛锛屽叾娆� yml 鍏滃簳
      */
     private boolean resolve() {
-        String value = readFromSysConfig();
+        String value = readConfig(CONFIG_KEY);
         if (value != null) {
             if (!"true".equalsIgnoreCase(value) && !"false".equalsIgnoreCase(value)) {
                 log.warn("銆愭弧鎰忓害銆憇ys_config 涓� {} 鐨勫�间笉鏄� true/false锛堝疄闄�=銆寋}銆嶏級锛屽皢鎸夈�屼笉鏄� false 鍗冲惎鐢ㄣ�嶅鐞�",
@@ -145,7 +211,7 @@
     /**
      * 璇� sys_config 鐨勫師濮嬮敭鍊硷紱娌℃湁瀹炵幇銆佹病鏈夎繖涓�琛屻�佹垨璇诲簱澶辫触閮借繑鍥� {@code null}
      */
-    private String readFromSysConfig() {
+    private String readConfig(String key) {
         if (configServiceProvider == null) {
             return null;
         }
@@ -154,7 +220,7 @@
             if (configService == null) {
                 return null;
             }
-            String value = configService.selectConfigByKey(CONFIG_KEY);
+            String value = configService.selectConfigByKey(key);
             if (value == null || value.trim().isEmpty()) {
                 return null;
             }
@@ -162,7 +228,7 @@
         } catch (Exception e) {
             // 瀹瑰櫒娌℃湁瀹炵幇銆佹暟鎹簮寮傚父銆丼QL 鎶ラ敊鈥︹�︿竴寰嬫寜"鍙傛暟缂哄け"澶勭悊锛坒ail-open锛夛紝缁濅笉褰卞搷涓绘祦绋�
             log.warn("銆愭弧鎰忓害銆戣鍙� sys_config 鐨� {} 澶辫触锛屾湰娆℃寜鏈厤缃鐞嗭紙fail-open锛夛細{}",
-                    CONFIG_KEY, e.toString());
+                    key, e.toString());
             return null;
         }
     }

--
Gitblit v1.9.3