From 0a2206a53d5889b6095f4819c263be858d86ca91 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 29 十月 2026 17:22:31 +0800
Subject: [PATCH] feat(mes): 增加盘号管理和库存搜索功能
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/mps/MesProMpsController.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/mps/MesProMpsController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/mps/MesProMpsController.java
index b174b5a..03fe143 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/mps/MesProMpsController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/mps/MesProMpsController.java
@@ -15,8 +15,10 @@
import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi;
import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO;
import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.mps.MesProMpsDO;
import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
+import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
import cn.iocoder.yudao.module.mes.service.pro.mps.MesProMpsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -32,21 +34,32 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.ArrayList;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_MPS_MERGE_ISSUE_DISABLED;
@Tag(name = "绠$悊鍚庡彴 - MES 鐢熶骇涓昏鍒�")
@RestController
@RequestMapping("/mes/pro-mps")
@Validated
+@Slf4j
public class MesProMpsController {
@Resource
private MesProMpsService mpsService;
@Resource
private MesMdItemService itemService;
+ @Resource
+ private MesMdUnitMeasureService unitMeasureService;
@Resource
private CrmCustomerApi customerApi;
@@ -77,7 +90,6 @@
@GetMapping("/get")
@Operation(summary = "鑾峰緱鐢熶骇涓昏鍒�")
@Parameter(name = "id", description = "缂栧彿", required = true, example = "1024")
- @PreAuthorize("@ss.hasPermission('mes:pro-mps:query')")
public CommonResult<MesProMpsRespVO> getMps(@RequestParam("id") Long id) {
MesProMpsDO mps = mpsService.getMps(id);
if (mps == null) {
@@ -88,7 +100,6 @@
@GetMapping("/page")
@Operation(summary = "鑾峰緱鐢熶骇涓昏鍒掑垎椤�")
- @PreAuthorize("@ss.hasPermission('mes:pro-mps:query')")
public CommonResult<PageResult<MesProMpsRespVO>> getMpsPage(@Valid MesProMpsPageReqVO pageReqVO) {
PageResult<MesProMpsDO> pageResult = mpsService.getMpsPage(pageReqVO);
return success(new PageResult<>(buildMpsRespVOList(pageResult.getList()), pageResult.getTotal()));
@@ -118,7 +129,36 @@
@Operation(summary = "鍚堝苟涓嬪彂鐢熶骇涓昏鍒�")
@PreAuthorize("@ss.hasPermission('mes:pro-mps:merge-issue')")
public CommonResult<Long> mergeAndIssueMps(@RequestBody List<Long> mpsIds) {
- return success(mpsService.mergeAndIssueMps(mpsIds));
+ // 鏃у叆鍙d繚鐣欑敤浜庢槑纭彁绀烘棫瀹㈡埛绔崌绾э紝绂佹缁曡繃鏂扮殑閫愭潯涓嬪彂鏉冮檺鏍¢獙銆�
+ throw exception(PRO_MPS_MERGE_ISSUE_DISABLED);
+ }
+
+ @PostMapping("/batch-issue")
+ @Operation(summary = "鎵归噺閫愭潯涓嬪彂鐢熶骇涓昏鍒�")
+ @PreAuthorize("@ss.hasPermission('mes:pro-mps:issue')")
+ public CommonResult<List<BatchIssueResult>> batchIssueMps(@RequestBody @NotEmpty List<@NotNull Long> ids) {
+ List<BatchIssueResult> results = new ArrayList<>();
+ for (Long id : ids) {
+ BatchIssueResult result = new BatchIssueResult();
+ result.setMpsId(id);
+ try {
+ result.setWorkOrderId(mpsService.issueMps(id));
+ } catch (ServiceException ex) {
+ result.setError(ex.getMessage());
+ } catch (Exception ex) {
+ log.error("[batchIssueMps] 涓嬪彂澶辫触锛宮psId={}", id, ex);
+ result.setError("涓嬪彂澶辫触锛岃鑱旂郴绠$悊鍛樻煡鐪嬫棩蹇�");
+ }
+ results.add(result);
+ }
+ return success(results);
+ }
+
+ @Data
+ public static class BatchIssueResult {
+ private Long mpsId;
+ private Long workOrderId;
+ private String error;
}
@PostMapping("/cancel")
@@ -139,6 +179,8 @@
// 1. 鎵归噺鑾峰彇鍏宠仈鏁版嵁
Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
convertSet(list, MesProMpsDO::getProductId));
+ Map<Long, MesMdUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap(
+ convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));
Map<Long, CrmCustomerRespDTO> clientMap = customerApi.getCustomerMap(
convertSet(list, MesProMpsDO::getClientId));
// 2. 鎷兼帴 VO
@@ -147,10 +189,12 @@
vo.setProductName(item.getName())
.setProductCode(item.getCode())
.setProductSpecification(item.getSpecification());
+ MapUtils.findAndThen(unitMap, item.getUnitMeasureId(),
+ unit -> vo.setUnitMeasureName(unit.getName()));
});
MapUtils.findAndThen(clientMap, vo.getClientId(),
client -> vo.setClientName(client.getName()));
});
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3