Commit 6358bff95194516c00e4d9d17a57e0619cf1eaa8
1 parent
5a16d833
✨ feat(mes): 添加仓库、库区和库位名称字段及相关校验
Showing
8 changed files
with
121 additions
and
46 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscissue/MesWmMiscIssueLineController.java
| ... | ... | @@ -11,9 +11,15 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.miscissue.vo.line.MesWmMi |
| 11 | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| 13 | 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.miscissue.MesWmMiscIssueLineDO; |
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | |
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | |
| 16 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | |
| 14 | 17 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| 15 | 18 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| 16 | 19 | import cn.iocoder.yudao.module.mes.service.wm.miscissue.MesWmMiscIssueLineService; |
| 20 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService; | |
| 21 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService; | |
| 22 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; | |
| 17 | 23 | import io.swagger.v3.oas.annotations.Operation; |
| 18 | 24 | import io.swagger.v3.oas.annotations.Parameter; |
| 19 | 25 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -45,6 +51,15 @@ public class MesWmMiscIssueLineController { |
| 45 | 51 | @Resource |
| 46 | 52 | private MesMdUnitMeasureService unitMeasureService; |
| 47 | 53 | |
| 54 | + @Resource | |
| 55 | + private MesWmWarehouseService warehouseService; | |
| 56 | + | |
| 57 | + @Resource | |
| 58 | + private MesWmWarehouseLocationService warehouseLocationService; | |
| 59 | + | |
| 60 | + @Resource | |
| 61 | + private MesWmWarehouseAreaService warehouseAreaService; | |
| 62 | + | |
| 48 | 63 | @PostMapping("/create") |
| 49 | 64 | @Operation(summary = "创建杂项出库单行") |
| 50 | 65 | @PreAuthorize("@ss.hasPermission('mes:wm-misc-issue:create')") |
| ... | ... | @@ -101,6 +116,13 @@ public class MesWmMiscIssueLineController { |
| 101 | 116 | convertSet(list, MesWmMiscIssueLineDO::getItemId)); |
| 102 | 117 | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| 103 | 118 | convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); |
| 119 | + Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 120 | + convertSet(list, MesWmMiscIssueLineDO::getWarehouseId)); | |
| 121 | + Map<Long, MesWmWarehouseLocationDO> locationMap = warehouseLocationService.getWarehouseLocationMap( | |
| 122 | + convertSet(list, MesWmMiscIssueLineDO::getLocationId)); | |
| 123 | + Map<Long, MesWmWarehouseAreaDO> areaMap = warehouseAreaService.getWarehouseAreaMap( | |
| 124 | + convertSet(list, MesWmMiscIssueLineDO::getAreaId)); | |
| 125 | + | |
| 104 | 126 | // 2. 构建结果 |
| 105 | 127 | return BeanUtils.toBean(list, MesWmMiscIssueLineRespVO.class, vo -> { |
| 106 | 128 | MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { |
| ... | ... | @@ -108,6 +130,9 @@ public class MesWmMiscIssueLineController { |
| 108 | 130 | MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), |
| 109 | 131 | unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); |
| 110 | 132 | }); |
| 133 | + MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), warehouse -> vo.setWarehouseName(warehouse.getName())); | |
| 134 | + MapUtils.findAndThen(locationMap, vo.getLocationId(), location -> vo.setLocationName(location.getName())); | |
| 135 | + MapUtils.findAndThen(areaMap, vo.getAreaId(), area -> vo.setAreaName(area.getName())); | |
| 111 | 136 | }); |
| 112 | 137 | } |
| 113 | 138 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscissue/vo/MesWmMiscIssueSaveReqVO.java
| ... | ... | @@ -35,7 +35,8 @@ public class MesWmMiscIssueSaveReqVO { |
| 35 | 35 | @Schema(description = "来源单据类型", example = "PURCHASE_ORDER") |
| 36 | 36 | private String sourceDocType; |
| 37 | 37 | |
| 38 | - @Schema(description = "出库日期") | |
| 38 | + @Schema(description = "出库日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 39 | + @NotNull(message = "出库日期不能为空") | |
| 39 | 40 | private LocalDateTime issueDate; |
| 40 | 41 | |
| 41 | 42 | @Schema(description = "备注", example = "备注") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscissue/vo/line/MesWmMiscIssueLineRespVO.java
| ... | ... | @@ -52,6 +52,15 @@ public class MesWmMiscIssueLineRespVO { |
| 52 | 52 | @Schema(description = "库位编号", example = "1") |
| 53 | 53 | private Long areaId; |
| 54 | 54 | |
| 55 | + @Schema(description = "仓库名称", example = "原料仓") | |
| 56 | + private String warehouseName; | |
| 57 | + | |
| 58 | + @Schema(description = "库区名称", example = "A区") | |
| 59 | + private String locationName; | |
| 60 | + | |
| 61 | + @Schema(description = "库位名称", example = "1排1架") | |
| 62 | + private String areaName; | |
| 63 | + | |
| 55 | 64 | @Schema(description = "备注", example = "备注") |
| 56 | 65 | private String remark; |
| 57 | 66 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscreceipt/MesWmMiscReceiptLineController.java
| ... | ... | @@ -17,9 +17,24 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 17 | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | 18 | import org.springframework.web.bind.annotation.*; |
| 19 | 19 | |
| 20 | +import java.util.Collections; | |
| 20 | 21 | import java.util.List; |
| 22 | +import java.util.Map; | |
| 21 | 23 | |
| 22 | 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 26 | +import cn.hutool.core.collection.CollUtil; | |
| 27 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 28 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | |
| 29 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | |
| 30 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO; | |
| 31 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseLocationDO; | |
| 32 | +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO; | |
| 33 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 34 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 35 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseService; | |
| 36 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseLocationService; | |
| 37 | +import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseAreaService; | |
| 23 | 38 | |
| 24 | 39 | /** |
| 25 | 40 | * MES 杂项入库单行 Controller |
| ... | ... | @@ -33,6 +48,21 @@ public class MesWmMiscReceiptLineController { |
| 33 | 48 | @Resource |
| 34 | 49 | private MesWmMiscReceiptLineService miscReceiptLineService; |
| 35 | 50 | |
| 51 | + @Resource | |
| 52 | + private MesMdItemService itemService; | |
| 53 | + | |
| 54 | + @Resource | |
| 55 | + private MesMdUnitMeasureService unitMeasureService; | |
| 56 | + | |
| 57 | + @Resource | |
| 58 | + private MesWmWarehouseService warehouseService; | |
| 59 | + | |
| 60 | + @Resource | |
| 61 | + private MesWmWarehouseLocationService warehouseLocationService; | |
| 62 | + | |
| 63 | + @Resource | |
| 64 | + private MesWmWarehouseAreaService warehouseAreaService; | |
| 65 | + | |
| 36 | 66 | @PostMapping("/create") |
| 37 | 67 | @Operation(summary = "创建杂项入库单行") |
| 38 | 68 | @PreAuthorize("@ss.hasPermission('mes:wm:misc-receipt:create')") |
| ... | ... | @@ -63,7 +93,10 @@ public class MesWmMiscReceiptLineController { |
| 63 | 93 | @PreAuthorize("@ss.hasPermission('mes:wm:misc-receipt:query')") |
| 64 | 94 | public CommonResult<MesWmMiscReceiptLineRespVO> getMiscReceiptLine(@RequestParam("id") Long id) { |
| 65 | 95 | MesWmMiscReceiptLineDO line = miscReceiptLineService.getMiscReceiptLine(id); |
| 66 | - return success(BeanUtils.toBean(line, MesWmMiscReceiptLineRespVO.class)); | |
| 96 | + if (line == null) { | |
| 97 | + return success(null); | |
| 98 | + } | |
| 99 | + return success(buildRespVOList(Collections.singletonList(line)).get(0)); | |
| 67 | 100 | } |
| 68 | 101 | |
| 69 | 102 | @GetMapping("/list-by-receipt-id") |
| ... | ... | @@ -72,7 +105,7 @@ public class MesWmMiscReceiptLineController { |
| 72 | 105 | @PreAuthorize("@ss.hasPermission('mes:wm:misc-receipt:query')") |
| 73 | 106 | public CommonResult<List<MesWmMiscReceiptLineRespVO>> getMiscReceiptLineListByReceiptId(@RequestParam("receiptId") Long receiptId) { |
| 74 | 107 | List<MesWmMiscReceiptLineDO> list = miscReceiptLineService.getMiscReceiptLineListByReceiptId(receiptId); |
| 75 | - return success(BeanUtils.toBean(list, MesWmMiscReceiptLineRespVO.class)); | |
| 108 | + return success(buildRespVOList(list)); | |
| 76 | 109 | } |
| 77 | 110 | |
| 78 | 111 | @GetMapping("/page") |
| ... | ... | @@ -80,7 +113,38 @@ public class MesWmMiscReceiptLineController { |
| 80 | 113 | @PreAuthorize("@ss.hasPermission('mes:wm:misc-receipt:query')") |
| 81 | 114 | public CommonResult<PageResult<MesWmMiscReceiptLineRespVO>> getMiscReceiptLinePage(@Valid MesWmMiscReceiptLinePageReqVO pageReqVO) { |
| 82 | 115 | PageResult<MesWmMiscReceiptLineDO> pageResult = miscReceiptLineService.getMiscReceiptLinePage(pageReqVO); |
| 83 | - return success(BeanUtils.toBean(pageResult, MesWmMiscReceiptLineRespVO.class)); | |
| 116 | + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 117 | + } | |
| 118 | + | |
| 119 | + // ==================== 拼接 VO ==================== | |
| 120 | + | |
| 121 | + private List<MesWmMiscReceiptLineRespVO> buildRespVOList(List<MesWmMiscReceiptLineDO> list) { | |
| 122 | + if (CollUtil.isEmpty(list)) { | |
| 123 | + return Collections.emptyList(); | |
| 124 | + } | |
| 125 | + // 1. 获得关联数据 | |
| 126 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 127 | + convertSet(list, MesWmMiscReceiptLineDO::getItemId)); | |
| 128 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 129 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | |
| 130 | + Map<Long, MesWmWarehouseDO> warehouseMap = warehouseService.getWarehouseMap( | |
| 131 | + convertSet(list, MesWmMiscReceiptLineDO::getWarehouseId)); | |
| 132 | + Map<Long, MesWmWarehouseLocationDO> locationMap = warehouseLocationService.getWarehouseLocationMap( | |
| 133 | + convertSet(list, MesWmMiscReceiptLineDO::getLocationId)); | |
| 134 | + Map<Long, MesWmWarehouseAreaDO> areaMap = warehouseAreaService.getWarehouseAreaMap( | |
| 135 | + convertSet(list, MesWmMiscReceiptLineDO::getAreaId)); | |
| 136 | + | |
| 137 | + // 2. 构建结果 | |
| 138 | + return BeanUtils.toBean(list, MesWmMiscReceiptLineRespVO.class, vo -> { | |
| 139 | + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> { | |
| 140 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification()); | |
| 141 | + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(), | |
| 142 | + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName())); | |
| 143 | + }); | |
| 144 | + MapUtils.findAndThen(warehouseMap, vo.getWarehouseId(), warehouse -> vo.setWarehouseName(warehouse.getName())); | |
| 145 | + MapUtils.findAndThen(locationMap, vo.getLocationId(), location -> vo.setLocationName(location.getName())); | |
| 146 | + MapUtils.findAndThen(areaMap, vo.getAreaId(), area -> vo.setAreaName(area.getName())); | |
| 147 | + }); | |
| 84 | 148 | } |
| 85 | 149 | |
| 86 | 150 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscreceipt/vo/line/MesWmMiscReceiptLineRespVO.java
| ... | ... | @@ -34,14 +34,26 @@ public class MesWmMiscReceiptLineRespVO { |
| 34 | 34 | @Schema(description = "库位编号", example = "1") |
| 35 | 35 | private Long areaId; |
| 36 | 36 | |
| 37 | - @Schema(description = "生产日期") | |
| 38 | - private LocalDateTime productionDate; | |
| 37 | + @Schema(description = "物料编码", example = "M001") | |
| 38 | + private String itemCode; | |
| 39 | 39 | |
| 40 | - @Schema(description = "有效期") | |
| 41 | - private LocalDateTime expireDate; | |
| 40 | + @Schema(description = "物料名称", example = "钢板") | |
| 41 | + private String itemName; | |
| 42 | 42 | |
| 43 | - @Schema(description = "生产批号", example = "PROD20260301") | |
| 44 | - private String lotNumber; | |
| 43 | + @Schema(description = "规格型号", example = "10mm*100mm") | |
| 44 | + private String specification; | |
| 45 | + | |
| 46 | + @Schema(description = "计量单位名称", example = "千克") | |
| 47 | + private String unitMeasureName; | |
| 48 | + | |
| 49 | + @Schema(description = "仓库名称", example = "原料仓") | |
| 50 | + private String warehouseName; | |
| 51 | + | |
| 52 | + @Schema(description = "库区名称", example = "A区") | |
| 53 | + private String locationName; | |
| 54 | + | |
| 55 | + @Schema(description = "库位名称", example = "1排1架") | |
| 56 | + private String areaName; | |
| 45 | 57 | |
| 46 | 58 | @Schema(description = "备注", example = "备注") |
| 47 | 59 | private String remark; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/miscreceipt/vo/line/MesWmMiscReceiptLineSaveReqVO.java
| ... | ... | @@ -6,7 +6,6 @@ import jakarta.validation.constraints.NotNull; |
| 6 | 6 | import lombok.Data; |
| 7 | 7 | |
| 8 | 8 | import java.math.BigDecimal; |
| 9 | -import java.time.LocalDateTime; | |
| 10 | 9 | |
| 11 | 10 | @Schema(description = "管理后台 - MES 杂项入库单行新增/修改 Request VO") |
| 12 | 11 | @Data |
| ... | ... | @@ -41,15 +40,6 @@ public class MesWmMiscReceiptLineSaveReqVO { |
| 41 | 40 | @Schema(description = "库位编号", example = "1") |
| 42 | 41 | private Long areaId; |
| 43 | 42 | |
| 44 | - @Schema(description = "生产日期") | |
| 45 | - private LocalDateTime productionDate; | |
| 46 | - | |
| 47 | - @Schema(description = "有效期") | |
| 48 | - private LocalDateTime expireDate; | |
| 49 | - | |
| 50 | - @Schema(description = "生产批号", example = "PROD20260301") | |
| 51 | - private String lotNumber; | |
| 52 | - | |
| 53 | 43 | @Schema(description = "备注", example = "备注") |
| 54 | 44 | private String remark; |
| 55 | 45 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/miscreceipt/MesWmMiscReceiptDetailDO.java
| ... | ... | @@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.annotation.TableName; |
| 11 | 11 | import lombok.*; |
| 12 | 12 | |
| 13 | 13 | import java.math.BigDecimal; |
| 14 | -import java.time.LocalDateTime; | |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * MES 杂项入库明细 DO |
| ... | ... | @@ -76,18 +75,6 @@ public class MesWmMiscReceiptDetailDO extends BaseDO { |
| 76 | 75 | */ |
| 77 | 76 | private Long areaId; |
| 78 | 77 | /** |
| 79 | - * 生产日期 | |
| 80 | - */ | |
| 81 | - private LocalDateTime productionDate; | |
| 82 | - /** | |
| 83 | - * 有效期 | |
| 84 | - */ | |
| 85 | - private LocalDateTime expireDate; | |
| 86 | - /** | |
| 87 | - * 生产批号 | |
| 88 | - */ | |
| 89 | - private String lotNumber; | |
| 90 | - /** | |
| 91 | 78 | * 备注 |
| 92 | 79 | */ |
| 93 | 80 | private String remark; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/miscreceipt/MesWmMiscReceiptLineDO.java
| ... | ... | @@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.annotation.TableName; |
| 11 | 11 | import lombok.*; |
| 12 | 12 | |
| 13 | 13 | import java.math.BigDecimal; |
| 14 | -import java.time.LocalDateTime; | |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * MES 杂项入库单行 DO |
| ... | ... | @@ -72,18 +71,6 @@ public class MesWmMiscReceiptLineDO extends BaseDO { |
| 72 | 71 | */ |
| 73 | 72 | private Long areaId; |
| 74 | 73 | /** |
| 75 | - * 生产日期(暂不使用) | |
| 76 | - */ | |
| 77 | - private LocalDateTime productionDate; | |
| 78 | - /** | |
| 79 | - * 有效期(暂不使用) | |
| 80 | - */ | |
| 81 | - private LocalDateTime expireDate; | |
| 82 | - /** | |
| 83 | - * 生产批号(暂不使用) | |
| 84 | - */ | |
| 85 | - private String lotNumber; | |
| 86 | - /** | |
| 87 | 74 | * 备注 |
| 88 | 75 | */ |
| 89 | 76 | private String remark; | ... | ... |