From 8e4eee5ad4d74e1a4e6ab4de3a9c28000700dce0 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 03 十一月 2026 13:49:04 +0800
Subject: [PATCH] 修复采购退货页面 ERP 模块已禁用报错
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java
index 2315426..368852e 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskResultServiceImpl.java
@@ -1,19 +1,23 @@
package cn.iocoder.yudao.module.mes.service.wm.stocktaking.task;
import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskLineDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.task.MesWmStockTakingTaskResultDO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO;
import cn.iocoder.yudao.module.mes.dal.mysql.wm.stocktaking.task.MesWmStockTakingTaskResultMapper;
+import cn.iocoder.yudao.module.mes.service.wm.warehouse.MesWmWarehouseDefaultService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.math.BigDecimal;
+import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_LINE_ALREADY_TAKEN;
@@ -22,7 +26,7 @@
/**
* MES 鐩樼偣缁撴灉 Service 瀹炵幇绫�
*
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
*/
@Service
@Validated
@@ -35,6 +39,8 @@
private MesWmStockTakingTaskLineService stockTakingTaskLineService;
@Resource
private MesWmStockTakingTaskService stockTakingTaskService;
+ @Resource
+ private MesWmWarehouseDefaultService warehouseDefaultService;
@Override
public PageResult<MesWmStockTakingTaskResultDO> getStockTakingTaskResultPage(
@@ -56,19 +62,43 @@
// 2. 纭畾 lineId 鍜岃处闈㈡暟閲�
Long lineId = createReqVO.getLineId();
MesWmStockTakingTaskLineDO existingLine = null;
+ if (lineId != null) {
+ // 2.1 濡傛灉浼犻�掍簡 lineId锛屼粠 line 涓幏鍙� quantity锛屽苟琛ラ綈浠撳簱/搴撳尯/搴撲綅/鎵规
+ existingLine = stockTakingTaskLineService.validateStockTakingTaskLineExists(lineId);
+ if (createReqVO.getWarehouseId() == null) {
+ createReqVO.setWarehouseId(existingLine.getWarehouseId());
+ }
+ if (createReqVO.getLocationId() == null) {
+ createReqVO.setLocationId(existingLine.getLocationId());
+ }
+ if (createReqVO.getAreaId() == null) {
+ createReqVO.setAreaId(existingLine.getAreaId());
+ }
+ if (createReqVO.getBatchId() == null) {
+ createReqVO.setBatchId(existingLine.getBatchId());
+ }
+ if (StrUtil.isEmpty(createReqVO.getBatchCode())) {
+ createReqVO.setBatchCode(existingLine.getBatchCode());
+ }
+ }
+ // 2.2 鏈寚瀹氬簱鍖�/搴撲綅鏃讹紝钀藉埌浠撳簱榛樿搴撳尯/搴撲綅锛堝鎴锋湭鍚敤搴撳尯/搴撲綅绠$悊锛�
+ if (createReqVO.getWarehouseId() != null
+ && (createReqVO.getLocationId() == null || createReqVO.getAreaId() == null)) {
+ MesWmWarehouseAreaDO defaultArea =
+ warehouseDefaultService.getOrCreateDefaultArea(createReqVO.getWarehouseId());
+ createReqVO.setLocationId(defaultArea.getLocationId());
+ createReqVO.setAreaId(defaultArea.getId());
+ }
if (lineId == null) {
- // 2.1 鍩轰簬 taskId + itemId + areaId 鏌ヨ宸插瓨鍦ㄧ殑 line
+ // 2.3 鍩轰簬 taskId + itemId + areaId 鏌ヨ宸插瓨鍦ㄧ殑 line
existingLine = stockTakingTaskLineService.getStockTakingTaskLine(
createReqVO.getTaskId(), createReqVO.getItemId(), createReqVO.getAreaId());
if (existingLine != null) {
lineId = existingLine.getId();
} else {
- // 2.2 鍒涘缓鏂扮殑 line锛堟敞鎰忥細褰撶洏鐐圭粨鏋滄病鏈夊搴旂殑鐩樼偣娓呭崟琛屾椂锛屼細鑷姩鍒涘缓涓�涓柊鐨勭洏鐐逛换鍔¤锛�
+ // 2.4 鍒涘缓鏂扮殑 line锛堟敞鎰忥細褰撶洏鐐圭粨鏋滄病鏈夊搴旂殑鐩樼偣娓呭崟琛屾椂锛屼細鑷姩鍒涘缓涓�涓柊鐨勭洏鐐逛换鍔¤锛�
lineId = stockTakingTaskLineService.createStockTakingTaskLine(createReqVO);
}
- } else {
- // 2.3 濡傛灉浼犻�掍簡 lineId锛屼粠 line 涓幏鍙� quantity
- existingLine = stockTakingTaskLineService.validateStockTakingTaskLineExists(lineId);
}
if (existingLine != null
&& existingLine.getTakingQuantity() != null
@@ -126,6 +156,11 @@
stockTakingTaskResultMapper.deleteByTaskId(taskId);
}
+ @Override
+ public List<MesWmStockTakingTaskResultDO> getStockTakingTaskResultListByTaskId(Long taskId) {
+ return stockTakingTaskResultMapper.selectListByTaskId(taskId);
+ }
+
/**
* 鏍¢獙鐩樼偣缁撴灉鏄惁瀛樺湪
*
--
Gitblit v1.9.3