feat(wms): 添加钢卷类别统计——汇总统计

- 新增 CategoryWidthRawVo 和 CategoryWidthStatisticsVo 数据传输对象
- 在 IWmsMaterialCoilService 中添加 getCategoryWidthStatistics 方法定义
- 实现 WmsMaterialCoilController 的 categoryWidthStatistics 接口
- 添加 WmsMaterialCoilMapper 的 selectCategoryWidthStatistics 查询方法
- 实现 WmsMaterialCoilServiceImpl 中的 getCategoryWidthStatistics 业务逻辑
- 在 XML 映射文件中添加类别宽度统计的 SQL 查询语句
This commit is contained in:
2026-03-09 10:46:22 +08:00
parent 7736ac3311
commit 0050af7677
7 changed files with 145 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import com.klp.common.utils.poi.ExcelUtil;
import com.klp.domain.vo.WmsMaterialCoilVo;
import com.klp.domain.bo.WmsMaterialCoilBo;
import com.klp.domain.vo.dashboard.CoilTrimStatisticsVo;
import com.klp.domain.vo.dashboard.CategoryWidthStatisticsVo;
import com.klp.service.IWmsMaterialCoilService;
import com.klp.common.core.page.TableDataInfo;
@@ -466,6 +467,16 @@ public class WmsMaterialCoilController extends BaseController {
return R.ok(iWmsMaterialCoilService.getCoilTrimStatistics());
}
/**
* 类别宽度统计
* 纵坐标:热轧卷板、冷硬卷、冷轧卷、镀锌钢卷(毛化)、镀锌管料、镀锌钢卷(未光整)
* 横坐标净边1000、1200、1220、1250 + 其他宽度及毛边 + 合计
*/
@GetMapping("/categoryWidthStatistics")
public R<List<CategoryWidthStatisticsVo>> categoryWidthStatistics() {
return R.ok(iWmsMaterialCoilService.getCategoryWidthStatistics());
}
}

View File

@@ -0,0 +1,12 @@
package com.klp.domain.vo.dashboard;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CategoryWidthRawVo {
private String category;
private String width;
private String isTrimmed;
private BigDecimal totalWeight;
}

View File

@@ -0,0 +1,16 @@
package com.klp.domain.vo.dashboard;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class CategoryWidthStatisticsVo {
private String category;
private BigDecimal width1000;
private BigDecimal width1200;
private BigDecimal width1220;
private BigDecimal width1250;
private BigDecimal otherWidth;
private BigDecimal total;
}

View File

@@ -9,6 +9,7 @@ import com.klp.domain.vo.WmsMaterialCoilVo;
import com.klp.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import com.klp.domain.vo.dashboard.CoilTrimRawVo;
import com.klp.domain.vo.dashboard.CategoryWidthRawVo;
import java.util.List;
import java.util.Map;
@@ -83,5 +84,7 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
List<WmsMaterialCoilDeliveryExportVo> selectDeliveryExportListByCoilIds(@Param("coilIds") java.util.Collection<Long> coilIds);
List<CoilTrimRawVo> selectCoilTrimStatistics();
List<CategoryWidthRawVo> selectCategoryWidthStatistics();
}

View File

