Commit a2832d9972bad3d6afd349ad8053bb20914d5907
1 parent
f51654cc
✨ feat(mes): 移除单位编号字段,优化工单请求参数
Showing
5 changed files
with
15 additions
and
24 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderController.java
| @@ -165,21 +165,23 @@ public class MesProWorkOrderController { | @@ -165,21 +165,23 @@ public class MesProWorkOrderController { | ||
| 165 | convertSet(list, MesProWorkOrderDO::getClientId)); | 165 | convertSet(list, MesProWorkOrderDO::getClientId)); |
| 166 | Map<Long, MesMdVendorDO> vendorMap = vendorService.getVendorMap( | 166 | Map<Long, MesMdVendorDO> vendorMap = vendorService.getVendorMap( |
| 167 | convertSet(list, MesProWorkOrderDO::getVendorId)); | 167 | convertSet(list, MesProWorkOrderDO::getVendorId)); |
| 168 | + // 单位从产品关联的 item 获得 | ||
| 168 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | 169 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| 169 | - convertSet(list, MesProWorkOrderDO::getUnitMeasureId)); | 170 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); |
| 170 | Map<Long, MesProWorkOrderDO> parentMap = workOrderService.getWorkOrderMap( | 171 | Map<Long, MesProWorkOrderDO> parentMap = workOrderService.getWorkOrderMap( |
| 171 | convertSet(list, MesProWorkOrderDO::getParentId)); | 172 | convertSet(list, MesProWorkOrderDO::getParentId)); |
| 172 | - // 2. 拼接 VO | 173 | + // 2. 拼接 VO(单位名称从产品关联的 item 获得) |
| 173 | return BeanUtils.toBean(list, MesProWorkOrderRespVO.class, vo -> { | 174 | return BeanUtils.toBean(list, MesProWorkOrderRespVO.class, vo -> { |
| 174 | - MapUtils.findAndThen(itemMap, vo.getProductId(), item -> | ||
| 175 | - vo.setProductName(item.getName()).setProductCode(item.getCode()) | ||
| 176 | - .setProductSpec(item.getSpecification())); | 175 | + MapUtils.findAndThen(itemMap, vo.getProductId(), item -> { |
| 176 | + vo.setProductName(item.getName()).setProductCode(item.getCode()) | ||
| 177 | + .setProductSpec(item.getSpecification()); | ||
| 178 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | ||
| 179 | + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | ||
| 180 | + }); | ||
| 177 | MapUtils.findAndThen(clientMap, vo.getClientId(), | 181 | MapUtils.findAndThen(clientMap, vo.getClientId(), |
| 178 | client -> vo.setClientName(client.getName()).setClientCode(client.getCode())); | 182 | client -> vo.setClientName(client.getName()).setClientCode(client.getCode())); |
| 179 | MapUtils.findAndThen(vendorMap, vo.getVendorId(), | 183 | MapUtils.findAndThen(vendorMap, vo.getVendorId(), |
| 180 | vendor -> vo.setVendorName(vendor.getName()).setVendorCode(vendor.getCode())); | 184 | vendor -> vo.setVendorName(vendor.getName()).setVendorCode(vendor.getCode())); |
| 181 | - MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(), | ||
| 182 | - unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | ||
| 183 | MapUtils.findAndThen(parentMap, vo.getParentId(), | 185 | MapUtils.findAndThen(parentMap, vo.getParentId(), |
| 184 | parent -> vo.setParentCode(parent.getCode())); | 186 | parent -> vo.setParentCode(parent.getCode())); |
| 185 | }); | 187 | }); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderRespVO.java
| @@ -57,9 +57,6 @@ public class MesProWorkOrderRespVO { | @@ -57,9 +57,6 @@ public class MesProWorkOrderRespVO { | ||
| 57 | @ExcelProperty("规格型号") | 57 | @ExcelProperty("规格型号") |
| 58 | private String productSpec; | 58 | private String productSpec; |
| 59 | 59 | ||
| 60 | - @Schema(description = "单位编号", example = "200") | ||
| 61 | - private Long unitMeasureId; | ||
| 62 | - | ||
| 63 | @Schema(description = "单位名称", example = "个") | 60 | @Schema(description = "单位名称", example = "个") |
| 64 | @ExcelProperty("单位") | 61 | @ExcelProperty("单位") |
| 65 | private String unitMeasureName; | 62 | private String unitMeasureName; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/MesProWorkorderSaveReqVO.java
| @@ -38,10 +38,6 @@ public class MesProWorkOrderSaveReqVO { | @@ -38,10 +38,6 @@ public class MesProWorkOrderSaveReqVO { | ||
| 38 | @NotNull(message = "产品不能为空") | 38 | @NotNull(message = "产品不能为空") |
| 39 | private Long productId; | 39 | private Long productId; |
| 40 | 40 | ||
| 41 | - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | ||
| 42 | - @NotNull(message = "单位不能为空") | ||
| 43 | - private Long unitMeasureId; | ||
| 44 | - | ||
| 45 | @Schema(description = "生产数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | 41 | @Schema(description = "生产数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") |
| 46 | @NotNull(message = "生产数量不能为空") | 42 | @NotNull(message = "生产数量不能为空") |
| 47 | private BigDecimal quantity; | 43 | private BigDecimal quantity; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/workorder/MesProWorkorderDO.java
| @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder; | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; |
| 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| 6 | -import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | ||
| 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.vendor.MesMdVendorDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.vendor.MesMdVendorDO; |
| 8 | import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderSourceTypeEnum; | 7 | import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderSourceTypeEnum; |
| 9 | import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum; | 8 | import cn.iocoder.yudao.module.mes.enums.pro.MesProWorkOrderStatusEnum; |
| @@ -72,12 +71,6 @@ public class MesProWorkOrderDO extends BaseDO { | @@ -72,12 +71,6 @@ public class MesProWorkOrderDO extends BaseDO { | ||
| 72 | */ | 71 | */ |
| 73 | private Long productId; | 72 | private Long productId; |
| 74 | /** | 73 | /** |
| 75 | - * 单位编号 | ||
| 76 | - * | ||
| 77 | - * 关联 {@link MesMdUnitMeasureDO#getId()} | ||
| 78 | - */ | ||
| 79 | - private Long unitMeasureId; | ||
| 80 | - /** | ||
| 81 | * 生产数量 | 74 | * 生产数量 |
| 82 | */ | 75 | */ |
| 83 | private BigDecimal quantity; | 76 | private BigDecimal quantity; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderBomServiceImpl.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.mes.service.pro.workorder; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.mes.service.pro.workorder; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkOrderSaveReqVO; | 6 | import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkOrderSaveReqVO; |
| 8 | import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.bom.MesProWorkOrderBomPageReqVO; | 7 | import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.bom.MesProWorkOrderBomPageReqVO; |
| @@ -18,9 +17,13 @@ import org.springframework.context.annotation.Lazy; | @@ -18,9 +17,13 @@ import org.springframework.context.annotation.Lazy; | ||
| 18 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 19 | import org.springframework.validation.annotation.Validated; | 18 | import org.springframework.validation.annotation.Validated; |
| 20 | 19 | ||
| 21 | -import java.util.*; | 20 | +import java.util.ArrayList; |
| 21 | +import java.util.List; | ||
| 22 | +import java.util.Map; | ||
| 23 | +import java.util.Set; | ||
| 22 | 24 | ||
| 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 24 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MD_ITEM_NOT_EXISTS; | 27 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MD_ITEM_NOT_EXISTS; |
| 25 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_WORK_ORDER_BOM_NOT_EXISTS; | 28 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_WORK_ORDER_BOM_NOT_EXISTS; |
| 26 | 29 | ||
| @@ -113,7 +116,7 @@ public class MesProWorkOrderBomServiceImpl implements MesProWorkOrderBomService | @@ -113,7 +116,7 @@ public class MesProWorkOrderBomServiceImpl implements MesProWorkOrderBomService | ||
| 113 | return; | 116 | return; |
| 114 | } | 117 | } |
| 115 | // 2.2 批量获取并校验 BOM 物料 | 118 | // 2.2 批量获取并校验 BOM 物料 |
| 116 | - Set<Long> bomItemIds = CollectionUtils.convertSet(productBomList, MesMdProductBomDO::getBomItemId); | 119 | + Set<Long> bomItemIds = convertSet(productBomList, MesMdProductBomDO::getBomItemId); |
| 117 | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(bomItemIds); | 120 | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(bomItemIds); |
| 118 | bomItemIds.forEach(itemId -> { | 121 | bomItemIds.forEach(itemId -> { |
| 119 | if (itemMap.get(itemId) == null) { | 122 | if (itemMap.get(itemId) == null) { |