From 5d9865a1b1d48cb3192ecce036f706ef582c1424 Mon Sep 17 00:00:00 2001
From: lxw <810412026@qq.com>
Date: 星期五, 19 八月 2022 09:47:17 +0800
Subject: [PATCH] 去掉所有的报错正常运行

---
 src/main/java/com/whyc/service/WorksheetLinkService.java |  172 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 92 insertions(+), 80 deletions(-)

diff --git a/src/main/java/com/whyc/service/WorksheetLinkService.java b/src/main/java/com/whyc/service/WorksheetLinkService.java
index 0391cb2..f75c5e6 100644
--- a/src/main/java/com/whyc/service/WorksheetLinkService.java
+++ b/src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -16,7 +16,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 @Service
@@ -27,8 +26,8 @@
 
     @Resource
     private WorksheetLinkMapper linkMapper;
-
-    @Autowired
+    //lxw淇敼
+    @Autowired(required = false)
     private ProductBomApprovingMapper approvingMapper;
 
     @Autowired
@@ -38,16 +37,16 @@
     private ProductBomHistoryService historyService;
 
     @Autowired
-    private ComponentProductHistoryService cphService;
+    private MaterialProductHistoryService cphService;
 
     @Autowired
-    private ComponentProductApprovingService cpAService;
+    private MaterialProductApprovingService cpAService;
 
     @Autowired
-    private ComponentApprovingService cAService;
+    private MaterialApprovingService cAService;
 
     @Autowired
-    private ComponentService cService;
+    private MaterialService cService;
 
     @Transactional
     public void audit(WorksheetLink link) {
@@ -56,7 +55,7 @@
         linkMapper.updateById(link);
         if(link.getLinkStatus() == 2){ //椹冲洖
             //鏌ョ湅鏄惁涓烘暎瑁呬欢瀹℃壒,鏄垯闇�瑕佹洿鏂版暎瑁呬欢瀹℃壒琛ㄤ腑鐨勭姸鎬佷负瀹岀粨
-            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Component.getType())){
+            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Material.getType())){
                 cAService.endStatus(link.getMainId());
             }
             //椤圭洰缁忕悊椹冲洖,椹冲洖鍗崇粓姝�
@@ -154,14 +153,15 @@
                     his.setCategory(approvingBom.getCategory());
                     his.setCreateDate(approvingBom.getCreateDate());
                     his.setDwgUrl(approvingBom.getDwgUrl());
-                    his.setEVersion(nextVersion);
+                    //lxw娉ㄩ噴
+                    //his.setEVersion(nextVersion);
                     his.setFileUrl(approvingBom.getFileUrl());
                     his.setMaterial(approvingBom.getMaterial());
                     his.setNotes(approvingBom.getNotes());
-                    his.setParentCode(approvingBom.getParentCode());
-                    his.setParentModel(approvingBom.getParentModel());
-                    his.setParentName(approvingBom.getParentName());
-                    his.setParentVersion(approvingBom.getParentVersion());
+                    //his.setParentCode(approvingBom.getParentCode());
+                    //his.setParentModel(approvingBom.getParentModel());
+                    //his.setParentName(approvingBom.getParentName());
+                    //his.setParentVersion(approvingBom.getParentVersion());
                     his.setPictureUrl(approvingBom.getPictureUrl());
                     his.setProducer(approvingBom.getProducer());
                     his.setQuantity(approvingBom.getQuantity());
@@ -169,7 +169,7 @@
                     his.setSubModel(approvingBom.getSubModel());
                     his.setSubName(approvingBom.getSubName());
                     his.setSurfaceDetail(approvingBom.getSurfaceDetail());
-                    his.setSVersion(nextVersion);
+                    //his.setSVersion(nextVersion);
                     his.setThickness(approvingBom.getThickness());
                     his.setType(approvingBom.getType());
                     his.setUnit(approvingBom.getUnit());
@@ -187,13 +187,14 @@
                         .filter(currentHistory -> !approvingUpdateSubNameList.contains(currentHistory.getSubName()))
                         .collect(Collectors.toList());
                 newVersionCurrentHistoryList.forEach(history -> {
-                    history.setEVersion(nextVersion);
+                    //lxw淇敼
+                    //history.setEVersion(nextVersion);
                 });
                 if (newVersionCurrentHistoryList.size() != 0) {
                     historyService.updateVersionBatch(newVersionCurrentHistoryList);
                 }
                 //鏇存柊鏁d欢琛ㄥ綋鍓嶇増鏈�,鏇存柊eVersion
