Преглед на файлове

工艺适用产品添加新接口

yzc преди 1 година
родител
ревизия
0339927191

+ 8 - 0
hx-mes/src/main/java/com/fjhx/mes/controller/technology/TechnologyController.java

@@ -61,6 +61,14 @@ public class TechnologyController {
     }
 
     /**
+     * 工艺适用产品修改
+     */
+    @PostMapping("/editProduct")
+    public void editProduct(@RequestBody TechnologyDto technologyDto) {
+        technologyService.editProduct(technologyDto);
+    }
+
+    /**
      * 工艺删除
      */
     @PostMapping("/delete")

+ 2 - 0
hx-mes/src/main/java/com/fjhx/mes/service/technology/TechnologyService.java

@@ -38,6 +38,8 @@ public interface TechnologyService extends BaseService<Technology> {
      */
     void edit(TechnologyDto technologyDto);
 
+    void editProduct(TechnologyDto dto);
+
     /**
      * 工艺删除
      */

+ 15 - 6
hx-mes/src/main/java/com/fjhx/mes/service/technology/impl/TechnologyServiceImpl.java

@@ -186,12 +186,9 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
 //        String join = String.join(",", technologyDto.getProcessRouteList());
 //        technologyDto.setProcessRoute(join);
         this.updateById(technologyDto);
-        List<ApplicableProducts> productList = technologyDto.getProductList();
-        applicableProductsService.remove(q -> q.eq(ApplicableProducts::getTechnologyId, technologyDto.getId()));
-        for (ApplicableProducts applicableProducts : productList) {
-            applicableProducts.setTechnologyId(technologyDto.getId());
-        }
-        applicableProductsService.saveBatch(productList);
+
+        //修改适用产品
+        editProduct(technologyDto);
 
         //修改工艺线路列表,只能全删了再创建
         String processRoute;
@@ -215,6 +212,18 @@ public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technol
     }
 
     /**
+     * 修改工艺适用产品
+     */
+    @Override
+    public void editProduct(TechnologyDto dto){
+        Long technologyId = dto.getId();
+        Assert.notEmpty(technologyId,"工艺id不能为空");
+        List<ApplicableProducts> productList = dto.getProductList();
+        productList.forEach(item->item.setTechnologyId(technologyId));
+        applicableProductsService.editLinked(productList,ApplicableProducts::getTechnologyId, technologyId);
+    }
+
+    /**
      * 遍历工艺线路
      *
      * @return