Min 11 kuukautta sitten
vanhempi
commit
75c4de81b4

+ 31 - 10
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/ProductServiceImpl.java

@@ -150,6 +150,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                 p.setProductId(product.getId());
                 p.setProductName(product.getName());
                 p.setProjectCode(product.getCode());
+                p.setProjectName(product.getProjectName());
             });
             if(planList.size()>0){
                 planService.updateBatchById(planList);
@@ -229,6 +230,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
         HttpRespMsg msg=new HttpRespMsg();
         List<Product> productList=new ArrayList<>();
         List<ProdProcedure> prodProcedureList=new ArrayList<>();
+        List<Plan> needUpdatePlanList=new ArrayList<>();
 
 
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
@@ -274,12 +276,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                 //产品基本信息
                 XSSFCell nameCell = row.getCell(0);
                 XSSFCell codeCell = row.getCell(1);
-                XSSFCell orderNumberCell = row.getCell(2);
-                XSSFCell unitCell = row.getCell(3);
-                XSSFCell groupNumberCell = row.getCell(4);
-                XSSFCell columnNumberCell = row.getCell(5);
-                XSSFCell vehicleNumberCell = row.getCell(6);
-                XSSFCell descriptionCell = row.getCell(7);
+                XSSFCell projectNameCell = row.getCell(2);
+                XSSFCell orderNumberCell = row.getCell(3);
+                XSSFCell unitCell = row.getCell(4);
+                XSSFCell groupNumberCell = row.getCell(5);
+                XSSFCell columnNumberCell = row.getCell(6);
+                XSSFCell vehicleNumberCell = row.getCell(7);
+                XSSFCell descriptionCell = row.getCell(8);
 
                 if(nameCell!=null){
                     nameCell.setCellType(CellType.STRING);
@@ -287,6 +290,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                 if(codeCell!=null){
                     codeCell.setCellType(CellType.STRING);
                 }
+                if(projectNameCell!=null){
+                    projectNameCell.setCellType(CellType.STRING);
+                }
                 if(orderNumberCell!=null){
                     orderNumberCell.setCellType(CellType.NUMERIC);
                 }
@@ -314,14 +320,20 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                     if(StringUtils.isEmpty(nameCell.getStringCellValue())){
                         continue;
                     }
+                    if(projectNameCell==null){
+                        msg.setError("项目名称不能为空");
+                        return msg;
+                    }
                     Product selectOne = productMapper.selectOne(new LambdaQueryWrapper<Product>()
                             .eq(companyId != null, Product::getCompanyId, companyId)
                             .eq(!StringUtils.isEmpty(nameCell.getStringCellValue()), Product::getName, nameCell.getStringCellValue())
+                            .eq(Product::getProjectName,projectNameCell.getStringCellValue())
                     );
                     if(selectOne!=null){
-                        product.setName(nameCell.getStringCellValue());
                         product.setId(selectOne.getId());
                     }
+                    product.setName(nameCell.getStringCellValue());
+                    product.setProjectName(projectNameCell.getStringCellValue());
 //                    else{
 //                        msg.setError("产品名和已存在的产品重复");
 //                        return msg;
@@ -456,7 +468,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                     msg.setError("质检类型不能为空");
                     return msg;
                 }
-
+                prodProcedure.setSeq(indexNum);
                 prodProcedureList.add(prodProcedure);
             }
 
@@ -478,13 +490,20 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                     return msg;
                 }
             }
-
             //插入数据
             if(saveOrUpdateBatch(productList)) {
                 List<Integer> productIds = productList.stream().map(Product::getId).distinct().collect(Collectors.toList());
                 List<ProdProcedure> prodProcedures = prodProcedureMapper.selectList(new LambdaQueryWrapper<ProdProcedure>().in(ProdProcedure::getProductId, productIds));
+                List<Plan> planList = planService.list(new LambdaQueryWrapper<Plan>().select(Plan::getId).in(Plan::getProductId, productIds));
                 for (Product product : productList) {
                     List<ProdProcedure> procedureList = prodProcedures.stream().filter(p -> p.getProductId().equals(product.getId())).collect(Collectors.toList());
+                    List<Plan> plans = planList.stream().filter(p -> p.getProductId().equals(product.getId())).collect(Collectors.toList());
+                    plans.forEach(p->{
+                        p.setProjectName(product.getProjectName());
+                        p.setProjectCode(product.getCode());
+                        p.setProductName(product.getName());
+                    });
+                    needUpdatePlanList.addAll(plans);
                     //找到当前产品下的工序版本号集合
                     List<String> versionNumberList = procedureList.stream().map(ProdProcedure::getVersionNumber).distinct().collect(Collectors.toList());
                     List<ProdProcedure> procedures = prodProcedureList.stream()
@@ -499,7 +518,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                 }
             }
             prodProcedureService.saveBatch(prodProcedureList);
-
+            planService.updateBatchById(needUpdatePlanList);
         } catch (IOException e) {
             e.printStackTrace();
         } catch (NullPointerException e) {
@@ -703,6 +722,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
             List<String> titleProductList = new ArrayList<>();
             titleProductList.add("产品名称");
             titleProductList.add("项目代码");
+            titleProductList.add("项目名称");
             titleProductList.add("订单数量");
             titleProductList.add("单位");
             titleProductList.add("编组");
@@ -715,6 +735,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
                 List<String> item=new ArrayList<>();
                 item.add(product.getName());
                 item.add(product.getCode());
+                item.add(product.getProjectName());
                 item.add(product.getOrderNumber().toString());
                 item.add(product.getUnit());
                 item.add(product.getGroupNumber());