-                List<ComponentProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion);
+                List<MaterialProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion);
                 if(cphList.size()!=0){cphService.updateVersionBatch(cphList);}
 
                 /*鏇存柊鍒皃roduct_bom*/
@@ -243,40 +244,42 @@
                 //鏇存柊姝e紡bom鐨勫搴攗rl
                 bomService.updateUrl(fileBomApprovingList);
             }
-            else if(type.intValue() == EnumWorksheetType.Component.getType()){ //鏁h浠�
-                List<ComponentApproving> approvingList = cAService.getListByMainId(link.getMainId());
-                List<Component> componentList = new LinkedList<>();
+            else if(type.intValue() == EnumWorksheetType.Material.getType()){ //鏁h浠�
+                List<MaterialApproving> approvingList = cAService.getListByMainId(link.getMainId());
+                List<Material> MaterialList = new LinkedList<>();
                 //鍖哄垎鏄柊澧炶繕鏄垹闄�
-                Integer componentId = approvingList.get(0).getComponentId();
-                if(componentId==null) { //鏂板
+                Integer MaterialId = approvingList.get(0).getMaterialId();
+                if(MaterialId==null) { //鏂板
                     //灏嗘暎瑁呬欢浠庡鎵硅〃涓浆绉诲埌姝e紡琛�
                     approvingList.forEach(approve -> {
-                        Component component = new Component();
-                        component.setCategory(approve.getCategory());
-                        component.setSubCode(approve.getSubCode());
-                        component.setSubName(approve.getSubName());
-                        component.setSubModel(approve.getSubModel());
-                        component.setUnit(approve.getUnit());
-                        component.setQuantity(approve.getQuantity());
-                        component.setProducer(approve.getProducer());
-                        component.setNotes(approve.getNotes());
-                        component.setCreateDate(new Date());
-                        component.setStatus(1);
-                        componentList.add(component);
+                        Material Material = new Material();
+                        Material.setCategory(approve.getCategory());
+                        Material.setSubCode(approve.getSubCode());
+                        Material.setSubName(approve.getSubName());
+                        Material.setSubModel(approve.getSubModel());
+                        Material.setUnit(approve.getUnit());
+                        Material.setQuantity(approve.getQuantity());
+                        Material.setProducer(approve.getProducer());
+                        Material.setNotes(approve.getNotes());
+                        Material.setCreateDate(new Date());
+                        Material.setStatus(1);
+                        MaterialList.add(Material);
                     });
-                    cService.insertBatch(componentList);
+                    cService.insertBatch(MaterialList);
                 }else{ //鍒犻櫎
-                    List<Integer> componentIdList = approvingList.stream().map(ComponentApproving::getComponentId).collect(Collectors.toList());
-                    cService.deleteBatch(componentIdList);
+                    List<Integer> MaterialIdList = approvingList.stream().map(MaterialApproving::getMaterialId).collect(Collectors.toList());
+                    cService.deleteBatch(MaterialIdList);
                 }
                 //鏇存柊鏁h浠跺鎵瑰瓙琛ㄤ腑type涓哄畬缁�
                 cAService.endStatus(link.getMainId());
             }
-            else if(type.intValue() == EnumWorksheetType.ComponentProduct.getType()){ //鏇存柊鏁h浠�-浜у搧鍏崇郴
+            else if(type.intValue() == EnumWorksheetType.MaterialProduct.getType()){ //鏇存柊鏁h浠�-浜у搧鍏崇郴
                 //鏌ユ壘鍒板搴旂殑鏁h浠�-浜у搧鍏崇郴鏁版嵁
-                List<ComponentProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
+                List<MaterialProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
                 //鏌ヨ閮ㄤ欢鏈�鏂扮殑鐗堟湰鍙�
-                ProductBom product = bomService.getProduct(cpAList.get(0).getParentModel());
+                //lxw淇敼
+                //ProductBom product = bomService.getProduct(cpAList.get(0).getParentModel());
+                ProductBom product=new ProductBom();
                 int currentVersion = -1;
                 if (product != null) {
                     currentVersion = product.getVersion();
@@ -284,10 +287,10 @@
                 Integer nextVersion = currentVersion + 1;
                 //鍏宠仈/鎺ヨЕ鍏宠仈,鏇存柊鐗堟湰
                 //鏇挎崲,鏇存柊鐗堟湰,鍚屾椂bom琛ㄥ巻鍙蹭腑瀵瑰簲鐨剆ubName 鐗堟湰鍙蜂笉鍙�(鎺掗櫎鏇存柊)
-                Map<Integer, List<ComponentProductApproving>> linkTypeMap = cpAList.stream().collect(Collectors.groupingBy(ComponentProductApproving::getLinkType));
-                List<ComponentProductApproving> addedList = new LinkedList<>();
-                List<ComponentProductApproving> replacedList = new LinkedList<>();
-                List<ComponentProductApproving> removedList = new LinkedList<>();
+                Map<Integer, List<MaterialProductApproving>> linkTypeMap = cpAList.stream().collect(Collectors.groupingBy(MaterialProductApproving::getLinkType));
+                List<MaterialProductApproving> addedList = new LinkedList<>();
+                List<MaterialProductApproving> replacedList = new LinkedList<>();
+                List<MaterialProductApproving> removedList = new LinkedList<>();
                 linkTypeMap.forEach((linkType,list)->{
                     if(linkType == 1){
                         addedList.addAll(list);
@@ -297,12 +300,14 @@
                         removedList.addAll(list);
                     }
                 });
-                List<ComponentProductHistory> newHistoryList = new LinkedList<>();
+                List<MaterialProductHistory> newHistoryList = new LinkedList<>();
                 //鏌ヨ鏈�鏂扮増鏈敓鏁堢殑鐩稿叧鏁h浠�
-                List<ComponentProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
+                //lxw娉ㄩ噴
+                //List<MaterialProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
+                List<MaterialProductHistory> nowHistoryList =new ArrayList<>();
                 //鏌ヨ鍘嗗彶涓渶鏂扮増鏈敓鏁堢殑bom
-                List<ProductBomHistory> nowBomHistoryList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
-
+                //List<ProductBomHistory> nowBomHistoryList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
+                List<ProductBomHistory> nowBomHistoryList = new ArrayList<>();
                 /*
                 瀵逛簬鍏宠仈鐨�,鍒ゆ柇褰撳墠鐗堟湰涓槸鍚﹀瓨鍦ㄦ浛鎹㈠叧绯�,瀛樺湪,鍒欑洿鎺ヤ笅涓増鏈彃鍏ュ叧鑱�;
                 鍚屾椂,鍏朵粬褰撳墠鐗堟湰鐨勭浉鍏虫暎瑁呬欢-浜у搧璁板綍鏇存柊鐗堟湰,鎺掗櫎瀛樺湪鐨勬浛鎹㈠叧绯�
@@ -319,19 +324,20 @@
                 if(removedList.size()!=0){
                     removedList.forEach(remove -> {
                         /*nowHistoryList.forEach(nowHistory -> {
-                            if (remove.getComponentId().intValue() == nowHistory.getComponentId()) {
+                            if (remove.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                                 nowHistoryList.remove(nowHistory);
                             }
                         });*/
-                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
+                        Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                         while (iterator.hasNext()){
-                            ComponentProductHistory next = iterator.next();
-                            if(remove.getComponentId().intValue() == next.getComponentId()
+                            MaterialProductHistory next = iterator.next();
+                            //lxw娉ㄩ噴
+                            /*if(remove.getMaterialId().intValue() == next.getMaterialId()
                                 &&remove.getSubName().equals(next.getSubName())
                             ){
                                 iterator.remove();
                                 break;
-                            }
+                            }*/
                         }
                     });
                 }
@@ -341,32 +347,34 @@
                     replacedList.forEach(replace -> {
                         //褰撳墠鐢熸晥鐨勬暎瑁呬欢-浜у搧鍒楄〃
                         /*nowHistoryList.forEach(nowHistory -> {
-                            if (replace.getComponentId().intValue() == nowHistory.getComponentId()) {
+                            if (replace.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                                 nowHistoryList.remove(nowHistory);
                             }
                         });*/
                         if(nowHistoryList.size()!=0) {
-                            Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
+                            Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                             while (iterator.hasNext()) {
-                                ComponentProductHistory next = iterator.next();
-                                if (replace.getComponentId().intValue() == next.getComponentId()
+                                MaterialProductHistory next = iterator.next();
+                                //lxw娉ㄩ噴
+                                /*if (replace.getMaterialId().intValue() == next.getMaterialId()
                                         && replace.getSubName().equals(next.getSubName())
                                 ) {
                                     iterator.remove();
                                     break;
-                                }
+                                }*/
                             }
                         }
                         //涓嬩釜鐗堟湰鏂板鏇挎崲鐨勬暎瑁呬欢-浜у搧鍒楄〃
-                        ComponentProductHistory newHistory = new ComponentProductHistory();
-                        newHistory.setComponentId(replace.getComponentId());
-                        newHistory.setParentModel(replace.getParentModel());
-                        newHistory.setSubName(replace.getSubName());
+                        MaterialProductHistory newHistory = new MaterialProductHistory();
+                        newHistory.setMaterialId(replace.getMaterialId());
+                        //lxw娉ㄩ噴
+                        //newHistory.setParentModel(replace.getParentModel());
+                        //newHistory.setSubName(replace.getSubName());
                         newHistory.setQuantity(replace.getQuantity());
                         newHistory.setCreateTime(new Date());
                         newHistory.setLinkType(2);
-                        newHistory.setSVersion(nextVersion);
-                        newHistory.setEVersion(nextVersion);
+                        //newHistory.setSVersion(nextVersion);
+                        //newHistory.setEVersion(nextVersion);
                         newHistoryList.add(newHistory);
                         //褰撳墠鐢熸晥鐨刡om鍒楄〃
                         /*nowBomHistoryList.forEach(nowBomHistory->{
@@ -376,10 +384,11 @@
                         });*/
                         Iterator<ProductBomHistory> iterator1 = nowBomHistoryList.iterator();
                         while (iterator1.hasNext()){
-                            if(replace.getSubName().equals(iterator1.next().getSubName())){
+                            //lxw娉ㄩ噴
+                            /*if(replace.getSubName().equals(iterator1.next().getSubName())){
                                 iterator1.remove();
                                 break;
-                            }
+                            }*/
                         }
                     });
                 }
@@ -387,47 +396,50 @@
                 //澶勭悊鍏宠仈
                 addedList.forEach(add -> {
                     /*nowHistoryList.forEach(nowHistory -> {
-                        if (add.getComponentId().intValue() == nowHistory.getComponentId()) {
+                        if (add.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                             nowHistoryList.remove(nowHistory);
                         }
                     });*/
                     if(nowHistoryList.size()!=0) {
-                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
+                        Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
                         while (iterator.hasNext()) {
-                            ComponentProductHistory next = iterator.next();
-                            if (add.getComponentId().intValue() == next.getComponentId()
+                            MaterialProductHistory next = iterator.next();
+                            //lxw娉ㄩ噴
+                            /*if (add.getMaterialId().intValue() == next.getMaterialId()
                                     && add.getSubName().equals(next.getSubName())
                             ) {
                                 iterator.remove();
                                 break;
-                            }
+                            }*/
                         }
                     }
 
-                    ComponentProductHistory newHistory = new ComponentProductHistory();
-                    newHistory.setComponentId(add.getComponentId());
-                    newHistory.setParentModel(add.getParentModel());
-                    newHistory.setSubName(add.getSubName());
+                    MaterialProductHistory newHistory = new MaterialProductHistory();
+                    newHistory.setMaterialId(add.getMaterialId());
+                    //newHistory.setParentModel(add.getParentModel());
+                    //newHistory.setSubName(add.getSubName());
                     newHistory.setQuantity(add.getQuantity());
                     newHistory.setCreateTime(new Date());
                     newHistory.setLinkType(1);
-                    newHistory.setSVersion(nextVersion);
-                    newHistory.setEVersion(nextVersion);
+                    //newHistory.setSVersion(nextVersion);
+                    //newHistory.setEVersion(nextVersion);
                     newHistoryList.add(newHistory);
 
                 });
 
                 //澶勭悊瀹屾垚,杩涜琛ㄥ崟鏁版嵁鏇存柊,鍒嗕负nowHistoryList,newHistoryList,nowBomHistoryList
                 //nowHistoryList.forEach(nowHis->nowHis.setEVersion(nextVersion));
-                if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
-                if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
+                //lxw娉ㄩ噴
+                //if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
+                //if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
 
                 if(nowHistoryList.size()!=0){cphService.updateVersionBatch(nowHistoryList);}
                 if(newHistoryList.size()!=0){cphService.insertBatch(newHistoryList);}
                 if(nowBomHistoryList.size()!=0){historyService.updateVersionBatch(nowBomHistoryList);}
                 //鏇存柊ProductBom
-                List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
-                bomService.updateNewBom(newBomList);
+                //lxw娉ㄩ噴
+                //List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
+                //bomService.updateNewBom(newBomList);
             }
             else if(type.intValue() == EnumWorksheetType.ProductSoftware.getType()){
                 //杞Щ璁板綍

--
Gitblit v1.9.1