xiatian 3 months ago
parent
commit
930c53a1a1
1 changed files with 28 additions and 21 deletions
  1. 28 21
      src/main/java/cn/com/qmth/am/service/impl/DsMarkingServiceImpl.java

+ 28 - 21
src/main/java/cn/com/qmth/am/service/impl/DsMarkingServiceImpl.java

@@ -36,26 +36,27 @@ public class DsMarkingServiceImpl implements DsMarkingService {
 
 
     private static final Logger log = LoggerFactory.getLogger(DsMarkingService.class);
     private static final Logger log = LoggerFactory.getLogger(DsMarkingService.class);
 
 
-    @SuppressWarnings("deprecation")
-    public static void main(String[] args) {
-
-        Map<String, String> headers = new HashMap<>();
-        headers.put("Authorization", "Bearer 7dac2f2166994b8f9c6de0a8eff2814c");
-        Response resp = null;
-        try {
-            resp = OKHttpUtil.call(HttpMethod.POST, "http://39.174.90.3:31091/spiritx-api/v1/chat/completions", headers,
-                    "{\"model\":\"deepseek-r1-distill-qwen-32b-awq\",\"messages\":[{\"role\":\"user\",\"content\":\"你是谁?\"}]}");
-            if (resp.code() != 200) {
-                throw new RuntimeException("err :" + resp.body().string());
-            } else {
-                System.out.println("成功处理:" + resp.body().string());
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        } finally {
-            IOUtils.closeQuietly(resp);
-        }
-    }
+    // @SuppressWarnings("deprecation")
+    // public static void main(String[] args) {
+    //
+    // Map<String, String> headers = new HashMap<>();
+    // headers.put("Authorization", "Bearer 7dac2f2166994b8f9c6de0a8eff2814c");
+    // Response resp = null;
+    // try {
+    // resp = OKHttpUtil.call(HttpMethod.POST,
+    // "http://39.174.90.3:31091/spiritx-api/v1/chat/completions", headers,
+    // "{\"model\":\"deepseek-r1-distill-qwen-32b-awq\",\"messages\":[{\"role\":\"user\",\"content\":\"你是谁?\"}]}");
+    // if (resp.code() != 200) {
+    // throw new RuntimeException("err :" + resp.body().string());
+    // } else {
+    // System.out.println("成功处理:" + resp.body().string());
+    // }
+    // } catch (Exception e) {
+    // throw new RuntimeException(e);
+    // } finally {
+    // IOUtils.closeQuietly(resp);
+    // }
+    // }
 
 
     @Override
     @Override
     public AutoScoreResult autoScore(AutoScoreRequest request) {
     public AutoScoreResult autoScore(AutoScoreRequest request) {
@@ -73,7 +74,7 @@ public class DsMarkingServiceImpl implements DsMarkingService {
                     getDecimalPlaces(request.getTotalScore()));
                     getDecimalPlaces(request.getTotalScore()));
             int stepCount = request.getStandardAnswer().size();
             int stepCount = request.getStandardAnswer().size();
             String scoreStr = text.substring(text.lastIndexOf("\n") + 1).trim();
             String scoreStr = text.substring(text.lastIndexOf("\n") + 1).trim();
-            String[] scores = StringUtils.split(scoreStr.replaceAll(",", ",").replaceAll("[0-9]\\.", ""), ",");
+            String[] scores = StringUtils.split(fomatStr(scoreStr), ",");
             double[] scoreArray = new double[stepCount];
             double[] scoreArray = new double[stepCount];
             for (int i = 0; i < stepCount; i++) {
             for (int i = 0; i < stepCount; i++) {
                 // 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
                 // 根据得分率与步骤总分计算实际得分,按最大精度保留小数位数
@@ -93,6 +94,12 @@ public class DsMarkingServiceImpl implements DsMarkingService {
         }
         }
     }
     }
 
 
+    private String fomatStr(String scoreStr) {
+        String ret = scoreStr.replaceAll(",", ",").replaceAll("。", "").replaceAll(":", ":").replaceAll("[0-9]\\.", "");
+        ret = ret.substring(ret.lastIndexOf(":") + 1).trim();
+        return ret;
+    }
+
     private int getDecimalPlaces(double value) {
     private int getDecimalPlaces(double value) {
         return Math.max(0, BigDecimal.valueOf(value).stripTrailingZeros().scale());
         return Math.max(0, BigDecimal.valueOf(value).stripTrailingZeros().scale());
     }
     }