diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java index c2ab343c..8a8ba885 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java @@ -21,7 +21,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; * @date 9:13 2024/9/13 **/ @RestController -@RequestMapping("/repair/so/page") +@RequestMapping("/repair/so") public class DlRepairSoController { /** * 服务对象 diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 82e8ff88..8fbf762d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -133,7 +133,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl goodsList = repairSoRespVO.getGoodsList(); - List ids = goodsList.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()); - List repairWares = waresService.listByIds(ids); - // 更新库存和进价 - List newWares = repairWares.stream().map(item -> { - // 取数据 - DlRepairSoi repairSoi = goodsList.stream().filter(i -> i.getGoodsId().equals(item.getId())).collect(Collectors.toList()).get(0); - // 设置新值 - // 如果是采购入库,数量+,如果是领料出库,数量- - // 01, 03 是采购 02 是领料 - BigDecimal count = new BigDecimal(repairSoi.getGoodsCount()); - RepairWares wares = new RepairWares(); - wares.setId(item.getId()); - wares.setStock("02".equals(repairSoRespVO.getSoType()) ? item.getStock().subtract(count) : item.getStock().add(count)); - // 更新进价 - wares.setPurPrice(repairSoi.getGoodsPrice()); - return wares; - }).collect(Collectors.toList()); - waresService.updateBatchById(newWares); // 获取所有需要操作的数据----生成采购单的时候,不直接操作库存,放到下面的inWares方法去操作 if (repairSoRespVO.getSoType() != null && !repairSoRespVO.getSoType().equals("01")){ List goodsList = repairSoRespVO.getGoodsList(); @@ -186,7 +166,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, reqVO.getId())); + // 过滤出入库数量等于采购数量的数据 + List allInSois = sois.stream().filter(item -> item.getInCount().equals(item.getGoodsCount())).collect(Collectors.toList()); + // 如果allInSois的size就是sois的size,那就是全部都入库了 + if (CollectionUtil.isNotEmpty(allInSois) && allInSois.size() == sois.size()) { + // 更新采购单的状态为已入库 + baseMapper.update(new LambdaUpdateWrapper() + .set(DlRepairSo::getSoStatus, "03") + .eq(DlRepairSo::getId, reqVO.getId()) + ); + } } }