From d727cdfbd0315850f3c7572149e77f5421db5682 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 18 六月 2025 15:52:12 +0800
Subject: [PATCH] 生成波次功能优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java |   73 +++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
index c65ac30..c2f1713 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
@@ -30,10 +30,10 @@
 public class FieldsUtils {
 
     /**
-     * @author Ryan
-     * @description 閫氳繃瀛楁鍞竴鏍囪瘑鑾峰彇鍔ㄦ�佸瓧娈靛璞ey-value
      * @param
      * @return 鎵╁睍瀛楁瀵硅薄
+     * @author Ryan
+     * @description 閫氳繃瀛楁鍞竴鏍囪瘑鑾峰彇鍔ㄦ�佸瓧娈靛璞ey-value
      * @time 2025/3/12 12:50
      */
     public static Map<String, String> getFields(String uuid) {
@@ -45,7 +45,7 @@
         }
         FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
         List<FieldsItem> fieldsItems = fieldsItemService.list(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getUuid, uuid));
-        for (Fields field : fields ) {
+        for (Fields field : fields) {
             if (fieldsItems.isEmpty()) {
                 fieldsMap.put(field.getFields(), null);
                 continue;
@@ -57,14 +57,14 @@
             });
         }
 
-        return  fieldsMap;
+        return fieldsMap;
     }
 
     /**
+     * @param
+     * @return 鍖呭惈鎵╁睍瀛楁鐨勯泦鍚堝璞�
      * @author Ryan
      * @description 鑾峰彇闆嗗悎鎵╁睍瀛楁key-value鍊�
-     * @param
-     * @return  鍖呭惈鎵╁睍瀛楁鐨勯泦鍚堝璞�
      * @time 2025/3/15 15:05
      */
     public static List<Map<String, Object>> getExtendFields(List<Map<String, Object>> params) {
@@ -104,7 +104,7 @@
      * @time 2025/3/18 15:00
      */
     @Transactional(rollbackFor = Exception.class)
-    public static boolean saveFields(Map<String, ?> template, String uuid) throws Exception{
+    public static boolean saveFields(Map<String, ?> template, String uuid) throws Exception {
         List<Fields> fields = getFieldsSta();
         FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
         List<FieldsItem> fieldsItems = new ArrayList<>();
@@ -132,6 +132,7 @@
 
     /**
      * 鑾峰彇鎵�鏈夊紑鍚姩鎬佹墿灞曞瓧娈�
+     *
      * @return
      */
     public static List<Fields> getFieldsSta() {
@@ -140,43 +141,45 @@
     }
 
     /**
-     * @author Ryan
-     * @description 鍔ㄦ�佸瓧娈典慨鏀�
      * @param
      * @return
+     * @author Ryan
+     * @description 鍔ㄦ�佸瓧娈典慨鏀�
      * @time 2025/4/7 15:28
      */
     @Synchronized
     @Transactional(rollbackFor = Exception.class)
     public static void updateFieldsValue(Map<String, Object> params) throws Exception {
         List<Fields> fields = getFieldsSta();
-        if (fields.isEmpty()) { return; }
+        if (fields.isEmpty()) {
+            return;
+        }
         Object fieldsIndex = params.get("fieldsIndex");
         if (!Objects.isNull(fieldsIndex) && StringUtils.isNotBlank(fieldsIndex.toString())) {
             String index = fieldsIndex.toString();
             FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class);
             for (Fields field : fields) {
-                    if (!Objects.isNull(params.get(field.getFields()))) {
-                        FieldsItem indexItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>()
-                                .eq(FieldsItem::getUuid, index)
-                                .eq(FieldsItem::getFieldsId, field.getId()));
-                        //濡傛灉瀛愯〃涓虹┖锛屾墽琛屾彃鍏ユ搷浣滐紝鍚﹀垯灏辨墽琛屼慨鏀规搷浣�
-                        if (Objects.isNull(indexItem)) {
-                            FieldsItem item = new FieldsItem();
-                            item.setUuid(index)
-                                    .setFieldsId(field.getId())
-                                    .setMatnrId(!Objects.isNull(params.get("matnrId")) ? Long.parseLong(params.get("matnrId").toString()) : null)
-                                    .setValue(params.get(field.getFields()).toString());
-                            if (!fieldsItemService.save(item)) {
-                                throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
-                            }
-                        } else {
-                            indexItem.setValue(params.get(field.getFields()).toString());
-                            if (!fieldsItemService.updateById(indexItem)) {
-                                throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
-                            }
+                if (!Objects.isNull(params.get(field.getFields()))) {
+                    FieldsItem indexItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>()
+                            .eq(FieldsItem::getUuid, index)
+                            .eq(FieldsItem::getFieldsId, field.getId()));
+                    //濡傛灉瀛愯〃涓虹┖锛屾墽琛屾彃鍏ユ搷浣滐紝鍚﹀垯灏辨墽琛屼慨鏀规搷浣�
+                    if (Objects.isNull(indexItem)) {
+                        FieldsItem item = new FieldsItem();
+                        item.setUuid(index)
+                                .setFieldsId(field.getId())
+                                .setMatnrId(!Objects.isNull(params.get("matnrId")) ? Long.parseLong(params.get("matnrId").toString()) : null)
+                                .setValue(params.get(field.getFields()).toString());
+                        if (!fieldsItemService.save(item)) {
+                            throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
+                        }
+                    } else {
+                        indexItem.setValue(params.get(field.getFields()).toString());
+                        if (!fieldsItemService.updateById(indexItem)) {
+                            throw new CoolException("鎵╁睍瀛楁淇敼澶辫触锛侊紒");
                         }
                     }
+                }
             }
         } else {
             saveFields(params, params.get("index").toString());
@@ -196,12 +199,12 @@
             Fields fields = fieldsService.getOne(new LambdaQueryWrapper<Fields>().eq(Fields::getFields, key));
             if (!Cools.isEmpty(fields)) {
                 String applySql = String.format(
-                    "EXISTS (SELECT 1 FROM sys_fields_item fie " +
-                    "WHERE %s.fields_index IS NOT NULL " +
-                    "AND fie.uuid = %s.fields_index " +
-                    "AND fie.fields_id = '%s' " +
-                    "AND fie.value = '%s')",
-                    tableName, tableName, fields.getId(), val
+                        "EXISTS (SELECT 1 FROM sys_fields_item fie " +
+                                "WHERE %s.fields_index IS NOT NULL " +
+                                "AND fie.uuid = %s.fields_index " +
+                                "AND fie.fields_id = '%s' " +
+                                "AND fie.value = '%s')",
+                        tableName, tableName, fields.getId(), val
                 );
                 queryWrapper.apply(applySql);
             }

--
Gitblit v1.9.1