From b852254d90e7d1955db31db154193ec8ee84d8b3 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 09 九月 2026 10:57:59 +0800
Subject: [PATCH] feat(hrm): 新增员工用工性质、班组归属字段及考勤异常处理优化
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java | 72 +++++++++++++++++++++++++++++++++++-
1 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java
index 5ac1e11..93662a1 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/stocktaking/task/MesWmStockTakingTaskLineServiceImpl.java
@@ -7,6 +7,8 @@
import cn.iocoder.yudao.module.mes.controller.admin.wm.materialstock.vo.MesWmMaterialStockListReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.line.MesWmStockTakingTaskLinePageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.line.MesWmStockTakingTaskLineSaveReqVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.line.MesWmStockTakingTaskLineImportExcelVO;
+import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.line.MesWmStockTakingTaskLineImportRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.wm.stocktaking.task.vo.result.MesWmStockTakingTaskResultSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.materialstock.MesWmMaterialStockDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.wm.stocktaking.plan.MesWmStockTakingPlanParamDO;
@@ -19,6 +21,7 @@
import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService;
import cn.iocoder.yudao.module.mes.service.wm.stocktaking.plan.MesWmStockTakingPlanParamService;
import jakarta.annotation.Resource;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
@@ -35,7 +38,7 @@
/**
* MES 鐩樼偣浠诲姟琛� Service 瀹炵幇绫�
*
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
*/
@Service
@Validated
@@ -50,6 +53,12 @@
private MesWmMaterialStockService materialStockService;
@Resource
private MesWmStockTakingTaskService stockTakingTaskService;
+ // 涓� ResultService 鐩镐簰寮曠敤锛圧esultServiceImpl 宸叉敞鍏� LineService锛夛紝椤荤敤 @Lazy 鎵撶牬寰幆
+ @Lazy
+ @Resource
+ private MesWmStockTakingTaskResultService stockTakingTaskResultService;
+ @Resource
+ private cn.iocoder.yudao.module.mdm.api.item.MdmItemApi mdmItemApi;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -70,7 +79,8 @@
// 3. 鎵归噺鐢熸垚鏄庣粏琛�
List<MesWmStockTakingTaskLineDO> lines = convertList(stocks, stock -> MesWmStockTakingTaskLineDO.builder()
.taskId(task.getId()).materialStockId(stock.getId()).itemId(stock.getItemId())
- .batchId(stock.getBatchId()).quantity(stock.getQuantity()).takingQuantity(BigDecimal.ZERO)
+ .batchId(stock.getBatchId()).batchCode(stock.getBatchCode())
+ .quantity(stock.getQuantity()).takingQuantity(BigDecimal.ZERO)
.warehouseId(stock.getWarehouseId()).locationId(stock.getLocationId()).areaId(stock.getAreaId())
.status(MesWmStockTakingTaskLineStatusEnum.LOSS.getStatus()).build());
stockTakingTaskLineMapper.insertBatch(lines);
@@ -230,4 +240,62 @@
return param != null ? param.getValueId() : null;
}
+ @Override
+ public MesWmStockTakingTaskLineImportRespVO importTakingQuantity(Long taskId,
+ List<MesWmStockTakingTaskLineImportExcelVO> list) {
+ MesWmStockTakingTaskLineImportRespVO respVO = new MesWmStockTakingTaskLineImportRespVO();
+ respVO.setSuccessCount(0);
+ respVO.setFailureCount(0);
+ respVO.setFailureMessages(new java.util.ArrayList<>());
+ if (CollUtil.isEmpty(list)) {
+ return respVO;
+ }
+ // 0. 鏍¢獙鐩樼偣浠诲姟澶勪簬鐩樼偣涓姸鎬侊紙涓庝汉宸ュ綍鍏ョ洏鐐圭粨鏋滃彛寰勪竴鑷达紝浠呯洏鐐逛腑鍙鍏ワ級
+ stockTakingTaskService.validateStockTakingTaskExistsAndApproving(taskId);
+ // 1. 鑾峰彇鐩樼偣浠诲姟琛�
+ List<MesWmStockTakingTaskLineDO> lines = stockTakingTaskLineMapper.selectListByTaskId(taskId);
+ if (CollUtil.isEmpty(lines)) {
+ throw exception(cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.WM_STOCK_TAKING_TASK_LINE_NOT_EXISTS);
+ }
+ // 2. 鏋勫缓 鐗╂枡缂栫爜 -> 鐗╂枡ID 鏄犲皠
+ java.util.Set<Long> itemIds = lines.stream().map(MesWmStockTakingTaskLineDO::getItemId)
+ .filter(Objects::nonNull).collect(java.util.stream.Collectors.toSet());
+ java.util.Map<Long, cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO> itemMap =
+ mdmItemApi.getItemMap(itemIds);
+ java.util.Map<String, Long> codeToItemIdMap = new java.util.HashMap<>();
+ itemMap.values().forEach(item -> {
+ if (item.getCode() != null) {
+ codeToItemIdMap.put(item.getCode(), item.getId());
+ }
+ });
+ // 3. 閫愯鍖归厤骞跺啓鍏ュ疄鐩樻暟閲�
+ for (MesWmStockTakingTaskLineImportExcelVO row : list) {
+ Long itemId = codeToItemIdMap.get(row.getItemCode());
+ if (itemId == null) {
+ respVO.setFailureCount(respVO.getFailureCount() + 1);
+ respVO.getFailureMessages().add("鐗╂枡缂栫爜涓嶅瓨鍦�: " + row.getItemCode());
+ continue;
+ }
+ MesWmStockTakingTaskLineDO matched = lines.stream()
+ .filter(line -> Objects.equals(line.getItemId(), itemId)
+ && Objects.equals(line.getBatchCode(), row.getBatchCode()))
+ .findFirst().orElse(null);
+ if (matched == null) {
+ respVO.setFailureCount(respVO.getFailureCount() + 1);
+ respVO.getFailureMessages().add("鏈壘鍒板搴旂洏鐐硅: 鐗╂枡=" + row.getItemCode() + " 鎵规=" + row.getBatchCode());
+ continue;
+ }
+ if (row.getTakingQuantity() == null) {
+ respVO.setFailureCount(respVO.getFailureCount() + 1);
+ respVO.getFailureMessages().add("瀹炵洏鏁伴噺涓虹┖: 鐗╂枡=" + row.getItemCode());
+ continue;
+ }
+ updateStockTakingTaskLineTakingQuantity(matched.getId(), row.getTakingQuantity());
+ // 鍚屾鍐欑洏鐐圭粨鏋滐紝淇濊瘉宸紓鏍搁攢鏉ユ簮锛坱ask_result锛変竴鑷�
+ stockTakingTaskResultService.upsertResultForImport(matched, row.getTakingQuantity());
+ respVO.setSuccessCount(respVO.getSuccessCount() + 1);
+ }
+ return respVO;
+ }
+
}
--
Gitblit v1.9.3