From 91acbe8b56194bbd834b1169b5578de8a5ed442c Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 14 三月 2026 17:53:10 +0800
Subject: [PATCH] fix: BOM产品查询调整、重命名字段
---
src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java | 40 ++++----
src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java | 4
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java | 2
src/main/resources/mapper/production/ProductBomMapper.xml | 44 +++++---
src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java | 2
src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java | 51 +++++-----
src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java | 4
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java | 10 +-
src/main/java/com/ruoyi/production/pojo/ProductMaterial.java | 4
src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java | 2
src/main/java/com/ruoyi/production/controller/ProductStructureController.java | 4
src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java | 4
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java | 2
src/main/java/com/ruoyi/production/service/ProductStructureService.java | 2
src/main/resources/mapper/production/ProductMaterialSkuMapper.xml | 28 ++--
src/main/resources/mapper/production/ProductStructureMapper.xml | 42 ++++----
src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java | 33 +++---
src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java | 4
src/main/resources/mapper/production/ProductMaterialMapper.xml | 4
19 files changed, 145 insertions(+), 141 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java b/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
index ed44765..9608738 100644
--- a/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
+++ b/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
@@ -7,7 +7,7 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.ProductMaterialSkuDto;
import com.ruoyi.production.pojo.ProductMaterialSku;
-import com.ruoyi.production.pojo.ProductMaterialSkuImportDto;
+import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
diff --git a/src/main/java/com/ruoyi/production/controller/ProductStructureController.java b/src/main/java/com/ruoyi/production/controller/ProductStructureController.java
index 89ead6d..59fb707 100644
--- a/src/main/java/com/ruoyi/production/controller/ProductStructureController.java
+++ b/src/main/java/com/ruoyi/production/controller/ProductStructureController.java
@@ -34,7 +34,7 @@
@ApiOperation("BOM鏌ョ湅瀛愰泦璇︽儏")
@GetMapping("/listBybomId/{bomId}")
- public R listBybomId( @PathVariable("bomId") Integer bomId){
- return R.ok(productStructureService.listBybomId(bomId));
+ public R listByBomId( @PathVariable("bomId") Integer bomId){
+ return R.ok(productStructureService.listByBomId(bomId));
}
}
diff --git a/src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java b/src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java
index 7fc9a8b..7b3e6bd 100644
--- a/src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java
+++ b/src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java
@@ -33,7 +33,7 @@
private Integer inventoryCategoryId;
@ApiModelProperty("鐗╂枡鍚嶇О")
- private String materialName;
+ private String productName;
}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java b/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java
index da6da70..5ec77e5 100644
--- a/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java
+++ b/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuDto.java
@@ -18,22 +18,22 @@
public class ProductMaterialSkuDto {
@ApiModelProperty("鐗╂枡ID")
- private Long materialId;
+ private Long productId;
@ApiModelProperty("鐗╂枡鍚嶇О")
- private String materialName;
+ private String productName;
@ApiModelProperty("鐗╂枡缂栫爜")
private String materialCode;
@ApiModelProperty("鍗曚綅")
- private String baseUnit;
+ private String unit;
@ApiModelProperty("瑙勬牸ID")
- private Long skuId;
+ private Long id;
@ApiModelProperty("瑙勬牸鍨嬪彿")
- private String specification;
+ private String model;
@ApiModelProperty("渚涘簲鏂瑰紡")
private String supplyType;
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductMaterialSkuImportDto.java b/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java
similarity index 91%
rename from src/main/java/com/ruoyi/production/pojo/ProductMaterialSkuImportDto.java
rename to src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java
index 06ed8b8..9d6c599 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductMaterialSkuImportDto.java
+++ b/src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java
@@ -1,4 +1,4 @@
-package com.ruoyi.production.pojo;
+package com.ruoyi.production.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -25,7 +25,7 @@
@ApiModelProperty("瑙勬牸鍨嬪彿")
@Excel(name = "瑙勬牸鍨嬪彿")
- private String specification;
+ private String model;
@ApiModelProperty("渚涘簲鏂瑰紡锛堣嚜鍒讹紝澶栬喘锛�")
@Excel(name = "渚涘簲鏂瑰紡")
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java
index bd59242..c2b75fc 100644
--- a/src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java
+++ b/src/main/java/com/ruoyi/production/mapper/ProductStructureMapper.java
@@ -13,7 +13,7 @@
@Mapper
public interface ProductStructureMapper extends BaseMapper<ProductStructure> {
- List<ProductStructureDto> listBybomId(@Param("bomId") Integer bomId);
+ List<ProductStructureDto> listByBomId(@Param("bomId") Integer bomId);
- List<ProductStructureDto> listBybomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId);
+ List<ProductStructureDto> listByBomAndProcess(@Param("bomId") Integer bomId, @Param("processId") Long processId);
}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java b/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
index 55fb868..bfe4b08 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
+++ b/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
@@ -38,10 +38,10 @@
private Integer inventoryCategoryId;
@ApiModelProperty("鐗╂枡鍚嶇О")
- private String materialName;
+ private String productName;
@ApiModelProperty("鍩烘湰鍗曚綅")
- private String baseUnit;
+ private String unit;
@ApiModelProperty("澶囨敞")
private String remark;
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java b/src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java
index e5c1c35..4678b5c 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java
+++ b/src/main/java/com/ruoyi/production/pojo/ProductMaterialSku.java
@@ -29,7 +29,7 @@
private Long id;
@ApiModelProperty("鐗╂枡ID")
- private Long materialId;
+ private Long productId;
@ApiModelProperty("鏍囪瘑缂栫爜")
private String identifierCode;
@@ -38,7 +38,7 @@
private String materialCode;
@ApiModelProperty("瑙勬牸鍨嬪彿")
- private String specification;
+ private String model;
@ApiModelProperty("渚涘簲鏂瑰紡锛堣嚜鍒讹紝澶栬喘锛�")
private String supplyType;
diff --git a/src/main/java/com/ruoyi/production/service/ProductStructureService.java b/src/main/java/com/ruoyi/production/service/ProductStructureService.java
index ebdddb1..760ca6e 100644
--- a/src/main/java/com/ruoyi/production/service/ProductStructureService.java
+++ b/src/main/java/com/ruoyi/production/service/ProductStructureService.java
@@ -12,6 +12,6 @@
Boolean addProductStructureDto(ProductStructureDto productStructureDto);
- List<ProductStructureDto> listBybomId(Integer bomId);
+ List<ProductStructureDto> listByBomId(Integer bomId);
}
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
index 2554b5e..43a8942 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductBomServiceImpl.java
@@ -4,10 +4,8 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.basic.pojo.Product;
-import com.ruoyi.basic.pojo.ProductModel;
-import com.ruoyi.basic.service.IProductModelService;
-import com.ruoyi.basic.service.IProductService;
+import com.ruoyi.production.pojo.ProductMaterial;
+import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -19,9 +17,7 @@
import com.ruoyi.production.pojo.ProductBom;
import com.ruoyi.production.pojo.ProductProcess;
import com.ruoyi.production.pojo.ProductStructure;
-import com.ruoyi.production.service.ProductBomService;
-import com.ruoyi.production.service.ProductProcessService;
-import com.ruoyi.production.service.ProductStructureService;
+import com.ruoyi.production.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -44,20 +40,20 @@
public class ProductBomServiceImpl extends ServiceImpl<ProductBomMapper, ProductBom> implements ProductBomService {
@Autowired
- private IProductService productService;
-
- @Autowired
private ProductBomMapper productBomMapper;
-
- @Autowired
- private IProductModelService productModelService;
@Autowired
private ProductStructureService productStructureService;
@Autowired
private ProductProcessService productProcessService;
+
+ @Autowired
+ private ProductMaterialService productMaterialService;
+
+ @Autowired
+ private ProductMaterialSkuService productMaterialSkuService;
@Override
public IPage<ProductBomDto> listPage(Page page, ProductBomDto productBomDto) {
@@ -78,15 +74,16 @@
throw new ServiceException("璇烽�夋嫨浜у搧妯″瀷");
}
- ProductModel productModel = productModelService.getById(productBom.getProductModelId());
+ ProductMaterialSku productModel = productMaterialSkuService.getById(productBom.getProductModelId());
if (productModel == null) {
throw new ServiceException("閫夋嫨鐨勪骇鍝佹ā鍨嬩笉瀛樺湪");
}
+ ProductMaterial productMaterial = productMaterialService.getById(productModel.getProductId());
// 娣诲姞鍒濆鐨勪骇鍝佺粨鏋�
ProductStructure productStructure = new ProductStructure();
productStructure.setProductModelId(productBom.getProductModelId());
- productStructure.setUnit(productModel.getUnit());
+ productStructure.setUnit(productMaterial != null ? productMaterial.getUnit() : null);
productStructure.setUnitQuantity(BigDecimal.valueOf(1));
productStructure.setBomId(productBom.getId());
@@ -123,7 +120,7 @@
// 鍒涘缓 BOM 鏁版嵁
BomImportDto first = list.get(0);
- ProductModel rootModel = findModel(first.getParentName(), first.getParentSpec());
+ ProductMaterialSku rootModel = findModel(first.getParentName(), first.getParentSpec());
ProductBom bom = new ProductBom();
bom.setProductModelId(rootModel.getId());
bom.setVersion("1.0");
@@ -146,7 +143,8 @@
rootNode.setParentId(null); // 椤跺眰娌℃湁鐖惰妭鐐�
rootNode.setProductModelId(rootModel.getId());
rootNode.setUnitQuantity(BigDecimal.ONE);
- rootNode.setUnit(rootModel.getUnit());
+ ProductMaterial rootMaterial = productMaterialService.getById(rootModel.getProductId());
+ rootNode.setUnit(rootMaterial != null ? rootMaterial.getUnit() : null);
productStructureService.save(rootNode);
treePathMap.put(parentKey, rootNode.getId());
@@ -162,7 +160,7 @@
}
// 鑾峰彇瀛愰」妯″瀷淇℃伅
- ProductModel childModel = findModel(dto.getChildName(), dto.getChildSpec());
+ ProductMaterialSku childModel = findModel(dto.getChildName(), dto.getChildSpec());
// 鎻掑叆缁撴瀯琛�
ProductStructure node = new ProductStructure();
@@ -170,7 +168,8 @@
node.setParentId(parentStructureId); // 鐖惰妭鐐笽D
node.setProductModelId(childModel.getId());
node.setUnitQuantity(dto.getUnitQty());
- node.setUnit(childModel.getUnit());
+ ProductMaterial childMaterial = productMaterialService.getById(childModel.getProductId());
+ node.setUnit(childMaterial != null ? childMaterial.getUnit() : null);
if (processMap.containsKey(dto.getProcess())) {
node.setProcessId(processMap.get(dto.getProcess()));
}
@@ -191,7 +190,7 @@
return;
}
- List<ProductStructureDto> treeData = productStructureService.listBybomId(bomId);
+ List<ProductStructureDto> treeData = productStructureService.listByBomId(bomId);
if (treeData == null || treeData.isEmpty()) {
return;
}
@@ -262,14 +261,14 @@
}
}
- private ProductModel findModel(String name, String spec) {
- Product product = productService.getOne(new LambdaQueryWrapper<Product>()
- .eq(Product::getProductName, name).last("limit 1"));
+ private ProductMaterialSku findModel(String name, String spec) {
+ ProductMaterial product = productMaterialService.getOne(new LambdaQueryWrapper<ProductMaterial>()
+ .eq(ProductMaterial::getProductName, name).last("limit 1"));
if (product == null) throw new ServiceException("浜у搧鏈淮鎶わ細" + name);
- ProductModel model = productModelService.getOne(new LambdaQueryWrapper<ProductModel>()
- .eq(ProductModel::getProductId, product.getId())
- .eq(ProductModel::getModel, spec).last("limit 1"));
+ ProductMaterialSku model = productMaterialSkuService.getOne(new LambdaQueryWrapper<ProductMaterialSku>()
+ .eq(ProductMaterialSku::getProductId, product.getId())
+ .eq(ProductMaterialSku::getModel, spec).last("limit 1"));
if (model == null) throw new ServiceException("瑙勬牸鏈淮鎶わ細" + name + "[" + spec + "]");
return model;
}
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 678cfd2..6fc0783 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
@@ -143,8 +143,8 @@
JSONObject formData = item.getJSONObject("formData");
// 澶勭悊鐗╂枡涓昏〃鏁版嵁
ProductMaterial material = new ProductMaterial();
- material.setMaterialName(formData.getString("textField_l92f36f5"));
- material.setBaseUnit(formData.getString("textField_la147lnw"));
+ material.setProductName(formData.getString("textField_l92f36f5"));
+ material.setUnit(formData.getString("textField_la147lnw"));
material.setRemark(formData.getString("textareaField_l92f36f9"));
String materialType = formData.getString("selectField_l92f36fb");
@@ -156,11 +156,11 @@
// 澶勭悊鐗╂枡瑙勬牸鏁版嵁
ProductMaterialSku sku = new ProductMaterialSku();
- sku.setMaterialId(materialId);
+ sku.setProductId(materialId);
sku.setFormInstanceId(formInstanceId);
sku.setIdentifierCode(formData.getString("textField_l92h77ju"));
sku.setMaterialCode(formData.getString("textField_l92f36f2"));
- sku.setSpecification(formData.getString("textField_l92f36f6"));
+ sku.setModel(formData.getString("textField_l92f36f6"));
sku.setSupplyType(formData.getString("selectField_la14k51j"));
sku.setOriginatorName(originatorName);
sku.setOriginatorOrg("瀹佸涓垱缁胯兘瀹炰笟闆嗗洟鏈夐檺鍏徃");
@@ -175,7 +175,7 @@
private Long getOrCreateMaterial(ProductMaterial material) {
LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ProductMaterial::getMaterialName, material.getMaterialName());
+ queryWrapper.eq(ProductMaterial::getProductName, material.getProductName());
ProductMaterial exist = this.getOne(queryWrapper);
if (exist == null) {
@@ -194,8 +194,8 @@
exist.setInventoryCategoryId(material.getInventoryCategoryId());
needUpdate = true;
}
- if (StringUtils.isNotEmpty(material.getBaseUnit()) && !material.getBaseUnit().equals(exist.getBaseUnit())) {
- exist.setBaseUnit(material.getBaseUnit());
+ if (StringUtils.isNotEmpty(material.getUnit()) && !material.getUnit().equals(exist.getUnit())) {
+ exist.setUnit(material.getUnit());
needUpdate = true;
}
if (needUpdate) {
@@ -229,8 +229,8 @@
for (ProductMaterialSku sku : list) {
LambdaQueryWrapper<ProductMaterialSku> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(ProductMaterialSku::getMaterialId, sku.getMaterialId())
- .eq(ProductMaterialSku::getSpecification, sku.getSpecification());
+ wrapper.eq(ProductMaterialSku::getProductId, sku.getProductId())
+ .eq(ProductMaterialSku::getModel, sku.getModel());
if (StringUtils.isNotEmpty(sku.getMaterialCode())) {
wrapper.eq(ProductMaterialSku::getMaterialCode, sku.getMaterialCode());
@@ -242,7 +242,7 @@
if (exist == null) {
productMaterialSkuService.save(sku);
affected++;
- log.info("鏂板鐗╂枡瑙勬牸 {}", sku.getSpecification());
+ log.info("鏂板鐗╂枡瑙勬牸 {}", sku.getModel());
} else {
if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(sku.getFormModifiedTime())) {
sku.setId(exist.getId());
@@ -250,7 +250,7 @@
productMaterialSkuService.updateById(sku);
affected++;
- log.info("鏇存柊鐗╂枡瑙勬牸 {}", sku.getSpecification());
+ log.info("鏇存柊鐗╂枡瑙勬牸 {}", sku.getModel());
}
}
}
@@ -273,7 +273,7 @@
ProductMaterial::getId,
ProductMaterial::getMaterialTypeId,
ProductMaterial::getInventoryCategoryId,
- ProductMaterial::getMaterialName
+ ProductMaterial::getProductName
)
);
materialMap = materialList.stream()
@@ -307,10 +307,10 @@
ProductMaterial::getId,
ProductMaterial::getMaterialTypeId,
ProductMaterial::getInventoryCategoryId,
- ProductMaterial::getMaterialName
+ ProductMaterial::getProductName
);
if (StringUtils.isNotEmpty(materialName)) {
- wrapper.like(ProductMaterial::getMaterialName, materialName);
+ wrapper.like(ProductMaterial::getProductName, materialName);
}
if (materialTypeId != null) {
wrapper.eq(ProductMaterial::getMaterialTypeId, materialTypeId);
@@ -345,7 +345,7 @@
private ProductMaterialDto convert(ProductMaterial m) {
ProductMaterialDto dto = new ProductMaterialDto();
dto.setId(m.getId());
- dto.setMaterialName(m.getMaterialName());
+ dto.setProductName(m.getProductName());
dto.setMaterialTypeId(m.getMaterialTypeId());
dto.setInventoryCategoryId(m.getInventoryCategoryId());
return dto;
@@ -355,7 +355,7 @@
@Transactional(rollbackFor = Exception.class)
public void addProductMaterial(ProductMaterial productMaterial) {
validateProductMaterial(productMaterial, false);
- if (existsMaterialName(productMaterial.getMaterialName(), null)) {
+ if (existsMaterialName(productMaterial.getProductName(), null)) {
throw new ServiceException("鐗╂枡鍚嶇О宸插瓨鍦�");
}
LocalDateTime now = LocalDateTime.now();
@@ -366,7 +366,7 @@
if (!this.save(productMaterial)) {
throw new ServiceException("鏂板鐗╂枡澶辫触");
}
- log.info("鏂板鐗╂枡鎴愬姛 materialName={}", productMaterial.getMaterialName());
+ log.info("鏂板鐗╂枡鎴愬姛 materialName={}", productMaterial.getProductName());
}
@Override
@@ -377,7 +377,7 @@
if (exist == null) {
throw new ServiceException("鐗╂枡涓嶅瓨鍦�");
}
- if (existsMaterialName(productMaterial.getMaterialName(), productMaterial.getId())) {
+ if (existsMaterialName(productMaterial.getProductName(), productMaterial.getId())) {
throw new ServiceException("鐗╂枡鍚嶇О宸插瓨鍦�");
}
productMaterial.setUpdateTime(LocalDateTime.now());
@@ -406,7 +406,7 @@
if (requireId && productMaterial.getId() == null) {
throw new ServiceException("涓婚敭ID涓嶈兘涓虹┖");
}
- if (StringUtils.isEmpty(productMaterial.getMaterialName())) {
+ if (StringUtils.isEmpty(productMaterial.getProductName())) {
throw new ServiceException("鐗╂枡鍚嶇О涓嶈兘涓虹┖");
}
}
@@ -416,7 +416,7 @@
return false;
}
LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ProductMaterial::getMaterialName, materialName);
+ queryWrapper.eq(ProductMaterial::getProductName, materialName);
if (excludeId != null) {
queryWrapper.ne(ProductMaterial::getId, excludeId);
}
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
index 49829f7..770944b 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
@@ -11,7 +11,7 @@
import com.ruoyi.production.mapper.ProductMaterialSkuMapper;
import com.ruoyi.production.pojo.ProductMaterial;
import com.ruoyi.production.pojo.ProductMaterialSku;
-import com.ruoyi.production.pojo.ProductMaterialSkuImportDto;
+import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +21,6 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -59,12 +58,12 @@
public void addProductMaterialSku(ProductMaterialSku sku) {
validateProductMaterialSku(sku, false);
// 鏍¢獙鐗╂枡鏄惁瀛樺湪
- ProductMaterial material = productMaterialMapper.selectById(sku.getMaterialId());
+ ProductMaterial material = productMaterialMapper.selectById(sku.getProductId());
if (material == null) {
throw new ServiceException("鐗╂枡涓嶅瓨鍦�");
}
// 鏍¢獙瑙勬牸鏄惁閲嶅
- if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), null)) {
+ if (existsSameSpecification(sku.getProductId(), sku.getModel(), null)) {
throw new ServiceException("璇ョ墿鏂欏凡瀛樺湪鐩稿悓瑙勬牸");
}
LocalDateTime now = LocalDateTime.now();
@@ -76,7 +75,7 @@
if (!this.save(sku)) {
throw new ServiceException("鏂板鐗╂枡瑙勬牸澶辫触");
}
- log.info("鏂板鐗╂枡瑙勬牸鎴愬姛 materialId={}, specification={}", sku.getMaterialId(), sku.getSpecification());
+ log.info("鏂板鐗╂枡瑙勬牸鎴愬姛 materialId={}, specification={}", sku.getProductId(), sku.getModel());
}
/**
@@ -86,7 +85,7 @@
public void updateProductMaterialSku(ProductMaterialSku sku) {
validateProductMaterialSku(sku, true);
// 鏍¢獙瑙勬牸鏄惁閲嶅
- if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), sku.getId())) {
+ if (existsSameSpecification(sku.getProductId(), sku.getModel(), sku.getId())) {
throw new ServiceException("璇ョ墿鏂欏凡瀛樺湪鐩稿悓瑙勬牸");
}
sku.setUpdateTime(LocalDateTime.now());
@@ -120,10 +119,10 @@
if (requireId && sku.getId() == null) {
throw new ServiceException("涓婚敭ID涓嶈兘涓虹┖");
}
- if (sku.getMaterialId() == null) {
+ if (sku.getProductId() == null) {
throw new ServiceException("鐗╂枡ID涓嶈兘涓虹┖");
}
- if (StringUtils.isEmpty(sku.getSpecification())) {
+ if (StringUtils.isEmpty(sku.getModel())) {
throw new ServiceException("瑙勬牸涓嶈兘涓虹┖");
}
}
@@ -133,8 +132,8 @@
*/
private boolean existsSameSpecification(Long materialId, String specification, Long excludeId) {
LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId)
- .eq(ProductMaterialSku::getSpecification, specification);
+ queryWrapper.eq(ProductMaterialSku::getProductId, materialId)
+ .eq(ProductMaterialSku::getModel, specification);
if (excludeId != null) {
queryWrapper.ne(ProductMaterialSku::getId, excludeId);
}
@@ -172,10 +171,10 @@
Map<String, ProductMaterialSkuImportDto> specMap = new LinkedHashMap<>();
for (ProductMaterialSkuImportDto dto : importList) {
- if (dto == null || StringUtils.isEmpty(dto.getSpecification())) {
+ if (dto == null || StringUtils.isEmpty(dto.getModel())) {
continue;
}
- String specification = dto.getSpecification().trim();
+ String specification = dto.getModel().trim();
if (specification.isEmpty()) {
continue;
}
@@ -189,10 +188,10 @@
Set<String> specifications = specMap.keySet();
List<ProductMaterialSku> existList = this.list(new LambdaQueryWrapper<ProductMaterialSku>()
- .eq(ProductMaterialSku::getMaterialId, materialId)
- .in(ProductMaterialSku::getSpecification, specifications));
+ .eq(ProductMaterialSku::getProductId, materialId)
+ .in(ProductMaterialSku::getModel, specifications));
Map<String, ProductMaterialSku> existMap = existList.stream()
- .collect(Collectors.toMap(ProductMaterialSku::getSpecification, sku -> sku, (a, b) -> a));
+ .collect(Collectors.toMap(ProductMaterialSku::getModel, sku -> sku, (a, b) -> a));
LocalDateTime now = LocalDateTime.now();
List<ProductMaterialSku> saveList = new ArrayList<>();
@@ -206,8 +205,8 @@
ProductMaterialSku exist = existMap.get(specification);
if (exist == null) {
ProductMaterialSku sku = new ProductMaterialSku();
- sku.setMaterialId(materialId);
- sku.setSpecification(specification);
+ sku.setProductId(materialId);
+ sku.setModel(specification);
sku.setSupplyType(supplyType);
sku.setCreateTime(now);
sku.setUpdateTime(now);
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
index 381b642..2dfd0f3 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
@@ -130,8 +130,8 @@
@Override
- public List<ProductStructureDto> listBybomId(Integer bomId) {
- List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId);
+ public List<ProductStructureDto> listByBomId(Integer bomId) {
+ List<ProductStructureDto> list = productStructureMapper.listByBomId(bomId);
Map<Long, ProductStructureDto> map = new HashMap<>();
for (ProductStructureDto node : list) {
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index fa34114..c4f6c86 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -140,7 +140,7 @@
productionProductMain.setStatus(0);
productionProductMainMapper.insert(productionProductMain);
/*鏂板鎶ュ伐鎶曞叆琛�*/
- List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomAndProcess(productProcessRoute.getBomId(), productProcess.getId());
+ List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomAndProcess(productProcessRoute.getBomId(), productProcess.getId());
if (productStructureDtos.size() == 0) {
//濡傛灉璇ュ伐搴忔病鏈変骇鍝佺粨鏋勭殑鎶曞叆鍝�,閭h繖涓姇鍏ュ搧鍜屼骇鍑哄搧鏄悓涓�涓�
ProductStructureDto productStructureDto = new ProductStructureDto();
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index 373beb4..802a579 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -495,7 +495,7 @@
if (processRoute == null) {
return R.fail("璇峰厛璁剧疆宸ヨ壓璺嚎");
}
- List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomId(processRoute.getBomId());
+ List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomId(processRoute.getBomId());
if (productStructureDtos.isEmpty()) {
return R.fail("璇峰厛璁剧疆浜у搧缁撴瀯");
}
diff --git a/src/main/resources/mapper/production/ProductBomMapper.xml b/src/main/resources/mapper/production/ProductBomMapper.xml
index ec06cd3..e812b2c 100644
--- a/src/main/resources/mapper/production/ProductBomMapper.xml
+++ b/src/main/resources/mapper/production/ProductBomMapper.xml
@@ -15,34 +15,40 @@
<result column="update_user" property="updateUser"/>
<result column="tenant_id" property="tenantId"/>
</resultMap>
+
<select id="listPage" resultType="com.ruoyi.production.dto.ProductBomDto">
- select * from (select pb.*,
- pm.model productModelName,
- p.product_name productName
- from product_bom pb
- left join product_model pm on pb.product_model_id = pm.id
- left join product p on pm.product_id = p.id)A
- where 1=1
- <if test="c.productModelName != null">
- and productModelName = #{c.productModelName}
+ SELECT * FROM (
+ SELECT
+ pb.*,
+ pms.model AS productModelName,
+ pm.product_name AS productName
+ FROM product_bom pb
+ LEFT JOIN product_material_sku pms ON pb.product_model_id = pms.id
+ LEFT JOIN product_material pm ON pms.product_id = pm.id
+ ) A
+ WHERE 1=1
+ <if test="c.productModelName != null and c.productModelName != ''">
+ AND productModelName LIKE CONCAT('%', #{c.productModelName}, '%')
</if>
- <if test="c.productName != null">
- and productName = #{c.productName}
+ <if test="c.productName != null and c.productName != ''">
+ AND productName LIKE CONCAT('%', #{c.productName}, '%')
</if>
- <if test="c.bomNo != null">
- and bom_no = #{c.bomNo}
+ <if test="c.bomNo != null and c.bomNo != ''">
+ AND bom_no = #{c.bomNo}
</if>
- <if test="c.version != null">
- and version = #{c.version}
+ <if test="c.version != null and c.version != ''">
+ AND version = #{c.version}
</if>
</select>
+
<select id="getById" resultType="com.ruoyi.production.dto.ProductBomDto">
select pb.*,
- pm.model productModelName,
- p.product_name productName
+ pms.model AS productModelName,
+ pm.product_name AS productName
from product_bom pb
- left join product_model pm on pb.product_model_id = pm.id
- left join product p on pm.product_id = p.id
+ left join product_material_sku pms on pb.product_model_id = pms.id
+ left join product_material pm on pms.product_id = pm.id
+ where pb.id = #{id}
</select>
</mapper>
diff --git a/src/main/resources/mapper/production/ProductMaterialMapper.xml b/src/main/resources/mapper/production/ProductMaterialMapper.xml
index 0f55a3b..827273a 100644
--- a/src/main/resources/mapper/production/ProductMaterialMapper.xml
+++ b/src/main/resources/mapper/production/ProductMaterialMapper.xml
@@ -9,8 +9,8 @@
<result property="tenantId" column="tenant_id"/>
<result property="materialTypeId" column="material_type_id"/>
<result property="inventoryCategoryId" column="inventory_category_id"/>
- <result property="materialName" column="material_name"/>
- <result property="baseUnit" column="base_unit"/>
+ <result property="productName" column="product_name"/>
+ <result property="unit" column="unit"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
diff --git a/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml b/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
index 31720c9..678bb12 100644
--- a/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
+++ b/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
@@ -6,10 +6,10 @@
<resultMap id="ProductMaterialSkuResultMap" type="com.ruoyi.production.pojo.ProductMaterialSku">
<id property="id" column="id"/>
- <result property="materialId" column="material_id"/>
+ <result property="productId" column="product_id"/>
<result property="identifierCode" column="identifier_code"/>
<result property="materialCode" column="material_code"/>
- <result property="specification" column="specification"/>
+ <result property="model" column="model"/>
<result property="supplyType" column="supply_type"/>
<result property="originatorName" column="originator_name"/>
<result property="originatorOrg" column="originator_org"/>
@@ -21,28 +21,28 @@
<select id="selectSkuWithMaterialPage" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto">
SELECT
- sku.id AS skuId,
- sku.material_id AS materialId,
+ sku.id AS id,
+ sku.product_id AS productId,
sku.material_code AS materialCode,
- sku.specification AS specification,
+ sku.model AS model,
sku.supply_type AS supplyType,
- m.material_name AS materialName,
- m.base_unit AS baseUnit
+ m.product_name AS productName,
+ m.unit AS unit
FROM product_material_sku sku
- LEFT JOIN product_material m ON sku.material_id = m.id
+ LEFT JOIN product_material m ON sku.product_id = m.id
<where>
- <if test="dto.materialId != null">
- AND sku.material_id = #{dto.materialId}
+ <if test="dto.productId != null">
+ AND sku.product_id = #{dto.productId}
</if>
- <if test="dto.specification != null and dto.specification != ''">
- AND sku.specification LIKE CONCAT('%', #{dto.specification}, '%')
+ <if test="dto.model != null and dto.model != ''">
+ AND sku.model LIKE CONCAT('%', #{dto.model}, '%')
</if>
<if test="dto.materialCode != null and dto.materialCode != ''">
AND sku.material_code LIKE CONCAT('%', #{dto.materialCode}, '%')
</if>
- <if test="type != null and type == 1 and dto.materialName != null and dto.materialName != ''">
- AND m.material_name LIKE CONCAT('%', #{dto.materialName}, '%')
+ <if test="type != null and type == 1 and dto.productName != null and dto.productName != ''">
+ AND m.product_name LIKE CONCAT('%', #{dto.productName}, '%')
</if>
</where>
ORDER BY sku.id ASC
diff --git a/src/main/resources/mapper/production/ProductStructureMapper.xml b/src/main/resources/mapper/production/ProductStructureMapper.xml
index e4a0795..8a707ba 100644
--- a/src/main/resources/mapper/production/ProductStructureMapper.xml
+++ b/src/main/resources/mapper/production/ProductStructureMapper.xml
@@ -11,33 +11,33 @@
<result property="unit" column="unit"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
- <select id="listBybomId" resultType="com.ruoyi.production.dto.ProductStructureDto">
+
+ <select id="listByBomId" resultType="com.ruoyi.production.dto.ProductStructureDto">
select ps.*,
- p.product_name,
- pp.name as process_name,
- pm.product_id,
- pm.model
- from
- product_structure ps
- left join product_model pm on ps.product_model_id = pm.id
- left join product p on pm.product_id = p.id
- left join product_process pp on ps.process_id = pp.id
+ pm.product_name as product_name,
+ pp.name as process_name,
+ pms.product_id as product_id,
+ pms.model as model
+ from product_structure ps
+ left join product_material_sku pms on ps.product_model_id = pms.id
+ left join product_material pm on pms.product_id = pm.id
+ left join product_process pp on ps.process_id = pp.id
where ps.bom_id = #{bomId}
order by ps.id
</select>
- <select id="listBybomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto">
+
+ <select id="listByBomAndProcess" resultType="com.ruoyi.production.dto.ProductStructureDto">
select ps.*,
- p.product_name,
- pp.name as process_name,
- pm.product_id,
- pm.model
- from
- product_structure ps
- left join product_model pm on ps.product_model_id = pm.id
- left join product p on pm.product_id = p.id
- left join product_process pp on ps.process_id = pp.id
+ pm.product_name as product_name,
+ pp.name as process_name,
+ pms.product_id as product_id,
+ pms.model as model
+ from product_structure ps
+ left join product_material_sku pms on ps.product_model_id = pms.id
+ left join product_material pm on pms.product_id = pm.id
+ left join product_process pp on ps.process_id = pp.id
where ps.bom_id = #{bomId}
- and ps.process_id=#{processId}
+ and ps.process_id = #{processId}
order by ps.id
</select>
</mapper>
--
Gitblit v1.9.3