代码更新
This commit is contained in:
@@ -101,7 +101,7 @@ public class OperationContrController extends BaseController {
|
||||
@PostMapping("/getComunicateStatics")
|
||||
@ApiOperation("获取中断异常统计")
|
||||
@ApiImplicitParam(name = "conditionBusinessParam", value = "实体", required = true)
|
||||
public HttpResult<DeviceAbnormalVO> getComunicateStatics(@RequestBody @Validated DeviceInfoParam.ConditionBusinessParam conditionBusinessParam) {
|
||||
public HttpResult<DeviceAbnormalVO> getComunicateStatics(@RequestBody @Validated DeviceInfoParam.BusinessParam conditionBusinessParam) {
|
||||
String methodDescribe = getMethodDescribe("getComunicateStatics");
|
||||
DeviceAbnormalVO result = lineService.getComunicateStatics(conditionBusinessParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.device.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
@@ -44,10 +45,10 @@ public class RunManageController extends BaseController {
|
||||
@PostMapping("/getLineLedger")
|
||||
@ApiOperation("监测点台账信息")
|
||||
@ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true)
|
||||
public HttpResult<List<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
public HttpResult<Page<RunManageVO>> getLineLedger(@RequestBody @Validated RunManageParam runManageParam) {
|
||||
String methodDescribe = getMethodDescribe("getLineLedger");
|
||||
List<RunManageVO> result = runManageService.getLineLedger(runManageParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
Page<RunManageVO> res = runManageService.getLineLedger(runManageParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.device.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.po.Device;
|
||||
import com.njcn.device.pojo.vo.RunManageVO;
|
||||
import com.njcn.device.pojo.vo.RunTimeVO;
|
||||
@@ -34,7 +35,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
* @param runFlag 状态
|
||||
* @return 结果
|
||||
*/
|
||||
List<RunManageVO> getRunManageList(@Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag);
|
||||
Page<RunManageVO> getRunManageList(@Param("page") Page<RunManageVO> page, @Param("list") List<String> list, @Param("comFlag")List<Integer> comFlag, @Param("runFlag")List<Integer> runFlag);
|
||||
|
||||
/**
|
||||
* 获取监测点台账信息
|
||||
|
||||
@@ -143,21 +143,21 @@
|
||||
INNER JOIN pq_line sub ON sub.Id = dev.Pid
|
||||
INNER JOIN pq_line gd ON gd.Id = sub.Pid
|
||||
INNER JOIN pq_line areaId ON areaId.Id = gd.Pid
|
||||
INNER JOIN sys_area area ON area.Id = areaId.
|
||||
NAME INNER JOIN pq_device device ON device.Id = dev.Id
|
||||
INNER JOIN sys_area area ON area.Id = areaId.NAME
|
||||
INNER JOIN pq_device device ON device.Id = dev.Id
|
||||
INNER JOIN sys_dict_data manufacturerId ON manufacturerId.Id = device.Manufacturer
|
||||
INNER JOIN sys_dict_data devT ON devT.Id = device.Dev_Type
|
||||
WHERE dev.Id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="runFlag == '' and type !=null">
|
||||
<if test="runFlag == '' and runFlag !=null">
|
||||
and device.Run_Flag in
|
||||
<foreach item="item1" collection="runFlag" open="(" separator="," close=")">
|
||||
#{item1}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="comFlag == '' and type !=null">
|
||||
<if test="comFlag == '' and comFlag !=null">
|
||||
and device.Com_Flag in
|
||||
<foreach item="item2" collection="comFlag" open="(" separator="," close=")">
|
||||
#{item2}
|
||||
|
||||
@@ -481,6 +481,7 @@
|
||||
gd.`Name` gdName,
|
||||
substation.id subId,
|
||||
substation.`Name` subName,
|
||||
subscale.name subScale,
|
||||
pqdevice.IP ip,
|
||||
pqdevice.Com_Flag comFlag,
|
||||
factory.`Name` manufacturer,
|
||||
@@ -520,7 +521,7 @@
|
||||
AND pqdevice.Manufacturer = factory.id
|
||||
AND device.pid = substation.id
|
||||
AND substation.id = pqsubstation.id
|
||||
AND pqsubstation.Scale = subscale.id
|
||||
AND pqsubstation.scale = subscale.id
|
||||
AND substation.pid = gd.id
|
||||
AND detail.load_type = loadtype.id
|
||||
AND line.Id IN
|
||||
@@ -534,13 +535,6 @@
|
||||
or substation.name like CONCAT('%', #{searchValue},'%')
|
||||
or gd.name like CONCAT('%', #{searchValue},'%'))
|
||||
</if>
|
||||
<if test="searchValue!=null and searchValue!=''">
|
||||
and (line.name like CONCAT('%', #{searchValue},'%')
|
||||
or voltage.name like CONCAT('%', #{searchValue},'%')
|
||||
or device.name like CONCAT('%', #{searchValue},'%')
|
||||
or substation.name like CONCAT('%', #{searchValue},'%')
|
||||
or gd.name like CONCAT('%', #{searchValue},'%'))
|
||||
</if>
|
||||
<if test="comFlag!=null">
|
||||
and pqdevice.com_flag = #{comFlag}
|
||||
</if>
|
||||
|
||||
@@ -146,6 +146,6 @@ public interface LineService {
|
||||
* @param deviceInfoParam 参数
|
||||
* @return 结果
|
||||
*/
|
||||
DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.ConditionBusinessParam deviceInfoParam);
|
||||
DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam deviceInfoParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pojo.param.RunManageParam;
|
||||
import com.njcn.device.pojo.param.TerminalLedgerParam;
|
||||
@@ -20,7 +21,7 @@ public interface RunManageService {
|
||||
* @param runManageParam 参数
|
||||
* @return 结果
|
||||
*/
|
||||
List<RunManageVO> getLineLedger(RunManageParam runManageParam);
|
||||
Page<RunManageVO> getLineLedger(RunManageParam runManageParam);
|
||||
|
||||
/**
|
||||
* 获取终端台账信息
|
||||
|
||||
@@ -672,7 +672,7 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.ConditionBusinessParam conditionBusinessParam) {
|
||||
public DeviceAbnormalVO getComunicateStatics(DeviceInfoParam.BusinessParam conditionBusinessParam) {
|
||||
DeviceAbnormalVO deviceAbnormalVO = new DeviceAbnormalVO();
|
||||
//获取所有监测点
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(conditionBusinessParam, null, Stream.of(1).collect(Collectors.toList()));
|
||||
|
||||
@@ -4,8 +4,12 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.common.utils.PubUtils;
|
||||
import com.njcn.device.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.enums.LineBaseEnum;
|
||||
import com.njcn.device.mapper.DeviceMapper;
|
||||
import com.njcn.device.mapper.LineDetailMapper;
|
||||
@@ -16,34 +20,37 @@ import com.njcn.device.pojo.param.RunManageParam;
|
||||
import com.njcn.device.pojo.po.Device;
|
||||
import com.njcn.device.pojo.po.Line;
|
||||
import com.njcn.device.pojo.po.LineDetail;
|
||||
import com.njcn.device.pojo.po.pv.PvVoltage;
|
||||
import com.njcn.device.pojo.vo.*;
|
||||
import com.njcn.device.service.LineService;
|
||||
import com.njcn.device.service.RunManageService;
|
||||
import com.njcn.device.service.TerminalBaseService;
|
||||
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.vo.LineDataVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
|
||||
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
@@ -61,68 +68,56 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final TerminalBaseService terminalBaseService;
|
||||
|
||||
private final LineDetailMapper lineDetailMapper;
|
||||
|
||||
private final AreaFeignClient areaFeignClient;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Override
|
||||
public List<RunManageVO> getLineLedger(RunManageParam runManageParam) {
|
||||
List<RunManageVO> runManageVOList = new ArrayList<>();
|
||||
public Page<RunManageVO> getLineLedger(RunManageParam runManageParam) {
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
|
||||
List<String> lineIndexes = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
lineIndexes.addAll(generalDeviceDTO.getLineIndexes());
|
||||
}
|
||||
List<RunManageVO> list = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
|
||||
runManageVOList = list.stream().skip((runManageParam.getPageNum() - 1) * runManageParam.getPageSize()).limit(runManageParam.getPageSize()).
|
||||
collect(Collectors.toList());
|
||||
int i = 1;
|
||||
for (RunManageVO runManageVO : runManageVOList) {
|
||||
runManageVO.setRunNo(i);
|
||||
i++;
|
||||
}
|
||||
List<String> lineIndexes = generalDeviceDTOList.stream().flatMap(list->list.getLineIndexes().stream()).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(lineIndexes)) {
|
||||
Page<RunManageVO> page = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam));
|
||||
return deviceMapper.getRunManageList(page,lineIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
|
||||
}else {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
return runManageVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
|
||||
List<RunTimeVO> runTimeVOList = new ArrayList<>();
|
||||
List<RunTimeVO> runManageDevList = new ArrayList<>();
|
||||
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
|
||||
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
List<String> devIndexes = new ArrayList<>();
|
||||
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
|
||||
|
||||
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
|
||||
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||
devIndexes.addAll(generalDeviceDTO.getDeviceIndexes());
|
||||
}
|
||||
List<RunTimeVO> list = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
|
||||
runTimeVOList = list.stream().skip((runManageParam.getPageNum() - 1) * runManageParam.getPageSize()).limit(runManageParam.getPageSize()).
|
||||
collect(Collectors.toList());
|
||||
int i = 1;
|
||||
for (RunTimeVO runTimeVO : runTimeVOList) {
|
||||
runTimeVO.setRunNo(i);
|
||||
//获取在线率
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
runTimeVO.setOnlineEvaluate(getCondition(formatter.format(DateUtil.lastMonth()), formatter.format(DateUtil.dateNew(new Date())), runTimeVO.getId()) * 100);
|
||||
i++;
|
||||
List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list->list.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||
|
||||
if(CollectionUtil.isNotEmpty(devIndexes)){
|
||||
runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag());
|
||||
|
||||
StringBuilder devSql = InfluxDBCommUtils.assToInfluxParamDev(devIndexes);
|
||||
String stringBuilder = "time >= '" + runManageParam.getSearchBeginTime() + "' and " + "time <= '" + runManageParam.getSearchEndTime()+"' and "+devSql+" group by dev_id";
|
||||
//sql语句
|
||||
String sql = "SELECT MEAN(online_rate) AS online_rate FROM " + PQS_ONLINERATE + " WHERE " + stringBuilder + TIME_ZONE+")";
|
||||
QueryResult queryResult = influxDbUtils.query(sql);
|
||||
|
||||
InfluxDBResultMapper inCn = new InfluxDBResultMapper();
|
||||
List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVOList = inCn.toPOJO(queryResult,LineInfluxDbOnlineVO.class);
|
||||
runManageDevList = runManageDevList.stream().peek(item-> lineInfluxDbOnlineVOList.stream().filter(it-> Objects.equals(item.getId(),it.getDevIndex())).findFirst().ifPresent(i->item.setOnlineEvaluate(i.getOnlineRate()))).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return runTimeVOList;
|
||||
return runManageDevList;
|
||||
}
|
||||
|
||||
private Float getCondition(String startTime, String endTime, String lineId) {
|
||||
/* private Float getCondition(String startTime, String endTime, String lineId) {
|
||||
final Float[] floatList = {0.0f};
|
||||
QueryResult queryResult;
|
||||
if (!lineId.isEmpty()) {
|
||||
@@ -148,7 +143,7 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
}
|
||||
|
||||
return floatList[0];
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<TerminalLedgerVO> getTerminalLedger(DeviceInfoParam deviceInfoParam) {
|
||||
|
||||
Reference in New Issue
Block a user