@@ -7,6 +7,7 @@ import com.klp.domain.bo.WmsMaterialCoilBo;
import com.klp.common.core.page.TableDataInfo;
import com.klp.common.core.domain.PageQuery;
import com.klp.domain.vo.dashboard.CoilTrimStatisticsVo;
import com.klp.domain.vo.dashboard.CategoryWidthStatisticsVo;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@@ -217,6 +218,9 @@ public interface IWmsMaterialCoilService {
Map<String, Object> cancelSpecialSplit(@NotNull(message = "待操作记录ID不能为空") Long pendingActionId);
List<CoilTrimStatisticsVo> getCoilTrimStatistics();
List<CategoryWidthStatisticsVo> getCategoryWidthStatistics();
WmsMaterialCoilVo returnCoil(@NotNull(message = "钢卷ID不能为空") Long coilId);
/**

View File

@@ -21,6 +21,8 @@ import com.klp.domain.vo.*;
import com.klp.domain.vo.dashboard.CoilTrimStatisticsVo;
import com.klp.domain.vo.dashboard.CoilTrimRawVo;
import com.klp.domain.vo.dashboard.TrimWidthStatisticsVo;
import com.klp.domain.vo.dashboard.CategoryWidthStatisticsVo;
import com.klp.domain.vo.dashboard.CategoryWidthRawVo;
import com.klp.domain.WmsCoilPendingAction;
import com.klp.domain.bo.WmsCoilPendingActionBo;
import com.klp.mapper.*;
@@ -4395,5 +4397,60 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
return result;
}
@Override
public List<CategoryWidthStatisticsVo> getCategoryWidthStatistics() {
List<CategoryWidthRawVo> rawList = baseMapper.selectCategoryWidthStatistics();
Map<String, List<CategoryWidthRawVo>> byCategory = rawList.stream()
.collect(Collectors.groupingBy(v -> v.getCategory() == null ? "其他" : v.getCategory()));
List<CategoryWidthStatisticsVo> result = new ArrayList<>();
for (Map.Entry<String, List<CategoryWidthRawVo>> categoryEntry : byCategory.entrySet()) {
CategoryWidthStatisticsVo vo = new CategoryWidthStatisticsVo();
vo.setCategory(categoryEntry.getKey());
BigDecimal total = BigDecimal.ZERO;
BigDecimal width1000 = BigDecimal.ZERO;
BigDecimal width1200 = BigDecimal.ZERO;
BigDecimal width1220 = BigDecimal.ZERO;
BigDecimal width1250 = BigDecimal.ZERO;
BigDecimal otherWidth = BigDecimal.ZERO;
for (CategoryWidthRawVo raw : categoryEntry.getValue()) {
BigDecimal weight = raw.getTotalWeight() == null ? BigDecimal.ZERO : raw.getTotalWeight();
String width = raw.getWidth();
String isTrimmed = raw.getIsTrimmed();
if ("净边".equals(isTrimmed)) {
if ("1000".equals(width)) {
width1000 = width1000.add(weight);
} else if ("1200".equals(width)) {
width1200 = width1200.add(weight);
} else if ("1220".equals(width)) {
width1220 = width1220.add(weight);
} else if ("1250".equals(width)) {
width1250 = width1250.add(weight);
} else {
otherWidth = otherWidth.add(weight);
}
} else {
otherWidth = otherWidth.add(weight);
}
total = total.add(weight);
}
vo.setWidth1000(width1000);
vo.setWidth1200(width1200);
vo.setWidth1220(width1220);
vo.setWidth1250(width1250);
vo.setOtherWidth(otherWidth);
vo.setTotal(total);
result.add(vo);
}
return result;
}
}

View File

@@ -703,5 +703,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY thickness, width, trimmingRequirement
</select>
<!-- 类别宽度统计 -->
<select id="selectCategoryWidthStatistics" resultType="com.klp.domain.vo.dashboard.CategoryWidthRawVo">
SELECT
CASE
WHEN rm.raw_material_name LIKE '%热轧卷板%' OR p.product_name LIKE '%热轧卷板%' THEN '热轧卷板'
WHEN rm.raw_material_name LIKE '%冷硬卷%' OR p.product_name LIKE '%冷硬卷%' THEN '冷硬卷'
WHEN rm.raw_material_name LIKE '%冷轧卷%' OR p.product_name LIKE '%冷轧卷%' THEN '冷轧卷'
WHEN rm.raw_material_name LIKE '%镀锌卷%' OR p.product_name LIKE '%镀锌卷%' THEN
CASE
WHEN mc.business_purpose = '毛化镀锌卷' THEN '镀锌钢卷(毛化)'
WHEN mc.business_purpose = '镀锌管料' THEN '镀锌管料'
WHEN mc.business_purpose = '镀锌钢卷' THEN '镀锌钢卷(未光整)'
ELSE '镀锌卷'
END
ELSE '其他'
END AS category,
SUBSTRING_INDEX(COALESCE(rm.specification, p.specification), '*', -1) AS width,
CASE
WHEN mc.trimming_requirement = '净边' THEN '净边'
ELSE '毛边'
END AS isTrimmed,
COALESCE(SUM(mc.net_weight), 0) AS totalWeight
FROM wms_material_coil mc
LEFT JOIN wms_raw_material rm ON mc.item_id = rm.raw_material_id AND mc.item_type = 'raw_material'
LEFT JOIN wms_product p ON mc.item_id = p.product_id AND mc.item_type = 'product'
WHERE mc.del_flag = 0
AND mc.data_type = 1
AND mc.status = 0
AND (
rm.raw_material_name LIKE '%热轧卷板%'
OR p.product_name LIKE '%热轧卷板%'
OR rm.raw_material_name LIKE '%冷硬卷%'
OR p.product_name LIKE '%冷硬卷%'
OR rm.raw_material_name LIKE '%冷轧卷%'
OR p.product_name LIKE '%冷轧卷%'
OR rm.raw_material_name LIKE '%镀锌卷%'
OR p.product_name LIKE '%镀锌卷%'
)
GROUP BY category, width, isTrimmed
ORDER BY category, isTrimmed, width
</select>
</mapper>