Commit 067890339a8a13e6501232fd9171d5916876f4d9
1 parent
67294192
✨ feat(mes): 新增生产任务投料功能及相关请求/响应对象
Showing
8 changed files
with
587 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/MesProTaskIssueController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task; | |
| 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.object.BeanUtils; | |
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssuePageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssueRespVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssueSaveReqVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskIssueDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 14 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 15 | +import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskIssueService; | |
| 16 | +import io.swagger.v3.oas.annotations.Operation; | |
| 17 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 18 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 19 | +import jakarta.annotation.Resource; | |
| 20 | +import jakarta.validation.Valid; | |
| 21 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 22 | +import org.springframework.validation.annotation.Validated; | |
| 23 | +import org.springframework.web.bind.annotation.*; | |
| 24 | + | |
| 25 | +import java.util.Collections; | |
| 26 | +import java.util.List; | |
| 27 | +import java.util.Map; | |
| 28 | + | |
| 29 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 31 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 32 | + | |
| 33 | +// TODO @芋艿:【对齐】前端没地方调用,这里只先写后端代码; | |
| 34 | +@Tag(name = "管理后台 - MES 生产任务投料") | |
| 35 | +@RestController | |
| 36 | +@RequestMapping("/mes/pro/task-issue") | |
| 37 | +@Validated | |
| 38 | +public class MesProTaskIssueController { | |
| 39 | + | |
| 40 | + @Resource | |
| 41 | + private MesProTaskIssueService taskIssueService; | |
| 42 | + | |
| 43 | + @Resource | |
| 44 | + private MesMdItemService itemService; | |
| 45 | + | |
| 46 | + @Resource | |
| 47 | + private MesMdUnitMeasureService unitMeasureService; | |
| 48 | + | |
| 49 | + @PostMapping("/create") | |
| 50 | + @Operation(summary = "创建生产任务投料") | |
| 51 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:create')") | |
| 52 | + public CommonResult<Long> createTaskIssue(@Valid @RequestBody MesProTaskIssueSaveReqVO createReqVO) { | |
| 53 | + return success(taskIssueService.createTaskIssue(createReqVO)); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @PutMapping("/update") | |
| 57 | + @Operation(summary = "更新生产任务投料") | |
| 58 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:update')") | |
| 59 | + public CommonResult<Boolean> updateTaskIssue(@Valid @RequestBody MesProTaskIssueSaveReqVO updateReqVO) { | |
| 60 | + taskIssueService.updateTaskIssue(updateReqVO); | |
| 61 | + return success(true); | |
| 62 | + } | |
| 63 | + | |
| 64 | + @DeleteMapping("/delete") | |
| 65 | + @Operation(summary = "删除生产任务投料") | |
| 66 | + @Parameter(name = "id", description = "编号", required = true) | |
| 67 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:delete')") | |
| 68 | + public CommonResult<Boolean> deleteTaskIssue(@RequestParam("id") Long id) { | |
| 69 | + taskIssueService.deleteTaskIssue(id); | |
| 70 | + return success(true); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @GetMapping("/get") | |
| 74 | + @Operation(summary = "获得生产任务投料") | |
| 75 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 76 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:query')") | |
| 77 | + public CommonResult<MesProTaskIssueRespVO> getTaskIssue(@RequestParam("id") Long id) { | |
| 78 | + MesProTaskIssueDO taskIssue = taskIssueService.getTaskIssue(id); | |
| 79 | + if (taskIssue == null) { | |
| 80 | + return success(null); | |
| 81 | + } | |
| 82 | + return success(buildIssueRespVOList(List.of(taskIssue)).get(0)); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @GetMapping("/page") | |
| 86 | + @Operation(summary = "获得生产任务投料分页") | |
| 87 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:query')") | |
| 88 | + public CommonResult<PageResult<MesProTaskIssueRespVO>> getTaskIssuePage(@Valid MesProTaskIssuePageReqVO pageReqVO) { | |
| 89 | + PageResult<MesProTaskIssueDO> pageResult = taskIssueService.getTaskIssuePage(pageReqVO); | |
| 90 | + return success(new PageResult<>(buildIssueRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 91 | + } | |
| 92 | + | |
| 93 | + @GetMapping("/list-by-task") | |
| 94 | + @Operation(summary = "根据任务获得投料列表") | |
| 95 | + @Parameter(name = "taskId", description = "任务编号", required = true) | |
| 96 | + @PreAuthorize("@ss.hasPermission('mes:pro-task-issue:query')") | |
| 97 | + public CommonResult<List<MesProTaskIssueRespVO>> getTaskIssueListByTask(@RequestParam("taskId") Long taskId) { | |
| 98 | + List<MesProTaskIssueDO> list = taskIssueService.getTaskIssueListByTaskId(taskId); | |
| 99 | + return success(buildIssueRespVOList(list)); | |
| 100 | + } | |
| 101 | + | |
| 102 | + // ==================== 拼接 VO ==================== | |
| 103 | + | |
| 104 | + private List<MesProTaskIssueRespVO> buildIssueRespVOList(List<MesProTaskIssueDO> list) { | |
| 105 | + if (CollUtil.isEmpty(list)) { | |
| 106 | + return Collections.emptyList(); | |
| 107 | + } | |
| 108 | + // 批量查询关联数据 | |
| 109 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 110 | + convertSet(list, MesProTaskIssueDO::getItemId)); | |
| 111 | + Map<Long, MesMdUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( | |
| 112 | + convertSet(list, MesProTaskIssueDO::getUnitMeasureId)); | |
| 113 | + // 拼接 VO | |
| 114 | + return cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList(list, issue -> { | |
| 115 | + MesProTaskIssueRespVO vo = BeanUtils.toBean(issue, MesProTaskIssueRespVO.class); | |
| 116 | + findAndThen(itemMap, issue.getItemId(), item -> | |
| 117 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setItemSpec(item.getSpecification())); | |
| 118 | + findAndThen(unitMap, issue.getUnitMeasureId(), unit -> | |
| 119 | + vo.setUnitMeasureName(unit.getName())); | |
| 120 | + return vo; | |
| 121 | + }); | |
| 122 | + } | |
| 123 | + | |
| 124 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskIssuePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - MES 生产任务投料分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class MesProTaskIssuePageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "生产任务编号", example = "1") | |
| 21 | + private Long taskId; | |
| 22 | + | |
| 23 | + @Schema(description = "生产工单编号", example = "1") | |
| 24 | + private Long workOrderId; | |
| 25 | + | |
| 26 | + @Schema(description = "产品物料编号", example = "100") | |
| 27 | + private Long itemId; | |
| 28 | + | |
| 29 | + @Schema(description = "来源单据类型", example = "MATERIAL_ISSUE") | |
| 30 | + private String sourceDocType; | |
| 31 | + | |
| 32 | + @Schema(description = "创建时间") | |
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 34 | + private LocalDateTime[] createTime; | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskIssueRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo; | |
| 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 MesProTaskIssueRespVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "生产任务编号", example = "1") | |
| 17 | + private Long taskId; | |
| 18 | + | |
| 19 | + @Schema(description = "生产工单编号", example = "1") | |
| 20 | + private Long workOrderId; | |
| 21 | + | |
| 22 | + @Schema(description = "工作站编号", example = "1") | |
| 23 | + private Long workstationId; | |
| 24 | + | |
| 25 | + @Schema(description = "来源单据编号", example = "1") | |
| 26 | + private Long sourceDocId; | |
| 27 | + | |
| 28 | + @Schema(description = "来源单据编码", example = "DOC-001") | |
| 29 | + private String sourceDocCode; | |
| 30 | + | |
| 31 | + @Schema(description = "来源单据类型", example = "MATERIAL_ISSUE") | |
| 32 | + private String sourceDocType; | |
| 33 | + | |
| 34 | + @Schema(description = "投料批次", example = "BATCH-001") | |
| 35 | + private String batchCode; | |
| 36 | + | |
| 37 | + @Schema(description = "来源单据行编号", example = "1") | |
| 38 | + private Long sourceLineId; | |
| 39 | + | |
| 40 | + @Schema(description = "产品物料编号", example = "100") | |
| 41 | + private Long itemId; | |
| 42 | + | |
| 43 | + @Schema(description = "产品编码", example = "P-001") | |
| 44 | + private String itemCode; | |
| 45 | + | |
| 46 | + @Schema(description = "产品名称", example = "电路板") | |
| 47 | + private String itemName; | |
| 48 | + | |
| 49 | + @Schema(description = "规格型号", example = "100x200mm") | |
| 50 | + private String itemSpec; | |
| 51 | + | |
| 52 | + @Schema(description = "单位编号", example = "1") | |
| 53 | + private Long unitMeasureId; | |
| 54 | + | |
| 55 | + @Schema(description = "单位名称", example = "个") | |
| 56 | + private String unitMeasureName; | |
| 57 | + | |
| 58 | + @Schema(description = "总投料数量", example = "100.00") | |
| 59 | + private BigDecimal issuedQuantity; | |
| 60 | + | |
| 61 | + @Schema(description = "当前可用数量", example = "80.00") | |
| 62 | + private BigDecimal availableQuantity; | |
| 63 | + | |
| 64 | + @Schema(description = "当前使用数量", example = "20.00") | |
| 65 | + private BigDecimal usedQuantity; | |
| 66 | + | |
| 67 | + @Schema(description = "备注", example = "备注") | |
| 68 | + private String remark; | |
| 69 | + | |
| 70 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 71 | + private LocalDateTime createTime; | |
| 72 | + | |
| 73 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskIssueSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo; | |
| 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 MesProTaskIssueSaveReqVO { | |
| 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 taskId; | |
| 19 | + | |
| 20 | + @Schema(description = "生产工单编号", example = "1") | |
| 21 | + private Long workOrderId; | |
| 22 | + | |
| 23 | + @Schema(description = "工作站编号", example = "1") | |
| 24 | + private Long workstationId; | |
| 25 | + | |
| 26 | + @Schema(description = "来源单据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @NotNull(message = "来源单据编号不能为空") | |
| 28 | + private Long sourceDocId; | |
| 29 | + | |
| 30 | + @Schema(description = "来源单据编码", example = "DOC-001") | |
| 31 | + private String sourceDocCode; | |
| 32 | + | |
| 33 | + @Schema(description = "来源单据类型", example = "MATERIAL_ISSUE") | |
| 34 | + private String sourceDocType; | |
| 35 | + | |
| 36 | + @Schema(description = "投料批次", example = "BATCH-001") | |
| 37 | + private String batchCode; | |
| 38 | + | |
| 39 | + @Schema(description = "来源单据行编号", example = "1") | |
| 40 | + private Long sourceLineId; | |
| 41 | + | |
| 42 | + @Schema(description = "产品物料编号", example = "100") | |
| 43 | + private Long itemId; | |
| 44 | + | |
| 45 | + @Schema(description = "单位编号", example = "1") | |
| 46 | + private Long unitMeasureId; | |
| 47 | + | |
| 48 | + @Schema(description = "总投料数量", example = "100.00") | |
| 49 | + private BigDecimal issuedQuantity; | |
| 50 | + | |
| 51 | + @Schema(description = "当前可用数量", example = "80.00") | |
| 52 | + private BigDecimal availableQuantity; | |
| 53 | + | |
| 54 | + @Schema(description = "当前使用数量", example = "20.00") | |
| 55 | + private BigDecimal usedQuantity; | |
| 56 | + | |
| 57 | + @Schema(description = "备注", example = "备注") | |
| 58 | + private String remark; | |
| 59 | + | |
| 60 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/task/MesProTaskIssueDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.pro.task; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | |
| 8 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 10 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 11 | +import lombok.*; | |
| 12 | + | |
| 13 | +import java.math.BigDecimal; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * MES 生产任务投料 DO | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@TableName("mes_pro_task_issue") | |
| 21 | +@KeySequence("mes_pro_task_issue_seq") | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class MesProTaskIssueDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 编号 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + /** | |
| 36 | + * 生产任务编号 | |
| 37 | + * | |
| 38 | + * 关联 {@link MesProTaskDO#getId()} | |
| 39 | + */ | |
| 40 | + private Long taskId; | |
| 41 | + /** | |
| 42 | + * 生产工单编号 | |
| 43 | + * | |
| 44 | + * 关联 {@link MesProWorkOrderDO#getId()} | |
| 45 | + */ | |
| 46 | + private Long workOrderId; | |
| 47 | + /** | |
| 48 | + * 工作站编号 | |
| 49 | + * | |
| 50 | + * 关联 {@link MesMdWorkstationDO#getId()} | |
| 51 | + */ | |
| 52 | + private Long workstationId; | |
| 53 | + /** | |
| 54 | + * 来源单据编号 | |
| 55 | + */ | |
| 56 | + private Long sourceDocId; | |
| 57 | + /** | |
| 58 | + * 来源单据编码 | |
| 59 | + */ | |
| 60 | + private String sourceDocCode; | |
| 61 | + /** | |
| 62 | + * 来源单据类型 | |
| 63 | + */ | |
| 64 | + private String sourceDocType; | |
| 65 | + /** | |
| 66 | + * 投料批次 | |
| 67 | + */ | |
| 68 | + private String batchCode; | |
| 69 | + /** | |
| 70 | + * 来源单据行编号 | |
| 71 | + */ | |
| 72 | + private Long sourceLineId; | |
| 73 | + /** | |
| 74 | + * 产品物料编号 | |
| 75 | + * | |
| 76 | + * 关联 {@link MesMdItemDO#getId()} | |
| 77 | + */ | |
| 78 | + private Long itemId; | |
| 79 | + /** | |
| 80 | + * 单位编号 | |
| 81 | + * | |
| 82 | + * 关联 {@link MesMdUnitMeasureDO#getId()} | |
| 83 | + */ | |
| 84 | + private Long unitMeasureId; | |
| 85 | + /** | |
| 86 | + * 总投料数量 | |
| 87 | + */ | |
| 88 | + private BigDecimal issuedQuantity; | |
| 89 | + /** | |
| 90 | + * 当前可用数量 | |
| 91 | + */ | |
| 92 | + private BigDecimal availableQuantity; | |
| 93 | + /** | |
| 94 | + * 当前使用数量 | |
| 95 | + */ | |
| 96 | + private BigDecimal usedQuantity; | |
| 97 | + /** | |
| 98 | + * 备注 | |
| 99 | + */ | |
| 100 | + private String remark; | |
| 101 | + | |
| 102 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/task/MesProTaskIssueMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro.task; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 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.pro.task.vo.MesProTaskIssuePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskIssueDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * MES 生产任务投料 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface MesProTaskIssueMapper extends BaseMapperX<MesProTaskIssueDO> { | |
| 19 | + | |
| 20 | + default PageResult<MesProTaskIssueDO> selectPage(MesProTaskIssuePageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesProTaskIssueDO>() | |
| 22 | + .eqIfPresent(MesProTaskIssueDO::getTaskId, reqVO.getTaskId()) | |
| 23 | + .eqIfPresent(MesProTaskIssueDO::getWorkOrderId, reqVO.getWorkOrderId()) | |
| 24 | + .eqIfPresent(MesProTaskIssueDO::getItemId, reqVO.getItemId()) | |
| 25 | + .eqIfPresent(MesProTaskIssueDO::getSourceDocType, reqVO.getSourceDocType()) | |
| 26 | + .betweenIfPresent(MesProTaskIssueDO::getCreateTime, reqVO.getCreateTime()) | |
| 27 | + .orderByDesc(MesProTaskIssueDO::getId)); | |
| 28 | + } | |
| 29 | + | |
| 30 | + default List<MesProTaskIssueDO> selectListByTaskId(Long taskId) { | |
| 31 | + return selectList(new LambdaQueryWrapperX<MesProTaskIssueDO>() | |
| 32 | + .eq(MesProTaskIssueDO::getTaskId, taskId) | |
| 33 | + .orderByDesc(MesProTaskIssueDO::getId)); | |
| 34 | + } | |
| 35 | + | |
| 36 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskIssueService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro.task; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssuePageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssueSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskIssueDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * MES 生产任务投料 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +public interface MesProTaskIssueService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建生产任务投料 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createTaskIssue(@Valid MesProTaskIssueSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新生产任务投料 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateTaskIssue(@Valid MesProTaskIssueSaveReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除生产任务投料 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteTaskIssue(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获得生产任务投料 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 生产任务投料 | |
| 45 | + */ | |
| 46 | + MesProTaskIssueDO getTaskIssue(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得生产任务投料分页 | |
| 50 | + * | |
| 51 | + * @param pageReqVO 分页查询 | |
| 52 | + * @return 生产任务投料分页 | |
| 53 | + */ | |
| 54 | + PageResult<MesProTaskIssueDO> getTaskIssuePage(MesProTaskIssuePageReqVO pageReqVO); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 根据任务编号,获得投料列表 | |
| 58 | + * | |
| 59 | + * @param taskId 任务编号 | |
| 60 | + * @return 投料列表 | |
| 61 | + */ | |
| 62 | + List<MesProTaskIssueDO> getTaskIssueListByTaskId(Long taskId); | |
| 63 | + | |
| 64 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskIssueServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro.task; | |
| 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.pro.task.vo.MesProTaskIssuePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskIssueSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskIssueDO; | |
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskIssueMapper; | |
| 9 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 10 | +import jakarta.annotation.Resource; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | + | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_TASK_ISSUE_NOT_EXISTS; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * MES 生产任务投料 Service 实现类 | |
| 21 | + * | |
| 22 | + * @author 芋道源码 | |
| 23 | + */ | |
| 24 | +@Service | |
| 25 | +@Validated | |
| 26 | +public class MesProTaskIssueServiceImpl implements MesProTaskIssueService { | |
| 27 | + | |
| 28 | + @Resource | |
| 29 | + private MesProTaskIssueMapper taskIssueMapper; | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private MesProTaskService taskService; | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private MesMdItemService itemService; | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public Long createTaskIssue(MesProTaskIssueSaveReqVO createReqVO) { | |
| 39 | + // 1. 校验关联数据存在 | |
| 40 | + taskService.validateTaskExists(createReqVO.getTaskId()); | |
| 41 | + if (createReqVO.getItemId() != null) { | |
| 42 | + itemService.validateItemExists(createReqVO.getItemId()); | |
| 43 | + } | |
| 44 | + // 2. 插入 | |
| 45 | + MesProTaskIssueDO taskIssue = BeanUtils.toBean(createReqVO, MesProTaskIssueDO.class); | |
| 46 | + taskIssueMapper.insert(taskIssue); | |
| 47 | + return taskIssue.getId(); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public void updateTaskIssue(MesProTaskIssueSaveReqVO updateReqVO) { | |
| 52 | + // 1. 校验存在 | |
| 53 | + validateTaskIssueExists(updateReqVO.getId()); | |
| 54 | + // 2. 校验关联数据存在 | |
| 55 | + if (updateReqVO.getItemId() != null) { | |
| 56 | + itemService.validateItemExists(updateReqVO.getItemId()); | |
| 57 | + } | |
| 58 | + // 3. 更新 | |
| 59 | + MesProTaskIssueDO updateObj = BeanUtils.toBean(updateReqVO, MesProTaskIssueDO.class); | |
| 60 | + taskIssueMapper.updateById(updateObj); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public void deleteTaskIssue(Long id) { | |
| 65 | + // 1. 校验存在 | |
| 66 | + validateTaskIssueExists(id); | |
| 67 | + // 2. 删除 | |
| 68 | + taskIssueMapper.deleteById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public MesProTaskIssueDO getTaskIssue(Long id) { | |
| 73 | + return taskIssueMapper.selectById(id); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public PageResult<MesProTaskIssueDO> getTaskIssuePage(MesProTaskIssuePageReqVO pageReqVO) { | |
| 78 | + return taskIssueMapper.selectPage(pageReqVO); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public List<MesProTaskIssueDO> getTaskIssueListByTaskId(Long taskId) { | |
| 83 | + return taskIssueMapper.selectListByTaskId(taskId); | |
| 84 | + } | |
| 85 | + | |
| 86 | + private void validateTaskIssueExists(Long id) { | |
| 87 | + if (taskIssueMapper.selectById(id) == null) { | |
| 88 | + throw exception(PRO_TASK_ISSUE_NOT_EXISTS); | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | +} | ... | ... |