Commit aea84c5981ff3eae3511d4fc3d074850895af54f
1 parent
46933d85
✨ feat(mes): 更新盘点方案参数类型枚举及相关逻辑
Showing
9 changed files
with
206 additions
and
128 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/MesWmStockTakingTaskController.java
| ... | ... | @@ -122,9 +122,10 @@ public class MesWmStockTakingTaskController { |
| 122 | 122 | |
| 123 | 123 | @PutMapping("/cancel") |
| 124 | 124 | @Operation(summary = "取消盘点任务") |
| 125 | + @Parameter(name = "id", description = "编号", required = true) | |
| 125 | 126 | @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:update')") |
| 126 | - public CommonResult<Boolean> cancelStockTakingTask(@Valid @RequestBody MesWmStockTakingTaskCancelReqVO reqVO) { | |
| 127 | - stockTakingTaskService.cancelStockTakingTask(reqVO.getId()); | |
| 127 | + public CommonResult<Boolean> cancelStockTakingTask(@RequestParam("id") Long id) { | |
| 128 | + stockTakingTaskService.cancelStockTakingTask(id); | |
| 128 | 129 | return success(true); |
| 129 | 130 | } |
| 130 | 131 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/MesWmStockTakingTaskLineController.java
| ... | ... | @@ -55,13 +55,25 @@ public class MesWmStockTakingTaskLineController { |
| 55 | 55 | @Resource |
| 56 | 56 | private MesWmWarehouseAreaService areaService; |
| 57 | 57 | |
| 58 | + @GetMapping("/get") | |
| 59 | + @Operation(summary = "获得盘点任务行") | |
| 60 | + @Parameter(name = "id", description = "编号", required = true) | |
| 61 | + @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") | |
| 62 | + public CommonResult<MesWmStockTakingTaskLineRespVO> getStockTakingTaskLine(@RequestParam("id") Long id) { | |
| 63 | + MesWmStockTakingTaskLineDO line = stockTakingTaskLineService.getStockTakingTaskLine(id); | |
| 64 | + if (line == null) { | |
| 65 | + return success(null); | |
| 66 | + } | |
| 67 | + return success(buildStockTakingTaskLineRespVOList(Collections.singletonList(line)).get(0)); | |
| 68 | + } | |
| 69 | + | |
| 58 | 70 | @GetMapping("/page") |
| 59 | 71 | @Operation(summary = "获得盘点任务行分页") |
| 60 | 72 | @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") |
| 61 | 73 | public CommonResult<PageResult<MesWmStockTakingTaskLineRespVO>> getStockTakingTaskLinePage( |
| 62 | 74 | @Valid MesWmStockTakingTaskLinePageReqVO pageReqVO) { |
| 63 | 75 | PageResult<MesWmStockTakingTaskLineDO> pageResult = stockTakingTaskLineService.getStockTakingTaskLinePage(pageReqVO); |
| 64 | - return success(new PageResult<>(buildTaskLineRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 76 | + return success(new PageResult<>(buildStockTakingTaskLineRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 65 | 77 | } |
| 66 | 78 | |
| 67 | 79 | @PostMapping("/create") |
| ... | ... | @@ -90,7 +102,7 @@ public class MesWmStockTakingTaskLineController { |
| 90 | 102 | |
| 91 | 103 | // ==================== 拼接 VO ==================== |
| 92 | 104 | |
| 93 | - private List<MesWmStockTakingTaskLineRespVO> buildTaskLineRespVOList(List<MesWmStockTakingTaskLineDO> list) { | |
| 105 | + private List<MesWmStockTakingTaskLineRespVO> buildStockTakingTaskLineRespVOList(List<MesWmStockTakingTaskLineDO> list) { | |
| 94 | 106 | if (CollUtil.isEmpty(list)) { |
| 95 | 107 | return Collections.emptyList(); |
| 96 | 108 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/MesWmStockTakingTaskResultController.java
| ... | ... | @@ -72,7 +72,7 @@ public class MesWmStockTakingTaskResultController { |
| 72 | 72 | if (result == null) { |
| 73 | 73 | return success(null); |
| 74 | 74 | } |
| 75 | - return success(buildRespVOList(Collections.singletonList(result)).get(0)); | |
| 75 | + return success(buildStockTakingTaskResultRespVOList(Collections.singletonList(result)).get(0)); | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | @GetMapping("/page") |
| ... | ... | @@ -80,7 +80,7 @@ public class MesWmStockTakingTaskResultController { |
| 80 | 80 | @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") |
| 81 | 81 | public CommonResult<PageResult<MesWmStockTakingTaskResultRespVO>> getStockTakingTaskResultPage(@Valid MesWmStockTakingTaskResultPageReqVO pageReqVO) { |
| 82 | 82 | PageResult<MesWmStockTakingTaskResultDO> pageResult = stockTakingTaskResultService.getStockTakingTaskResultPage(pageReqVO); |
| 83 | - return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 83 | + return success(new PageResult<>(buildStockTakingTaskResultRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | @GetMapping("/list") |
| ... | ... | @@ -88,7 +88,7 @@ public class MesWmStockTakingTaskResultController { |
| 88 | 88 | @Parameter(name = "taskId", description = "任务编号", required = true) |
| 89 | 89 | @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") |
| 90 | 90 | public CommonResult<List<MesWmStockTakingTaskResultRespVO>> getStockTakingTaskResultList(@RequestParam("taskId") Long taskId) { |
| 91 | - return success(buildRespVOList(stockTakingTaskResultService.getStockTakingTaskResultList(taskId))); | |
| 91 | + return success(buildStockTakingTaskResultRespVOList(stockTakingTaskResultService.getStockTakingTaskResultList(taskId))); | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | @GetMapping("/export-excel") |
| ... | ... | @@ -100,10 +100,10 @@ public class MesWmStockTakingTaskResultController { |
| 100 | 100 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 101 | 101 | PageResult<MesWmStockTakingTaskResultDO> pageResult = stockTakingTaskResultService.getStockTakingTaskResultPage(pageReqVO); |
| 102 | 102 | ExcelUtils.write(response, "盘点结果.xls", "数据", MesWmStockTakingTaskResultRespVO.class, |
| 103 | - buildRespVOList(pageResult.getList())); | |
| 103 | + buildStockTakingTaskResultRespVOList(pageResult.getList())); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - private List<MesWmStockTakingTaskResultRespVO> buildRespVOList(List<MesWmStockTakingTaskResultDO> list) { | |
| 106 | + private List<MesWmStockTakingTaskResultRespVO> buildStockTakingTaskResultRespVOList(List<MesWmStockTakingTaskResultDO> list) { | |
| 107 | 107 | if (CollUtil.isEmpty(list)) { |
| 108 | 108 | return Collections.emptyList(); |
| 109 | 109 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineService.java
| ... | ... | @@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.line. |
| 6 | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskDO; |
| 7 | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskLineDO; |
| 8 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 9 | 11 | /** |
| 10 | 12 | * MES 盘点任务行 Service 接口 |
| 11 | 13 | * |
| ... | ... | @@ -17,8 +19,9 @@ public interface MesWmStockTakingTaskLineService { |
| 17 | 19 | * 根据盘点方案生成盘点明细行 |
| 18 | 20 | * |
| 19 | 21 | * @param task 盘点任务 |
| 22 | + * @param isCreate 是否为创建操作(true-创建,false-更新时需先清理旧数据) | |
| 20 | 23 | */ |
| 21 | - void generateStockTakingLines(MesWmStockTakingTaskDO task); | |
| 24 | + void generateStockTakingLines(MesWmStockTakingTaskDO task, boolean isCreate); | |
| 22 | 25 | |
| 23 | 26 | /** |
| 24 | 27 | * 分页查询盘点任务行 |
| ... | ... | @@ -29,6 +32,14 @@ public interface MesWmStockTakingTaskLineService { |
| 29 | 32 | PageResult<MesWmStockTakingTaskLineDO> getStockTakingTaskLinePage(MesWmStockTakingTaskLinePageReqVO pageReqVO); |
| 30 | 33 | |
| 31 | 34 | /** |
| 35 | + * 获得盘点任务行 | |
| 36 | + * | |
| 37 | + * @param id 编号 | |
| 38 | + * @return 盘点任务行 | |
| 39 | + */ | |
| 40 | + MesWmStockTakingTaskLineDO getStockTakingTaskLine(Long id); | |
| 41 | + | |
| 42 | + /** | |
| 32 | 43 | * 创建盘点任务行 |
| 33 | 44 | * |
| 34 | 45 | * @param createReqVO 创建信息 |
| ... | ... | @@ -50,4 +61,19 @@ public interface MesWmStockTakingTaskLineService { |
| 50 | 61 | */ |
| 51 | 62 | void deleteStockTakingTaskLine(Long id); |
| 52 | 63 | |
| 64 | + /** | |
| 65 | + * 根据任务编号获取盘点任务行列表 | |
| 66 | + * | |
| 67 | + * @param taskId 任务编号 | |
| 68 | + * @return 盘点任务行列表 | |
| 69 | + */ | |
| 70 | + List<MesWmStockTakingTaskLineDO> getStockTakingTaskLineListByTaskId(Long taskId); | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 根据任务编号删除盘点任务行 | |
| 74 | + * | |
| 75 | + * @param taskId 任务编号 | |
| 76 | + */ | |
| 77 | + void deleteStockTakingTaskLineByTaskId(Long taskId); | |
| 78 | + | |
| 53 | 79 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.mes.service.wm.stocktaking.task; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | -import cn.hutool.core.util.ObjUtil; | |
| 6 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 7 | import cn.iocoder.yudao.module.mes.controller.admin.wm.materialstock.vo.MesWmMaterialStockListReqVO; |
| ... | ... | @@ -14,10 +13,8 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStock |
| 14 | 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskLineDO; |
| 15 | 14 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.plan.MesWmStockTakingPlanParamMapper; |
| 16 | 15 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskLineMapper; |
| 17 | -import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskMapper; | |
| 18 | 16 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingPlanParamTypeEnum; |
| 19 | 17 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTaskLineStatusEnum; |
| 20 | -import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTaskStatusEnum; | |
| 21 | 18 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTypeEnum; |
| 22 | 19 | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| 23 | 20 | import jakarta.annotation.Resource; |
| ... | ... | @@ -31,7 +28,8 @@ import java.util.Objects; |
| 31 | 28 | |
| 32 | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 33 | 30 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 34 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 31 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS; | |
| 32 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_NO_STOCK; | |
| 35 | 33 | |
| 36 | 34 | /** |
| 37 | 35 | * MES 盘点任务行 Service 实现类 |
| ... | ... | @@ -48,29 +46,31 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 48 | 46 | private MesWmStockTakingPlanParamMapper stockTakingPlanParamMapper; |
| 49 | 47 | @Resource |
| 50 | 48 | private MesWmMaterialStockService materialStockService; |
| 51 | - | |
| 52 | 49 | @Resource |
| 53 | - private MesWmStockTakingTaskMapper stockTakingTaskMapper; | |
| 50 | + private MesWmStockTakingTaskService stockTakingTaskService; | |
| 54 | 51 | |
| 55 | 52 | @Override |
| 56 | 53 | @Transactional(rollbackFor = Exception.class) |
| 57 | - public void generateStockTakingLines(MesWmStockTakingTaskDO task) { | |
| 58 | - // 1.1 构建查询条件(包含动态盘点时间校验) | |
| 54 | + public void generateStockTakingLines(MesWmStockTakingTaskDO task, boolean isCreate) { | |
| 55 | + // 1. 如果非创建操作,先清理旧数据 | |
| 56 | + if (!isCreate) { | |
| 57 | + stockTakingTaskLineMapper.deleteByTaskId(task.getId()); | |
| 58 | + } | |
| 59 | + | |
| 60 | + // 2.1 构建查询条件(包含动态盘点时间校验) | |
| 59 | 61 | MesWmMaterialStockListReqVO reqVO = buildStockQueryReqVO(task); |
| 60 | - // 1.2 查询物料库存 | |
| 62 | + // 2.2 查询物料库存 | |
| 61 | 63 | List<MesWmMaterialStockDO> stocks = materialStockService.getMaterialStockList(reqVO); |
| 62 | 64 | if (CollUtil.isEmpty(stocks)) { |
| 63 | 65 | throw exception(WM_STOCK_TAKING_TASK_NO_STOCK); |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | - // 2. 批量生成明细行 | |
| 67 | - // TODO DONE @AI:使用 CollectionUtils convertList 方法简化代码 | |
| 68 | - List<MesWmStockTakingTaskLineDO> lines = convertList(stocks, stock -> | |
| 69 | - MesWmStockTakingTaskLineDO.builder() | |
| 70 | - .taskId(task.getId()).materialStockId(stock.getId()).itemId(stock.getItemId()) | |
| 71 | - .batchId(stock.getBatchId()).quantity(defaultQuantity(stock.getQuantityOnhand())) | |
| 72 | - .warehouseId(stock.getWarehouseId()).locationId(stock.getLocationId()).areaId(stock.getAreaId()) | |
| 73 | - .status(MesWmStockTakingTaskLineStatusEnum.LOSS.getStatus()).build()); | |
| 68 | + // 3. 批量生成明细行 | |
| 69 | + List<MesWmStockTakingTaskLineDO> lines = convertList(stocks, stock -> MesWmStockTakingTaskLineDO.builder() | |
| 70 | + .taskId(task.getId()).materialStockId(stock.getId()).itemId(stock.getItemId()) | |
| 71 | + .batchId(stock.getBatchId()).quantity(stock.getQuantityOnhand()).takingQuantity(BigDecimal.ZERO) | |
| 72 | + .warehouseId(stock.getWarehouseId()).locationId(stock.getLocationId()).areaId(stock.getAreaId()) | |
| 73 | + .status(MesWmStockTakingTaskLineStatusEnum.LOSS.getStatus()).build()); | |
| 74 | 74 | stockTakingTaskLineMapper.insertBatch(lines); |
| 75 | 75 | } |
| 76 | 76 | |
| ... | ... | @@ -80,10 +80,15 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | @Override |
| 83 | + public MesWmStockTakingTaskLineDO getStockTakingTaskLine(Long id) { | |
| 84 | + return stockTakingTaskLineMapper.selectById(id); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 83 | 88 | @Transactional(rollbackFor = Exception.class) |
| 84 | 89 | public Long createStockTakingTaskLine(MesWmStockTakingTaskLineSaveReqVO createReqVO) { |
| 85 | 90 | // 1. 校验盘点任务存在,并且处于【准备中】状态 |
| 86 | - validateTaskExistsAndPrepare(createReqVO.getTaskId()); | |
| 91 | + stockTakingTaskService.validateStockTakingTaskExistsAndPrepare(createReqVO.getTaskId()); | |
| 87 | 92 | |
| 88 | 93 | // 2. 创建盘点任务行 |
| 89 | 94 | MesWmStockTakingTaskLineDO line = BeanUtils.toBean(createReqVO, MesWmStockTakingTaskLineDO.class); |
| ... | ... | @@ -94,15 +99,12 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 94 | 99 | @Override |
| 95 | 100 | @Transactional(rollbackFor = Exception.class) |
| 96 | 101 | public void updateStockTakingTaskLine(MesWmStockTakingTaskLineSaveReqVO updateReqVO) { |
| 97 | - // TODO @AI:补全注释 | |
| 98 | - // TODO @AI:搞个 validate exists 方法,这样 update 和 delete 可以服用; | |
| 99 | - MesWmStockTakingTaskLineDO line = stockTakingTaskLineMapper.selectById(updateReqVO.getId()); | |
| 100 | - if (line == null) { | |
| 101 | - throw exception(WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS); | |
| 102 | - } | |
| 103 | - validateTaskExistsAndPrepare(updateReqVO.getTaskId()); | |
| 102 | + // 1.1 校验盘点任务行存在 | |
| 103 | + MesWmStockTakingTaskLineDO line = validateStockTakingTaskLineExists(updateReqVO.getId()); | |
| 104 | + // 1.2 校验盘点任务存在,并且处于【准备中】状态 | |
| 105 | + stockTakingTaskService.validateStockTakingTaskExistsAndPrepare(updateReqVO.getTaskId()); | |
| 104 | 106 | |
| 105 | - // 更新 | |
| 107 | + // 2. 更新盘点任务行 | |
| 106 | 108 | MesWmStockTakingTaskLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmStockTakingTaskLineDO.class); |
| 107 | 109 | stockTakingTaskLineMapper.updateById(updateObj); |
| 108 | 110 | } |
| ... | ... | @@ -110,27 +112,27 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 110 | 112 | @Override |
| 111 | 113 | @Transactional(rollbackFor = Exception.class) |
| 112 | 114 | public void deleteStockTakingTaskLine(Long id) { |
| 113 | - // TODO @AI:补全注释 | |
| 114 | - MesWmStockTakingTaskLineDO line = stockTakingTaskLineMapper.selectById(id); | |
| 115 | - if (line == null) { | |
| 116 | - throw exception(WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS); | |
| 117 | - } | |
| 118 | - validateTaskExistsAndPrepare(line.getTaskId()); | |
| 115 | + // 1.1 校验盘点任务行存在 | |
| 116 | + MesWmStockTakingTaskLineDO line = validateStockTakingTaskLineExists(id); | |
| 117 | + // 1.2 校验盘点任务存在,并且处于【准备中】状态 | |
| 118 | + stockTakingTaskService.validateStockTakingTaskExistsAndPrepare(line.getTaskId()); | |
| 119 | 119 | |
| 120 | - // 2. 删除 | |
| 120 | + // 2. 删除盘点任务行 | |
| 121 | 121 | stockTakingTaskLineMapper.deleteById(id); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - // TODO @AI:应该在对方的 service 里提供; | |
| 125 | - private MesWmStockTakingTaskDO validateTaskExistsAndPrepare(Long id) { | |
| 126 | - MesWmStockTakingTaskDO task = stockTakingTaskMapper.selectById(id); | |
| 127 | - if (task == null) { | |
| 128 | - throw exception(WM_STOCK_TAKING_TASK_NOT_EXISTS); | |
| 129 | - } | |
| 130 | - if (ObjUtil.notEqual(MesWmStockTakingTaskStatusEnum.PREPARE.getStatus(), task.getStatus())) { | |
| 131 | - throw exception(WM_STOCK_TAKING_TASK_NOT_PREPARE); | |
| 124 | + /** | |
| 125 | + * 校验盘点任务行是否存在 | |
| 126 | + * | |
| 127 | + * @param id 盘点任务行编号 | |
| 128 | + * @return 盘点任务行 | |
| 129 | + */ | |
| 130 | + private MesWmStockTakingTaskLineDO validateStockTakingTaskLineExists(Long id) { | |
| 131 | + MesWmStockTakingTaskLineDO line = stockTakingTaskLineMapper.selectById(id); | |
| 132 | + if (line == null) { | |
| 133 | + throw exception(WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS); | |
| 132 | 134 | } |
| 133 | - return task; | |
| 135 | + return line; | |
| 134 | 136 | } |
| 135 | 137 | |
| 136 | 138 | /** |
| ... | ... | @@ -160,6 +162,16 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 160 | 162 | return reqVO; |
| 161 | 163 | } |
| 162 | 164 | |
| 165 | + @Override | |
| 166 | + public List<MesWmStockTakingTaskLineDO> getStockTakingTaskLineListByTaskId(Long taskId) { | |
| 167 | + return stockTakingTaskLineMapper.selectListByTaskId(taskId); | |
| 168 | + } | |
| 169 | + | |
| 170 | + @Override | |
| 171 | + public void deleteStockTakingTaskLineByTaskId(Long taskId) { | |
| 172 | + stockTakingTaskLineMapper.deleteByTaskId(taskId); | |
| 173 | + } | |
| 174 | + | |
| 163 | 175 | /** |
| 164 | 176 | * 从参数列表中提取第一个匹配类型的参数 ID |
| 165 | 177 | * |
| ... | ... | @@ -173,9 +185,4 @@ public class MesWmStockTakingTaskLineServiceImpl implements MesWmStockTakingTask |
| 173 | 185 | return param != null ? param.getValueId() : null; |
| 174 | 186 | } |
| 175 | 187 | |
| 176 | - // TODO @芋艿:在确认下这个逻辑; | |
| 177 | - private BigDecimal defaultQuantity(BigDecimal quantity) { | |
| 178 | - return quantity == null ? BigDecimal.ZERO : quantity; | |
| 179 | - } | |
| 180 | - | |
| 181 | 188 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultService.java
| ... | ... | @@ -37,4 +37,18 @@ public interface MesWmStockTakingTaskResultService { |
| 37 | 37 | */ |
| 38 | 38 | List<MesWmStockTakingTaskResultDO> getStockTakingTaskResultList(Long taskId); |
| 39 | 39 | |
| 40 | + /** | |
| 41 | + * 创建盘点结果 | |
| 42 | + * | |
| 43 | + * @param result 盘点结果 | |
| 44 | + */ | |
| 45 | + void createStockTakingTaskResult(MesWmStockTakingTaskResultDO result); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 根据任务编号删除盘点结果 | |
| 49 | + * | |
| 50 | + * @param taskId 任务编号 | |
| 51 | + */ | |
| 52 | + void deleteStockTakingTaskResultByTaskId(Long taskId); | |
| 53 | + | |
| 40 | 54 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java
| ... | ... | @@ -38,4 +38,14 @@ public class MesWmStockTakingTaskResultServiceImpl implements MesWmStockTakingTa |
| 38 | 38 | return stockTakingTaskResultMapper.selectListByTaskId(taskId); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | + @Override | |
| 42 | + public void createStockTakingTaskResult(MesWmStockTakingTaskResultDO result) { | |
| 43 | + stockTakingTaskResultMapper.insert(result); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public void deleteStockTakingTaskResultByTaskId(Long taskId) { | |
| 48 | + stockTakingTaskResultMapper.deleteByTaskId(taskId); | |
| 49 | + } | |
| 50 | + | |
| 41 | 51 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskService.java
| ... | ... | @@ -73,6 +73,14 @@ public interface MesWmStockTakingTaskService { |
| 73 | 73 | MesWmStockTakingTaskDO validateStockTakingTaskExists(Long id); |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | + * 校验盘点任务存在,并且处于【准备中】状态 | |
| 77 | + * | |
| 78 | + * @param id 盘点任务编号 | |
| 79 | + * @return 盘点任务 | |
| 80 | + */ | |
| 81 | + MesWmStockTakingTaskDO validateStockTakingTaskExistsAndPrepare(Long id); | |
| 82 | + | |
| 83 | + /** | |
| 76 | 84 | * 分页查询盘点任务 |
| 77 | 85 | * |
| 78 | 86 | * @param pageReqVO 分页查询条件 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskServiceImpl.java
| ... | ... | @@ -10,15 +10,14 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.MesWm |
| 10 | 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskDO; |
| 11 | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskLineDO; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskResultDO; |
| 13 | -import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskLineMapper; | |
| 14 | 13 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskMapper; |
| 15 | -import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskResultMapper; | |
| 16 | 14 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTaskLineStatusEnum; |
| 17 | 15 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmStockTakingTaskStatusEnum; |
| 18 | 16 | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| 19 | 17 | import cn.iocoder.yudao.module.mes.service.wm.stocktaking.plan.MesWmStockTakingPlanService; |
| 20 | 18 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 21 | 19 | import jakarta.annotation.Resource; |
| 20 | +import org.springframework.context.annotation.Lazy; | |
| 22 | 21 | import org.springframework.stereotype.Service; |
| 23 | 22 | import org.springframework.transaction.annotation.Transactional; |
| 24 | 23 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -26,7 +25,6 @@ import org.springframework.validation.annotation.Validated; |
| 26 | 25 | import java.math.BigDecimal; |
| 27 | 26 | import java.time.LocalDateTime; |
| 28 | 27 | import java.util.List; |
| 29 | -import java.util.Objects; | |
| 30 | 28 | |
| 31 | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 32 | 30 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -42,41 +40,42 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 42 | 40 | |
| 43 | 41 | @Resource |
| 44 | 42 | private MesWmStockTakingTaskMapper stockTakingTaskMapper; |
| 45 | - // TODO @芋艿:看看怎么清理掉,这块的依赖;应该调用对方的 service | |
| 46 | - @Resource | |
| 47 | - private MesWmStockTakingTaskLineMapper stockTakingTaskLineMapper; | |
| 48 | - // TODO @芋艿:看看怎么清理掉,这块的依赖;应该调用对方的 service | |
| 49 | - @Resource | |
| 50 | - private MesWmStockTakingTaskResultMapper stockTakingTaskResultMapper; | |
| 51 | 43 | |
| 52 | 44 | @Resource |
| 53 | 45 | private MesWmMaterialStockService materialStockService; |
| 54 | 46 | @Resource |
| 55 | - private AdminUserApi adminUserApi; | |
| 56 | - @Resource | |
| 57 | 47 | private MesWmStockTakingPlanService stockTakingPlanService; |
| 48 | + @Lazy | |
| 58 | 49 | @Resource |
| 59 | 50 | private MesWmStockTakingTaskLineService stockTakingTaskLineService; |
| 51 | + @Lazy | |
| 52 | + @Resource | |
| 53 | + private MesWmStockTakingTaskResultService stockTakingTaskResultService; | |
| 54 | + | |
| 55 | + @Resource | |
| 56 | + private AdminUserApi adminUserApi; | |
| 60 | 57 | |
| 61 | 58 | @Override |
| 62 | 59 | @Transactional(rollbackFor = Exception.class) |
| 63 | 60 | public Long createStockTakingTask(MesWmStockTakingTaskSaveReqVO createReqVO) { |
| 64 | 61 | // 1.1 校验 code 唯一 |
| 65 | - validateTaskCodeUnique(null, createReqVO.getCode()); | |
| 62 | + validateStockTakingTaskCodeUnique(null, createReqVO.getCode()); | |
| 66 | 63 | // 1.2 校验方案存在 |
| 67 | 64 | adminUserApi.validateUser(createReqVO.getUserId()); |
| 68 | - // 1.3 校验方案可用 | |
| 69 | - // TODO @芋艿:貌似可以 planId 不填写;无 plan 就手动维护; | |
| 70 | - stockTakingPlanService.validateStockTakingPlanEnabled(createReqVO.getPlanId()); | |
| 65 | + // 1.3 校验方案可用(如果有 planId) | |
| 66 | + if (createReqVO.getPlanId() != null) { | |
| 67 | + stockTakingPlanService.validateStockTakingPlanEnabled(createReqVO.getPlanId()); | |
| 68 | + } | |
| 71 | 69 | |
| 72 | 70 | // 2. 插入任务 |
| 73 | 71 | MesWmStockTakingTaskDO task = BeanUtils.toBean(createReqVO, MesWmStockTakingTaskDO.class) |
| 74 | 72 | .setStatus(MesWmStockTakingTaskStatusEnum.PREPARE.getStatus()); |
| 75 | 73 | stockTakingTaskMapper.insert(task); |
| 76 | 74 | |
| 77 | - // 3. 根据方案生成盘点明细行 | |
| 78 | - // TODO @AI:有 plan 的情况下,才类似操作; | |
| 79 | - stockTakingTaskLineService.generateStockTakingLines(task); | |
| 75 | + // 3. 根据方案生成盘点明细行(仅当有 plan 时) | |
| 76 | + if (task.getPlanId() != null) { | |
| 77 | + stockTakingTaskLineService.generateStockTakingLines(task, true); | |
| 78 | + } | |
| 80 | 79 | return task.getId(); |
| 81 | 80 | } |
| 82 | 81 | |
| ... | ... | @@ -84,34 +83,35 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 84 | 83 | @Transactional(rollbackFor = Exception.class) |
| 85 | 84 | public void updateStockTakingTask(MesWmStockTakingTaskSaveReqVO updateReqVO) { |
| 86 | 85 | // 1.1 校验任务存在且为草稿状态 |
| 87 | - validateTaskExistsAndPrepare(updateReqVO.getId()); | |
| 86 | + validateStockTakingTaskExistsAndPrepare(updateReqVO.getId()); | |
| 88 | 87 | // 1.2 校验 code 唯一 |
| 89 | - validateTaskCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | |
| 88 | + validateStockTakingTaskCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | |
| 90 | 89 | // 1.3 校验方案存在 |
| 91 | 90 | adminUserApi.validateUser(updateReqVO.getUserId()); |
| 92 | - // 1.4 校验方案可用 | |
| 93 | - // TODO @芋艿:貌似可以 planId 不填写;无 plan 就手动维护; | |
| 94 | - stockTakingPlanService.validateStockTakingPlanEnabled(updateReqVO.getPlanId()); | |
| 91 | + // 1.4 校验方案可用(如果有 planId) | |
| 92 | + if (updateReqVO.getPlanId() != null) { | |
| 93 | + stockTakingPlanService.validateStockTakingPlanEnabled(updateReqVO.getPlanId()); | |
| 94 | + } | |
| 95 | 95 | |
| 96 | 96 | // 2. 更新任务 |
| 97 | 97 | MesWmStockTakingTaskDO updateObj = BeanUtils.toBean(updateReqVO, MesWmStockTakingTaskDO.class); |
| 98 | 98 | stockTakingTaskMapper.updateById(updateObj); |
| 99 | 99 | |
| 100 | - // 3. 删除老的明细,重新生成新的 | |
| 101 | - // TODO @AI:有 plan 的情况下,才类似操作; | |
| 102 | - stockTakingTaskLineMapper.deleteByTaskId(updateReqVO.getId()); | |
| 103 | - stockTakingTaskLineService.generateStockTakingLines(updateObj); | |
| 100 | + // 3. 重新生成盘点明细行(仅当有 plan 时) | |
| 101 | + if (updateObj.getPlanId() != null) { | |
| 102 | + stockTakingTaskLineService.generateStockTakingLines(updateObj, false); | |
| 103 | + } | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | @Override |
| 107 | 107 | @Transactional(rollbackFor = Exception.class) |
| 108 | 108 | public void deleteStockTakingTask(Long id) { |
| 109 | 109 | // 1. 校验任务存在且为草稿状态 |
| 110 | - validateTaskExistsAndPrepare(id); | |
| 110 | + validateStockTakingTaskExistsAndPrepare(id); | |
| 111 | 111 | |
| 112 | 112 | // 2. 删除任务和明细 |
| 113 | - stockTakingTaskResultMapper.deleteByTaskId(id); | |
| 114 | - stockTakingTaskLineMapper.deleteByTaskId(id); | |
| 113 | + stockTakingTaskResultService.deleteStockTakingTaskResultByTaskId(id); | |
| 114 | + stockTakingTaskLineService.deleteStockTakingTaskLineByTaskId(id); | |
| 115 | 115 | stockTakingTaskMapper.deleteById(id); |
| 116 | 116 | } |
| 117 | 117 | |
| ... | ... | @@ -119,9 +119,9 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 119 | 119 | @Transactional(rollbackFor = Exception.class) |
| 120 | 120 | public void submitStockTakingTask(Long id) { |
| 121 | 121 | // 1.1 校验任务存在且为草稿状态 |
| 122 | - MesWmStockTakingTaskDO task = validateTaskExistsAndPrepare(id); | |
| 122 | + MesWmStockTakingTaskDO task = validateStockTakingTaskExistsAndPrepare(id); | |
| 123 | 123 | // 1.2 检查要盘点的内容 |
| 124 | - List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineMapper.selectListByTaskId(id); | |
| 124 | + List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineService.getStockTakingTaskLineListByTaskId(id); | |
| 125 | 125 | if (CollUtil.isEmpty(lines)) { |
| 126 | 126 | throw exception(WM_STOCK_TAKING_TASK_NO_LINE); |
| 127 | 127 | } |
| ... | ... | @@ -135,7 +135,7 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 135 | 135 | if (Boolean.TRUE.equals(task.getFrozenFlag())) { |
| 136 | 136 | for (MesWmStockTakingTaskLineDO line : lines) { |
| 137 | 137 | if (line.getMaterialStockId() != null) { |
| 138 | - updateFrozen(line.getMaterialStockId(), true); | |
| 138 | + updateMaterialStockFrozen(line.getMaterialStockId(), true); | |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
| ... | ... | @@ -145,23 +145,25 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 145 | 145 | @Override |
| 146 | 146 | @Transactional(rollbackFor = Exception.class) |
| 147 | 147 | public void finishStockTakingTask(Long id) { |
| 148 | - // TODO @AI:补全下注释; | |
| 149 | - // TODO @AI:notEquals; | |
| 150 | - MesWmStockTakingTaskDO task = validateTaskExists(id); | |
| 151 | - if (!MesWmStockTakingTaskStatusEnum.APPROVING.getStatus().equals(task.getStatus())) { | |
| 148 | + // 1.1 校验任务存在且为审批中状态 | |
| 149 | + MesWmStockTakingTaskDO task = validateStockTakingTaskExistsInternal(id); | |
| 150 | + // 1.2 校验任务状态 | |
| 151 | + if (ObjUtil.notEqual(MesWmStockTakingTaskStatusEnum.APPROVING.getStatus(), task.getStatus())) { | |
| 152 | 152 | throw exception(WM_STOCK_TAKING_TASK_NOT_APPROVING); |
| 153 | 153 | } |
| 154 | - List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineMapper.selectListByTaskId(id); | |
| 154 | + // 1.3 获取盘点任务行 | |
| 155 | + List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineService.getStockTakingTaskLineListByTaskId(id); | |
| 155 | 156 | if (CollUtil.isEmpty(lines)) { |
| 156 | 157 | throw exception(WM_STOCK_TAKING_TASK_NO_LINE); |
| 157 | 158 | } |
| 158 | 159 | |
| 159 | - stockTakingTaskResultMapper.deleteByTaskId(id); | |
| 160 | + // 2. 生成盘点结果(仅保存差异数据) | |
| 161 | + stockTakingTaskResultService.deleteStockTakingTaskResultByTaskId(id); | |
| 160 | 162 | for (MesWmStockTakingTaskLineDO line : lines) { |
| 161 | 163 | if (MesWmStockTakingTaskLineStatusEnum.NORMAL.getStatus().equals(line.getStatus())) { |
| 162 | 164 | continue; |
| 163 | 165 | } |
| 164 | - stockTakingTaskResultMapper.insert(MesWmStockTakingTaskResultDO.builder() | |
| 166 | + stockTakingTaskResultService.createStockTakingTaskResult(MesWmStockTakingTaskResultDO.builder() | |
| 165 | 167 | .taskId(id) |
| 166 | 168 | .lineId(line.getId()) |
| 167 | 169 | .materialStockId(line.getMaterialStockId()) |
| ... | ... | @@ -171,23 +173,26 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 171 | 173 | .warehouseId(line.getWarehouseId()) |
| 172 | 174 | .locationId(line.getLocationId()) |
| 173 | 175 | .areaId(line.getAreaId()) |
| 174 | - .quantity(differenceQuantity(line)) | |
| 176 | + .quantity(calculateStockTakingDifferenceQuantity(line)) | |
| 175 | 177 | .remark(line.getRemark()) |
| 176 | 178 | .build()); |
| 177 | 179 | } |
| 178 | 180 | |
| 181 | + // 3. 更新任务状态为已完成 | |
| 179 | 182 | task.setEndTime(LocalDateTime.now()); |
| 180 | 183 | task.setStatus(MesWmStockTakingTaskStatusEnum.FINISHED.getStatus()); |
| 181 | 184 | stockTakingTaskMapper.updateById(task); |
| 185 | + | |
| 186 | + // 4. 解冻库存 | |
| 182 | 187 | if (Boolean.TRUE.equals(task.getFrozenFlag())) { |
| 183 | - unfreezeTaskStocks(lines); | |
| 188 | + unfreezeStockTakingTaskStocks(lines); | |
| 184 | 189 | } |
| 185 | 190 | } |
| 186 | 191 | |
| 187 | 192 | @Override |
| 188 | 193 | @Transactional(rollbackFor = Exception.class) |
| 189 | 194 | public void cancelStockTakingTask(Long id) { |
| 190 | - MesWmStockTakingTaskDO task = validateTaskExists(id); | |
| 195 | + MesWmStockTakingTaskDO task = validateStockTakingTaskExistsInternal(id); | |
| 191 | 196 | if (MesWmStockTakingTaskStatusEnum.FINISHED.getStatus().equals(task.getStatus()) |
| 192 | 197 | || MesWmStockTakingTaskStatusEnum.CANCELED.getStatus().equals(task.getStatus())) { |
| 193 | 198 | throw exception(WM_STOCK_TAKING_TASK_CANNOT_CANCEL); |
| ... | ... | @@ -195,7 +200,7 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 195 | 200 | task.setStatus(MesWmStockTakingTaskStatusEnum.CANCELED.getStatus()); |
| 196 | 201 | stockTakingTaskMapper.updateById(task); |
| 197 | 202 | if (Boolean.TRUE.equals(task.getFrozenFlag())) { |
| 198 | - unfreezeTaskStocks(stockTakingTaskLineMapper.selectListByTaskId(id)); | |
| 203 | + unfreezeStockTakingTaskStocks(stockTakingTaskLineService.getStockTakingTaskLineListByTaskId(id)); | |
| 199 | 204 | } |
| 200 | 205 | } |
| 201 | 206 | |
| ... | ... | @@ -206,7 +211,19 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 206 | 211 | |
| 207 | 212 | @Override |
| 208 | 213 | public MesWmStockTakingTaskDO validateStockTakingTaskExists(Long id) { |
| 209 | - return validateTaskExists(id); | |
| 214 | + return validateStockTakingTaskExistsInternal(id); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + public MesWmStockTakingTaskDO validateStockTakingTaskExistsAndPrepare(Long id) { | |
| 219 | + MesWmStockTakingTaskDO task = stockTakingTaskMapper.selectById(id); | |
| 220 | + if (task == null) { | |
| 221 | + throw exception(WM_STOCK_TAKING_TASK_NOT_EXISTS); | |
| 222 | + } | |
| 223 | + if (ObjUtil.notEqual(MesWmStockTakingTaskStatusEnum.PREPARE.getStatus(), task.getStatus())) { | |
| 224 | + throw exception(WM_STOCK_TAKING_TASK_NOT_PREPARE); | |
| 225 | + } | |
| 226 | + return task; | |
| 210 | 227 | } |
| 211 | 228 | |
| 212 | 229 | @Override |
| ... | ... | @@ -214,52 +231,43 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 214 | 231 | return stockTakingTaskMapper.selectPage(pageReqVO); |
| 215 | 232 | } |
| 216 | 233 | |
| 217 | - private void updateFrozen(Long materialStockId, boolean frozen) { | |
| 234 | + private void updateMaterialStockFrozen(Long materialStockId, boolean frozen) { | |
| 218 | 235 | MesWmMaterialStockFreezeReqVO reqVO = new MesWmMaterialStockFreezeReqVO(); |
| 219 | 236 | reqVO.setId(materialStockId); |
| 220 | 237 | reqVO.setFrozen(frozen); |
| 221 | 238 | materialStockService.updateMaterialStockFrozen(reqVO); |
| 222 | 239 | } |
| 223 | 240 | |
| 224 | - private void unfreezeTaskStocks(List<MesWmStockTakingTaskLineDO> lines) { | |
| 241 | + private void unfreezeStockTakingTaskStocks(List<MesWmStockTakingTaskLineDO> lines) { | |
| 225 | 242 | if (CollUtil.isEmpty(lines)) { |
| 226 | 243 | return; |
| 227 | 244 | } |
| 228 | 245 | for (MesWmStockTakingTaskLineDO line : lines) { |
| 229 | 246 | if (line.getMaterialStockId() != null) { |
| 230 | - updateFrozen(line.getMaterialStockId(), false); | |
| 247 | + updateMaterialStockFrozen(line.getMaterialStockId(), false); | |
| 231 | 248 | } |
| 232 | 249 | } |
| 233 | 250 | } |
| 234 | 251 | |
| 235 | - private Integer resolveLineStatus(BigDecimal quantity, BigDecimal takingQuantity) { | |
| 236 | - int compare = takingQuantity.compareTo(defaultQuantity(quantity)); | |
| 237 | - if (compare == 0) { | |
| 238 | - return MesWmStockTakingTaskLineStatusEnum.NORMAL.getStatus(); | |
| 239 | - } | |
| 240 | - return compare > 0 ? MesWmStockTakingTaskLineStatusEnum.GAIN.getStatus() | |
| 241 | - : MesWmStockTakingTaskLineStatusEnum.LOSS.getStatus(); | |
| 242 | - } | |
| 243 | - | |
| 244 | - private BigDecimal differenceQuantity(MesWmStockTakingTaskLineDO line) { | |
| 245 | - return defaultQuantity(line.getTakingQuantity()).subtract(defaultQuantity(line.getQuantity())); | |
| 252 | + private BigDecimal calculateStockTakingDifferenceQuantity(MesWmStockTakingTaskLineDO line) { | |
| 253 | + return getDefaultQuantity(line.getTakingQuantity()).subtract(getDefaultQuantity(line.getQuantity())); | |
| 246 | 254 | } |
| 247 | 255 | |
| 248 | - private BigDecimal defaultQuantity(BigDecimal quantity) { | |
| 256 | + private BigDecimal getDefaultQuantity(BigDecimal quantity) { | |
| 249 | 257 | return quantity == null ? BigDecimal.ZERO : quantity; |
| 250 | 258 | } |
| 251 | 259 | |
| 252 | - private void validateTaskCodeUnique(Long id, String code) { | |
| 260 | + private void validateStockTakingTaskCodeUnique(Long id, String code) { | |
| 253 | 261 | MesWmStockTakingTaskDO task = stockTakingTaskMapper.selectByCode(code); |
| 254 | 262 | if (task == null) { |
| 255 | 263 | return; |
| 256 | 264 | } |
| 257 | - if (id == null || !Objects.equals(task.getId(), id)) { | |
| 265 | + if (ObjUtil.notEqual(task.getId(), id)) { | |
| 258 | 266 | throw exception(WM_STOCK_TAKING_TASK_CODE_DUPLICATE); |
| 259 | 267 | } |
| 260 | 268 | } |
| 261 | 269 | |
| 262 | - private MesWmStockTakingTaskDO validateTaskExists(Long id) { | |
| 270 | + private MesWmStockTakingTaskDO validateStockTakingTaskExistsInternal(Long id) { | |
| 263 | 271 | MesWmStockTakingTaskDO task = stockTakingTaskMapper.selectById(id); |
| 264 | 272 | if (task == null) { |
| 265 | 273 | throw exception(WM_STOCK_TAKING_TASK_NOT_EXISTS); |
| ... | ... | @@ -267,12 +275,4 @@ public class MesWmStockTakingTaskServiceImpl implements MesWmStockTakingTaskServ |
| 267 | 275 | return task; |
| 268 | 276 | } |
| 269 | 277 | |
| 270 | - private MesWmStockTakingTaskDO validateTaskExistsAndPrepare(Long id) { | |
| 271 | - MesWmStockTakingTaskDO task = validateTaskExists(id); | |
| 272 | - if (ObjUtil.notEqual(MesWmStockTakingTaskStatusEnum.PREPARE.getStatus(), task.getStatus())) { | |
| 273 | - throw exception(WM_STOCK_TAKING_TASK_NOT_PREPARE); | |
| 274 | - } | |
| 275 | - return task; | |
| 276 | - } | |
| 277 | - | |
| 278 | 278 | } | ... | ... |