From 89601693cac022cd36288f67afc39c079ce70810 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 10 四月 2026 11:11:24 +0800
Subject: [PATCH] feat: 标准成本导入页面接口
---
src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
index 1336736..b2a7397 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.framework.util.AliDingUtils;
import com.ruoyi.production.dto.ProductMaterialDto;
import com.ruoyi.production.dto.ProductMaterialGroupDto;
+import com.ruoyi.production.dto.ProductMaterialSkuDto;
import com.ruoyi.production.enums.MaterialConfigTypeEnum;
import com.ruoyi.production.mapper.ProductMaterialMapper;
import com.ruoyi.production.pojo.ProductMaterial;
@@ -105,7 +106,10 @@
String searchFieldJson = searchConditions.toJSONString();
- JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getMaterialCodeFormUuid(), searchFieldJson, productMaterialSkuService, ProductMaterialSku::getFormModifiedTime);
+ LambdaQueryWrapper<ProductMaterialSku> countWrapper = new LambdaQueryWrapper<>();
+ countWrapper.eq(ProductMaterialSku::getType, 1);
+
+ JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getMaterialCodeFormUuid(), searchFieldJson, productMaterialSkuService, ProductMaterialSku::getFormModifiedTime, countWrapper);
if (dataArr.isEmpty()) {
log.info("娌℃湁鏇村鏂版暟鎹渶瑕佸悓姝�");
@@ -168,6 +172,7 @@
sku.setFormModifiedTime(AliDingUtils.parseUtcTime(item.getString("modifiedTimeGMT")));
sku.setCreateTime(now);
sku.setUpdateTime(now);
+ sku.setType(1);
list.add(sku);
}
@@ -270,8 +275,7 @@
@Override
public List<ProductMaterialGroupDto> ProductMaterialList(Integer type) {
List<ProductMaterialConfig> configList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>()
- .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name())
- );
+ .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name()));
if (CollectionUtils.isEmpty(configList)) {
return new ArrayList<>();
}
@@ -283,7 +287,9 @@
ProductMaterial::getId,
ProductMaterial::getMaterialTypeId,
ProductMaterial::getInventoryCategoryId,
- ProductMaterial::getProductName
+ ProductMaterial::getProductName,
+ ProductMaterial::getUnit,
+ ProductMaterial::getRemark
)
);
materialMap = materialList.stream()
@@ -358,6 +364,8 @@
dto.setProductName(m.getProductName());
dto.setMaterialTypeId(m.getMaterialTypeId());
dto.setInventoryCategoryId(m.getInventoryCategoryId());
+ dto.setUnit(m.getUnit());
+ dto.setRemark(m.getRemark());
return dto;
}
@@ -403,12 +411,29 @@
if (ids == null || ids.isEmpty()) {
throw new ServiceException("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
}
+
+ // 瀛樺湪瑙勬牸灏变笉鑳藉垹闄�
+ long skuCount = productMaterialSkuService.count(new LambdaQueryWrapper<ProductMaterialSku>().in(ProductMaterialSku::getProductId, ids));
+ if (skuCount > 0) {
+ throw new ServiceException("璇ョ墿鏂欎笅瀛樺湪瑙勬牸鏁版嵁锛屾棤娉曞垹闄�");
+ }
+
if (!this.removeByIds(ids)) {
throw new ServiceException("鍒犻櫎鐗╂枡澶辫触");
}
log.info("鍒犻櫎鐗╂枡鎴愬姛 ids={}", ids);
}
+ @Override
+ public ProductMaterialSkuDto selectProductByModelId(Long productModelId) {
+ return baseMapper.selectProductByModelId(productModelId);
+ }
+
+ @Override
+ public ProductMaterialSkuDto selectProductByProductMainId(Long productOrderId) {
+ return baseMapper.selectProductByProductMainId(productOrderId);
+ }
+
private void validateProductMaterial(ProductMaterial productMaterial, boolean requireId) {
if (productMaterial == null) {
throw new ServiceException("鍙傛暟涓嶈兘涓虹┖");
--
Gitblit v1.9.3