Commit c9ef64512fcc7f6d044d2dfb67304a339d882530

Authored by YunaiV
1 parent aca010b7

feat(mes): 添加流转卡和工序记录相关的请求和响应 VO,重构服务接口及实现

Showing 21 changed files with 1376 additions and 0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
  5 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  9 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  10 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardPageReqVO;
  12 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardRespVO;
  13 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardSaveReqVO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  15 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
  16 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardDO;
  17 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO;
  18 +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
  19 +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
  20 +import cn.iocoder.yudao.module.mes.service.pro.card.MesProCardService;
  21 +import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService;
  22 +import io.swagger.v3.oas.annotations.Operation;
  23 +import io.swagger.v3.oas.annotations.Parameter;
  24 +import io.swagger.v3.oas.annotations.tags.Tag;
  25 +import jakarta.annotation.Resource;
  26 +import jakarta.servlet.http.HttpServletResponse;
  27 +import jakarta.validation.Valid;
  28 +import org.springframework.security.access.prepost.PreAuthorize;
  29 +import org.springframework.validation.annotation.Validated;
  30 +import org.springframework.web.bind.annotation.*;
  31 +
  32 +import java.io.IOException;
  33 +import java.util.Collections;
  34 +import java.util.List;
  35 +import java.util.Map;
  36 +
  37 +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
  38 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  39 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  40 +
  41 +@Tag(name = "管理后台 - MES 生产流转卡")
  42 +@RestController
  43 +@RequestMapping("/mes/pro/card")
  44 +@Validated
  45 +public class MesProCardController {
  46 +
  47 + @Resource
  48 + private MesProCardService cardService;
  49 +
  50 + @Resource
  51 + private MesProWorkOrderService workOrderService;
  52 +
  53 + @Resource
  54 + private MesMdItemService itemService;
  55 +
  56 + @Resource
  57 + private MesMdUnitMeasureService unitMeasureService;
  58 +
  59 + @PostMapping("/create")
  60 + @Operation(summary = "创建生产流转卡")
  61 + @PreAuthorize("@ss.hasPermission('mes:pro-card:create')")
  62 + public CommonResult<Long> createCard(@Valid @RequestBody MesProCardSaveReqVO createReqVO) {
  63 + return success(cardService.createCard(createReqVO));
  64 + }
  65 +
  66 + @PutMapping("/update")
  67 + @Operation(summary = "更新生产流转卡")
  68 + @PreAuthorize("@ss.hasPermission('mes:pro-card:update')")
  69 + public CommonResult<Boolean> updateCard(@Valid @RequestBody MesProCardSaveReqVO updateReqVO) {
  70 + cardService.updateCard(updateReqVO);
  71 + return success(true);
  72 + }
  73 +
  74 + @DeleteMapping("/delete")
  75 + @Operation(summary = "删除生产流转卡")
  76 + @Parameter(name = "id", description = "编号", required = true)
  77 + @PreAuthorize("@ss.hasPermission('mes:pro-card:delete')")
  78 + public CommonResult<Boolean> deleteCard(@RequestParam("id") Long id) {
  79 + cardService.deleteCard(id);
  80 + return success(true);
  81 + }
  82 +
  83 + @GetMapping("/get")
  84 + @Operation(summary = "获得生产流转卡")
  85 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  86 + @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
  87 + public CommonResult<MesProCardRespVO> getCard(@RequestParam("id") Long id) {
  88 + MesProCardDO card = cardService.getCard(id);
  89 + if (card == null) {
  90 + return success(null);
  91 + }
  92 + return success(buildCardRespVOList(List.of(card)).get(0));
  93 + }
  94 +
  95 + @GetMapping("/page")
  96 + @Operation(summary = "获得生产流转卡分页")
  97 + @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
  98 + public CommonResult<PageResult<MesProCardRespVO>> getCardPage(@Valid MesProCardPageReqVO pageReqVO) {
  99 + PageResult<MesProCardDO> pageResult = cardService.getCardPage(pageReqVO);
  100 + return success(new PageResult<>(buildCardRespVOList(pageResult.getList()), pageResult.getTotal()));
  101 + }
  102 +
  103 + @GetMapping("/export-excel")
  104 + @Operation(summary = "导出生产流转卡 Excel")
  105 + @PreAuthorize("@ss.hasPermission('mes:pro-card:export')")
  106 + @ApiAccessLog(operateType = EXPORT)
  107 + public void exportCardExcel(@Valid MesProCardPageReqVO pageReqVO,
  108 + HttpServletResponse response) throws IOException {
  109 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  110 + List<MesProCardDO> list = cardService.getCardPage(pageReqVO).getList();
  111 + List<MesProCardRespVO> voList = buildCardRespVOList(list);
  112 + ExcelUtils.write(response, "生产流转卡.xls", "数据", MesProCardRespVO.class, voList);
  113 + }
  114 +
  115 + // ==================== 拼接 VO ====================
  116 +
  117 + private List<MesProCardRespVO> buildCardRespVOList(List<MesProCardDO> list) {
  118 + if (CollUtil.isEmpty(list)) {
  119 + return Collections.emptyList();
  120 + }
  121 + // 1. 批量获取关联数据
  122 + Map<Long, MesProWorkOrderDO> workOrderMap = workOrderService.getWorkOrderMap(
  123 + convertSet(list, MesProCardDO::getWorkOrderId));
  124 + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
  125 + convertSet(list, MesProCardDO::getItemId));
  126 + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
  127 + convertSet(list, MesProCardDO::getUnitMeasureId));
  128 + // 2. 拼接 VO
  129 + return BeanUtils.toBean(list, MesProCardRespVO.class, vo -> {
  130 + MapUtils.findAndThen(workOrderMap, vo.getWorkOrderId(), workOrder ->
  131 + vo.setWorkOrderCode(workOrder.getCode()).setWorkOrderName(workOrder.getName()));
  132 + MapUtils.findAndThen(itemMap, vo.getItemId(), item ->
  133 + vo.setItemCode(item.getCode()).setItemName(item.getName()));
  134 + MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(),
  135 + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName()));
  136 + });
  137 + }
  138 +
  139 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardProcessController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card;
  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.CollectionUtils;
  7 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  8 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  9 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessPageReqVO;
  10 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessRespVO;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessSaveReqVO;
  12 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO;
  13 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardProcessDO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
  15 +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService;
  16 +import cn.iocoder.yudao.module.mes.service.pro.card.MesProCardProcessService;
  17 +import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService;
  18 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  19 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
  20 +import io.swagger.v3.oas.annotations.Operation;
  21 +import io.swagger.v3.oas.annotations.Parameter;
  22 +import io.swagger.v3.oas.annotations.tags.Tag;
  23 +import jakarta.annotation.Resource;
  24 +import jakarta.validation.Valid;
  25 +import org.springframework.security.access.prepost.PreAuthorize;
  26 +import org.springframework.validation.annotation.Validated;
  27 +import org.springframework.web.bind.annotation.*;
  28 +
  29 +import java.util.*;
  30 +
  31 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  32 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  33 +
  34 +@Tag(name = "管理后台 - MES 流转卡工序记录")
  35 +@RestController
  36 +@RequestMapping("/mes/pro/card-process")
  37 +@Validated
  38 +public class MesProCardProcessController {
  39 +
  40 + @Resource
  41 + private MesProCardProcessService cardProcessService;
  42 +
  43 + @Resource
  44 + private MesProProcessService processService;
  45 +
  46 + @Resource
  47 + private MesMdWorkstationService workstationService;
  48 +
  49 + @Resource
  50 + private AdminUserApi adminUserApi;
  51 +
  52 + @PostMapping("/create")
  53 + @Operation(summary = "创建流转卡工序记录")
  54 + @PreAuthorize("@ss.hasPermission('mes:pro-card:create')")
  55 + public CommonResult<Long> createCardProcess(@Valid @RequestBody MesProCardProcessSaveReqVO createReqVO) {
  56 + return success(cardProcessService.createCardProcess(createReqVO));
  57 + }
  58 +
  59 + @PutMapping("/update")
  60 + @Operation(summary = "更新流转卡工序记录")
  61 + @PreAuthorize("@ss.hasPermission('mes:pro-card:update')")
  62 + public CommonResult<Boolean> updateCardProcess(@Valid @RequestBody MesProCardProcessSaveReqVO updateReqVO) {
  63 + cardProcessService.updateCardProcess(updateReqVO);
  64 + return success(true);
  65 + }
  66 +
  67 + @DeleteMapping("/delete")
  68 + @Operation(summary = "删除流转卡工序记录")
  69 + @Parameter(name = "id", description = "编号", required = true)
  70 + @PreAuthorize("@ss.hasPermission('mes:pro-card:delete')")
  71 + public CommonResult<Boolean> deleteCardProcess(@RequestParam("id") Long id) {
  72 + cardProcessService.deleteCardProcess(id);
  73 + return success(true);
  74 + }
  75 +
  76 + @GetMapping("/get")
  77 + @Operation(summary = "获得流转卡工序记录")
  78 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  79 + @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
  80 + public CommonResult<MesProCardProcessRespVO> getCardProcess(@RequestParam("id") Long id) {
  81 + MesProCardProcessDO cardProcess = cardProcessService.getCardProcess(id);
  82 + if (cardProcess == null) {
  83 + return success(null);
  84 + }
  85 + return success(buildCardProcessRespVOList(List.of(cardProcess)).get(0));
  86 + }
  87 +
  88 + @GetMapping("/page")
  89 + @Operation(summary = "获得流转卡工序记录分页")
  90 + @PreAuthorize("@ss.hasPermission('mes:pro-card:query')")
  91 + public CommonResult<PageResult<MesProCardProcessRespVO>> getCardProcessPage(@Valid MesProCardProcessPageReqVO pageReqVO) {
  92 + PageResult<MesProCardProcessDO> pageResult = cardProcessService.getCardProcessPage(pageReqVO);
  93 + return success(new PageResult<>(buildCardProcessRespVOList(pageResult.getList()), pageResult.getTotal()));
  94 + }
  95 +
  96 + // ==================== 拼接 VO ====================
  97 +
  98 + private List<MesProCardProcessRespVO> buildCardProcessRespVOList(List<MesProCardProcessDO> list) {
  99 + if (CollUtil.isEmpty(list)) {
  100 + return Collections.emptyList();
  101 + }
  102 + // 1. 批量获取关联数据
  103 + Map<Long, MesProProcessDO> processMap = CollectionUtils.convertMap(
  104 + processService.getProcessList(new ArrayList<>(convertSet(list, MesProCardProcessDO::getProcessId))),
  105 + MesProProcessDO::getId);
  106 + // 工位:逐个获取(MesMdWorkstationService 暂无批量方法,单页数据量小可接受)
  107 + // TODO @AI:还是批量,getWorkstationMap
  108 + Set<Long> workstationIds = convertSet(list, MesProCardProcessDO::getWorkstationId);
  109 + Map<Long, MesMdWorkstationDO> workstationMap = new HashMap<>();
  110 + workstationIds.forEach(wsId -> {
  111 + if (wsId != null) {
  112 + MesMdWorkstationDO ws = workstationService.getWorkstation(wsId);
  113 + if (ws != null) {
  114 + workstationMap.put(wsId, ws);
  115 + }
  116 + }
  117 + });
  118 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
  119 + convertSet(list, MesProCardProcessDO::getUserId));
  120 + // 2. 拼接 VO
  121 + return BeanUtils.toBean(list, MesProCardProcessRespVO.class, vo -> {
  122 + MapUtils.findAndThen(processMap, vo.getProcessId(), process ->
  123 + vo.setProcessCode(process.getCode()).setProcessName(process.getName()));
  124 + MapUtils.findAndThen(workstationMap, vo.getWorkstationId(), ws ->
  125 + vo.setWorkstationCode(ws.getCode()).setWorkstationName(ws.getName()));
  126 + MapUtils.findAndThen(userMap, vo.getUserId(),
  127 + user -> vo.setNickname(user.getNickname()));
  128 + });
  129 + }
  130 +
  131 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/MesProCardPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.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 MesProCardPageReqVO extends PageParam {
  19 +
  20 + @Schema(description = "流转卡编码", example = "CARD-001")
  21 + private String code;
  22 +
  23 + @Schema(description = "生产工单编号", example = "100")
  24 + private Long workOrderId;
  25 +
  26 + @Schema(description = "产品物料编号", example = "200")
  27 + private Long itemId;
  28 +
  29 + @Schema(description = "批次号", example = "BATCH-001")
  30 + private String batchCode;
  31 +
  32 + @Schema(description = "状态", example = "0")
  33 + private Integer status;
  34 +
  35 + @Schema(description = "创建时间")
  36 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  37 + private LocalDateTime[] createTime;
  38 +
  39 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/MesProCardRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.mes.enums.DictTypeConstants;
  6 +import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
  7 +import cn.idev.excel.annotation.ExcelProperty;
  8 +import io.swagger.v3.oas.annotations.media.Schema;
  9 +import lombok.Data;
  10 +
  11 +import java.math.BigDecimal;
  12 +import java.time.LocalDateTime;
  13 +
  14 +@Schema(description = "管理后台 - MES 生产流转卡 Response VO")
  15 +@Data
  16 +@ExcelIgnoreUnannotated
  17 +public class MesProCardRespVO {
  18 +
  19 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  20 + @ExcelProperty("编号")
  21 + private Long id;
  22 +
  23 + @Schema(description = "流转卡编码", example = "CARD-001")
  24 + @ExcelProperty("流转卡编码")
  25 + private String code;
  26 +
  27 + @Schema(description = "生产工单编号", example = "100")
  28 + private Long workOrderId;
  29 +
  30 + @Schema(description = "工单编码", example = "WO-001")
  31 + @ExcelProperty("工单编码")
  32 + private String workOrderCode;
  33 +
  34 + @Schema(description = "工单名称", example = "生产工单-A")
  35 + @ExcelProperty("工单名称")
  36 + private String workOrderName;
  37 +
  38 + @Schema(description = "批次号", example = "BATCH-001")
  39 + @ExcelProperty("批次号")
  40 + private String batchCode;
  41 +
  42 + @Schema(description = "产品物料编号", example = "200")
  43 + private Long itemId;
  44 +
  45 + @Schema(description = "产品编码", example = "P-001")
  46 + @ExcelProperty("产品编码")
  47 + private String itemCode;
  48 +
  49 + @Schema(description = "产品名称", example = "电路板 A")
  50 + @ExcelProperty("产品名称")
  51 + private String itemName;
  52 +
  53 + @Schema(description = "规格型号", example = "100x200mm")
  54 + @ExcelProperty("规格型号")
  55 + private String specification;
  56 +
  57 + @Schema(description = "单位编号", example = "300")
  58 + private Long unitMeasureId;
  59 +
  60 + @Schema(description = "单位名称", example = "个")
  61 + @ExcelProperty("单位")
  62 + private String unitMeasureName;
  63 +
  64 + @Schema(description = "条码地址", example = "https://xxx")
  65 + private String barcodeUrl;
  66 +
  67 + @Schema(description = "流转数量", example = "100.00")
  68 + @ExcelProperty("流转数量")
  69 + private BigDecimal transferedQuantity;
  70 +
  71 + @Schema(description = "状态", example = "0")
  72 + @ExcelProperty(value = "状态", converter = DictConvert.class)
  73 + @DictFormat(DictTypeConstants.MES_PRO_WORK_ORDER_STATUS)
  74 + private Integer status;
  75 +
  76 + @Schema(description = "备注", example = "备注")
  77 + @ExcelProperty("备注")
  78 + private String remark;
  79 +
  80 + @Schema(description = "预留字段1")
  81 + private String attribute1;
  82 +
  83 + @Schema(description = "预留字段2")
  84 + private String attribute2;
  85 +
  86 + @Schema(description = "预留字段3")
  87 + private Integer attribute3;
  88 +
  89 + @Schema(description = "预留字段4")
  90 + private Integer attribute4;
  91 +
  92 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  93 + @ExcelProperty("创建时间")
  94 + private LocalDateTime createTime;
  95 +
  96 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/MesProCardSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
  7 +
  8 +import java.math.BigDecimal;
  9 +
  10 +@Schema(description = "管理后台 - MES 生产流转卡新增/修改 Request VO")
  11 +@Data
  12 +public class MesProCardSaveReqVO {
  13 +
  14 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  15 + private Long id;
  16 +
  17 + @Schema(description = "流转卡编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CARD-001")
  18 + @NotEmpty(message = "流转卡编码不能为空")
  19 + private String code;
  20 +
  21 + @Schema(description = "生产工单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
  22 + @NotNull(message = "生产工单不能为空")
  23 + private Long workOrderId;
  24 +
  25 + @Schema(description = "批次号", example = "BATCH-001")
  26 + private String batchCode;
  27 +
  28 + @Schema(description = "产品物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
  29 + @NotNull(message = "产品物料不能为空")
  30 + private Long itemId;
  31 +
  32 + @Schema(description = "规格型号", example = "100x200mm")
  33 + private String specification;
  34 +
  35 + @Schema(description = "单位编号", example = "300")
  36 + private Long unitMeasureId;
  37 +
  38 + @Schema(description = "流转数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
  39 + @NotNull(message = "流转数量不能为空")
  40 + private BigDecimal transferedQuantity;
  41 +
  42 + @Schema(description = "状态", example = "0")
  43 + private Integer status;
  44 +
  45 + @Schema(description = "备注", example = "备注")
  46 + private String remark;
  47 +
  48 + @Schema(description = "预留字段1")
  49 + private String attribute1;
  50 +
  51 + @Schema(description = "预留字段2")
  52 + private String attribute2;
  53 +
  54 + @Schema(description = "预留字段3")
  55 + private Integer attribute3;
  56 +
  57 + @Schema(description = "预留字段4")
  58 + private Integer attribute4;
  59 +
  60 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/process/MesProCardProcessPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process;
  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 MesProCardProcessPageReqVO extends PageParam {
  15 +
  16 + @Schema(description = "流转卡编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
  17 + @NotNull(message = "流转卡编号不能为空")
  18 + private Long cardId;
  19 +
  20 + @Schema(description = "工序编号", example = "200")
  21 + private Long processId;
  22 +
  23 + @Schema(description = "工位编号", example = "300")
  24 + private Long workstationId;
  25 +
  26 + @Schema(description = "操作人编号", example = "400")
  27 + private Long userId;
  28 +
  29 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/process/MesProCardProcessRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process;
  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 MesProCardProcessRespVO {
  12 +
  13 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  14 + private Long id;
  15 +
  16 + @Schema(description = "流转卡编号", example = "100")
  17 + private Long cardId;
  18 +
  19 + @Schema(description = "序号", example = "1")
  20 + private Integer sort;
  21 +
  22 + @Schema(description = "工序编号", example = "200")
  23 + private Long processId;
  24 +
  25 + @Schema(description = "工序编码", example = "PROC-001")
  26 + private String processCode;
  27 +
  28 + @Schema(description = "工序名称", example = "焊接")
  29 + private String processName;
  30 +
  31 + @Schema(description = "进入工序时间")
  32 + private LocalDateTime inputTime;
  33 +
  34 + @Schema(description = "出工序时间")
  35 + private LocalDateTime outputTime;
  36 +
  37 + @Schema(description = "投入数量", example = "100.00")
  38 + private BigDecimal inputQuantity;
  39 +
  40 + @Schema(description = "产出数量", example = "98.00")
  41 + private BigDecimal outputQuantity;
  42 +
  43 + @Schema(description = "不合格品数量", example = "2.00")
  44 + private BigDecimal unqualifiedQuantity;
  45 +
  46 + @Schema(description = "工位编号", example = "300")
  47 + private Long workstationId;
  48 +
  49 + @Schema(description = "工位编码", example = "WS-001")
  50 + private String workstationCode;
  51 +
  52 + @Schema(description = "工位名称", example = "焊接工位 1")
  53 + private String workstationName;
  54 +
  55 + @Schema(description = "操作人编号", example = "400")
  56 + private Long userId;
  57 +
  58 + @Schema(description = "操作人名称", example = "张三")
  59 + private String nickname;
  60 +
  61 + @Schema(description = "过程检验单编号", example = "500")
  62 + private Long ipqcId;
  63 +
  64 + @Schema(description = "备注", example = "备注")
  65 + private String remark;
  66 +
  67 + @Schema(description = "预留字段1")
  68 + private String attribute1;
  69 +
  70 + @Schema(description = "预留字段2")
  71 + private String attribute2;
  72 +
  73 + @Schema(description = "预留字段3")
  74 + private Integer attribute3;
  75 +
  76 + @Schema(description = "预留字段4")
  77 + private Integer attribute4;
  78 +
  79 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  80 + private LocalDateTime createTime;
  81 +
  82 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/vo/process/MesProCardProcessSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process;
  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 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - MES 流转卡工序记录新增/修改 Request VO")
  11 +@Data
  12 +public class MesProCardProcessSaveReqVO {
  13 +
  14 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  15 + private Long id;
  16 +
  17 + @Schema(description = "流转卡编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
  18 + @NotNull(message = "流转卡不能为空")
  19 + private Long cardId;
  20 +
  21 + @Schema(description = "序号", example = "1")
  22 + private Integer sort;
  23 +
  24 + @Schema(description = "工序编号", example = "200")
  25 + private Long processId;
  26 +
  27 + @Schema(description = "进入工序时间")
  28 + private LocalDateTime inputTime;
  29 +
  30 + @Schema(description = "出工序时间")
  31 + private LocalDateTime outputTime;
  32 +
  33 + @Schema(description = "投入数量", example = "100.00")
  34 + private BigDecimal inputQuantity;
  35 +
  36 + @Schema(description = "产出数量", example = "98.00")
  37 + private BigDecimal outputQuantity;
  38 +
  39 + @Schema(description = "不合格品数量", example = "2.00")
  40 + private BigDecimal unqualifiedQuantity;
  41 +
  42 + @Schema(description = "工位编号", example = "300")
  43 + private Long workstationId;
  44 +
  45 + @Schema(description = "操作人编号", example = "400")
  46 + private Long userId;
  47 +
  48 + @Schema(description = "过程检验单编号", example = "500")
  49 + private Long ipqcId;
  50 +
  51 + @Schema(description = "备注", example = "备注")
  52 + private String remark;
  53 +
  54 + @Schema(description = "预留字段1")
  55 + private String attribute1;
  56 +
  57 + @Schema(description = "预留字段2")
  58 + private String attribute2;
  59 +
  60 + @Schema(description = "预留字段3")
  61 + private Integer attribute3;
  62 +
  63 + @Schema(description = "预留字段4")
  64 + private Integer attribute4;
  65 +
  66 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/card/MesProCardDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.pro.card;
  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.pro.workorder.MesProWorkOrderDO;
  7 +import com.baomidou.mybatisplus.annotation.KeySequence;
  8 +import com.baomidou.mybatisplus.annotation.TableId;
  9 +import com.baomidou.mybatisplus.annotation.TableName;
  10 +import lombok.*;
  11 +
  12 +import java.math.BigDecimal;
  13 +
  14 +/**
  15 + * MES 生产流转卡 DO
  16 + *
  17 + * @author 芋道源码
  18 + */
  19 +@TableName("mes_pro_card")
  20 +@KeySequence("mes_pro_card_seq")
  21 +@Data
  22 +@EqualsAndHashCode(callSuper = true)
  23 +@ToString(callSuper = true)
  24 +@Builder
  25 +@NoArgsConstructor
  26 +@AllArgsConstructor
  27 +public class MesProCardDO extends BaseDO {
  28 +
  29 + /**
  30 + * 编号
  31 + */
  32 + @TableId
  33 + private Long id;
  34 + /**
  35 + * 流转卡编码
  36 + */
  37 + private String code;
  38 + /**
  39 + * 生产工单编号
  40 + *
  41 + * 关联 {@link MesProWorkOrderDO#getId()}
  42 + */
  43 + private Long workOrderId;
  44 + /**
  45 + * 批次号
  46 + */
  47 + private String batchCode;
  48 + /**
  49 + * 产品物料编号
  50 + *
  51 + * 关联 {@link MesMdItemDO#getId()}
  52 + */
  53 + private Long itemId;
  54 + /**
  55 + * 规格型号
  56 + */
  57 + private String specification;
  58 + /**
  59 + * 单位编号
  60 + *
  61 + * 关联 {@link MesMdUnitMeasureDO#getId()}
  62 + */
  63 + private Long unitMeasureId;
  64 + /**
  65 + * 条码地址
  66 + *
  67 + * TODO @芋艿:条码生成功能,需等条码模块(wm_barcode)迁移后再对接
  68 + */
  69 + private String barcodeUrl;
  70 + /**
  71 + * 流转数量
  72 + */
  73 + private BigDecimal transferedQuantity;
  74 + /**
  75 + * 状态
  76 + *
  77 + * 枚举 {@link cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum}
  78 + */
  79 + private Integer status;
  80 + /**
  81 + * 备注
  82 + */
  83 + private String remark;
  84 + /**
  85 + * 预留字段1
  86 + */
  87 + private String attribute1;
  88 + /**
  89 + * 预留字段2
  90 + */
  91 + private String attribute2;
  92 + /**
  93 + * 预留字段3
  94 + */
  95 + private Integer attribute3;
  96 + /**
  97 + * 预留字段4
  98 + */
  99 + private Integer attribute4;
  100 +
  101 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/card/MesProCardProcessDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.pro.card;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO;
  5 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
  6 +import com.baomidou.mybatisplus.annotation.KeySequence;
  7 +import com.baomidou.mybatisplus.annotation.TableId;
  8 +import com.baomidou.mybatisplus.annotation.TableName;
  9 +import lombok.*;
  10 +
  11 +import java.math.BigDecimal;
  12 +import java.time.LocalDateTime;
  13 +
  14 +/**
  15 + * MES 流转卡工序记录 DO
  16 + *
  17 + * @author 芋道源码
  18 + */
  19 +@TableName("mes_pro_card_process")
  20 +@KeySequence("mes_pro_card_process_seq")
  21 +@Data
  22 +@EqualsAndHashCode(callSuper = true)
  23 +@ToString(callSuper = true)
  24 +@Builder
  25 +@NoArgsConstructor
  26 +@AllArgsConstructor
  27 +public class MesProCardProcessDO extends BaseDO {
  28 +
  29 + /**
  30 + * 编号
  31 + */
  32 + @TableId
  33 + private Long id;
  34 + /**
  35 + * 流转卡编号
  36 + *
  37 + * 关联 {@link MesProCardDO#getId()}
  38 + */
  39 + private Long cardId;
  40 + /**
  41 + * 序号
  42 + */
  43 + private Integer sort;
  44 + /**
  45 + * 工序编号
  46 + *
  47 + * 关联 {@link MesProProcessDO#getId()}
  48 + */
  49 + private Long processId;
  50 + /**
  51 + * 进入工序时间
  52 + */
  53 + private LocalDateTime inputTime;
  54 + /**
  55 + * 出工序时间
  56 + */
  57 + private LocalDateTime outputTime;
  58 + /**
  59 + * 投入数量
  60 + */
  61 + private BigDecimal inputQuantity;
  62 + /**
  63 + * 产出数量
  64 + */
  65 + private BigDecimal outputQuantity;
  66 + /**
  67 + * 不合格品数量
  68 + */
  69 + private BigDecimal unqualifiedQuantity;
  70 + /**
  71 + * 工位编号
  72 + *
  73 + * 关联 {@link MesMdWorkstationDO#getId()}
  74 + */
  75 + private Long workstationId;
  76 + /**
  77 + * 操作人编号
  78 + *
  79 + * 关联 AdminUserDO#getId()
  80 + */
  81 + private Long userId;
  82 + /**
  83 + * 过程检验单编号
  84 + *
  85 + * TODO @芋艿:关联 mes_qc_ipqc 表,等 IPQC 模块迁移后再对接
  86 + */
  87 + private Long ipqcId;
  88 + /**
  89 + * 备注
  90 + */
  91 + private String remark;
  92 + /**
  93 + * 预留字段1
  94 + */
  95 + private String attribute1;
  96 + /**
  97 + * 预留字段2
  98 + */
  99 + private String attribute2;
  100 + /**
  101 + * 预留字段3
  102 + */
  103 + private Integer attribute3;
  104 + /**
  105 + * 预留字段4
  106 + */
  107 + private Integer attribute4;
  108 +
  109 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/card/MesProCardMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.pro.card;
  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.card.vo.MesProCardPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * MES 生产流转卡 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface MesProCardMapper extends BaseMapperX<MesProCardDO> {
  17 +
  18 + default PageResult<MesProCardDO> selectPage(MesProCardPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesProCardDO>()
  20 + .likeIfPresent(MesProCardDO::getCode, reqVO.getCode())
  21 + .eqIfPresent(MesProCardDO::getWorkOrderId, reqVO.getWorkOrderId())
  22 + .eqIfPresent(MesProCardDO::getItemId, reqVO.getItemId())
  23 + .likeIfPresent(MesProCardDO::getBatchCode, reqVO.getBatchCode())
  24 + .eqIfPresent(MesProCardDO::getStatus, reqVO.getStatus())
  25 + .betweenIfPresent(MesProCardDO::getCreateTime, reqVO.getCreateTime())
  26 + .orderByDesc(MesProCardDO::getId));
  27 + }
  28 +
  29 + default MesProCardDO selectByCode(String code) {
  30 + return selectOne(MesProCardDO::getCode, code);
  31 + }
  32 +
  33 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/card/MesProCardProcessMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.pro.card;
  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.card.vo.process.MesProCardProcessPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardProcessDO;
  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 MesProCardProcessMapper extends BaseMapperX<MesProCardProcessDO> {
  19 +
  20 + default PageResult<MesProCardProcessDO> selectPage(MesProCardProcessPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<MesProCardProcessDO>()
  22 + .eqIfPresent(MesProCardProcessDO::getCardId, reqVO.getCardId())
  23 + .eqIfPresent(MesProCardProcessDO::getProcessId, reqVO.getProcessId())
  24 + .eqIfPresent(MesProCardProcessDO::getWorkstationId, reqVO.getWorkstationId())
  25 + .eqIfPresent(MesProCardProcessDO::getUserId, reqVO.getUserId())
  26 + .orderByAsc(MesProCardProcessDO::getSort));
  27 + }
  28 +
  29 + default List<MesProCardProcessDO> selectListByCardId(Long cardId) {
  30 + return selectList(MesProCardProcessDO::getCardId, cardId);
  31 + }
  32 +
  33 + default void deleteByCardId(Long cardId) {
  34 + delete(MesProCardProcessDO::getCardId, cardId);
  35 + }
  36 +
  37 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/feedback/MesProFeedbackMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.pro.feedback;
  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.feedback.vo.MesProFeedbackPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.feedback.MesProFeedbackDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * MES 生产报工 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface MesProFeedbackMapper extends BaseMapperX<MesProFeedbackDO> {
  17 +
  18 + default PageResult<MesProFeedbackDO> selectPage(MesProFeedbackPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesProFeedbackDO>()
  20 + .likeIfPresent(MesProFeedbackDO::getCode, reqVO.getCode())
  21 + .eqIfPresent(MesProFeedbackDO::getType, reqVO.getType())
  22 + .eqIfPresent(MesProFeedbackDO::getWorkOrderId, reqVO.getWorkOrderId())
  23 + .eqIfPresent(MesProFeedbackDO::getStatus, reqVO.getStatus())
  24 + .betweenIfPresent(MesProFeedbackDO::getFeedbackTime, reqVO.getFeedbackTime())
  25 + .eqIfPresent(MesProFeedbackDO::getItemId, reqVO.getItemId())
  26 + .eqIfPresent(MesProFeedbackDO::getFeedbackUserId, reqVO.getFeedbackUserId())
  27 + .eqIfPresent(MesProFeedbackDO::getCreator, reqVO.getCreator())
  28 + .orderByDesc(MesProFeedbackDO::getId));
  29 + }
  30 +
  31 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationService.java
... ... @@ -6,7 +6,11 @@ import cn.iocoder.yudao.module.mes.controller.admin.md.workstation.vo.MesMdWorks
6 6 import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO;
7 7 import jakarta.validation.Valid;
8 8  
  9 +import java.util.Collection;
9 10 import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
10 14  
11 15 /**
12 16 * MES 工作站 Service 接口
... ... @@ -92,4 +96,22 @@ public interface MesMdWorkstationService {
92 96 */
93 97 Long getWorkstationCountByAreaId(Long areaId);
94 98  
  99 + /**
  100 + * 获得工作站列表
  101 + *
  102 + * @param ids 编号数组
  103 + * @return 工作站列表
  104 + */
  105 + List<MesMdWorkstationDO> getWorkstationList(Collection<Long> ids);
  106 +
  107 + /**
  108 + * 获得工作站 Map
  109 + *
  110 + * @param ids 编号数组
  111 + * @return 工作站 Map
  112 + */
  113 + default Map<Long, MesMdWorkstationDO> getWorkstationMap(Collection<Long> ids) {
  114 + return convertMap(getWorkstationList(ids), MesMdWorkstationDO::getId);
  115 + }
  116 +
95 117 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.md.workstation;
2 2  
  3 +import cn.hutool.core.collection.CollUtil;
3 4 import cn.hutool.core.util.ObjUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -21,6 +22,8 @@ import org.springframework.stereotype.Service;
21 22 import org.springframework.transaction.annotation.Transactional;
22 23 import org.springframework.validation.annotation.Validated;
23 24  
  25 +import java.util.Collection;
  26 +import java.util.Collections;
24 27 import java.util.List;
25 28  
26 29 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
... ... @@ -228,4 +231,12 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService {
228 231 return workstationMapper.selectCountByAreaId(areaId);
229 232 }
230 233  
  234 + @Override
  235 + public List<MesMdWorkstationDO> getWorkstationList(Collection<Long> ids) {
  236 + if (CollUtil.isEmpty(ids)) {
  237 + return Collections.emptyList();
  238 + }
  239 + return workstationMapper.selectByIds(ids);
  240 + }
  241 +
231 242 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/card/MesProCardProcessService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.pro.card;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardProcessDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +/**
  10 + * MES 流转卡工序记录 Service 接口
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +public interface MesProCardProcessService {
  15 +
  16 + /**
  17 + * 创建流转卡工序记录
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createCardProcess(@Valid MesProCardProcessSaveReqVO createReqVO);
  23 +
  24 + /**
  25 + * 更新流转卡工序记录
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateCardProcess(@Valid MesProCardProcessSaveReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除流转卡工序记录
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteCardProcess(Long id);
  37 +
  38 + /**
  39 + * 获得流转卡工序记录
  40 + *
  41 + * @param id 编号
  42 + * @return 流转卡工序记录
  43 + */
  44 + MesProCardProcessDO getCardProcess(Long id);
  45 +
  46 + /**
  47 + * 获得流转卡工序记录分页
  48 + *
  49 + * @param pageReqVO 分页查询
  50 + * @return 流转卡工序记录分页
  51 + */
  52 + PageResult<MesProCardProcessDO> getCardProcessPage(MesProCardProcessPageReqVO pageReqVO);
  53 +
  54 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/card/MesProCardProcessServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.pro.card;
  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.card.vo.process.MesProCardProcessPageReqVO;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.process.MesProCardProcessSaveReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardProcessDO;
  8 +import cn.iocoder.yudao.module.mes.dal.mysql.pro.card.MesProCardProcessMapper;
  9 +import jakarta.annotation.Resource;
  10 +import org.springframework.stereotype.Service;
  11 +import org.springframework.validation.annotation.Validated;
  12 +
  13 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  14 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_CARD_PROCESS_NOT_EXISTS;
  15 +
  16 +/**
  17 + * MES 流转卡工序记录 Service 实现类
  18 + *
  19 + * @author 芋道源码
  20 + */
  21 +@Service
  22 +@Validated
  23 +public class MesProCardProcessServiceImpl implements MesProCardProcessService {
  24 +
  25 + @Resource
  26 + private MesProCardProcessMapper cardProcessMapper;
  27 +
  28 + @Override
  29 + public Long createCardProcess(MesProCardProcessSaveReqVO createReqVO) {
  30 + // TODO @AI:card 存在,通过 cardService 的 validateCardExists() 方法校验
  31 + MesProCardProcessDO cardProcess = BeanUtils.toBean(createReqVO, MesProCardProcessDO.class);
  32 + cardProcessMapper.insert(cardProcess);
  33 + return cardProcess.getId();
  34 + }
  35 +
  36 + @Override
  37 + public void updateCardProcess(MesProCardProcessSaveReqVO updateReqVO) {
  38 + // 1. 校验存在
  39 + validateCardProcessExists(updateReqVO.getId());
  40 + // TODO @AI:card 存在,通过 cardService 的 validateCardExists() 方法校验
  41 +
  42 + // 2. 更新
  43 + MesProCardProcessDO updateObj = BeanUtils.toBean(updateReqVO, MesProCardProcessDO.class);
  44 + cardProcessMapper.updateById(updateObj);
  45 + }
  46 +
  47 + @Override
  48 + public void deleteCardProcess(Long id) {
  49 + // 1. 校验存在
  50 + validateCardProcessExists(id);
  51 +
  52 + // 2. 删除
  53 + cardProcessMapper.deleteById(id);
  54 + }
  55 +
  56 + @Override
  57 + public MesProCardProcessDO getCardProcess(Long id) {
  58 + return cardProcessMapper.selectById(id);
  59 + }
  60 +
  61 + @Override
  62 + public PageResult<MesProCardProcessDO> getCardProcessPage(MesProCardProcessPageReqVO pageReqVO) {
  63 + return cardProcessMapper.selectPage(pageReqVO);
  64 + }
  65 +
  66 + // ==================== 校验方法 ====================
  67 +
  68 + private void validateCardProcessExists(Long id) {
  69 + if (cardProcessMapper.selectById(id) == null) {
  70 + throw exception(PRO_CARD_PROCESS_NOT_EXISTS);
  71 + }
  72 + }
  73 +
  74 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/card/MesProCardService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.pro.card;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +/**
  10 + * MES 生产流转卡 Service 接口
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +public interface MesProCardService {
  15 +
  16 + /**
  17 + * 创建生产流转卡
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createCard(@Valid MesProCardSaveReqVO createReqVO);
  23 +
  24 + /**
  25 + * 更新生产流转卡
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateCard(@Valid MesProCardSaveReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除生产流转卡
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteCard(Long id);
  37 +
  38 + /**
  39 + * 获得生产流转卡
  40 + *
  41 + * @param id 编号
  42 + * @return 生产流转卡
  43 + */
  44 + MesProCardDO getCard(Long id);
  45 +
  46 + /**
  47 + * 获得生产流转卡分页
  48 + *
  49 + * @param pageReqVO 分页查询
  50 + * @return 生产流转卡分页
  51 + */
  52 + PageResult<MesProCardDO> getCardPage(MesProCardPageReqVO pageReqVO);
  53 +
  54 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/card/MesProCardServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.pro.card;
  2 +
  3 +import cn.hutool.core.util.ObjUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.pro.card.vo.MesProCardSaveReqVO;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.card.MesProCardDO;
  9 +import cn.iocoder.yudao.module.mes.dal.mysql.pro.card.MesProCardMapper;
  10 +import cn.iocoder.yudao.module.mes.dal.mysql.pro.card.MesProCardProcessMapper;
  11 +import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService;
  12 +import jakarta.annotation.Resource;
  13 +import org.springframework.stereotype.Service;
  14 +import org.springframework.transaction.annotation.Transactional;
  15 +import org.springframework.validation.annotation.Validated;
  16 +
  17 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  18 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  19 +
  20 +/**
  21 + * MES 生产流转卡 Service 实现类
  22 + *
  23 + * @author 芋道源码
  24 + */
  25 +@Service
  26 +@Validated
  27 +public class MesProCardServiceImpl implements MesProCardService {
  28 +
  29 + @Resource
  30 + private MesProCardMapper cardMapper;
  31 +
  32 + @Resource
  33 + private MesProCardProcessMapper cardProcessMapper;
  34 +
  35 + @Resource
  36 + private MesProWorkOrderService workOrderService;
  37 +
  38 + @Override
  39 + public Long createCard(MesProCardSaveReqVO createReqVO) {
  40 + // 1.1 校验编码唯一
  41 + validateCardCodeUnique(null, createReqVO.getCode());
  42 + // 1.2 校验工单存在
  43 + workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId());
  44 +
  45 + // 2. 插入
  46 + MesProCardDO card = BeanUtils.toBean(createReqVO, MesProCardDO.class);
  47 + cardMapper.insert(card);
  48 + // TODO @芋艿:条码生成(barcode_url),需等条码模块(wm_barcode)迁移后再对接
  49 + return card.getId();
  50 + }
  51 +
  52 + @Override
  53 + public void updateCard(MesProCardSaveReqVO updateReqVO) {
  54 + // 1.1 校验存在
  55 + validateCardExists(updateReqVO.getId());
  56 + // 1.2 校验编码唯一
  57 + validateCardCodeUnique(updateReqVO.getId(), updateReqVO.getCode());
  58 +
  59 + // 2. 更新
  60 + MesProCardDO updateObj = BeanUtils.toBean(updateReqVO, MesProCardDO.class);
  61 + cardMapper.updateById(updateObj);
  62 + }
  63 +
  64 + @Override
  65 + @Transactional(rollbackFor = Exception.class)
  66 + public void deleteCard(Long id) {
  67 + // 1. 校验存在
  68 + validateCardExists(id);
  69 +
  70 + // 2. 删除流转卡 + 级联删除工序记录
  71 + cardMapper.deleteById(id);
  72 + cardProcessMapper.deleteByCardId(id);
  73 + }
  74 +
  75 + @Override
  76 + public MesProCardDO getCard(Long id) {
  77 + return cardMapper.selectById(id);
  78 + }
  79 +
  80 + @Override
  81 + public PageResult<MesProCardDO> getCardPage(MesProCardPageReqVO pageReqVO) {
  82 + return cardMapper.selectPage(pageReqVO);
  83 + }
  84 +
  85 + // ==================== 校验方法 ====================
  86 +
  87 + private void validateCardExists(Long id) {
  88 + if (cardMapper.selectById(id) == null) {
  89 + throw exception(PRO_CARD_NOT_EXISTS);
  90 + }
  91 + }
  92 +
  93 + private void validateCardCodeUnique(Long id, String code) {
  94 + if (code == null) {
  95 + return;
  96 + }
  97 + MesProCardDO card = cardMapper.selectByCode(code);
  98 + if (card == null) {
  99 + return;
  100 + }
  101 + if (ObjUtil.notEqual(card.getId(), id)) {
  102 + throw exception(PRO_CARD_CODE_DUPLICATE);
  103 + }
  104 + }
  105 +
  106 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/feedback/MesProFeedbackService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.pro.feedback;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.pro.feedback.vo.MesProFeedbackPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.pro.feedback.vo.MesProFeedbackSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.feedback.MesProFeedbackDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +/**
  10 + * MES 生产报工 Service 接口
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +public interface MesProFeedbackService {
  15 +
  16 + /**
  17 + * 创建生产报工(草稿)
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createFeedback(@Valid MesProFeedbackSaveReqVO createReqVO);
  23 +
  24 + /**
  25 + * 修改生产报工
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateFeedback(@Valid MesProFeedbackSaveReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除生产报工(仅草稿)
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteFeedback(Long id);
  37 +
  38 + /**
  39 + * 获得生产报工
  40 + *
  41 + * @param id 编号
  42 + * @return 生产报工
  43 + */
  44 + MesProFeedbackDO getFeedback(Long id);
  45 +
  46 + /**
  47 + * 获得生产报工分页
  48 + *
  49 + * @param pageReqVO 分页查询
  50 + * @return 生产报工分页
  51 + */
  52 + PageResult<MesProFeedbackDO> getFeedbackPage(MesProFeedbackPageReqVO pageReqVO);
  53 +
  54 + /**
  55 + * 提交报工(草稿 → 审批中)
  56 + *
  57 + * @param id 编号
  58 + */
  59 + void submitFeedback(Long id);
  60 +
  61 + /**
  62 + * 驳回报工(审批中 → 草稿)
  63 + *
  64 + * @param id 编号
  65 + */
  66 + void rejectFeedback(Long id);
  67 +
  68 + /**
  69 + * 执行报工(审批中 → 已完成 或 待检验)
  70 + *
  71 + * @param id 编号
  72 + */
  73 + void executeFeedback(Long id);
  74 +
  75 + /**
  76 + * 取消报工
  77 + *
  78 + * @param id 编号
  79 + */
  80 + void cancelFeedback(Long id);
  81 +
  82 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessService.java
... ... @@ -7,6 +7,9 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
7 7  
8 8 import jakarta.validation.Valid;
9 9 import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
10 13  
11 14 /**
12 15 * MES 生产工序 Service 接口
... ... @@ -69,4 +72,21 @@ public interface MesProProcessService {
69 72 */
70 73 List<MesProProcessDO> getProcessListByStatus(Integer status);
71 74  
  75 + /**
  76 + * 校验工序存在
  77 + *
  78 + * @param id 编号
  79 + */
  80 + void validateProcessExists(Long id);
  81 +
  82 + /**
  83 + * 获得工序 Map
  84 + *
  85 + * @param ids 编号列表
  86 + * @return 工序 Map
  87 + */
  88 + default Map<Long, MesProProcessDO> getProcessMap(List<Long> ids) {
  89 + return convertMap(getProcessList(ids), MesProProcessDO::getId);
  90 + }
  91 +
72 92 }
... ...