فهرست منبع

chore: auto bump version and changelog [skip ci]

iwt 1 ماه پیش
والد
کامیت
7e27841d4c

+ 23 - 22
cfc-backend/src/main/java/com/etotem/cfc/service/BodyFatScaleService.java

@@ -48,17 +48,18 @@ public class BodyFatScaleService {
     /**
      * 体脂秤指标编码定义
      */
-    private static final Map<String, String> BODY_FAT_INDICATORS = Map.of(
-            "体重", "weight",
-            "BMI", "bmi",
-            "体脂率", "body_fat_percent",
-            "肌肉量", "muscle_mass",
-            "水分", "water_percent",
-            "蛋白质", "protein_percent",
-            "骨量", "bone_mass",
-            "内脏脂肪", "visceral_fat",
-            "基础代谢", "basal_metabolic"
-    );
+    private static final Map<String, String> BODY_FAT_INDICATORS = new HashMap<String, String>();
+    static {
+        BODY_FAT_INDICATORS.put("体重", "weight");
+        BODY_FAT_INDICATORS.put("BMI", "bmi");
+        BODY_FAT_INDICATORS.put("体脂率", "body_fat_percent");
+        BODY_FAT_INDICATORS.put("肌肉量", "muscle_mass");
+        BODY_FAT_INDICATORS.put("水分", "water_percent");
+        BODY_FAT_INDICATORS.put("蛋白质", "protein_percent");
+        BODY_FAT_INDICATORS.put("骨量", "bone_mass");
+        BODY_FAT_INDICATORS.put("内脏脂肪", "visceral_fat");
+        BODY_FAT_INDICATORS.put("基础代谢", "basal_metabolic");
+    }
 
     /**
      * 获取目录下所有图片文件
@@ -152,7 +153,7 @@ public class BodyFatScaleService {
             imageUrlContent.set("image_url", imageUrl);
             contentArr.add(textContent);
             contentArr.add(imageUrlContent);
-            userMsg.set("content", contentArr);
+            userMsg.put("content", contentArr.toString());
             messages.add(userMsg);
             body.set("messages", messages);
             body.put("max_tokens", 500);
@@ -213,12 +214,12 @@ public class BodyFatScaleService {
      */
     private List<Map<String, Object>> mockMetrics() {
         List<Map<String, Object>> metrics = new ArrayList<>();
-        metrics.add(Map.of("name", "体重", "value", "65.2", "unit", "kg"));
-        metrics.add(Map.of("name", "BMI", "value", "22.5", "unit", ""));
-        metrics.add(Map.of("name", "体脂率", "value", "25.3", "unit", "%"));
-        metrics.add(Map.of("name", "肌肉量", "value", "52.1", "unit", "kg"));
-        metrics.add(Map.of("name", "水分", "value", "55.2", "unit", "%"));
-        metrics.add(Map.of("name", "内脏脂肪", "value", "8", "unit", "级"));
+        Map<String,Object> m1=new HashMap<>(); m1.put("name","体重"); m1.put("value","65.2"); m1.put("unit","kg"); metrics.add(m1);
+        Map<String,Object> m2=new HashMap<>(); m2.put("name","BMI"); m2.put("value","22.5"); m2.put("unit",""); metrics.add(m2);
+        Map<String,Object> m3=new HashMap<>(); m3.put("name","体脂率"); m3.put("value","25.3"); m3.put("unit","%"); metrics.add(m3);
+        Map<String,Object> m4=new HashMap<>(); m4.put("name","肌肉量"); m4.put("value","52.1"); m4.put("unit","kg"); metrics.add(m4);
+        Map<String,Object> m5=new HashMap<>(); m5.put("name","水分"); m5.put("value","55.2"); m5.put("unit","%"); metrics.add(m5);
+        Map<String,Object> m6=new HashMap<>(); m6.put("name","内脏脂肪"); m6.put("value","8"); m6.put("unit","级"); metrics.add(m6);
         return metrics;
     }
 
@@ -236,7 +237,7 @@ public class BodyFatScaleService {
             String valueStr = (String) metric.get("value");
             String unit = (String) metric.get("unit");
 
-            if (name == null || name.isBlank() || valueStr == null || valueStr.isBlank()) {
+            if (name == null || name.trim().isEmpty() || valueStr == null || valueStr.trim().isEmpty()) {
                 skipped.incrementAndGet();
                 continue;
             }
@@ -253,7 +254,7 @@ public class BodyFatScaleService {
             iv.setSourceType("body_fat_scale");
             iv.setSourceId(memberId);
             iv.setDefinitionId(def.getId());
-            iv.setValue(valueStr + (unit != null && !unit.isBlank() ? " " + unit : ""));
+            iv.setValue(valueStr + (unit != null && !unit.trim().isEmpty() ? " " + unit : ""));
             try {
                 iv.setNumericValue(new java.math.BigDecimal(valueStr));
             } catch (Exception e) {
@@ -275,7 +276,7 @@ public class BodyFatScaleService {
      */
     private IndicatorDefinition findOrCreateDefinition(String name, String unit) {
         // 先按中文名查找
-        var defs = indicatorDefinitionMapper.selectList(
+        List<IndicatorDefinition> defs = indicatorDefinitionMapper.selectList(
                 new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<IndicatorDefinition>()
                         .eq(IndicatorDefinition::getName, name)
                         .eq(IndicatorDefinition::getStatus, 1));
@@ -298,7 +299,7 @@ public class BodyFatScaleService {
         def.setCode(code);
         def.setName(name);
         def.setDataType("number");
-        def.setUnit(unit != null && !unit.isBlank() ? unit : "");
+        def.setUnit(unit != null && !unit.trim().isEmpty() ? unit : "");
         def.setSortOrder(0);
         def.setStatus(1);
         indicatorDefinitionMapper.insert(def);

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-91d5a1a3924490e833253cfb22647dd491290f49
+78cb0bc43af56b2d1a943ef27678b9c93c489f56

+ 2 - 2
cfc-web/package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "cfc-web",
-  "version": "1.0.1158",
+  "version": "1.0.1159",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "cfc-web",
-      "version": "1.0.1158",
+      "version": "1.0.1159",
       "dependencies": {
         "@wangeditor/editor": "^5.1.23",
         "@wangeditor/editor-for-vue": "^1.0.2",