Compare commits

...

2 Commits

Author SHA1 Message Date
30f9b533b2 Merge remote-tracking branch 'origin/0.8.X' into 0.8.X 2026-05-22 15:30:18 +08:00
b7016b3591 feat(eqp): 添加设备检验清单部位名称填充功能
- 在EqpEquipmentChecklistBo中新增partIds字段用于批量查询
- 实现检验清单查询时自动填充检验部位名称的功能
- 重构设备部件服务中的检验清单列表获取逻辑
- 优化设备部件页面数据加载性能通过批量查询方式
- 移除手动设置部位名称的冗余代码实现自动关联
2026-05-22 15:30:01 +08:00
3 changed files with 36 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import com.klp.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
import java.util.List;
/**
@@ -62,5 +63,7 @@ public class EqpEquipmentChecklistBo extends BaseEntity {
*/
private String remark;
private List<Long> partIds;
}

View File

@@ -12,7 +12,9 @@ import org.springframework.stereotype.Service;
import com.klp.mes.eqp.domain.bo.EqpEquipmentChecklistBo;
import com.klp.mes.eqp.domain.vo.EqpEquipmentChecklistVo;
import com.klp.mes.eqp.domain.EqpEquipmentChecklist;
import com.klp.mes.eqp.domain.EqpEquipmentPart;
import com.klp.mes.eqp.mapper.EqpEquipmentChecklistMapper;
import com.klp.mes.eqp.mapper.EqpEquipmentPartMapper;
import com.klp.mes.eqp.service.IEqpEquipmentChecklistService;
import java.util.List;
@@ -30,6 +32,7 @@ import java.util.Collection;
public class EqpEquipmentChecklistServiceImpl implements IEqpEquipmentChecklistService {
private final EqpEquipmentChecklistMapper baseMapper;
private final EqpEquipmentPartMapper eqpEquipmentPartMapper;
/**
* 查询设备检验清单
@@ -46,6 +49,7 @@ public class EqpEquipmentChecklistServiceImpl implements IEqpEquipmentChecklistS
public TableDataInfo<EqpEquipmentChecklistVo> queryPageList(EqpEquipmentChecklistBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<EqpEquipmentChecklist> lqw = buildQueryWrapper(bo);
Page<EqpEquipmentChecklistVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
fillPartName(result.getRecords());
return TableDataInfo.build(result);
}
@@ -55,7 +59,26 @@ public class EqpEquipmentChecklistServiceImpl implements IEqpEquipmentChecklistS
@Override
public List<EqpEquipmentChecklistVo> queryList(EqpEquipmentChecklistBo bo) {
LambdaQueryWrapper<EqpEquipmentChecklist> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
List<EqpEquipmentChecklistVo> list = baseMapper.selectVoList(lqw);
fillPartName(list);
return list;
}
/**
* 填充检验清单的检验部位名称
*/
private void fillPartName(List<EqpEquipmentChecklistVo> list) {
if (list == null || list.isEmpty()) {
return;
}
list.forEach(vo -> {
if (vo.getPartId() != null) {
EqpEquipmentPart part = eqpEquipmentPartMapper.selectById(vo.getPartId());
if (part != null) {
vo.setPartName(part.getInspectPart());
}
}
});
}
private LambdaQueryWrapper<EqpEquipmentChecklist> buildQueryWrapper(EqpEquipmentChecklistBo bo) {

View File

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.klp.common.utils.StringUtils;
import com.klp.mes.eqp.domain.bo.EqpEquipmentChecklistBo;
import com.klp.mes.eqp.service.IEqpEquipmentChecklistService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.klp.mes.eqp.domain.bo.EqpEquipmentPartBo;
@@ -21,6 +22,7 @@ import com.klp.mes.eqp.service.IEqpEquipmentPartService;
import java.util.*;
import java.util.stream.Collectors;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -34,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
public class EqpEquipmentPartServiceImpl implements IEqpEquipmentPartService {
private final EqpEquipmentPartMapper baseMapper;
private final IEqpEquipmentChecklistService checklistService;
private final EqpEquipmentChecklistMapper checklistMapper;
/**
@@ -54,16 +57,14 @@ public class EqpEquipmentPartServiceImpl implements IEqpEquipmentPartService {
List<Long> partIds = result.getRecords().stream()
.map(EqpEquipmentPartVo::getPartId).collect(Collectors.toList());
if (!partIds.isEmpty()) {
LambdaQueryWrapper<EqpEquipmentChecklist> checklistLqw = Wrappers.lambdaQuery();
checklistLqw.in(EqpEquipmentChecklist::getPartId, partIds);
List<EqpEquipmentChecklistVo> checklistList = checklistMapper.selectVoList(checklistLqw);
EqpEquipmentChecklistBo eqpEquipmentChecklistBo = new EqpEquipmentChecklistBo();
eqpEquipmentChecklistBo.setPartIds(partIds);
List<EqpEquipmentChecklistVo> checklistList = checklistService.queryList(eqpEquipmentChecklistBo);
Map<Long, List<EqpEquipmentChecklistVo>> checklistMap = checklistList.stream()
.collect(Collectors.groupingBy(EqpEquipmentChecklistVo::getPartId));
result.getRecords().forEach(vo -> {
List<EqpEquipmentChecklistVo> items = checklistMap.getOrDefault(vo.getPartId(), Collections.emptyList());
items.forEach(checklist -> checklist.setPartName(vo.getInspectPart()));
vo.setChecklistList(items);
});
result.getRecords().forEach(vo ->
vo.setChecklistList(checklistMap.getOrDefault(vo.getPartId(), Collections.emptyList()))
);
}
return TableDataInfo.build(result);
}