Commit d1d19393351fbd7ce980f754aa6a4712d74f143f
1 parent
a2832d99
✨ feat(mes): 移除单位编号字段,优化工单 BOM 相关逻辑
Showing
5 changed files
with
7 additions
and
18 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkorderBomController.java
| @@ -113,7 +113,7 @@ public class MesProWorkOrderBomController { | @@ -113,7 +113,7 @@ public class MesProWorkOrderBomController { | ||
| 113 | 113 | ||
| 114 | // 2. 逐层展开,得到叶子物料 itemId → quantity | 114 | // 2. 逐层展开,得到叶子物料 itemId → quantity |
| 115 | Map<Long, BigDecimal> leafItems = buildWorkOrderItems(bomList); | 115 | Map<Long, BigDecimal> leafItems = buildWorkOrderItems(bomList); |
| 116 | - if (leafItems.isEmpty()) { | 116 | + if (CollUtil.isEmpty(leafItems)) { |
| 117 | return success(Collections.emptyList()); | 117 | return success(Collections.emptyList()); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| @@ -147,7 +147,7 @@ public class MesProWorkOrderBomController { | @@ -147,7 +147,7 @@ public class MesProWorkOrderBomController { | ||
| 147 | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | 147 | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( |
| 148 | convertSet(list, MesProWorkOrderBomDO::getItemId)); | 148 | convertSet(list, MesProWorkOrderBomDO::getItemId)); |
| 149 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | 149 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| 150 | - convertSet(list, MesProWorkOrderBomDO::getUnitMeasureId)); | 150 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); |
| 151 | Map<Long, MesMdItemTypeDO> itemTypeMap = itemTypeService.getItemTypeMap( | 151 | Map<Long, MesMdItemTypeDO> itemTypeMap = itemTypeService.getItemTypeMap( |
| 152 | convertSet(itemMap.values(), MesMdItemDO::getItemTypeId)); | 152 | convertSet(itemMap.values(), MesMdItemDO::getItemTypeId)); |
| 153 | // 2. 拼接 VO | 153 | // 2. 拼接 VO |
| @@ -157,9 +157,9 @@ public class MesProWorkOrderBomController { | @@ -157,9 +157,9 @@ public class MesProWorkOrderBomController { | ||
| 157 | .setItemSpec(item.getSpecification()); | 157 | .setItemSpec(item.getSpecification()); |
| 158 | MapUtils.findAndThen(itemTypeMap, item.getItemTypeId(), | 158 | MapUtils.findAndThen(itemTypeMap, item.getItemTypeId(), |
| 159 | itemType -> vo.setItemOrProduct(itemType.getItemOrProduct())); | 159 | itemType -> vo.setItemOrProduct(itemType.getItemOrProduct())); |
| 160 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | ||
| 161 | + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | ||
| 160 | }); | 162 | }); |
| 161 | - MapUtils.findAndThen(unitMeasureMap, vo.getUnitMeasureId(), | ||
| 162 | - unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | ||
| 163 | }); | 163 | }); |
| 164 | } | 164 | } |
| 165 | 165 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/vo/bom/MesProWorkorderBomSaveReqVO.java
| @@ -21,10 +21,6 @@ public class MesProWorkOrderBomSaveReqVO { | @@ -21,10 +21,6 @@ public class MesProWorkOrderBomSaveReqVO { | ||
| 21 | @NotNull(message = "BOM 物料不能为空") | 21 | @NotNull(message = "BOM 物料不能为空") |
| 22 | private Long itemId; | 22 | private Long itemId; |
| 23 | 23 | ||
| 24 | - @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "300") | ||
| 25 | - @NotNull(message = "单位不能为空") | ||
| 26 | - private Long unitMeasureId; | ||
| 27 | - | ||
| 28 | @Schema(description = "预计使用量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10.00") | 24 | @Schema(description = "预计使用量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10.00") |
| 29 | @NotNull(message = "预计使用量不能为空") | 25 | @NotNull(message = "预计使用量不能为空") |
| 30 | private BigDecimal quantity; | 26 | private BigDecimal quantity; |
| @@ -32,4 +28,4 @@ public class MesProWorkOrderBomSaveReqVO { | @@ -32,4 +28,4 @@ public class MesProWorkOrderBomSaveReqVO { | ||
| 32 | @Schema(description = "备注", example = "备注") | 28 | @Schema(description = "备注", example = "备注") |
| 33 | private String remark; | 29 | private String remark; |
| 34 | 30 | ||
| 35 | - } | 31 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/workorder/MesProWorkorderBomDO.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder; | ||
| 2 | 2 | ||
| 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.item.MesMdItemDO; | 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 com.baomidou.mybatisplus.annotation.KeySequence; | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | import com.baomidou.mybatisplus.annotation.TableId; | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -43,12 +42,6 @@ public class MesProWorkOrderBomDO extends BaseDO { | @@ -43,12 +42,6 @@ public class MesProWorkOrderBomDO extends BaseDO { | ||
| 43 | */ | 42 | */ |
| 44 | private Long itemId; | 43 | private Long itemId; |
| 45 | /** | 44 | /** |
| 46 | - * 单位编号 | ||
| 47 | - * | ||
| 48 | - * 关联 {@link MesMdUnitMeasureDO#getId()} | ||
| 49 | - */ | ||
| 50 | - private Long unitMeasureId; | ||
| 51 | - /** | ||
| 52 | * 预计使用量 | 45 | * 预计使用量 |
| 53 | */ | 46 | */ |
| 54 | private BigDecimal quantity; | 47 | private BigDecimal quantity; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
| @@ -7,6 +7,7 @@ package cn.iocoder.yudao.module.mes.enums; | @@ -7,6 +7,7 @@ package cn.iocoder.yudao.module.mes.enums; | ||
| 7 | */ | 7 | */ |
| 8 | public interface DictTypeConstants { | 8 | public interface DictTypeConstants { |
| 9 | 9 | ||
| 10 | + String MES_MD_ITEM_OR_PRODUCT = "mes_md_item_or_product"; // MES 物料产品标识 | ||
| 10 | String MES_CLIENT_TYPE = "mes_client_type"; // MES 客户类型 | 11 | String MES_CLIENT_TYPE = "mes_client_type"; // MES 客户类型 |
| 11 | String MES_VENDOR_LEVEL = "mes_vendor_level"; // MES 供应商级别 | 12 | String MES_VENDOR_LEVEL = "mes_vendor_level"; // MES 供应商级别 |
| 12 | String MES_CAL_HOLIDAY_TYPE = "mes_cal_holiday_type"; // MES 假期类型 | 13 | String MES_CAL_HOLIDAY_TYPE = "mes_cal_holiday_type"; // MES 假期类型 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/workorder/MesProWorkorderBomServiceImpl.java
| @@ -127,9 +127,8 @@ public class MesProWorkOrderBomServiceImpl implements MesProWorkOrderBomService | @@ -127,9 +127,8 @@ public class MesProWorkOrderBomServiceImpl implements MesProWorkOrderBomService | ||
| 127 | // 3. 构建工单 BOM 列表并批量插入 | 127 | // 3. 构建工单 BOM 列表并批量插入 |
| 128 | List<MesProWorkOrderBomDO> bomList = new ArrayList<>(productBomList.size()); | 128 | List<MesProWorkOrderBomDO> bomList = new ArrayList<>(productBomList.size()); |
| 129 | for (MesMdProductBomDO productBom : productBomList) { | 129 | for (MesMdProductBomDO productBom : productBomList) { |
| 130 | - MesMdItemDO bomItem = itemMap.get(productBom.getBomItemId()); | ||
| 131 | bomList.add(new MesProWorkOrderBomDO().setWorkOrderId(workOrderId).setItemId(productBom.getBomItemId()) | 130 | bomList.add(new MesProWorkOrderBomDO().setWorkOrderId(workOrderId).setItemId(productBom.getBomItemId()) |
| 132 | - .setQuantity(reqVO.getQuantity().multiply(productBom.getQuantity())).setUnitMeasureId(bomItem.getUnitMeasureId())); | 131 | + .setQuantity(reqVO.getQuantity().multiply(productBom.getQuantity()))); |
| 133 | } | 132 | } |
| 134 | workOrderBomMapper.insertBatch(bomList); | 133 | workOrderBomMapper.insertBatch(bomList); |
| 135 | } | 134 | } |