Commit f677aa7bfdf319d13a9eff6f9f91fc8cf77c7897

Authored by YunaiV
1 parent f5e56fd9

✨ feat(mes): 新增批次号字段并重命名收货地址字段

yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/MesWmProductSalesController.java
... ... @@ -13,13 +13,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProd
13 13 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesSaveReqVO;
14 14 import cn.iocoder.yudao.module.mes.controller.admin.wm.productsales.vo.MesWmProductSalesShippingReqVO;
15 15 import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO;
16   -import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
17 16 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesDO;
18   -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
19 17 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
20 18 import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService;
21   -import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
22   -import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesLineService;
23 19 import cn.iocoder.yudao.module.mes.service.wm.productsales.MesWmProductSalesService;
24 20 import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
25 21 import io.swagger.v3.oas.annotations.Operation;
... ... @@ -37,7 +33,6 @@ import java.util.*;
37 33  
38 34 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
39 35 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
40   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
41 36 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
42 37  
43 38 @Tag(name = "管理后台 - MES 销售出库单")
... ... @@ -52,10 +47,6 @@ public class MesWmProductSalesController {
52 47 @Resource
53 48 private MesMdClientService clientService;
54 49 @Resource
55   - private MesMdItemService itemService;
56   - @Resource
57   - private MesWmProductSalesLineService productSalesLineService;
58   - @Resource
59 50 private MesWmSalesNoticeService salesNoticeService;
60 51  
61 52 @PostMapping("/create")
... ... @@ -167,35 +158,6 @@ public class MesWmProductSalesController {
167 158 return success(true);
168 159 }
169 160  
170   - // TODO @AI:是不是有需要?有需要在提供;
171   - @GetMapping("/get-item")
172   - @Operation(summary = "根据客户 ID 获取曾出库的产品清单(去重)")
173   - @Parameter(name = "clientId", description = "客户 ID", required = true, example = "1")
174   - @PreAuthorize("@ss.hasPermission('mes:wm-product-sales:query')")
175   - public CommonResult<List<MesMdItemDO>> getItemByClientId(@RequestParam("clientId") Long clientId) {
176   - // 1. 查询该客户的所有出库单
177   - List<MesWmProductSalesDO> salesList = productSalesService.getProductSalesListByClientId(clientId);
178   - if (CollUtil.isEmpty(salesList)) {
179   - return success(Collections.emptyList());
180   - }
181   - // 2. 查询所有行,提取去重的 itemId
182   - List<Long> salesIds = convertList(salesList, MesWmProductSalesDO::getId);
183   - Set<Long> itemIds = new LinkedHashSet<>();
184   - for (Long salesId : salesIds) {
185   - List<MesWmProductSalesLineDO> lines = productSalesLineService.getProductSalesLineListBySalesId(salesId);
186   - for (MesWmProductSalesLineDO line : lines) {
187   - if (line.getItemId() != null) {
188   - itemIds.add(line.getItemId());
189   - }
190   - }
191   - }
192   - if (itemIds.isEmpty()) {
193   - return success(Collections.emptyList());
194   - }
195   - // 3. 返回物料列表
196   - return success(new ArrayList<>(itemService.getItemMap(itemIds).values()));
197   - }
198   -
199 161 // ==================== 拼接 VO ====================
200 162  
201 163 private List<MesWmProductSalesRespVO> buildRespVOList(List<MesWmProductSalesDO> list) {
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/vo/MesWmProductSalesRespVO.java
... ... @@ -60,7 +60,7 @@ public class MesWmProductSalesRespVO {
60 60  
61 61 @Schema(description = "收货地址", example = "北京市朝阳区XX路XX号")
62 62 @ExcelProperty("收货地址")
63   - private String address;
  63 + private String contactAddress;
64 64  
65 65 @Schema(description = "承运商", example = "顺丰快递")
66 66 @ExcelProperty("承运商")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/vo/MesWmProductSalesSaveReqVO.java
... ... @@ -43,7 +43,7 @@ public class MesWmProductSalesSaveReqVO {
43 43 private String contactTelephone;
44 44  
45 45 @Schema(description = "收货地址", example = "北京市朝阳区XX路XX号")
46   - private String address;
  46 + private String contactAddress;
47 47  
48 48 @Schema(description = "承运商", example = "顺丰快递")
49 49 private String carrier;
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/vo/detail/MesWmProductSalesDetailRespVO.java
... ... @@ -43,6 +43,9 @@ public class MesWmProductSalesDetailRespVO {
43 43 @Schema(description = "批次ID", example = "1")
44 44 private Long batchId;
45 45  
  46 + @Schema(description = "批次号", example = "BATCH001")
  47 + private String batchCode;
  48 +
46 49 @Schema(description = "仓库ID", example = "1")
47 50 private Long warehouseId;
48 51  
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/productsales/vo/detail/MesWmProductSalesDetailSaveReqVO.java
... ... @@ -35,6 +35,9 @@ public class MesWmProductSalesDetailSaveReqVO {
35 35 @Schema(description = "批次ID", example = "1")
36 36 private Long batchId;
37 37  
  38 + @Schema(description = "批次号", example = "BATCH001")
  39 + private String batchCode;
  40 +
38 41 @Schema(description = "仓库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
39 42 @NotNull(message = "仓库不能为空")
40 43 private Long warehouseId;
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesDO.java
... ... @@ -69,11 +69,10 @@ public class MesWmProductSalesDO extends BaseDO {
69 69 * 联系电话
70 70 */
71 71 private String contactTelephone;
72   - // TODO @AI:改成 contactAddress
73 72 /**
74 73 * 收货地址
75 74 */
76   - private String address;
  75 + private String contactAddress;
77 76  
78 77 /**
79 78 * 承运商
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/productsales/MesWmProductSalesDetailDO.java
... ... @@ -68,7 +68,12 @@ public class MesWmProductSalesDetailDO extends BaseDO {
68 68 * 关联 {@link MesWmBatchDO#getId()}
69 69 */
70 70 private Long batchId;
71   - // TODO @AI:增加 batchCode 字段
  71 + /**
  72 + * 批次号
  73 + *
  74 + * 关联 {@link MesWmBatchDO#getCode()}
  75 + */
  76 + private String batchCode;
72 77 /**
73 78 * 仓库ID
74 79 *
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesLineMapper.java
... ... @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.mysql.wm.productsales;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
4 4 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productsales.MesWmProductSalesLineDO;
  5 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
5 6 import org.apache.ibatis.annotations.Mapper;
6 7  
7 8 import java.util.List;
... ... @@ -30,4 +31,9 @@ public interface MesWmProductSalesLineMapper extends BaseMapperX&lt;MesWmProductSal
30 31 .orderByDesc(MesWmProductSalesLineDO::getId));
31 32 }
32 33  
  34 + default void updateQualityStatusByIds(List<Long> ids, Integer qualityStatus) {
  35 + update(new MesWmProductSalesLineDO().setQualityStatus(qualityStatus),
  36 + new LambdaUpdateWrapper<MesWmProductSalesLineDO>().in(MesWmProductSalesLineDO::getId, ids));
  37 + }
  38 +
33 39 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineService.java
... ... @@ -78,11 +78,11 @@ public interface MesWmProductSalesLineService {
78 78 void updateProductSalesLineWhenOqcFinish(Long id, Long oqcId, Integer checkResult);
79 79  
80 80 /**
81   - * 更新行的质量状态
  81 + * 批量更新行的质量状态
82 82 *
83   - * @param id 行 ID
  83 + * @param ids 行 ID 列表
84 84 * @param qualityStatus 质量状态
85 85 */
86   - void updateProductSalesLineQualityStatus(Long id, Integer qualityStatus);
  86 + void updateProductSalesLineQualityStatus(List<Long> ids, Integer qualityStatus);
87 87  
88 88 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
... ... @@ -155,9 +155,11 @@ public class MesWmProductSalesLineServiceImpl implements MesWmProductSalesLineSe
155 155 }
156 156  
157 157 @Override
158   - public void updateProductSalesLineQualityStatus(Long id, Integer qualityStatus) {
159   - productSalesLineMapper.updateById(new MesWmProductSalesLineDO()
160   - .setId(id).setQualityStatus(qualityStatus));
  158 + public void updateProductSalesLineQualityStatus(List<Long> ids, Integer qualityStatus) {
  159 + if (CollUtil.isEmpty(ids)) {
  160 + return;
  161 + }
  162 + productSalesLineMapper.updateQualityStatusByIds(ids, qualityStatus);
161 163 }
162 164  
163 165 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesServiceImpl.java
... ... @@ -58,11 +58,8 @@ public class MesWmProductSalesServiceImpl implements MesWmProductSalesService {
58 58  
59 59 @Override
60 60 public Long createProductSales(MesWmProductSalesSaveReqVO createReqVO) {
61   - // TODO @AI:增加 validateXXXSaveData;
62   - // 校验编码唯一
63   - validateCodeUnique(null, createReqVO.getCode());
64   - // 校验客户存在
65   - clientService.validateClientExists(createReqVO.getClientId());
  61 + // 校验数据
  62 + validateProductSalesSaveData(null, createReqVO);
66 63  
67 64 // 插入
68 65 MesWmProductSalesDO sales = BeanUtils.toBean(createReqVO, MesWmProductSalesDO.class);
... ... @@ -75,11 +72,8 @@ public class MesWmProductSalesServiceImpl implements MesWmProductSalesService {
75 72 public void updateProductSales(MesWmProductSalesSaveReqVO updateReqVO) {
76 73 // 校验存在 + 草稿状态
77 74 validateProductSalesExistsAndDraft(updateReqVO.getId());
78   - // TODO @AI:增加 validateXXXSaveData;(校验数据)
79   - // 校验编码唯一
80   - validateCodeUnique(updateReqVO.getId(), updateReqVO.getCode());
81   - // 校验客户存在
82   - clientService.validateClientExists(updateReqVO.getClientId());
  75 + // 校验数据
  76 + validateProductSalesSaveData(updateReqVO.getId(), updateReqVO);
83 77  
84 78 // 更新
85 79 MesWmProductSalesDO updateObj = BeanUtils.toBean(updateReqVO, MesWmProductSalesDO.class);
... ... @@ -130,14 +124,11 @@ public class MesWmProductSalesServiceImpl implements MesWmProductSalesService {
130 124 boolean needOqc = CollectionUtils.anyMatch(lines,
131 125 line -> Boolean.TRUE.equals(line.getOqcCheckFlag()));
132 126 if (needOqc) {
133   - // 初始化 OQC 行的质量状态为"待检验"
134   - // TODO @AI:改成批量更新接口?productSalesLineService 提供一个?【对齐:这个是否为必须?!】
135   - for (MesWmProductSalesLineDO line : lines) {
136   - if (Boolean.TRUE.equals(line.getOqcCheckFlag())) {
137   - productSalesLineService.updateProductSalesLineQualityStatus(
138   - line.getId(), MesWmQualityStatusEnum.PENDING.getStatus());
139   - }
140   - }
  127 + // 批量初始化 OQC 行的质量状态为"待检验"
  128 + List<Long> oqcLineIds = convertList(
  129 + CollectionUtils.filterList(lines, line -> Boolean.TRUE.equals(line.getOqcCheckFlag())),
  130 + MesWmProductSalesLineDO::getId);
  131 + productSalesLineService.updateProductSalesLineQualityStatus(oqcLineIds, MesWmQualityStatusEnum.PENDING.getStatus());
141 132 // 需要检验,进入待检测
142 133 productSalesMapper.updateById(new MesWmProductSalesDO()
143 134 .setId(id).setStatus(MesWmProductSalesStatusEnum.CONFIRMED.getStatus()));
... ... @@ -266,6 +257,13 @@ public class MesWmProductSalesServiceImpl implements MesWmProductSalesService {
266 257 return productSalesMapper.selectListByClientId(clientId);
267 258 }
268 259  
  260 + private void validateProductSalesSaveData(Long id, MesWmProductSalesSaveReqVO reqVO) {
  261 + // 校验编码唯一
  262 + validateCodeUnique(id, reqVO.getCode());
  263 + // 校验客户存在
  264 + clientService.validateClientExists(reqVO.getClientId());
  265 + }
  266 +
269 267 private MesWmProductSalesDO validateProductSalesExists(Long id) {
270 268 MesWmProductSalesDO sales = productSalesMapper.selectById(id);
271 269 if (sales == null) {
... ...