feat(wms): 新增第三个报表统计——冷硬卷统计
- 在IWmsMaterialCoilService中添加getCoilTrimStatistics方法 - 在WmsMaterialCoilController中新增trimStatistics接口 - 在WmsMaterialCoilMapper中添加selectCoilTrimStatistics查询方法 - 在WmsMaterialCoilMapper.xml中实现切边统计数据SQL查询 - 在WmsMaterialCoilServiceImpl中实现切边统计业务逻辑 - 新增CoilTrimRawVo、CoilTrimStatisticsVo和TrimWidthStatisticsVo数据传输对象 - 按厚度、宽度、切边要求(净边/毛边)统计钢卷数量和重量 - 实现数据分组和排序功能,支持前端展示需求
This commit is contained in:
@@ -24,6 +24,7 @@ import com.klp.common.enums.BusinessType;
|
||||
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.service.IWmsMaterialCoilService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
|
||||
@@ -442,6 +443,15 @@ public class WmsMaterialCoilController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 冷硬卷切边统计
|
||||
* 按厚度、宽度、切边要求(净边/毛边)统计钢卷数量和重量
|
||||
*/
|
||||
@GetMapping("/trimStatistics")
|
||||
public R<List<CoilTrimStatisticsVo>> trimStatistics() {
|
||||
return R.ok(iWmsMaterialCoilService.getCoilTrimStatistics());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.klp.domain.vo.dashboard;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CoilTrimRawVo {
|
||||
private String thickness;
|
||||
private String width;
|
||||
private String trimmingRequirement;
|
||||
private Integer coilCount;
|
||||
private BigDecimal totalWeight;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.klp.domain.vo.dashboard;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CoilTrimStatisticsVo {
|
||||
private String thickness;
|
||||
private List<TrimWidthStatisticsVo> trimmedList;
|
||||
private List<TrimWidthStatisticsVo> untrimmedList;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.klp.domain.vo.dashboard;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class TrimWidthStatisticsVo {
|
||||
private String width;
|
||||
private Integer coilCount;
|
||||
private BigDecimal totalWeight;
|
||||
}
|
||||
@@ -8,15 +8,10 @@ import com.klp.domain.vo.WmsMaterialCoilDeliveryExportVo;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 钢卷物料表Mapper接口
|
||||
*
|
||||
* @author Joshi
|
||||
* @date 2025-07-18
|
||||
*/
|
||||
public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMapper, WmsMaterialCoil, WmsMaterialCoilVo> {
|
||||
|
||||
/**
|
||||
@@ -85,6 +80,8 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
|
||||
* @param coilIds 钢卷ID集合
|
||||
* @return 发货报表导出数据
|
||||
*/
|
||||
List<WmsMaterialCoilDeliveryExportVo> selectDeliveryExportListByCoilIds(@Param("coilIds") java.util.Collection<Long> coilIds);
|
||||
List<WmsMaterialCoilDeliveryExportVo> selectDeliveryExportListByCoilIds(@Param("coilIds") java.util.Collection<Long> coilIds);
|
||||
|
||||
List<CoilTrimRawVo> selectCoilTrimStatistics();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.klp.domain.vo.WmsMaterialCoilVo;
|
||||
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 javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -221,6 +222,8 @@ public interface IWmsMaterialCoilService {
|
||||
* @param coilId 原钢卷ID
|
||||
* @return 退货后的新钢卷信息
|
||||
*/
|
||||
WmsMaterialCoilVo returnCoil(@NotNull(message = "钢卷ID不能为空") Long coilId);
|
||||
WmsMaterialCoilVo returnCoil(@NotNull(message = "钢卷ID不能为空") Long coilId);
|
||||
|
||||
List<CoilTrimStatisticsVo> getCoilTrimStatistics();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ import com.klp.common.utils.StringUtils;
|
||||
import com.klp.domain.*;
|
||||
import com.klp.domain.bo.*;
|
||||
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.WmsCoilPendingAction;
|
||||
import com.klp.domain.bo.WmsCoilPendingActionBo;
|
||||
import com.klp.mapper.*;
|
||||
@@ -4304,5 +4307,77 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CoilTrimStatisticsVo> getCoilTrimStatistics() {
|
||||
List<CoilTrimRawVo> rawList = baseMapper.selectCoilTrimStatistics();
|
||||
|
||||
Map<String, List<CoilTrimRawVo>> byThickness = rawList.stream()
|
||||
.collect(Collectors.groupingBy(v -> v.getThickness() == null ? "空置" : v.getThickness()));
|
||||
|
||||
List<CoilTrimStatisticsVo> result = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, List<CoilTrimRawVo>> thicknessEntry : byThickness.entrySet()) {
|
||||
CoilTrimStatisticsVo vo = new CoilTrimStatisticsVo();
|
||||
vo.setThickness(thicknessEntry.getKey());
|
||||
|
||||
List<CoilTrimRawVo> thicknessList = thicknessEntry.getValue();
|
||||
|
||||
Map<String, List<CoilTrimRawVo>> byTrim = thicknessList.stream()
|
||||
.collect(Collectors.groupingBy(v -> v.getTrimmingRequirement() == null ? "未知" : v.getTrimmingRequirement()));
|
||||
|
||||
List<CoilTrimStatisticsVo> resultList = new ArrayList<>();
|
||||
for (Map.Entry<String, List<CoilTrimRawVo>> trimEntry : byTrim.entrySet()) {
|
||||
CoilTrimStatisticsVo trimVo = new CoilTrimStatisticsVo();
|
||||
trimVo.setThickness(trimEntry.getKey());
|
||||
|
||||
List<TrimWidthStatisticsVo> widthList = new ArrayList<>();
|
||||
for (CoilTrimRawVo raw : trimEntry.getValue()) {
|
||||
TrimWidthStatisticsVo widthVo = new TrimWidthStatisticsVo();
|
||||
widthVo.setWidth(raw.getWidth() == null ? "空置" : raw.getWidth());
|
||||
widthVo.setCoilCount(raw.getCoilCount() == null ? 0 : raw.getCoilCount());
|
||||
widthVo.setTotalWeight(raw.getTotalWeight() == null ? BigDecimal.ZERO : raw.getTotalWeight());
|
||||
widthList.add(widthVo);
|
||||
}
|
||||
trimVo.setTrimmedList(widthList);
|
||||
resultList.add(trimVo);
|
||||
}
|
||||
|
||||
List<CoilTrimRawVo> trimmedList = byTrim.getOrDefault("净边", new ArrayList<>());
|
||||
List<CoilTrimRawVo> untrimmedList = byTrim.getOrDefault("毛边", new ArrayList<>());
|
||||
|
||||
List<TrimWidthStatisticsVo> trimmedWidthList = new ArrayList<>();
|
||||
for (CoilTrimRawVo raw : trimmedList) {
|
||||
TrimWidthStatisticsVo widthVo = new TrimWidthStatisticsVo();
|
||||
widthVo.setWidth(raw.getWidth() == null ? "空置" : raw.getWidth());
|
||||
widthVo.setCoilCount(raw.getCoilCount() == null ? 0 : raw.getCoilCount());
|
||||
widthVo.setTotalWeight(raw.getTotalWeight() == null ? BigDecimal.ZERO : raw.getTotalWeight());
|
||||
trimmedWidthList.add(widthVo);
|
||||
}
|
||||
|
||||
List<TrimWidthStatisticsVo> untrimmedWidthList = new ArrayList<>();
|
||||
for (CoilTrimRawVo raw : untrimmedList) {
|
||||
TrimWidthStatisticsVo widthVo = new TrimWidthStatisticsVo();
|
||||
widthVo.setWidth(raw.getWidth() == null ? "空置" : raw.getWidth());
|
||||
widthVo.setCoilCount(raw.getCoilCount() == null ? 0 : raw.getCoilCount());
|
||||
widthVo.setTotalWeight(raw.getTotalWeight() == null ? BigDecimal.ZERO : raw.getTotalWeight());
|
||||
untrimmedWidthList.add(widthVo);
|
||||
}
|
||||
|
||||
vo.setTrimmedList(trimmedWidthList);
|
||||
vo.setUntrimmedList(untrimmedWidthList);
|
||||
result.add(vo);
|
||||
}
|
||||
|
||||
result.sort(Comparator.comparing(v -> {
|
||||
try {
|
||||
return new BigDecimal(v.getThickness());
|
||||
} catch (Exception e) {
|
||||
return new BigDecimal("999999");
|
||||
}
|
||||
}));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -678,5 +678,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE coil_id = #{coilId}
|
||||
</update>
|
||||
|
||||
<!-- 冷硬卷切边统计:按厚度、宽度、切边要求统计数量和重量 -->
|
||||
<select id="selectCoilTrimStatistics" resultType="com.klp.domain.vo.dashboard.CoilTrimRawVo">
|
||||
SELECT
|
||||
SUBSTRING_INDEX(COALESCE(rm.specification, p.specification), '*', 1) AS thickness,
|
||||
SUBSTRING_INDEX(COALESCE(rm.specification, p.specification), '*', -1) AS width,
|
||||
CASE
|
||||
WHEN mc.trimming_requirement = '净边' THEN '净边'
|
||||
ELSE '毛边'
|
||||
END AS trimmingRequirement,
|
||||
COUNT(mc.coil_id) AS coilCount,
|
||||
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 '%冷硬卷%'
|
||||
)
|
||||
GROUP BY thickness, width, trimmingRequirement
|
||||
ORDER BY thickness, width, trimmingRequirement
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user