Commit 068d8951526cf73fc5a8eca5f68604c0fff6bfde

Authored by YunaiV
1 parent e93ba841

✨ feat(mes): 移除库存物资记录编号字段并优化批次处理逻辑

yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/line/MesWmSalesNoticeLineRespVO.java
@@ -19,9 +19,6 @@ public class MesWmSalesNoticeLineRespVO { @@ -19,9 +19,6 @@ public class MesWmSalesNoticeLineRespVO {
19 @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 19 @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
20 private Long itemId; 20 private Long itemId;
21 21
22 - @Schema(description = "库存物资记录编号", example = "1")  
23 - private Long materialStockId;  
24 -  
25 @Schema(description = "物料编码", example = "M001") 22 @Schema(description = "物料编码", example = "M001")
26 private String itemCode; 23 private String itemCode;
27 24
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/line/MesWmSalesNoticeLineSaveReqVO.java
@@ -22,9 +22,6 @@ public class MesWmSalesNoticeLineSaveReqVO { @@ -22,9 +22,6 @@ public class MesWmSalesNoticeLineSaveReqVO {
22 @NotNull(message = "物料编号不能为空") 22 @NotNull(message = "物料编号不能为空")
23 private Long itemId; 23 private Long itemId;
24 24
25 - @Schema(description = "库存物资记录编号", example = "1")  
26 - private Long materialStockId;  
27 -  
28 @Schema(description = "批次编号", example = "1") 25 @Schema(description = "批次编号", example = "1")
29 private Long batchId; 26 private Long batchId;
30 27
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeLineDO.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice; @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice;
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.wm.batch.MesWmBatchDO;
5 import com.baomidou.mybatisplus.annotation.KeySequence; 6 import com.baomidou.mybatisplus.annotation.KeySequence;
6 import com.baomidou.mybatisplus.annotation.TableId; 7 import com.baomidou.mybatisplus.annotation.TableId;
7 import com.baomidou.mybatisplus.annotation.TableName; 8 import com.baomidou.mybatisplus.annotation.TableName;
@@ -40,17 +41,15 @@ public class MesWmSalesNoticeLineDO extends BaseDO { @@ -40,17 +41,15 @@ public class MesWmSalesNoticeLineDO extends BaseDO {
40 */ 41 */
41 private Long itemId; 42 private Long itemId;
42 /** 43 /**
43 - * 库存物资记录编号  
44 - *  
45 - * 关联 {@link cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO#getId()}  
46 - */  
47 - private Long materialStockId;  
48 - /**  
49 * 批次编号 44 * 批次编号
  45 + *
  46 + * 关联 {@link MesWmBatchDO#getId()}
50 */ 47 */
51 private Long batchId; 48 private Long batchId;
52 /** 49 /**
53 * 批次号 50 * 批次号
  51 + *
  52 + * 关联 {@link MesWmBatchDO#getCode()}
54 */ 53 */
55 private String batchCode; 54 private String batchCode;
56 /** 55 /**
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmSalesNoticeStatusEnum.java
@@ -29,12 +29,8 @@ public enum MesWmSalesNoticeStatusEnum implements ArrayValuable<Integer> { @@ -29,12 +29,8 @@ public enum MesWmSalesNoticeStatusEnum implements ArrayValuable<Integer> {
29 * 29 *
30 * 对应方法:{@link MesWmSalesNoticeService#submitSalesNotice(Long)} 30 * 对应方法:{@link MesWmSalesNoticeService#submitSalesNotice(Long)}
31 */ 31 */
32 - APPROVED(MesOrderStatusConstants.APPROVED, "待出库"),  
33 - /**  
34 - * 已完成  
35 - */  
36 - // TODO @芋艿:这个待实现;  
37 - FINISHED(MesOrderStatusConstants.FINISHED, "已完成"); 32 + APPROVED(MesOrderStatusConstants.APPROVED, "待出库");
  33 + // TODO @芋艿:【对齐】暂时无后续流程,看看后续要怎么支持下。
38 34
39 public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesWmSalesNoticeStatusEnum::getStatus).toArray(Integer[]::new); 35 public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesWmSalesNoticeStatusEnum::getStatus).toArray(Integer[]::new);
40 36
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeLineServiceImpl.java
1 package cn.iocoder.yudao.module.mes.service.wm.salesnotice; 1 package cn.iocoder.yudao.module.mes.service.wm.salesnotice;
2 2
3 import cn.hutool.core.util.ObjUtil; 3 import cn.hutool.core.util.ObjUtil;
  4 +import cn.hutool.core.util.StrUtil;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6 import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO; 7 import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO;
7 import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineSaveReqVO; 8 import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineSaveReqVO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.batch.MesWmBatchDO;
8 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO; 10 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
9 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO; 11 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
10 import cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice.MesWmSalesNoticeLineMapper; 12 import cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice.MesWmSalesNoticeLineMapper;
  13 +import cn.iocoder.yudao.module.mes.service.wm.batch.MesWmBatchService;
11 import jakarta.annotation.Resource; 14 import jakarta.annotation.Resource;
12 import org.springframework.context.annotation.Lazy; 15 import org.springframework.context.annotation.Lazy;
13 import org.springframework.stereotype.Service; 16 import org.springframework.stereotype.Service;
@@ -33,6 +36,9 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ @@ -33,6 +36,9 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ
33 @Lazy 36 @Lazy
34 private MesWmSalesNoticeService salesNoticeService; 37 private MesWmSalesNoticeService salesNoticeService;
35 38
  39 + @Resource
  40 + private MesWmBatchService batchService;
  41 +
36 @Override 42 @Override
37 public Long createSalesNoticeLine(MesWmSalesNoticeLineSaveReqVO createReqVO) { 43 public Long createSalesNoticeLine(MesWmSalesNoticeLineSaveReqVO createReqVO) {
38 // 校验父单据存在且为草稿状态 44 // 校验父单据存在且为草稿状态
@@ -40,6 +46,7 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ @@ -40,6 +46,7 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ
40 46
41 // 插入 47 // 插入
42 MesWmSalesNoticeLineDO line = BeanUtils.toBean(createReqVO, MesWmSalesNoticeLineDO.class); 48 MesWmSalesNoticeLineDO line = BeanUtils.toBean(createReqVO, MesWmSalesNoticeLineDO.class);
  49 + fillBatchId(line);
43 salesNoticeLineMapper.insert(line); 50 salesNoticeLineMapper.insert(line);
44 return line.getId(); 51 return line.getId();
45 } 52 }
@@ -53,6 +60,7 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ @@ -53,6 +60,7 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ
53 60
54 // 更新 61 // 更新
55 MesWmSalesNoticeLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmSalesNoticeLineDO.class); 62 MesWmSalesNoticeLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmSalesNoticeLineDO.class);
  63 + fillBatchId(updateObj);
56 salesNoticeLineMapper.updateById(updateObj); 64 salesNoticeLineMapper.updateById(updateObj);
57 } 65 }
58 66
@@ -108,4 +116,17 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ @@ -108,4 +116,17 @@ public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineServ
108 } 116 }
109 } 117 }
110 118
  119 + /**
  120 + * 根据 batchCode 回填 batchId
  121 + */
  122 + private void fillBatchId(MesWmSalesNoticeLineDO line) {
  123 + if (StrUtil.isEmpty(line.getBatchCode())) {
  124 + return;
  125 + }
  126 + MesWmBatchDO batch = batchService.getBatchByCode(line.getBatchCode());
  127 + if (batch != null) {
  128 + line.setBatchId(batch.getId());
  129 + }
  130 + }
  131 +
111 } 132 }