From 5a3fe9400d1b7f89a4794798d6e74515cb2aad2d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 19 Feb 2026 19:26:17 +0800 Subject: [PATCH] fix(mes): 修复生产工单模块 TODO,新增 clientCode/parentCode 拼接及 getWorkOrderList 方法 --- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java | 11 ++++++++++- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java | 7 +++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java | 38 ++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderService.java | 11 +++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderServiceImpl.java | 6 ++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java index 2757ec1..37f4ed4 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java @@ -35,9 +35,11 @@ import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Tag(name = "管理后台 - MES 生产工单") @@ -150,17 +152,24 @@ public class MesProWorkOrderController { convertSet(list, MesProWorkOrderDO::getVendorId)); Map unitMeasureMap = unitMeasureService.getUnitMeasureMap( convertSet(list, MesProWorkOrderDO::getUnitMeasureId)); + // TODO @AI:直接 workOrderService.getWorkOrderMap,内部调用 workOrderService.getWorkOrderList + Set parentIds = convertSet(list, MesProWorkOrderDO::getParentId); + Map parentMap = CollUtil.isEmpty(parentIds) + ? Collections.emptyMap() + : convertMap(workOrderService.getWorkOrderList(parentIds), MesProWorkOrderDO::getId); // 2. 拼接 VO return BeanUtils.toBean(list, MesProWorkOrderRespVO.class, vo -> { MapUtils.findAndThen(itemMap, vo.getProductId(), item -> vo.setProductName(item.getName()).setProductCode(item.getCode()) .setProductSpec(item.getSpecification())); MapUtils.findAndThen(clientMap, vo.getClientId(), - client -> vo.setClientName(client.getName())); + client -> vo.setClientName(client.getName()).setClientCode(client.getCode())); MapUtils.findAndThen(vendorMap, vo.getVendorId(), vendor -> vo.setVendorName(vendor.getName())); MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(), unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); + MapUtils.findAndThen(parentMap, vo.getParentId(), + parent -> vo.setParentCode(parent.getCode())); }); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java index af81b21..faf99cc 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java @@ -83,6 +83,10 @@ public class MesProWorkOrderRespVO { @Schema(description = "客户编号", example = "300") private Long clientId; + @Schema(description = "客户编码", example = "C-001") + @ExcelProperty("客户编码") + private String clientCode; + @Schema(description = "客户名称", example = "客户 A") @ExcelProperty("客户名称") private String clientName; @@ -105,6 +109,9 @@ public class MesProWorkOrderRespVO { @Schema(description = "父工单编号", example = "0") private Long parentId; + @Schema(description = "父工单编码", example = "WO-001") + private String parentCode; + @Schema(description = "完成时间") @ExcelProperty("完成时间") private LocalDateTime finishDate; diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java new file mode 100644 index 0000000..b6fa8b3 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.mes.enums.pro; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 时间单位枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesTimeUnitTypeEnum implements ArrayValuable { + + MINUTE("MINUTE", "分钟"), + HOUR("HOUR", "小时"), + DAY("DAY", "天"); + + public static final String[] ARRAYS = Arrays.stream(values()).map(MesTimeUnitTypeEnum::getType).toArray(String[]::new); + + /** + * 类型值 + */ + private final String type; + /** + * 类型名 + */ + private final String name; + + @Override + public String[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderService.java index 02fc879..61ad50f 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderService.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderService.java @@ -6,6 +6,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkO import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; import jakarta.validation.Valid; +import java.util.Collection; +import java.util.List; + /** * MES 生产工单 Service 接口 * @@ -73,4 +76,12 @@ public interface MesProWorkOrderService { */ void cancelWorkOrder(Long id); + /** + * 获得工单列表 + * + * @param ids 编号数组 + * @return 工单列表 + */ + List getWorkOrderList(Collection ids); + } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderServiceImpl.java index 108f305..01519c5 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -161,6 +162,11 @@ public class MesProWorkOrderServiceImpl implements MesProWorkOrderService { // TODO @芋艿:pro_task 未迁移,暂不级联更新任务状态 } + @Override + public List getWorkOrderList(Collection ids) { + return workOrderMapper.selectByIds(ids); + } + // ==================== 校验方法 ==================== private void validateWorkOrderCodeUnique(Long id, String code) { -- libgit2 0.21.4