diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index 631f90b..173105d 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -18,9 +18,8 @@ public interface AbnormalAlarmConstant { String WEBSOCKET_FAULT = "3"; - List ALARM_WARN_TYPES = Arrays.asList("0","1","2"); - - String[] TYPE_NAMES = {"默认", "系统", "告警", "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"}; + String[] TYPE_NAMES = {"默认", "系统", "告警" + , "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"}; /**处理、延后、误报*/ List HANDLE_WAY = Arrays.asList(1L,2L,3L,4L); diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java new file mode 100644 index 0000000..30d8559 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.operational.alert.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +import java.util.Date; + +/** + * @author ysj + */ +@Data +@TableName("hzims_history_level_alarm") +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "数据中断告警对象") +public class HistoryLevelAlarmEntity extends BaseEntity { + + @ApiModelProperty("ID") + private Long id; + + @ApiModelProperty("站点编码") + private String stationId; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("告警编码") + private Long alarmId; + + @ApiModelProperty("检查点") + private String realId; + + @ApiModelProperty("告警开始时间") + private Date alarmTime; + + @ApiModelProperty("告警类型") + private String type; + + @ApiModelProperty("状态") + private Integer status; + + @ApiModelProperty("告警原因") + private String soeExplain; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java index 74a49b0..6371158 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java @@ -26,7 +26,7 @@ public class AlarmMergeVo{ private String realId; @ApiModelProperty("告警编号") - private String alarmCode; + private Long alarmCode; @ApiModelProperty("告警类型") private String type; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java index e5c525b..f2fbf01 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java @@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; +/** + * @author ysj + */ @Api(tags = {"通讯中断、数据异常"}) @RestController @AllArgsConstructor @@ -122,18 +125,6 @@ public class AbnormalAlarmController extends BladeController { } /** - * - */ - @ApiLog - @ApiOperation(value = "等级告警接口") - @ApiOperationSupport(order = 7) - @RequestMapping(value = "/terrace_alarms", method = {RequestMethod.GET, RequestMethod.POST}) - public R terrace_alarms(SoeParamVo param){ - return R.data(service.terrace_alarms(param)); - } - - - /** * 智能告警数量: 时间范围当天 */ @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java new file mode 100644 index 0000000..9947e90 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java @@ -0,0 +1,70 @@ +package com.hnac.hzims.operational.alert.controller; + + +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.entity.HistoryLevelAlarmEntity; +import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService; +import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.log.annotation.ApiLog; +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.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author ysj + */ +@Api(tags = {"等级告警"}) +@RestController +@AllArgsConstructor +@RequestMapping("/level/alarm") +public class LevelAlarmController extends BladeController { + + private HistoryLevelAlarmService service; + + /** + * 分页 + */ + @ApiLog + @GetMapping("/list") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "分页", notes = "传入HistoryAbnormalAlarmEntity") + public R> list(HistoryLevelAlarmEntity entity, Query query) { + IPage pages = service.pageCondition(query, entity); + return R.data(pages); + } + + + /** + * 删除 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(service.deleteLogic(Func.toLongList(ids))); + } + + /** + * 智能告警数量: 时间范围当天 + */ + @ApiLog + @ApiOperation(value = "智能告警数量") + @ApiOperationSupport(order = 3) + @RequestMapping(value = "/count", method = {RequestMethod.GET, RequestMethod.POST}) + public R> count(){ + return R.data(service.alarmCount()); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.java new file mode 100644 index 0000000..19eb927 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.operational.alert.mapper; + +import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author YSJ + */ +public interface HistoryLevelAlarmMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.xml new file mode 100644 index 0000000..40e7037 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryLevelAlarmMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java index 94ec897..f122e23 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java @@ -36,5 +36,4 @@ public interface HistoryAbnormalAlarmService extends BaseService queryStationName(); - SoeReustVo terrace_alarms(SoeParamVo param); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryLevelAlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryLevelAlarmService.java new file mode 100644 index 0000000..c0cffea --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryLevelAlarmService.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.operational.alert.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; +import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; + +import java.util.List; + +/** + * 等级告警数据查询 + * @author ysj + */ +public interface HistoryLevelAlarmService extends BaseService { + + + IPage pageCondition(Query query, HistoryLevelAlarmEntity entity); + + List alarmCount(); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java index 5398e76..6972275 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java @@ -80,7 +80,7 @@ public class AlertMerageServiceImpl implements AlarmMergeService { // 处理告警记录 List handles = alarmHandleService.list(Wrappers.lambdaQuery() .in(AlarmHandleEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) - .in(AlarmHandleEntity::getAlarmType, AbnormalAlarmConstant.ALARM_WARN_TYPES) + .in(AlarmHandleEntity::getAlarmType, AbnormalAlarmConstant.TYPE_LIST) .between(AlarmHandleEntity::getCreateTime,start,end) ); List alarms = new ArrayList<>(); @@ -94,6 +94,7 @@ public class AlertMerageServiceImpl implements AlarmMergeService { alarm.setContent(fault.getSoeExplain()); alarm.setDate(fault.getStartTime()); alarm.setRealId(fault.getRealId()); + alarm.setAlarmCode(fault.getAlarmId()); alarm.setType(AbnormalAlarmConstant.WEBSOCKET_FAULT); return alarm; }).collect(Collectors.toList())); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 87a7fc8..c82aed4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -286,48 +286,6 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl wrapper = Wrappers.lambdaQuery(); - if(StringUtils.isNotEmpty(param.getCode())){ - wrapper.eq(StationEntity::getCode,param.getCode()); - } - List stations = stationService.list(wrapper); - if(CollectionUtil.isEmpty(stations)){ - return new SoeReustVo(); - } - // 参数设置 - SoeDTO soe_params = new SoeDTO(); - //soe_params.setProjectId(); - String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; - String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME) + " 00:00:00"; - soe_params.setBeginTime(DateUtil.parse(start,DateUtil.PATTERN_DATETIME)); - soe_params.setEndTime(DateUtil.parse(end,DateUtil.PATTERN_DATETIME)); - soe_params.setNeedPage(true); - soe_params.setPage(param.getCurrent()); - soe_params.setPageSize(param.getSize()); - if(ObjectUtil.isEmpty(param.getType())){ - soe_params.setTypes(AbnormalAlarmConstant.SOE_TYPE_LIST); - }else{ - soe_params.setTypes(Collections.singletonList(param.getType())); - } - // 查询等级告警数据 - Result> soes = soeClient.pageQuery(soe_params); - if(!soes.isSuccess() || ObjectUtil.isEmpty(soes.getData())){ - return new SoeReustVo(); - } - List handles = this.getAlarmHandleIds(); - - - return null; - } - /** * 获取处理数据ID集合 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java new file mode 100644 index 0000000..1367baf --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java @@ -0,0 +1,106 @@ +package com.hnac.hzims.operational.alert.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; +import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity; +import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; +import com.hnac.hzims.operational.alert.mapper.HistoryLevelAlarmMapper; +import com.hnac.hzims.operational.alert.service.AlarmHandleService; +import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService; +import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 等级告警实现类 + * @author ysj + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl implements HistoryLevelAlarmService { + + + private final IStationService stationService; + + private final AlarmHandleService handleServicel; + + /** + * 列表查询 + * @param query + * @param entity + * @return + */ + @Override + public IPage pageCondition(Query query, HistoryLevelAlarmEntity entity) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.between(HistoryLevelAlarmEntity::getAlarmTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", + DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); + if(ObjectUtil.isNotEmpty(entity.getType())){ + wrapper.eq(HistoryLevelAlarmEntity::getType, entity.getType()); + } + if(ObjectUtil.isNotEmpty(entity.getStationId())){ + wrapper.eq(HistoryLevelAlarmEntity::getStationId, entity.getStationId()); + } + return super.page(Condition.getPage(query), wrapper); + } + + /** + * 告警数量:时间范围-当天 + * @return + */ + @Override + public List alarmCount() { + // 步骤1.查询用户权限站点 + List stations = stationService.list(); + if(CollectionUtil.isEmpty(stations)){ + return null; + } + + // 步骤2. 过滤已处理等級告警 + LambdaQueryWrapper handleWarpper = new LambdaQueryWrapper(); + handleWarpper.between(AlarmHandleEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", + DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); + handleWarpper.in(AlarmHandleEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + List handles = handleServicel.list(); + + // 步骤2.查询告警数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.between(HistoryLevelAlarmEntity::getAlarmTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", + DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); + wrapper.in(HistoryLevelAlarmEntity::getStationId, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + wrapper.in(HistoryLevelAlarmEntity::getType,AbnormalAlarmConstant.TYPE_LIST); + if(CollectionUtil.isNotEmpty(handles)){ + wrapper.notIn(HistoryLevelAlarmEntity::getAlarmId,handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList())); + } + List levels = this.list(wrapper); + + // 步骤4.遍历获取 + return AbnormalAlarmConstant.TYPE_LIST.stream().map(type->{ + IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); + count.setType(type); + count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(type)]); + if(CollectionUtil.isEmpty(levels)){ + count.setCount(0L); + }else{ + count.setCount(levels.stream().filter(level->level.getType().equals(type)).count()); + } + return count; + }).collect(Collectors.toList()); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 7dc7495..677a0b2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -530,7 +530,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 计划发电量、实际发电量、发电完成率 this.powerMonth(planList, actualMap, oldActualMap, areaStationList, areaMonthReport); // 操作票、操作票合格率/ 工作票、工作票合格率 - this.doubleMonth(areaStationList, areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); + this.doubleMonth(area, areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); // 日常维护、巡检任务、缺陷数、消缺率、检修任务 this.taskMonth(areaStationList, areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); // 预测 @@ -742,16 +742,15 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { /** * 区域-操作票、操作票合格率/ 工作票、工作票合格率 * - * @param areaStationList + * @param area * @param areaMonthReport */ - private void doubleMonth(List areaStationList, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { + private void doubleMonth(Dept area, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { // 站点归属机构集合 - List list = areaStationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); Map map = new HashMap<>(); map.put("startDate", startTime); map.put("endDate", endTime); - map.put("deptList", list); + map.put("deptList", Collections.singletonList(area.getId())); R R = ticketInfoClient.getOperateWorkStatistic(map); if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { areaMonthReport.setOperate(0);