From 26e295956b81d6bfe5f181f040bf8ecd0079ba54 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 14 三月 2026 16:21:03 +0800
Subject: [PATCH] feat: 判断是否为BOM的选择产品查询
---
src/main/resources/mapper/production/ProductMaterialSkuMapper.xml | 29 ++++++++++++++
src/main/java/com/ruoyi/production/mapper/ProductMaterialSkuMapper.java | 11 +++++
src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java | 43 +--------------------
src/main/java/com/ruoyi/production/service/ProductMaterialSkuService.java | 2
src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java | 4 +-
5 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java b/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
index 170cefe..ed44765 100644
--- a/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
+++ b/src/main/java/com/ruoyi/production/controller/ProductMaterialSkuController.java
@@ -38,8 +38,8 @@
@GetMapping("/list")
@ApiOperation("鐗╂枡瑙勬牸鏁版嵁闆嗗悎")
@Log(title = "鐗╂枡瑙勬牸鏁版嵁闆嗗悎", businessType = BusinessType.OTHER)
- public AjaxResult productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) {
- Page<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(page, dto);
+ public AjaxResult productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, @RequestParam(value = "type", required = false) Integer type) {
+ Page<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(page, dto, type);
return AjaxResult.success(list);
}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductMaterialSkuMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductMaterialSkuMapper.java
index 0bdbcf2..f9fbe78 100644
--- a/src/main/java/com/ruoyi/production/mapper/ProductMaterialSkuMapper.java
+++ b/src/main/java/com/ruoyi/production/mapper/ProductMaterialSkuMapper.java
@@ -1,7 +1,10 @@
package com.ruoyi.production.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.production.dto.ProductMaterialSkuDto;
import com.ruoyi.production.pojo.ProductMaterialSku;
+import org.apache.ibatis.annotations.Param;
/**
* <br>
@@ -13,4 +16,10 @@
* @since 2026/03/12 10:04
*/
public interface ProductMaterialSkuMapper extends BaseMapper<ProductMaterialSku> {
-}
+
+ /**
+ * 杩炶〃鏌ヨ鐗╂枡鍜岃鏍�
+ */
+ Page<ProductMaterialSkuDto> selectSkuWithMaterialPage(@Param("page") Page<ProductMaterialSkuDto> page, @Param("dto") ProductMaterialSkuDto dto, @Param("type") Integer type);
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/service/ProductMaterialSkuService.java b/src/main/java/com/ruoyi/production/service/ProductMaterialSkuService.java
index 104f17d..3f53dc2 100644
--- a/src/main/java/com/ruoyi/production/service/ProductMaterialSkuService.java
+++ b/src/main/java/com/ruoyi/production/service/ProductMaterialSkuService.java
@@ -18,7 +18,7 @@
* @since 2026/03/12 10:04
*/
public interface ProductMaterialSkuService extends IService<ProductMaterialSku> {
- Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto);
+ Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, Integer type);
void addProductMaterialSku(ProductMaterialSku productMaterialSku);
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 b3717ad..49829f7 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
@@ -39,9 +39,7 @@
*/
@Slf4j
@Service
-public class ProductMaterialSkuServiceImpl
- extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku>
- implements ProductMaterialSkuService {
+public class ProductMaterialSkuServiceImpl extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> implements ProductMaterialSkuService {
@Autowired
private ProductMaterialMapper productMaterialMapper;
@@ -50,43 +48,8 @@
* 鏌ヨ鐗╂枡瑙勬牸鍒楄〃
*/
@Override
- public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) {
- LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>();
- if (dto != null && dto.getMaterialId() != null) {
- queryWrapper.eq(ProductMaterialSku::getMaterialId, dto.getMaterialId())
- .like(StringUtils.isNotBlank(dto.getSpecification()),
- ProductMaterialSku::getSpecification, dto.getSpecification())
- .like(StringUtils.isNotBlank(dto.getMaterialCode()),
- ProductMaterialSku::getMaterialCode, dto.getMaterialCode())
- .orderByAsc(ProductMaterialSku::getId);
- }
- Page<ProductMaterialSku> skuPage = this.page(page, queryWrapper);
- List<ProductMaterialSku> skuList = skuPage.getRecords();
- if (skuList == null || skuList.isEmpty()) {
- return new Page<>();
- }
-
- ProductMaterial material = productMaterialMapper.selectById(dto.getMaterialId());
- String materialName = material != null ? material.getMaterialName() : null;
- String baseUnit = material != null ? material.getBaseUnit() : null;
- List<ProductMaterialSkuDto> result = new ArrayList<>(skuList.size());
- for (ProductMaterialSku sku : skuList) {
- ProductMaterialSkuDto productMaterialSkuDto = new ProductMaterialSkuDto();
- productMaterialSkuDto.setMaterialId(dto.getMaterialId());
- productMaterialSkuDto.setMaterialName(materialName);
- productMaterialSkuDto.setMaterialCode(sku.getMaterialCode());
- productMaterialSkuDto.setBaseUnit(baseUnit);
- productMaterialSkuDto.setSkuId(sku.getId());
- productMaterialSkuDto.setSpecification(sku.getSpecification());
- productMaterialSkuDto.setSupplyType(sku.getSupplyType());
- result.add(productMaterialSkuDto);
- }
- Page<ProductMaterialSkuDto> dtoPage = new Page<>();
- dtoPage.setCurrent(skuPage.getCurrent());
- dtoPage.setSize(skuPage.getSize());
- dtoPage.setTotal(skuPage.getTotal());
- dtoPage.setRecords(result);
- return dtoPage;
+ public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, Integer type) {
+ return baseMapper.selectSkuWithMaterialPage(page, dto, type);
}
/**
diff --git a/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml b/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
index ccd26ed..31720c9 100644
--- a/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
+++ b/src/main/resources/mapper/production/ProductMaterialSkuMapper.xml
@@ -19,4 +19,33 @@
<result property="updateTime" column="update_time"/>
</resultMap>
+ <select id="selectSkuWithMaterialPage" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto">
+ SELECT
+ sku.id AS skuId,
+ sku.material_id AS materialId,
+ sku.material_code AS materialCode,
+ sku.specification AS specification,
+ sku.supply_type AS supplyType,
+ m.material_name AS materialName,
+ m.base_unit AS baseUnit
+ FROM product_material_sku sku
+ LEFT JOIN product_material m ON sku.material_id = m.id
+ <where>
+ <if test="dto.materialId != null">
+ AND sku.material_id = #{dto.materialId}
+ </if>
+ <if test="dto.specification != null and dto.specification != ''">
+ AND sku.specification LIKE CONCAT('%', #{dto.specification}, '%')
+ </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>
+ </where>
+ ORDER BY sku.id ASC
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3