feat(qc): 增强检查任务查询功能以支持详细检查项信息
- 在 WmsCheckItemVo 中新增 checkTaskItemId 字段 - 修改 WmsCheckTaskMapper.xml 以查询更多检查项相关字段 - 更新 WmsCheckTaskServiceImpl 中的 queryById 方法以处理新增字段 - 在 WmsCheckTaskVo 中添加 targetUppers、targetLowers 等字段用于存储检查项详情 - 优化字段拆分和赋值逻辑,增强数据处理的健壮性- 添加对数值类型字段的安全转换处理,避免解析异常
This commit is contained in:
@@ -54,4 +54,6 @@ public class WmsCheckItemVo {
|
||||
//定性定量
|
||||
private Integer qualitativeQuantitative;
|
||||
|
||||
private Long checkTaskItemId;
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class WmsCheckTaskVo {
|
||||
*/
|
||||
private String itemNames;
|
||||
|
||||
|
||||
// 校验目标(JSON格式,存储复杂校验规则)
|
||||
private String verifyTarget;
|
||||
|
||||
@@ -69,4 +70,24 @@ public class WmsCheckTaskVo {
|
||||
|
||||
// 检验类型
|
||||
private String inspectionType;
|
||||
|
||||
// 目标上限
|
||||
private String targetUppers;
|
||||
|
||||
// 目标下限
|
||||
private String targetLowers;
|
||||
|
||||
// 标准目标
|
||||
private String standardTargets;
|
||||
|
||||
// 单位
|
||||
private String units;
|
||||
|
||||
// 定性定量:0=定性,1=定量
|
||||
private String qualitativeQuantitatives;
|
||||
|
||||
// 实测值
|
||||
private String actualMeasures;
|
||||
|
||||
private String checkTaskItemIds;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.klp.mes.qc.mapper.WmsCheckTaskMapper;
|
||||
import com.klp.mes.qc.service.IWmsCheckTaskService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -45,16 +46,44 @@ public class WmsCheckTaskServiceImpl implements IWmsCheckTaskService {
|
||||
public WmsCheckTaskVo queryById(Long taskId) {
|
||||
WmsCheckTaskVo vo = baseMapper.selectVoByIdPlus(taskId);
|
||||
if (vo != null && vo.getItemIds() != null) {
|
||||
String[] ids = vo.getItemIds().split(",");
|
||||
// 1. 拆分所有聚合字段(新增 checkTaskItemIds 的处理)
|
||||
String[] ids = vo.getItemIds().split(","); // 检查项表的 item_id
|
||||
String[] checkTaskItemIds = vo.getCheckTaskItemIds() != null ? vo.getCheckTaskItemIds().split(",") : new String[ids.length]; // 关联表的 item_id(新增)
|
||||
String[] names = vo.getItemNames() != null ? vo.getItemNames().split(",") : new String[ids.length];
|
||||
String[] statusArr = vo.getItemStatus() != null ? vo.getItemStatus().split(",") : new String[ids.length];
|
||||
String[] targetUppers = vo.getTargetUppers() != null ? vo.getTargetUppers().split(",") : new String[ids.length];
|
||||
String[] targetLowers = vo.getTargetLowers() != null ? vo.getTargetLowers().split(",") : new String[ids.length];
|
||||
String[] standardTargets = vo.getStandardTargets() != null ? vo.getStandardTargets().split(",") : new String[ids.length];
|
||||
String[] units = vo.getUnits() != null ? vo.getUnits().split(",") : new String[ids.length];
|
||||
String[] qualitativeQuantitatives = vo.getQualitativeQuantitatives() != null ? vo.getQualitativeQuantitatives().split(",") : new String[ids.length];
|
||||
|
||||
List<WmsCheckItemVo> itemList = new ArrayList<>();
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (!ids[i].isEmpty()) {
|
||||
if (!ids[i].isEmpty()) { // 跳过空字符串(避免拆分后出现空元素)
|
||||
WmsCheckItemVo item = new WmsCheckItemVo();
|
||||
// 2. 赋值检查项 ID(原逻辑保留)
|
||||
item.setItemId(Long.valueOf(ids[i]));
|
||||
// 3. 新增:赋值关联表的 item_id
|
||||
if (checkTaskItemIds.length > i && !checkTaskItemIds[i].isEmpty()) {
|
||||
item.setCheckTaskItemId(Long.valueOf(checkTaskItemIds[i])); // 假设 WmsCheckItemVo 有这个字段
|
||||
}
|
||||
// 4. 其他字段赋值(保持原逻辑,补充判空)
|
||||
if (names.length > i) item.setItemName(names[i]);
|
||||
if (statusArr.length > i) item.setStatus(statusArr[i]);
|
||||
// 处理数值类型时,先判空再转换,避免 NumberFormatException
|
||||
if (targetUppers.length > i && StringUtils.isNotBlank(targetUppers[i])) {
|
||||
item.setTargetUpper(new BigDecimal(targetUppers[i])); // 推荐用 new BigDecimal,避免 Double 精度问题
|
||||
}
|
||||
if (targetLowers.length > i && StringUtils.isNotBlank(targetLowers[i])) {
|
||||
item.setTargetLower(new BigDecimal(targetLowers[i]));
|
||||
}
|
||||
if (standardTargets.length > i && StringUtils.isNotBlank(standardTargets[i])) {
|
||||
item.setStandardTarget(new BigDecimal(standardTargets[i]));
|
||||
}
|
||||
if (units.length > i) item.setUnit(units[i]);
|
||||
if (qualitativeQuantitatives.length > i && StringUtils.isNotBlank(qualitativeQuantitatives[i])) {
|
||||
item.setQualitativeQuantitative(Integer.parseInt(qualitativeQuantitatives[i]));
|
||||
}
|
||||
itemList.add(item);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +92,7 @@ public class WmsCheckTaskServiceImpl implements IWmsCheckTaskService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询检查任务列表
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,16 @@
|
||||
GROUP BY t.task_id
|
||||
</select>
|
||||
<select id="selectVoByIdPlus" resultType="com.klp.mes.qc.domain.vo.WmsCheckTaskVo">
|
||||
SELECT t.*, GROUP_CONCAT(i.item_name) AS itemNames, GROUP_CONCAT(i.item_id) AS itemIds, GROUP_CONCAT(ti.status) AS itemStatus
|
||||
SELECT
|
||||
t.*,
|
||||
GROUP_CONCAT(ti.item_id) AS checkTaskItemIds,
|
||||
GROUP_CONCAT(i.item_name) AS itemNames,
|
||||
GROUP_CONCAT(i.item_id) AS itemIds,
|
||||
GROUP_CONCAT(ti.target_upper) AS targetUppers,
|
||||
GROUP_CONCAT(ti.target_lower) AS targetLowers,
|
||||
GROUP_CONCAT(ti.standard_target) AS standardTargets,
|
||||
GROUP_CONCAT(ti.unit) AS units,
|
||||
GROUP_CONCAT(ti.qualitative_quantitative) AS qualitativeQuantitatives
|
||||
FROM wms_check_task t
|
||||
LEFT JOIN wms_check_task_item ti ON t.task_id = ti.check_task_id AND ti.del_flag = 0
|
||||
LEFT JOIN wms_check_item i ON ti.check_item_id = i.item_id AND i.del_flag = 0
|
||||
|
||||
Reference in New Issue
Block a user