From 19ed9b41cf75f132fe081ece5a20966611ccd123 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 15 七月 2026 15:50:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_business' into dev_business
---
yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java | 121 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 118 insertions(+), 3 deletions(-)
diff --git a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java
index f12ff9e..d60e1f1 100644
--- a/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java
+++ b/yudao-module-mdm/src/main/java/cn/iocoder/yudao/module/mdm/controller/admin/item/MdmItemController.java
@@ -7,10 +7,17 @@
import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemRespVO;
import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSaveReqVO;
import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemStatusUpdateReqVO;
+import cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO;
+import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemBatchConfigDO;
import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO;
import cn.iocoder.yudao.module.mdm.dal.dataobject.unit.MdmUnitMeasureDO;
+import cn.iocoder.yudao.module.mdm.dal.dataobject.warehouse.MdmWarehouseDO;
+import cn.iocoder.yudao.module.mdm.service.brand.MdmBrandService;
+import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService;
+import cn.iocoder.yudao.module.mdm.service.item.MdmItemBatchConfigService;
import cn.iocoder.yudao.module.mdm.service.item.MdmItemService;
import cn.iocoder.yudao.module.mdm.service.unit.MdmUnitMeasureService;
+import cn.iocoder.yudao.module.mdm.service.warehouse.MdmWarehouseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -20,8 +27,8 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@@ -36,7 +43,15 @@
private MdmItemService itemService;
@Resource
+ private MdmItemCategoryService itemCategoryService;
+ @Resource
private MdmUnitMeasureService unitMeasureService;
+ @Resource
+ private MdmWarehouseService warehouseService;
+ @Resource
+ private MdmBrandService brandService;
+ @Resource
+ private MdmItemBatchConfigService itemBatchConfigService;
@PostMapping("/create")
@Operation(summary = "鍒涘缓鐗╂枡")
@@ -76,7 +91,13 @@
@PreAuthorize("@ss.hasPermission('mdm:item:query')")
public CommonResult<MdmItemRespVO> getItem(@RequestParam("id") Long id) {
MdmItemDO item = itemService.getItem(id);
- return success(BeanUtils.toBean(item, MdmItemRespVO.class));
+ MdmItemRespVO resp = BeanUtils.toBean(item, MdmItemRespVO.class);
+ if (resp != null) {
+ enrichItemRespVO(resp);
+ // 濉厖鎵规灞炴�ч厤缃�
+ enrichItemBatchConfig(resp);
+ }
+ return success(resp);
}
@GetMapping("/page")
@@ -84,15 +105,52 @@
@PreAuthorize("@ss.hasPermission('mdm:item:query')")
public CommonResult<PageResult<MdmItemRespVO>> getItemPage(@Valid MdmItemPageReqVO pageReqVO) {
PageResult<MdmItemDO> pageResult = itemService.getItemPage(pageReqVO);
+ // 鍏宠仈鏌ヨ鍒嗙被鍚嶇О
+ Map<Long, MdmItemCategoryDO> categoryMap = itemCategoryService.getItemCategoryMap(
+ convertSet(pageResult.getList(), MdmItemDO::getCategoryId));
// 鍏宠仈鏌ヨ璁¢噺鍗曚綅鍚嶇О
Map<Long, MdmUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap(
convertSet(pageResult.getList(), MdmItemDO::getUnitMeasureId));
// 杞崲
List<MdmItemRespVO> respList = BeanUtils.toBean(pageResult.getList(), MdmItemRespVO.class);
+ // 鎵归噺鍏宠仈鏌ヨ杈呭崟浣嶅悕绉�
+ Set<Long> unitIds = new HashSet<>();
respList.forEach(resp -> {
+ if (resp.getUnitMeasureId2() != null) unitIds.add(resp.getUnitMeasureId2());
+ if (resp.getUnitMeasureId3() != null) unitIds.add(resp.getUnitMeasureId3());
+ });
+ Map<Long, MdmUnitMeasureDO> auxUnitMap = unitIds.isEmpty() ?
+ Collections.emptyMap() : unitMeasureService.getUnitMeasureMap(unitIds);
+ // 鎵归噺鍏宠仈鏌ヨ浠撳簱鍚嶇О
+ Set<Long> warehouseIds = new HashSet<>();
+ respList.forEach(resp -> {
+ if (resp.getWarehouseId() != null) warehouseIds.add(resp.getWarehouseId());
+ });
+ Map<Long, MdmWarehouseDO> warehouseMap = warehouseIds.isEmpty() ?
+ Collections.emptyMap() : warehouseService.getWarehouseList(warehouseIds).stream()
+ .collect(Collectors.toMap(MdmWarehouseDO::getId, w -> w));
+ // 璧嬪��
+ respList.forEach(resp -> {
+ // 鍒嗙被鍚嶇О
+ MdmItemCategoryDO category = categoryMap.get(resp.getCategoryId());
+ if (category != null) {
+ resp.setCategoryName(category.getName());
+ }
MdmUnitMeasureDO unit = unitMap.get(resp.getUnitMeasureId());
if (unit != null) {
resp.setUnitMeasureName(unit.getName());
+ }
+ MdmUnitMeasureDO auxUnit1 = auxUnitMap.get(resp.getUnitMeasureId2());
+ if (auxUnit1 != null) {
+ resp.setUnitMeasureName2(auxUnit1.getName());
+ }
+ MdmUnitMeasureDO auxUnit2 = auxUnitMap.get(resp.getUnitMeasureId3());
+ if (auxUnit2 != null) {
+ resp.setUnitMeasureName3(auxUnit2.getName());
+ }
+ MdmWarehouseDO warehouse = warehouseMap.get(resp.getWarehouseId());
+ if (warehouse != null) {
+ resp.setWarehouseName(warehouse.getName());
}
});
return success(new PageResult<>(respList, pageResult.getTotal()));
@@ -107,4 +165,61 @@
return success(BeanUtils.toBean(list, MdmItemRespVO.class));
}
+ /**
+ * 濉厖鐗╂枡鍝嶅簲 VO 鐨勫叧鑱斿悕绉帮紙鍒嗙被銆佷富鍗曚綅銆佽緟鍗曚綅銆佷粨搴撳悕绉帮級
+ */
+ private void enrichItemRespVO(MdmItemRespVO resp) {
+ // 鍒嗙被鍚嶇О
+ if (resp.getCategoryId() != null) {
+ MdmItemCategoryDO category = itemCategoryService.getItemCategory(resp.getCategoryId());
+ if (category != null) {
+ resp.setCategoryName(category.getName());
+ }
+ }
+ // 涓诲崟浣嶅悕绉�
+ if (resp.getUnitMeasureId() != null) {
+ MdmUnitMeasureDO unit = unitMeasureService.getUnitMeasure(resp.getUnitMeasureId());
+ if (unit != null) {
+ resp.setUnitMeasureName(unit.getName());
+ }
+ }
+ // 杈呭崟浣�1鍚嶇О
+ if (resp.getUnitMeasureId2() != null) {
+ MdmUnitMeasureDO unit2 = unitMeasureService.getUnitMeasure(resp.getUnitMeasureId2());
+ if (unit2 != null) {
+ resp.setUnitMeasureName2(unit2.getName());
+ }
+ }
+ // 杈呭崟浣�2鍚嶇О
+ if (resp.getUnitMeasureId3() != null) {
+ MdmUnitMeasureDO unit3 = unitMeasureService.getUnitMeasure(resp.getUnitMeasureId3());
+ if (unit3 != null) {
+ resp.setUnitMeasureName3(unit3.getName());
+ }
+ }
+ // 榛樿浠撳簱鍚嶇О
+ if (resp.getWarehouseId() != null) {
+ MdmWarehouseDO warehouse = warehouseService.getWarehouse(resp.getWarehouseId());
+ if (warehouse != null) {
+ resp.setWarehouseName(warehouse.getName());
+ }
+ }
+ }
+
+ /**
+ * 濉厖鐗╂枡鎵规灞炴�ч厤缃�
+ */
+ private void enrichItemBatchConfig(MdmItemRespVO resp) {
+ MdmItemBatchConfigDO config = itemBatchConfigService.getItemBatchConfigByItemId(resp.getId());
+ if (config != null) {
+ resp.setProduceDateFlag(config.getProduceDateFlag());
+ resp.setExpireDateFlag(config.getExpireDateFlag());
+ resp.setReceiptDateFlag(config.getReceiptDateFlag());
+ resp.setVendorFlag(config.getVendorFlag());
+ resp.setPurchaseOrderCodeFlag(config.getPurchaseOrderCodeFlag());
+ resp.setLotNumberFlag(config.getLotNumberFlag());
+ resp.setQualityStatusFlag(config.getQualityStatusFlag());
+ }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.3