From 032cf35726c649b48ac04d0088fd8ae9117c09e4 Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期三, 10 八月 2022 15:11:26 +0800 Subject: [PATCH] 更新散装件审批 --- src/main/java/com/whyc/service/WorksheetLinkService.java | 64 +++++++++++++++++++++++++------- 1 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/whyc/service/WorksheetLinkService.java b/src/main/java/com/whyc/service/WorksheetLinkService.java index cd706d3..d2cb427 100644 --- a/src/main/java/com/whyc/service/WorksheetLinkService.java +++ b/src/main/java/com/whyc/service/WorksheetLinkService.java @@ -15,10 +15,7 @@ import javax.annotation.Resource; import java.io.File; import java.io.IOException; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -187,7 +184,7 @@ } //鏇存柊鏁d欢琛ㄥ綋鍓嶇増鏈�,鏇存柊eVersion List<ComponentProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion); - cphService.updateVersionBatch(cphList); + if(cphList.size()!=0){cphService.updateVersionBatch(cphList);} /*鏇存柊鍒皃roduct_bom*/ //鏌ヨ鏂扮殑鐗堟湰 @@ -285,11 +282,18 @@ //澶勭悊鎬濊矾:鍏堣В闄ゅ叧鑱�,鍐嶆浛鎹�,鍐嶅叧鑱� if(removedList.size()!=0){ removedList.forEach(remove -> { - nowHistoryList.forEach(nowHistory -> { + /*nowHistoryList.forEach(nowHistory -> { if (remove.getComponentId().intValue() == nowHistory.getComponentId()) { nowHistoryList.remove(nowHistory); } - }); + });*/ + Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); + while (iterator.hasNext()){ + if(remove.getComponentId().intValue() == iterator.next().getComponentId()){ + iterator.remove(); + break; + } + } }); } @@ -297,12 +301,19 @@ if(replacedList.size()!=0){ replacedList.forEach(replace -> { //褰撳墠鐢熸晥鐨勬暎瑁呬欢-浜у搧鍒楄〃 - nowHistoryList.forEach(nowHistory -> { + /*nowHistoryList.forEach(nowHistory -> { if (replace.getComponentId().intValue() == nowHistory.getComponentId()) { nowHistoryList.remove(nowHistory); } - }); - //涓嬩釜鐗堟湰鏂板鐨勬暎瑁呬欢-浜у搧鍒楄〃 + });*/ + Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); + while (iterator.hasNext()){ + if(replace.getComponentId().intValue() == iterator.next().getComponentId()){ + iterator.remove(); + break; + } + } + //涓嬩釜鐗堟湰鏂板鏇挎崲鐨勬暎瑁呬欢-浜у搧鍒楄〃 ComponentProductHistory newHistory = new ComponentProductHistory(); newHistory.setComponentId(replace.getComponentId()); newHistory.setParentModel(replace.getParentModel()); @@ -313,21 +324,46 @@ newHistory.setEVersion(nextVersion); newHistoryList.add(newHistory); //褰撳墠鐢熸晥鐨刡om鍒楄〃 - nowBomHistoryList.forEach(nowBomHistory->{ + /*nowBomHistoryList.forEach(nowBomHistory->{ if(replace.getSubName().equals(nowBomHistory.getSubName())){ nowBomHistoryList.remove(nowBomHistory); } - }); + });*/ + Iterator<ProductBomHistory> iterator1 = nowBomHistoryList.iterator(); + while (iterator1.hasNext()){ + if(replace.getSubName().equals(iterator1.next().getSubName())){ + iterator1.remove(); + break; + } + } }); } //澶勭悊鍏宠仈 addedList.forEach(add -> { - nowHistoryList.forEach(nowHistory -> { + /*nowHistoryList.forEach(nowHistory -> { if (add.getComponentId().intValue() == nowHistory.getComponentId()) { nowHistoryList.remove(nowHistory); } - }); + });*/ + Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); + while (iterator.hasNext()){ + if(add.getComponentId().intValue() == iterator.next().getComponentId()){ + iterator.remove(); + break; + } + } + + ComponentProductHistory newHistory = new ComponentProductHistory(); + newHistory.setComponentId(add.getComponentId()); + newHistory.setParentModel(add.getParentModel()); + newHistory.setSubName(add.getSubName()); + newHistory.setCreateTime(new Date()); + newHistory.setLinkType(1); + newHistory.setSVersion(nextVersion); + newHistory.setEVersion(nextVersion); + newHistoryList.add(newHistory); + }); //澶勭悊瀹屾垚,杩涜琛ㄥ崟鏁版嵁鏇存柊,鍒嗕负nowHistoryList,newHistoryList,nowBomHistoryList -- Gitblit v1.9.1