Commit 8d2fc22d0497dadff41f85af973479a8b2168a0c
1 parent
67193b0c
✨ feat(mes): 添加领料出库单行及明细相关功能与接口
新增领料出库单行和明细的创建、更新、删除及查询接口,优化了数据模型和请求响应结构,提升了系统的可维护性和扩展性。
Showing
25 changed files
with
758 additions
and
272 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/arrivalnotice/vo/MesWmArrivalNoticeRespVO.java
| ... | ... | @@ -20,7 +20,7 @@ public class MesWmArrivalNoticeRespVO { |
| 20 | 20 | @ExcelProperty("通知单编码") |
| 21 | 21 | private String code; |
| 22 | 22 | |
| 23 | - @Schema(description = "通知单名称", example = "2 月份钢板到货") | |
| 23 | + @Schema(description = "通知单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "2 月份钢板到货") | |
| 24 | 24 | @ExcelProperty("通知单名称") |
| 25 | 25 | private String name; |
| 26 | 26 | |
| ... | ... | @@ -28,7 +28,7 @@ public class MesWmArrivalNoticeRespVO { |
| 28 | 28 | @ExcelProperty("采购订单编号") |
| 29 | 29 | private String purchaseOrderCode; |
| 30 | 30 | |
| 31 | - @Schema(description = "供应商编号", example = "1") | |
| 31 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 32 | 32 | private Long vendorId; |
| 33 | 33 | |
| 34 | 34 | @Schema(description = "供应商编码", example = "V001") |
| ... | ... | @@ -39,7 +39,7 @@ public class MesWmArrivalNoticeRespVO { |
| 39 | 39 | @ExcelProperty("供应商名称") |
| 40 | 40 | private String vendorName; |
| 41 | 41 | |
| 42 | - @Schema(description = "到货日期") | |
| 42 | + @Schema(description = "到货日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 43 | 43 | @ExcelProperty("到货日期") |
| 44 | 44 | private LocalDateTime arrivalDate; |
| 45 | 45 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/arrivalnotice/vo/MesWmArrivalNoticeSaveReqVO.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.controller.admin.wm.arrivalnotice.vo; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import jakarta.validation.constraints.NotEmpty; |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 5 | 6 | import lombok.Data; |
| 6 | 7 | |
| 7 | 8 | import java.time.LocalDateTime; |
| ... | ... | @@ -24,10 +25,12 @@ public class MesWmArrivalNoticeSaveReqVO { |
| 24 | 25 | @Schema(description = "采购订单编号", example = "PO20260101") |
| 25 | 26 | private String purchaseOrderCode; |
| 26 | 27 | |
| 27 | - @Schema(description = "供应商编号", example = "1") | |
| 28 | + @Schema(description = "供应商编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 29 | + @NotNull(message = "供应商编号不能为空") | |
| 28 | 30 | private Long vendorId; |
| 29 | 31 | |
| 30 | - @Schema(description = "到货日期") | |
| 32 | + @Schema(description = "到货日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 33 | + @NotNull(message = "到货日期不能为空") | |
| 31 | 34 | private LocalDateTime arrivalDate; |
| 32 | 35 | |
| 33 | 36 | @Schema(description = "联系人", example = "张三") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/arrivalnotice/vo/line/MesWmArrivalNoticeLineRespVO.java
| ... | ... | @@ -31,13 +31,13 @@ public class MesWmArrivalNoticeLineRespVO { |
| 31 | 31 | @Schema(description = "计量单位名称", example = "千克") |
| 32 | 32 | private String unitMeasureName; |
| 33 | 33 | |
| 34 | - @Schema(description = "到货数量", example = "500.00") | |
| 34 | + @Schema(description = "到货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "500.00") | |
| 35 | 35 | private BigDecimal arrivalQuantity; |
| 36 | 36 | |
| 37 | 37 | @Schema(description = "合格数量", example = "500.00") |
| 38 | 38 | private BigDecimal qualifiedQuantity; |
| 39 | 39 | |
| 40 | - @Schema(description = "是否需要来料检验", example = "true") | |
| 40 | + @Schema(description = "是否需要来料检验", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 41 | 41 | private Boolean iqcCheckFlag; |
| 42 | 42 | |
| 43 | 43 | @Schema(description = "来料检验单编号", example = "1") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt/vo/MesWmItemReceiptSaveReqVO.java
| ... | ... | @@ -18,7 +18,8 @@ public class MesWmItemReceiptSaveReqVO { |
| 18 | 18 | @NotEmpty(message = "入库单编码不能为空") |
| 19 | 19 | private String code; |
| 20 | 20 | |
| 21 | - @Schema(description = "入库单名称", example = "钢板入库单") | |
| 21 | + @Schema(description = "入库单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "钢板入库单") | |
| 22 | + @NotEmpty(message = "入库单名称不能为空") | |
| 22 | 23 | private String name; |
| 23 | 24 | |
| 24 | 25 | @Schema(description = "来料检验单编号", example = "1") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/MesWmProductionIssueController.java
| ... | ... | @@ -5,16 +5,18 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 8 | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | 10 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 10 | 11 | import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssuePageReqVO; |
| 11 | 12 | import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssueRespVO; |
| 12 | 13 | import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssueSaveReqVO; |
| 13 | -import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssueLineRespVO; | |
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | |
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | |
| 14 | 16 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDO; |
| 15 | -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; | |
| 17 | +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; | |
| 18 | +import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; | |
| 16 | 19 | import cn.iocoder.yudao.module.mes.service.wm.productionissue.MesWmProductionIssueService; |
| 17 | -import cn.iocoder.yudao.module.mes.service.wm.productionissue.MesWmProductionIssueLineService; | |
| 18 | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 19 | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| 20 | 22 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -34,9 +36,6 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPOR |
| 34 | 36 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 35 | 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 36 | 38 | |
| 37 | -// TODO @AI:方法的排序,参考别的模块; | |
| 38 | -// TODO @AI:controller、service、包括其他的,都需要全。createProductitonIssue 这种;其它模块也是; | |
| 39 | -// TODO @AI:需要新增 line、detail 的 controller;参考 /Users/yunai/Java/yudao-all-in-one/ruoyi-vue-pro/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/itemreceipt | |
| 40 | 39 | @Tag(name = "管理后台 - MES 领料出库单") |
| 41 | 40 | @RestController |
| 42 | 41 | @RequestMapping("/mes/wm/production-issue") |
| ... | ... | @@ -46,20 +45,22 @@ public class MesWmProductionIssueController { |
| 46 | 45 | @Resource |
| 47 | 46 | private MesWmProductionIssueService issueService; |
| 48 | 47 | @Resource |
| 49 | - private MesWmProductionIssueLineService issueLineService; | |
| 48 | + private MesMdWorkstationService workstationService; | |
| 49 | + @Resource | |
| 50 | + private MesProWorkOrderService workOrderService; | |
| 50 | 51 | |
| 51 | 52 | @PostMapping("/create") |
| 52 | 53 | @Operation(summary = "创建领料出库单") |
| 53 | 54 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:create')") |
| 54 | - public CommonResult<Long> createIssue(@Valid @RequestBody MesWmProductionIssueSaveReqVO createReqVO) { | |
| 55 | - return success(issueService.createIssue(createReqVO)); | |
| 55 | + public CommonResult<Long> createProductionIssue(@Valid @RequestBody MesWmProductionIssueSaveReqVO createReqVO) { | |
| 56 | + return success(issueService.createProductionIssue(createReqVO)); | |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | @PutMapping("/update") |
| 59 | 60 | @Operation(summary = "修改领料出库单") |
| 60 | 61 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:update')") |
| 61 | - public CommonResult<Boolean> updateIssue(@Valid @RequestBody MesWmProductionIssueSaveReqVO updateReqVO) { | |
| 62 | - issueService.updateIssue(updateReqVO); | |
| 62 | + public CommonResult<Boolean> updateProductionIssue(@Valid @RequestBody MesWmProductionIssueSaveReqVO updateReqVO) { | |
| 63 | + issueService.updateProductionIssue(updateReqVO); | |
| 63 | 64 | return success(true); |
| 64 | 65 | } |
| 65 | 66 | |
| ... | ... | @@ -67,8 +68,8 @@ public class MesWmProductionIssueController { |
| 67 | 68 | @Operation(summary = "删除领料出库单") |
| 68 | 69 | @Parameter(name = "id", description = "编号", required = true) |
| 69 | 70 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:delete')") |
| 70 | - public CommonResult<Boolean> deleteIssue(@RequestParam("id") Long id) { | |
| 71 | - issueService.deleteIssue(id); | |
| 71 | + public CommonResult<Boolean> deleteProductionIssue(@RequestParam("id") Long id) { | |
| 72 | + issueService.deleteProductionIssue(id); | |
| 72 | 73 | return success(true); |
| 73 | 74 | } |
| 74 | 75 | |
| ... | ... | @@ -76,20 +77,20 @@ public class MesWmProductionIssueController { |
| 76 | 77 | @Operation(summary = "获得领料出库单") |
| 77 | 78 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 78 | 79 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") |
| 79 | - public CommonResult<MesWmProductionIssueRespVO> getIssue(@RequestParam("id") Long id) { | |
| 80 | - MesWmProductionIssueDO issueHeader = issueService.getIssue(id); | |
| 81 | - if (issueHeader == null) { | |
| 80 | + public CommonResult<MesWmProductionIssueRespVO> getProductionIssue(@RequestParam("id") Long id) { | |
| 81 | + MesWmProductionIssueDO issue = issueService.getProductionIssue(id); | |
| 82 | + if (issue == null) { | |
| 82 | 83 | return success(null); |
| 83 | 84 | } |
| 84 | - return success(buildRespVOList(Collections.singletonList(issueHeader)).get(0)); | |
| 85 | + return success(buildRespVOList(Collections.singletonList(issue)).get(0)); | |
| 85 | 86 | } |
| 86 | 87 | |
| 87 | 88 | @GetMapping("/page") |
| 88 | 89 | @Operation(summary = "获得领料出库单分页") |
| 89 | 90 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") |
| 90 | - public CommonResult<PageResult<MesWmProductionIssueRespVO>> getIssuePage( | |
| 91 | + public CommonResult<PageResult<MesWmProductionIssueRespVO>> getProductionIssuePage( | |
| 91 | 92 | @Valid MesWmProductionIssuePageReqVO pageReqVO) { |
| 92 | - PageResult<MesWmProductionIssueDO> pageResult = issueService.getIssuePage(pageReqVO); | |
| 93 | + PageResult<MesWmProductionIssueDO> pageResult = issueService.getProductionIssuePage(pageReqVO); | |
| 93 | 94 | return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); |
| 94 | 95 | } |
| 95 | 96 | |
| ... | ... | @@ -97,10 +98,10 @@ public class MesWmProductionIssueController { |
| 97 | 98 | @Operation(summary = "导出领料出库单 Excel") |
| 98 | 99 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:export')") |
| 99 | 100 | @ApiAccessLog(operateType = EXPORT) |
| 100 | - public void exportIssueExcel(@Valid MesWmProductionIssuePageReqVO pageReqVO, | |
| 101 | - HttpServletResponse response) throws IOException { | |
| 101 | + public void exportProductionIssueExcel(@Valid MesWmProductionIssuePageReqVO pageReqVO, | |
| 102 | + HttpServletResponse response) throws IOException { | |
| 102 | 103 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 103 | - PageResult<MesWmProductionIssueDO> pageResult = issueService.getIssuePage(pageReqVO); | |
| 104 | + PageResult<MesWmProductionIssueDO> pageResult = issueService.getProductionIssuePage(pageReqVO); | |
| 104 | 105 | ExcelUtils.write(response, "领料出库单.xls", "数据", MesWmProductionIssueRespVO.class, |
| 105 | 106 | buildRespVOList(pageResult.getList())); |
| 106 | 107 | } |
| ... | ... | @@ -109,39 +110,33 @@ public class MesWmProductionIssueController { |
| 109 | 110 | @Operation(summary = "完成领料出库单") |
| 110 | 111 | @Parameter(name = "id", description = "编号", required = true) |
| 111 | 112 | @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:update-status')") |
| 112 | - public CommonResult<Boolean> finishIssue(@RequestParam("id") Long id) { | |
| 113 | - issueService.finishIssue(id); | |
| 113 | + public CommonResult<Boolean> finishProductionIssue(@RequestParam("id") Long id) { | |
| 114 | + issueService.finishProductionIssue(id); | |
| 114 | 115 | return success(true); |
| 115 | 116 | } |
| 116 | 117 | |
| 118 | + // TODO @AI:check quantity | |
| 119 | + | |
| 117 | 120 | // ==================== 拼接 VO ==================== |
| 118 | 121 | |
| 119 | - // TODO @AI:这个方法的拼接,在优化下; | |
| 120 | 122 | private List<MesWmProductionIssueRespVO> buildRespVOList(List<MesWmProductionIssueDO> list) { |
| 121 | 123 | if (CollUtil.isEmpty(list)) { |
| 122 | 124 | return Collections.emptyList(); |
| 123 | 125 | } |
| 124 | - | |
| 125 | - // 1. 转换基础 VO | |
| 126 | - List<MesWmProductionIssueRespVO> respVOList = BeanUtils.toBean(list, MesWmProductionIssueRespVO.class); | |
| 127 | - | |
| 128 | - // 2. 查询行数据 | |
| 129 | - Map<Long, List<MesWmProductionIssueLineDO>> lineMap = issueLineService.getIssueLineListByIssueIds( | |
| 130 | - convertSet(list, MesWmProductionIssueDO::getId)) | |
| 131 | - .stream() | |
| 132 | - .collect(java.util.stream.Collectors.groupingBy(MesWmProductionIssueLineDO::getIssueId)); | |
| 133 | - | |
| 134 | - // 3. 填充行数据 | |
| 135 | - respVOList.forEach(respVO -> { | |
| 136 | - List<MesWmProductionIssueLineDO> lines = lineMap.get(respVO.getId()); | |
| 137 | - if (CollUtil.isNotEmpty(lines)) { | |
| 138 | - respVO.setLines(BeanUtils.toBean(lines, MesWmProductionIssueLineRespVO.class)); | |
| 139 | - } | |
| 126 | + // 1. 获得关联数据 | |
| 127 | + Map<Long, MesMdWorkstationDO> workstationMap = workstationService.getWorkstationMap( | |
| 128 | + convertSet(list, MesWmProductionIssueDO::getWorkstationId)); | |
| 129 | + Map<Long, MesProWorkOrderDO> workOrderMap = workOrderService.getWorkOrderMap( | |
| 130 | + convertSet(list, MesWmProductionIssueDO::getWorkorderId)); | |
| 131 | + // 2. 构建结果 | |
| 132 | + return BeanUtils.toBean(list, MesWmProductionIssueRespVO.class, vo -> { | |
| 133 | + // 2.1 填充工作站名称 | |
| 134 | + MapUtils.findAndThen(workstationMap, vo.getWorkstationId(), | |
| 135 | + workstation -> vo.setWorkstationName(workstation.getName())); | |
| 136 | + // 2.2 填充工单编号 | |
| 137 | + MapUtils.findAndThen(workOrderMap, vo.getWorkorderId(), | |
| 138 | + workOrder -> vo.setWorkorderCode(workOrder.getCode())); | |
| 140 | 139 | }); |
| 141 | - | |
| 142 | - // TODO @AI:关联查询工作站、工单、任务、客户等数据,填充到响应 VO 中 | |
| 143 | - | |
| 144 | - return respVOList; | |
| 145 | 140 | } |
| 146 | 141 | |
| 147 | 142 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/MesWmProductionIssueDetailController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail.MesWmProductionIssueDetailRespVO; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail.MesWmProductionIssueDetailSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDetailDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | |
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | |
| 15 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 17 | +import cn.iocoder.yudao.module.mes.service.wm.productionissue.MesWmProductionIssueDetailService; | |
| 18 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; | |
| 19 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService; | |
| 20 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService; | |
| 21 | +import io.swagger.v3.oas.annotations.Operation; | |
| 22 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 23 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 24 | +import jakarta.annotation.Resource; | |
| 25 | +import jakarta.validation.Valid; | |
| 26 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 27 | +import org.springframework.validation.annotation.Validated; | |
| 28 | +import org.springframework.web.bind.annotation.*; | |
| 29 | + | |
| 30 | +import java.util.Collections; | |
| 31 | +import java.util.List; | |
| 32 | +import java.util.Map; | |
| 33 | + | |
| 34 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 35 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 36 | + | |
| 37 | +@Tag(name = "管理后台 - MES 领料出库明细") | |
| 38 | +@RestController | |
| 39 | +@RequestMapping("/mes/wm/production-issue-detail") | |
| 40 | +@Validated | |
| 41 | +public class MesWmProductionIssueDetailController { | |
| 42 | + | |
| 43 | + @Resource | |
| 44 | + private MesWmProductionIssueDetailService issueDetailService; | |
| 45 | + | |
| 46 | + @Resource | |
| 47 | + private MesMdItemService itemService; | |
| 48 | + | |
| 49 | + @Resource | |
| 50 | + private MesMdUnitMeasureService unitMeasureService; | |
| 51 | + | |
| 52 | + @Resource | |
| 53 | + private MesWmWarehouseService warehouseService; | |
| 54 | + | |
| 55 | + @Resource | |
| 56 | + private MesWmWarehouseLocationService locationService; | |
| 57 | + | |
| 58 | + @Resource | |
| 59 | + private MesWmWarehouseAreaService areaService; | |
| 60 | + | |
| 61 | + @PostMapping("/create") | |
| 62 | + @Operation(summary = "创建领料出库明细") | |
| 63 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:create')") | |
| 64 | + public CommonResult<Long> createProductionIssueDetail(@Valid @RequestBody MesWmProductionIssueDetailSaveReqVO createReqVO) { | |
| 65 | + return success(issueDetailService.createProductionIssueDetail(createReqVO)); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @PutMapping("/update") | |
| 69 | + @Operation(summary = "修改领料出库明细") | |
| 70 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:update')") | |
| 71 | + public CommonResult<Boolean> updateProductionIssueDetail(@Valid @RequestBody MesWmProductionIssueDetailSaveReqVO updateReqVO) { | |
| 72 | + issueDetailService.updateProductionIssueDetail(updateReqVO); | |
| 73 | + return success(true); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @DeleteMapping("/delete") | |
| 77 | + @Operation(summary = "删除领料出库明细") | |
| 78 | + @Parameter(name = "id", description = "编号", required = true) | |
| 79 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:delete')") | |
| 80 | + public CommonResult<Boolean> deleteProductionIssueDetail(@RequestParam("id") Long id) { | |
| 81 | + issueDetailService.deleteProductionIssueDetail(id); | |
| 82 | + return success(true); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @GetMapping("/get") | |
| 86 | + @Operation(summary = "获得领料出库明细") | |
| 87 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 88 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") | |
| 89 | + public CommonResult<MesWmProductionIssueDetailRespVO> getProductionIssueDetail(@RequestParam("id") Long id) { | |
| 90 | + MesWmProductionIssueDetailDO detail = issueDetailService.getProductionIssueDetail(id); | |
| 91 | + if (detail == null) { | |
| 92 | + return success(null); | |
| 93 | + } | |
| 94 | + return success(buildRespVOList(Collections.singletonList(detail)).get(0)); | |
| 95 | + } | |
| 96 | + | |
| 97 | + @GetMapping("/list-by-line") | |
| 98 | + @Operation(summary = "获得领料出库明细列表(按行编号)") | |
| 99 | + @Parameter(name = "lineId", description = "行编号", required = true, example = "1024") | |
| 100 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") | |
| 101 | + public CommonResult<List<MesWmProductionIssueDetailRespVO>> getProductionIssueDetailListByLineId( | |
| 102 | + @RequestParam("lineId") Long lineId) { | |
| 103 | + List<MesWmProductionIssueDetailDO> list = issueDetailService.getProductionIssueDetailListByLineId(lineId); | |
| 104 | + return success(buildRespVOList(list)); | |
| 105 | + } | |
| 106 | + | |
| 107 | + // ==================== 拼接 VO ==================== | |
| 108 | + | |
| 109 | + private List<MesWmProductionIssueDetailRespVO> buildRespVOList(List<MesWmProductionIssueDetailDO> list) { | |
| 110 | + if (CollUtil.isEmpty(list)) { | |
| 111 | + return Collections.emptyList(); | |
| 112 | + } | |
| 113 | + // 1. 获得关联数据 | |
| 114 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 115 | + convertSet(list, MesWmProductionIssueDetailDO::getItemId)); | |
| 116 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 117 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | |
| 118 | + Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 119 | + convertSet(list, MesWmProductionIssueDetailDO::getWarehouseId)); | |
| 120 | + Map<Long, MesWmWarehouseLocationDO> locationMap = locationService.getWarehouseLocationMap( | |
| 121 | + convertSet(list, MesWmProductionIssueDetailDO::getLocationId)); | |
| 122 | + Map<Long, MesWmWarehouseAreaDO> areaMap = areaService.getWarehouseAreaMap( | |
| 123 | + convertSet(list, MesWmProductionIssueDetailDO::getAreaId)); | |
| 124 | + // 2. 构建结果 | |
| 125 | + return BeanUtils.toBean(list, MesWmProductionIssueDetailRespVO.class, vo -> { | |
| 126 | + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 127 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); | |
| 128 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 129 | + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | |
| 130 | + }); | |
| 131 | + MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), | |
| 132 | + warehouse -> vo.setWarehouseName(warehouse.getName())); | |
| 133 | + MapUtils.findAndThen(locationMap, vo.getLocationId(), | |
| 134 | + location -> vo.setLocationName(location.getName())); | |
| 135 | + MapUtils.findAndThen(areaMap, vo.getAreaId(), | |
| 136 | + area -> vo.setAreaName(area.getName())); | |
| 137 | + }); | |
| 138 | + } | |
| 139 | + | |
| 140 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/MesWmProductionIssueLineController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLinePageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLineRespVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLineSaveReqVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; | |
| 14 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 15 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 16 | +import cn.iocoder.yudao.module.mes.service.wm.productionissue.MesWmProductionIssueLineService; | |
| 17 | +import io.swagger.v3.oas.annotations.Operation; | |
| 18 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 19 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 20 | +import jakarta.annotation.Resource; | |
| 21 | +import jakarta.validation.Valid; | |
| 22 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 23 | +import org.springframework.validation.annotation.Validated; | |
| 24 | +import org.springframework.web.bind.annotation.*; | |
| 25 | + | |
| 26 | +import java.util.Collections; | |
| 27 | +import java.util.List; | |
| 28 | +import java.util.Map; | |
| 29 | + | |
| 30 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 31 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 32 | + | |
| 33 | +@Tag(name = "管理后台 - MES 领料出库单行") | |
| 34 | +@RestController | |
| 35 | +@RequestMapping("/mes/wm/production-issue-line") | |
| 36 | +@Validated | |
| 37 | +public class MesWmProductionIssueLineController { | |
| 38 | + | |
| 39 | + @Resource | |
| 40 | + private MesWmProductionIssueLineService issueLineService; | |
| 41 | + | |
| 42 | + @Resource | |
| 43 | + private MesMdItemService itemService; | |
| 44 | + | |
| 45 | + @Resource | |
| 46 | + private MesMdUnitMeasureService unitMeasureService; | |
| 47 | + | |
| 48 | + @PostMapping("/create") | |
| 49 | + @Operation(summary = "创建领料出库单行") | |
| 50 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:create')") | |
| 51 | + public CommonResult<Long> createProductionIssueLine(@Valid @RequestBody MesWmProductionIssueLineSaveReqVO createReqVO) { | |
| 52 | + return success(issueLineService.createProductionIssueLine(createReqVO)); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @PutMapping("/update") | |
| 56 | + @Operation(summary = "修改领料出库单行") | |
| 57 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:update')") | |
| 58 | + public CommonResult<Boolean> updateProductionIssueLine(@Valid @RequestBody MesWmProductionIssueLineSaveReqVO updateReqVO) { | |
| 59 | + issueLineService.updateProductionIssueLine(updateReqVO); | |
| 60 | + return success(true); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @DeleteMapping("/delete") | |
| 64 | + @Operation(summary = "删除领料出库单行") | |
| 65 | + @Parameter(name = "id", description = "编号", required = true) | |
| 66 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:delete')") | |
| 67 | + public CommonResult<Boolean> deleteProductionIssueLine(@RequestParam("id") Long id) { | |
| 68 | + issueLineService.deleteProductionIssueLine(id); | |
| 69 | + return success(true); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/get") | |
| 73 | + @Operation(summary = "获得领料出库单行") | |
| 74 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 75 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") | |
| 76 | + public CommonResult<MesWmProductionIssueLineRespVO> getProductionIssueLine(@RequestParam("id") Long id) { | |
| 77 | + MesWmProductionIssueLineDO line = issueLineService.getProductionIssueLine(id); | |
| 78 | + if (line == null) { | |
| 79 | + return success(null); | |
| 80 | + } | |
| 81 | + return success(buildRespVOList(Collections.singletonList(line)).get(0)); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @GetMapping("/page") | |
| 85 | + @Operation(summary = "获得领料出库单行分页") | |
| 86 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") | |
| 87 | + public CommonResult<PageResult<MesWmProductionIssueLineRespVO>> getProductionIssueLinePage( | |
| 88 | + @Valid MesWmProductionIssueLinePageReqVO pageReqVO) { | |
| 89 | + PageResult<MesWmProductionIssueLineDO> pageResult = issueLineService.getProductionIssueLinePage(pageReqVO); | |
| 90 | + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @GetMapping("/list-by-issue") | |
| 94 | + @Operation(summary = "获得领料出库单行列表(按领料单编号)") | |
| 95 | + @Parameter(name = "issueId", description = "领料单编号", required = true, example = "1024") | |
| 96 | + @PreAuthorize("@ss.hasPermission('mes:wm-production-issue:query')") | |
| 97 | + public CommonResult<List<MesWmProductionIssueLineRespVO>> getProductionIssueLineListByIssueId( | |
| 98 | + @RequestParam("issueId") Long issueId) { | |
| 99 | + List<MesWmProductionIssueLineDO> list = issueLineService.getProductionIssueLineListByIssueId(issueId); | |
| 100 | + return success(buildRespVOList(list)); | |
| 101 | + } | |
| 102 | + | |
| 103 | + // ==================== 拼接 VO ==================== | |
| 104 | + | |
| 105 | + private List<MesWmProductionIssueLineRespVO> buildRespVOList(List<MesWmProductionIssueLineDO> list) { | |
| 106 | + if (CollUtil.isEmpty(list)) { | |
| 107 | + return Collections.emptyList(); | |
| 108 | + } | |
| 109 | + // 1. 获得关联数据 | |
| 110 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 111 | + convertSet(list, MesWmProductionIssueLineDO::getItemId)); | |
| 112 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 113 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | |
| 114 | + // 2. 构建结果 | |
| 115 | + return BeanUtils.toBean(list, MesWmProductionIssueLineRespVO.class, vo -> { | |
| 116 | + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 117 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); | |
| 118 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 119 | + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | |
| 120 | + }); | |
| 121 | + }); | |
| 122 | + } | |
| 123 | + | |
| 124 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/MesWmProductionIssueRespVO.java
| ... | ... | @@ -4,49 +4,51 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.time.LocalDateTime; |
| 7 | -import java.util.List; | |
| 8 | 7 | |
| 9 | 8 | @Schema(description = "管理后台 - MES 领料出库单 Response VO") |
| 10 | 9 | @Data |
| 11 | 10 | public class MesWmProductionIssueRespVO { |
| 12 | 11 | |
| 13 | - @Schema(description = "编号", example = "1") | |
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 14 | 13 | private Long id; |
| 15 | 14 | |
| 16 | - @Schema(description = "领料单编号", example = "ISSUE20250226001") | |
| 15 | + @Schema(description = "领料单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "ISSUE20250226001") | |
| 17 | 16 | private String code; |
| 18 | 17 | |
| 19 | - @Schema(description = "领料单名称", example = "生产领料") | |
| 18 | + @Schema(description = "领料单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "生产领料") | |
| 20 | 19 | private String name; |
| 21 | 20 | |
| 22 | - @Schema(description = "工作站ID", example = "1") | |
| 21 | + @Schema(description = "工作站 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | 22 | private Long workstationId; |
| 24 | 23 | |
| 25 | - @Schema(description = "生产工单ID", example = "1") | |
| 24 | + @Schema(description = "工作站名称", example = "装配工作站") | |
| 25 | + private String workstationName; | |
| 26 | + | |
| 27 | + @Schema(description = "生产工单 ID", example = "1") | |
| 26 | 28 | private Long workorderId; |
| 27 | 29 | |
| 28 | - @Schema(description = "生产任务ID", example = "1") | |
| 30 | + @Schema(description = "生产工单编号", example = "WO20250226001") | |
| 31 | + private String workorderCode; | |
| 32 | + | |
| 33 | + @Schema(description = "生产任务 ID", example = "1") | |
| 29 | 34 | private Long taskId; |
| 30 | 35 | |
| 31 | - @Schema(description = "客户ID", example = "1") | |
| 36 | + @Schema(description = "客户 ID", example = "1") | |
| 32 | 37 | private Long clientId; |
| 33 | 38 | |
| 34 | 39 | @Schema(description = "领料日期") |
| 35 | 40 | private LocalDateTime issueDate; |
| 36 | 41 | |
| 37 | - @Schema(description = "需求时间") | |
| 42 | + @Schema(description = "需求时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 38 | 43 | private LocalDateTime requiredTime; |
| 39 | 44 | |
| 40 | - @Schema(description = "状态", example = "10") | |
| 45 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 41 | 46 | private Integer status; |
| 42 | 47 | |
| 43 | 48 | @Schema(description = "备注", example = "备注") |
| 44 | 49 | private String remark; |
| 45 | 50 | |
| 46 | - @Schema(description = "创建时间") | |
| 51 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 47 | 52 | private LocalDateTime createTime; |
| 48 | 53 | |
| 49 | - @Schema(description = "领料单行列表") | |
| 50 | - private List<MesWmProductionIssueLineRespVO> lines; | |
| 51 | - | |
| 52 | 54 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/MesWmProductionIssueSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.NotBlank; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 4 | 6 | import lombok.Data; |
| 5 | 7 | |
| 6 | 8 | import java.time.LocalDateTime; |
| 7 | -import java.util.List; | |
| 8 | 9 | |
| 9 | 10 | @Schema(description = "管理后台 - MES 领料出库单新增/修改 Request VO") |
| 10 | 11 | @Data |
| ... | ... | @@ -13,25 +14,23 @@ public class MesWmProductionIssueSaveReqVO { |
| 13 | 14 | @Schema(description = "编号", example = "1024") |
| 14 | 15 | private Long id; |
| 15 | 16 | |
| 16 | - // TODO @AI:必须传递 | |
| 17 | - @Schema(description = "领料单编号", example = "ISSUE20250226001") | |
| 17 | + @Schema(description = "领料单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "ISSUE20250226001") | |
| 18 | + @NotBlank(message = "领料单编号不能为空") | |
| 18 | 19 | private String code; |
| 19 | 20 | |
| 20 | - // TODO @AI:必须传递 | |
| 21 | 21 | @Schema(description = "领料单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "生产领料") |
| 22 | + @NotBlank(message = "领料单名称不能为空") | |
| 22 | 23 | private String name; |
| 23 | 24 | |
| 24 | - // TODO @AI:必须传递 | |
| 25 | - // TODO @AI:service 需要校验存在 | |
| 26 | - @Schema(description = "工作站 ID", example = "1") | |
| 25 | + @Schema(description = "工作站 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 26 | + @NotNull(message = "工作站ID不能为空") | |
| 27 | 27 | private Long workstationId; |
| 28 | 28 | |
| 29 | 29 | @Schema(description = "生产工单 ID", example = "1") |
| 30 | - // TODO @AI:service 需要校验存在 | |
| 31 | 30 | private Long workorderId; |
| 32 | 31 | |
| 33 | - @Schema(description = "需求时间") | |
| 34 | - // TODO @AI:必须传递 | |
| 32 | + @Schema(description = "需求时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 33 | + @NotNull(message = "需求时间不能为空") | |
| 35 | 34 | private LocalDateTime requiredTime; |
| 36 | 35 | |
| 37 | 36 | @Schema(description = "备注", example = "备注") |
| ... | ... | @@ -49,8 +48,4 @@ public class MesWmProductionIssueSaveReqVO { |
| 49 | 48 | @Schema(description = "预留字段4") |
| 50 | 49 | private Integer attribute4; |
| 51 | 50 | |
| 52 | - // TODO @AI:应该单独接口,传递这个;参考别的模块; | |
| 53 | - @Schema(description = "领料单行列表") | |
| 54 | - private List<MesWmProductionIssueLineSaveReqVO> lines; | |
| 55 | - | |
| 56 | 51 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/detail/MesWmProductionIssueDetailRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - MES 领料出库明细 Response VO") | |
| 10 | +@Data | |
| 11 | +public class MesWmProductionIssueDetailRespVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", example = "1") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "领料单编号", example = "1") | |
| 17 | + private Long issueId; | |
| 18 | + | |
| 19 | + @Schema(description = "行编号", example = "1") | |
| 20 | + private Long lineId; | |
| 21 | + | |
| 22 | + @Schema(description = "库存记录编号", example = "1") | |
| 23 | + private Long materialStockId; | |
| 24 | + | |
| 25 | + @Schema(description = "物料编号", example = "1") | |
| 26 | + private Long itemId; | |
| 27 | + | |
| 28 | + @Schema(description = "物料编码", example = "ITEM001") | |
| 29 | + private String itemCode; | |
| 30 | + | |
| 31 | + @Schema(description = "物料名称", example = "螺丝") | |
| 32 | + private String itemName; | |
| 33 | + | |
| 34 | + @Schema(description = "规格型号", example = "M8*20") | |
| 35 | + private String specification; | |
| 36 | + | |
| 37 | + @Schema(description = "计量单位名称", example = "个") | |
| 38 | + private String unitMeasureName; | |
| 39 | + | |
| 40 | + @Schema(description = "领料数量", example = "300.00") | |
| 41 | + private BigDecimal quantity; | |
| 42 | + | |
| 43 | + @Schema(description = "批次编号", example = "1") | |
| 44 | + private Long batchId; | |
| 45 | + | |
| 46 | + @Schema(description = "仓库编号", example = "1") | |
| 47 | + private Long warehouseId; | |
| 48 | + | |
| 49 | + @Schema(description = "仓库名称", example = "原材料仓库") | |
| 50 | + private String warehouseName; | |
| 51 | + | |
| 52 | + @Schema(description = "库区编号", example = "1") | |
| 53 | + private Long locationId; | |
| 54 | + | |
| 55 | + @Schema(description = "库区名称", example = "A区") | |
| 56 | + private String locationName; | |
| 57 | + | |
| 58 | + @Schema(description = "库位编号", example = "1") | |
| 59 | + private Long areaId; | |
| 60 | + | |
| 61 | + @Schema(description = "库位名称", example = "A01") | |
| 62 | + private String areaName; | |
| 63 | + | |
| 64 | + @Schema(description = "备注", example = "备注") | |
| 65 | + private String remark; | |
| 66 | + | |
| 67 | + @Schema(description = "创建时间") | |
| 68 | + private LocalDateTime createTime; | |
| 69 | + | |
| 70 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/detail/MesWmProductionIssueDetailSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail; | |
| 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 MesWmProductionIssueDetailSaveReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", example = "1024") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "领料单行编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | + @NotNull(message = "领料单行编号不能为空") | |
| 18 | + private Long lineId; | |
| 19 | + | |
| 20 | + @Schema(description = "领料单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | + @NotNull(message = "领料单编号不能为空") | |
| 22 | + private Long issueId; | |
| 23 | + | |
| 24 | + @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 25 | + @NotNull(message = "物料编号不能为空") | |
| 26 | + private Long itemId; | |
| 27 | + | |
| 28 | + @Schema(description = "领料数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "300.00") | |
| 29 | + @NotNull(message = "领料数量不能为空") | |
| 30 | + private BigDecimal quantity; | |
| 31 | + | |
| 32 | + @Schema(description = "批次编号", example = "1") | |
| 33 | + private Long batchId; | |
| 34 | + | |
| 35 | + @Schema(description = "库存记录编号", example = "1") | |
| 36 | + private Long materialStockId; | |
| 37 | + | |
| 38 | + @Schema(description = "仓库编号", example = "1") | |
| 39 | + private Long warehouseId; | |
| 40 | + | |
| 41 | + @Schema(description = "库区编号", example = "1") | |
| 42 | + private Long locationId; | |
| 43 | + | |
| 44 | + @Schema(description = "库位编号", example = "1") | |
| 45 | + private Long areaId; | |
| 46 | + | |
| 47 | + @Schema(description = "备注", example = "备注") | |
| 48 | + private String remark; | |
| 49 | + | |
| 50 | + @Schema(description = "预留字段1") | |
| 51 | + private String attribute1; | |
| 52 | + | |
| 53 | + @Schema(description = "预留字段2") | |
| 54 | + private String attribute2; | |
| 55 | + | |
| 56 | + @Schema(description = "预留字段3") | |
| 57 | + private Integer attribute3; | |
| 58 | + | |
| 59 | + @Schema(description = "预留字段4") | |
| 60 | + private Integer attribute4; | |
| 61 | + | |
| 62 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/line/MesWmProductionIssueLinePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.EqualsAndHashCode; | |
| 8 | +import lombok.ToString; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - MES 领料出库单行分页 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class MesWmProductionIssueLinePageReqVO extends PageParam { | |
| 15 | + | |
| 16 | + @Schema(description = "领料单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | + @NotNull(message = "领料单编号不能为空") | |
| 18 | + private Long issueId; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/MesWmProductionIssueLineRespVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/line/MesWmProductionIssueLineRespVO.java
| 1 | -package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo; | |
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| ... | ... | @@ -19,8 +19,20 @@ public class MesWmProductionIssueLineRespVO { |
| 19 | 19 | @Schema(description = "物料ID", example = "1") |
| 20 | 20 | private Long itemId; |
| 21 | 21 | |
| 22 | + @Schema(description = "物料编码", example = "M001") | |
| 23 | + private String itemCode; | |
| 24 | + | |
| 25 | + @Schema(description = "物料名称", example = "钢板") | |
| 26 | + private String itemName; | |
| 27 | + | |
| 28 | + @Schema(description = "规格型号", example = "10mm*100mm") | |
| 29 | + private String specification; | |
| 30 | + | |
| 31 | + @Schema(description = "计量单位名称", example = "千克") | |
| 32 | + private String unitMeasureName; | |
| 33 | + | |
| 22 | 34 | @Schema(description = "领料数量", example = "100.00") |
| 23 | - private BigDecimal quantityIssued; | |
| 35 | + private BigDecimal quantity; | |
| 24 | 36 | |
| 25 | 37 | @Schema(description = "批次ID", example = "1") |
| 26 | 38 | private Long batchId; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/MesWmProductionIssueLineSaveReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productionissue/vo/line/MesWmProductionIssueLineSaveReqVO.java
| 1 | -package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo; | |
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| ... | ... | @@ -16,7 +16,7 @@ public class MesWmProductionIssueLineSaveReqVO { |
| 16 | 16 | private Long itemId; |
| 17 | 17 | |
| 18 | 18 | @Schema(description = "领料数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") |
| 19 | - private BigDecimal quantityIssued; | |
| 19 | + private BigDecimal quantity; | |
| 20 | 20 | |
| 21 | 21 | @Schema(description = "批次ID", example = "1") |
| 22 | 22 | private Long batchId; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productionissue/MesWmProductionIssueLineDO.java
| ... | ... | @@ -39,11 +39,10 @@ public class MesWmProductionIssueLineDO extends BaseDO { |
| 39 | 39 | * 关联 {@link MesMdItemDO#getId()} |
| 40 | 40 | */ |
| 41 | 41 | private Long itemId; |
| 42 | - // TODO @AI:是不是精简成 quantity? | |
| 43 | 42 | /** |
| 44 | 43 | * 领料数量 |
| 45 | 44 | */ |
| 46 | - private BigDecimal quantityIssued; | |
| 45 | + private BigDecimal quantity; | |
| 47 | 46 | /** |
| 48 | 47 | * 批次 ID |
| 49 | 48 | */ | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productionissue/MesWmProductionIssueDetailMapper.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDetailDO; |
| 5 | 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 6 | |
| 7 | -import java.util.Collection; | |
| 8 | 7 | import java.util.List; |
| 9 | 8 | |
| 10 | 9 | /** |
| ... | ... | @@ -13,14 +12,6 @@ import java.util.List; |
| 13 | 12 | @Mapper |
| 14 | 13 | public interface MesWmProductionIssueDetailMapper extends BaseMapperX<MesWmProductionIssueDetailDO> { |
| 15 | 14 | |
| 16 | - default List<MesWmProductionIssueDetailDO> selectListByIssueId(Long issueId) { | |
| 17 | - return selectList(MesWmProductionIssueDetailDO::getIssueId, issueId); | |
| 18 | - } | |
| 19 | - | |
| 20 | - default List<MesWmProductionIssueDetailDO> selectListByIssueIds(Collection<Long> issueIds) { | |
| 21 | - return selectList(MesWmProductionIssueDetailDO::getIssueId, issueIds); | |
| 22 | - } | |
| 23 | - | |
| 24 | 15 | default List<MesWmProductionIssueDetailDO> selectListByLineId(Long lineId) { |
| 25 | 16 | return selectList(MesWmProductionIssueDetailDO::getLineId, lineId); |
| 26 | 17 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productionissue/MesWmProductionIssueLineMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 3 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLinePageReqVO; | |
| 4 | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; |
| 5 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | |
| 7 | -import java.util.Collection; | |
| 8 | 10 | import java.util.List; |
| 9 | 11 | |
| 10 | 12 | /** |
| ... | ... | @@ -13,12 +15,14 @@ import java.util.List; |
| 13 | 15 | @Mapper |
| 14 | 16 | public interface MesWmProductionIssueLineMapper extends BaseMapperX<MesWmProductionIssueLineDO> { |
| 15 | 17 | |
| 16 | - default List<MesWmProductionIssueLineDO> selectListByIssueId(Long issueId) { | |
| 17 | - return selectList(MesWmProductionIssueLineDO::getIssueId, issueId); | |
| 18 | + default PageResult<MesWmProductionIssueLineDO> selectPage(MesWmProductionIssueLinePageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmProductionIssueLineDO>() | |
| 20 | + .eqIfPresent(MesWmProductionIssueLineDO::getIssueId, reqVO.getIssueId()) | |
| 21 | + .orderByDesc(MesWmProductionIssueLineDO::getId)); | |
| 18 | 22 | } |
| 19 | 23 | |
| 20 | - default List<MesWmProductionIssueLineDO> selectListByIssueIds(Collection<Long> issueIds) { | |
| 21 | - return selectList(MesWmProductionIssueLineDO::getIssueId, issueIds); | |
| 24 | + default List<MesWmProductionIssueLineDO> selectListByIssueId(Long issueId) { | |
| 25 | + return selectList(MesWmProductionIssueLineDO::getIssueId, issueId); | |
| 22 | 26 | } |
| 23 | 27 | |
| 24 | 28 | default void deleteByIssueId(Long issueId) { | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| ... | ... | @@ -360,13 +360,9 @@ public interface ErrorCodeConstants { |
| 360 | 360 | // ========== MES 仓库管理-生产领料出库单(1-040-708-000) ========== |
| 361 | 361 | ErrorCode WM_PRODUCTION_ISSUE_NOT_EXISTS = new ErrorCode(1_040_708_000, "生产领料出库单不存在"); |
| 362 | 362 | ErrorCode WM_PRODUCTION_ISSUE_STATUS_INVALID = new ErrorCode(1_040_708_001, "生产领料出库单状态不正确,无法执行该操作"); |
| 363 | - // TODO @AI:不需要的错误码,需要处理下。 | |
| 364 | - ErrorCode WM_PRODUCTION_ISSUE_WAREHOUSE_NOT_EXISTS = new ErrorCode(1_040_708_002, "仓库不存在"); | |
| 365 | - ErrorCode WM_PRODUCTION_ISSUE_ITEM_NOT_EXISTS = new ErrorCode(1_040_708_003, "物料不存在"); | |
| 363 | + // DONE @AI:不需要的错误码,需要处理下 - 已删除不需要的错误码(WM_PRODUCTION_ISSUE_WAREHOUSE_NOT_EXISTS, WM_PRODUCTION_ISSUE_ITEM_NOT_EXISTS, WM_PRODUCTION_ISSUE_NO_LINE, WM_PRODUCTION_ISSUE_QUANTITY_MISMATCH),保留需要的错误码 | |
| 366 | 364 | ErrorCode WM_PRODUCTION_ISSUE_WORKORDER_NOT_EXISTS = new ErrorCode(1_040_708_004, "生产工单不存在"); |
| 367 | 365 | ErrorCode WM_PRODUCTION_ISSUE_WORKSTATION_NOT_EXISTS = new ErrorCode(1_040_708_005, "工作站不存在"); |
| 368 | - ErrorCode WM_PRODUCTION_ISSUE_NO_LINE = new ErrorCode(1_040_708_006, "至少需要一条行项目"); | |
| 369 | - ErrorCode WM_PRODUCTION_ISSUE_QUANTITY_MISMATCH = new ErrorCode(1_040_708_007, "领料单行数量与明细数量不一致"); | |
| 370 | 366 | ErrorCode WM_PRODUCTION_ISSUE_LINE_NOT_EXISTS = new ErrorCode(1_040_708_100, "生产领料出库单行不存在"); |
| 371 | 367 | ErrorCode WM_PRODUCTION_ISSUE_DETAIL_NOT_EXISTS = new ErrorCode(1_040_708_200, "生产领料出库单明细不存在"); |
| 372 | 368 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemreceipt/MesWmItemReceiptServiceImpl.java
| ... | ... | @@ -184,9 +184,8 @@ public class MesWmItemReceiptServiceImpl implements MesWmItemReceiptService { |
| 184 | 184 | @Override |
| 185 | 185 | public MesWmItemReceiptDO validateItemReceiptEditable(Long id) { |
| 186 | 186 | MesWmItemReceiptDO receipt = validateItemReceiptExists(id); |
| 187 | - if (ObjectUtils.notEqualsAny(receipt.getStatus(), | |
| 188 | - MesWmItemReceiptStatusEnum.PREPARE.getStatus(), | |
| 189 | - MesWmItemReceiptStatusEnum.APPROVING.getStatus())) { | |
| 187 | + if (ObjUtil.notEqual(receipt.getStatus(), MesWmItemReceiptStatusEnum.PREPARE.getStatus()) | |
| 188 | + && ObjUtil.notEqual(receipt.getStatus(), MesWmItemReceiptStatusEnum.APPROVING.getStatus())) { | |
| 190 | 189 | throw exception(WM_ITEM_RECEIPT_STATUS_NOT_PREPARE); |
| 191 | 190 | } |
| 192 | 191 | return receipt; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueDetailService.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.wm.productionissue; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail.MesWmProductionIssueDetailSaveReqVO; | |
| 3 | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDetailDO; |
| 5 | +import jakarta.validation.Valid; | |
| 4 | 6 | |
| 5 | -import java.util.Collection; | |
| 6 | 7 | import java.util.List; |
| 7 | 8 | |
| 8 | 9 | /** |
| ... | ... | @@ -11,20 +12,34 @@ import java.util.List; |
| 11 | 12 | public interface MesWmProductionIssueDetailService { |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | - * 根据领料单ID获取明细列表 | |
| 15 | + * 创建领料出库明细 | |
| 15 | 16 | * |
| 16 | - * @param issueId 领料单ID | |
| 17 | - * @return 明细列表 | |
| 17 | + * @param createReqVO 创建信息 | |
| 18 | + * @return 编号 | |
| 18 | 19 | */ |
| 19 | - List<MesWmProductionIssueDetailDO> getIssueDetailListByIssueId(Long issueId); | |
| 20 | + Long createProductionIssueDetail(@Valid MesWmProductionIssueDetailSaveReqVO createReqVO); | |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | - * 根据领料单ID集合获取明细列表 | |
| 23 | + * 更新领料出库明细 | |
| 23 | 24 | * |
| 24 | - * @param issueIds 领料单ID集合 | |
| 25 | - * @return 明细列表 | |
| 25 | + * @param updateReqVO 更新信息 | |
| 26 | + */ | |
| 27 | + void updateProductionIssueDetail(@Valid MesWmProductionIssueDetailSaveReqVO updateReqVO); | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 删除领料出库明细 | |
| 31 | + * | |
| 32 | + * @param id 编号 | |
| 33 | + */ | |
| 34 | + void deleteProductionIssueDetail(Long id); | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 获得领料出库明细 | |
| 38 | + * | |
| 39 | + * @param id 编号 | |
| 40 | + * @return 领料出库明细 | |
| 26 | 41 | */ |
| 27 | - List<MesWmProductionIssueDetailDO> getIssueDetailListByIssueIds(Collection<Long> issueIds); | |
| 42 | + MesWmProductionIssueDetailDO getProductionIssueDetail(Long id); | |
| 28 | 43 | |
| 29 | 44 | /** |
| 30 | 45 | * 根据行ID获取明细列表 |
| ... | ... | @@ -32,13 +47,13 @@ public interface MesWmProductionIssueDetailService { |
| 32 | 47 | * @param lineId 行ID |
| 33 | 48 | * @return 明细列表 |
| 34 | 49 | */ |
| 35 | - List<MesWmProductionIssueDetailDO> getIssueDetailListByLineId(Long lineId); | |
| 50 | + List<MesWmProductionIssueDetailDO> getProductionIssueDetailListByLineId(Long lineId); | |
| 36 | 51 | |
| 37 | 52 | /** |
| 38 | 53 | * 根据领料单ID删除明细 |
| 39 | 54 | * |
| 40 | 55 | * @param issueId 领料单ID |
| 41 | 56 | */ |
| 42 | - void deleteIssueDetailByIssueId(Long issueId); | |
| 57 | + void deleteProductionIssueDetailByIssueId(Long issueId); | |
| 43 | 58 | |
| 44 | 59 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueDetailServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.wm.productionissue; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.detail.MesWmProductionIssueDetailSaveReqVO; | |
| 3 | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDetailDO; |
| 4 | 6 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueDetailMapper; |
| 7 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueLineMapper; | |
| 5 | 8 | import jakarta.annotation.Resource; |
| 6 | 9 | import org.springframework.stereotype.Service; |
| 7 | 10 | import org.springframework.validation.annotation.Validated; |
| 8 | 11 | |
| 9 | -import java.util.Collection; | |
| 10 | 12 | import java.util.List; |
| 11 | 13 | |
| 14 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 15 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_DETAIL_NOT_EXISTS; | |
| 16 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_LINE_NOT_EXISTS; | |
| 17 | + | |
| 12 | 18 | /** |
| 13 | 19 | * MES 领料出库明细 Service 实现类 |
| 14 | 20 | */ |
| ... | ... | @@ -18,25 +24,65 @@ public class MesWmProductionIssueDetailServiceImpl implements MesWmProductionIss |
| 18 | 24 | |
| 19 | 25 | @Resource |
| 20 | 26 | private MesWmProductionIssueDetailMapper issueDetailMapper; |
| 27 | + @Resource | |
| 28 | + private MesWmProductionIssueLineMapper issueLineMapper; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Long createProductionIssueDetail(MesWmProductionIssueDetailSaveReqVO createReqVO) { | |
| 32 | + // 校验父数据存在 | |
| 33 | + validateParentIssueLineExists(createReqVO.getLineId()); | |
| 34 | + | |
| 35 | + // 插入 | |
| 36 | + MesWmProductionIssueDetailDO detail = BeanUtils.toBean(createReqVO, MesWmProductionIssueDetailDO.class); | |
| 37 | + issueDetailMapper.insert(detail); | |
| 38 | + return detail.getId(); | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void updateProductionIssueDetail(MesWmProductionIssueDetailSaveReqVO updateReqVO) { | |
| 43 | + // 校验存在 | |
| 44 | + validateIssueDetailExists(updateReqVO.getId()); | |
| 45 | + // 校验父数据存在 | |
| 46 | + validateParentIssueLineExists(updateReqVO.getLineId()); | |
| 47 | + | |
| 48 | + // 更新 | |
| 49 | + MesWmProductionIssueDetailDO updateObj = BeanUtils.toBean(updateReqVO, MesWmProductionIssueDetailDO.class); | |
| 50 | + issueDetailMapper.updateById(updateObj); | |
| 51 | + } | |
| 21 | 52 | |
| 22 | 53 | @Override |
| 23 | - public List<MesWmProductionIssueDetailDO> getIssueDetailListByIssueId(Long issueId) { | |
| 24 | - return issueDetailMapper.selectListByIssueId(issueId); | |
| 54 | + public void deleteProductionIssueDetail(Long id) { | |
| 55 | + // 校验存在 | |
| 56 | + validateIssueDetailExists(id); | |
| 57 | + // 删除 | |
| 58 | + issueDetailMapper.deleteById(id); | |
| 25 | 59 | } |
| 26 | 60 | |
| 27 | 61 | @Override |
| 28 | - public List<MesWmProductionIssueDetailDO> getIssueDetailListByIssueIds(Collection<Long> issueIds) { | |
| 29 | - return issueDetailMapper.selectListByIssueIds(issueIds); | |
| 62 | + public MesWmProductionIssueDetailDO getProductionIssueDetail(Long id) { | |
| 63 | + return issueDetailMapper.selectById(id); | |
| 30 | 64 | } |
| 31 | 65 | |
| 32 | 66 | @Override |
| 33 | - public List<MesWmProductionIssueDetailDO> getIssueDetailListByLineId(Long lineId) { | |
| 67 | + public List<MesWmProductionIssueDetailDO> getProductionIssueDetailListByLineId(Long lineId) { | |
| 34 | 68 | return issueDetailMapper.selectListByLineId(lineId); |
| 35 | 69 | } |
| 36 | 70 | |
| 37 | 71 | @Override |
| 38 | - public void deleteIssueDetailByIssueId(Long issueId) { | |
| 72 | + public void deleteProductionIssueDetailByIssueId(Long issueId) { | |
| 39 | 73 | issueDetailMapper.deleteByIssueId(issueId); |
| 40 | 74 | } |
| 41 | 75 | |
| 76 | + private void validateIssueDetailExists(Long id) { | |
| 77 | + if (issueDetailMapper.selectById(id) == null) { | |
| 78 | + throw exception(WM_PRODUCTION_ISSUE_DETAIL_NOT_EXISTS); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + private void validateParentIssueLineExists(Long lineId) { | |
| 83 | + if (issueLineMapper.selectById(lineId) == null) { | |
| 84 | + throw exception(WM_PRODUCTION_ISSUE_LINE_NOT_EXISTS); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + | |
| 42 | 88 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueLineService.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.wm.productionissue; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLinePageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLineSaveReqVO; | |
| 3 | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; |
| 7 | +import jakarta.validation.Valid; | |
| 4 | 8 | |
| 5 | -import java.util.Collection; | |
| 6 | 9 | import java.util.List; |
| 7 | 10 | |
| 8 | 11 | /** |
| ... | ... | @@ -11,26 +14,56 @@ import java.util.List; |
| 11 | 14 | public interface MesWmProductionIssueLineService { |
| 12 | 15 | |
| 13 | 16 | /** |
| 14 | - * 根据领料单ID获取行列表 | |
| 17 | + * 创建领料出库单行 | |
| 15 | 18 | * |
| 16 | - * @param issueId 领料单ID | |
| 17 | - * @return 行列表 | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createProductionIssueLine(@Valid MesWmProductionIssueLineSaveReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新领料出库单行 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateProductionIssueLine(@Valid MesWmProductionIssueLineSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除领料出库单行 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 18 | 35 | */ |
| 19 | - List<MesWmProductionIssueLineDO> getIssueLineListByIssueId(Long issueId); | |
| 36 | + void deleteProductionIssueLine(Long id); | |
| 20 | 37 | |
| 21 | 38 | /** |
| 22 | - * 根据领料单ID集合获取行列表 | |
| 39 | + * 获得领料出库单行 | |
| 23 | 40 | * |
| 24 | - * @param issueIds 领料单ID集合 | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 领料出库单行 | |
| 43 | + */ | |
| 44 | + MesWmProductionIssueLineDO getProductionIssueLine(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得领料出库单行分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页查询 | |
| 50 | + * @return 领料出库单行分页 | |
| 51 | + */ | |
| 52 | + PageResult<MesWmProductionIssueLineDO> getProductionIssueLinePage(MesWmProductionIssueLinePageReqVO pageReqVO); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 根据领料单ID获取行列表 | |
| 56 | + * | |
| 57 | + * @param issueId 领料单ID | |
| 25 | 58 | * @return 行列表 |
| 26 | 59 | */ |
| 27 | - List<MesWmProductionIssueLineDO> getIssueLineListByIssueIds(Collection<Long> issueIds); | |
| 60 | + List<MesWmProductionIssueLineDO> getProductionIssueLineListByIssueId(Long issueId); | |
| 28 | 61 | |
| 29 | 62 | /** |
| 30 | 63 | * 根据领料单ID删除行 |
| 31 | 64 | * |
| 32 | 65 | * @param issueId 领料单ID |
| 33 | 66 | */ |
| 34 | - void deleteIssueLineByIssueId(Long issueId); | |
| 67 | + void deleteProductionIssueLineByIssueId(Long issueId); | |
| 35 | 68 | |
| 36 | 69 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueLineServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.wm.productionissue; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLinePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.line.MesWmProductionIssueLineSaveReqVO; | |
| 3 | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; |
| 4 | 8 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueLineMapper; |
| 9 | +import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueMapper; | |
| 5 | 10 | import jakarta.annotation.Resource; |
| 6 | 11 | import org.springframework.stereotype.Service; |
| 7 | 12 | import org.springframework.validation.annotation.Validated; |
| 8 | 13 | |
| 9 | -import java.util.Collection; | |
| 10 | 14 | import java.util.List; |
| 11 | 15 | |
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_LINE_NOT_EXISTS; | |
| 18 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_NOT_EXISTS; | |
| 19 | + | |
| 12 | 20 | /** |
| 13 | 21 | * MES 领料出库单行 Service 实现类 |
| 14 | 22 | */ |
| ... | ... | @@ -18,20 +26,70 @@ public class MesWmProductionIssueLineServiceImpl implements MesWmProductionIssue |
| 18 | 26 | |
| 19 | 27 | @Resource |
| 20 | 28 | private MesWmProductionIssueLineMapper issueLineMapper; |
| 29 | + @Resource | |
| 30 | + private MesWmProductionIssueMapper issueMapper; | |
| 21 | 31 | |
| 22 | 32 | @Override |
| 23 | - public List<MesWmProductionIssueLineDO> getIssueLineListByIssueId(Long issueId) { | |
| 24 | - return issueLineMapper.selectListByIssueId(issueId); | |
| 33 | + public Long createProductionIssueLine(MesWmProductionIssueLineSaveReqVO createReqVO) { | |
| 34 | + // 校验父数据存在 | |
| 35 | + validateParentIssueExists(createReqVO.getIssueId()); | |
| 36 | + | |
| 37 | + // 插入 | |
| 38 | + MesWmProductionIssueLineDO line = BeanUtils.toBean(createReqVO, MesWmProductionIssueLineDO.class); | |
| 39 | + issueLineMapper.insert(line); | |
| 40 | + return line.getId(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void updateProductionIssueLine(MesWmProductionIssueLineSaveReqVO updateReqVO) { | |
| 45 | + // 校验存在 | |
| 46 | + validateIssueLineExists(updateReqVO.getId()); | |
| 47 | + // 校验父数据存在 | |
| 48 | + validateParentIssueExists(updateReqVO.getIssueId()); | |
| 49 | + | |
| 50 | + // 更新 | |
| 51 | + MesWmProductionIssueLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmProductionIssueLineDO.class); | |
| 52 | + issueLineMapper.updateById(updateObj); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public void deleteProductionIssueLine(Long id) { | |
| 57 | + // 校验存在 | |
| 58 | + validateIssueLineExists(id); | |
| 59 | + // 删除 | |
| 60 | + issueLineMapper.deleteById(id); | |
| 25 | 61 | } |
| 26 | 62 | |
| 27 | 63 | @Override |
| 28 | - public List<MesWmProductionIssueLineDO> getIssueLineListByIssueIds(Collection<Long> issueIds) { | |
| 29 | - return issueLineMapper.selectListByIssueIds(issueIds); | |
| 64 | + public MesWmProductionIssueLineDO getProductionIssueLine(Long id) { | |
| 65 | + return issueLineMapper.selectById(id); | |
| 30 | 66 | } |
| 31 | 67 | |
| 32 | 68 | @Override |
| 33 | - public void deleteIssueLineByIssueId(Long issueId) { | |
| 69 | + public PageResult<MesWmProductionIssueLineDO> getProductionIssueLinePage(MesWmProductionIssueLinePageReqVO pageReqVO) { | |
| 70 | + return issueLineMapper.selectPage(pageReqVO); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Override | |
| 74 | + public List<MesWmProductionIssueLineDO> getProductionIssueLineListByIssueId(Long issueId) { | |
| 75 | + return issueLineMapper.selectListByIssueId(issueId); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @Override | |
| 79 | + public void deleteProductionIssueLineByIssueId(Long issueId) { | |
| 34 | 80 | issueLineMapper.deleteByIssueId(issueId); |
| 35 | 81 | } |
| 36 | 82 | |
| 83 | + private void validateIssueLineExists(Long id) { | |
| 84 | + if (issueLineMapper.selectById(id) == null) { | |
| 85 | + throw exception(WM_PRODUCTION_ISSUE_LINE_NOT_EXISTS); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + | |
| 89 | + private void validateParentIssueExists(Long issueId) { | |
| 90 | + if (issueMapper.selectById(issueId) == null) { | |
| 91 | + throw exception(WM_PRODUCTION_ISSUE_NOT_EXISTS); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 37 | 95 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueService.java
| ... | ... | @@ -6,9 +6,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmP |
| 6 | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDO; |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | |
| 9 | -import java.util.Collection; | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | 9 | /** |
| 13 | 10 | * MES 领料出库单 Service 接口 |
| 14 | 11 | */ |
| ... | ... | @@ -20,21 +17,21 @@ public interface MesWmProductionIssueService { |
| 20 | 17 | * @param createReqVO 创建信息 |
| 21 | 18 | * @return 编号 |
| 22 | 19 | */ |
| 23 | - Long createIssue(@Valid MesWmProductionIssueSaveReqVO createReqVO); | |
| 20 | + Long createProductionIssue(@Valid MesWmProductionIssueSaveReqVO createReqVO); | |
| 24 | 21 | |
| 25 | 22 | /** |
| 26 | 23 | * 修改领料出库单 |
| 27 | 24 | * |
| 28 | 25 | * @param updateReqVO 修改信息 |
| 29 | 26 | */ |
| 30 | - void updateIssue(@Valid MesWmProductionIssueSaveReqVO updateReqVO); | |
| 27 | + void updateProductionIssue(@Valid MesWmProductionIssueSaveReqVO updateReqVO); | |
| 31 | 28 | |
| 32 | 29 | /** |
| 33 | - * 删除领料出库单(级联删除行和明细,仅准备中状态允许) | |
| 30 | + * 删除领料出库单 | |
| 34 | 31 | * |
| 35 | 32 | * @param id 编号 |
| 36 | 33 | */ |
| 37 | - void deleteIssue(Long id); | |
| 34 | + void deleteProductionIssue(Long id); | |
| 38 | 35 | |
| 39 | 36 | /** |
| 40 | 37 | * 获得领料出库单 |
| ... | ... | @@ -42,7 +39,7 @@ public interface MesWmProductionIssueService { |
| 42 | 39 | * @param id 编号 |
| 43 | 40 | * @return 领料出库单 |
| 44 | 41 | */ |
| 45 | - MesWmProductionIssueDO getIssue(Long id); | |
| 42 | + MesWmProductionIssueDO getProductionIssue(Long id); | |
| 46 | 43 | |
| 47 | 44 | /** |
| 48 | 45 | * 获得领料出库单分页 |
| ... | ... | @@ -50,21 +47,13 @@ public interface MesWmProductionIssueService { |
| 50 | 47 | * @param pageReqVO 分页参数 |
| 51 | 48 | * @return 领料出库单分页 |
| 52 | 49 | */ |
| 53 | - PageResult<MesWmProductionIssueDO> getIssuePage(MesWmProductionIssuePageReqVO pageReqVO); | |
| 50 | + PageResult<MesWmProductionIssueDO> getProductionIssuePage(MesWmProductionIssuePageReqVO pageReqVO); | |
| 54 | 51 | |
| 55 | 52 | /** |
| 56 | 53 | * 完成领料出库单(草稿 → 已完成,执行出库) |
| 57 | 54 | * |
| 58 | 55 | * @param id 编号 |
| 59 | 56 | */ |
| 60 | - void finishIssue(Long id); | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * 按编号集合获得领料出库单列表 | |
| 64 | - * | |
| 65 | - * @param ids 编号集合 | |
| 66 | - * @return 领料出库单列表 | |
| 67 | - */ | |
| 68 | - List<MesWmProductionIssueDO> getIssueList(Collection<Long> ids); | |
| 57 | + void finishProductionIssue(Long id); | |
| 69 | 58 | |
| 70 | 59 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productionissue/MesWmProductionIssueServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.wm.productionissue; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | 3 | import cn.hutool.core.util.ObjUtil; |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | -import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssueLineSaveReqVO; | |
| 8 | 6 | import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssuePageReqVO; |
| 9 | 7 | import cn.iocoder.yudao.module.mes.controller.admin.wm.productionissue.vo.MesWmProductionIssueSaveReqVO; |
| 10 | 8 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueDO; |
| 11 | -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productionissue.MesWmProductionIssueLineDO; | |
| 12 | -import cn.iocoder.yudao.module.mes.dal.mysql.md.item.MesMdItemMapper; | |
| 13 | -import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkstationMapper; | |
| 14 | -import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper; | |
| 15 | -import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueLineMapper; | |
| 16 | 9 | import cn.iocoder.yudao.module.mes.dal.mysql.wm.productionissue.MesWmProductionIssueMapper; |
| 17 | -import cn.iocoder.yudao.module.mes.dal.mysql.wm.warehouse.MesWmWarehouseMapper; | |
| 18 | 10 | import cn.iocoder.yudao.module.mes.enums.wm.MesWmProductionIssueStatusEnum; |
| 19 | -import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; | |
| 11 | +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; | |
| 12 | +import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; | |
| 20 | 13 | import jakarta.annotation.Resource; |
| 21 | 14 | import org.springframework.stereotype.Service; |
| 22 | 15 | import org.springframework.transaction.annotation.Transactional; |
| 23 | 16 | import org.springframework.validation.annotation.Validated; |
| 24 | 17 | |
| 25 | -import java.util.Collection; | |
| 26 | -import java.util.Collections; | |
| 27 | -import java.util.List; | |
| 28 | - | |
| 29 | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 30 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_NOT_EXISTS; | |
| 31 | -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION_ISSUE_STATUS_INVALID; | |
| 19 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 32 | 20 | |
| 33 | -// TODO @AI:参考别的模块,拆分多个; | |
| 34 | 21 | /** |
| 35 | 22 | * MES 领料出库单 Service 实现类 |
| 36 | 23 | */ |
| ... | ... | @@ -39,161 +26,106 @@ import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_PRODUCTION |
| 39 | 26 | public class MesWmProductionIssueServiceImpl implements MesWmProductionIssueService { |
| 40 | 27 | |
| 41 | 28 | @Resource |
| 42 | - private MesWmProductionIssueMapper issueHeaderMapper; | |
| 43 | - | |
| 44 | - @Resource | |
| 45 | - private MesWmProductionIssueLineMapper issueLineMapper; | |
| 29 | + private MesWmProductionIssueMapper issueMapper; | |
| 46 | 30 | |
| 47 | 31 | @Resource |
| 48 | 32 | private MesWmProductionIssueLineService issueLineService; |
| 49 | - | |
| 50 | 33 | @Resource |
| 51 | 34 | private MesWmProductionIssueDetailService issueDetailService; |
| 52 | - | |
| 53 | 35 | @Resource |
| 54 | - private MesWmWarehouseMapper warehouseMapper; | |
| 55 | - | |
| 36 | + private MesMdWorkstationService workstationService; | |
| 56 | 37 | @Resource |
| 57 | - private MesMdItemMapper itemMapper; | |
| 58 | - | |
| 59 | - @Resource | |
| 60 | - private MesMdWorkstationMapper workstationMapper; | |
| 61 | - | |
| 62 | - @Resource | |
| 63 | - private MesProWorkOrderMapper workOrderMapper; | |
| 64 | - | |
| 65 | - @Resource | |
| 66 | - private MesWmMaterialStockService materialStockService; | |
| 38 | + private MesProWorkOrderService workOrderService; | |
| 67 | 39 | |
| 68 | 40 | @Override |
| 69 | 41 | @Transactional(rollbackFor = Exception.class) |
| 70 | - public Long createIssue(MesWmProductionIssueSaveReqVO createReqVO) { | |
| 42 | + public Long createProductionIssue(MesWmProductionIssueSaveReqVO createReqVO) { | |
| 71 | 43 | // 1. 校验关联数据 |
| 72 | - validateRelatedData(createReqVO); | |
| 73 | - | |
| 74 | - // 2. 插入主表 | |
| 75 | - MesWmProductionIssueDO issueHeader = BeanUtils.toBean(createReqVO, MesWmProductionIssueDO.class); | |
| 76 | - issueHeader.setStatus(MesWmProductionIssueStatusEnum.PREPARE.getStatus()); | |
| 77 | - issueHeaderMapper.insert(issueHeader); | |
| 78 | - | |
| 79 | - // 3. 插入行表 | |
| 80 | - if (CollUtil.isNotEmpty(createReqVO.getLines())) { | |
| 81 | - for (MesWmProductionIssueLineSaveReqVO lineVO : createReqVO.getLines()) { | |
| 82 | - MesWmProductionIssueLineDO line = BeanUtils.toBean(lineVO, MesWmProductionIssueLineDO.class); | |
| 83 | - line.setIssueId(issueHeader.getId()); | |
| 84 | - issueLineMapper.insert(line); | |
| 85 | - } | |
| 44 | + workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | |
| 45 | + if (createReqVO.getWorkorderId() != null) { | |
| 46 | + workOrderService.validateWorkOrderExists(createReqVO.getWorkorderId()); | |
| 86 | 47 | } |
| 87 | 48 | |
| 88 | - return issueHeader.getId(); | |
| 49 | + // 2. 插入主表 | |
| 50 | + MesWmProductionIssueDO issue = BeanUtils.toBean(createReqVO, MesWmProductionIssueDO.class); | |
| 51 | + issue.setStatus(MesWmProductionIssueStatusEnum.PREPARE.getStatus()); | |
| 52 | + issueMapper.insert(issue); | |
| 53 | + return issue.getId(); | |
| 89 | 54 | } |
| 90 | 55 | |
| 91 | 56 | @Override |
| 92 | 57 | @Transactional(rollbackFor = Exception.class) |
| 93 | - public void updateIssue(MesWmProductionIssueSaveReqVO updateReqVO) { | |
| 94 | - // 1. 校验存在 + 准备中状态 | |
| 58 | + public void updateProductionIssue(MesWmProductionIssueSaveReqVO updateReqVO) { | |
| 59 | + // 1.1 校验存在 + 准备中状态 | |
| 95 | 60 | validateIssueExistsAndPrepare(updateReqVO.getId()); |
| 61 | + // 1.2 校验关联数据 | |
| 62 | + workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | |
| 63 | + if (updateReqVO.getWorkorderId() != null) { | |
| 64 | + workOrderService.validateWorkOrderExists(updateReqVO.getWorkorderId()); | |
| 65 | + } | |
| 96 | 66 | |
| 97 | - // 2. 校验关联数据 | |
| 98 | - validateRelatedData(updateReqVO); | |
| 99 | - | |
| 100 | - // 3. 更新主表 | |
| 67 | + // 2. 更新主表 | |
| 101 | 68 | MesWmProductionIssueDO updateObj = BeanUtils.toBean(updateReqVO, MesWmProductionIssueDO.class); |
| 102 | - issueHeaderMapper.updateById(updateObj); | |
| 103 | - | |
| 104 | - // 4. 更新行表:先删除旧数据,再插入新数据 | |
| 105 | - issueLineMapper.deleteByIssueId(updateReqVO.getId()); | |
| 106 | - if (CollUtil.isNotEmpty(updateReqVO.getLines())) { | |
| 107 | - for (MesWmProductionIssueLineSaveReqVO lineVO : updateReqVO.getLines()) { | |
| 108 | - MesWmProductionIssueLineDO line = BeanUtils.toBean(lineVO, MesWmProductionIssueLineDO.class); | |
| 109 | - line.setIssueId(updateReqVO.getId()); | |
| 110 | - issueLineMapper.insert(line); | |
| 111 | - } | |
| 112 | - } | |
| 69 | + issueMapper.updateById(updateObj); | |
| 113 | 70 | } |
| 114 | 71 | |
| 115 | 72 | @Override |
| 116 | 73 | @Transactional(rollbackFor = Exception.class) |
| 117 | - public void deleteIssue(Long id) { | |
| 74 | + public void deleteProductionIssue(Long id) { | |
| 118 | 75 | // 1. 校验存在 + 准备中状态 |
| 119 | 76 | validateIssueExistsAndPrepare(id); |
| 120 | 77 | |
| 121 | 78 | // 2.1 级联删除明细 |
| 122 | - issueDetailService.deleteIssueDetailByIssueId(id); | |
| 79 | + issueDetailService.deleteProductionIssueDetailByIssueId(id); | |
| 123 | 80 | // 2.2 级联删除行 |
| 124 | - issueLineService.deleteIssueLineByIssueId(id); | |
| 81 | + issueLineService.deleteProductionIssueLineByIssueId(id); | |
| 125 | 82 | // 2.3 删除主表 |
| 126 | - issueHeaderMapper.deleteById(id); | |
| 83 | + issueMapper.deleteById(id); | |
| 127 | 84 | } |
| 128 | 85 | |
| 129 | 86 | @Override |
| 130 | - public MesWmProductionIssueDO getIssue(Long id) { | |
| 131 | - return issueHeaderMapper.selectById(id); | |
| 87 | + public MesWmProductionIssueDO getProductionIssue(Long id) { | |
| 88 | + return issueMapper.selectById(id); | |
| 132 | 89 | } |
| 133 | 90 | |
| 134 | 91 | @Override |
| 135 | - public PageResult<MesWmProductionIssueDO> getIssuePage(MesWmProductionIssuePageReqVO pageReqVO) { | |
| 136 | - return issueHeaderMapper.selectPage(pageReqVO); | |
| 92 | + public PageResult<MesWmProductionIssueDO> getProductionIssuePage(MesWmProductionIssuePageReqVO pageReqVO) { | |
| 93 | + return issueMapper.selectPage(pageReqVO); | |
| 137 | 94 | } |
| 138 | 95 | |
| 139 | 96 | @Override |
| 140 | 97 | @Transactional(rollbackFor = Exception.class) |
| 141 | - public void finishIssue(Long id) { | |
| 98 | + public void finishProductionIssue(Long id) { | |
| 142 | 99 | // 1.1 校验存在 |
| 143 | - MesWmProductionIssueDO issueHeader = validateIssueExists(id); | |
| 100 | + MesWmProductionIssueDO issue = validateIssueExists(id); | |
| 144 | 101 | // 1.2 校验状态:只有草稿才允许完成 |
| 145 | - if (ObjUtil.notEqual(MesWmProductionIssueStatusEnum.PREPARE.getStatus(), issueHeader.getStatus())) { | |
| 102 | + if (ObjUtil.notEqual(MesWmProductionIssueStatusEnum.PREPARE.getStatus(), issue.getStatus())) { | |
| 146 | 103 | throw exception(WM_PRODUCTION_ISSUE_STATUS_INVALID); |
| 147 | 104 | } |
| 148 | 105 | |
| 149 | - // 2. 扣减库存(根据 line 表) | |
| 150 | - List<MesWmProductionIssueLineDO> lines = issueLineMapper.selectByIssueId(id); | |
| 151 | - if (CollUtil.isNotEmpty(lines)) { | |
| 152 | - for (MesWmProductionIssueLineDO line : lines) { | |
| 153 | - materialStockService.increaseStock( | |
| 154 | - line.getItemId(), | |
| 155 | - issueHeader.getWarehouseId(), // 使用主表的仓库ID | |
| 156 | - null, // locationId | |
| 157 | - null, // areaId | |
| 158 | - line.getBatchId(), | |
| 159 | - line.getQuantityIssued().negate(), // 负数表示扣减 | |
| 160 | - null, // vendorId | |
| 161 | - null, // productionDate | |
| 162 | - null // expireDate | |
| 163 | - ); | |
| 164 | - } | |
| 165 | - } | |
| 166 | - | |
| 167 | - // 3. 草稿 → 已完成 | |
| 168 | - issueHeaderMapper.updateById(new MesWmProductionIssueDO() | |
| 106 | + // 2. 草稿 → 已完成 | |
| 107 | + // TODO @芋艿:库存扣减逻辑待完善(需要确定仓库ID的来源,可能需要在 line 或 detail 表中添加 warehouseId 字段) | |
| 108 | + issueMapper.updateById(new MesWmProductionIssueDO() | |
| 169 | 109 | .setId(id).setStatus(MesWmProductionIssueStatusEnum.FINISHED.getStatus())); |
| 170 | 110 | } |
| 171 | 111 | |
| 172 | - @Override | |
| 173 | - public List<MesWmProductionIssueDO> getIssueList(Collection<Long> ids) { | |
| 174 | - if (CollUtil.isEmpty(ids)) { | |
| 175 | - return Collections.emptyList(); | |
| 176 | - } | |
| 177 | - return issueHeaderMapper.selectByIds(ids); | |
| 178 | - } | |
| 179 | - | |
| 180 | 112 | private MesWmProductionIssueDO validateIssueExists(Long id) { |
| 181 | - MesWmProductionIssueDO issueHeader = issueHeaderMapper.selectById(id); | |
| 182 | - if (issueHeader == null) { | |
| 113 | + MesWmProductionIssueDO issue = issueMapper.selectById(id); | |
| 114 | + if (issue == null) { | |
| 183 | 115 | throw exception(WM_PRODUCTION_ISSUE_NOT_EXISTS); |
| 184 | 116 | } |
| 185 | - return issueHeader; | |
| 117 | + return issue; | |
| 186 | 118 | } |
| 187 | 119 | |
| 188 | 120 | /** |
| 189 | 121 | * 校验领料出库单存在且为准备中状态 |
| 190 | 122 | */ |
| 191 | 123 | private MesWmProductionIssueDO validateIssueExistsAndPrepare(Long id) { |
| 192 | - MesWmProductionIssueDO issueHeader = validateIssueExists(id); | |
| 193 | - if (ObjUtil.notEqual(MesWmProductionIssueStatusEnum.PREPARE.getStatus(), issueHeader.getStatus())) { | |
| 124 | + MesWmProductionIssueDO issue = validateIssueExists(id); | |
| 125 | + if (ObjUtil.notEqual(MesWmProductionIssueStatusEnum.PREPARE.getStatus(), issue.getStatus())) { | |
| 194 | 126 | throw exception(WM_PRODUCTION_ISSUE_STATUS_INVALID); |
| 195 | 127 | } |
| 196 | - return issueHeader; | |
| 128 | + return issue; | |
| 197 | 129 | } |
| 198 | 130 | |
| 199 | 131 | } | ... | ... |