From bbf3c5b4db8d1510e3cdae429e1d1fe54249c18e Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期四, 08 九月 2022 16:52:01 +0800
Subject: [PATCH] 修复

---
 src/main/java/com/whyc/service/ProductService.java |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/whyc/service/ProductService.java b/src/main/java/com/whyc/service/ProductService.java
index 6a51b7e..1634f84 100644
--- a/src/main/java/com/whyc/service/ProductService.java
+++ b/src/main/java/com/whyc/service/ProductService.java
@@ -330,33 +330,40 @@
                 && relatedProduct.getCustomCode().equals(product.getCustomCode())
                 )
             ) { //灞炰簬鏄骇鍝佸崌绾ф垨鍩轰簬鏍囧噯浜у搧瀹氬埗
-                if (latestProduct != null && enabledProduct != null) {
-                    List<MaterialProductHistory> mpList;
-                    if(customCode.equals("")){ //浜у搧鍗囩骇
-                        mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion());
-                    }else{ //鍩轰簬鏍囧噯浜у搧瀹氬埗
-                        int standardEnabledVersion = getVersion(parentCode, "").getVersion();
-                        mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode,"",standardEnabledVersion);
-                    }
-                    if (mpList.size() != 0) { //瀛樺湪鍏宠仈鍏崇郴
-                        //褰撳墠鐨勪骇鍝乥om鏄庣粏鍖呭惈 缁ф壙鐨勪骇鍝佸瓙浠剁墿鏂�,缁ф壙鍏崇郴淇濈暀
-                        //璁剧疆mpList鍏宠仈鐨勭墿鏂欒缁嗕俊鎭�
-                        mpList = mphService.getListWithMaterialInfo(mpList);
-                        List<String> newBomMaterialStrList = bomList.stream().map(bom -> bom.getSubCode() + "/" + bom.getSubModel()).collect(Collectors.toList());
-                        mpList = mpList.stream().filter(mp -> newBomMaterialStrList.contains(mp.getSubMaterial().getSubCode() + "/" + mp.getSubMaterial().getSubModel())).collect(Collectors.toList());
-                        if(mpList.size()!=0) {
-                            if (latestProduct.getVersion().intValue() == enabledProduct.getVersion()) {
-                                //鏈�鏂扮増鏈敓鏁�,鍏宠仈鍏崇郴鐗堟湰杩炵潃鐨�
-                                mphService.updateVersionBatch(mpList);
-                            } else {
-                                //鏃х増鏈敓鏁�,鍏宠仈鍏崇郴鐗堟湰涓嶈繛鐫�
+                List<MaterialProductHistory> mpList;
+                if (latestProduct != null && enabledProduct != null) { //浜у搧鍗囩骇
+                    mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion());
+                }else{ //鍩轰簬鏍囧噯浜у搧瀹氬埗
+                    int standardEnabledVersion = getVersion(parentCode, "").getVersion();
+                    mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode,"",standardEnabledVersion);
+                }
+                if (mpList.size() != 0) { //瀛樺湪鍏宠仈鍏崇郴
+                    //褰撳墠鐨勪骇鍝乥om鏄庣粏鍖呭惈 缁ф壙鐨勪骇鍝佸瓙浠剁墿鏂�,缁ф壙鍏崇郴淇濈暀
+                    //璁剧疆mpList鍏宠仈鐨勭墿鏂欒缁嗕俊鎭�
+                    mpList = mphService.getListWithMaterialInfo(mpList);
+                    List<String> newBomMaterialStrList = bomList.stream().map(bom -> bom.getSubCode() + "/" + bom.getSubModel()).collect(Collectors.toList());
+                    mpList = mpList.stream().filter(mp -> newBomMaterialStrList.contains(mp.getSubMaterial().getSubCode() + "/" + mp.getSubMaterial().getSubModel())).collect(Collectors.toList());
+                    if(mpList.size()!=0) {
+                        if ((latestProduct !=null && enabledProduct!=null) && latestProduct.getVersion().intValue() == enabledProduct.getVersion()) {
+                            //鏈�鏂扮増鏈敓鏁�,鍏宠仈鍏崇郴鐗堟湰杩炵潃鐨�
+                            mphService.updateVersionBatch(mpList);
+                        } else {
+                            //鍏宠仈鍏崇郴鐗堟湰涓嶈繛鐫�,鐢熸垚鏂扮邯褰�:鍖呭惈 鍗囩骇鍜屽熀浜庢爣鍑嗕骇鍝佸畾鍒�
+                            if(customCode.equals("")) {
                                 mpList.forEach(mp -> {
                                     mp.setSVersion(nextVersion);
                                     mp.setEVersion(nextVersion);
                                     mp.setCreateTime(date);
                                 });
-                                mphService.insertBatch(mpList);
+                            }else{
+                                mpList.forEach(mp -> {
+                                    mp.setCustomCode(customCode);
+                                    mp.setSVersion(nextVersion);
+                                    mp.setEVersion(nextVersion);
+                                    mp.setCreateTime(date);
+                                });
                             }
+                            mphService.insertBatch(mpList);
                         }
                     }
                 }

--
Gitblit v1.9.1