1.解决审计统计没有显示的bug

2.解决数据中心数据查询过慢和数据展示bug
This commit is contained in:
wr
2023-06-01 17:16:28 +08:00
parent 4fe1039934
commit 7419142abe
33 changed files with 797 additions and 286 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -134,7 +135,7 @@ public class GeneralDeviceInfoController extends BaseController {
String methodDescribe = getMethodDescribe("getPracticalRunDeviceInfoAsSubstation");
List<GeneralDeviceDTO> substationDeviceInfos = generalDeviceService.getDeviceInfoAsSubstation(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(substationDeviceInfos)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, new ArrayList<>(), methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, substationDeviceInfos, methodDescribe);
}

View File

@@ -436,4 +436,11 @@ public interface LineMapper extends BaseMapper<Line> {
* @date 2023/5/25
*/
List<String> getLineByIDs(@Param("searchValue")String searchValue);
/**
* 通过电站id集合和电压等级
* @author cdf
* @date 2023/5/10
*/
List<Line> getSubStations(@Param("subId")List<String> subId, @Param("scale") List<String> scale);
}

View File

@@ -1109,4 +1109,29 @@
</where>
</select>
<select id="getSubStations" resultType="com.njcn.device.pq.pojo.po.Line">
SELECT
line.*
FROM
pq_line line
INNER JOIN pq_substation sub on line.id = sub.id
<where>
line.Level = 3
AND line.State = 1
<if test="subId!=null and subId.size()!=0">
and line.id in
<foreach collection="subId" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="scale!=null and scale.size()!=0">
and sub.Scale in
<foreach collection="scale" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>

View File

