Commit 5a3fe9400d1b7f89a4794798d6e74515cb2aad2d
1 parent
74005fc6
fix(mes): 修复生产工单模块 TODO,新增 clientCode/parentCode 拼接及 getWorkOrderList 方法
- RespVO 新增 clientCode、parentCode 字段 - Service 新增 getWorkOrderList(ids) 批量查询方法 - Controller buildWorkOrderRespVOList 拼接客户编码、父工单编码
Showing
5 changed files
with
72 additions
and
1 deletions
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; | @@ -35,9 +35,11 @@ import java.io.IOException; | ||
| 35 | import java.util.Collections; | 35 | import java.util.Collections; |
| 36 | import java.util.List; | 36 | import java.util.List; |
| 37 | import java.util.Map; | 37 | import java.util.Map; |
| 38 | +import java.util.Set; | ||
| 38 | 39 | ||
| 39 | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | 40 | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| 40 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 41 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 42 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 41 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 43 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 42 | 44 | ||
| 43 | @Tag(name = "管理后台 - MES 生产工单") | 45 | @Tag(name = "管理后台 - MES 生产工单") |
| @@ -150,17 +152,24 @@ public class MesProWorkOrderController { | @@ -150,17 +152,24 @@ public class MesProWorkOrderController { | ||
| 150 | convertSet(list, MesProWorkOrderDO::getVendorId)); | 152 | convertSet(list, MesProWorkOrderDO::getVendorId)); |
| 151 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | 153 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| 152 | convertSet(list, MesProWorkOrderDO::getUnitMeasureId)); | 154 | convertSet(list, MesProWorkOrderDO::getUnitMeasureId)); |
| 155 | + // TODO @AI:直接 workOrderService.getWorkOrderMap,内部调用 workOrderService.getWorkOrderList | ||
| 156 | + Set<Long> parentIds = convertSet(list, MesProWorkOrderDO::getParentId); | ||
| 157 | + Map<Long, MesProWorkOrderDO> parentMap = CollUtil.isEmpty(parentIds) | ||
| 158 | + ? Collections.emptyMap() | ||
| 159 | + : convertMap(workOrderService.getWorkOrderList(parentIds), MesProWorkOrderDO::getId); | ||
| 153 | // 2. 拼接 VO | 160 | // 2. 拼接 VO |
| 154 | return BeanUtils.toBean(list, MesProWorkOrderRespVO.class, vo -> { | 161 | return BeanUtils.toBean(list, MesProWorkOrderRespVO.class, vo -> { |
| 155 | MapUtils.findAndThen(itemMap, vo.getProductId(), item -> | 162 | MapUtils.findAndThen(itemMap, vo.getProductId(), item -> |
| 156 | vo.setProductName(item.getName()).setProductCode(item.getCode()) | 163 | vo.setProductName(item.getName()).setProductCode(item.getCode()) |
| 157 | .setProductSpec(item.getSpecification())); | 164 | .setProductSpec(item.getSpecification())); |
| 158 | MapUtils.findAndThen(clientMap, vo.getClientId(), | 165 | MapUtils.findAndThen(clientMap, vo.getClientId(), |
| 159 | - client -> vo.setClientName(client.getName())); | 166 | + client -> vo.setClientName(client.getName()).setClientCode(client.getCode())); |
| 160 | MapUtils.findAndThen(vendorMap, vo.getVendorId(), | 167 | MapUtils.findAndThen(vendorMap, vo.getVendorId(), |
| 161 | vendor -> vo.setVendorName(vendor.getName())); | 168 | vendor -> vo.setVendorName(vendor.getName())); |
| 162 | MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(), | 169 | MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(), |
| 163 | unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | 170 | unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); |
| 171 | + MapUtils.findAndThen(parentMap, vo.getParentId(), | ||
| 172 | + parent -> vo.setParentCode(parent.getCode())); | ||
| 164 | }); | 173 | }); |
| 165 | } | 174 | } |
| 166 | 175 |
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 { | @@ -83,6 +83,10 @@ public class MesProWorkOrderRespVO { | ||
| 83 | @Schema(description = "客户编号", example = "300") | 83 | @Schema(description = "客户编号", example = "300") |
| 84 | private Long clientId; | 84 | private Long clientId; |
| 85 | 85 | ||
| 86 | + @Schema(description = "客户编码", example = "C-001") | ||
| 87 | + @ExcelProperty("客户编码") | ||
| 88 | + private String clientCode; | ||
| 89 | + | ||
| 86 | @Schema(description = "客户名称", example = "客户 A") | 90 | @Schema(description = "客户名称", example = "客户 A") |
| 87 | @ExcelProperty("客户名称") | 91 | @ExcelProperty("客户名称") |
| 88 | private String clientName; | 92 | private String clientName; |
| @@ -105,6 +109,9 @@ public class MesProWorkOrderRespVO { | @@ -105,6 +109,9 @@ public class MesProWorkOrderRespVO { | ||
| 105 | @Schema(description = "父工单编号", example = "0") | 109 | @Schema(description = "父工单编号", example = "0") |
| 106 | private Long parentId; | 110 | private Long parentId; |
| 107 | 111 | ||
| 112 | + @Schema(description = "父工单编码", example = "WO-001") | ||
| 113 | + private String parentCode; | ||
| 114 | + | ||
| 108 | @Schema(description = "完成时间") | 115 | @Schema(description = "完成时间") |
| 109 | @ExcelProperty("完成时间") | 116 | @ExcelProperty("完成时间") |
| 110 | private LocalDateTime finishDate; | 117 | private LocalDateTime finishDate; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/pro/MesTimeUnitTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.enums.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.ArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * MES 时间单位枚举 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +@Getter | ||
| 15 | +@AllArgsConstructor | ||
| 16 | +public enum MesTimeUnitTypeEnum implements ArrayValuable<String> { | ||
| 17 | + | ||
| 18 | + MINUTE("MINUTE", "分钟"), | ||
| 19 | + HOUR("HOUR", "小时"), | ||
| 20 | + DAY("DAY", "天"); | ||
| 21 | + | ||
| 22 | + public static final String[] ARRAYS = Arrays.stream(values()).map(MesTimeUnitTypeEnum::getType).toArray(String[]::new); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 类型值 | ||
| 26 | + */ | ||
| 27 | + private final String type; | ||
| 28 | + /** | ||
| 29 | + * 类型名 | ||
| 30 | + */ | ||
| 31 | + private final String name; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public String[] array() { | ||
| 35 | + return ARRAYS; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
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 | @@ -6,6 +6,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkO | ||
| 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; |
| 7 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | 8 | ||
| 9 | +import java.util.Collection; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 9 | /** | 12 | /** |
| 10 | * MES 生产工单 Service 接口 | 13 | * MES 生产工单 Service 接口 |
| 11 | * | 14 | * |
| @@ -73,4 +76,12 @@ public interface MesProWorkOrderService { | @@ -73,4 +76,12 @@ public interface MesProWorkOrderService { | ||
| 73 | */ | 76 | */ |
| 74 | void cancelWorkOrder(Long id); | 77 | void cancelWorkOrder(Long id); |
| 75 | 78 | ||
| 79 | + /** | ||
| 80 | + * 获得工单列表 | ||
| 81 | + * | ||
| 82 | + * @param ids 编号数组 | ||
| 83 | + * @return 工单列表 | ||
| 84 | + */ | ||
| 85 | + List<MesProWorkOrderDO> getWorkOrderList(Collection<Long> ids); | ||
| 86 | + | ||
| 76 | } | 87 | } |
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; | @@ -24,6 +24,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 24 | 24 | ||
| 25 | import java.math.BigDecimal; | 25 | import java.math.BigDecimal; |
| 26 | import java.time.LocalDateTime; | 26 | import java.time.LocalDateTime; |
| 27 | +import java.util.Collection; | ||
| 27 | import java.util.List; | 28 | import java.util.List; |
| 28 | 29 | ||
| 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 30 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| @@ -161,6 +162,11 @@ public class MesProWorkOrderServiceImpl implements MesProWorkOrderService { | @@ -161,6 +162,11 @@ public class MesProWorkOrderServiceImpl implements MesProWorkOrderService { | ||
| 161 | // TODO @芋艿:pro_task 未迁移,暂不级联更新任务状态 | 162 | // TODO @芋艿:pro_task 未迁移,暂不级联更新任务状态 |
| 162 | } | 163 | } |
| 163 | 164 | ||
| 165 | + @Override | ||
| 166 | + public List<MesProWorkOrderDO> getWorkOrderList(Collection<Long> ids) { | ||
| 167 | + return workOrderMapper.selectByIds(ids); | ||
| 168 | + } | ||
| 169 | + | ||
| 164 | // ==================== 校验方法 ==================== | 170 | // ==================== 校验方法 ==================== |
| 165 | 171 | ||
| 166 | private void validateWorkOrderCodeUnique(Long id, String code) { | 172 | private void validateWorkOrderCodeUnique(Long id, String code) { |