ezhizao_zx 3 weken geleden
bovenliggende
commit
9e4100d057

+ 263 - 218
src/main/java/cn/ezhizao/project/business/controller/BizProductAccessoriesMaterialController.java

@@ -42,8 +42,7 @@ import static cn.ezhizao.framework.web.page.TableSupport.PAGE_SIZE;
 @Api("物料管理")
 @RestController
 @RequestMapping("/business/productAccessoriesMaterial")
-public class BizProductAccessoriesMaterialController extends BaseController
-{
+public class BizProductAccessoriesMaterialController extends BaseController {
     @Resource
     private IBizProductService bizProductService;
     @Resource
@@ -53,57 +52,57 @@ public class BizProductAccessoriesMaterialController extends BaseController
     @Resource
     private IBizMaterialBaseService bizMaterialBaseService;
     public static final String PAGE_SIZE = "pageSize";
-//    @ApiOperation("获取物料详细")
+
+    //    @ApiOperation("获取物料详细")
     @GetMapping("/list")
-    public TableDataInfo list(BizProductAccessoriesMaterial bizProductAccessoriesMaterial) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo list(BizProductAccessoriesMaterial bizProductAccessoriesMaterial) throws NoSuchFieldException, IllegalAccessException {
         //判断类别
-        if(bizProductAccessoriesMaterial.getCategory() == null){
+        if (bizProductAccessoriesMaterial.getCategory() == null) {
             throw new RuntimeException("查询失败,类别不能为空");
         }
-        if(bizProductAccessoriesMaterial.getCategory() != 1 && bizProductAccessoriesMaterial.getCategory() != 2 && bizProductAccessoriesMaterial.getCategory() != 3){
+        if (bizProductAccessoriesMaterial.getCategory() != 1 && bizProductAccessoriesMaterial.getCategory() != 2 && bizProductAccessoriesMaterial.getCategory() != 3) {
             throw new RuntimeException("查询失败,类别只能为1、2、3");
         }
-      //判断厂别
-        if(bizProductAccessoriesMaterial.getTenantId() != null){
+        //判断厂别
+        if (bizProductAccessoriesMaterial.getTenantId() != null) {
             List<BizTenant> tenantList = bizTenantService.query().eq("id", bizProductAccessoriesMaterial.getTenantId()).list();
-            if(tenantList.isEmpty()){
+            if (tenantList.isEmpty()) {
                 throw new RuntimeException("查询失败,租户ID不存在");
             }
         }
         String pageSizeStr = ServletUtils.getParameter(PAGE_SIZE);
-        if (pageSizeStr !=null) {
+        if (pageSizeStr != null) {
             startPage(); // 若依的分页方法
         }
         //类别为1 product
-        if(bizProductAccessoriesMaterial.getCategory() == 1){
+        if (bizProductAccessoriesMaterial.getCategory() == 1) {
             BizProduct bizProduct = new BizProduct();
-            if(bizProductAccessoriesMaterial.getTenantId() != null){
+            if (bizProductAccessoriesMaterial.getTenantId() != null) {
                 bizProduct.setTenantId(bizProductAccessoriesMaterial.getTenantId());
             }
-            if(bizProductAccessoriesMaterial.getProductCode() != null && bizProductAccessoriesMaterial.getProductCode() != ""){
+            if (bizProductAccessoriesMaterial.getProductCode() != null && bizProductAccessoriesMaterial.getProductCode() != "") {
                 bizProduct.setProductCode(bizProductAccessoriesMaterial.getProductCode());
             }
             return getDataTable(bizProductService.getList(bizProduct));
         }
         //类别为2 accessories
-        if(bizProductAccessoriesMaterial.getCategory() == 2){
+        if (bizProductAccessoriesMaterial.getCategory() == 2) {
             BizAccessories bizAccessories = new BizAccessories();
-            if(bizProductAccessoriesMaterial.getTenantId() != null){
+            if (bizProductAccessoriesMaterial.getTenantId() != null) {
                 bizAccessories.setTenantId(bizProductAccessoriesMaterial.getTenantId());
             }
-            if(bizProductAccessoriesMaterial.getAccessoriesCode() != null && bizProductAccessoriesMaterial.getAccessoriesCode() != ""){
+            if (bizProductAccessoriesMaterial.getAccessoriesCode() != null && bizProductAccessoriesMaterial.getAccessoriesCode() != "") {
                 bizAccessories.setAccessoriesCode(bizProductAccessoriesMaterial.getAccessoriesCode());
             }
             return getDataTable(bizAccessoriesService.getList(bizAccessories));
         }
         //类别为3 material
-        if(bizProductAccessoriesMaterial.getCategory() == 3){
+        if (bizProductAccessoriesMaterial.getCategory() == 3) {
             BizMaterialBase bizMaterialBase = new BizMaterialBase();
-            if(bizProductAccessoriesMaterial.getTenantId() != null){
+            if (bizProductAccessoriesMaterial.getTenantId() != null) {
                 bizMaterialBase.setTenantId(bizProductAccessoriesMaterial.getTenantId());
             }
-            if(bizProductAccessoriesMaterial.getMaterialCode() != null && bizProductAccessoriesMaterial.getMaterialCode() != ""){
+            if (bizProductAccessoriesMaterial.getMaterialCode() != null && bizProductAccessoriesMaterial.getMaterialCode() != "") {
                 bizMaterialBase.setMaterialCode(bizProductAccessoriesMaterial.getMaterialCode());
             }
             return getDataTable(bizMaterialBaseService.getList(bizMaterialBase));
@@ -113,13 +112,13 @@ public class BizProductAccessoriesMaterialController extends BaseController
 
     @PostMapping
     @Transactional
-    public AjaxResult add(@RequestBody List<BizProductAccessoriesMaterial> bizProductAccessoriesMaterialList) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult add(@RequestBody List<BizProductAccessoriesMaterial> bizProductAccessoriesMaterialList) throws NoSuchFieldException, IllegalAccessException {
+        List<Map<String, Object>> ids = new ArrayList<>();
         //判断传入的个数
-        if(bizProductAccessoriesMaterialList.size() == 0){
+        if (bizProductAccessoriesMaterialList.size() == 0) {
             throw new RuntimeException("新增失败,数据不能为空");
         }
-        if(bizProductAccessoriesMaterialList.size() >100) {
+        if (bizProductAccessoriesMaterialList.size() > 100) {
             Set<Integer> categorySet = bizProductAccessoriesMaterialList.stream()
                     .filter(Objects::nonNull) // 确保对象本身不为 null
                     .map(BizProductAccessoriesMaterial::getCategory)
@@ -138,11 +137,11 @@ public class BizProductAccessoriesMaterialController extends BaseController
                     throw new RuntimeException("新增失败:" + categoryType + "不允许超过100条");
                 }
             }
-        }else {
+        } else {
             if (bizProductAccessoriesMaterialList.stream().anyMatch(material -> material.getCategory() == null)) {
                 throw new RuntimeException("新增失败,类别不能为空");
             }
-            if (bizProductAccessoriesMaterialList.stream().anyMatch(material ->  material.getCategory() != 1 && material.getCategory() != 2 && material.getCategory() != 3)) {
+            if (bizProductAccessoriesMaterialList.stream().anyMatch(material -> material.getCategory() != 1 && material.getCategory() != 2 && material.getCategory() != 3)) {
                 throw new RuntimeException("新增失败,类别只能为1、2、3");
             }
             //查询厂别是否存在
@@ -155,13 +154,13 @@ public class BizProductAccessoriesMaterialController extends BaseController
             List<Long> tenantIdsList = new ArrayList<>(tenantSet);
             if (tenantIdsList.size() > 1) {
                 List<BizTenant> tenantList = bizTenantService.query().in("id", tenantIdsList).list();
-                if(tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()){
+                if (tenantList.isEmpty() || tenantList.size() != tenantIdsList.size()) {
                     throw new RuntimeException("新增失败,厂别不存在");
                 }
             }
             //产品
             List<BizProductAccessoriesMaterial> productCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 1).collect(Collectors.toList());
-            if(!productCollect.isEmpty()){
+            if (!productCollect.isEmpty()) {
                 if (productCollect.stream().anyMatch(material -> material.getProductCode() == null || material.getProductCode() == "")) {
                     throw new RuntimeException("新增失败,产品编码不能为空");
                 }
@@ -176,57 +175,65 @@ public class BizProductAccessoriesMaterialController extends BaseController
                     //新增的产品编码没有重复
                     //判断数据库是否存在相同的产品编码
                     List<BizProduct> bizProductList = bizProductService.query().in("product_code", productCodes).list();
-                        if (!bizProductList.isEmpty()){
-                            throw new RuntimeException("新增失败,存在重复的产品编码");
-                        }else{
-                            List<BizProduct> productList = new ArrayList<>();
-                            for (BizProductAccessoriesMaterial product : productCollect) {
-                                BizProduct bizProduct = new BizProduct();
-                                bizProduct.setTenantId(product.getTenantId() != null ? product.getTenantId() : 0L);
-                                bizProduct.setProductCode(product.getProductCode() != null ? product.getProductCode() : "");
-                                bizProduct.setPreStock(product.getPreStock() != null ? product.getPreStock() : "");
-                                bizProduct.setType(product.getType() != null ? product.getType() : "");
-                                bizProduct.setShaftBroadCategoryId(product.getShaftBroadCategoryId() != null ? product.getShaftBroadCategoryId() : 0L);
-                                bizProduct.setShaftBroadCategoryCode(product.getShaftBroadCategoryCode() != null ? product.getShaftBroadCategoryCode() : "");
-                                bizProduct.setShaftCategoryId(product.getShaftCategoryId() != null ? product.getShaftCategoryId() : 0L);
-                                bizProduct.setShaftCategoryCode(product.getShaftCategoryCode() != null ? product.getShaftCategoryCode() : "");
-                                bizProduct.setSpecification(product.getSpecification() != null ? product.getSpecification() : "");
-                                bizProduct.setDrawingNumber(product.getDrawingNumber() != null ? product.getDrawingNumber() : "");
-                                bizProduct.setDescription(product.getDescription() != null ? product.getDescription() : "");
-                                bizProduct.setProductionTenantId(product.getProductionTenantId() != null ? product.getProductionTenantId() : 0L);
-                                bizProduct.setDiameter(product.getDiameter() != null ? product.getDiameter() : BigDecimal.ZERO);
-                                bizProduct.setLenght(product.getLenght() != null ? product.getLenght() : BigDecimal.ZERO);
-                                bizProduct.setThickness(product.getThickness() != null ? product.getThickness() : BigDecimal.ZERO);
-                                bizProduct.setCompanyId(product.getCompanyId() != null ? product.getCompanyId() : 0L);
-                                bizProduct.setCompanyCode(product.getCompanyCode() != null ? product.getCompanyCode() : "");
-                                bizProduct.setCompanyAlias(product.getCompanyAlias() != null ? product.getCompanyAlias() : "");
-                                bizProduct.setMaterialId(product.getMaterialId() != null ? product.getMaterialId() : 0L);
-                                bizProduct.setMaterialCode(product.getMaterialCode() != null ? product.getMaterialCode() : "");
-                                bizProduct.setDensity(product.getDensity() != null ? product.getDensity() : BigDecimal.ZERO);
-                                bizProduct.setSalesmanId(product.getSalesmanId() != null ? product.getSalesmanId() : 0L);
-                                bizProduct.setSalesmanCode(product.getSalesmanCode() != null ? product.getSalesmanCode() : "");
-                                bizProduct.setStockKeeperId(product.getStockKeeperId() != null ? product.getStockKeeperId() : 0L);
-                                bizProduct.setStockKeeperCode(product.getStockKeeperCode() != null ? product.getStockKeeperCode() : "");
-                                bizProduct.setDispatcherId(product.getDispatcherId() != null ? product.getDispatcherId() : 0L);
-                                bizProduct.setDispatcherCode(product.getDispatcherCode() != null ? product.getDispatcherCode() : "");
-                                bizProduct.setProductStatusCode(product.getProductStatusCode() != null ? product.getProductStatusCode() : "");
-                                bizProduct.setProductStatusId(product.getProductStatusId() != null ? product.getProductStatusId() : 0L);
-                                bizProduct.setProductionTypeId(product.getProductionTypeId() != null ? product.getProductionTypeId() : 0L);
-                                bizProduct.setProductionTypeCode(product.getProductionTypeCode() != null ? product.getProductionTypeCode() : "");
-                                bizProduct.setTechnicianId(product.getTechnicianId() != null ? product.getTechnicianId() : 0L);
-                                bizProduct.setTechnicianCode(product.getTechnicianCode() != null ? product.getTechnicianCode() : "");
-                                bizProduct.setCreatorCode(product.getCreatorCode() != null ? product.getCreatorCode() : "");
-                                bizProduct.setMaterialNum(product.getMaterialNum() != null ? product.getMaterialNum() : "");
-                                bizProduct.setIsSubclass(product.getIsSubclass() != null ? product.getIsSubclass() : 0);
-                                productList.add(bizProduct);
-                            }
-                            bizProductService.saveBatch(productList);
-                        }
+                    if (!bizProductList.isEmpty()) {
+                        throw new RuntimeException("新增失败,存在重复的产品编码");
+                    } else {
+                        List<BizProduct> productList = new ArrayList<>();
+                        for (BizProductAccessoriesMaterial product : productCollect) {
+                            BizProduct bizProduct = new BizProduct();
+                            bizProduct.setTenantId(product.getTenantId() != null ? product.getTenantId() : 0L);
+                            bizProduct.setProductCode(product.getProductCode() != null ? product.getProductCode() : "");
+                            bizProduct.setPreStock(product.getPreStock() != null ? product.getPreStock() : "");
+                            bizProduct.setType(product.getType() != null ? product.getType() : "");
+                            bizProduct.setShaftBroadCategoryId(product.getShaftBroadCategoryId() != null ? product.getShaftBroadCategoryId() : 0L);
+                            bizProduct.setShaftBroadCategoryCode(product.getShaftBroadCategoryCode() != null ? product.getShaftBroadCategoryCode() : "");
+                            bizProduct.setShaftCategoryId(product.getShaftCategoryId() != null ? product.getShaftCategoryId() : 0L);
+                            bizProduct.setShaftCategoryCode(product.getShaftCategoryCode() != null ? product.getShaftCategoryCode() : "");
+                            bizProduct.setSpecification(product.getSpecification() != null ? product.getSpecification() : "");
+                            bizProduct.setDrawingNumber(product.getDrawingNumber() != null ? product.getDrawingNumber() : "");
+                            bizProduct.setDescription(product.getDescription() != null ? product.getDescription() : "");
+                            bizProduct.setProductionTenantId(product.getProductionTenantId() != null ? product.getProductionTenantId() : 0L);
+                            bizProduct.setDiameter(product.getDiameter() != null ? product.getDiameter() : BigDecimal.ZERO);
+                            bizProduct.setLenght(product.getLenght() != null ? product.getLenght() : BigDecimal.ZERO);
+                            bizProduct.setThickness(product.getThickness() != null ? product.getThickness() : BigDecimal.ZERO);
+                            bizProduct.setCompanyId(product.getCompanyId() != null ? product.getCompanyId() : 0L);
+                            bizProduct.setCompanyCode(product.getCompanyCode() != null ? product.getCompanyCode() : "");
+                            bizProduct.setCompanyAlias(product.getCompanyAlias() != null ? product.getCompanyAlias() : "");
+                            bizProduct.setMaterialId(product.getMaterialId() != null ? product.getMaterialId() : 0L);
+                            bizProduct.setMaterialCode(product.getMaterialCode() != null ? product.getMaterialCode() : "");
+                            bizProduct.setDensity(product.getDensity() != null ? product.getDensity() : BigDecimal.ZERO);
+                            bizProduct.setSalesmanId(product.getSalesmanId() != null ? product.getSalesmanId() : 0L);
+                            bizProduct.setSalesmanCode(product.getSalesmanCode() != null ? product.getSalesmanCode() : "");
+                            bizProduct.setStockKeeperId(product.getStockKeeperId() != null ? product.getStockKeeperId() : 0L);
+                            bizProduct.setStockKeeperCode(product.getStockKeeperCode() != null ? product.getStockKeeperCode() : "");
+                            bizProduct.setDispatcherId(product.getDispatcherId() != null ? product.getDispatcherId() : 0L);
+                            bizProduct.setDispatcherCode(product.getDispatcherCode() != null ? product.getDispatcherCode() : "");
+                            bizProduct.setProductStatusCode(product.getProductStatusCode() != null ? product.getProductStatusCode() : "");
+                            bizProduct.setProductStatusId(product.getProductStatusId() != null ? product.getProductStatusId() : 0L);
+                            bizProduct.setProductionTypeId(product.getProductionTypeId() != null ? product.getProductionTypeId() : 0L);
+                            bizProduct.setProductionTypeCode(product.getProductionTypeCode() != null ? product.getProductionTypeCode() : "");
+                            bizProduct.setTechnicianId(product.getTechnicianId() != null ? product.getTechnicianId() : 0L);
+                            bizProduct.setTechnicianCode(product.getTechnicianCode() != null ? product.getTechnicianCode() : "");
+                            bizProduct.setCreatorCode(product.getCreatorCode() != null ? product.getCreatorCode() : "");
+                            bizProduct.setMaterialNum(product.getMaterialNum() != null ? product.getMaterialNum() : "");
+                            bizProduct.setIsSubclass(product.getIsSubclass() != null ? product.getIsSubclass() : 0);
+                            productList.add(bizProduct);
+                        }
+                        bizProductService.saveBatch(productList);
+//                        ids.addAll(productList.stream().map(BizProduct::getId).collect(Collectors.toList()));
+                        productList.forEach(v ->{
+                            Map<String,Object> t = new HashMap<String, Object>();
+                            t.put("id", v.getId());
+                            t.put("category", 1);
+                            t.put("code", v.getProductCode());
+                            ids.add(t);
+                        });
+                    }
                 }
             }
             //辅料
             List<BizProductAccessoriesMaterial> accessoriesCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 2).collect(Collectors.toList());
-            if(!accessoriesCollect.isEmpty()){
+            if (!accessoriesCollect.isEmpty()) {
                 if (accessoriesCollect.stream().anyMatch(material -> material.getAccessoriesCode() == null || material.getAccessoriesCode() == "")) {
                     throw new RuntimeException("新增失败,辅料编码不能为空");
                 }
@@ -241,12 +248,12 @@ public class BizProductAccessoriesMaterialController extends BaseController
                     //新增的辅料编码没有重复
                     //判断数据库是否存在相同的辅料编码
                     List<BizAccessories> bizAccessoriesList = bizAccessoriesService.query().in("accessories_code", accessoriesCodes).list();
-                    if (!bizAccessoriesList.isEmpty()){
-                        throw new RuntimeException("新增失败,存在重复的辅料编码");
-                    }else{
-                        List<BizAccessories> accessoriesList =  new ArrayList<>();
+                    if (!bizAccessoriesList.isEmpty()) {
+                        throw new RuntimeException("新增失败,存在重复的辅料编码");
+                    } else {
+                        List<BizAccessories> accessoriesList = new ArrayList<>();
                         for (BizProductAccessoriesMaterial accessories : accessoriesCollect) {
-                           BizAccessories bizAccessories = new BizAccessories();
+                            BizAccessories bizAccessories = new BizAccessories();
                             bizAccessories.setAccessoriesCode(accessories.getAccessoriesCode() != null ? accessories.getAccessoriesCode() : "");
                             bizAccessories.setItype(accessories.getItype() != null ? accessories.getItype() : "");
                             bizAccessories.setCusven(accessories.getCusven() != null ? accessories.getCusven() : "");
@@ -280,13 +287,21 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             bizAccessories.setTenantId(accessories.getTenantId() != null ? accessories.getTenantId() : 0L);
                             accessoriesList.add(bizAccessories);
                         }
-                    bizAccessoriesService.saveBatch(accessoriesList);
+                        bizAccessoriesService.saveBatch(accessoriesList);
+//                        ids.addAll(accessoriesList.stream().map(BizAccessories::getId).collect(Collectors.toList()));
+                        accessoriesList.forEach(v ->{
+                            Map<String, Object>  t = new HashMap<>();
+                            t.put("id",v.getId());
+                            t.put("code", v.getAccessoriesCode());
+                            t.put("category", 2);
+                            ids.add(t);
+                        });
                     }
                 }
             }
             //原材料
             List<BizProductAccessoriesMaterial> materialCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 3).collect(Collectors.toList());
-            if(!materialCollect.isEmpty()){
+            if (!materialCollect.isEmpty()) {
                 if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == null || material.getMaterialCode() == "")) {
                     throw new RuntimeException("新增失败,材料编码不能为空");
                 }
@@ -301,10 +316,10 @@ public class BizProductAccessoriesMaterialController extends BaseController
                     //新增的原材料编码没有重复
                     //判断数据库是否存在相同的原材料编码
                     List<BizMaterialBase> bizMaterialList = bizMaterialBaseService.query().in("material_code", materialCodes).list();
-                    if (!bizMaterialList.isEmpty()){
+                    if (!bizMaterialList.isEmpty()) {
                         throw new RuntimeException("新增失败,存在重复的原材料编码");
-                    }else{
-                        List<BizMaterialBase> materialList =  new ArrayList<>();
+                    } else {
+                        List<BizMaterialBase> materialList = new ArrayList<>();
                         for (BizProductAccessoriesMaterial material : materialCollect) {
                             BizMaterialBase bizMaterialBase = new BizMaterialBase();
                             bizMaterialBase.setMaterialCode(material.getMaterialCode() != null ? material.getMaterialCode() : "");
@@ -462,15 +477,24 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             bizMaterialBase.setTenantId(material.getTenantId() != null ? material.getTenantId() : 0L);
                             materialList.add(bizMaterialBase);
                         }
-                    bizMaterialBaseService.saveBatch(materialList);
+                        bizMaterialBaseService.saveBatch(materialList);
+                        materialList.forEach(v ->{
+                            Map<String, Object>  t = new HashMap<>();
+                            t.put("id",v.getId());
+                            t.put("code", v.getMaterialCode());
+                            t.put("category", 2);
+                            ids.add(t);
+                        });
                     }
                 }
             }
         }
-        return success();
+        return success(ids);
     }
+
     @PutMapping
     public AjaxResult edit(@RequestBody List<BizProductAccessoriesMaterial> bizProductAccessoriesMaterialList) throws NoSuchFieldException, IllegalAccessException {
+        List<Map<String, Object>> ids = new ArrayList<>();
         //判断传入的个数
         if (bizProductAccessoriesMaterialList.size() == 0) {
             throw new RuntimeException("修改失败,数据不能为空");
@@ -518,10 +542,10 @@ public class BizProductAccessoriesMaterialController extends BaseController
             //产品
             List<BizProductAccessoriesMaterial> productCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 1).collect(Collectors.toList());
             if (!productCollect.isEmpty()) {
-                if (productCollect.stream().anyMatch(material -> material.getHistoryProductCode()== null || material.getHistoryProductCode()== "")) {
+                if (productCollect.stream().anyMatch(material -> material.getHistoryProductCode() == null || material.getHistoryProductCode() == "")) {
                     throw new RuntimeException("修改失败,产品原始编码不能为空");
                 }
-                if (productCollect.stream().anyMatch(material -> material.getProductCode()== "")) {
+                if (productCollect.stream().anyMatch(material -> material.getProductCode() == "")) {
                     throw new RuntimeException("修改失败,产品目标编码不能为空");
                 }
                 //判断产品编码是否有重复(可能存在相同的id和编码写了多次
@@ -542,7 +566,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             .filter(material -> material.getProductCode() != null)
                             .map(BizProductAccessoriesMaterial::getProductCode)
                             .collect(Collectors.toList());
-                    if(!productCodes.isEmpty()) {
+                    if (!productCodes.isEmpty()) {
                         List<BizProduct> bizProductList = bizProductService.query().in("product_code", productCodes).list();
                         for (BizProductAccessoriesMaterial material : productCollect) {
                             for (BizProduct product : bizProductList) {
@@ -554,131 +578,137 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             }
                         }
                     }
-                        List<BizProduct> productList = bizProductService.query().in("product_code", productCollect.stream()
-                                .map(BizProductAccessoriesMaterial::getHistoryProductCode)
-                                .collect(Collectors.toList())).list();
-                        for (BizProductAccessoriesMaterial product : productCollect) {
-                            BizProduct bizProduct  = productList.stream().filter(item->item.getProductCode().equals(product.getHistoryProductCode())).findFirst().orElse(null);
-                            if (bizProduct == null) {
-                                throw new RuntimeException("修改失败,产品编码不存在");
-                            }
-                            if (product.getTenantId() != null) {
-                                bizProduct.setTenantId(product.getTenantId());
-                            }
-                            if (product.getProductCode() != null) {
-                                bizProduct.setProductCode(product.getProductCode());
-                            }
-                            if (product.getPreStock() != null) {
-                                bizProduct.setPreStock(product.getPreStock());
-                            }
-                            if (product.getType() != null) {
-                                bizProduct.setType(product.getType());
-                            }
-                            if (product.getShaftBroadCategoryId() != null) {
-                                bizProduct.setShaftBroadCategoryId(product.getShaftBroadCategoryId());
-                            }
-                            if (product.getShaftBroadCategoryCode() != null) {
-                                bizProduct.setShaftBroadCategoryCode(product.getShaftBroadCategoryCode());
-                            }
-                            if (product.getShaftCategoryId() != null) {
-                                bizProduct.setShaftCategoryId(product.getShaftCategoryId());
-                            }
-                            if (product.getShaftCategoryCode() != null) {
-                                bizProduct.setShaftCategoryCode(product.getShaftCategoryCode());
-                            }
-                            if (product.getSpecification() != null) {
-                                bizProduct.setSpecification(product.getSpecification());
-                            }
-                            if (product.getDrawingNumber() != null) {
-                                bizProduct.setDrawingNumber(product.getDrawingNumber());
-                            }
-                            if (product.getDescription() != null) {
-                                bizProduct.setDescription(product.getDescription());
-                            }
-                            if (product.getProductionTenantId() != null) {
-                                bizProduct.setProductionTenantId(product.getProductionTenantId());
-                            }
-                            if (product.getDiameter() != null) {
-                                bizProduct.setDiameter(product.getDiameter());
-                            }
-                            if (product.getLenght() != null) {
-                                bizProduct.setLenght(product.getLenght());
-                            }
-                            if (product.getThickness() != null) {
-                                bizProduct.setThickness(product.getThickness());
-                            }
-                            if (product.getCompanyId() != null) {
-                                bizProduct.setCompanyId(product.getCompanyId());
-                            }
-                            if (product.getCompanyCode() != null) {
-                                bizProduct.setCompanyCode(product.getCompanyCode());
-                            }
-                            if (product.getCompanyAlias() != null) {
-                                bizProduct.setCompanyAlias(product.getCompanyAlias());
-                            }
-                            if (product.getMaterialId() != null) {
-                                bizProduct.setMaterialId(product.getMaterialId());
-                            }
-                            if (product.getMaterialCode() != null) {
-                                bizProduct.setMaterialCode(product.getMaterialCode());
-                            }
-                            if (product.getDensity() != null) {
-                                bizProduct.setDensity(product.getDensity());
-                            }
-                            if (product.getSalesmanId() != null) {
-                                bizProduct.setSalesmanId(product.getSalesmanId());
-                            }
-                            if (product.getSalesmanCode() != null) {
-                                bizProduct.setSalesmanCode(product.getSalesmanCode());
-                            }
-                            if (product.getStockKeeperId() != null) {
-                                bizProduct.setStockKeeperId(product.getStockKeeperId());
-                            }
-                            if (product.getStockKeeperCode() != null) {
-                                bizProduct.setStockKeeperCode(product.getStockKeeperCode());
-                            }
-                            if (product.getDispatcherId() != null) {
-                                bizProduct.setDispatcherId(product.getDispatcherId());
-                            }
-                            if (product.getDispatcherCode() != null) {
-                                bizProduct.setDispatcherCode(product.getDispatcherCode());
-                            }
-                            if (product.getProductStatusCode() != null) {
-                                bizProduct.setProductStatusCode(product.getProductStatusCode());
-                            }
-                            if (product.getProductStatusId() != null) {
-                                bizProduct.setProductStatusId(product.getProductStatusId());
-                            }
-                            if (product.getProductionTypeId() != null) {
-                                bizProduct.setProductionTypeId(product.getProductionTypeId());
-                            }
-                            if (product.getProductionTypeCode() != null) {
-                                bizProduct.setProductionTypeCode(product.getProductionTypeCode());
-                            }
-                            if (product.getTechnicianId() != null) {
-                                bizProduct.setTechnicianId(product.getTechnicianId());
-                            }
-                            if (product.getTechnicianCode() != null) {
-                                bizProduct.setTechnicianCode(product.getTechnicianCode());
-                            }
-                            if (product.getCreatorCode() != null) {
-                                bizProduct.setCreatorCode(product.getCreatorCode());
-                            }
-                            if (product.getMaterialNum() != null) {
-                                bizProduct.setMaterialNum(product.getMaterialNum());
-                            }
-                            if (product.getIsSubclass() != null) {
-                                bizProduct.setIsSubclass(product.getIsSubclass());
-                            }
+                    List<BizProduct> productList = bizProductService.query().in("product_code", productCollect.stream()
+                            .map(BizProductAccessoriesMaterial::getHistoryProductCode)
+                            .collect(Collectors.toList())).list();
+                    for (BizProductAccessoriesMaterial product : productCollect) {
+                        BizProduct bizProduct = productList.stream().filter(item -> item.getProductCode().equals(product.getHistoryProductCode())).findFirst().orElse(null);
+                        if (bizProduct == null) {
+                            throw new RuntimeException("修改失败,产品编码不存在");
                         }
-                        bizProductService.updateBatchById(productList);
-
+                        if (product.getTenantId() != null) {
+                            bizProduct.setTenantId(product.getTenantId());
+                        }
+                        if (product.getProductCode() != null) {
+                            bizProduct.setProductCode(product.getProductCode());
+                        }
+                        if (product.getPreStock() != null) {
+                            bizProduct.setPreStock(product.getPreStock());
+                        }
+                        if (product.getType() != null) {
+                            bizProduct.setType(product.getType());
+                        }
+                        if (product.getShaftBroadCategoryId() != null) {
+                            bizProduct.setShaftBroadCategoryId(product.getShaftBroadCategoryId());
+                        }
+                        if (product.getShaftBroadCategoryCode() != null) {
+                            bizProduct.setShaftBroadCategoryCode(product.getShaftBroadCategoryCode());
+                        }
+                        if (product.getShaftCategoryId() != null) {
+                            bizProduct.setShaftCategoryId(product.getShaftCategoryId());
+                        }
+                        if (product.getShaftCategoryCode() != null) {
+                            bizProduct.setShaftCategoryCode(product.getShaftCategoryCode());
+                        }
+                        if (product.getSpecification() != null) {
+                            bizProduct.setSpecification(product.getSpecification());
+                        }
+                        if (product.getDrawingNumber() != null) {
+                            bizProduct.setDrawingNumber(product.getDrawingNumber());
+                        }
+                        if (product.getDescription() != null) {
+                            bizProduct.setDescription(product.getDescription());
+                        }
+                        if (product.getProductionTenantId() != null) {
+                            bizProduct.setProductionTenantId(product.getProductionTenantId());
+                        }
+                        if (product.getDiameter() != null) {
+                            bizProduct.setDiameter(product.getDiameter());
+                        }
+                        if (product.getLenght() != null) {
+                            bizProduct.setLenght(product.getLenght());
+                        }
+                        if (product.getThickness() != null) {
+                            bizProduct.setThickness(product.getThickness());
+                        }
+                        if (product.getCompanyId() != null) {
+                            bizProduct.setCompanyId(product.getCompanyId());
+                        }
+                        if (product.getCompanyCode() != null) {
+                            bizProduct.setCompanyCode(product.getCompanyCode());
+                        }
+                        if (product.getCompanyAlias() != null) {
+                            bizProduct.setCompanyAlias(product.getCompanyAlias());
+                        }
+                        if (product.getMaterialId() != null) {
+                            bizProduct.setMaterialId(product.getMaterialId());
+                        }
+                        if (product.getMaterialCode() != null) {
+                            bizProduct.setMaterialCode(product.getMaterialCode());
+                        }
+                        if (product.getDensity() != null) {
+                            bizProduct.setDensity(product.getDensity());
+                        }
+                        if (product.getSalesmanId() != null) {
+                            bizProduct.setSalesmanId(product.getSalesmanId());
+                        }
+                        if (product.getSalesmanCode() != null) {
+                            bizProduct.setSalesmanCode(product.getSalesmanCode());
+                        }
+                        if (product.getStockKeeperId() != null) {
+                            bizProduct.setStockKeeperId(product.getStockKeeperId());
+                        }
+                        if (product.getStockKeeperCode() != null) {
+                            bizProduct.setStockKeeperCode(product.getStockKeeperCode());
+                        }
+                        if (product.getDispatcherId() != null) {
+                            bizProduct.setDispatcherId(product.getDispatcherId());
+                        }
+                        if (product.getDispatcherCode() != null) {
+                            bizProduct.setDispatcherCode(product.getDispatcherCode());
+                        }
+                        if (product.getProductStatusCode() != null) {
+                            bizProduct.setProductStatusCode(product.getProductStatusCode());
+                        }
+                        if (product.getProductStatusId() != null) {
+                            bizProduct.setProductStatusId(product.getProductStatusId());
+                        }
+                        if (product.getProductionTypeId() != null) {
+                            bizProduct.setProductionTypeId(product.getProductionTypeId());
+                        }
+                        if (product.getProductionTypeCode() != null) {
+                            bizProduct.setProductionTypeCode(product.getProductionTypeCode());
+                        }
+                        if (product.getTechnicianId() != null) {
+                            bizProduct.setTechnicianId(product.getTechnicianId());
+                        }
+                        if (product.getTechnicianCode() != null) {
+                            bizProduct.setTechnicianCode(product.getTechnicianCode());
+                        }
+                        if (product.getCreatorCode() != null) {
+                            bizProduct.setCreatorCode(product.getCreatorCode());
+                        }
+                        if (product.getMaterialNum() != null) {
+                            bizProduct.setMaterialNum(product.getMaterialNum());
+                        }
+                        if (product.getIsSubclass() != null) {
+                            bizProduct.setIsSubclass(product.getIsSubclass());
+                        }
+                    }
+                    bizProductService.updateBatchById(productList);
+                    productList.forEach(v ->{
+                        Map<String,Object> t = new HashMap<String, Object>();
+                        t.put("id", v.getId());
+                        t.put("category", 1);
+                        t.put("code", v.getProductCode());
+                        ids.add(t);
+                    });
                 }
             }
             //辅料
             List<BizProductAccessoriesMaterial> accessoriesCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 2).collect(Collectors.toList());
             if (!accessoriesCollect.isEmpty()) {
-                if (accessoriesCollect.stream().anyMatch(material -> material.getHistoryAccessoriesCode()== null || material.getHistoryAccessoriesCode()== "")) {
+                if (accessoriesCollect.stream().anyMatch(material -> material.getHistoryAccessoriesCode() == null || material.getHistoryAccessoriesCode() == "")) {
                     throw new RuntimeException("修改失败,辅料原始编码不能为空");
                 }
                 if (accessoriesCollect.stream().anyMatch(material -> material.getAccessoriesCode() == "")) {
@@ -701,7 +731,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             .filter(material -> material.getAccessoriesCode() != null)
                             .map(BizProductAccessoriesMaterial::getAccessoriesCode)
                             .collect(Collectors.toList());
-                    if(!accessorieCodes.isEmpty()) {
+                    if (!accessorieCodes.isEmpty()) {
                         List<BizAccessories> bizAccessoriesList = bizAccessoriesService.query().in("accessories_code", accessorieCodes).list();
                         for (BizProductAccessoriesMaterial material : accessoriesCollect) {
                             for (BizAccessories accessories : bizAccessoriesList) {
@@ -717,7 +747,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             .map(BizProductAccessoriesMaterial::getHistoryAccessoriesCode)
                             .collect(Collectors.toList())).list();
                     for (BizProductAccessoriesMaterial accessories : accessoriesCollect) {
-                        BizAccessories bizAccessories  = accesoriesList.stream().filter(item->item.getAccessoriesCode().equals(accessories.getHistoryAccessoriesCode())).findFirst().orElse(null);
+                        BizAccessories bizAccessories = accesoriesList.stream().filter(item -> item.getAccessoriesCode().equals(accessories.getHistoryAccessoriesCode())).findFirst().orElse(null);
                         if (bizAccessories == null) {
                             throw new RuntimeException("修改失败,辅料编码不存在");
                         }
@@ -814,14 +844,21 @@ public class BizProductAccessoriesMaterialController extends BaseController
                         if (accessories.getTenantId() != null) {
                             bizAccessories.setTenantId(accessories.getTenantId());
                         }
-                        }
-                        bizAccessoriesService.updateBatchById(accesoriesList);
                     }
+                    bizAccessoriesService.updateBatchById(accesoriesList);
+                    accesoriesList.forEach(v ->{
+                        Map<String,Object> t = new HashMap<String, Object>();
+                        t.put("id", v.getId());
+                        t.put("category", 2);
+                        t.put("code", v.getAccessoriesCode());
+                        ids.add(t);
+                    });
                 }
+            }
             //原材料
             List<BizProductAccessoriesMaterial> materialCollect = bizProductAccessoriesMaterialList.stream().filter(item -> item.getCategory() == 3).collect(Collectors.toList());
             if (!materialCollect.isEmpty()) {
-                if (materialCollect.stream().anyMatch(material -> material.getHistoryMaterialCode()== null || material.getHistoryMaterialCode()== "")) {
+                if (materialCollect.stream().anyMatch(material -> material.getHistoryMaterialCode() == null || material.getHistoryMaterialCode() == "")) {
                     throw new RuntimeException("修改失败,原材料原始编码不能为空");
                 }
                 if (materialCollect.stream().anyMatch(material -> material.getMaterialCode() == "")) {
@@ -860,7 +897,7 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             .map(BizProductAccessoriesMaterial::getHistoryMaterialCode)
                             .collect(Collectors.toList())).list();
                     for (BizProductAccessoriesMaterial material : materialCollect) {
-                        BizMaterialBase bizMaterialBase  = materialList.stream().filter(item->item.getMaterialCode().equals(material.getHistoryMaterialCode())).findFirst().orElse(null);
+                        BizMaterialBase bizMaterialBase = materialList.stream().filter(item -> item.getMaterialCode().equals(material.getHistoryMaterialCode())).findFirst().orElse(null);
                         if (bizMaterialBase == null) {
                             throw new RuntimeException("修改失败,原材料编码不存在");
                         }
@@ -1324,12 +1361,20 @@ public class BizProductAccessoriesMaterialController extends BaseController
                         if (material.getTenantId() != null) {
                             bizMaterialBase.setTenantId(material.getTenantId());
                         }
-                        }
-                        bizMaterialBaseService.updateBatchById(materialList);
                     }
+                    bizMaterialBaseService.updateBatchById(materialList);
+
+                    materialList.forEach(v ->{
+                        Map<String,Object> t = new HashMap<String, Object>();
+                        t.put("id", v.getId());
+                        t.put("category", 3);
+                        t.put("code", v.getMaterialCode());
+                        ids.add(t);
+                    });
                 }
             }
-            return success();
+        }
+        return success(ids);
     }
 
 }