1.pqbug修改

This commit is contained in:
wr
2023-06-02 16:36:25 +08:00
parent 7f71e9e5d8
commit e37fbf4f47
7 changed files with 128 additions and 86 deletions

View File

@@ -2,33 +2,26 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.njcn.device.pq.mapper.OnlineRateMapper;
import com.njcn.device.pq.mapper.RStatIntegrityDMapper; import com.njcn.device.pq.mapper.RStatIntegrityDMapper;
import com.njcn.device.pq.mapper.RStatOnlinerateDMapper; import com.njcn.device.pq.mapper.RStatOnlinerateDMapper;
import com.njcn.device.pq.pojo.param.OnlineRateParam; import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.param.PulicTimeParam; import com.njcn.device.pq.pojo.param.PulicTimeParam;
import com.njcn.device.pq.pojo.param.PulicTimeStatisParam; import com.njcn.device.pq.pojo.param.PulicTimeStatisParam;
import com.njcn.device.pq.pojo.po.LineDataIntegrity;
import com.njcn.device.pq.pojo.po.RStatOnlinerateD;
import com.njcn.device.pq.pojo.vo.*; import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.service.CommunicateService; import com.njcn.device.pq.service.CommunicateService;
import com.njcn.device.pq.service.IRStatOnlinerateDService;
import com.njcn.device.pq.service.LineService; import com.njcn.device.pq.service.LineService;
import com.njcn.device.pq.utils.PublicDateUtil; import com.njcn.device.pq.utils.PublicDateUtil;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
/** /**
* @author denghuajun * @author denghuajun
@@ -97,30 +90,48 @@ public class CommunicateServiceImpl implements CommunicateService {
deviceOnlineDataList.add(inter); deviceOnlineDataList.add(inter);
} }
} else { } else {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); List<String> intervalTime = this.getIntervalTime(pulicTimeParam.getSearchBeginTime(),pulicTimeParam.getSearchEndTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (int j = 0; j < intervalTime.size(); j++) {
Date dt = simpleDateFormat.parse(pulicTimeParam.getSearchBeginTime()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dtDate = simpleDateFormat.parse(pulicTimeParam.getSearchEndTime()); Date dt ;
Integer year = Integer.valueOf(String.format("%tY", dt)); Date dtDate;
Integer mon = Integer.valueOf(String.format("%tm", dt)); if(j==0){
Integer day = Integer.valueOf(String.format("%td", dtDate)); dt= simpleDateFormat.parse(pulicTimeParam.getSearchBeginTime());
List<String> intervalTime = this.getIntervalDateTime(year, mon,day); }else{
for (String interTime : intervalTime) { String startTime = PublicDateUtil.getFisrtDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5)));
DeviceOnlineDataVO inter = new DeviceOnlineDataVO(); dt= simpleDateFormat.parse(startTime);
String startTime, endTime;
inter.setMonth(interTime.substring(5, 7)); }
inter.setYear(interTime.substring(0, 4)); int beginDay = Integer.valueOf(String.format("%td", dt));
inter.setDay(interTime.substring(8)); if(j==intervalTime.size()-1){
startTime =sdf.format(DateUtil.beginOfDay(DateUtil.parse(interTime))); dtDate= simpleDateFormat.parse(pulicTimeParam.getSearchEndTime());
endTime = sdf.format(DateUtil.endOfDay(DateUtil.parse(interTime))); }else{
floatList = getCondition(devId, startTime, endTime, 1); String startTime = PublicDateUtil.getLastDayOfMonth(Integer.parseInt(intervalTime.get(j).substring(0, 4)), Integer.parseInt(intervalTime.get(j).substring(5)));
if (floatList == 0) { dtDate= simpleDateFormat.parse(startTime);
inter.setOnlineRate(3.14159f); }
} else { Integer year = Integer.valueOf(String.format("%tY", dt));
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList))); Integer mon = Integer.valueOf(String.format("%tm", dt));
Integer day = Integer.valueOf(String.format("%td", dtDate));
List<String> dayTime = this.getIntervalDateTime(year,beginDay, mon, day);
for (String interTime : dayTime) {
DeviceOnlineDataVO inter = new DeviceOnlineDataVO();
String startTime, endTime;
inter.setMonth(interTime.substring(5, 7));
inter.setYear(interTime.substring(0, 4));
inter.setDay(interTime.substring(8));
startTime =simpleDateFormat.format(DateUtil.beginOfDay(DateUtil.parse(interTime)));
endTime = simpleDateFormat.format(DateUtil.endOfDay(DateUtil.parse(interTime)));
floatList = getCondition(devId, startTime, endTime, 1);
if (floatList == 0) {
inter.setOnlineRate(3.14159f);
} else {
inter.setOnlineRate(Float.parseFloat(decimalFormat.format(floatList)));
}
deviceOnlineDataList.add(inter);
} }
deviceOnlineDataList.add(inter);
} }
} }
return deviceOnlineDataList; return deviceOnlineDataList;
} }
@@ -290,13 +301,13 @@ public class CommunicateServiceImpl implements CommunicateService {
} }
@SneakyThrows @SneakyThrows
private List<String> getIntervalDateTime(Integer startTime, Integer endTime,Integer dd) { private List<String> getIntervalDateTime(Integer startTime, int beginDay,Integer endTime,Integer dd) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
Calendar calendar = Calendar.getInstance(Locale.CHINA); Calendar calendar = Calendar.getInstance(Locale.CHINA);
calendar.set(startTime, endTime - 1, 1); calendar.set(startTime, endTime - 1, 1);
int year = calendar.get(Calendar.YEAR);//年份 int year = calendar.get(Calendar.YEAR);//年份
int month = calendar.get(Calendar.MONTH) + 1;//月份 int month = calendar.get(Calendar.MONTH) + 1;//月份
for (int i = 1; i <= dd; i++) { for (int i = beginDay; i <= dd; i++) {
String date = null; String date = null;
if (month < 10 && i < 10) { if (month < 10 && i < 10) {
date = year + "-0" + month + "-0" + i; date = year + "-0" + month + "-0" + i;

View File

@@ -4,12 +4,15 @@ import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory; import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.GeneralVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author denghuajun * @author denghuajun
@@ -41,4 +44,11 @@ public interface EventDetailFeignClient {
@PostMapping("/getEventDetailLimit") @PostMapping("/getEventDetailLimit")
HttpResult<List<EventDetail>> getEventDetailLimit(@RequestBody List<String> lineIndexes, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime,@RequestParam("pageSize") Integer pageSize,@RequestParam("pageNum") Integer pageNum); HttpResult<List<EventDetail>> getEventDetailLimit(@RequestBody List<String> lineIndexes, @RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime,@RequestParam("pageSize") Integer pageSize,@RequestParam("pageNum") Integer pageNum);
/**
* 根据监测点集合获取短时终端,电压暂升,电压暂降数量
* @return 暂降事件信息
*/
@PostMapping("/getEventDetailCount")
HttpResult<List<GeneralVO>> getEventDetailCount(@RequestBody Map<String, Object> condMap);
} }

