Browse Source

#数据填报

zhongwei
yang_shj 2 years ago
parent
commit
c324a96e63
  1. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java
  3. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java
  4. 128
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  5. 21
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/AlarmDataPageVo.java
  6. 57
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/AlarmVo.java
  7. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/IntelligentAlarmCountVo.java

4
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java

@ -1,6 +1,5 @@
package com.hnac.hzims.operational.alert.constants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -12,4 +11,7 @@ public interface AbnormalAlarmConstant {
List<String> TYPE_LIST = Arrays.asList("13","14");
String ABNORMAL_STATUS = "1";
String TYPE_NAMES[] = {"默认", "系统", "告警", "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"};
}

38
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java

@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
import com.hnac.hzims.operational.config.vo.AlarmDataPageVo;
import com.hnac.hzims.operational.config.vo.AlarmVo;
import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo;
import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -18,6 +21,7 @@ import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@Api(tags = {"通讯中断、数据异常"})
@RestController
@ -30,7 +34,7 @@ public class AbnormalAlarmController extends BladeController {
* 统计通讯中断时间
*/
@GetMapping("/statisticsTime")
@ApiOperationSupport(order = 2)
@ApiOperationSupport(order = 0)
@ApiOperation(value = "统计通讯中断时间", notes = "传入imsDutyMainEntity")
public R<IPage<HistoryAbnormalAlarmVo>> statisticsTime(HistoryAbnormalAlarmEntity entity, Query query) {
IPage<HistoryAbnormalAlarmVo> pages = service.getAlarmTime(query,entity);
@ -41,7 +45,7 @@ public class AbnormalAlarmController extends BladeController {
* 统计通讯中断二级目录查询
*/
@GetMapping("/queryByEntity")
@ApiOperationSupport(order = 2)
@ApiOperationSupport(order = 1)
@ApiOperation(value = "统计通讯中断二级目录查询", notes = "传入imsDutyMainEntity")
public R<IPage<HistoryAbnormalAlarmEntity>> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) {
IPage<HistoryAbnormalAlarmEntity> pages = service.queryByEntity(entity,query);
@ -52,7 +56,7 @@ public class AbnormalAlarmController extends BladeController {
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperationSupport(order = 2)
@ApiOperation(value = "详情", notes = "传入HistoryAbnormalAlarmEntity")
public R<HistoryAbnormalAlarmEntity> detail(HistoryAbnormalAlarmEntity entity) {
HistoryAbnormalAlarmEntity detail = service.getOne(Condition.getQueryWrapper(entity));
@ -63,7 +67,7 @@ public class AbnormalAlarmController extends BladeController {
* 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@ApiOperationSupport(order = 3)
@ApiOperation(value = "分页", notes = "传入HistoryAbnormalAlarmEntity")
public R<IPage<HistoryAbnormalAlarmEntity>> list(HistoryAbnormalAlarmEntity entity, Query query) {
IPage<HistoryAbnormalAlarmEntity> pages = service.page(Condition.getPage(query), Condition.getQueryWrapper(entity));
@ -74,7 +78,7 @@ public class AbnormalAlarmController extends BladeController {
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增或修改", notes = "传入HistoryAbnormalAlarmEntity")
public R submit(@Valid @RequestBody HistoryAbnormalAlarmEntity entity) {
return R.status(service.saveOrUpdate(entity));
@ -85,9 +89,31 @@ public class AbnormalAlarmController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperationSupport(order = 5)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(service.deleteLogic(Func.toLongList(ids)));
}
/**
* 智能告警数量: 时间范围当天
*/
@ApiOperation(value = "智能告警数量")
@ApiOperationSupport(order = 6)
@RequestMapping(value = "/count", method = {RequestMethod.GET, RequestMethod.POST})
public R<List<IntelligentAlarmCountVo>> count(){
return R.data(service.alarmCount());
}
/**
* 智能告警数据: 时间范围当天
*/
@ApiOperation(value = "智能告警数据")
@ApiOperationSupport(order = 7)
@RequestMapping(value = "/data", method = RequestMethod.GET)
public R<IPage<AlarmVo>> data(AlarmDataPageVo page,Query query) {
return R.data(service.alarmData(page,query));
}
}

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java

@ -2,6 +2,9 @@ package com.hnac.hzims.operational.alert.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.config.vo.AlarmDataPageVo;
import com.hnac.hzims.operational.config.vo.AlarmVo;
import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo;
import com.hnac.hzims.operational.fill.vo.OverConfigVo;
import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo;
import org.springblade.core.mp.base.BaseService;
@ -9,6 +12,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import java.util.Date;
import java.util.List;
/**
* 告警处理接口
@ -22,4 +26,10 @@ public interface HistoryAbnormalAlarmService extends BaseService<HistoryAbnormal
IPage<HistoryAbnormalAlarmVo> getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity);
IPage<HistoryAbnormalAlarmEntity> queryByEntity(HistoryAbnormalAlarmEntity entity,Query query);
// 智能告警数量: 时间范围当天
List<IntelligentAlarmCountVo> alarmCount();
// 告警数据:时间范围-当天
IPage<AlarmVo> alarmData(AlarmDataPageVo page,Query query);
}

128
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -3,26 +3,45 @@ package com.hnac.hzims.operational.alert.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity;
import com.hnac.hzims.operational.config.vo.AlarmDataPageVo;
import com.hnac.hzims.operational.config.vo.AlarmVo;
import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo;
import com.hnac.hzims.operational.config.vo.SoeBodyVo;
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo;
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.BladePage;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -36,6 +55,11 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
private final IStationService stationService;
private final ISoeClient alarmClient;
@Value("${hzims.operation.alarm.types}")
private String types;
/**
* 查询单条历史告警
* @param station
@ -151,4 +175,108 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
return historyAbnormalAlarmEntityIPage;
}
/**
* 告警数量:时间范围-当天
* @return
*/
@Override
public List<IntelligentAlarmCountVo> alarmCount() {
// 步骤1.查询用户权限站点
List<StationEntity> stations = stationService.list();
// 步骤2.查询告警数据
SoeQueryConditionByStation condition = new SoeQueryConditionByStation();
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format));
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format));
condition.setNeedPage(false);
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList()));
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
condition.setTypes(Arrays.asList(types.split(",")));
R<BladePage<SoeData>> result = alarmClient.getByStationsAndTime(condition);
// 步骤3. TODO 过滤已处理告警
// 步骤4.遍历获取
return Arrays.asList(types.split(",")).stream().map(type->{
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo();
count.setType(type);
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(type)]);
if(result.isSuccess() && !ObjectUtil.isEmpty(result.getData())){
count.setCount(result.getData().getRecords().stream().filter(record->type.equals(record.getSoeType())).count());
}else {
count.setCount(0L);
}
return count;
}).collect(Collectors.toList());
}
/**
* 告警数据:时间范围-当天
* @param param
* @param query
* @return
*/
@Override
public IPage<AlarmVo> alarmData(AlarmDataPageVo param,Query query) {
// 步骤1.查询用户权限站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
if(StringUtils.isNotEmpty(param.getCode())){
wappers.eq(StationEntity::getCode,param.getCode());
}
List<StationEntity> stations = stationService.list(wappers);
// 步骤2.查询告警数据
List<String> type_list;
if(Optional.ofNullable(param.getType()).isPresent()){
type_list = Collections.singletonList(param.getType());
}else {
type_list = Collections.singletonList(Arrays.asList(types.split(",")).get(0));
}
SoeQueryConditionByStation condition = new SoeQueryConditionByStation();
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME);
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format));
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format));
condition.setNeedPage(false);
condition.setStationIds(stations.stream().filter(station->StringUtils.isNotEmpty(station.getCode())).map(StationEntity::getCode).collect(Collectors.toList()));
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
condition.setTypes(type_list);
R<BladePage<SoeData>> result = alarmClient.getByStationsAndTime(condition);
IPage<AlarmVo> page = Condition.getPage(query);
if(result.isSuccess() && ObjectUtil.isNotEmpty(result)){
// 步骤3.TODO 过滤完成告警处理数据
List<AlarmVo> alarms = result.getData().getRecords().stream().map(record ->{
AlarmVo alarm = new AlarmVo();
alarm.setId(record.getId());
alarm.setContent(record.getSoeExplain());
alarm.setRealId(record.getRealId());
alarm.setTs(record.getTs());
alarm.setSoeStatus(record.getSoeStatus());
alarm.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(record.getSoeType())]);
alarm.setOptionvals(record.getOptionvals());
alarm.setSoeStatus(record.getSoeStatus());
alarm.setStation(record.getStation());
List<String> names = stations.stream().filter(station -> station.getCode().equals(record.getStation())).map(StationEntity::getName).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(names)){
alarm.setStationName(names.get(0));
}
return alarm;
}).collect(Collectors.toList());
// 步骤4.分页
page.setTotal(alarms.size());
page.setRecords(alarms.stream().sorted(Comparator.comparing(AlarmVo::getTs,Comparator.reverseOrder()))
.skip((long) page.getSize() * (page.getCurrent() - 1)).limit(page.getSize())
.collect(Collectors.toList()));
page.setPages((alarms.size() -1) / page.getSize() + 1);
}else{
page.setTotal(0);
page.setPages(0);
}
return page;
}
}

