From 1fb57472e5e7748e6cf153795f566a877e4ada5b Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期六, 13 八月 2022 11:30:37 +0800 Subject: [PATCH] 更新审批 --- src/main/java/com/whyc/service/WorksheetMainService.java | 101 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 69 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/whyc/service/WorksheetMainService.java b/src/main/java/com/whyc/service/WorksheetMainService.java index 42f867a..85b434a 100644 --- a/src/main/java/com/whyc/service/WorksheetMainService.java +++ b/src/main/java/com/whyc/service/WorksheetMainService.java @@ -11,6 +11,7 @@ import com.whyc.mapper.WorksheetLinkMapper; import com.whyc.mapper.WorksheetMainMapper; import com.whyc.pojo.*; +import io.swagger.annotations.ApiModelProperty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -48,6 +49,12 @@ @Autowired private ComponentService cService; + + @Autowired + private ProductBomService pbService; + + @Autowired + private ComponentProductHistoryService cphService; @Transactional public boolean submit(WorksheetMain main, DocUser user) { @@ -213,48 +220,78 @@ public Response componentSubmit(WorksheetMain main, DocUser user) { Response<Object> response = new Response<>(); List<ComponentApproving> cApprovingList = main.getCApprovingList(); - //鏌ヨ鏄惁鏈� 宸茬敓鏁堟垨鑰呭凡鎻愪氦瀹℃壒鐨� 鐩稿悓鐨勬暎瑁呬欢 - List<Component> existComponentList = new LinkedList<>(); - List<ComponentApproving> existCAList = new LinkedList<>(); + //鍒ゆ柇鏄柊澧炶繕鏄垹闄� + boolean isAdded = cApprovingList.get(0).getSubName()!=null; + if(isAdded) { //鏂板 + //鏌ヨ鏄惁鏈� 宸茬敓鏁堟垨鑰呭凡鎻愪氦瀹℃壒鐨� 鐩稿悓鐨勬暎瑁呬欢 + List<Component> existComponentList = new LinkedList<>(); + List<ComponentApproving> existCAList = new LinkedList<>(); - List<Component> componentList = cService.getList(); - List<ComponentApproving> cAList = cApprovingService.getListByStatus(1); - for (int i = 0; i < cApprovingList.size(); i++) { - ComponentApproving componentApproving = cApprovingList.get(i); - for (int j = 0; j < componentList.size(); j++) { - if(componentApproving.getSubCode().equals(componentList.get(j).getSubCode()) - && componentApproving.getSubName().equals(componentList.get(j).getSubName()) - && componentApproving.getSubModel().equals(componentList.get(j).getSubModel()) - ){ - existComponentList.add(componentList.get(j)); + List<Component> componentList = cService.getList(); + List<ComponentApproving> cAList = cApprovingService.getListByStatus(1); + for (int i = 0; i < cApprovingList.size(); i++) { + ComponentApproving componentApproving = cApprovingList.get(i); + for (int j = 0; j < componentList.size(); j++) { + if (componentApproving.getSubCode().equals(componentList.get(j).getSubCode()) + && componentApproving.getSubName().equals(componentList.get(j).getSubName()) + && componentApproving.getSubModel().equals(componentList.get(j).getSubModel()) + ) { + existComponentList.add(componentList.get(j)); + } + } + + for (int j = 0; j < cAList.size(); j++) { + if (componentApproving.getSubCode().equals(cAList.get(j).getSubCode()) + && componentApproving.getSubName().equals(cAList.get(j).getSubName()) + && componentApproving.getSubModel().equals(cAList.get(j).getSubModel()) + ) { + existCAList.add(cAList.get(j)); + } } } - for (int j = 0; j < cAList.size(); j++) { - if(componentApproving.getSubCode().equals(cAList.get(j).getSubCode()) - && componentApproving.getSubName().equals(cAList.get(j).getSubName()) - && componentApproving.getSubModel().equals(cAList.get(j).getSubModel()) - ){ - existCAList.add(cAList.get(j)); + int existCASize = existCAList.size(); + int existComponentSize = existComponentList.size(); + if (existCASize != 0) { + if (existComponentSize != 0) { + response.setII(21, existCAList, existComponentList, "閲嶅鎻愪氦:鐜版湁鏁h浠跺強姝e湪杩涜瀹℃壒鐨勬暎瑁呬欢涓�,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); + } else { + response.set(22, existCAList, "閲嶅鎻愪氦:姝e湪杩涜瀹℃壒鐨勬暎瑁呬欢涓�,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); + } + return response; + } else { + if (existComponentSize != 0) { + return response.setII(23, null, existComponentList, "閲嶅鎻愪氦:鐜版湁鏁h浠朵腑,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); } } - } + }else{ //鍒犻櫎 TODO + //鍒ゆ柇鏄惁鍦ㄦ暎瑁呬欢瀹℃壒鍒犻櫎涓�,鏄惁瀛樺湪浜у搧鍏宠仈鍙婂叧鑱斿鎵� + ComponentApproving deleteApproving = new ComponentApproving(); + List<ComponentProductHistory> existComponentProducts = new LinkedList<>(); + List<ComponentProductApproving> existComponentProductApprovingList = new LinkedList<>(); + deleteApproving = cApprovingService.getListByComponentId(cApprovingList.get(0).getComponentId()); - int existCASize = existCAList.size(); - int existComponentSize = existComponentList.size(); - if(existCASize!=0){ - if(existComponentSize!=0){ - response.setII(21,existCAList,existComponentList,"閲嶅鎻愪氦:鐜版湁鏁h浠跺強姝e湪杩涜瀹℃壒鐨勬暎瑁呬欢涓�,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); + //鏌ョ湅浜у搧鍏宠仈 + List<ComponentProductHistory> cphLatestExistList = cphService.getLatestExistListByComponentId(cApprovingList.get(0).getComponentId()); + //鏌ョ湅浜у搧鍏宠仈瀹℃壒 + List<ComponentProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByComponentId(cApprovingList.get(0).getComponentId()); + + if(deleteApproving!=null){ + return response.set(31,deleteApproving,"鎷掔粷鏈鍒犻櫎鐢宠,褰撳墠鏁h浠舵鍦ㄨ繘琛屽垹闄ゅ鎵�"); + } + if(cphLatestExistList!=null && cphLatestExistList.size()!=0){ + if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){ + return response.setII(32,cpaLatestExistList,cphLatestExistList,"鎷掔粷鏈鍒犻櫎鐢宠,褰撳墠鏁h宸茬粡鍏宠仈浜у搧鍙婂湪浜у搧鍏宠仈瀹℃壒"); + }else{ + return response.setII(33,null,cphLatestExistList,"鎷掔粷鏈鍒犻櫎鐢宠,褰撳墠鏁h浠跺湪浜у搧鍏宠仈瀹℃壒"); + } }else{ - response.set(22,existCAList,"閲嶅鎻愪氦:姝e湪杩涜瀹℃壒鐨勬暎瑁呬欢涓�,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); + if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){ + return response.set(34,cpaLatestExistList,"鎷掔粷鏈鍒犻櫎鐢宠,褰撳墠鏁h浠跺凡缁忓叧鑱斾骇鍝�"); + } } - return response; - }else{ - if(existComponentSize!=0){ - return response.setII(23,null,existComponentList,"閲嶅鎻愪氦:鐜版湁鏁h浠朵腑,瀛樺湪褰撳墠鎻愪氦涓婁紶鐨勬暎瑁呬欢"); - } - } + } main.setType(EnumWorksheetType.Component.getType()); //鎻愪氦涓昏〃 main.setCreateUserId(user.getId()); -- Gitblit v1.9.1