|
@@ -13,8 +13,10 @@ import com.zksy.base.constant.GasEquipmentTypeEnum;
|
|
|
import com.zksy.base.domain.*;
|
|
import com.zksy.base.domain.*;
|
|
|
import com.zksy.base.enums.AlarmStatusEnum;
|
|
import com.zksy.base.enums.AlarmStatusEnum;
|
|
|
import com.zksy.base.enums.CurrentStatusEnum;
|
|
import com.zksy.base.enums.CurrentStatusEnum;
|
|
|
|
|
+import com.zksy.base.enums.DistrictEnum;
|
|
|
import com.zksy.base.enums.EquipmentTypeEnum;
|
|
import com.zksy.base.enums.EquipmentTypeEnum;
|
|
|
import com.zksy.base.enums.OnlineStatusEnum;
|
|
import com.zksy.base.enums.OnlineStatusEnum;
|
|
|
|
|
+import com.zksy.base.domain.vo.EquipmentBaseVO;
|
|
|
import com.zksy.base.domain.vo.EquipmentFullVO;
|
|
import com.zksy.base.domain.vo.EquipmentFullVO;
|
|
|
import com.zksy.base.event.DeviceStatusChangePublisher;
|
|
import com.zksy.base.event.DeviceStatusChangePublisher;
|
|
|
import com.zksy.base.manhole.domain.ManholeData;
|
|
import com.zksy.base.manhole.domain.ManholeData;
|
|
@@ -83,9 +85,9 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
private WorkOrderMapper workOrderMapper;
|
|
private WorkOrderMapper workOrderMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Page<EquipmentBase> findByPage(long pageNum, long pageSize,
|
|
|
|
|
|
|
+ public Page<EquipmentBaseVO> findByPage(long pageNum, long pageSize,
|
|
|
String equipmentCode, String equipmentName,
|
|
String equipmentCode, String equipmentName,
|
|
|
- String equipmentTypeId, Integer rootTypeId,
|
|
|
|
|
|
|
+ Integer equipmentTypeId, Integer rootTypeId,
|
|
|
Integer onlineStatus, Integer alarmStatus) {
|
|
Integer onlineStatus, Integer alarmStatus) {
|
|
|
Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
|
|
Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
|
|
|
LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -95,7 +97,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
if (equipmentName != null && !equipmentName.isEmpty()) {
|
|
if (equipmentName != null && !equipmentName.isEmpty()) {
|
|
|
queryWrapper.like(EquipmentBase::getEquipmentName, equipmentName);
|
|
queryWrapper.like(EquipmentBase::getEquipmentName, equipmentName);
|
|
|
}
|
|
}
|
|
|
- if (equipmentTypeId != null && !equipmentTypeId.isEmpty()) {
|
|
|
|
|
|
|
+ if (equipmentTypeId != null) {
|
|
|
queryWrapper.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId);
|
|
queryWrapper.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId);
|
|
|
}
|
|
}
|
|
|
// 在线/报警条件位于 equipment_status,先取出命中的设备ID再回主表过滤
|
|
// 在线/报警条件位于 equipment_status,先取出命中的设备ID再回主表过滤
|
|
@@ -113,23 +115,76 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
if (matchedIds.isEmpty()) {
|
|
if (matchedIds.isEmpty()) {
|
|
|
- page.setRecords(Collections.emptyList());
|
|
|
|
|
- page.setTotal(0);
|
|
|
|
|
- return page;
|
|
|
|
|
|
|
+ return new Page<>(pageNum, pageSize, 0);
|
|
|
}
|
|
}
|
|
|
queryWrapper.in(EquipmentBase::getEquipmentId, matchedIds);
|
|
queryWrapper.in(EquipmentBase::getEquipmentId, matchedIds);
|
|
|
}
|
|
}
|
|
|
Set<String> allowedTypeIds = resolveChildTypeIds(rootTypeId);
|
|
Set<String> allowedTypeIds = resolveChildTypeIds(rootTypeId);
|
|
|
if (allowedTypeIds != null) {
|
|
if (allowedTypeIds != null) {
|
|
|
if (allowedTypeIds.isEmpty()) {
|
|
if (allowedTypeIds.isEmpty()) {
|
|
|
- page.setRecords(Collections.emptyList());
|
|
|
|
|
- page.setTotal(0);
|
|
|
|
|
- return page;
|
|
|
|
|
|
|
+ return new Page<>(pageNum, pageSize, 0);
|
|
|
}
|
|
}
|
|
|
queryWrapper.in(EquipmentBase::getEquipmentTypeId, allowedTypeIds);
|
|
queryWrapper.in(EquipmentBase::getEquipmentTypeId, allowedTypeIds);
|
|
|
}
|
|
}
|
|
|
queryWrapper.orderByDesc(EquipmentBase::getCreateTime);
|
|
queryWrapper.orderByDesc(EquipmentBase::getCreateTime);
|
|
|
- return this.page(page, queryWrapper);
|
|
|
|
|
|
|
+ Page<EquipmentBase> basePage = this.page(page, queryWrapper);
|
|
|
|
|
+ List<String> equipmentIds = basePage.getRecords().stream().map(EquipmentBase::getEquipmentId)
|
|
|
|
|
+ .filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
+ Map<String, EquipmentStatus> statusMap = equipmentIds.isEmpty() ? Collections.emptyMap() :
|
|
|
|
|
+ equipmentStatusMapper.selectList(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
|
|
+ .in(EquipmentStatus::getEquipmentId, equipmentIds)).stream()
|
|
|
|
|
+ .collect(Collectors.toMap(EquipmentStatus::getEquipmentId, Function.identity(), (a, b) -> a));
|
|
|
|
|
+ Set<Integer> typeIds = basePage.getRecords().stream().map(EquipmentBase::getEquipmentTypeId)
|
|
|
|
|
+ .filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
|
|
+ Map<Integer, EquipmentType> typeMap = typeIds.isEmpty() ? Collections.emptyMap() :
|
|
|
|
|
+ equipmentTypeMapper.selectBatchIds(typeIds).stream()
|
|
|
|
|
+ .collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (a, b) -> a));
|
|
|
|
|
+ List<EquipmentBaseVO> records = new ArrayList<>();
|
|
|
|
|
+ for (EquipmentBase equipment : basePage.getRecords()) {
|
|
|
|
|
+ EquipmentBaseVO vo = new EquipmentBaseVO();
|
|
|
|
|
+ BeanUtil.copyProperties(equipment, vo);
|
|
|
|
|
+ EquipmentType type = typeMap.get(equipment.getEquipmentTypeId());
|
|
|
|
|
+ vo.setEquipmentTypeName(type == null ? equipment.getEquipmentTypeName() : type.getTypeName());
|
|
|
|
|
+ EquipmentStatus status = statusMap.get(equipment.getEquipmentId());
|
|
|
|
|
+ if (status != null) {
|
|
|
|
|
+ vo.setCurrentStatus(status.getCurrentStatus());
|
|
|
|
|
+ vo.setAlarmStatus(status.getAlarmStatus());
|
|
|
|
|
+ vo.setOnlineStatus(status.getOnlineStatus());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ vo.setCurrentStatus(0);
|
|
|
|
|
+ vo.setAlarmStatus(0);
|
|
|
|
|
+ vo.setOnlineStatus(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ records.add(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<EquipmentBaseVO> result = new Page<>(pageNum, pageSize, basePage.getTotal());
|
|
|
|
|
+ result.setRecords(records);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, Object> getEquipmentStatusStatistics(Integer rootTypeId) {
|
|
|
|
|
+ Set<String> allowedTypeIds = resolveChildTypeIds(rootTypeId);
|
|
|
|
|
+ LambdaQueryWrapper<EquipmentBase> baseWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ if (allowedTypeIds != null) {
|
|
|
|
|
+ baseWrapper.in(EquipmentBase::getEquipmentTypeId,
|
|
|
|
|
+ allowedTypeIds.isEmpty() ? Collections.singleton("") : allowedTypeIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> equipmentIds = this.list(baseWrapper).stream().map(EquipmentBase::getEquipmentId)
|
|
|
|
|
+ .filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
|
|
+ result.put("total", equipmentIds.size());
|
|
|
|
|
+ if (equipmentIds.isEmpty()) {
|
|
|
|
|
+ result.put("online", 0L); result.put("offline", 0L); result.put("alarm", 0L);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.put("online", equipmentStatusMapper.selectCount(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
|
|
+ .in(EquipmentStatus::getEquipmentId, equipmentIds).eq(EquipmentStatus::getOnlineStatus, 1)));
|
|
|
|
|
+ result.put("offline", equipmentStatusMapper.selectCount(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
|
|
+ .in(EquipmentStatus::getEquipmentId, equipmentIds).eq(EquipmentStatus::getOnlineStatus, 0)));
|
|
|
|
|
+ result.put("alarm", equipmentStatusMapper.selectCount(new LambdaQueryWrapper<EquipmentStatus>()
|
|
|
|
|
+ .in(EquipmentStatus::getEquipmentId, equipmentIds).eq(EquipmentStatus::getAlarmStatus, 1)));
|
|
|
|
|
+ return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -154,7 +209,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public boolean saveWithCheck(EquipmentBase entity) {
|
|
public boolean saveWithCheck(EquipmentBase entity) {
|
|
|
- String equipmentTypeId = entity.getEquipmentTypeId();
|
|
|
|
|
|
|
+ Integer equipmentTypeId = entity.getEquipmentTypeId();
|
|
|
EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
|
|
EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
|
|
|
if (equipmentType == null) {
|
|
if (equipmentType == null) {
|
|
|
throw new ServiceException("设备类型不存在,请检查equipment_type_id:" + equipmentTypeId);
|
|
throw new ServiceException("设备类型不存在,请检查equipment_type_id:" + equipmentTypeId);
|
|
@@ -231,6 +286,14 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
throw new ServiceException("设备不存在,无法修改:" + equipmentId);
|
|
throw new ServiceException("设备不存在,无法修改:" + equipmentId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 编辑时所属片区必填,且必须是 DistrictEnum 合法编码(0-城南 1-城北 2-太常)
|
|
|
|
|
+ if (entity.getDistrict() == null) {
|
|
|
|
|
+ throw new ServiceException("所属片区不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!DistrictEnum.isValid(entity.getDistrict())) {
|
|
|
|
|
+ throw new ServiceException("所属片区取值非法:" + entity.getDistrict());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*String newTypeId = entity.getEquipmentTypeId();
|
|
/*String newTypeId = entity.getEquipmentTypeId();
|
|
|
if (newTypeId != null && getEquipmentTypeById(newTypeId) == null) {
|
|
if (newTypeId != null && getEquipmentTypeById(newTypeId) == null) {
|
|
|
throw new ServiceException("设备类型不存在:" + newTypeId);
|
|
throw new ServiceException("设备类型不存在:" + newTypeId);
|
|
@@ -353,14 +416,14 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(rs.getRecords(), EquipmentBaseOutDTO.class);
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(rs.getRecords(), EquipmentBaseOutDTO.class);
|
|
|
if (CollUtil.isNotEmpty(outDTOList)) {
|
|
if (CollUtil.isNotEmpty(outDTOList)) {
|
|
|
//查询设备类型
|
|
//查询设备类型
|
|
|
- List<String> equipmentTypeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Integer> equipmentTypeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
LambdaQueryWrapper<EquipmentType> batchQw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EquipmentType> batchQw = new LambdaQueryWrapper<>();
|
|
|
batchQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
batchQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchQw);
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchQw);
|
|
|
- Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(equipmentTypeList)){
|
|
if(CollUtil.isNotEmpty(equipmentTypeList)){
|
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
|
- Collectors.toMap(t -> String.valueOf(t.getId()), Function.identity(), (key1, key2) -> key2)));
|
|
|
|
|
|
|
+ Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
}
|
|
|
//查询设备状态
|
|
//查询设备状态
|
|
|
List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
|
|
List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
|
|
@@ -413,22 +476,22 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
@Override
|
|
@Override
|
|
|
public Map<String, Object> getManholeDeviceStatistics(ManholeDeviceStatisticsInDTO inDTO) {
|
|
public Map<String, Object> getManholeDeviceStatistics(ManholeDeviceStatisticsInDTO inDTO) {
|
|
|
// 窨井设备:排水窨井(equipment_type_id=9)/供水窨井(equipment_type_id=10),筛选时仅统计所选类别
|
|
// 窨井设备:排水窨井(equipment_type_id=9)/供水窨井(equipment_type_id=10),筛选时仅统计所选类别
|
|
|
- List<String> manholeTypeIds = StringUtils.isNotEmpty(inDTO.getEquipmentTypeId())
|
|
|
|
|
- ? Collections.singletonList(inDTO.getEquipmentTypeId()) : Arrays.asList("5", "9", "10");
|
|
|
|
|
|
|
+ List<Integer> manholeTypeIds = inDTO.getEquipmentTypeId() != null
|
|
|
|
|
+ ? Collections.singletonList(inDTO.getEquipmentTypeId()) : Arrays.asList(5, 9, 10);
|
|
|
List<EquipmentBase> devices = this.list(new LambdaQueryWrapper<EquipmentBase>()
|
|
List<EquipmentBase> devices = this.list(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
.in(EquipmentBase::getEquipmentTypeId, manholeTypeIds)
|
|
.in(EquipmentBase::getEquipmentTypeId, manholeTypeIds)
|
|
|
- .eq(StringUtils.isNotEmpty(inDTO.getDistrict()), EquipmentBase::getDistrict, inDTO.getDistrict()));
|
|
|
|
|
|
|
+ .eq(inDTO.getDistrict() != null, EquipmentBase::getDistrict, inDTO.getDistrict()));
|
|
|
int total = devices.size();
|
|
int total = devices.size();
|
|
|
|
|
|
|
|
- // 区域分布:按所属片区(district)分组统计
|
|
|
|
|
- Map<String, Long> regionCountMap = devices.stream()
|
|
|
|
|
- .filter(d -> StringUtils.isNotBlank(d.getDistrict()))
|
|
|
|
|
|
|
+ // 区域分布:按所属片区(district)分组统计,展示用 DistrictEnum 名称
|
|
|
|
|
+ Map<Integer, Long> regionCountMap = devices.stream()
|
|
|
|
|
+ .filter(d -> d.getDistrict() != null)
|
|
|
.collect(Collectors.groupingBy(EquipmentBase::getDistrict, Collectors.counting()));
|
|
.collect(Collectors.groupingBy(EquipmentBase::getDistrict, Collectors.counting()));
|
|
|
List<Map<String, Object>> regionDistribution = regionCountMap.entrySet().stream()
|
|
List<Map<String, Object>> regionDistribution = regionCountMap.entrySet().stream()
|
|
|
.sorted((a, b) -> Long.compare(b.getValue(), a.getValue()))
|
|
.sorted((a, b) -> Long.compare(b.getValue(), a.getValue()))
|
|
|
.map(e -> {
|
|
.map(e -> {
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
- item.put("name", e.getKey());
|
|
|
|
|
|
|
+ item.put("name", DistrictEnum.getDescByCode(e.getKey()));
|
|
|
item.put("count", e.getValue());
|
|
item.put("count", e.getValue());
|
|
|
item.put("percent", calcPercent(e.getValue(), total));
|
|
item.put("percent", calcPercent(e.getValue(), total));
|
|
|
return item;
|
|
return item;
|
|
@@ -436,17 +499,17 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 类型分布:按设备类型分组统计(9=排水窨井设备,10=供水窨井设备)
|
|
// 类型分布:按设备类型分组统计(9=排水窨井设备,10=供水窨井设备)
|
|
|
- Map<String, String> typeNameMap = new HashMap<>();
|
|
|
|
|
- typeNameMap.put("9", "排水窨井设备");
|
|
|
|
|
- typeNameMap.put("10", "供水窨井设备");
|
|
|
|
|
- Map<String, Long> typeCountMap = devices.stream()
|
|
|
|
|
- .filter(d -> StringUtils.isNotBlank(d.getEquipmentTypeId()))
|
|
|
|
|
|
|
+ Map<Integer, String> typeNameMap = new HashMap<>();
|
|
|
|
|
+ typeNameMap.put(9, "排水窨井设备");
|
|
|
|
|
+ typeNameMap.put(10, "供水窨井设备");
|
|
|
|
|
+ Map<Integer, Long> typeCountMap = devices.stream()
|
|
|
|
|
+ .filter(d -> d.getEquipmentTypeId() != null)
|
|
|
.collect(Collectors.groupingBy(EquipmentBase::getEquipmentTypeId, Collectors.counting()));
|
|
.collect(Collectors.groupingBy(EquipmentBase::getEquipmentTypeId, Collectors.counting()));
|
|
|
List<Map<String, Object>> typeDistribution = typeCountMap.entrySet().stream()
|
|
List<Map<String, Object>> typeDistribution = typeCountMap.entrySet().stream()
|
|
|
.sorted((a, b) -> Long.compare(b.getValue(), a.getValue()))
|
|
.sorted((a, b) -> Long.compare(b.getValue(), a.getValue()))
|
|
|
.map(e -> {
|
|
.map(e -> {
|
|
|
Map<String, Object> item = new HashMap<>();
|
|
Map<String, Object> item = new HashMap<>();
|
|
|
- item.put("name", typeNameMap.getOrDefault(e.getKey(), e.getKey()));
|
|
|
|
|
|
|
+ item.put("name", typeNameMap.getOrDefault(e.getKey(), String.valueOf(e.getKey())));
|
|
|
item.put("count", e.getValue());
|
|
item.put("count", e.getValue());
|
|
|
item.put("percent", calcPercent(e.getValue(), total));
|
|
item.put("percent", calcPercent(e.getValue(), total));
|
|
|
return item;
|
|
return item;
|
|
@@ -522,14 +585,14 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(rs.getRecords(), EquipmentBaseOutDTO.class);
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(rs.getRecords(), EquipmentBaseOutDTO.class);
|
|
|
if (CollUtil.isNotEmpty(outDTOList)) {
|
|
if (CollUtil.isNotEmpty(outDTOList)) {
|
|
|
//查询设备类型
|
|
//查询设备类型
|
|
|
- List<String> equipmentTypeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Integer> equipmentTypeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
LambdaQueryWrapper<EquipmentType> batchQw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EquipmentType> batchQw = new LambdaQueryWrapper<>();
|
|
|
batchQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
batchQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchQw);
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchQw);
|
|
|
- Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(equipmentTypeList)){
|
|
if(CollUtil.isNotEmpty(equipmentTypeList)){
|
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
|
- Collectors.toMap(t -> String.valueOf(t.getId()), Function.identity(), (key1, key2) -> key2)));
|
|
|
|
|
|
|
+ Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
}
|
|
|
//查询设备状态
|
|
//查询设备状态
|
|
|
List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
|
|
List<String> equipmentIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentId).distinct().collect(Collectors.toList());
|
|
@@ -684,12 +747,12 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(equipmentList, EquipmentBaseOutDTO.class);
|
|
List<EquipmentBaseOutDTO> outDTOList = BeanUtil.copyToList(equipmentList, EquipmentBaseOutDTO.class);
|
|
|
|
|
|
|
|
// 批量查询设备类型名称
|
|
// 批量查询设备类型名称
|
|
|
- List<String> typeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Integer> typeIdList = outDTOList.stream().map(EquipmentBaseOutDTO::getEquipmentTypeId).distinct().collect(Collectors.toList());
|
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(new LambdaQueryWrapper<EquipmentType>()
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(new LambdaQueryWrapper<EquipmentType>()
|
|
|
.in(EquipmentType::getId, typeIdList));
|
|
.in(EquipmentType::getId, typeIdList));
|
|
|
- Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(equipmentTypeList)) {
|
|
if (CollUtil.isNotEmpty(equipmentTypeList)) {
|
|
|
- equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(t -> String.valueOf(t.getId()), Function.identity(), (k1, k2) -> k2)));
|
|
|
|
|
|
|
+ equipmentTypeMap.putAll(equipmentTypeList.stream().collect(Collectors.toMap(EquipmentType::getId, Function.identity(), (k1, k2) -> k2)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 批量查询设备运维状态
|
|
// 批量查询设备运维状态
|
|
@@ -981,18 +1044,18 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 批量查设备类型(用于解析类型名称)
|
|
// 批量查设备类型(用于解析类型名称)
|
|
|
- List<String> equipmentTypeIdList = equipmentList.stream()
|
|
|
|
|
|
|
+ List<Integer> equipmentTypeIdList = equipmentList.stream()
|
|
|
.map(EquipmentBase::getEquipmentTypeId)
|
|
.map(EquipmentBase::getEquipmentTypeId)
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.distinct().collect(Collectors.toList());
|
|
.distinct().collect(Collectors.toList());
|
|
|
- Map<String, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, EquipmentType> equipmentTypeMap = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(equipmentTypeIdList)) {
|
|
if (CollUtil.isNotEmpty(equipmentTypeIdList)) {
|
|
|
LambdaQueryWrapper<EquipmentType> batchTypeQw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<EquipmentType> batchTypeQw = new LambdaQueryWrapper<>();
|
|
|
batchTypeQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
batchTypeQw.in(EquipmentType::getId, equipmentTypeIdList);
|
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchTypeQw);
|
|
List<EquipmentType> equipmentTypeList = equipmentTypeMapper.selectList(batchTypeQw);
|
|
|
if (CollUtil.isNotEmpty(equipmentTypeList)) {
|
|
if (CollUtil.isNotEmpty(equipmentTypeList)) {
|
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
equipmentTypeMap.putAll(equipmentTypeList.stream().collect(
|
|
|
- Collectors.toMap(t -> String.valueOf(t.getId()), Function.identity(), (key1, key2) -> key2)));
|
|
|
|
|
|
|
+ Collectors.toMap(EquipmentType::getId, Function.identity(), (key1, key2) -> key2)));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1105,7 +1168,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 无子类别:直接统计该类别的设备数量
|
|
// 无子类别:直接统计该类别的设备数量
|
|
|
- EquipmentType equipmentType = getEquipmentTypeById(equipmentTypeId);
|
|
|
|
|
|
|
+ EquipmentType equipmentType = getEquipmentTypeById(Integer.valueOf(equipmentTypeId));
|
|
|
long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
|
|
.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
|
|
|
EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
@@ -1135,16 +1198,16 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
// 一次性查询所有设备类别
|
|
// 一次性查询所有设备类别
|
|
|
- List<String> typeIds = equipmentList.stream()
|
|
|
|
|
|
|
+ List<Integer> typeIds = equipmentList.stream()
|
|
|
.map(EquipmentBase::getEquipmentTypeId)
|
|
.map(EquipmentBase::getEquipmentTypeId)
|
|
|
- .filter(StringUtils::isNotEmpty)
|
|
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
.distinct()
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
- Map<String, String> typeNameMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, String> typeNameMap = new HashMap<>();
|
|
|
if(CollUtil.isNotEmpty(typeIds)){
|
|
if(CollUtil.isNotEmpty(typeIds)){
|
|
|
List<EquipmentType> typeList = equipmentTypeMapper.selectBatchIds(typeIds);
|
|
List<EquipmentType> typeList = equipmentTypeMapper.selectBatchIds(typeIds);
|
|
|
typeNameMap = typeList.stream()
|
|
typeNameMap = typeList.stream()
|
|
|
- .collect(Collectors.toMap(t -> String.valueOf(t.getId()), EquipmentType::getTypeName, (k1, k2) -> k1));
|
|
|
|
|
|
|
+ .collect(Collectors.toMap(EquipmentType::getId, EquipmentType::getTypeName, (k1, k2) -> k1));
|
|
|
}
|
|
}
|
|
|
// 一次性查询所有设备状态
|
|
// 一次性查询所有设备状态
|
|
|
List<String> equipmentIds = equipmentList.stream()
|
|
List<String> equipmentIds = equipmentList.stream()
|
|
@@ -1194,8 +1257,8 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
* @param id equipment_type 主键
|
|
* @param id equipment_type 主键
|
|
|
* @return 设备类型,未找到返回 null
|
|
* @return 设备类型,未找到返回 null
|
|
|
*/
|
|
*/
|
|
|
- private EquipmentType getEquipmentTypeById(String id) {
|
|
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
|
|
|
+ private EquipmentType getEquipmentTypeById(Integer id) {
|
|
|
|
|
+ if (id == null) {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
return equipmentTypeMapper.selectById(id);
|
|
return equipmentTypeMapper.selectById(id);
|
|
@@ -1243,7 +1306,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 排水模块的顶级名称在历史数据中可能不是“排水”,按稳定 type_id 兼容查询。
|
|
|
|
|
|
|
+ // 排水模块的顶级名称在历史数据中可能不是"排水",按稳定 type_id 兼容查询。
|
|
|
if (typeIds.isEmpty() && StringUtils.isNotEmpty(typeName) && typeName.contains("排水")) {
|
|
if (typeIds.isEmpty() && StringUtils.isNotEmpty(typeName) && typeName.contains("排水")) {
|
|
|
List<EquipmentType> drainageTypes = equipmentTypeMapper.selectList(
|
|
List<EquipmentType> drainageTypes = equipmentTypeMapper.selectList(
|
|
|
new LambdaQueryWrapper<EquipmentType>()
|
|
new LambdaQueryWrapper<EquipmentType>()
|
|
@@ -1282,18 +1345,18 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
List<EquipmentBase> equipmentList = this.list(wrapper);
|
|
List<EquipmentBase> equipmentList = this.list(wrapper);
|
|
|
|
|
|
|
|
// 回填设备类型名称,供阈值配置、设备台账等页面直接展示。
|
|
// 回填设备类型名称,供阈值配置、设备台账等页面直接展示。
|
|
|
- Map<String, String> typeNameMap = new HashMap<>();
|
|
|
|
|
|
|
+ Map<Integer, String> typeNameMap = new HashMap<>();
|
|
|
List<EquipmentType> equipmentTypes = equipmentTypeMapper.selectList(
|
|
List<EquipmentType> equipmentTypes = equipmentTypeMapper.selectList(
|
|
|
new LambdaQueryWrapper<EquipmentType>().in(EquipmentType::getId, new ArrayList<>(typeIds)));
|
|
new LambdaQueryWrapper<EquipmentType>().in(EquipmentType::getId, new ArrayList<>(typeIds)));
|
|
|
for (EquipmentType type : equipmentTypes) {
|
|
for (EquipmentType type : equipmentTypes) {
|
|
|
if (type != null && type.getId() != null) {
|
|
if (type != null && type.getId() != null) {
|
|
|
- typeNameMap.put(String.valueOf(type.getId()), type.getTypeName());
|
|
|
|
|
|
|
+ typeNameMap.put(type.getId(), type.getTypeName());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
equipmentList.forEach(equipment -> {
|
|
equipmentList.forEach(equipment -> {
|
|
|
String resolvedTypeName = typeNameMap.get(equipment.getEquipmentTypeId());
|
|
String resolvedTypeName = typeNameMap.get(equipment.getEquipmentTypeId());
|
|
|
equipment.setEquipmentTypeName(StringUtils.isNotEmpty(resolvedTypeName)
|
|
equipment.setEquipmentTypeName(StringUtils.isNotEmpty(resolvedTypeName)
|
|
|
- ? resolvedTypeName : equipment.getEquipmentTypeId());
|
|
|
|
|
|
|
+ ? resolvedTypeName : String.valueOf(equipment.getEquipmentTypeId()));
|
|
|
});
|
|
});
|
|
|
return equipmentList;
|
|
return equipmentList;
|
|
|
}
|
|
}
|