21
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/AlarmDataPageVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.operational.config.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/03/16 10:06:33
* @version 4.0.0
*/
@Data
public class AlarmDataPageVo {
@ApiModelProperty(value = "类型")
private String type;
@ApiModelProperty(value = "过滤站点编码")
private String code;
}

57
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/AlarmVo.java

@ -0,0 +1,57 @@
package com.hnac.hzims.operational.config.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author ysj
* @date 2023/03/16 11:05:58
* @version 4.0.0
*/
@Data
public class AlarmVo {
@ApiModelProperty(value = "主键Id")
private Long id;
@ApiModelProperty(value = "站点变号")
private String station;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "监测点位")
private String realId;
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss.SSS"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss.SSS"
)
@ApiModelProperty(value = "告警发生时间")
private Date ts;
@ApiModelProperty(value = "事件状态")
private String soeStatus;
@Deprecated
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModelProperty(value = "事件类型")
private String soeType;
@ApiModelProperty(value = "事件值")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String optionvals;
@ApiModelProperty(value = "事件报警类型")
private String soeAlarmType;
}

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/IntelligentAlarmCountVo.java

@ -0,0 +1,28 @@
package com.hnac.hzims.operational.config.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.operational.main.vo.SoeDataVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
* @date 2023/03/16 10:06:33
* @version 4.0.0
*/
@Data
public class IntelligentAlarmCountVo {
@ApiModelProperty(value = "智能告警类型")
private String type;
@ApiModelProperty(value = "智能告警名称")
private String name;
@ApiModelProperty(value = "告警数量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long count;
}
Loading…
Cancel
Save