@@ -62,7 +62,7 @@ public interface TerminalBaseService {
* @param substationIds 监测点id
* @return 变电站信息
*/
List<Line> getSubstationByIds(List<String> substationIds);
List<Line> getSubstationByIds(List<String> substationIds,List<String> scale);
/**
* 根据监测点id获取所有监测点

View File

@@ -1,6 +1,7 @@
package com.njcn.device.pq.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.dto.SimpleDTO;
@@ -198,6 +199,12 @@ public class GeneralDeviceService {
*/
public List<GeneralDeviceDTO> getDeviceInfoAsSubstation(DeviceInfoParam deviceInfoParam, List<Integer> runFlag, List<Integer> devModel) {
List<GeneralDeviceDTO> deviceInfoAsSubstation = new ArrayList<>();
List<String> scale = new ArrayList<>();
if(CollUtil.isNotEmpty(deviceInfoParam.getScale())){
scale = deviceInfoParam.getScale().stream().map(SimpleDTO::getId).collect(Collectors.toList());
deviceInfoParam.setScale(new ArrayList<>());
}
List<GeneralDeviceDTO> deviceInfoAsDept = getDeviceInfo(deviceInfoParam, runFlag, devModel);
List<String> substationIds = new ArrayList<>();
List<String> lineIds = new ArrayList<>();
@@ -212,7 +219,7 @@ public class GeneralDeviceService {
substationIds = substationIds.stream().distinct().collect(Collectors.toList());
lineIds = lineIds.stream().distinct().collect(Collectors.toList());
if (!CollectionUtil.isEmpty(substationIds)) {
List<Line> substations = terminalBaseService.getSubstationByIds(substationIds);
List<Line> substations = terminalBaseService.getSubstationByIds(substationIds,scale);
List<Line> lines = terminalBaseService.getLineById(lineIds);
for (Line substation : substations) {
deviceInfoAsSubstation.add(mergeDeviceInfoAsSubstation(substation, lines));

View File

@@ -203,7 +203,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
if (CollectionUtils.isEmpty(lineIndexes)) {
continue;
}
outParam.setType(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getDeviceIndexes().size()+")");
outParam.setType(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getLineIndexes().size()+")");
//根据监测点查询数据完整性
List<PublicDTO> integrityData = getCondition(lineIndexes, integrityIconParam.getSearchBeginTime(), integrityIconParam.getSearchEndTime());
outParam.setSingle(NumberUtil.round(integrityData.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159),2).doubleValue());

View File

@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
@@ -1427,12 +1428,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
@Override
public List<Line> getSubstationByIds(List<String> substationIds) {
return this.lambdaQuery()
.in(Line::getId, substationIds)
.eq(Line::getLevel, 3)
.eq(Line::getState, DataStateEnum.ENABLE.getCode())
.list();
public List<Line> getSubstationByIds(List<String> substationIds,List<String> scale) {
return this.baseMapper.getSubStations(substationIds,scale);
// .in(Line::getId, substationIds)
// .eq(Line::getLevel, 3)
// .in(CollUtil.isNotEmpty(scale),Line::getLevel)
// .eq(Line::getState, DataStateEnum.ENABLE.getCode())
// .list();
}
@Override

View File

@@ -167,7 +167,7 @@ public class TerminalOnlineRateDataServiceImpl implements TerminalOnlineRateData
if (CollectionUtils.isEmpty(deviceIndexes)) {
continue;
}
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getDeviceIndexes().size()+")");
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getLineIndexes().size()+")");
//根据终端索引集查询在线率
List<PublicDTO> onlineRateList = getCondition(deviceIndexes, onlineRateCensusParam.getSearchBeginTime(), onlineRateCensusParam.getSearchEndTime());
single.add(onlineRateList.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159));

View File

@@ -111,7 +111,9 @@ public class RmpEventDetailPO implements Serializable {
private LocalDateTime createTime;
@ApiModelProperty(value = "用于计算数量")
@TableField(exist = false)
private Integer count;
}

View File

@@ -45,5 +45,6 @@ public class GeneralVO implements Serializable {
@ApiModelProperty(name = "upCount",value = "暂升次数")
private Integer upCount;
@ApiModelProperty(name = "id",value = "id")
private String id;
}

View File

@@ -2,6 +2,11 @@ package com.njcn.event.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -13,4 +18,10 @@ import com.njcn.event.pojo.po.RmpEventDetailPO;
*/
public interface EventDetailMapper extends BaseMapper<RmpEventDetailPO> {
/**
* 根据时间范围查询信息数据
* @param condMap
* @return
*/
List<GeneralVO> ListEventType( @Param("condMap") Map<String, Object> condMap);
}

View File

@@ -15,5 +15,32 @@
<result column="event_describe" property="eventDescribe" />
<result column="wave_path" property="wavePath" />
</resultMap>
<select id="ListEventType" resultType="com.njcn.event.pojo.vo.GeneralVO">
SELECT
id,
IF(`event_type` =#{condMap.Voltage_Dip}, num, 0) as sagsCount,
IF(`event_type` = #{condMap.Short_Interruptions}, num, 0) as breakCount,
IF(`event_type` = #{condMap.Voltage_Rise}, num, 0) as upCount
from(
SELECT
measurement_point_id AS id,
event_type,
count(event_id) as num
FROM
r_mp_event_detail
where measurement_point_id in
<foreach collection="condMap.ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
<if test="condMap.startTime != null and condMap.startTime != ''">
and start_time &gt;= #{condMap.startTime}
</if>
<if test="condMap.endTime != null and condMap.endTime != ''">
and start_time &lt;= #{condMap.endTime}
</if>
GROUP BY
measurement_point_id,event_type
) a
</select>
</mapper>

View File

@@ -6,6 +6,9 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
@@ -22,6 +25,7 @@ import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -50,6 +54,11 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
private final EventDetailService eventDetailService;
@Override
public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
// DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
// if(ObjectUtil.isNull(voltageData)){
// throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
// }
AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO();
List<DictData> dicReasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
List<DictData> dicTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
@@ -59,18 +68,21 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
//查询数据
// List<AreaAnalysisVO.Children> reasonList = assData(dicReasonList, lineIds, deviceInfoParam.getSearchBeginTime(), deviceInfoParam.getSearchEndTime(), "event_reason");
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.in(RmpEventDetailPO::getAdvanceReason, dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
.in(RmpEventDetailPO::getAdvanceType, dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("advance_reason,advance_type,count(event_id) as count")
.in("measurement_point_id", lineIds)
// .eq("event_type", voltageData.getId())
.in("advance_reason", dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
.in("advance_type", dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id,advance_reason,advance_type")
);
List<AreaAnalysisVO.Children> reasonList = assDataPQ(info, dicReasonList);
//暂降类型特殊处理
DictData dictData = dicReasonList.stream().filter(item->"短路故障".equals(item.getName())).findFirst().get();
DictData dictData = dicReasonList.stream().filter(item->DicDataEnum.SHORT_TROUBLE.getCode().equals(item.getCode())).findFirst().get();
//相间
List<String> dicIdsXi = dicTypeList.stream().filter(item->
ObjectUtil.equals(DicDataEnum.INTERPHASE_AB.getCode(),item.getCode())||
@@ -186,6 +198,27 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
}
private List<AreaAnalysisVO.Children> assDataPQ(List<RmpEventDetailPO> info,List<DictData> dicReasonList) {
List<AreaAnalysisVO.Children> reasonList = new ArrayList<>();
Map<String, List<RmpEventDetailPO>> reasonMap = info.stream().collect(Collectors.groupingBy(RmpEventDetailPO::getAdvanceReason));
AreaAnalysisVO.Children allType ;
Integer allCount = 0;
for (DictData dictData : dicReasonList) {
allType = new AreaAnalysisVO.Children();
if(reasonMap.containsKey(dictData.getId())){
Integer sum = reasonMap.get(dictData.getId()).stream().mapToInt(RmpEventDetailPO::getCount).sum();
allCount+=sum;
allType.setValue(sum);
}else{
allType.setValue(0);
}
allType.setName(dictData.getName());
reasonList.add(allType);
}
AreaAnalysisVO.Children zj = new AreaAnalysisVO.Children();
zj.setName("总计");
zj.setValue(allCount);
reasonList.add(zj);
/*
List<AreaAnalysisVO.Children> reasonList = new ArrayList<>();
//根据暂降原因分组
Map<String, String> reasonMap = dicReasonList.stream().collect(Collectors.toMap(DictData::getId,DictData::getName));
@@ -219,7 +252,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
AreaAnalysisVO.Children zj = new AreaAnalysisVO.Children();
zj.setName("总计");
zj.setValue(allCount);
reasonList.add(zj);
reasonList.add(zj);*/
return reasonList;
}
@@ -230,7 +263,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
Integer allCount = 0;
for (Map.Entry<String, List<String>> stringListEntry : stringListMap.entrySet()) {
List<String> value = stringListEntry.getValue();
Integer count = Math.toIntExact(reasons.stream().filter(x -> value.contains(x.getAdvanceType())).count());
Integer count = reasons.stream().filter(x -> value.contains(x.getAdvanceType())).mapToInt(RmpEventDetailPO::getCount).sum();
AreaAnalysisVO.Children allType = new AreaAnalysisVO.Children();
allType.setName(stringListEntry.getKey());
allType.setValue(count);

View File

@@ -3,9 +3,13 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
@@ -29,12 +33,14 @@ import com.njcn.harmonic.pojo.po.PQSComAssesPO;
import com.njcn.harmonic.utils.HarmonicComAssesUtil;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -44,7 +50,6 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.njcn.event.influxdb.PqsOnlinerateQuery.devIdOr;
import static com.njcn.event.influxdb.QueryBuilder.*;
/**
@@ -69,10 +74,10 @@ public class AreaLineServiceImpl implements AreaLineService {
private final PqDeviceMapper pqDeviceMapper;
private final EventDetailService eventDetailService;
@Autowired
private LargeScreenService largeScreenService;
@Autowired
private HarmonicComAssesUtil comAssesUtil;
private final LargeScreenService largeScreenService;
private final HarmonicComAssesUtil comAssesUtil;
private final DicDataFeignClient dicDataFeignClient;
@Override
public AreaLineVO getAreaLineVO(DeviceInfoParam deviceInfoParam) {
@@ -164,10 +169,16 @@ public class AreaLineServiceImpl implements AreaLineService {
@Override
public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
EventHeatMapVO eventHeatMapVO = new EventHeatMapVO();
List<List<AreaLineInfoVO>> eventHeatMapDetailList = new ArrayList<>();
deviceInfoParam.setServerName(ServerEnum.EVENT.getName());
List<BaseVO> listObject = new ArrayList<>();
// 获取暂降监测点
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
List<String> lineIndexs;
@@ -177,38 +188,29 @@ public class AreaLineServiceImpl implements AreaLineService {
lineIndexs = generalDeviceDTO.getLineIndexes();
// 获取暂降数据
if (lineIndexs.size() > 0) {
int tail = 0;
// List<EventHeatDeatilVO> eventdetailList = getContion(deviceInfoParam, lineIndexs);
Integer tail = 0;
//数据暂降查询
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexs)
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
.in("measurement_point_id", lineIndexs)
.eq("event_type", voltageData.getId())
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id")
);
List<EventHeatDeatilVO> eventdetailList = BeanUtil.copyToList(info, EventHeatDeatilVO.class);
if (eventdetailList.size() > 0) {
List<String> lineIds = eventdetailList.stream().map(EventHeatDeatilVO::getLineId).distinct().collect(Collectors.toList());
if (info.size() > 0) {
List<String> lineIds = info.stream().map(RmpEventDetailPO::getMeasurementPointId).distinct().collect(Collectors.toList());
List<AreaLineInfoVO> areaAnalysisVOList = lineFeignClient.getBaseLineAreaInfo(lineIds).getData();
/* for (EventHeatDeatilVO eventHeat : eventdetailList) {
for (AreaLineInfoVO areaLineInfoVO : areaAnalysisVOList) {
if (eventHeat.getLineId().equals(areaLineInfoVO.getLineId())) {
List<AreaLineInfoVO> ev = new ArrayList<>();
tail += eventHeat.getCount() == null ? 0 : eventHeat.getCount();
areaLineInfoVO.setTail(tail);
ev.add(areaLineInfoVO);
eventHeatMapDetailList.add(ev);
break;
}
}
}*/
for (AreaLineInfoVO areaLineInfoVO : areaAnalysisVOList) {
List<AreaLineInfoVO> ev = new ArrayList<>();
long count = eventdetailList.stream()
.filter(obj -> obj.getLineId().equals( areaLineInfoVO.getLineId()))
.count();
int c = (int) count;
areaLineInfoVO.setTail(c);
Integer count = info.stream()
.filter(obj -> obj.getMeasurementPointId().equals( areaLineInfoVO.getLineId()))
.mapToInt(RmpEventDetailPO::getFileFlag)
.sum();
tail+=count;
areaLineInfoVO.setTail(count);
ev.add(areaLineInfoVO);
eventHeatMapDetailList.add(ev);
}
@@ -221,7 +223,7 @@ public class AreaLineServiceImpl implements AreaLineService {
baseVO.setName(generalDeviceDTO.getName());
baseVO.setValue(BigDecimal.valueOf(lineIndexs.size()));
baseVO.setData(String.valueOf(allComAss));
baseVO.setCount(eventdetailList.size());
baseVO.setCount(tail);
baseVO.setSize(lineIndexs.size());
listObject.add(baseVO);
}
@@ -243,6 +245,11 @@ public class AreaLineServiceImpl implements AreaLineService {
@Override
public EventSeverityVO getEventSeverity(DeviceInfoParam.BusinessParam deviceInfoParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
EventSeverityVO eventSeverityVO = new EventSeverityVO();
List<EventSeverityValueVO> eventSeverityValueList = new ArrayList<>();
deviceInfoParam.setServerName(ServerEnum.EVENT.getName());
@@ -259,16 +266,18 @@ public class AreaLineServiceImpl implements AreaLineService {
if (lineIndexs.size() > 0) {
int tail = 0;
EventSeverityValueVO eventSeverityValueVO = new EventSeverityValueVO();
// List<EventHeatDeatilVO> eventdetailList = getContion(deviceInfoParam, lineIndexs);
List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexs)
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
.in("measurement_point_id", lineIndexs)
.eq("event_type", voltageData.getId())
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(deviceInfoParam.getSearchEndTime()), "start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id")
);
List<EventHeatDeatilVO> eventdetailList = BeanUtil.copyToList(info, EventHeatDeatilVO.class);
if (eventdetailList.size() > 0) {
for (int eventNum = 0; eventNum < eventdetailList.size(); eventNum++) {
tail += eventdetailList.get(eventNum).getCount();
if (info.size() > 0) {
for (int eventNum = 0; eventNum < info.size(); eventNum++) {
tail += info.get(eventNum).getFileFlag();
}
eventSeverityValueVO.setAreaName(generalDeviceDTO.getName());
eventSeverityValueVO.setLineNum(lineIndexs.size());

View File

@@ -2,13 +2,14 @@ package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.github.abel533.echarts.Label;
import com.github.abel533.echarts.Title;
import com.github.abel533.echarts.axis.AxisLabel;
@@ -26,6 +27,7 @@ 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.pojo.response.HttpResult;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
@@ -33,13 +35,13 @@ import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.*;
@@ -65,6 +67,23 @@ import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import freemarker.template.TemplateException;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
@@ -78,7 +97,6 @@ import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.http.*;
@@ -86,22 +104,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Decoder;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author xxy
@@ -133,6 +135,7 @@ public class ReportServiceImpl implements ReportService {
private final MonitorClient monitorClient;
private final EventDetailService eventDetailService;
private final EventDetailMapper eventDetailMapper;
private final FreemarkerUtil freemarkerUtil;
@@ -190,62 +193,50 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(dictType)){
return new ArrayList<>();
}
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode));
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
//查区域
HttpResult<List<GeneralDeviceDTO>> info = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam);
List<GeneralDeviceDTO> data = info.getData();
//所有根据line_id查询出来的数据
HashMap<String, List<EventDetail>> map = new HashMap<>();
//循环查找所有数据
// QueryResult queryResult = new QueryResult();
ArrayList<GeneralVO> list = new ArrayList<>();
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升
//根据id把所有的数据查询出来
List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);
GeneralVO generalVO;
List<GeneralVO> list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
list.add(new GeneralVO(dto.getName(), 0.0,0, 0, 0, 0, 0));
generalVO= new GeneralVO();
generalVO.setName(dto.getName());
// queryResult = null;
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT).append(Param.EVENT_DETAIL);
List<String> lineIndexes = dto.getLineIndexes();
if (lineIndexes.size() > 0) {
//数据暂降查询
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId,lineIndexes)
.ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
);
List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class);
if(CollUtil.isNotEmpty(dto.getLineIndexes())){
List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
generalVO.setVol(0.0D);
generalVO.setOnLine(onLineCount);
generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
}else{
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
generalVO.setSagsCount(0);
generalVO.setBreakCount(0);
generalVO.setUpCount(0);
}
list.add(generalVO);
map.put(dto.getName(), eventDetailList);
} else {
List<EventDetail> eventDetailList = new ArrayList<>();
map.put(dto.getName(), eventDetailList);
}
}
Set<String> keySet = map.keySet();
//获取状态
for (int i = 0; i < keySet.size(); i++) {
for (String s : keySet) {
GeneralVO generalVO = list.get(i);
if (map.get(s).size() > 0 && generalVO.getName().equals(s)) {
long count1 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(dictMap.get(x.getEventType()))).count();
long count2 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_RISE.getCode().equals(dictMap.get(x.getEventType()))).count();
long count3 = map.get(s).stream().filter(x -> DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(dictMap.get(x.getEventType()))).count();
generalVO.setSagsCount((int) count1);
generalVO.setUpCount((int) count2);
generalVO.setBreakCount((int) count3);
}
}
}
//是否在线
for (int i = 0; i < data.size(); i++) {
GeneralVO generalVO = list.get(i);
GeneralDeviceDTO dto = data.get(i);
if (dto.getLineIndexes().size() > 0) {
HttpResult<Integer> result = lineFeignClient.getOnLineCount(dto.getLineIndexes());
generalVO.setOnLine(result.getData());
generalVO.setOffLine(dto.getLineIndexes().size() - result.getData());
}
}
return list;
}
@@ -263,66 +254,50 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(dictType)){
return new ArrayList<>();
}
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getId, DictData::getCode));
Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
//查电压
List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
//所有根据line_id查询出来的数据
HashMap<String, List<EventDetail>> map = new HashMap<>();
//循环查找所有数据
// QueryResult queryResult = new QueryResult();
ArrayList<GeneralVO> list = new ArrayList<>();
List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
condMap.put("ids", lineIds);
condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升
//根据id把所有的数据查询出来
List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);
GeneralVO generalVO;
List<GeneralVO> list = new ArrayList<>();
for (GeneralDeviceDTO dto : data) {
list.add(new GeneralVO(dto.getName(), 0.0,0, 0, 0, 0, 0));
// queryResult = null;
// StringBuilder stringBuilder = new StringBuilder(Param.SELECT + Param.EVENT_DETAIL);
List<String> lineIndexes = dto.getLineIndexes();
if (lineIndexes.size() > 0) {
//数据暂降查询
List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId,lineIndexes)
.ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
);
List<EventDetail> eventDetailList= BeanUtil.copyToList(eventDetails,EventDetail.class);
// stringBuilder.append(Param.WHERE);
// lineIndexes.stream().forEach(line -> {
// stringBuilder.append("line_id = '").append(line + "' ").append("or ");
// });
// String substring = stringBuilder.substring(0, stringBuilder.length() - 3);
// queryResult = influxDbUtils.query(substring.toString());
// //结果集映射到对象中
// InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
// List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(queryResult, EventDetail.class);
map.put(dto.getName(), eventDetailList);
} else {
List<EventDetail> eventDetailList = new ArrayList<>();
map.put(dto.getName(), eventDetailList);
}
}
Set<String> keySet = map.keySet();
//获取状态
for (int i = 0; i < keySet.size(); i++) {
for (String s : keySet) {
GeneralVO generalVO = list.get(i);
if (map.get(s).size() > 0 && generalVO.getName().equals(s)) {
long count1 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(dictMap.get(x.getEventType()))).count();
long count2 = map.get(s).stream().filter(x -> DicDataEnum.VOLTAGE_RISE.getCode().equals(dictMap.get(x.getEventType()))).count();
long count3 = map.get(s).stream().filter(x -> DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(dictMap.get(x.getEventType()))).count();
generalVO.setSagsCount((int) count1);
generalVO.setUpCount((int) count2);
generalVO.setBreakCount((int) count3);
}
}
}
//是否在线
for (int i = 0; i < data.size(); i++) {
GeneralVO generalVO = list.get(i);
GeneralDeviceDTO dto = data.get(i);
if (dto.getLineIndexes().size() > 0) {
HttpResult<Integer> result = lineFeignClient.getOnLineCount(dto.getLineIndexes());
generalVO.setOnLine(result.getData());
generalVO.setOffLine(dto.getLineIndexes().size() - result.getData());
generalVO= new GeneralVO();
generalVO.setName(dto.getName());
if(CollUtil.isNotEmpty(dto.getLineIndexes())){
List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
generalVO.setVol(0.0D);
generalVO.setOnLine(onLineCount);
generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
generalVO.setSagsCount(sagsCount);
generalVO.setBreakCount(breakCount);
generalVO.setUpCount(upCount);
}else{
generalVO.setVol(0.0D);
generalVO.setOnLine(0);
generalVO.setOffLine(0);
generalVO.setSagsCount(0);
generalVO.setBreakCount(0);
generalVO.setUpCount(0);
}
list.add(generalVO);
}
list.forEach(item -> item.setVol(Double.parseDouble(item.getName().substring(0,item.getName().indexOf("k")))));
List<GeneralVO> sortedList = list.stream().sorted(Comparator.comparing(GeneralVO::getVol)).collect(Collectors.toList());
@@ -441,6 +416,11 @@ public class ReportServiceImpl implements ReportService {
*/
@Override
public Page<DetailVO> getContinueTime(WaveTypeParam waveTypeParam) {
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List<String> lineIds =new ArrayList<>();
List<DetailVO> result = new ArrayList<>();
if(waveTypeParam.getType()==0){
@@ -467,7 +447,7 @@ public class ReportServiceImpl implements ReportService {
}
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(waveTypeParam.getStatisticalType().getId()),RmpEventDetailPO::getEventType,waveTypeParam.getStatisticalType().getId())
.eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
.ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
@@ -481,45 +461,47 @@ public class ReportServiceImpl implements ReportService {
result.add(vo);
idlist.add(eventDetail.getLineId());
}
if(waveTypeParam.getType()==0){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
if(CollUtil.isNotEmpty(idlist)){
if(waveTypeParam.getType()==0){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
}
}
}
}else{
//pms系统
List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
for (DetailVO detailVO : result) {
for (Monitor vo : monitorInfo) {
if (vo.getId().equals(detailVO.getLineId())) {
detailVO.setLineId(vo.getId());
detailVO.setLineName(vo.getName());
detailVO.setSubId(vo.getPowerrId());
detailVO.setSubName(vo.getPowerrName());
detailVO.setGdId(vo.getOrgId());
detailVO.setGdName(vo.getOrgName());
detailVO.setVoltageScale(vo.getVoltageLevel());
}
}
}
}
}else{
//pms系统
List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (Monitor vo : monitorInfo) {
if (vo.getId().equals(detailVO.getLineId())) {
detailVO.setLineId(vo.getId());
detailVO.setLineName(vo.getName());
detailVO.setSubId(vo.getPowerrId());
detailVO.setSubName(vo.getPowerrName());
detailVO.setGdId(vo.getOrgId());
detailVO.setGdName(vo.getOrgName());
detailVO.setVoltageScale(vo.getVoltageLevel());
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(pageInfo,Page.class);
page.setRecords(result);
@@ -575,8 +557,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -589,13 +572,15 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(detail,Page.class);
page.setRecords(detailVO);
return page;
@@ -656,8 +641,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/*for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -670,10 +656,11 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
@@ -737,8 +724,9 @@ public class ReportServiceImpl implements ReportService {
for (DetailVO vo : detailVO) {
idlist.add(vo.getLineId());
}
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
if(CollUtil.isNotEmpty(idlist)){
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
/* for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
@@ -751,13 +739,15 @@ public class ReportServiceImpl implements ReportService {
}
}
}*/
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
for (DetailVO v : detailVO) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(v.getLineId())) {
BeanUtils.copyProperties(vo, v);
}
}
}
}
Page<DetailVO> page = BeanUtil.copyProperties(detail,Page.class);
page.setRecords(detailVO);
return page;
@@ -835,7 +825,7 @@ public class ReportServiceImpl implements ReportService {
//表格操作
HSSFWorkbook sheets = new HSSFWorkbook();
sheets.createSheet("sheet1");
sheets.createSheet("暂态总体概况");
HSSFSheet sheetAt = sheets.getSheetAt(0);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 9 * 256);
@@ -887,6 +877,7 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r3Cell1, "在线", cellStyle);
HSSFCell r3Cell2 = row3.createCell(2);
setCellStyle(r3Cell2, "离线", cellStyle);
int titleSize = 4;
HSSFCellStyle bodyStyle = sheets.createCellStyle();
bodyStyle.setAlignment(HorizontalAlignment.CENTER);
@@ -896,6 +887,11 @@ public class ReportServiceImpl implements ReportService {
bodyFont.setFontHeightInPoints((short) 9);
bodyStyle.setFont(bodyFont);
sheet2(sheets,cellStyle,bodyStyle,businessParam);
sheet3(sheets,cellStyle,bodyStyle,businessParam);
sheet4(sheets,cellStyle,bodyStyle,businessParam);
ArrayList<Integer> online = new ArrayList<>();
ArrayList<Integer> offline = new ArrayList<>();
ArrayList<String> xdata = new ArrayList<>();
@@ -911,7 +907,7 @@ public class ReportServiceImpl implements ReportService {
List<Integer> up2 = new ArrayList<>();
List<Integer> sag2 = new ArrayList<>();
List<Integer> break2 = new ArrayList<>();
/*
for (int i = 0; i < GereralList.size(); i++) {
GeneralVO vo = GereralList.get(i);
@@ -1076,9 +1072,341 @@ public class ReportServiceImpl implements ReportService {
drawingPatriarch.createPicture(anchor1, sheets.addPicture(bytes2, HSSFWorkbook.PICTURE_TYPE_JPEG));
drawingPatriarch.createPicture(anchor2, sheets.addPicture(bytes3, HSSFWorkbook.PICTURE_TYPE_JPEG));
drawingPatriarch.createPicture(anchor3, sheets.addPicture(bytes4, HSSFWorkbook.PICTURE_TYPE_JPEG));
*/
PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response);
}
public void sheet2(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂态严重度统计");
HSSFSheet sheetAt = sheets.getSheetAt(1);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256);
sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.setColumnWidth(7, 24 * 256);
sheetAt.setColumnWidth(8, 24 * 256);
sheetAt.setColumnWidth(9, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 10));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 7, 7));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 8, 8));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 9, 9));
HSSFRow title = sheetAt.createRow(0);
HSSFRow row1 = sheetAt.createRow(1);
HSSFCell titleCell = title.createCell(0);
setCellStyle(titleCell, "暂态事件严重度(前二十)", cellStyle);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
HSSFCell r1Cell6 = row1.createCell(6);
HSSFCell r1Cell7 = row1.createCell(7);
HSSFCell r1Cell8 = row1.createCell(8);
HSSFCell r1Cell9 = row1.createCell(9);
setCellStyle(r1Cell0, "序号", cellStyle);
setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
setCellStyle(r1Cell2, "供电公司", cellStyle);
setCellStyle(r1Cell3, "变电站", cellStyle);
setCellStyle(r1Cell4, "监测点", cellStyle);
setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
setCellStyle(r1Cell6, "干扰源类型", cellStyle);
setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle);
setCellStyle(r1Cell8, "持续时间(s)", cellStyle);
setCellStyle(r1Cell9, "暂态事件严重度", cellStyle);
List<WaveTypeVO> severity = getSeverity(businessParam);
for (int i = 0; i < severity.size(); i++) {
WaveTypeVO vo = severity.get(i);
HSSFRow row = sheetAt.createRow(i + 3);
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
HSSFCell cell2 = row.createCell(2);
HSSFCell cell3 = row.createCell(3);
HSSFCell cell4 = row.createCell(4);
HSSFCell cell5 = row.createCell(5);
HSSFCell cell6 = row.createCell(6);
HSSFCell cell7 = row.createCell(7);
HSSFCell cell8 = row.createCell(8);
HSSFCell cell9 = row.createCell(9);
cell0.setCellStyle(bodyStyle);
cell1.setCellStyle(bodyStyle);
cell2.setCellStyle(bodyStyle);
cell3.setCellStyle(bodyStyle);
cell4.setCellStyle(bodyStyle);
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
cell7.setCellStyle(bodyStyle);
cell8.setCellStyle(bodyStyle);
cell9.setCellStyle(bodyStyle);
cell0.setCellValue(i+1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getFeatureAmplitude()*100);
cell8.setCellValue(vo.getDuration());
cell9.setCellValue(vo.getSeverity());
}
}
public void sheet3(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂态原因统计");
HSSFSheet sheetAt = sheets.getSheetAt(2);
sheetAt.setColumnWidth(0, 40 * 256);
sheetAt.setColumnWidth(1, 40 * 256);
sheetAt.setColumnWidth(2, 40 * 256);
sheetAt.setColumnWidth(3, 40 * 256);
sheetAt.setColumnWidth(4, 40 * 256);
sheetAt.setColumnWidth(5, 40 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
HSSFRow title = sheetAt.createRow(0);
HSSFRow row1 = sheetAt.createRow(1);
HSSFCell titleCell = title.createCell(0);
setCellStyle(titleCell, "暂态原因统计表", cellStyle);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
setCellStyle(r1Cell0, "暂态原因", cellStyle);
setCellStyle(r1Cell1, "短路故障", cellStyle);
setCellStyle(r1Cell2, "变压器激磁", cellStyle);
setCellStyle(r1Cell3, "电压扰动", cellStyle);
setCellStyle(r1Cell4, "大型感应电动机启动", cellStyle);
setCellStyle(r1Cell5, "其他", cellStyle);
List<ReasonsVO> reason = getReason(businessParam);
HSSFRow row = sheetAt.createRow(3);
HSSFCell cell0 = row.createCell(0);
cell0.setCellValue("次数");
cell0.setCellStyle(bodyStyle);
HSSFRow row2 = sheetAt.createRow(4);
HSSFCell cellR0 = row2.createCell(0);
cellR0.setCellValue("占比(%)");
cellR0.setCellStyle(bodyStyle);
for (ReasonsVO reasonsVO : reason) {
if(ObjectUtil.equals(reasonsVO.getReason(),"短路故障")) {
HSSFCell cell1 = row.createCell(1);
HSSFCell cellR1 = row2.createCell(1);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"变压器激磁")) {
HSSFCell cell1 = row.createCell(2);
HSSFCell cellR1 = row2.createCell(2);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"电压扰动")) {
HSSFCell cell1 = row.createCell(3);
HSSFCell cellR1 = row2.createCell(3);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"大型感应电动机启动")) {
HSSFCell cell1 = row.createCell(4);
HSSFCell cellR1 = row2.createCell(4);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
if(ObjectUtil.equals(reasonsVO.getReason(),"其他")) {
HSSFCell cell1 = row.createCell(5);
HSSFCell cellR1 = row2.createCell(5);
cell1.setCellStyle(bodyStyle);
cellR1.setCellStyle(bodyStyle);
cell1.setCellValue(reasonsVO.getTimes());
cellR1.setCellValue(reasonsVO.getRate());
}
}
//todo 缺少eaches
}
public void sheet4(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("详细事件列表");
HSSFSheet sheetAt = sheets.getSheetAt(3);
sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256);
sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.setColumnWidth(7, 24 * 256);
sheetAt.setColumnWidth(8, 24 * 256);
sheetAt.setColumnWidth(9, 24 * 256);
sheetAt.setColumnWidth(10, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 7, 7));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));
HSSFRow row1 = sheetAt.createRow(0);
HSSFCell r1Cell0 = row1.createCell(0);
HSSFCell r1Cell1 = row1.createCell(1);
HSSFCell r1Cell2 = row1.createCell(2);
HSSFCell r1Cell3 = row1.createCell(3);
HSSFCell r1Cell4 = row1.createCell(4);
HSSFCell r1Cell5 = row1.createCell(5);
HSSFCell r1Cell6 = row1.createCell(6);
HSSFCell r1Cell7 = row1.createCell(7);
HSSFCell r1Cell8 = row1.createCell(8);
HSSFCell r1Cell9 = row1.createCell(9);
HSSFCell r1Cell10 = row1.createCell(10);
setCellStyle(r1Cell0, "序号", cellStyle);
setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
setCellStyle(r1Cell2, "供电公司", cellStyle);
setCellStyle(r1Cell3, "变电站", cellStyle);
setCellStyle(r1Cell4, "监测点", cellStyle);
setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
setCellStyle(r1Cell6, "干扰源类型", cellStyle);
setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle);
setCellStyle(r1Cell8, "持续时间(s)", cellStyle);
setCellStyle(r1Cell9, "暂态事件严重度", cellStyle);
setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle);
List<DetailVO> severity = sheetDetailed(businessParam);
for (int i = 0; i < severity.size(); i++) {
DetailVO vo = severity.get(i);
HSSFRow row = sheetAt.createRow(i + 2);
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
HSSFCell cell2 = row.createCell(2);
HSSFCell cell3 = row.createCell(3);
HSSFCell cell4 = row.createCell(4);
HSSFCell cell5 = row.createCell(5);
HSSFCell cell6 = row.createCell(6);
HSSFCell cell7 = row.createCell(7);
HSSFCell cell8 = row.createCell(8);
HSSFCell cell9 = row.createCell(9);
HSSFCell cell10 = row.createCell(10);
cell0.setCellStyle(bodyStyle);
cell1.setCellStyle(bodyStyle);
cell2.setCellStyle(bodyStyle);
cell3.setCellStyle(bodyStyle);
cell4.setCellStyle(bodyStyle);
cell5.setCellStyle(bodyStyle);
cell6.setCellStyle(bodyStyle);
cell7.setCellStyle(bodyStyle);
cell8.setCellStyle(bodyStyle);
cell9.setCellStyle(bodyStyle);
cell10.setCellStyle(bodyStyle);
cell0.setCellValue(i+1);
cell1.setCellValue(vo.getStartTime());
cell2.setCellValue(vo.getGdName());
cell3.setCellValue(vo.getSubName());
cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getObjName());
cell8.setCellValue(vo.getFeatureAmplitude()*100);
cell9.setCellValue(vo.getDuration());
cell10.setCellValue(vo.getAdvanceType());
}
}
/**
* sheet 详细数据列表
*/
private List<DetailVO> sheetDetailed(DeviceInfoParam.BusinessParam businessParam){
//获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
}
List<DetailVO> result = new ArrayList<>();
//pq系统
List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
List<String> lineIds =deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
if (CollectionUtil.isEmpty(lineIds)) {
throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
}
List<RmpEventDetailPO> info = eventDetailService.list( new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineIds)
.eq(StrUtil.isNotBlank(voltageData.getId()),RmpEventDetailPO::getEventType,voltageData.getId())
.ge(StringUtils.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
.orderByDesc(RmpEventDetailPO::getStartTime)
);
if (CollectionUtil.isNotEmpty(info)) {
ArrayList<String> idlist = new ArrayList<>();
for (RmpEventDetailPO eventDetail : info) {
DetailVO vo = new DetailVO();
vo.setStartTime( eventDetail.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)));
BeanUtils.copyProperties(eventDetail, vo);
result.add(vo);
idlist.add(eventDetail.getLineId());
}
if(CollUtil.isNotEmpty(idlist)){
//pq系统
HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
List<AreaLineInfoVO> data = AreaInfo.getData();
for (DetailVO detailVO : result) {
for (AreaLineInfoVO vo : data) {
if (vo.getLineId().equals(detailVO.getLineId())) {
BeanUtils.copyProperties(vo, detailVO);
}
}
}
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
List<DictData> type = reason.getData();
for (DetailVO detailVO : result) {
for (DictData dictData : type) {
if (dictData.getId().equals(detailVO.getAdvanceType())) {
detailVO.setAdvanceType(dictData.getName());
}
}
}
}
}
return result;
}
/**
* 创建标题
@@ -1261,7 +1589,7 @@ public class ReportServiceImpl implements ReportService {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, eventDetail.getFeatureAmplitude() + "", eventDetail.getDuration() / 1000.0 + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, eventDetail.getFeatureAmplitude()*100 + "", eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
@@ -1497,7 +1825,7 @@ public class ReportServiceImpl implements ReportService {
ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetail eventDetail : plot) {
ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + ""));
doubles.add(eventDetail.getDuration());
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles);
}

View File

@@ -322,10 +322,10 @@ public class TransientServiceImpl implements TransientService {
.orderByDesc(RmpEventDetailPO::getStartTime);
//暂态幅值
if (Objects.nonNull(transientParam.getEventValueMin())) {
wrapper.ge(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
wrapper.ge(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin());
}
if (Objects.nonNull(transientParam.getEventValueMax())) {
wrapper.le(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
wrapper.le(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax());
}
if (Objects.nonNull(transientParam.getPersistMin()) && Objects.nonNull(transientParam.getSeverityMax())) {
wrapper.ge(RmpEventDetailPO::getDuration, transientParam.getPersistMin()).le(RmpEventDetailPO::getDuration, transientParam.getPersistMax());

View File

@@ -3,16 +3,19 @@
backgroundColor: "#FFF",
title: {
text: "ITIC曲线",
x: "center",
left: "center",
},
grid: {
left: "4%",
right: "2%",
top: "80px",
left: "40px",
right: "40px",
bottom: "10%",
},
legend: {
data: ["上限", "下限", "可容忍事件", "不可容忍事件"],
x: "left",
top:"26px",
left: "0px",
bottom: "94%",
},
color: ["#FF8C00", "#00BFFF", "green", "red"],
xAxis: [

View File

@@ -3,16 +3,19 @@
backgroundColor: "#fff",
title: {
text: "SEMI F47曲线",
x: "center",
left: "center",
},
grid: {
left: "4%",
right: "5%",
top: "80px",
left: "40px",
right: "40px",
bottom: "10%",
},
legend: {
data: ["边界线", "可容忍事件", "不可容忍事件"],
x: "left",
top:"26px",
left: "0px",
bottom: "94%",
},
color: ["yellow", "green", "red"],
xAxis: [

View File

@@ -30,10 +30,10 @@
xAxis: [
{
type: "category",
boundaryGap: false,
boundaryGap: true,
name: "暂降幅值",
nameLocation: "center",
nameGap: 20,
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
@@ -56,7 +56,7 @@
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameGap: 60,
nameTextStyle: {
fontSize: 15,
},
@@ -68,7 +68,7 @@
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},

View File

@@ -19,10 +19,10 @@ bottom: "15%"
xAxis: [
{
type: "category",
boundaryGap: false,
boundaryGap: true,
name: "暂降持续时间(s)",
nameLocation: "center",
nameGap: 20,
nameGap: 40,
nameTextStyle: {
fontSize: 15,
},
@@ -34,7 +34,7 @@ yAxis: [
type: "value",
name: "概率分布",
nameLocation: "center",
nameGap: 40,
nameGap: 60,
nameTextStyle: {
fontSize: 15,
},
@@ -46,7 +46,7 @@ formatter: "{value} %",
type: "value",
name: "占比",
nameLocation: "center",
nameGap: 40,
nameGap: 20,
nameTextStyle: {
fontSize: 15,
},

View File

@@ -11,9 +11,10 @@ data: ["暂降次数"],
x: "left",
},
grid: {
left: "3%",
bottom: "3%",
right: "7%",
top: "80px",
left: "40px",
right: "60px",
bottom:"20px",
containLabel: true,
},
xAxis: [

View File

@@ -190,7 +190,7 @@ public class PubUtils {
}
@SneakyThrows
public static List<String> getIntervalDateTime(Integer startTime, Integer endTime, Integer dd) {
public static List<String> getIntervalDateTime(Integer startTime,int beginDay, Integer endTime, Integer dd) {
List<String> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance(Locale.CHINA);
calendar.set(startTime, endTime - 1, 1);
@@ -198,7 +198,7 @@ public class PubUtils {
int year = calendar.get(Calendar.YEAR);
//月份
int month = calendar.get(Calendar.MONTH) + 1;
for (int i = 1; i <= dd; i++) {
for (int i = beginDay; i <= dd; i++) {
String date = null;
if (month < 10 && i < 10) {
date = year + "-0" + month + "-0" + i;

View File

@@ -95,7 +95,7 @@ public class HarmonicServiceImpl implements IHarmonicService {
List<PollutionVO> childrenList = new ArrayList<>();
PollutionVO pollutionVO = new PollutionVO();
pollutionVO.setId(dept.getIndex());
pollutionVO.setName(dept.getName());
pollutionVO.setName(dept.getName()+"\n("+dept.getLineIndexes().size()+")");
dept.getSubIndexes().forEach(sub->{
List<PollutionLineDTO> l1 = map.get(sub);
PollutionVO children = new PollutionVO();

View File

@@ -195,7 +195,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
String name =temp.getName ();
List<String> powers = temp.getPowerrIdList ( );
pollutionVO.setId (detpid);
pollutionVO.setName (name);
pollutionVO.setName (name+"\n("+temp.getMonitorIdList().size()+")");
pollutionVO.setData (-1.0);
setData(harmonicPublicParam, pollutionType, searchBeginTime,harmonicPublicParam.getSearchEndTime(), pollutionVO, detpid);
if(CollectionUtil.isNotEmpty(powers)) {
@@ -242,7 +242,7 @@ public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSu
String name = temp.getName();
pollutionVO.setId(detpid);
pollutionVO.setName(name);
pollutionVO.setName(name+"\n("+temp.getLineIndexes().size()+")");
pollutionVO.setData(-1.0);
setData(harmonicPublicParam, pollutionType, searchBeginTime,harmonicPublicParam.getSearchEndTime(), pollutionVO, detpid);
List<PollutionVO> subPollutionVO = new ArrayList<>();

View File

@@ -89,7 +89,7 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
if (!CollectionUtils.isEmpty(deviceDataList)) {
List<Map<String,Double>> maps=new ArrayList<>();
for (GeneralDeviceDTO generalDeviceDTO: deviceDataList) {
type.add("("+generalDeviceDTO.getDeviceIndexes().size()+")"+generalDeviceDTO.getName());
type.add("("+generalDeviceDTO.getLineIndexes().size()+")"+generalDeviceDTO.getName());
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
Map<String, Double> collect=new HashMap<>();
@@ -129,15 +129,31 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
case 1:
//查询是天
List<String> intervalTime = PubUtils.getIntervalTime(steadyExceedCensusParam.getSearchBeginTime(),steadyExceedCensusParam.getSearchEndTime());
for (String interTime : intervalTime) {
String startTime = PublicDateUtil.getFisrtDayOfMonth(Integer.parseInt(interTime.substring(0, 4)), Integer.parseInt(interTime.substring(5)));
for (int j = 0; j < intervalTime.size(); j++) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dt = simpleDateFormat.parse(startTime);
Date dtDate = simpleDateFormat.parse(steadyExceedCensusParam.getSearchEndTime());
Date dt ;
Date dtDate;
int beginDay;
if(j==0){
dt= simpleDateFormat.parse(steadyExceedCensusParam.getSearchBeginTime());
beginDay = Integer.valueOf(String.format("%td", dt));
}else{
String startTime = PublicDateUtil.getFisrtDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5)));
dt= simpleDateFormat.parse(startTime);
beginDay = Integer.valueOf(String.format("%td", dt));
}
if(j==intervalTime.size()-1){
dtDate= simpleDateFormat.parse(steadyExceedCensusParam.getSearchEndTime());
}else{
String startTime = PublicDateUtil.getLastDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5)));
dtDate= simpleDateFormat.parse(startTime);
}
Integer year = Integer.valueOf(String.format("%tY", dt));
Integer mon = Integer.valueOf(String.format("%tm", dt));
Integer day = Integer.valueOf(String.format("%td", dtDate));
List<String> dayTime = PubUtils.getIntervalDateTime(year, mon, day);
List<String> dayTime = PubUtils.getIntervalDateTime(year,beginDay, mon, day);
for (String s : dayTime) {
List<Double> steadyExceedRate = new ArrayList<>();
for (int i = 0; i < tempIndex.size(); i++) {

View File

@@ -116,7 +116,7 @@ public class SteadyQualifyServiceImpl implements SteadyQualifyService {
if (CollectionUtils.isEmpty(lineIndexes)) {
continue;
}
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getDeviceIndexes().size()+")");
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getLineIndexes().size()+")");
List<SteadyQualifyDTO> qualifiesRate = getQualifiesRate(lineIndexes, steadyCensusParam.getSearchBeginTime(), steadyCensusParam.getSearchEndTime());
SteadyQualifyVO dataMoreMonitorMoreDay = getDataMoreMonitorMoreDay(qualifiesRate);
harmonicVoltage.add(dataMoreMonitorMoreDay.getHarmonicVoltage());

View File

@@ -101,7 +101,7 @@ public class THDistortionServiceImpl implements THDistortionService {
if (CollectionUtils.isEmpty(lineIndexes)) {
continue;
}
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getDeviceIndexes().size()+")");
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getLineIndexes().size()+")");
List<PublicDTO> condition = getCondition(lineIndexes, thDistortionCensusParam.getSearchBeginTime(), thDistortionCensusParam.getSearchEndTime());
single.add(roundHalfUp(condition.stream().mapToDouble(PublicDTO::getData).average().orElse(3.14159)));
}

View File

@@ -88,7 +88,7 @@ public class TerminalServiceImpl implements TerminalService {
if (CollectionUtils.isEmpty(generalDeviceDTO.getDeviceIndexes())) {
continue;
}
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getDeviceIndexes().size()+")");
type.add(generalDeviceDTO.getName()+"\n("+generalDeviceDTO.getLineIndexes().size()+")");
List<String> deviceIndexes = generalDeviceDTO.getDeviceIndexes();
//根据终端查询在线率
List<PublicDTO> condition = getCondition(deviceIndexes, terminalCensusParam.getSearchBeginTime(), terminalCensusParam.getSearchEndTime());

View File

@@ -347,6 +347,10 @@ public enum DicDataEnum {
SET("定值","Set"),
INSET("内部定值","InSet"),
CTRL("控制","Ctrl"),
/**
* 暂降原因
*/
SHORT_TROUBLE("短路故障", "Short_Trouble"),
/**
* 暂降类型

View File

@@ -1,11 +1,13 @@
package com.njcn.system.excel;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.util.ListUtils;
import com.njcn.system.mapper.UserLogMapper;
import java.util.List;
import java.util.stream.Collectors;
// 有个很重要的点 DemoDataListener 不能被spring管理要每次读取excel都要new,然后里面用到spring可以构造方法传进去
public class DataListener implements ReadListener<UserLogExcel> {
@@ -14,7 +16,7 @@ public class DataListener implements ReadListener<UserLogExcel> {
/**
* 每隔5条存储数据库实际使用中可以100条然后清理list ,方便内存回收
*/
private static final int BATCH_COUNT = 1000;
private static final int BATCH_COUNT = 5000;
/**
* 缓存的数据
*/
@@ -23,14 +25,16 @@ public class DataListener implements ReadListener<UserLogExcel> {
* 假设这个是一个DAO当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。
*/
private UserLogMapper userLogMapper;
private List<String> ids;
/**
* 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来
*
* @param userLogMapper
*/
public DataListener(UserLogMapper userLogMapper) {
public DataListener(UserLogMapper userLogMapper,List<String> ids) {
this.userLogMapper = userLogMapper;
this.ids = ids;
}
/**
@@ -66,6 +70,11 @@ public class DataListener implements ReadListener<UserLogExcel> {
* 加上存储数据库
*/
public void saveData() {
userLogMapper.insertBatch(cachedDataList);
//剔除数据库存在的数据
List<UserLogExcel> newCachedDataList = cachedDataList.stream().filter(x -> !ids.contains(x.getId())).collect(Collectors.toList());
System.err.println(newCachedDataList.size());
if(CollUtil.isNotEmpty(newCachedDataList)){
userLogMapper.insertBatch(newCachedDataList);
}
}
}

View File

@@ -45,4 +45,10 @@ public interface AuditMapper {
*/
List<String> selectOperateType();
/**
* 时间范围查询id集合
* @return
*/
List<String> getListIDs(@Param("startTime") String startTime,
@Param("endTime") String endTime);
}

View File

@@ -148,5 +148,18 @@
</where>
</select>
<select id="getListIDs" resultType="java.lang.String">
SELECT
id
FROM sys_user_log
<where>
<if test="startTime != null and startTime != ''">
and create_time >= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and create_time &lt;= #{endTime}
</if>
</where>
</select>
</mapper>

View File

@@ -29,7 +29,6 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.oss.constant.OssPath;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.enums.AuditLogEnum;
import com.njcn.system.excel.DataListener;
import com.njcn.system.excel.UserLogExcel;
import com.njcn.system.mapper.AuditMapper;
import com.njcn.system.mapper.UserLogMapper;
@@ -267,8 +266,10 @@ public class AuditServiceImpl extends ServiceImpl<UserLogMapper, UserLog> implem
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}).sheet().doRead();
// 执行批量插入
saveLogsBatch(userLogs, 1500);
if(CollUtil.isNotEmpty(userLogs)){
// 执行批量插入
saveLogsBatch(userLogs, 1500);
}
} catch (Exception e) {
redisUtil.delete("recoverLogFile");
e.printStackTrace();
@@ -317,6 +318,8 @@ public class AuditServiceImpl extends ServiceImpl<UserLogMapper, UserLog> implem
@Override
public Page<AuditLogCusVO> censusAuditLog(AuditParam auditParam) {
auditParam.setSearchBeginTime(DateUtil.beginOfDay(DateUtil.parse(auditParam.getSearchBeginTime())).toString());
auditParam.setSearchEndTime(DateUtil.endOfDay(DateUtil.parse(auditParam.getSearchBeginTime())).toString());
//待分页数据总量
Page<AuditLogCusVO> page = auditMapper.selectCensusAuditLog(new Page<>(auditParam.getPageNum(), auditParam.getPageSize()), auditParam);
return page;