Browse Source

改动过的

huanglizhi 1 year ago
parent
commit
9c84780109

+ 13 - 15
module-erp/src/main/java/com/hys/app/controller/erp/use/StockInventoryManagerController.java

@@ -46,6 +46,13 @@ public class StockInventoryManagerController {
     public void add(@RequestBody @Valid StockInventoryDTO stockInventoryDTO) {
     public void add(@RequestBody @Valid StockInventoryDTO stockInventoryDTO) {
         this.stockInventoryManager.add(stockInventoryDTO);
         this.stockInventoryManager.add(stockInventoryDTO);
     }
     }
+
+    @ApiOperation(value = "修改库存盘点单")
+    @PostMapping("/{id}")
+    @Log(client = LogClient.admin, detail = "修改id为[${id}]的库存盘点单")
+    public void edit(@PathVariable Long id, @RequestBody @Valid StockInventoryDTO stockInventoryDTO) {
+        this.stockInventoryManager.edit(id, stockInventoryDTO);
+    }
     @ApiOperation(value = "查询库存盘点单详细信息")
     @ApiOperation(value = "查询库存盘点单详细信息")
     @GetMapping("/{id}")
     @GetMapping("/{id}")
     public StockInventoryVO getDetail(@PathVariable Long id) {
     public StockInventoryVO getDetail(@PathVariable Long id) {
@@ -55,29 +62,20 @@ public class StockInventoryManagerController {
     @ApiOperation(value = "同步库存")
     @ApiOperation(value = "同步库存")
     @GetMapping("/syncStock/{id}")
     @GetMapping("/syncStock/{id}")
     public void syncStock(@PathVariable Long id) {
     public void syncStock(@PathVariable Long id) {
-         stockInventoryManager.syncStock(id);
+        stockInventoryManager.syncStock(id);
     }
     }
 
 
-    @ApiOperation(value = "修改库存盘点单")
-    @PostMapping("/{id}")
-    @Log(client = LogClient.admin, detail = "修改id为[${id}]的库存盘点单")
-    public void edit(@PathVariable Long id, @RequestBody @Valid StockInventoryDTO stockInventoryDTO) {
-        this.stockInventoryManager.edit(id, stockInventoryDTO);
-    }
+
+
 
 
     @ApiOperation(value = "批量删除库存盘点单")
     @ApiOperation(value = "批量删除库存盘点单")
-    @DeleteMapping("/{ids}")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "要删除的库存盘点单ID集合", required = true, dataType = "int", paramType = "path", allowMultiple = true)
-    })
+    @DeleteMapping("/{id}")
     @Log(client = LogClient.admin, detail = "删除ID为[${ids}]的库存盘点单")
     @Log(client = LogClient.admin, detail = "删除ID为[${ids}]的库存盘点单")
-    public void delete(@PathVariable List<Long> ids) {
-        this.stockInventoryManager.delete(ids);
+    public void delete(@PathVariable Long id) {
+        this.stockInventoryManager.delete(id);
     }
     }
 
 
 
 
-
-
     @ApiOperation(value = "批量提交审核库存盘点单")
     @ApiOperation(value = "批量提交审核库存盘点单")
     @PostMapping("/submit/{ids}")
     @PostMapping("/submit/{ids}")
     @ApiImplicitParams({
     @ApiImplicitParams({

+ 1 - 1
module-erp/src/main/java/com/hys/app/service/erp/StockInventoryManager.java

@@ -46,7 +46,7 @@ public interface StockInventoryManager   extends BaseService<StockInventory> {
      *
      *
      * @param ids 库存盘点单主键ID集合
      * @param ids 库存盘点单主键ID集合
      */
      */
-    void delete(List<Long> ids);
+    void delete(Long id);
 
 
     /**
     /**
      * 获取库存盘点单详情
      * 获取库存盘点单详情

+ 40 - 43
module-erp/src/main/java/com/hys/app/service/erp/impl/StockInventoryManagerImpl.java

@@ -98,13 +98,41 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
 
 
     }
     }
 
 
+    /**
+     * 编辑库存盘点单
+     *
+     * @param id                主键ID
+     * @param stockInventoryDTO 库存盘点单信息
+     */
+    @Override
+    @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void edit(Long id, StockInventoryDTO stockInventoryDTO) {
+        //获取库存盘点单旧数据
+        StockInventory stockInventory = this.getById(id);
+        if (DamageinventoryEnum.HAS_HANDLE.equals(stockInventory.getStatus())) {
+            throw new ServiceException("该盘点单已同步数据,不允许操作");
+        }
+        stockInventoryProductManager.remove(new LambdaQueryWrapper<StockInventoryProduct>().eq(StockInventoryProduct::getInventoryId, id));
+        List<StockInventoryProduct> list = BeanUtils.toBean(stockInventoryDTO.getProductList(), StockInventoryProduct.class);
+        list.forEach(item -> item.setInventoryId(id));
+        this.stockInventoryProductManager.saveBatch(list);
+        //如果这个商品有序列号补习不全序列号关系
+        for (StockInventoryProductDTO dto : stockInventoryDTO.getProductList()) {
+            StockInventoryProduct product = list.stream().filter(item -> item.getProductId().equals(dto.getProductId())).findFirst().get();
+            dto.setId(product.getId());
+        }
+        itemSnCodeManager.remove(new LambdaQueryWrapper<ItemSnCodeDO>().eq(ItemSnCodeDO::getEntryOutHouseId, id));
+        saveSnCode(id, stockInventoryDTO.getProductList());
+    }
+
+
     private void saveSnCode(Long stockInventoryId, List<StockInventoryProductDTO> productList) {
     private void saveSnCode(Long stockInventoryId, List<StockInventoryProductDTO> productList) {
         List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
         List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
         //如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
         //如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
         List<String> arrayList = new ArrayList<>();
         List<String> arrayList = new ArrayList<>();
         for (StockInventoryProductDTO aDo : productList) {
         for (StockInventoryProductDTO aDo : productList) {
             ProductDO byId = productManager.getById(aDo.getProductId());
             ProductDO byId = productManager.getById(aDo.getProductId());
-            if (byId.getHaveSn() && CollUtil.isEmpty(aDo.getSnCodeList())){
+            if (byId.getHaveSn() && CollUtil.isEmpty(aDo.getSnCodeList())) {
                 throw new ServiceException("有序列号的商品序列号不能为空");
                 throw new ServiceException("有序列号的商品序列号不能为空");
             }
             }
             if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
             if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
@@ -122,7 +150,7 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
                 });
                 });
             }
             }
         }
         }
-        if(CollUtil.isNotEmpty(arrayList)){
+        if (CollUtil.isNotEmpty(arrayList)) {
             long count = goodsSnManager.count(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getSnCode, arrayList));
             long count = goodsSnManager.count(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getSnCode, arrayList));
             if (count != arrayList.size()) {
             if (count != arrayList.size()) {
                 throw new ServiceException("部分序列号不存在");
                 throw new ServiceException("部分序列号不存在");
@@ -166,7 +194,7 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
         //找到这个订单关联的所有序列号
         //找到这个订单关联的所有序列号
         List<ItemSnCodeDO> listed = itemSnCodeManager.list(new LambdaQueryWrapper<ItemSnCodeDO>()
         List<ItemSnCodeDO> listed = itemSnCodeManager.list(new LambdaQueryWrapper<ItemSnCodeDO>()
                 .eq(ItemSnCodeDO::getType, "inventory").eq(ItemSnCodeDO::getEntryOutHouseId, id));
                 .eq(ItemSnCodeDO::getType, "inventory").eq(ItemSnCodeDO::getEntryOutHouseId, id));
-        if (CollUtil.isNotEmpty(listed)){
+        if (CollUtil.isNotEmpty(listed)) {
             List<GoodsSnDO> goodsSnDOS = goodsSnManager.list(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getId, listed.stream().map(ItemSnCodeDO::getSnCodeId).collect(Collectors.toList())));
             List<GoodsSnDO> goodsSnDOS = goodsSnManager.list(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getId, listed.stream().map(ItemSnCodeDO::getSnCodeId).collect(Collectors.toList())));
             //更爱序列号状态
             //更爱序列号状态
             for (GoodsSnDO aDo : goodsSnDOS) {
             for (GoodsSnDO aDo : goodsSnDOS) {
@@ -215,56 +243,25 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
     }
     }
 
 
 
 
-    /**
-     * 编辑库存盘点单
-     *
-     * @param id                主键ID
-     * @param stockInventoryDTO 库存盘点单信息
-     */
-    @Override
-    @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void edit(Long id, StockInventoryDTO stockInventoryDTO) {
-        //获取库存盘点单旧数据
-        StockInventory stockInventory = this.getById(id);
-        if (!StockInventoryStatusEnum.NEW.name().equals(stockInventory.getStatus())
-                && !StockInventoryStatusEnum.REJECT.name().equals(stockInventory.getStatus())) {
-            throw new ServiceException("只有状态为未提交或审核驳回的库存盘点单才可以进行编辑操作");
-        }
-        //复制修改后的数据
-        //修改库存盘点单信息
-        this.updateById(stockInventory);
-        //入库库存报损单商品
-        this.stockInventoryProductManager.saveProduct(id, stockInventoryDTO.getProductList());
-    }
-
     /**
     /**
      * 删除库存盘点单
      * 删除库存盘点单
      *
      *
-     * @param ids 库存盘点单主键ID集合
+     * @param id 库存盘点单主键ID集合
      */
      */
     @Override
     @Override
     @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void delete(List<Long> ids) {
-        List<StockInventory> inventories = this.lambdaQuery()
-                .in(StockInventory::getId, ids)
-                .list();
-        if (inventories == null || inventories.size() == 0) {
-            throw new ServiceException("要删除的库存盘点单不存在");
+    public void delete(Long id) {
+        StockInventory inventory = getById(id);
+        if (DamageinventoryEnum.HAS_HANDLE.equals(inventory.getStatus())) {
+            throw new ServiceException("该盘点单已同步数据,不允许操作");
         }
         }
-        //验证库存盘点单状态是否可以删除
-        for (StockInventory inventory : inventories) {
-            if (!StockInventoryStatusEnum.NEW.name().equals(inventory.getStatus())
-                    && !StockInventoryStatusEnum.REJECT.name().equals(inventory.getStatus())) {
-                throw new ServiceException("只有状态为未提交或审核驳回的库存盘点单才可进行删除操作");
-            }
-        }
-        //批量删除库存盘点单
-        this.removeByIds(ids);
-        //删除库存盘点单商品信息
-        this.stockInventoryProductManager.deleteProduct(ids);
+        removeById(id);
+        stockInventoryProductManager.remove(new LambdaQueryWrapper<StockInventoryProduct>().eq(StockInventoryProduct::getInventoryId, id));
+        itemSnCodeManager.remove(new LambdaQueryWrapper<ItemSnCodeDO>().eq(ItemSnCodeDO::getEntryOutHouseId, id));
     }
     }
 
 
 
 
+
     /**
     /**
      * 库存盘点单提交审核
      * 库存盘点单提交审核
      *
      *