feat(material): 添加钢卷原料厚度自动提取功能
- 新增 WmsMaterialCoilMapper.selectRawMaterialThicknessByEnterCoilNos 方法 - 添加 MyBatis 映射查询热轧卷板原料规格 - 在 WmsMaterialCoilServiceImpl 中实现 fillRawMaterialThickness 方法 - 自动从规格字段提取 * 前的数字作为厚度值 - 在 WmsMaterialCoilVo 中新增 rawMaterialThickness 字段 - 分页查询时自动填充原料厚度信息
This commit is contained in:
@@ -364,5 +364,10 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
||||
* 合同编号
|
||||
*/
|
||||
private String contractNo;
|
||||
|
||||
/**
|
||||
* 原料厚度(从热轧卷板原料的规格中提取*前面的数字,如 0.1*1000 → 0.1)
|
||||
*/
|
||||
private String rawMaterialThickness;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,5 +172,13 @@ public interface WmsMaterialCoilMapper extends BaseMapperPlus<WmsMaterialCoilMap
|
||||
* @return 子钢卷列表
|
||||
*/
|
||||
List<WmsMaterialCoil> selectByParentCoilIds(@Param("coilIds") java.util.Collection<Long> coilIds);
|
||||
/**
|
||||
* 根据入场钢卷号列表批量查询热轧卷板原料的规格
|
||||
* 用于提取原料厚度:同一个入场卷号下,parent_coil_id 为空且 item_type='raw_material' 且 raw_material_name 包含"热轧卷板"
|
||||
*
|
||||
* @param enterCoilNos 入场钢卷号列表
|
||||
* @return 列表,每项包含 enterCoilNo 和 specification
|
||||
*/
|
||||
List<Map<String, String>> selectRawMaterialThicknessByEnterCoilNos(@Param("enterCoilNos") java.util.Collection<String> enterCoilNos);
|
||||
}
|
||||
|
||||
|
||||
@@ -577,6 +577,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
fillPageCommonFields(records);
|
||||
fillRawMaterialThickness(records);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@@ -790,6 +791,50 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量填充原料厚度:根据入场卷号查询热轧卷板原料的规格,提取*前面的数字作为厚度
|
||||
* <p>逻辑:同一个 enterCoilNo 下,找 parent_coil_id 为空、itemType=raw_material、
|
||||
* 且关联的 wms_raw_material.raw_material_name 包含"热轧卷板"的记录,
|
||||
* 取 specification 中 * 前面的数字(如 0.1*1000 → 0.1)</p>
|
||||
*/
|
||||
private void fillRawMaterialThickness(List<WmsMaterialCoilVo> records) {
|
||||
List<String> enterCoilNos = records.stream()
|
||||
.map(WmsMaterialCoilVo::getEnterCoilNo)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (enterCoilNos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Map<String, String>> rawList = baseMapper.selectRawMaterialThicknessByEnterCoilNos(enterCoilNos);
|
||||
if (rawList == null || rawList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建 enterCoilNo → 厚度 的映射
|
||||
Map<String, String> thickMap = new HashMap<>();
|
||||
for (Map<String, String> row : rawList) {
|
||||
String enterCoilNo = row.get("enterCoilNo");
|
||||
String spec = row.get("specification");
|
||||
if (StringUtils.isNotBlank(enterCoilNo) && StringUtils.isNotBlank(spec)) {
|
||||
int starIdx = spec.indexOf('*');
|
||||
if (starIdx > 0) {
|
||||
thickMap.put(enterCoilNo, spec.substring(0, starIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 回填到每条记录
|
||||
for (WmsMaterialCoilVo vo : records) {
|
||||
String thickness = thickMap.get(vo.getEnterCoilNo());
|
||||
if (thickness != null) {
|
||||
vo.setRawMaterialThickness(thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计筛选条件下的全量汇总数据(高性能:只查sum/count)
|
||||
*/
|
||||
|
||||
@@ -1122,5 +1122,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 根据入场钢卷号列表批量查询热轧卷板原料的规格(用于提取原料厚度) -->
|
||||
<select id="selectRawMaterialThicknessByEnterCoilNos" resultType="java.util.Map">
|
||||
SELECT mc.enter_coil_no AS enterCoilNo, rm.specification AS specification
|
||||
FROM wms_material_coil mc
|
||||
INNER JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id AND rm.del_flag = 0
|
||||
WHERE mc.del_flag = 0
|
||||
AND mc.enter_coil_no IN
|
||||
<foreach collection="enterCoilNos" item="no" open="(" separator="," close=")">
|
||||
#{no}
|
||||
</foreach>
|
||||
AND (mc.parent_coil_id IS NULL OR mc.parent_coil_id = '')
|
||||
AND mc.item_type = 'raw_material'
|
||||
AND rm.raw_material_name LIKE '%热轧卷板%'
|
||||
AND rm.specification IS NOT NULL
|
||||
AND rm.specification != ''
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user