View File

@@ -5,12 +5,14 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.event.utils.EventlEnumUtil; import com.njcn.event.utils.EventlEnumUtil;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author denghuajun * @author denghuajun
@@ -48,6 +50,12 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<GeneralVO>> getEventDetailCount(Map<String, Object> condMap) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点集合获取短时终端,电压暂升,电压暂降数量", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -6,7 +6,9 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author denghuajun * @author denghuajun
@@ -35,6 +38,7 @@ import java.util.List;
public class EventDetailController extends BaseController { public class EventDetailController extends BaseController {
private final EventDetailService eventDetailService; private final EventDetailService eventDetailService;
private final EventDetailMapper eventDetailMapper;
/** /**
* 获取暂降事件 * 获取暂降事件
@@ -124,6 +128,17 @@ public class EventDetailController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
/**
* 根据监测点集合获取短时终端,电压暂升,电压暂降
* @return
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventDetailCount")
@ApiOperation("根据监测点集合获取各个监测点的统计类型数量")
public HttpResult<List<GeneralVO>> getEventDetail(@RequestBody Map<String, Object> condMap) {
String methodDescribe = getMethodDescribe("getEventDetail");
List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, generalVOS, methodDescribe);
}
} }

View File

@@ -18,9 +18,9 @@
<select id="ListEventType" resultType="com.njcn.event.pojo.vo.GeneralVO"> <select id="ListEventType" resultType="com.njcn.event.pojo.vo.GeneralVO">
SELECT SELECT
id, id,
IF(`event_type` =#{condMap.Voltage_Dip}, num, 0) as sagsCount, sum(IF(`event_type` =#{condMap.Voltage_Dip}, num, 0)) as sagsCount,
IF(`event_type` = #{condMap.Short_Interruptions}, num, 0) as breakCount, sum(IF(`event_type` = #{condMap.Short_Interruptions}, num, 0)) as breakCount,
IF(`event_type` = #{condMap.Voltage_Rise}, num, 0) as upCount sum(IF(`event_type` = #{condMap.Voltage_Rise}, num, 0)) as upCount
from( from(
SELECT SELECT
measurement_point_id AS id, measurement_point_id AS id,
@@ -41,6 +41,7 @@
GROUP BY GROUP BY
measurement_point_id,event_type measurement_point_id,event_type
) a ) a
GROUP BY id
</select> </select>
</mapper> </mapper>

View File

@@ -1083,7 +1083,7 @@ public class ReportServiceImpl implements ReportService {
sheetAt.setColumnWidth(0, 24 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256); sheetAt.setColumnWidth(3, 44 * 256);
sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256);
@@ -1164,7 +1164,7 @@ public class ReportServiceImpl implements ReportService {
cell6.setCellValue(vo.getLoadType()); cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getFeatureAmplitude()*100); cell7.setCellValue(vo.getFeatureAmplitude()*100);
cell8.setCellValue(vo.getDuration()); cell8.setCellValue(vo.getDuration());
cell9.setCellValue(vo.getSeverity()); cell9.setCellValue(BigDecimal.valueOf(vo.getSeverity()).setScale(2, RoundingMode.HALF_UP).doubleValue());
} }
} }
@@ -1279,11 +1279,11 @@ public class ReportServiceImpl implements ReportService {
sheetAt.setColumnWidth(0, 24 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 24 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256); sheetAt.setColumnWidth(3, 44 * 256);
sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(4, 24 * 256);
sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.setColumnWidth(7, 24 * 256); sheetAt.setColumnWidth(7, 50 * 256);
sheetAt.setColumnWidth(8, 24 * 256); sheetAt.setColumnWidth(8, 24 * 256);
sheetAt.setColumnWidth(9, 24 * 256); sheetAt.setColumnWidth(9, 24 * 256);
sheetAt.setColumnWidth(10, 24 * 256); sheetAt.setColumnWidth(10, 24 * 256);
@@ -1320,9 +1320,9 @@ public class ReportServiceImpl implements ReportService {
setCellStyle(r1Cell4, "监测点", cellStyle); setCellStyle(r1Cell4, "监测点", cellStyle);
setCellStyle(r1Cell5, "监测点电压等级", cellStyle); setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
setCellStyle(r1Cell6, "干扰源类型", cellStyle); setCellStyle(r1Cell6, "干扰源类型", cellStyle);
setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle); setCellStyle(r1Cell7, "监测点对象名称", cellStyle);
setCellStyle(r1Cell8, "持续时间(s)", cellStyle); setCellStyle(r1Cell8, "暂降(骤升)幅值(%)", cellStyle);
setCellStyle(r1Cell9, "暂态事件严重度", cellStyle); setCellStyle(r1Cell9, "持续时间(s)", cellStyle);
setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle); setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle);
List<DetailVO> severity = sheetDetailed(businessParam); List<DetailVO> severity = sheetDetailed(businessParam);
for (int i = 0; i < severity.size(); i++) { for (int i = 0; i < severity.size(); i++) {
@@ -1360,7 +1360,7 @@ public class ReportServiceImpl implements ReportService {
cell4.setCellValue(vo.getLineName()); cell4.setCellValue(vo.getLineName());
cell5.setCellValue(vo.getVoltageScale()); cell5.setCellValue(vo.getVoltageScale());
cell6.setCellValue(vo.getLoadType()); cell6.setCellValue(vo.getLoadType());
cell7.setCellValue(vo.getObjName()); cell7.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
cell8.setCellValue(vo.getFeatureAmplitude()*100); cell8.setCellValue(vo.getFeatureAmplitude()*100);
cell9.setCellValue(vo.getDuration()); cell9.setCellValue(vo.getDuration());
cell10.setCellValue(vo.getAdvanceType()); cell10.setCellValue(vo.getAdvanceType());
@@ -1370,11 +1370,11 @@ public class ReportServiceImpl implements ReportService {
public void sheet5(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ public void sheet5(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂降次数统计"); sheets.createSheet("暂降次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(4); HSSFSheet sheetAt = sheets.getSheetAt(4);
sheetAt.setColumnWidth(0, 9 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 30 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256); sheetAt.setColumnWidth(3, 50 * 256);
sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(4, 44 * 256);
sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
@@ -1427,7 +1427,7 @@ public class ReportServiceImpl implements ReportService {
cell0.setCellValue(i+1); cell0.setCellValue(i+1);
cell1.setCellValue(vo.getLineName()); cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType()); cell2.setCellValue(vo.getLoadType());
cell3.setCellValue(vo.getObjName()); cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
cell4.setCellValue(vo.getSubName()); cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName()); cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes()); cell6.setCellValue(vo.getTimes());
@@ -1437,11 +1437,11 @@ public class ReportServiceImpl implements ReportService {
public void sheet6(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ public void sheet6(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("暂升次数统计"); sheets.createSheet("暂升次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(5); HSSFSheet sheetAt = sheets.getSheetAt(5);
sheetAt.setColumnWidth(0, 9 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 30 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256); sheetAt.setColumnWidth(3, 50 * 256);
sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(4, 44 * 256);
sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
@@ -1494,7 +1494,7 @@ public class ReportServiceImpl implements ReportService {
cell0.setCellValue(i+1); cell0.setCellValue(i+1);
cell1.setCellValue(vo.getLineName()); cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType()); cell2.setCellValue(vo.getLoadType());
cell3.setCellValue(vo.getObjName()); cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
cell4.setCellValue(vo.getSubName()); cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName()); cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes()); cell6.setCellValue(vo.getTimes());
@@ -1504,11 +1504,11 @@ public class ReportServiceImpl implements ReportService {
public void sheet7(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){ public void sheet7(HSSFWorkbook sheets,HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle ,DeviceInfoParam.BusinessParam businessParam){
sheets.createSheet("短时中断次数统计"); sheets.createSheet("短时中断次数统计");
HSSFSheet sheetAt = sheets.getSheetAt(6); HSSFSheet sheetAt = sheets.getSheetAt(6);
sheetAt.setColumnWidth(0, 9 * 256); sheetAt.setColumnWidth(0, 24 * 256);
sheetAt.setColumnWidth(1, 24 * 256); sheetAt.setColumnWidth(1, 30 * 256);
sheetAt.setColumnWidth(2, 24 * 256); sheetAt.setColumnWidth(2, 24 * 256);
sheetAt.setColumnWidth(3, 24 * 256); sheetAt.setColumnWidth(3, 50 * 256);
sheetAt.setColumnWidth(4, 24 * 256); sheetAt.setColumnWidth(4, 44 * 256);
sheetAt.setColumnWidth(5, 24 * 256); sheetAt.setColumnWidth(5, 24 * 256);
sheetAt.setColumnWidth(6, 24 * 256); sheetAt.setColumnWidth(6, 24 * 256);
sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
@@ -1561,7 +1561,7 @@ public class ReportServiceImpl implements ReportService {
cell0.setCellValue(i+1); cell0.setCellValue(i+1);
cell1.setCellValue(vo.getLineName()); cell1.setCellValue(vo.getLineName());
cell2.setCellValue(vo.getLoadType()); cell2.setCellValue(vo.getLoadType());
cell3.setCellValue(vo.getObjName()); cell3.setCellValue(vo.getObjName()==null||vo.getObjName()==""?"/":vo.getObjName());
cell4.setCellValue(vo.getSubName()); cell4.setCellValue(vo.getSubName());
cell5.setCellValue(vo.getGdName()); cell5.setCellValue(vo.getGdName());
cell6.setCellValue(vo.getTimes()); cell6.setCellValue(vo.getTimes());

View File

@@ -2,11 +2,11 @@ package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharUtil; import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -18,6 +18,7 @@ import com.njcn.device.pq.pojo.dto.OverLimitLineDTO;
import com.njcn.device.pq.pojo.dto.PollutionParamDTO; import com.njcn.device.pq.pojo.dto.PollutionParamDTO;
import com.njcn.device.pq.pojo.dto.WarningSubstationDTO; import com.njcn.device.pq.pojo.dto.WarningSubstationDTO;
import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.harmonic.constant.Param; import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.mapper.RStatLimitTargetMapper; import com.njcn.harmonic.mapper.RStatLimitTargetMapper;
@@ -27,7 +28,6 @@ import com.njcn.harmonic.pojo.excel.monitor.MonitorExcel;
import com.njcn.harmonic.pojo.excel.monitor.OverLimitDays; import com.njcn.harmonic.pojo.excel.monitor.OverLimitDays;
import com.njcn.harmonic.pojo.excel.monitor.UTimes; import com.njcn.harmonic.pojo.excel.monitor.UTimes;
import com.njcn.harmonic.pojo.excel.substation.SubstationExcel; import com.njcn.harmonic.pojo.excel.substation.SubstationExcel;
import com.njcn.harmonic.pojo.po.EventDetail;
import com.njcn.harmonic.pojo.po.LimitTarget; import com.njcn.harmonic.pojo.po.LimitTarget;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
@@ -55,6 +55,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -132,7 +133,7 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
List<String> line = new ArrayList<>(), subInfo = new ArrayList<>(); List<String> line = new ArrayList<>(), subInfo = new ArrayList<>();
List<WarningSubstationDTO> substationDTOList = new ArrayList<>(); List<WarningSubstationDTO> substationDTOList = new ArrayList<>();
Map<String, List<RStatLimitRateDPO>> map = new HashMap<>(); Map<String, List<RStatLimitRateDPO>> map = new HashMap<>();
Map<String, List<com.njcn.event.pojo.po.EventDetail>> map2 = new HashMap<>(); Map<String, GeneralVO> map2 = new HashMap<>();
param.setServerName(generalInfo.getMicroServiceName()); param.setServerName(generalInfo.getMicroServiceName());
List<WarningSubstationVO> list = new ArrayList<>(); List<WarningSubstationVO> list = new ArrayList<>();
List<GeneralDeviceDTO> subList = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(param).getData(); List<GeneralDeviceDTO> subList = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(param).getData();
@@ -152,9 +153,9 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
if (!CollectionUtils.isEmpty(limitRateList)) { if (!CollectionUtils.isEmpty(limitRateList)) {
map = limitRateList.stream().collect(Collectors.groupingBy(RStatLimitRateDPO::getLineId)); map = limitRateList.stream().collect(Collectors.groupingBy(RStatLimitRateDPO::getLineId));
} }
List<com.njcn.event.pojo.po.EventDetail> eventDetailList = getEventDetail(line, param.getSearchBeginTime(), param.getSearchEndTime()); List<GeneralVO> eventDetailList = getEventDetail(line, param.getSearchBeginTime(), param.getSearchEndTime(), eventStatis);
if (!CollectionUtils.isEmpty(eventDetailList)) { if (!CollectionUtils.isEmpty(eventDetailList)) {
map2 = eventDetailList.stream().collect(Collectors.groupingBy(com.njcn.event.pojo.po.EventDetail::getLineId)); map2 = eventDetailList.stream().collect(Collectors.toMap(GeneralVO::getId, Function.identity()));
} }
} }
for (GeneralDeviceDTO item : temList) { for (GeneralDeviceDTO item : temList) {
@@ -213,27 +214,15 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
} }
} }
//暂降统计 //暂降统计
if (!CollectionUtils.isEmpty(map2.get(item2))) { if (ObjectUtil.isNotNull(map2.get(item2))) {
List<com.njcn.event.pojo.po.EventDetail> eventDetailList = map2.get(item2); GeneralVO eventDetailList = map2.get(item2);
if (!CollectionUtils.isEmpty(eventDetailList)) { if (ObjectUtil.isNotNull(eventDetailList)) {
for (com.njcn.event.pojo.po.EventDetail item3 : eventDetailList) { //电压暂降
String eventType = item3.getEventType(); eventDowns += eventDetailList.getSagsCount();
List<String> code = eventStatis.stream().filter(x -> x.getId().equals(eventType)) //电压暂升
.map(DictData::getCode).collect(Collectors.toList()); eventUps += eventDetailList.getUpCount();
if (CollUtil.isNotEmpty(code)) { //电压暂升
if (DicDataEnum.VOLTAGE_DIP.getCode().equals(code.get(0))) { eventInterrupts += eventDetailList.getBreakCount();
eventDowns++;
}
if (DicDataEnum.VOLTAGE_RISE.getCode().equals(code.get(0))) {
eventUps++;
}
if (DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(code.get(0))) {
eventInterrupts++;
}
}
}
} }
} }
if (eventDowns > 0) { if (eventDowns > 0) {
@@ -781,8 +770,16 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
return result; return result;
} }
public List<com.njcn.event.pojo.po.EventDetail> getEventDetail(List<String> list, String startTime, String endTime) { public List<GeneralVO> getEventDetail(List<String> list, String startTime, String endTime, List<DictData> eventStatis) {
return eventDetailFeignClient.getEventDetail(list, startTime, endTime).getData(); Map<String, String> dictMap = eventStatis.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
HashMap<String, Object> condMap = new HashMap<>();
condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(startTime)).toString());
condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(endTime)).toString());
condMap.put("ids", list);
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())); //电压暂升
return eventDetailFeignClient.getEventDetailCount(condMap).getData();
} }
public List<LimitTarget> getOverDays(List<String> list, String startTime, String endTime) { public List<LimitTarget> getOverDays(List<String> list, String startTime, String endTime) {