Explorar o código

Merge remote-tracking branch 'origin/master'

guoyujia hai 3 semanas
pai
achega
c2f3161dc5

+ 275 - 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,16 +154,19 @@ public class BizProductAccessoriesMaterialController extends BaseController
             List<Long> tenantIdsList = new ArrayList<>(tenantSet);
             if (tenantIdsList.size() > 0) {
                 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("新增失败,产品编码不能为空");
                 }
+                if (productCollect.stream().anyMatch(material -> material.getJdId() == null)) {
+                    throw new RuntimeException("新增失败,金蝶id不能为空");
+                }
                 //判断产品编码是否有重复
                 List<String> productCodes = productCollect.stream()
                         .map(BizProductAccessoriesMaterial::getProductCode)
@@ -176,60 +178,72 @@ 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);
+                            bizProduct.setJdId(product.getJdId() != null ? product.getJdId() : 0L);
+                            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("新增失败,辅料编码不能为空");
                 }
+                if (accessoriesCollect.stream().anyMatch(material -> material.getJdId() == null)) {
+                    throw new RuntimeException("新增失败,金蝶id不能为空");
+                }
                 //判断辅料编码是否有重复
                 List<String> accessoriesCodes = accessoriesCollect.stream()
                         .map(BizProductAccessoriesMaterial::getAccessoriesCode)
@@ -241,12 +255,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() : "");
@@ -278,18 +292,30 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             bizAccessories.setKtyts(accessories.getKtyts() != null ? accessories.getKtyts() : 0L);
                             bizAccessories.setFacno(accessories.getFacno() != null ? accessories.getFacno() : "");
                             bizAccessories.setTenantId(accessories.getTenantId() != null ? accessories.getTenantId() : 0L);
+                            bizAccessories.setJdId(accessories.getJdId() != null ? accessories.getJdId() : 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("新增失败,材料编码不能为空");
                 }
+                if (materialCollect.stream().anyMatch(material -> material.getJdId() == null)) {
+                    throw new RuntimeException("新增失败,金碟id不能为空");
+                }
                 //判断原材料编码是否有重复
                 List<String> materialCodes = materialCollect.stream()
                         .map(BizProductAccessoriesMaterial::getMaterialCode)
@@ -301,10 +327,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() : "");
@@ -460,17 +486,27 @@ public class BizProductAccessoriesMaterialController extends BaseController
                             bizMaterialBase.setDtype(material.getDtype() != null ? material.getDtype() : "");
                             bizMaterialBase.setZjbxprc(material.getZjbxprc() != null ? material.getZjbxprc() : BigDecimal.ZERO);
                             bizMaterialBase.setTenantId(material.getTenantId() != null ? material.getTenantId() : 0L);
+                            bizMaterialBase.setJdId(material.getJdId() != null ? material.getJdId() : 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 +554,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 +578,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 +590,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 +743,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 +759,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 +856,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 +909,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 +1373,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);
     }
 
 }

+ 59 - 68
src/main/java/cn/ezhizao/project/business/controller/SysDeptController.java

@@ -39,8 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
 //@Api("部门管理")
 @RestController
 @RequestMapping("/business/dept")
