From 604d00f67ddcf25a9d079ceddd1c668b2a4e5288 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 19 四月 2024 15:08:22 +0800
Subject: [PATCH] bug修复

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataConfigServiceImpl.java |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataConfigServiceImpl.java
index 6e3712d..f92b9d1 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataConfigServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataConfigServiceImpl.java
@@ -38,9 +38,7 @@
 import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
-import java.util.stream.IntStream;
 import lombok.RequiredArgsConstructor;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -69,9 +67,11 @@
         List<CalculateItemDTO> calculateItemList = dto.getCalculateItemList();
         CalculateTypeEnum calculateType = tbBasicDataConfig.getCalculateType();
         List<CalculateDTO> dtoList = dto.getDtoList();
+        this.save(tbBasicDataConfig);
         if (CalculateTypeEnum.NUMBER.equals(calculateType)) {
             String fieldIdStr = getFieldIdStr(calculateItemList, tbBasicDataConfig);
             tbBasicDataConfig.setFieldIdStr(fieldIdStr);
+            this.updateById(tbBasicDataConfig);
         } else {
             if (CollUtils.isEmpty(dtoList)) {
                 throw new ServiceException("基础数据配置不能为空");
@@ -98,17 +98,21 @@
                 tbBasicDataConfigDetailService.saveBatch(collect);
             }
         }
-        this.save(tbBasicDataConfig);
     }
 
-    public boolean hasConsecutiveDuplicates(List<CalculateItemDTO> calculateItemList) {
-        return IntStream.range(1, calculateItemList.size())
-                .anyMatch(i -> calculateItemList.get(i - 1).getValueType()
-                        .equals(calculateItemList.get(i).getValueType()));
+    public static boolean hasConsecutiveDuplicates(List<CalculateItemDTO> calculateItemList) {
+        for (int i = 0; i < calculateItemList.size() - 1; i++) {
+            if (calculateItemList.get(i).getValueType()
+                    .equals(calculateItemList.get(i + 1).getValueType()) && !calculateItemList.get(
+                            i + 1)
+                    .getContent().equals("(")) {
+                return true;
+            }
+        }
+        return false;
     }
 
 
-    @NotNull
     private String getFieldIdStr(List<CalculateItemDTO> calculateItemList,
             TbBasicDataConfig tbBasicDataConfig) {
         if (CollUtils.isEmpty(calculateItemList)) {
@@ -159,6 +163,9 @@
             tbBasicDataConfig.setFieldIdStr(
                     getFieldIdStr(dto.getCalculateItemList(), tbBasicDataConfig));
         } else {
+            if (StringUtils.isEmpty(dto.getFieldIdStr())) {
+                throw new ServiceException("字段id不能为空");
+            }
             if (CollUtils.isEmpty(dtoList)) {
                 throw new ServiceException("计算公式不能为空");
             }

--
Gitblit v1.7.1