From 6b5f7c66fc40d7f6099d561e31a34fbd50dd20d3 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 01 七月 2026 15:54:57 +0800
Subject: [PATCH] 初始化项目
---
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java | 393 ++++++++++++++++++++++++++-----------------------------
1 files changed, 184 insertions(+), 209 deletions(-)
diff --git a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
index cf7cb5c..247295e 100644
--- a/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
+++ b/yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java
@@ -4,19 +4,16 @@
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
+import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper;
import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemCreateReqDTO;
import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO;
import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemUpdateReqDTO;
-import cn.iocoder.yudao.module.mdm.api.category.MdmItemCategoryApi;
-import cn.iocoder.yudao.module.mdm.api.category.dto.MdmItemCategoryRespDTO;
-import cn.iocoder.yudao.module.mdm.api.unit.MdmUnitMeasureApi;
-import cn.iocoder.yudao.module.mdm.api.unit.dto.MdmUnitMeasureRespDTO;
+import cn.iocoder.yudao.module.mdm.enums.MdmItemTypeEnum;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -30,9 +27,9 @@
/**
* ERP 浜у搧 Service 瀹炵幇绫�
*
- * 鏀归�犺鏄庯細ERP 浜у搧鏁版嵁鏉ユ簮浜� MDM 鐗╂枡涓绘暟鎹�
- * - 鎵�鏈変骇鍝佹搷浣滃潎璋冪敤 MDM API
- * - ERP 浜у搧瀵瑰簲 MDM 鐗╂枡绫诲瀷 = 鎴愬搧锛坕temType = 2锛�
+ * 鏀归�犺鏄庯細浜у搧鏁版嵁缁熶竴浣跨敤 MDM 涓绘暟鎹鐞嗭紙itemType=2 浜у搧绫诲瀷锛�
+ * - 鍒涘缓銆佹洿鏂般�佸垹闄ゆ搷浣滈�氳繃 MDM API 杩涜
+ * - 鏌ヨ鎿嶄綔浠� MDM 鑾峰彇鏁版嵁
*
* @author 鑺嬮亾婧愮爜
*/
@@ -40,46 +37,80 @@
@Validated
public class ErpProductServiceImpl implements ErpProductService {
- /** ERP 浜у搧瀵瑰簲鐨� MDM 鐗╂枡绫诲瀷锛氭垚鍝� */
- private static final int MDM_ITEM_TYPE_PRODUCT = 2;
+ @Resource
+ private ErpProductMapper productMapper;
@Resource
private MdmItemApi mdmItemApi;
- @Resource
- private MdmItemCategoryApi mdmItemCategoryApi;
-
- @Resource
- private MdmUnitMeasureApi mdmUnitMeasureApi;
-
@Override
public Long createProduct(ProductSaveReqVO createReqVO) {
- // 1. 鏍¢獙鏉$爜鍞竴
- validateProductBarCodeUnique(null, createReqVO.getBarCode());
-
- // 2. 鏋勫缓鍒涘缓璇锋眰骞惰皟鐢� MDM API
- MdmItemCreateReqDTO createReqDTO = buildCreateReqDTO(createReqVO);
+ // 1. 鏍¢獙鏉$爜鏄惁閲嶅
+ MdmItemRespDTO existItem = mdmItemApi.getItemByBarCode(createReqVO.getBarCode()).getCheckedData();
+ if (existItem != null) {
+ throw exception(PRODUCT_BAR_CODE_EXISTS);
+ }
+ // 2. 閫氳繃 MDM API 鍒涘缓浜у搧
+ MdmItemCreateReqDTO createReqDTO = new MdmItemCreateReqDTO();
+ createReqDTO.setCode(createReqVO.getBarCode()); // 浣跨敤鏉$爜浣滀负缂栫爜
+ createReqDTO.setName(createReqVO.getName());
+ createReqDTO.setBarCode(createReqVO.getBarCode());
+ createReqDTO.setSpecification(createReqVO.getStandard());
+ createReqDTO.setCategoryId(createReqVO.getCategoryId());
+ createReqDTO.setUnitMeasureId(createReqVO.getUnitId());
+ createReqDTO.setItemType(MdmItemTypeEnum.PRODUCT.getType()); // 浜у搧绫诲瀷
+ createReqDTO.setStatus(createReqVO.getStatus() != null ? createReqVO.getStatus() : CommonStatusEnum.ENABLE.getStatus());
+ createReqDTO.setPurchasePrice(createReqVO.getPurchasePrice());
+ createReqDTO.setSalesPrice(createReqVO.getSalePrice());
+ createReqDTO.setCostPrice(createReqVO.getMinPrice());
+ createReqDTO.setExpiryDay(createReqVO.getExpiryDay());
+ createReqDTO.setWeight(createReqVO.getWeight());
+ createReqDTO.setRemark(createReqVO.getRemark());
return mdmItemApi.createItem(createReqDTO).getCheckedData();
}
@Override
public void updateProduct(ProductSaveReqVO updateReqVO) {
// 1. 鏍¢獙瀛樺湪
- validateProductExists(updateReqVO.getId());
-
- // 2. 鏍¢獙鏉$爜鍞竴
- validateProductBarCodeUnique(updateReqVO.getId(), updateReqVO.getBarCode());
-
- // 3. 鏋勫缓鏇存柊璇锋眰骞惰皟鐢� MDM API
- MdmItemUpdateReqDTO updateReqDTO = buildUpdateReqDTO(updateReqVO);
+ MdmItemRespDTO existItem = mdmItemApi.getItem(updateReqVO.getId()).getCheckedData();
+ if (existItem == null) {
+ throw exception(PRODUCT_NOT_EXISTS);
+ }
+ // 2. 鏍¢獙鏉$爜鏄惁閲嶅
+ if (!existItem.getBarCode().equals(updateReqVO.getBarCode())) {
+ MdmItemRespDTO barCodeItem = mdmItemApi.getItemByBarCode(updateReqVO.getBarCode()).getCheckedData();
+ if (barCodeItem != null) {
+ throw exception(PRODUCT_BAR_CODE_EXISTS);
+ }
+ }
+ // 3. 閫氳繃 MDM API 鏇存柊浜у搧
+ MdmItemUpdateReqDTO updateReqDTO = new MdmItemUpdateReqDTO();
+ updateReqDTO.setId(updateReqVO.getId());
+ updateReqDTO.setCode(updateReqVO.getBarCode());
+ updateReqDTO.setName(updateReqVO.getName());
+ updateReqDTO.setBarCode(updateReqVO.getBarCode());
+ updateReqDTO.setSpecification(updateReqVO.getStandard());
+ updateReqDTO.setCategoryId(updateReqVO.getCategoryId());
+ updateReqDTO.setUnitMeasureId(updateReqVO.getUnitId());
+ updateReqDTO.setItemType(MdmItemTypeEnum.PRODUCT.getType());
+ updateReqDTO.setStatus(updateReqVO.getStatus());
+ updateReqDTO.setPurchasePrice(updateReqVO.getPurchasePrice());
+ updateReqDTO.setSalesPrice(updateReqVO.getSalePrice());
+ updateReqDTO.setCostPrice(updateReqVO.getMinPrice());
+ updateReqDTO.setExpiryDay(updateReqVO.getExpiryDay());
+ updateReqDTO.setWeight(updateReqVO.getWeight());
+ updateReqDTO.setRemark(updateReqVO.getRemark());
mdmItemApi.updateItem(updateReqDTO);
}
@Override
public void deleteProduct(Long id) {
// 鏍¢獙瀛樺湪
- validateProductExists(id);
- // ERP 浜у搧鍒犻櫎瀹為檯涓虹鐢紙MDM 鐗╂枡涓嶈兘鐗╃悊鍒犻櫎锛�
+ MdmItemRespDTO item = mdmItemApi.getItem(id).getCheckedData();
+ if (item == null) {
+ throw exception(PRODUCT_NOT_EXISTS);
+ }
+ // 閫氳繃 MDM API 鍒犻櫎锛堟洿鏂扮姸鎬佷负绂佺敤锛�
mdmItemApi.updateItemStatus(id, CommonStatusEnum.DISABLE.getStatus());
}
@@ -88,12 +119,10 @@
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
-
- // 1. 璋冪敤 MDM API 鑾峰彇鐗╂枡鍒楄〃
- List<MdmItemRespDTO> itemList = mdmItemApi.getItemList(ids).getCheckedData();
- Map<Long, MdmItemRespDTO> itemMap = convertMap(itemList, MdmItemRespDTO::getId);
-
- // 2. 鏍¢獙姣忎釜浜у搧
+ // 浠� MDM 鑾峰彇浜у搧鏁版嵁
+ List<MdmItemRespDTO> items = mdmItemApi.getItemList(ids).getCheckedData();
+ Map<Long, MdmItemRespDTO> itemMap = convertMap(items, MdmItemRespDTO::getId);
+ List<ErpProductDO> result = new ArrayList<>();
for (Long id : ids) {
MdmItemRespDTO item = itemMap.get(id);
if (item == null) {
@@ -102,22 +131,78 @@
if (CommonStatusEnum.isDisable(item.getStatus())) {
throw exception(PRODUCT_NOT_ENABLE, item.getName());
}
+ // 杞崲涓� ErpProductDO
+ result.add(convertToErpProduct(item));
}
+ return result;
+ }
- // 3. 杞崲涓� ERP Product DO锛堟墜鍔ㄦ槧灏勫瓧娈碉級
- return convertToErpProductDOList(itemList);
+ private void validateProductExists(Long id) {
+ // 浠� MDM 鏍¢獙
+ MdmItemRespDTO item = mdmItemApi.getItem(id).getCheckedData();
+ if (item == null) {
+ throw exception(PRODUCT_NOT_EXISTS);
+ }
}
@Override
public ErpProductDO getProduct(Long id) {
+ // 浠� MDM 鑾峰彇浜у搧鏁版嵁
MdmItemRespDTO item = mdmItemApi.getItem(id).getCheckedData();
- return convertToErpProductDO(item);
+ if (item == null) {
+ return null;
+ }
+ // 妫�鏌ユ槸鍚︿负浜у搧绫诲瀷
+ if (!MdmItemTypeEnum.PRODUCT.getType().equals(item.getItemType())) {
+ return null;
+ }
+ return convertToErpProduct(item);
+ }
+
+ @Override
+ public ErpProductRespVO getProductVO(Long id) {
+ // 浠� MDM 鑾峰彇浜у搧鏁版嵁
+ MdmItemRespDTO item = mdmItemApi.getItem(id).getCheckedData();
+ if (item == null) {
+ return null;
+ }
+ // 妫�鏌ユ槸鍚︿负浜у搧绫诲瀷
+ if (!MdmItemTypeEnum.PRODUCT.getType().equals(item.getItemType())) {
+ return null;
+ }
+ return convertToErpProductVO(item);
+ }
+
+ /**
+ * 灏� MDM 鐗╂枡杞崲涓� ERP 浜у搧 VO
+ */
+ private ErpProductRespVO convertToErpProductVO(MdmItemRespDTO item) {
+ ErpProductRespVO vo = new ErpProductRespVO();
+ vo.setId(item.getId());
+ vo.setName(item.getName());
+ vo.setBarCode(item.getBarCode());
+ vo.setStandard(item.getSpecification());
+ vo.setCategoryId(item.getCategoryId());
+ vo.setUnitId(item.getUnitMeasureId());
+ vo.setStatus(item.getStatus());
+ vo.setExpiryDay(item.getExpiryDay());
+ vo.setWeight(item.getWeight());
+ vo.setPurchasePrice(item.getPurchasePrice());
+ vo.setSalePrice(item.getSalesPrice());
+ vo.setMinPrice(item.getCostPrice());
+ vo.setRemark(item.getRemark());
+ return vo;
}
@Override
public List<ErpProductRespVO> getProductVOListByStatus(Integer status) {
- List<MdmItemRespDTO> itemList = mdmItemApi.getItemListByStatus(status).getCheckedData();
- return buildProductVOList(itemList);
+ // 浠� MDM 鑾峰彇浜у搧鏁版嵁锛坕temType=2锛�
+ List<MdmItemRespDTO> items = mdmItemApi.getItemListByStatus(status).getCheckedData();
+ // 杩囨护浜у搧绫诲瀷
+ items = items.stream()
+ .filter(item -> MdmItemTypeEnum.PRODUCT.getType().equals(item.getItemType()))
+ .toList();
+ return buildProductVOListFromMdm(items);
}
@Override
@@ -125,22 +210,68 @@
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
- List<MdmItemRespDTO> itemList = mdmItemApi.getItemList(ids).getCheckedData();
- return buildProductVOList(itemList);
+ // 浠� MDM 鑾峰彇浜у搧鏁版嵁
+ List<MdmItemRespDTO> items = mdmItemApi.getItemList(ids).getCheckedData();
+ return buildProductVOListFromMdm(items);
}
@Override
public PageResult<ErpProductRespVO> getProductVOPage(ErpProductPageReqVO pageReqVO) {
- // 璋冪敤 MDM API 鍒嗛〉鏌ヨ
- PageResult<MdmItemRespDTO> mdmPageResult = mdmItemApi.getItemPage(
- MDM_ITEM_TYPE_PRODUCT,
- pageReqVO.getStatus(),
- pageReqVO.getPageNo(),
- pageReqVO.getPageSize()
- ).getCheckedData();
+ // 浠� MDM 鑾峰彇浜у搧鍒嗛〉鏁版嵁
+ cn.iocoder.yudao.framework.common.pojo.PageResult<MdmItemRespDTO> mdmPageResult =
+ mdmItemApi.getItemPage(MdmItemTypeEnum.PRODUCT.getType(), null,
+ pageReqVO.getPageNo(), pageReqVO.getPageSize()).getCheckedData();
+ return new PageResult<>(buildProductVOListFromMdm(mdmPageResult.getList()), mdmPageResult.getTotal());
+ }
- List<ErpProductRespVO> productVOList = buildProductVOList(mdmPageResult.getList());
- return new PageResult<>(productVOList, mdmPageResult.getTotal());
+ /**
+ * 浠� MDM 鏁版嵁鏋勫缓 ERP 浜у搧 VO 鍒楄〃
+ */
+ private List<ErpProductRespVO> buildProductVOListFromMdm(List<MdmItemRespDTO> items) {
+ if (CollUtil.isEmpty(items)) {
+ return Collections.emptyList();
+ }
+ List<ErpProductRespVO> result = new ArrayList<>();
+ for (MdmItemRespDTO item : items) {
+ ErpProductRespVO vo = new ErpProductRespVO();
+ vo.setId(item.getId());
+ vo.setName(item.getName());
+ vo.setBarCode(item.getBarCode());
+ vo.setStandard(item.getSpecification());
+ vo.setCategoryId(item.getCategoryId());
+ vo.setUnitId(item.getUnitMeasureId());
+ vo.setStatus(item.getStatus());
+ vo.setExpiryDay(item.getExpiryDay());
+ vo.setWeight(item.getWeight());
+ vo.setPurchasePrice(item.getPurchasePrice());
+ vo.setSalePrice(item.getSalesPrice());
+ vo.setMinPrice(item.getCostPrice()); // 浣跨敤鎴愭湰浠蜂綔涓烘渶浣庝环
+ vo.setRemark(item.getRemark());
+ // 鍒嗙被鍚嶇О鍜屽崟浣嶅悕绉伴渶瑕侀澶栨煡璇紙绠�鍖栧鐞嗭紝鍚庣画鍙紭鍖栵級
+ result.add(vo);
+ }
+ return result;
+ }
+
+ /**
+ * 灏� MDM 鐗╂枡杞崲涓� ERP 浜у搧 DO
+ */
+ private ErpProductDO convertToErpProduct(MdmItemRespDTO item) {
+ ErpProductDO product = new ErpProductDO();
+ product.setId(item.getId());
+ product.setName(item.getName());
+ product.setBarCode(item.getBarCode());
+ product.setStandard(item.getSpecification());
+ product.setCategoryId(item.getCategoryId());
+ product.setUnitId(item.getUnitMeasureId());
+ product.setStatus(item.getStatus());
+ product.setExpiryDay(item.getExpiryDay());
+ product.setWeight(item.getWeight());
+ product.setPurchasePrice(item.getPurchasePrice());
+ product.setSalePrice(item.getSalesPrice());
+ product.setMinPrice(item.getCostPrice());
+ product.setRemark(item.getRemark());
+ return product;
}
@Override
@@ -153,160 +284,4 @@
return mdmItemApi.getItemCountByUnitMeasureId(unitId).getCheckedData();
}
- // ==================== 绉佹湁鏂规硶 ====================
-
- /**
- * 鏍¢獙浜у搧瀛樺湪
- */
- private void validateProductExists(Long id) {
- mdmItemApi.validateItemExists(id).getCheckedData();
- }
-
- /**
- * 鏍¢獙浜у搧鏉$爜鍞竴
- */
- private void validateProductBarCodeUnique(Long id, String barCode) {
- if (barCode == null) {
- return;
- }
- MdmItemRespDTO existItem = mdmItemApi.getItemByBarCode(barCode).getCheckedData();
- if (existItem != null && !existItem.getId().equals(id)) {
- throw exception(PRODUCT_BAR_CODE_EXISTS);
- }
- }
-
- /**
- * 鏋勫缓鍒涘缓璇锋眰 DTO
- * 娉ㄦ剰锛歅roductSaveReqVO 浣跨敤 standard 瀛楁浣滀负瑙勬牸锛孧DM 浣跨敤 specification
- */
- private MdmItemCreateReqDTO buildCreateReqDTO(ProductSaveReqVO saveReqVO) {
- MdmItemCreateReqDTO createReqDTO = new MdmItemCreateReqDTO();
- createReqDTO.setCode(saveReqVO.getBarCode()); // 浣跨敤鏉$爜浣滀负缂栫爜
- createReqDTO.setName(saveReqVO.getName());
- createReqDTO.setBarCode(saveReqVO.getBarCode());
- createReqDTO.setSpecification(saveReqVO.getStandard()); // standard -> specification
- createReqDTO.setCategoryId(saveReqVO.getCategoryId());
- createReqDTO.setUnitMeasureId(saveReqVO.getUnitId()); // unitId -> unitMeasureId
- createReqDTO.setItemType(MDM_ITEM_TYPE_PRODUCT);
- createReqDTO.setStatus(saveReqVO.getStatus() != null ? saveReqVO.getStatus() : CommonStatusEnum.ENABLE.getStatus());
- createReqDTO.setPurchasePrice(saveReqVO.getPurchasePrice());
- createReqDTO.setSalesPrice(saveReqVO.getSalePrice());
- createReqDTO.setCostPrice(saveReqVO.getMinPrice()); // minPrice -> costPrice
- createReqDTO.setExpiryDay(saveReqVO.getExpiryDay());
- createReqDTO.setWeight(saveReqVO.getWeight());
- createReqDTO.setRemark(saveReqVO.getRemark());
- return createReqDTO;
- }
-
- /**
- * 鏋勫缓鏇存柊璇锋眰 DTO
- */
- private MdmItemUpdateReqDTO buildUpdateReqDTO(ProductSaveReqVO saveReqVO) {
- MdmItemUpdateReqDTO updateReqDTO = new MdmItemUpdateReqDTO();
- updateReqDTO.setId(saveReqVO.getId());
- updateReqDTO.setCode(saveReqVO.getBarCode());
- updateReqDTO.setName(saveReqVO.getName());
- updateReqDTO.setBarCode(saveReqVO.getBarCode());
- updateReqDTO.setSpecification(saveReqVO.getStandard()); // standard -> specification
- updateReqDTO.setCategoryId(saveReqVO.getCategoryId());
- updateReqDTO.setUnitMeasureId(saveReqVO.getUnitId()); // unitId -> unitMeasureId
- updateReqDTO.setStatus(saveReqVO.getStatus());
- updateReqDTO.setPurchasePrice(saveReqVO.getPurchasePrice());
- updateReqDTO.setSalesPrice(saveReqVO.getSalePrice());
- updateReqDTO.setCostPrice(saveReqVO.getMinPrice());
- updateReqDTO.setExpiryDay(saveReqVO.getExpiryDay());
- updateReqDTO.setWeight(saveReqVO.getWeight());
- updateReqDTO.setRemark(saveReqVO.getRemark());
- return updateReqDTO;
- }
-
- /**
- * 鏋勫缓浜у搧 VO 鍒楄〃锛堝寘鍚垎绫诲拰鍗曚綅鍚嶇О锛�
- * 娉ㄦ剰锛歁DM 鍜� ERP 瀛楁鍚嶆湁宸紓锛岄渶瑕佹墜鍔ㄦ槧灏�
- */
- private List<ErpProductRespVO> buildProductVOList(List<MdmItemRespDTO> itemList) {
- if (CollUtil.isEmpty(itemList)) {
- return Collections.emptyList();
- }
-
- // 1. 鑾峰彇鍒嗙被鍜屽崟浣嶄俊鎭�
- Set<Long> categoryIds = convertSet(itemList, MdmItemRespDTO::getCategoryId);
- Set<Long> unitIds = convertSet(itemList, MdmItemRespDTO::getUnitMeasureId);
-
- Map<Long, MdmItemCategoryRespDTO> categoryMap = CollUtil.isEmpty(categoryIds)
- ? Collections.emptyMap()
- : convertMap(mdmItemCategoryApi.getItemCategoryList(categoryIds).getCheckedData(), MdmItemCategoryRespDTO::getId);
-
- Map<Long, MdmUnitMeasureRespDTO> unitMap = CollUtil.isEmpty(unitIds)
- ? Collections.emptyMap()
- : convertMap(mdmUnitMeasureApi.getUnitMeasureList(unitIds).getCheckedData(), MdmUnitMeasureRespDTO::getId);
-
- // 2. 鎵嬪姩杞崲骞跺~鍏呭叧鑱斾俊鎭紙澶勭悊瀛楁鍚嶅樊寮傦級
- List<ErpProductRespVO> result = new ArrayList<>();
- for (MdmItemRespDTO mdmItem : itemList) {
- ErpProductRespVO product = new ErpProductRespVO();
- product.setId(mdmItem.getId());
- product.setName(mdmItem.getName());
- product.setBarCode(mdmItem.getBarCode());
- product.setStandard(mdmItem.getSpecification()); // specification -> standard
- product.setCategoryId(mdmItem.getCategoryId());
- product.setUnitId(mdmItem.getUnitMeasureId()); // unitMeasureId -> unitId
- product.setStatus(mdmItem.getStatus());
- product.setPurchasePrice(mdmItem.getPurchasePrice());
- product.setSalePrice(mdmItem.getSalesPrice()); // salesPrice -> salePrice
- product.setMinPrice(mdmItem.getCostPrice()); // costPrice -> minPrice
- product.setExpiryDay(mdmItem.getExpiryDay());
- product.setWeight(mdmItem.getWeight());
- product.setRemark(mdmItem.getRemark());
-
- // 璁剧疆鍒嗙被鍜屽崟浣嶅悕绉�
- MapUtils.findAndThen(categoryMap, mdmItem.getCategoryId(),
- category -> product.setCategoryName(category.getName()));
- MapUtils.findAndThen(unitMap, mdmItem.getUnitMeasureId(),
- unit -> product.setUnitName(unit.getName()));
-
- result.add(product);
- }
- return result;
- }
-
- /**
- * 杞崲 MDM 鐗╂枡涓� ERP 浜у搧 DO
- * 娉ㄦ剰锛氬瓧娈靛悕宸紓闇�瑕佹墜鍔ㄦ槧灏�
- */
- private ErpProductDO convertToErpProductDO(MdmItemRespDTO mdmItem) {
- if (mdmItem == null) {
- return null;
- }
- ErpProductDO product = new ErpProductDO();
- product.setId(mdmItem.getId());
- product.setName(mdmItem.getName());
- product.setBarCode(mdmItem.getBarCode());
- product.setStandard(mdmItem.getSpecification()); // specification -> standard
- product.setCategoryId(mdmItem.getCategoryId());
- product.setUnitId(mdmItem.getUnitMeasureId()); // unitMeasureId -> unitId
- product.setStatus(mdmItem.getStatus());
- product.setPurchasePrice(mdmItem.getPurchasePrice());
- product.setSalePrice(mdmItem.getSalesPrice()); // salesPrice -> salePrice
- product.setMinPrice(mdmItem.getCostPrice()); // costPrice -> minPrice
- product.setExpiryDay(mdmItem.getExpiryDay());
- product.setWeight(mdmItem.getWeight());
- product.setRemark(mdmItem.getRemark());
- return product;
- }
-
- /**
- * 鎵归噺杞崲 MDM 鐗╂枡鍒楄〃涓� ERP 浜у搧鍒楄〃
- */
- private List<ErpProductDO> convertToErpProductDOList(List<MdmItemRespDTO> mdmItemList) {
- if (CollUtil.isEmpty(mdmItemList)) {
- return Collections.emptyList();
- }
- List<ErpProductDO> result = new ArrayList<>();
- for (MdmItemRespDTO mdmItem : mdmItemList) {
- result.add(convertToErpProductDO(mdmItem));
- }
- return result;
- }
-
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3