-public class SysDeptController extends BaseController
-{
+public class SysDeptController extends BaseController {
     @Resource
     private ISysDeptService sysDeptService;
     @Resource
@@ -65,11 +64,11 @@ public class SysDeptController extends BaseController
 //            @ApiImplicitParam(name = "tenantId", value = "厂别ID", required = false, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
 //    })
     @GetMapping("/list")
-    public TableDataInfo list(SysDept sysDept) throws NoSuchFieldException, IllegalAccessException
-    {
+    public TableDataInfo list(SysDept sysDept) throws NoSuchFieldException, IllegalAccessException {
         List<SysDept> list = sysDeptService.getList(sysDept);
         return getDataTable(list);
     }
+
     /**
      * 新增部门
      */
@@ -87,73 +86,70 @@ public class SysDeptController extends BaseController
 //    })
     @Log(title = "部门", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody SysDept sysDept) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult add(@RequestBody SysDept sysDept) throws NoSuchFieldException, IllegalAccessException {
         //判断必填项
-        if(sysDept.getTenantId() ==null ||sysDept.getDeptName() ==null || sysDept.getDeptName() ==""||sysDept.getDeptCode() ==null || sysDept.getDeptCode() =="") {
-           return error("新增部门失败,请求必填项:厂别、部门名称、部门编码不能为空");
+        if (sysDept.getTenantId() == null || sysDept.getDeptName() == null || sysDept.getDeptName().isEmpty() || sysDept.getDeptCode() == null || sysDept.getDeptCode().isEmpty() || sysDept.getJdId() == null) {
+            return error("新增部门失败,请求必填项:金碟id、厂别、部门名称、部门编码不能为空");
         }
-        if((sysDept.getIsOutsourcing() !=null && sysDept.getIsOutsourcing() ==1) && sysDept.getSupplierId() ==null) {
+        if ((sysDept.getIsOutsourcing() != null && sysDept.getIsOutsourcing() == 1) && sysDept.getSupplierId() == null) {
             return error("新增部门失败,外协商不能为空");
         }
-        if(sysDept.getIsOutsourcing() ==null && sysDept.getSupplierId() !=null) {
+        if (sysDept.getIsOutsourcing() == null && sysDept.getSupplierId() != null) {
             return error("新增部门失败,是否外协应为是");
         }
         //是否判断,只能是null,0,1
-        if(sysDept.getIsOutsourcing() !=null && !(sysDept.getIsOutsourcing() ==0 || sysDept.getIsOutsourcing() ==1)){
+        if (sysDept.getIsOutsourcing() != null && !(sysDept.getIsOutsourcing() == 0 || sysDept.getIsOutsourcing() == 1)) {
             return error("新增部门失败,是否外协只能是0或1");
         }
-        if(sysDept.getIsWorkSection() !=null &&sysDept.getIsWorkSection() !="" && !(sysDept.getIsWorkSection().equals("0") || sysDept.getIsWorkSection().equals("1"))){
+        if (sysDept.getIsWorkSection() != null && sysDept.getIsWorkSection() != "" && !(sysDept.getIsWorkSection().equals("0") || sysDept.getIsWorkSection().equals("1"))) {
             return error("新增部门失败,是否为工段只能是0或1");
         }
-        if(sysDept.getEquimentFlag() !=null && !(sysDept.getEquimentFlag() ==0 || sysDept.getEquimentFlag() ==1)){
+        if (sysDept.getEquimentFlag() != null && !(sysDept.getEquimentFlag() == 0 || sysDept.getEquimentFlag() == 1)) {
             return error("新增部门失败,是否一机多批只能是0或1");
         }
-        if(sysDept.getIsSortPackaging() !=null && !(sysDept.getIsSortPackaging() ==0 || sysDept.getIsSortPackaging() ==1)){
+        if (sysDept.getIsSortPackaging() != null && !(sysDept.getIsSortPackaging() == 0 || sysDept.getIsSortPackaging() == 1)) {
             return error("新增部门失败,是否分选只能是0或1");
         }
         //厂别判断
         List<BizTenant> tenantList = bizTenantService.query().eq("id", sysDept.getTenantId()).list();
-        if(tenantList.isEmpty()){
+        if (tenantList.isEmpty()) {
             return error("新增部门失败,厂别不存在");
         }
         //外协商判断
-        if((sysDept.getIsOutsourcing() !=null && sysDept.getIsOutsourcing() ==1) && sysDept.getSupplierId() !=null) {
+        if ((sysDept.getIsOutsourcing() != null && sysDept.getIsOutsourcing() == 1) && sysDept.getSupplierId() != null) {
             SysDept dept = new SysDept();
             dept.setDeptId(0L);
             dept.setIsInnerOutsource(1);
             List<BizSupplier> supplierList = bizSupplierService.getListByDept(dept);
-            if(supplierList.isEmpty()){
+            if (supplierList.isEmpty()) {
                 return error("新增部门失败,外协商都被使用,请新增外协商");
-            }else{
-                if(supplierList.stream().filter(supplier -> supplier.getId().equals(sysDept.getSupplierId())).findFirst().orElse(null) == null){
+            } else {
+                if (supplierList.stream().filter(supplier -> supplier.getId().equals(sysDept.getSupplierId())).findFirst().orElse(null) == null) {
                     return error("新增部门失败,外协商已被使用,请重新选择");
                 }
             }
         }
-        if(sysDept.getParentId() == null){
+        if (sysDept.getParentId() == null) {
             sysDept.setParentId(0L);
         }
-            if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptNameUnique(sysDept)))
-            {
-                return error("新增部门'" + sysDept.getDeptName() + "'失败,部门名称已存在");
-            }
-            if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptCodeUnique(sysDept)))
-            {
-                return error("新增部门'" + sysDept.getDeptName() + "'失败,部门编码已存在");
-            }
-            sysDept.setCreateBy(getUsername());
-            int i = sysDeptService.insertDept(sysDept);
-            //  新增默认摆放区域信息
-            if (i > 0) {
-                BizTurnover turnover = new BizTurnover();
-                turnover.setStatus(9);
-                turnover.setCode("默认区");
-                turnover.setTenantId(sysDept.getTenantId());
-                turnover.setDeptId(sysDept.getDeptId());
-                bizTurnoverService.save(turnover);
-            }
-            return success();
+        if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptNameUnique(sysDept))) {
+            return error("新增部门'" + sysDept.getDeptName() + "'失败,部门名称已存在");
+        }
+        if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptCodeUnique(sysDept))) {
+            return error("新增部门'" + sysDept.getDeptName() + "'失败,部门编码已存在");
+        }
+        sysDept.setCreateBy(getUsername());
+        int i = sysDeptService.insertDept(sysDept);
+        //  新增默认摆放区域信息
+        if (i > 0) {
+            BizTurnover turnover = new BizTurnover();
+            turnover.setStatus(9);
+            turnover.setCode("默认区");
+            turnover.setTenantId(sysDept.getTenantId());
+            turnover.setDeptId(sysDept.getDeptId());
+            bizTurnoverService.save(turnover);
+        }
+        return success();
     }
 
     /**
@@ -174,59 +170,57 @@ public class SysDeptController extends BaseController
 //    })
     @Log(title = "部门", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody SysDept sysDept) throws NoSuchFieldException, IllegalAccessException
-    {
+    public AjaxResult edit(@RequestBody SysDept sysDept) throws NoSuchFieldException, IllegalAccessException {
         //判断必填项
-        if(sysDept.getDeptId() ==null) {
-            return error("修改部门失败,部门id不能为空");
+        if (sysDept.getDeptId() == null || sysDept.getJdId() == null) {
+            return error("修改部门失败,部门id、金碟id不能为空");
         }
-        if((sysDept.getIsOutsourcing() !=null && sysDept.getIsOutsourcing() ==1) && sysDept.getSupplierId() ==null) {
+        if ((sysDept.getIsOutsourcing() != null && sysDept.getIsOutsourcing() == 1) && sysDept.getSupplierId() == null) {
             return error("修改部门失败,外协商不能为空");
         }
-        if(sysDept.getIsOutsourcing() ==null && sysDept.getSupplierId() !=null) {
+        if (sysDept.getIsOutsourcing() == null && sysDept.getSupplierId() != null) {
             return error("修改部门失败,是否外协应为是");
         }
         //是否判断,只能是null,0,1
-        if(sysDept.getIsOutsourcing() !=null && !(sysDept.getIsOutsourcing() ==0 || sysDept.getIsOutsourcing() ==1)){
+        if (sysDept.getIsOutsourcing() != null && !(sysDept.getIsOutsourcing() == 0 || sysDept.getIsOutsourcing() == 1)) {
             return error("修改部门失败,是否外协只能是0或1");
         }
-        if(sysDept.getIsWorkSection() !=null && sysDept.getIsWorkSection() !="" && !(sysDept.getIsWorkSection().equals("0") || sysDept.getIsWorkSection().equals("1"))){
+        if (sysDept.getIsWorkSection() != null && sysDept.getIsWorkSection() != "" && !(sysDept.getIsWorkSection().equals("0") || sysDept.getIsWorkSection().equals("1"))) {
             return error("修改部门失败,是否为工段只能是0或1");
         }
-        if(sysDept.getEquimentFlag() !=null && !(sysDept.getEquimentFlag() ==0 || sysDept.getEquimentFlag() ==1)){
+        if (sysDept.getEquimentFlag() != null && !(sysDept.getEquimentFlag() == 0 || sysDept.getEquimentFlag() == 1)) {
             return error("修改部门失败,是否一机多批只能是0或1");
         }
-        if(sysDept.getIsSortPackaging() !=null && !(sysDept.getIsSortPackaging() ==0 || sysDept.getIsSortPackaging() ==1)){
+        if (sysDept.getIsSortPackaging() != null && !(sysDept.getIsSortPackaging() == 0 || sysDept.getIsSortPackaging() == 1)) {
             return error("修改部门失败,是否分选只能是0或1");
         }
         //厂别判断
         List<BizTenant> tenantList = bizTenantService.query().eq("id", sysDept.getTenantId()).list();
-        if(tenantList.isEmpty()){
+        if (tenantList.isEmpty()) {
             return error("修改部门失败,厂别不存在");
         }
         //外协商判断
-        if((sysDept.getIsOutsourcing() !=null && sysDept.getIsOutsourcing() ==1) && sysDept.getSupplierId() !=null) {
+        if ((sysDept.getIsOutsourcing() != null && sysDept.getIsOutsourcing() == 1) && sysDept.getSupplierId() != null) {
             SysDept dept = new SysDept();
             dept.setDeptId(0L);
             dept.setIsInnerOutsource(1);
             List<BizSupplier> supplierList = bizSupplierService.getListByDept(dept);
-            if(supplierList.isEmpty()){
+            if (supplierList.isEmpty()) {
                 return error("修改部门失败,外协商都被使用,请新增外协商");
-            }else{
-                if(supplierList.stream().filter(supplier -> supplier.getId().equals(sysDept.getSupplierId())).findFirst().orElse(null) == null){
+            } else {
+                if (supplierList.stream().filter(supplier -> supplier.getId().equals(sysDept.getSupplierId())).findFirst().orElse(null) == null) {
                     return error("修改部门失败,外协商已被使用,请重新选择");
                 }
             }
         }
-        if(sysDept.getParentId() == null){
+        if (sysDept.getParentId() == null) {
             sysDept.setParentId(0L);
         }
         if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptNameUnique(sysDept))) {
             return error("修改部门'" + sysDept.getDeptName() + "'失败,部门名称已存在");
-        }else if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptCodeUnique(sysDept))) {
+        } else if (UserConstants.NOT_UNIQUE.equals(sysDeptService.checkDeptCodeUnique(sysDept))) {
             return error("修改部门'" + sysDept.getDeptName() + "'失败,部门编码已存在");
-        }
-        else if (sysDept.getParentId().equals(sysDept.getDeptId())) {
+        } else if (sysDept.getParentId().equals(sysDept.getDeptId())) {
             return error("修改部门'" + sysDept.getDeptName() + "'失败,上级部门不能是自己");
         } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, sysDept.getStatus()) && sysDeptService.selectNormalChildrenDeptById(sysDept.getDeptId()) > 0) {
             return error("该部门包含未停用的子部门!");
@@ -244,20 +238,17 @@ public class SysDeptController extends BaseController
 //            @ApiImplicitParam(name = "deptId", value = "部门ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
 //    })
     @Log(title = "部门", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{deptId}")
-    public AjaxResult remove(@PathVariable Long deptId)
-    {
+    @DeleteMapping("/{deptId}")
+    public AjaxResult remove(@PathVariable Long deptId) {
         SysDept dept = sysDeptService.getDeptByDeptId(deptId);
-        if (dept == null){
+        if (dept == null) {
             return error("部门不存在");
         }
-        List<SysDeptUser> deptUserList = sysDeptUserService.query().in("dept_id", deptId).eq("deleted",0).list();
-        if (deptUserList.size() > 0)
-        {
+        List<SysDeptUser> deptUserList = sysDeptUserService.query().in("dept_id", deptId).eq("deleted", 0).list();
+        if (deptUserList.size() > 0) {
             return error("部门存在用户,不允许删除");
         }
-        if (sysDeptService.hasChildByDeptId(deptId))
-        {
+        if (sysDeptService.hasChildByDeptId(deptId)) {
             return warn("存在下级部门,不允许删除");
         }
         return toAjax(sysDeptService.deleteDeptById(deptId));

+ 4 - 2
src/main/java/cn/ezhizao/project/business/controller/SysUserController.java

@@ -91,8 +91,7 @@ public class SysUserController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody SysUser sysUser) throws NoSuchFieldException, IllegalAccessException
     {
-        if(sysUser.getUserName() == null || sysUser.getUserName() == ""||sysUser.getNickName() == null || sysUser.getNickName() == "" || sysUser.getUsageCompanyId() == null
-                ||sysUser.getContractCompanyId() == null ){
+        if(sysUser.getUserName() == null || sysUser.getUserName() == ""||sysUser.getNickName() == null || sysUser.getNickName() == "" || sysUser.getUsageCompanyId() == null ||sysUser.getContractCompanyId() == null || sysUser.getJdId() == null){
             return error("新增用户失败,员工姓名,员工编码,合同单位,使用单位必填项不能为空");
         }
         //判断员工状态,用户性别的值
@@ -156,6 +155,9 @@ public class SysUserController extends BaseController
         if(sysUser.getUserId() == null){
             return error("修改用户失败,用户ID不能为空");
         }
+        if(sysUser.getJdId() == null){
+            return error("修改用户失败,金碟ID不能为空");
+        }
         if(sysUser.getUserName() == ""|| sysUser.getNickName() == "" ){
             return error("修改用户失败,员工姓名,员工编码不能为空");
         }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/domain/BizProductAccessoriesMaterial.java

@@ -1058,4 +1058,6 @@ public class BizProductAccessoriesMaterial extends BaseEntity
 
     private List<Long> ids;
 
+    private Long jdId;
+
 }

+ 9 - 0
src/main/java/cn/ezhizao/project/system/domain/SysUser.java

@@ -142,6 +142,7 @@ public class SysUser extends BaseEntity {
     private String deptName;
     private Long usageCompanyId;
     private String usageCompanyName;
+    private Long jdId;
 
     @TableField(exist = false)
     private List<Long> hasAddIds;
@@ -439,4 +440,12 @@ public class SysUser extends BaseEntity {
                 .append("remark", getRemark())
                 .toString();
     }
+
+    public Long getJdId() {
+        return jdId;
+    }
+
+    public void setJdId(Long jdId) {
+        this.jdId = jdId;
+    }
 }

+ 3 - 0
src/main/resources/mybatis/business/SysDeptMapper.xml

@@ -101,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="supplierId != null">supplier_id,</if>
         <if test="createBy != null and createBy != ''">create_by,</if>
         <if test="type != null ">type,</if>
+        <if test="jdId != null">jd_id,</if>
         create_time
         )values(
         <if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -121,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="supplierId != null">#{supplierId},</if>
         <if test="createBy != null and createBy != ''">#{createBy},</if>
         <if test="type != null">#{type},</if>
+        <if test="jdId != null">#{jdId},</if>
         sysdate()
         )
     </insert>
@@ -145,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="supplierId != null">supplier_id = #{supplierId},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             <if test="type != null">type = #{type},</if>
+            <if test="jdId != null">jd_id = #{jdId}</if>
             update_time = sysdate()
         </set>
         where dept_id = #{deptId}

+ 3 - 0
src/main/resources/mybatis/system/SysUserMapper.xml

@@ -279,6 +279,7 @@
 		<if test="contractCompanyId != null and contractCompanyId != ''">contract_company_id,</if>
 		<if test="usageCompanyId != null and usageCompanyId != 0">usage_company_id,</if>
 		<if test="usageCompanyName != null and usageCompanyName != ''">usage_company_name,</if>
+		<if test="jdId != null">jd_id,</if>
 		create_time
 		)VALUES(
 		<if test="userId != null and userId != ''">#{userId},</if>
@@ -298,6 +299,7 @@
 		<if test="contractCompanyId != null and contractCompanyId != ''">#{contractCompanyId},</if>
 		<if test="usageCompanyId != null and usageCompanyId != 0">#{usageCompanyId},</if>
 		<if test="usageCompanyName != null and usageCompanyName != ''">#{usageCompanyName},</if>
+		<if test="jdId != null">#{jdId},</if>
 		sysdate()
 		)
 	</insert>
@@ -322,6 +324,7 @@
 			<if test="contractCompanyId != null and contractCompanyId != ''">contract_company_id = #{contractCompanyId},</if>
 			<if test="usageCompanyId != null and usageCompanyId != 0">usage_company_id = #{usageCompanyId},</if>
 			<if test="usageCompanyName != null and usageCompanyName != ''">usage_company_name = #{usageCompanyName},</if>
+			<if test="jdId != null">jd_id = #{jdId},</if>
 			update_time = sysdate()
 		</set>
 		WHERE user_id = #{userId}