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; 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)); } } src/main/java/com/ruoyi/production/dto/ProductMaterialDto.java
@@ -33,7 +33,7 @@ private Integer inventoryCategoryId; @ApiModelProperty("ç©æåç§°") private String materialName; private String productName; } 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; src/main/java/com/ruoyi/production/dto/ProductMaterialSkuImportDto.java
ÎļþÃû´Ó src/main/java/com/ruoyi/production/pojo/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 = "ä¾åºæ¹å¼") 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); } 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; 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; 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); } 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); // ç¶èç¹ID 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; } 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); } 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); 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) { 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) { //å¦æè¯¥å·¥åºæ²¡æäº§åç»æçæå ¥å,é£è¿ä¸ªæå ¥åå产åºåæ¯åä¸ä¸ª ProductStructureDto productStructureDto = new ProductStructureDto(); 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("请å 设置产åç»æ"); } 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> 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"/> 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 src/main/resources/mapper/production/ProductStructureMapper.xml
@@ -11,30 +11,30 @@ <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, pm.product_name as 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 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, pm.product_name as 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 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}