|
|
@@ -23,8 +23,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -67,34 +69,39 @@ public class CaseInfoServiceImpl extends ServiceImpl<CaseInfoMapper, CaseInfo>
|
|
|
Page<CaseInfo> page = new Page<>(pageInDTO.getPageNum(), pageInDTO.getPageSize());
|
|
|
LambdaQueryWrapper<CaseInfo> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.like(StringUtils.isNotEmpty(pageInDTO.getCaseNo()), CaseInfo::getCaseNo, pageInDTO.getCaseNo())
|
|
|
- .in(CollUtil.isNotEmpty(equipmentIds), CaseInfo::getDeviceId, equipmentIds)
|
|
|
+ .in(CollUtil.isNotEmpty(equipmentIds), CaseInfo::getEquipmentId, equipmentIds)
|
|
|
.orderByDesc(CaseInfo::getUpdateTime);
|
|
|
Page<CaseInfo> rs = this.page(page, queryWrapper);
|
|
|
List<CaseInfoOutDTO> outDTOList = BeanUtil.copyToList(rs.getRecords(), CaseInfoOutDTO.class);
|
|
|
if (CollUtil.isNotEmpty(outDTOList)) {
|
|
|
//查询设备状态
|
|
|
- List<String> equipmentIdList = outDTOList.stream().map(CaseInfoOutDTO::getDeviceId).distinct().collect(Collectors.toList());
|
|
|
- List<EquipmentStatus> equipmentStatusList = equipmentStatusMapper.selectList(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
+ List<String> equipmentIdList = outDTOList.stream().map(CaseInfoOutDTO::getEquipmentId)
|
|
|
+ .filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
|
|
|
+ List<EquipmentStatus> equipmentStatusList = equipmentIdList.isEmpty() ? Collections.emptyList()
|
|
|
+ : equipmentStatusMapper.selectList(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
.in(EquipmentStatus::getEquipmentId, equipmentIdList));
|
|
|
Map<String, EquipmentStatus> equipmentStatusMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(equipmentStatusList)){
|
|
|
equipmentStatusMap.putAll(equipmentStatusList.stream().collect(Collectors.toMap(EquipmentStatus::getEquipmentId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
|
//查询设备类型
|
|
|
- List<EquipmentBase> equipmentBaseList = equipmentBaseMapper.selectBatchIds(equipmentIdList);
|
|
|
+ List<EquipmentBase> equipmentBaseList = equipmentIdList.isEmpty() ? Collections.emptyList()
|
|
|
+ : equipmentBaseMapper.selectBatchIds(equipmentIdList);
|
|
|
Map<String, EquipmentBase> equipmentBaseMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(equipmentBaseList)){
|
|
|
equipmentBaseMap.putAll(equipmentBaseList.stream().collect(Collectors.toMap(EquipmentBase::getEquipmentId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
|
- List<Integer> equipmentTypeIdList = equipmentBaseList.stream().map(EquipmentBase::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
- List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectBatchIds(equipmentTypeIdList);
|
|
|
+ List<Integer> equipmentTypeIdList = equipmentBaseList.stream().map(EquipmentBase::getEquipmentTypeId)
|
|
|
+ .filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ List<EquipmentType> equipmentTypeList = equipmentTypeIdList.isEmpty() ? Collections.emptyList()
|
|
|
+ : equipmentTypeMapper.selectBatchIds(equipmentTypeIdList);
|
|
|
Map<Integer, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(equipmentTypeList)){
|
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
|
Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
|
for(CaseInfoOutDTO outDTO : outDTOList) {
|
|
|
- EquipmentBase equipmentBase = equipmentBaseMap.get(outDTO.getDeviceId());
|
|
|
+ EquipmentBase equipmentBase = equipmentBaseMap.get(outDTO.getEquipmentId());
|
|
|
if(equipmentBase != null){
|
|
|
outDTO.setDeviceCode(equipmentBase.getEquipmentCode());
|
|
|
EquipmentType equipmentType = equipmentTypeMap.get(equipmentBase.getEquipmentTypeId());
|
|
|
@@ -102,7 +109,7 @@ public class CaseInfoServiceImpl extends ServiceImpl<CaseInfoMapper, CaseInfo>
|
|
|
outDTO.setEquipmentTypeName(equipmentType.getTypeName());
|
|
|
}
|
|
|
}
|
|
|
- EquipmentStatus equipmentStatus = equipmentStatusMap.get(outDTO.getDeviceId());
|
|
|
+ EquipmentStatus equipmentStatus = equipmentStatusMap.get(outDTO.getEquipmentId());
|
|
|
if(equipmentStatus != null){
|
|
|
EquipmentStatusOutDTO equipmentStatusOutDTO = BeanUtil.copyProperties(equipmentStatus, EquipmentStatusOutDTO.class);
|
|
|
outDTO.setEquipmentStatus(equipmentStatusOutDTO);
|