Commit 1fd112c6eae4eb2e7019f58e243542e64dd88785
1 parent
aea84c59
✨ feat(mes): 添加盘点结果的创建、更新和删除功能
Showing
5 changed files
with
143 additions
and
35 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/MesWmStockTakingTaskLineController.java
| ... | ... | @@ -100,6 +100,15 @@ public class MesWmStockTakingTaskLineController { |
| 100 | 100 | return success(true); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | + @GetMapping("/simple-list") | |
| 104 | + @Operation(summary = "获得盘点任务行精简列表", description = "根据任务编号查询,主要用于前端的下拉选项") | |
| 105 | + @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") | |
| 106 | + public CommonResult<List<MesWmStockTakingTaskLineRespVO>> getStockTakingTaskLineSimpleList( | |
| 107 | + @RequestParam("taskId") Long taskId) { | |
| 108 | + List<MesWmStockTakingTaskLineDO> list = stockTakingTaskLineService.getStockTakingTaskLineListByTaskId(taskId); | |
| 109 | + return success(buildStockTakingTaskLineRespVOList(list)); | |
| 110 | + } | |
| 111 | + | |
| 103 | 112 | // ==================== 拼接 VO ==================== |
| 104 | 113 | |
| 105 | 114 | private List<MesWmStockTakingTaskLineRespVO> buildStockTakingTaskLineRespVOList(List<MesWmStockTakingTaskLineDO> list) { | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/MesWmStockTakingTaskResultController.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 6 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 9 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 11 | 8 | import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultPageReqVO; |
| 12 | 9 | import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultRespVO; |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultSaveReqVO; | |
| 13 | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| 14 | 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| 15 | 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskResultDO; |
| ... | ... | @@ -26,21 +24,16 @@ import io.swagger.v3.oas.annotations.Operation; |
| 26 | 24 | import io.swagger.v3.oas.annotations.Parameter; |
| 27 | 25 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 28 | 26 | import jakarta.annotation.Resource; |
| 29 | -import jakarta.servlet.http.HttpServletResponse; | |
| 30 | 27 | import jakarta.validation.Valid; |
| 31 | 28 | import org.springframework.security.access.prepost.PreAuthorize; |
| 29 | +import org.springframework.transaction.annotation.Transactional; | |
| 32 | 30 | import org.springframework.validation.annotation.Validated; |
| 33 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 34 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 35 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 36 | -import org.springframework.web.bind.annotation.RestController; | |
| 31 | +import org.springframework.web.bind.annotation.*; | |
| 37 | 32 | |
| 38 | -import java.io.IOException; | |
| 39 | 33 | import java.util.Collections; |
| 40 | 34 | import java.util.List; |
| 41 | 35 | import java.util.Map; |
| 42 | 36 | |
| 43 | -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 44 | 37 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 45 | 38 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 46 | 39 | |
| ... | ... | @@ -84,45 +77,74 @@ public class MesWmStockTakingTaskResultController { |
| 84 | 77 | } |
| 85 | 78 | |
| 86 | 79 | @GetMapping("/list") |
| 87 | - @Operation(summary = "获得盘点结果列表") | |
| 88 | - @Parameter(name = "taskId", description = "任务编号", required = true) | |
| 80 | + @Operation(summary = "获得盘点结果分页列表") | |
| 89 | 81 | @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:query')") |
| 90 | - public CommonResult<List<MesWmStockTakingTaskResultRespVO>> getStockTakingTaskResultList(@RequestParam("taskId") Long taskId) { | |
| 91 | - return success(buildStockTakingTaskResultRespVOList(stockTakingTaskResultService.getStockTakingTaskResultList(taskId))); | |
| 82 | + public CommonResult<PageResult<MesWmStockTakingTaskResultRespVO>> getStockTakingTaskResultList(@Valid MesWmStockTakingTaskResultPageReqVO pageReqVO) { | |
| 83 | + PageResult<MesWmStockTakingTaskResultDO> pageResult = stockTakingTaskResultService.getStockTakingTaskResultPage(pageReqVO); | |
| 84 | + return success(new PageResult<>(buildStockTakingTaskResultRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 92 | 85 | } |
| 93 | 86 | |
| 94 | - @GetMapping("/export-excel") | |
| 95 | - @Operation(summary = "导出盘点结果 Excel") | |
| 96 | - @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:export')") | |
| 97 | - @ApiAccessLog(operateType = EXPORT) | |
| 98 | - public void exportStockTakingTaskResultExcel(@Valid MesWmStockTakingTaskResultPageReqVO pageReqVO, | |
| 99 | - HttpServletResponse response) throws IOException { | |
| 100 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 101 | - PageResult<MesWmStockTakingTaskResultDO> pageResult = stockTakingTaskResultService.getStockTakingTaskResultPage(pageReqVO); | |
| 102 | - ExcelUtils.write(response, "盘点结果.xls", "数据", MesWmStockTakingTaskResultRespVO.class, | |
| 103 | - buildStockTakingTaskResultRespVOList(pageResult.getList())); | |
| 87 | + @PostMapping("/create") | |
| 88 | + @Operation(summary = "创建盘点结果") | |
| 89 | + @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:update')") | |
| 90 | + @Transactional(rollbackFor = Exception.class) | |
| 91 | + public CommonResult<Long> createStockTakingTaskResult(@Valid @RequestBody MesWmStockTakingTaskResultSaveReqVO createReqVO) { | |
| 92 | + MesWmStockTakingTaskResultDO result = BeanUtils.toBean(createReqVO, MesWmStockTakingTaskResultDO.class); | |
| 93 | + stockTakingTaskResultService.createStockTakingTaskResult(result); | |
| 94 | + return success(result.getId()); | |
| 95 | + } | |
| 96 | + | |
| 97 | + @PutMapping("/update") | |
| 98 | + @Operation(summary = "更新盘点结果") | |
| 99 | + @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:update')") | |
| 100 | + @Transactional(rollbackFor = Exception.class) | |
| 101 | + public CommonResult<Boolean> updateStockTakingTaskResult(@Valid @RequestBody MesWmStockTakingTaskResultSaveReqVO updateReqVO) { | |
| 102 | + MesWmStockTakingTaskResultDO result = BeanUtils.toBean(updateReqVO, MesWmStockTakingTaskResultDO.class); | |
| 103 | + stockTakingTaskResultService.updateStockTakingTaskResult(result); | |
| 104 | + return success(true); | |
| 104 | 105 | } |
| 105 | 106 | |
| 107 | + @DeleteMapping("/delete") | |
| 108 | + @Operation(summary = "删除盘点结果") | |
| 109 | + @Parameter(name = "id", description = "编号", required = true) | |
| 110 | + @PreAuthorize("@ss.hasPermission('mes:wm-stock-taking-task:update')") | |
| 111 | + @Transactional(rollbackFor = Exception.class) | |
| 112 | + public CommonResult<Boolean> deleteStockTakingTaskResult(@RequestParam("id") Long id) { | |
| 113 | + stockTakingTaskResultService.deleteStockTakingTaskResult(id); | |
| 114 | + return success(true); | |
| 115 | + } | |
| 116 | + | |
| 117 | + // ==================== 拼接 VO ==================== | |
| 118 | + | |
| 119 | + | |
| 106 | 120 | private List<MesWmStockTakingTaskResultRespVO> buildStockTakingTaskResultRespVOList(List<MesWmStockTakingTaskResultDO> list) { |
| 107 | 121 | if (CollUtil.isEmpty(list)) { |
| 108 | 122 | return Collections.emptyList(); |
| 109 | 123 | } |
| 110 | - Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(convertSet(list, MesWmStockTakingTaskResultDO::getItemId)); | |
| 124 | + // 查询关联数据 | |
| 125 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 126 | + convertSet(list, MesWmStockTakingTaskResultDO::getItemId)); | |
| 111 | 127 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| 112 | 128 | convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); |
| 113 | - Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap(convertSet(list, MesWmStockTakingTaskResultDO::getWarehouseId)); | |
| 114 | - Map<Long, MesWmWarehouseLocationDO> locationMap = locationService.getWarehouseLocationMap(convertSet(list, MesWmStockTakingTaskResultDO::getLocationId)); | |
| 115 | - Map<Long, MesWmWarehouseAreaDO> areaMap = areaService.getWarehouseAreaMap(convertSet(list, MesWmStockTakingTaskResultDO::getAreaId)); | |
| 129 | + Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 130 | + convertSet(list, MesWmStockTakingTaskResultDO::getWarehouseId)); | |
| 131 | + Map<Long, MesWmWarehouseLocationDO> locationMap = locationService.getWarehouseLocationMap( | |
| 132 | + convertSet(list, MesWmStockTakingTaskResultDO::getLocationId)); | |
| 133 | + Map<Long, MesWmWarehouseAreaDO> areaMap = areaService.getWarehouseAreaMap( | |
| 134 | + convertSet(list, MesWmStockTakingTaskResultDO::getAreaId)); | |
| 135 | + // 拼接 VO | |
| 116 | 136 | return BeanUtils.toBean(list, MesWmStockTakingTaskResultRespVO.class, vo -> { |
| 117 | 137 | MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { |
| 118 | - vo.setItemCode(item.getCode()); | |
| 119 | - vo.setItemName(item.getName()); | |
| 120 | - vo.setSpecification(item.getSpecification()); | |
| 121 | - MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), unit -> vo.setUnitMeasureName(unit.getName())); | |
| 138 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); | |
| 139 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 140 | + unit -> vo.setUnitMeasureName(unit.getName())); | |
| 122 | 141 | }); |
| 123 | - MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), warehouse -> vo.setWarehouseName(warehouse.getName())); | |
| 124 | - MapUtils.findAndThen(locationMap, vo.getLocationId(), location -> vo.setLocationName(location.getName())); | |
| 125 | - MapUtils.findAndThen(areaMap, vo.getAreaId(), area -> vo.setAreaName(area.getName())); | |
| 142 | + MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), | |
| 143 | + warehouse -> vo.setWarehouseName(warehouse.getName())); | |
| 144 | + MapUtils.findAndThen(locationMap, vo.getLocationId(), | |
| 145 | + location -> vo.setLocationName(location.getName())); | |
| 146 | + MapUtils.findAndThen(areaMap, vo.getAreaId(), | |
| 147 | + area -> vo.setAreaName(area.getName())); | |
| 126 | 148 | }); |
| 127 | 149 | } |
| 128 | 150 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/stocktaking/task/vo/result/MesWmStockTakingTaskResultSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotNull; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.math.BigDecimal; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - MES 盘点结果新增/修改 Request VO") | |
| 10 | +@Data | |
| 11 | +public class MesWmStockTakingTaskResultSaveReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", example = "1") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "任务 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | + @NotNull(message = "任务 ID 不能为空") | |
| 18 | + private Long taskId; | |
| 19 | + | |
| 20 | + @Schema(description = "任务行 ID", example = "1") | |
| 21 | + private Long lineId; | |
| 22 | + | |
| 23 | + @Schema(description = "库存台账 ID", example = "1") | |
| 24 | + private Long materialStockId; | |
| 25 | + | |
| 26 | + @Schema(description = "物料 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @NotNull(message = "物料 ID 不能为空") | |
| 28 | + private Long itemId; | |
| 29 | + | |
| 30 | + @Schema(description = "批次 ID", example = "1") | |
| 31 | + private Long batchId; | |
| 32 | + | |
| 33 | + @Schema(description = "批次编码", example = "B202603080001") | |
| 34 | + private String batchCode; | |
| 35 | + | |
| 36 | + @Schema(description = "仓库 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 37 | + @NotNull(message = "仓库 ID 不能为空") | |
| 38 | + private Long warehouseId; | |
| 39 | + | |
| 40 | + @Schema(description = "库区 ID", example = "1") | |
| 41 | + private Long locationId; | |
| 42 | + | |
| 43 | + @Schema(description = "库位 ID", example = "1") | |
| 44 | + private Long areaId; | |
| 45 | + | |
| 46 | + @Schema(description = "差异数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.000000") | |
| 47 | + @NotNull(message = "差异数量不能为空") | |
| 48 | + private BigDecimal quantity; | |
| 49 | + | |
| 50 | + @Schema(description = "备注", example = "备注") | |
| 51 | + private String remark; | |
| 52 | + | |
| 53 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultService.java
| ... | ... | @@ -45,6 +45,20 @@ public interface MesWmStockTakingTaskResultService { |
| 45 | 45 | void createStockTakingTaskResult(MesWmStockTakingTaskResultDO result); |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | + * 更新盘点结果 | |
| 49 | + * | |
| 50 | + * @param result 盘点结果 | |
| 51 | + */ | |
| 52 | + void updateStockTakingTaskResult(MesWmStockTakingTaskResultDO result); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 删除盘点结果 | |
| 56 | + * | |
| 57 | + * @param id 盘点结果编号 | |
| 58 | + */ | |
| 59 | + void deleteStockTakingTaskResult(Long id); | |
| 60 | + | |
| 61 | + /** | |
| 48 | 62 | * 根据任务编号删除盘点结果 |
| 49 | 63 | * |
| 50 | 64 | * @param taskId 任务编号 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java
| ... | ... | @@ -44,6 +44,16 @@ public class MesWmStockTakingTaskResultServiceImpl implements MesWmStockTakingTa |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | @Override |
| 47 | + public void updateStockTakingTaskResult(MesWmStockTakingTaskResultDO result) { | |
| 48 | + stockTakingTaskResultMapper.updateById(result); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void deleteStockTakingTaskResult(Long id) { | |
| 53 | + stockTakingTaskResultMapper.deleteById(id); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 47 | 57 | public void deleteStockTakingTaskResultByTaskId(Long taskId) { |
| 48 | 58 | stockTakingTaskResultMapper.deleteByTaskId(taskId); |
| 49 | 59 | } | ... | ... |