|
|
|
|
@@ -1,10 +1,15 @@
|
|
|
|
|
package com.njcn.device.pq.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
|
|
|
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
|
|
|
|
import com.njcn.device.pq.mapper.TerminalMaintainMapper;
|
|
|
|
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
|
|
|
import com.njcn.device.pq.pojo.dto.InfluxBaseDTO;
|
|
|
|
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
|
|
|
|
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
|
|
|
|
|
import com.njcn.device.pq.pojo.param.TerminalParam;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.DevMeal;
|
|
|
|
|
@@ -15,12 +20,16 @@ import com.njcn.device.pq.service.IDevMealService;
|
|
|
|
|
import com.njcn.device.pq.service.IDevStrategyService;
|
|
|
|
|
import com.njcn.device.pq.service.IDeviceService;
|
|
|
|
|
import com.njcn.device.pq.service.TerminalMaintainService;
|
|
|
|
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
|
|
|
|
import com.njcn.user.api.DeptFeignClient;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -42,36 +51,72 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|
|
|
|
|
|
|
|
|
private final IDevStrategyService iDevStrategyService;
|
|
|
|
|
|
|
|
|
|
private final GeneralDeviceService generalDeviceService;
|
|
|
|
|
|
|
|
|
|
private final DeptFeignClient deptFeignClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TerminalMaintainVO> getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) {
|
|
|
|
|
List<TerminalMaintainVO> devList = terminalMaintainMapper.getTerminalDevInfo();
|
|
|
|
|
if(CollectionUtil.isEmpty(devList)){
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_EMPTY);
|
|
|
|
|
}
|
|
|
|
|
List<String> subIndexes = devList.stream().map(TerminalMaintainVO::getPid).collect(Collectors.toList());
|
|
|
|
|
List<TerminalMaintainVO> subList = terminalMaintainMapper.getPqLineGdAndSubList(subIndexes);
|
|
|
|
|
if(CollectionUtil.isEmpty(subList)){
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.SUB_NO);
|
|
|
|
|
}
|
|
|
|
|
List<String> gdIds = subList.stream().map(TerminalMaintainVO::getPid).collect(Collectors.toList());
|
|
|
|
|
List<TerminalMaintainVO> gdList = terminalMaintainMapper.getPqLineGdAndSubList(gdIds);
|
|
|
|
|
if(CollectionUtil.isEmpty(gdList)){
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.GD_NO);
|
|
|
|
|
}
|
|
|
|
|
List<String> proIds = gdList.stream().map(TerminalMaintainVO::getPid).collect(Collectors.toList());
|
|
|
|
|
List<TerminalMaintainVO> proList = terminalMaintainMapper.getPqLineProvList(proIds);
|
|
|
|
|
if(CollectionUtil.isEmpty(proList)){
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.PROVINCE_EMPTY);
|
|
|
|
|
}
|
|
|
|
|
SimpleDTO simpleDTO = new SimpleDTO();
|
|
|
|
|
simpleDTO.setCode(StatisticsEnum.POWER_NETWORK.getCode());
|
|
|
|
|
|
|
|
|
|
List<TerminalMaintainVO> subListTem = subList.stream().peek(item->item.setChildren(getChildren(item.getId(),devList))).collect(Collectors.toList());
|
|
|
|
|
List<TerminalMaintainVO> gdListTem = gdList.stream().peek(item->item.setChildren(getChildren(item.getId(),subListTem))).collect(Collectors.toList());
|
|
|
|
|
return proList.stream().peek(item->item.setChildren(getChildren(item.getId(),gdListTem))).collect(Collectors.toList());
|
|
|
|
|
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
|
|
|
|
deviceInfoParam.setStatisticalType(simpleDTO);
|
|
|
|
|
deviceInfoParam.setDeptIndex(deptFeignClient.getRootDept().getData().getId());
|
|
|
|
|
deviceInfoParam.setPowerFlag(2);
|
|
|
|
|
deviceInfoParam.setMonitorFlag(2);
|
|
|
|
|
|
|
|
|
|
List<TerminalMaintainVO> resList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Objects.isNull(terminalMainQueryParam.getRunFlag())?null: CollUtil.newArrayList(terminalMainQueryParam.getRunFlag()), CollUtil.newArrayList(1));
|
|
|
|
|
if(CollectionUtil.isNotEmpty(generalDeviceDTOList)){
|
|
|
|
|
|
|
|
|
|
for(GeneralDeviceDTO generalDeviceDTO:generalDeviceDTOList){
|
|
|
|
|
List<String> devIds = generalDeviceDTO.getDeviceIndexes();
|
|
|
|
|
if (CollectionUtils.isEmpty(devIds)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TerminalMaintainVO terminalMaintainVO = new TerminalMaintainVO();
|
|
|
|
|
terminalMaintainVO.setName(generalDeviceDTO.getName());
|
|
|
|
|
terminalMaintainVO.setId(generalDeviceDTO.getIndex());
|
|
|
|
|
terminalMaintainVO.setLevel(1);
|
|
|
|
|
//根据监测点查询数据完整性
|
|
|
|
|
List<InfluxBaseDTO> integrityData = getCondition(devIds, "","");
|
|
|
|
|
|
|
|
|
|
List<TerminalMaintainVO> devList = terminalMaintainMapper.getTerminalDevInfoClone(terminalMainQueryParam,devIds);
|
|
|
|
|
List<TerminalMaintainVO> subList = terminalMaintainMapper.getPqLineGdAndSubList(generalDeviceDTO.getSubIndexes());
|
|
|
|
|
List<TerminalMaintainVO> gdList = terminalMaintainMapper.getPqLineGdAndSubList(generalDeviceDTO.getGdIndexes());
|
|
|
|
|
|
|
|
|
|
dealTerminalData(subList,devList);
|
|
|
|
|
dealTerminalData(gdList,subList);
|
|
|
|
|
terminalMaintainVO.setChildren(gdList);
|
|
|
|
|
resList.add(terminalMaintainVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* influxdb语句
|
|
|
|
|
*/
|
|
|
|
|
List<InfluxBaseDTO> getCondition(List<String> devIds,String startTime,String endTime){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TerminalMaintainVO> dealTerminalData(List<TerminalMaintainVO> parent,List<TerminalMaintainVO> children){
|
|
|
|
|
return parent.stream().peek(item->item.setChildren(getChildren(item.getId(),children))).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TerminalMaintainVO> getManageList(List<String> ids, Integer type) {
|
|
|
|
|
if(type == 0){
|
|
|
|
|
|