1.暂降概览下穿页面接口

This commit is contained in:
2025-11-26 08:43:19 +08:00
parent 85ae7e7ddb
commit 02e5100426
9 changed files with 229 additions and 80 deletions

View File

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
@@ -60,6 +61,8 @@ public class DataGroupEventVO {
@ApiModelProperty("暂降幅值") @ApiModelProperty("暂降幅值")
private Float featureAmplitude; private Float featureAmplitude;
private Double amplitude;
@ApiModelProperty("波形路径") @ApiModelProperty("波形路径")
private String wavePath; private String wavePath;

View File

@@ -5,16 +5,30 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.List;
/** /**
* @Author: cdf * @Author: cdf
* @CreateTime: 2025-11-24 * @CreateTime: 2025-11-24
* @Description: * @Description:
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class EventCoordsVO { public class EventCoordsVO {
@ApiModelProperty(name = "xList",value = "下面的图x轴")
private List<String> xList;
@ApiModelProperty(name = "trendList",value = "下面的图y轴")
private List<TagObj> trendList;
@ApiModelProperty(name = "innerList",value = "xyz图")
private List<inner> innerList;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class inner {
@ApiModelProperty(name = "x",value = "x轴") @ApiModelProperty(name = "x",value = "x轴")
private Integer x; private Integer x;
@@ -23,4 +37,17 @@ public class EventCoordsVO {
@ApiModelProperty(name = "z",value = "z轴") @ApiModelProperty(name = "z",value = "z轴")
private Integer z; private Integer z;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TagObj {
@ApiModelProperty(name = "name",value = "名称")
private String name;
@ApiModelProperty(name = "trendList",value = "y轴数据")
private List<Integer> trendList;
}
} }

View File

@@ -1,8 +1,11 @@
package com.njcn.csharmonic.pojo.vo.event; package com.njcn.csharmonic.pojo.vo.event;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
/** /**
* @Author: cdf * @Author: cdf
@@ -12,13 +15,21 @@ import java.math.BigDecimal;
@Data @Data
public class F47Curve { public class F47Curve {
private String id; @ApiModelProperty(name = "eventId", value = "暂降id")
private String eventId;
@ApiModelProperty(name = "time", value = "事件发生时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS",timezone = "GMT+8")
private LocalDateTime time;
@ApiModelProperty(name = "tag", value = "事件类型")
private String tag; private String tag;
@ApiModelProperty(name = "persistTime", value = "持续时间ms")
private BigDecimal persistTime; private BigDecimal persistTime;
private BigDecimal amplitude; @ApiModelProperty(name = "eventValue", value = "特征幅值")
private BigDecimal eventValue;
} }

View File

@@ -11,6 +11,7 @@ import com.njcn.csharmonic.param.CldEventParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.param.DataParam; import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
@@ -65,6 +66,15 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/pageEvent")
@ApiOperation("分页查询暂降事件")
public HttpResult<Page<DataGroupEventVO>> pageEvent(@RequestBody EventStatisticParam baseParam) {
String methodDescribe = getMethodDescribe("pageEvent");
Page<DataGroupEventVO> page = csEventPOService.pageEvent(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/analyseWave") @GetMapping("/analyseWave")
@ApiOperation("暂态事件波形分析") @ApiOperation("暂态事件波形分析")

View File

@@ -84,10 +84,10 @@ public class EventOverviewController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventCoords") @PostMapping("/getEventCoords")
@ApiOperation("获取电压暂态表及密度坐标图") @ApiOperation("获取电压暂态表及密度坐标图")
public HttpResult<List<EventCoordsVO>> getEventCoords(@RequestBody EventStatisticParam baseParam){ public HttpResult<EventCoordsVO> getEventCoords(@RequestBody EventStatisticParam baseParam){
String methodDescribe = getMethodDescribe("getEventCoords"); String methodDescribe = getMethodDescribe("getEventCoords");
List<EventCoordsVO> list = eventOverviewService.getEventCoords(baseParam); EventCoordsVO vo = eventOverviewService.getEventCoords(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,list,methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,vo,methodDescribe);
} }

View File

@@ -7,11 +7,13 @@ import com.njcn.csharmonic.param.CldEventParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.param.DataParam; import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.pojo.vo.EventStatisticsVo; import com.njcn.csharmonic.pojo.vo.EventStatisticsVo;
import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.file.pojo.dto.WaveDataDTO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -51,6 +53,8 @@ public interface CsEventPOService extends IService<CsEventPO>{
Page<DataGroupEventVO> pageQueryByLineId(CsEventUserQueryPage csEventUserQueryPage); Page<DataGroupEventVO> pageQueryByLineId(CsEventUserQueryPage csEventUserQueryPage);
Page<DataGroupEventVO> pageEvent(EventStatisticParam baseParam);
void saveBatchEventList(List<CsEventPO> csEventPOS); void saveBatchEventList(List<CsEventPO> csEventPOS);
void getFileZip(String eventId,HttpServletResponse response); void getFileZip(String eventId,HttpServletResponse response);

View File

@@ -27,5 +27,5 @@ public interface EventOverviewService {
List<EventStatisticVO> getEventDate(EventStatisticParam baseParam); List<EventStatisticVO> getEventDate(EventStatisticParam baseParam);
List<EventCoordsVO> getEventCoords(EventStatisticParam baseParam); EventCoordsVO getEventCoords(EventStatisticParam baseParam);
} }

View File

@@ -19,11 +19,13 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.DevDetailDTO; import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO; import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.enums.CsEventEnum;
import com.njcn.csharmonic.mapper.CsEventPOMapper; import com.njcn.csharmonic.mapper.CsEventPOMapper;
import com.njcn.csharmonic.param.CldEventParam; import com.njcn.csharmonic.param.CldEventParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.param.DataParam; import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
@@ -48,6 +50,7 @@ import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient; import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -73,6 +76,8 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.njcn.csharmonic.enums.CsTransientEnum.*;
/** /**
* Description: * Description:
* Date: 2023/9/4 15:15【需求编号】 * Date: 2023/9/4 15:15【需求编号】
@@ -166,6 +171,39 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return result; return result;
} }
@Override
public Page<DataGroupEventVO> pageEvent(EventStatisticParam baseParam) {
Page<DataGroupEventVO> result = new Page<>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam));
DateTime begin = DateUtil.parse(baseParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN);
DateTime end = DateUtil.parse(baseParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN);
List<String> EVENT_TAGS = Arrays.asList(
EVT_SYS_DIPSTR.getCode(),
EVT_SYS_INTRSTRr.getCode(),
EVT_SYS_SWLSTR.getCode()
);
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StrUtil.isNotBlank(baseParam.getLineId()),CsEventPO::getLineId,baseParam.getLineId())
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
.in(CsEventPO::getTag, EVENT_TAGS)
.between(CsEventPO::getStartTime,begin,end)
.orderByDesc(CsEventPO::getStartTime);
Page<CsEventPO> page = this.page(new Page<>(PageFactory.getPageNum(baseParam),PageFactory.getPageSize(baseParam)),lambdaQueryWrapper);
if(CollUtil.isNotEmpty(page.getRecords())){
List<String> ids = page.getRecords().stream().map(CsEventPO::getLineId).distinct().collect(Collectors.toList());
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(ids).getData();
Map<String,String> linePOMap = csLinePOList.stream().collect(Collectors.toMap(CsLinePO::getLineId, CsLinePO::getName));
List<DataGroupEventVO> dataGroupEventVOList = BeanUtil.copyToList(page.getRecords(),DataGroupEventVO.class);
dataGroupEventVOList.forEach(item->item.setLineName(linePOMap.getOrDefault(item.getLineId(),"/")));
result.setRecords(dataGroupEventVOList);
result.setTotal(page.getTotal());
}
return result;
}
@Override @Override
@Transactional @Transactional
public void saveBatchEventList(List<CsEventPO> csEventPOS) { public void saveBatchEventList(List<CsEventPO> csEventPOS) {

View File

@@ -3,6 +3,7 @@ package com.njcn.csharmonic.service.impl.event;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.*; import cn.hutool.core.date.*;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@@ -24,8 +25,14 @@ import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import static com.njcn.csharmonic.enums.CsTransientEnum.*;
/** /**
* @Author: cdf * @Author: cdf
@@ -36,9 +43,9 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class EventOverviewServiceImpl implements EventOverviewService { public class EventOverviewServiceImpl implements EventOverviewService {
private static final List<String> EVENT_TAGS = Arrays.asList( private static final List<String> EVENT_TAGS = Arrays.asList(
CsTransientEnum.EVT_SYS_DIPSTR.getCode(), EVT_SYS_DIPSTR.getCode(),
CsTransientEnum.EVT_SYS_INTRSTRr.getCode(), EVT_SYS_INTRSTRr.getCode(),
CsTransientEnum.EVT_SYS_SWLSTR.getCode() EVT_SYS_SWLSTR.getCode()
); );
private final CsEventPOService csEventPOService; private final CsEventPOService csEventPOService;
@@ -47,26 +54,29 @@ public class EventOverviewServiceImpl implements EventOverviewService {
@Override @Override
public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) { public EventStatisticVO netEventEcharts(EventStatisticParam baseParam) {
EventStatisticVO result = new EventStatisticVO();
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
if(CollUtil.isEmpty(ids)){
return result;
}
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery() List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery()
.between(CsEventPO::getStartTime, start, end) .between(CsEventPO::getStartTime, start, end)
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
.in(CsEventPO::getTag, EVENT_TAGS) .in(CsEventPO::getTag, EVENT_TAGS)
//TODO // .in(CsEventPO::getLineId,ids)
.list(); .list();
EventStatisticVO result = new EventStatisticVO();
if (CollUtil.isEmpty(csEventPOList)) { if (CollUtil.isEmpty(csEventPOList)) {
return result; return result;
} }
Map<String, Long> eventCountByTag = csEventPOList.stream().collect(Collectors.groupingBy(CsEventPO::getTag, Collectors.counting())); Map<String, Long> eventCountByTag = csEventPOList.stream().collect(Collectors.groupingBy(CsEventPO::getTag, Collectors.counting()));
result.setEventDown(eventCountByTag.getOrDefault(CsTransientEnum.EVT_SYS_DIPSTR.getCode(), 0L).intValue()); result.setEventDown(eventCountByTag.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
result.setEventOff(eventCountByTag.getOrDefault(CsTransientEnum.EVT_SYS_INTRSTRr.getCode(), 0L).intValue()); result.setEventOff(eventCountByTag.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
result.setEventUp(eventCountByTag.getOrDefault(CsTransientEnum.EVT_SYS_SWLSTR.getCode(), 0L).intValue()); result.setEventUp(eventCountByTag.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
result.setAllNum(csEventPOList.size()); result.setAllNum(csEventPOList.size());
return result; return result;
} }
@@ -76,13 +86,13 @@ public class EventOverviewServiceImpl implements EventOverviewService {
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
List<String> lineIds = StrUtil.isBlank(baseParam.getSearchValue()) List<String> lineIds = StrUtil.isBlank(baseParam.getSearchValue())
? csLineFeignClient.getAllLine().getData() ? csLineFeignClient.getAllLine().getData()
: Collections.singletonList(baseParam.getSearchValue()); : Collections.singletonList(baseParam.getSearchValue());
if(CollUtil.isEmpty(lineIds)){
return Collections.emptyList();
}
List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(lineIds).getData(); List<CsLinePO> csLinePOList = csLineFeignClient.queryLineById(lineIds).getData();
if (CollUtil.isEmpty(csLinePOList)) { if (CollUtil.isEmpty(csLinePOList)) {
return Collections.emptyList(); return Collections.emptyList();
@@ -126,9 +136,9 @@ public class EventOverviewServiceImpl implements EventOverviewService {
vo.setName(line.getName()); vo.setName(line.getName());
Map<String, Long> lineEvents = eventCountByLineAndTag.getOrDefault(line.getLineId(), Collections.emptyMap()); Map<String, Long> lineEvents = eventCountByLineAndTag.getOrDefault(line.getLineId(), Collections.emptyMap());
vo.setEventDown(lineEvents.getOrDefault(CsTransientEnum.EVT_SYS_DIPSTR.getCode(), 0L).intValue()); vo.setEventDown(lineEvents.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
vo.setEventOff(lineEvents.getOrDefault(CsTransientEnum.EVT_SYS_INTRSTRr.getCode(), 0L).intValue()); vo.setEventOff(lineEvents.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
vo.setEventUp(lineEvents.getOrDefault(CsTransientEnum.EVT_SYS_SWLSTR.getCode(), 0L).intValue()); vo.setEventUp(lineEvents.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
return vo; return vo;
}).sorted(Comparator.comparing(EventStatisticVO::getEventDown, Comparator.reverseOrder()) }).sorted(Comparator.comparing(EventStatisticVO::getEventDown, Comparator.reverseOrder())
@@ -141,22 +151,25 @@ public class EventOverviewServiceImpl implements EventOverviewService {
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); /* List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
if(CollUtil.isEmpty(ids)){
return Collections.emptyList();
}*/
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getStartTime,CsEventPO::getTag,CsEventPO::getPersistTime,CsEventPO::getAmplitude)
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getPersistTime,CsEventPO::getAmplitude)
.between(CsEventPO::getStartTime, start, end) .between(CsEventPO::getStartTime, start, end)
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
.in(CsEventPO::getTag, EVENT_TAGS) .in(CsEventPO::getTag, EVENT_TAGS)
//TODO // .in(CsEventPO::getLineId,ids)
.list(); .list();
List<F47Curve> f47CurveList = csEventPOList.stream().map(item->{ List<F47Curve> f47CurveList = csEventPOList.stream().map(item->{
F47Curve f47Curve = new F47Curve(); F47Curve f47Curve = new F47Curve();
f47Curve.setId(item.getId()); f47Curve.setEventId(item.getId());
f47Curve.setTime(item.getStartTime());
f47Curve.setTag(item.getTag()); f47Curve.setTag(item.getTag());
f47Curve.setPersistTime(BigDecimal.valueOf(item.getPersistTime())); f47Curve.setPersistTime(BigDecimal.valueOf(item.getPersistTime()).setScale(3, RoundingMode.HALF_UP));
f47Curve.setAmplitude(BigDecimal.valueOf(item.getAmplitude())); f47Curve.setEventValue(BigDecimal.valueOf(item.getAmplitude()));
return f47Curve; return f47Curve;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return f47CurveList; return f47CurveList;
@@ -167,21 +180,20 @@ public class EventOverviewServiceImpl implements EventOverviewService {
if(StrUtil.isBlank(baseParam.getSearchBeginTime())){ if(StrUtil.isBlank(baseParam.getSearchBeginTime())){
throw new BusinessException(CommonResponseEnum.FAIL,"月份不可为空"); throw new BusinessException(CommonResponseEnum.FAIL,"月份不可为空");
} }
DateTime dateTime = DateUtil.parse(baseParam.getSearchBeginTime(), DatePattern.NORM_MONTH_PATTERN); DateTime dateTime = DateUtil.parse(baseParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN);
DateTime start = DateUtil.beginOfMonth(dateTime); DateTime start = DateUtil.beginOfMonth(dateTime);
DateTime end = DateUtil.endOfMonth(dateTime); DateTime end = DateUtil.endOfMonth(dateTime);
List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); /* List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
if(CollUtil.isEmpty(ids)){
return Collections.emptyList();
}*/
List<DateTime> rangList = DateUtil.rangeToList(start,end, DateField.DAY_OF_MONTH); List<DateTime> rangList = DateUtil.rangeToList(start,end, DateField.DAY_OF_MONTH);
List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getStartTime,CsEventPO::getPersistTime,CsEventPO::getAmplitude) List<CsEventPO> csEventPOList = csEventPOService.lambdaQuery().select(CsEventPO::getId,CsEventPO::getTag,CsEventPO::getStartTime,CsEventPO::getPersistTime,CsEventPO::getAmplitude)
.between(CsEventPO::getStartTime, start, end) .between(CsEventPO::getStartTime, start, end)
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
.in(CsEventPO::getTag, EVENT_TAGS) .in(CsEventPO::getTag, EVENT_TAGS)
//TODO // .in(CsEventPO::getLineId,ids)
.list(); .list();
if(CollUtil.isEmpty(csEventPOList)){ if(CollUtil.isEmpty(csEventPOList)){
@@ -203,22 +215,31 @@ public class EventOverviewServiceImpl implements EventOverviewService {
eventStatisticVO.setName(day); eventStatisticVO.setName(day);
Map<String,Long> itemMap = map.getOrDefault(day,Collections.emptyMap()); Map<String,Long> itemMap = map.getOrDefault(day,Collections.emptyMap());
eventStatisticVO.setEventDown(itemMap.getOrDefault(CsTransientEnum.EVT_SYS_DIPSTR.getCode(), 0L).intValue()); eventStatisticVO.setEventDown(itemMap.getOrDefault(EVT_SYS_DIPSTR.getCode(), 0L).intValue());
eventStatisticVO.setEventOff(itemMap.getOrDefault(CsTransientEnum.EVT_SYS_INTRSTRr.getCode(), 0L).intValue()); eventStatisticVO.setEventOff(itemMap.getOrDefault(EVT_SYS_INTRSTRr.getCode(), 0L).intValue());
eventStatisticVO.setEventUp(itemMap.getOrDefault(CsTransientEnum.EVT_SYS_SWLSTR.getCode(), 0L).intValue()); eventStatisticVO.setEventUp(itemMap.getOrDefault(EVT_SYS_SWLSTR.getCode(), 0L).intValue());
return eventStatisticVO; return eventStatisticVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override @Override
public List<EventCoordsVO> getEventCoords(EventStatisticParam baseParam) { public EventCoordsVO getEventCoords(EventStatisticParam baseParam) {
EventCoordsVO eventCoordsVO = new EventCoordsVO();
// 初始化结果列表 // 初始化结果列表
List<EventCoordsVO> result = new ArrayList<>(90); List<EventCoordsVO.inner> result = new ArrayList<>(50);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 5; j++) {
result.add(new EventCoordsVO(i, j, 0)); result.add(new EventCoordsVO.inner(i, j, 0));
} }
} }
/* List<String> ids = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
if(CollUtil.isEmpty(ids)){
return result;
}*/
//查询监测点未处理暂态事件 //查询监测点未处理暂态事件
DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())); DateTime start = DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime()));
DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())); DateTime end = DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime()));
@@ -226,62 +247,95 @@ public class EventOverviewServiceImpl implements EventOverviewService {
.between(CsEventPO::getStartTime, start, end) .between(CsEventPO::getStartTime, start, end)
.eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode()) .eq(CsEventPO::getType, CsEventEnum.EVENT_TYPE.getCode())
.in(CsEventPO::getTag, EVENT_TAGS) .in(CsEventPO::getTag, EVENT_TAGS)
//TODO // .in(CsEventPO::getLineId,ids)
.list(); .list();
// 定义幅值和持续时间的分类规则 // 定义幅值和持续时间的分类规则
Map<Double, Integer> amplitudeRanges = ImmutableMap.<Double, Integer>builder() Map<Double, Integer> amplitudeRanges = ImmutableMap.<Double, Integer>builder()
.put(0.0, 0) .put(0.0, 0)
.put(0.1, 1) .put(10.0, 1)
.put(0.2, 2) .put(20.0, 2)
.put(0.3, 3) .put(30.0, 3)
.put(0.4, 4) .put(40.0, 4)
.put(0.5, 5) .put(50.0, 5)
.put(0.6, 6) .put(60.0, 6)
.put(0.7, 7) .put(70.0, 7)
.put(0.8, 8) .put(80.0, 8)
.put(0.9, 9) .put(90.0, 9)
// 默认分类 // 默认分类
.put(Double.MAX_VALUE, 10) .put(Double.MAX_VALUE, 10)
.build(); .build();
// 持续时间分类规则 // 持续时间分类规则
Map<Double, Integer> persistTimeRanges = ImmutableMap.<Double, Integer>builder() Map<Double, Integer> persistTimeRanges = ImmutableMap.<Double, Integer>builder()
.put(0.0, 0) .put(0.01, 0)
.put(0.020, 1) .put(0.1, 1)
.put(0.040, 2) .put(1.0, 2)
.put(0.060, 3) .put(10.0, 3)
.put(0.080, 4) .put(1000.0, 4)
.put(0.120, 5) .build();
.put(0.200, 6)
.put(0.400, 7) // 时间段分类规则
.put(0.600, 8) Map<Double, Integer> startTimeRanges = ImmutableMap.<Double, Integer>builder()
.put(1.200, 9) .put(8.0, 0)
.put(12.0, 1)
.put(14.0, 2)
.put(18.0, 3)
.put(24.0, 4)
.build(); .build();
// 分类事件 // 分类事件
// 0:down, 1:off, 2:up
List<Integer>[] timeSegmentStats = new List[3];
for (int i = 0; i < timeSegmentStats.length; i++) {
timeSegmentStats[i] = IntStream.range(0, 5).boxed().collect(Collectors.toList());
}
for (CsEventPO event : events) { for (CsEventPO event : events) {
double amplitude = event.getAmplitude(); double amplitude = event.getAmplitude();
double persistTimeSec = event.getPersistTime() / 1000.0; double persistTimeSec = event.getPersistTime();
// 确定幅分类 // 确定幅分类
int amplitudeGroup = getRangeGroup(amplitudeRanges, amplitude); int amplitudeGroup = getRangeGroup(amplitudeRanges, amplitude);
// 确定持续时间分类(幅分类作为行,持续时间分类作为列) // 确定持续时间分类(幅分类作为行,持续时间分类作为列)
int persistTimeGroup = getRangeGroup(persistTimeRanges, persistTimeSec); int persistTimeGroup = getRangeGroup(persistTimeRanges, persistTimeSec);
// 计算索引:行 = 幅分组,列 = 持续时间分组 // 计算索引:行 = 幅分组,列 = 持续时间分组
int row = amplitudeGroup; int row = amplitudeGroup;
int col = persistTimeGroup; int col = persistTimeGroup;
// 10行 x 9列的网格 // 10行 x 5列的网格
int index = row * 9 + col; int index = row * 5 + col;
// 安全更新结果
if (index >= 0 && index < result.size()) { if (index >= 0 && index < result.size()) {
EventCoordsVO coordsVO = result.get(index); EventCoordsVO.inner inner = result.get(index);
coordsVO.setZ(coordsVO.getZ() + 1); inner.setZ(inner.getZ() + 1);
}
int hour = event.getStartTime().getHour();
int startTimeGroup = getRangeGroup(startTimeRanges, hour);
String tag = event.getTag();
if (EVT_SYS_DIPSTR.getCode().equals(tag)) {
timeSegmentStats[0].set(startTimeGroup, timeSegmentStats[0].get(startTimeGroup) + 1);
} else if (EVT_SYS_INTRSTRr.getCode().equals(tag)) {
timeSegmentStats[1].set(startTimeGroup, timeSegmentStats[1].get(startTimeGroup) + 1);
} else if (EVT_SYS_SWLSTR.getCode().equals(tag)) {
timeSegmentStats[2].set(startTimeGroup, timeSegmentStats[2].get(startTimeGroup) + 1);
} }
} }
return result; eventCoordsVO.setInnerList(result);
List<String> xList = Stream.of("0时-8时","8时-12时","12时-14时","14时-18时","18时-24时").collect(Collectors.toList());
List<EventCoordsVO.TagObj> trendList = Arrays.asList(
new EventCoordsVO.TagObj(EVT_SYS_DIPSTR.getCode(),
timeSegmentStats[0]),
new EventCoordsVO.TagObj(EVT_SYS_INTRSTRr.getCode(),
timeSegmentStats[1]),
new EventCoordsVO.TagObj(EVT_SYS_SWLSTR.getCode(),
timeSegmentStats[2])
);
eventCoordsVO.setXList(xList);
eventCoordsVO.setTrendList(trendList);
return eventCoordsVO;
} }
/** /**
@@ -296,4 +350,6 @@ public class EventOverviewServiceImpl implements EventOverviewService {
// 默认返回最大分组 // 默认返回最大分组
return ranges.size() - 1; return ranges.size() - 1;
} }
} }