From e56ecf1a502dfcac5bb6ef509a08164aee7c6154 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期六, 07 十二月 2024 18:23:24 +0800
Subject: [PATCH] 新增白名单故障类型

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java
index 8289811..a62a22e 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwThresholdServiceImpl.java
@@ -517,8 +517,6 @@
         }
         boolean duplic = checkDuplic(dataList);
         if (duplic) throw new RuntimeException("瀛樺湪閲嶅鍥芥爣璁惧");
-        //宸插瓨鍦ㄧ殑鐧藉悕鍗�
-        Map<String, WorkOrderWhite> whiteMap = workOrderWhiteMapper.selectList().stream().collect(Collectors.toMap(WorkOrderWhite::getSerialNumber, Function.identity()));
         List<WorkOrderWhite> addList = new ArrayList<>();
         dataList.stream().forEach(item -> {
             WorkOrderWhite white = new WorkOrderWhite();
@@ -542,9 +540,6 @@
                     errorDataList.add(errorText);
                 });
                 white.setErrorType(String.join(",", errorDataList));
-                //濡傛灉宸插瓨鍦ㄨˉ鍏卛d
-                WorkOrderWhite whiteExsit = whiteMap.get(white.getSerialNumber());
-                if (whiteExsit != null) white.setId(whiteExsit.getId());
                 addList.add(white);
             } catch (Exception e) {
                 throw new RuntimeException("鍥芥爣鐮佷负" + item.getSerialNumber() + "鐨勮澶囨晠闅滅被鍨嬫湁璇�");
@@ -664,6 +659,33 @@
         );
     }
 
+    /**
+     * 鎵�鏈夌櫧鍚嶅崟娣诲姞鏁呴殰绫诲瀷
+     *
+     * @param workOrderWhite
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void addBatch(WorkOrderWhite workOrderWhite) {
+        List<String> errorTypeListAdd = workOrderWhite.getErrorTypeList();
+        List<WorkOrderWhite> whites = workOrderWhiteMapper.selectList();
+        for (WorkOrderWhite white : whites) {
+            List<String> errorTypeList = Arrays.asList(white.getErrorType().split(","));
+            for (String newError : errorTypeListAdd) {
+                if (errorTypeList.contains(newError)) {
+                    continue;
+                } else {
+                    errorTypeList.add(newError);
+                }
+            }
+            white.setErrorType(String.join(",", errorTypeList));
+        }
+        if (!CollectionUtils.isEmpty(whites)) {
+            workOrderWhiteMapper.deleteAll();
+            workOrderWhiteMapper.insertBatch(whites);
+        }
+    }
+
     private <T extends Comparable<T>> T parseThreshold(String thresholdStr, Class<?> type) {
         if (Integer.class.equals(type)) {
             return (T) Integer.valueOf(thresholdStr);

--
Gitblit v1.8.0