diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java index 97a9216..312d843 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java @@ -15,6 +15,9 @@ import java.util.Date; @ApiModel(value = "告警处理对象") public class AlarmHandleEntity extends BaseEntity { + @ApiModelProperty("告警Id") + private Long alarmId; + @ApiModelProperty("站点编码") private String stationCode; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmDataVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmDataVo.java new file mode 100644 index 0000000..99f5235 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmDataVo.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.operational.alert.vo; + +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/03/23 14:06:27 + * @version 4.0.0 + */ +@Data +public class AlarmDataVo extends SoeData { + + @ApiModelProperty(value = "数量") + private String unitName; + + @ApiModelProperty(value = "数量") + private String pointName; + + @ApiModelProperty(value = "数量") + private int count; + + @ApiModelProperty(value = "站点编号") + private String stationCode; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "内容") + private String content; + + @ApiModelProperty(value = "是否绑定") + private Boolean isBinding; + + @ApiModelProperty(value = "站点类型: 2-待运维 1-云服务") + private String serveType; + + @ApiModelProperty(value = "告警类型") + private String type; + + @ApiModelProperty(value = "告警是否处理") + private Boolean isHandle; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmParamVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmParamVo.java new file mode 100644 index 0000000..197e415 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmParamVo.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.operational.alert.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/03/23 13:34:37 + * @version 4.0.0 + */ +@Data +public class AlarmParamVo { + + @ApiModelProperty(value = "查询开始时间:yyyy-MM-dd HH:mm:ss") + private String date; + + @ApiModelProperty(value = "默认,系统,告警,故障,用户操作,遥测越限,遥信变位,注册信息,信息提示,设备巡检,遥控操作,遥测越限恢复,未定义,通讯中断,数据异常") + private String type; + + @ApiModelProperty(value = "当前页码") + private Integer current; + + + @ApiModelProperty(value = "每页条目") + private Integer size; + + + @ApiModelProperty(value = "站点编码") + private String code; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmReustVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmReustVo.java new file mode 100644 index 0000000..e30ae12 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmReustVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.alert.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/03/23 13:34:37 + * @version 4.0.0 + */ +@Data +public class AlarmReustVo { + + @ApiModelProperty(value = "最新的时间") + private String date; + + @ApiModelProperty(value = "告警数据") + private List soeList; + + @ApiModelProperty(value = "数量统计") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer count; + + @ApiModelProperty(value = "总条数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long total; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java index bcaf0e4..d8a8d8a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java @@ -1,7 +1,6 @@ package com.hnac.hzims.operational.access.feign; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -12,10 +11,6 @@ import com.hnac.hzims.operational.access.service.IOperAccessTaskService; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.feign.IAccessTaskClient; -import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; -import com.hnac.hzims.ticket.constants.TicketConstants; -import com.sun.org.apache.xpath.internal.operations.Bool; -import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; 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 3f5163a..1c886e6 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 @@ -5,9 +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.alert.vo.AlarmParamVo; +import com.hnac.hzims.operational.alert.vo.AlarmReustVo; +import com.hnac.hzims.operational.config.vo.*; import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,7 +34,7 @@ public class AbnormalAlarmController extends BladeController { * 统计通讯中断时间 */ @GetMapping("/statisticsTime") - @ApiOperationSupport(order = 0) + @ApiOperationSupport(order = 1) @ApiOperation(value = "统计通讯中断时间", notes = "传入imsDutyMainEntity") public R> statisticsTime(HistoryAbnormalAlarmEntity entity, Query query) { IPage pages = service.getAlarmTime(query,entity); @@ -53,7 +53,7 @@ public class AbnormalAlarmController extends BladeController { } @GetMapping("/queryStationName") - @ApiOperationSupport(order = 0) + @ApiOperationSupport(order = 2) @ApiOperation(value = "查询站点") public R> queryStationName() { List res = service.queryStationName(); @@ -63,7 +63,7 @@ public class AbnormalAlarmController extends BladeController { * 详情 */ @GetMapping("/detail") - @ApiOperationSupport(order = 2) + @ApiOperationSupport(order = 3) @ApiOperation(value = "详情", notes = "传入HistoryAbnormalAlarmEntity") public R detail(HistoryAbnormalAlarmEntity entity) { HistoryAbnormalAlarmEntity detail = service.getOne(Condition.getQueryWrapper(entity)); @@ -74,7 +74,7 @@ public class AbnormalAlarmController extends BladeController { * 分页 */ @GetMapping("/list") - @ApiOperationSupport(order = 3) + @ApiOperationSupport(order = 4) @ApiOperation(value = "分页", notes = "传入HistoryAbnormalAlarmEntity") public R> list(HistoryAbnormalAlarmEntity entity, Query query) { IPage pages = service.page(Condition.getPage(query), Condition.getQueryWrapper(entity)); @@ -85,7 +85,7 @@ public class AbnormalAlarmController extends BladeController { * 新增或修改 */ @PostMapping("/submit") - @ApiOperationSupport(order = 4) + @ApiOperationSupport(order = 5) @ApiOperation(value = "新增或修改", notes = "传入HistoryAbnormalAlarmEntity") public R submit(@Valid @RequestBody HistoryAbnormalAlarmEntity entity) { return R.status(service.saveOrUpdate(entity)); @@ -96,17 +96,27 @@ public class AbnormalAlarmController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperationSupport(order = 5) + @ApiOperationSupport(order = 6) @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 = 7) + @RequestMapping(value = "/alarms", method = {RequestMethod.GET, RequestMethod.POST}) + public R alarms(AlarmParamVo param){ + return R.data(service.alarms(param)); + } + + /** * 智能告警数量: 时间范围当天 */ @ApiOperation(value = "智能告警数量") - @ApiOperationSupport(order = 6) + @ApiOperationSupport(order = 8) @RequestMapping(value = "/count", method = {RequestMethod.GET, RequestMethod.POST}) public R> count(){ return R.data(service.alarmCount()); @@ -117,7 +127,7 @@ public class AbnormalAlarmController extends BladeController { * 智能告警数据: 时间范围当天 */ @ApiOperation(value = "智能告警数据") - @ApiOperationSupport(order = 7) + @ApiOperationSupport(order = 9) @RequestMapping(value = "/data", method = RequestMethod.GET) public R> data(AlarmDataPageVo page,Query query) { return R.data(service.alarmData(page,query)); 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 4fce544..ac56340 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 @@ -2,16 +2,13 @@ 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.alert.vo.AlarmParamVo; +import com.hnac.hzims.operational.alert.vo.AlarmReustVo; +import com.hnac.hzims.operational.config.vo.*; import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import java.util.Date; import java.util.List; /** @@ -27,6 +24,8 @@ public interface HistoryAbnormalAlarmService extends BaseService queryByEntity(HistoryAbnormalAlarmEntity entity,Query query); + AlarmReustVo alarms(AlarmParamVo param); + // 智能告警数量: 时间范围当天 List alarmCount(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java index c85924a..cd15f3d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlarmHandleServiceImpl.java @@ -68,6 +68,7 @@ public class AlarmHandleServiceImpl 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 AlarmReustVo(); + } + + // 查询告警数据 + DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); + SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); + /*if (StringUtils.isEmpty(param.getDate())) { + condition.setBeginTime(LocalDateTime.parse( + DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", format + )); + } else { + condition.setBeginTime(LocalDateTime.parse(param.getDate(), format)); + }*/ + // condition.setEndTime(LocalDateTime.now()); + // FIXME 测试使用时间 + condition.setBeginTime(LocalDateTime.parse("2023-02-01 00:00:00", format)); + condition.setEndTime(LocalDateTime.parse("2023-02-27 00:00:00", format)); + condition.setNeedPage(true); + condition.setPage(param.getCurrent()); + condition.setLimit(param.getSize()); + condition.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + condition.setTypes(Arrays.asList(param.getType().split(","))); + Result> result = alarmClient.getByStationsAndTime(condition); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ + return new AlarmReustVo(); + } + + // 查询处理告警 + List handles = this.getAlarmHandleIds(); + + // 返回数据 + AlarmReustVo response = new AlarmReustVo(); + List datas = result.getData().getRecords().stream().map(alarm -> { + AlarmDataVo record = new AlarmDataVo(); + // 继承类属性拷贝 + BeanUtil.copyProperties(alarm, record); + if(CollectionUtil.isEmpty(handles)){ + record.setIsHandle(false); + }else{ + record.setIsHandle(handles.contains(alarm.getId())); + } + record.setStationCode(alarm.getStation()); + record.setContent(alarm.getSoeExplain()); + record.setType(alarm.getSoeType()); + record.setSoeType(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(alarm.getSoeType())]); + List filter = stations.stream().filter(station -> station.getCode().equals(alarm.getStation())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(filter)) { + return record; + } + record.setStationName(filter.get(0).getName()); + record.setServeType(filter.get(0).getServeType()); + return record; + }).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) + .thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); + response.setCount(datas.size()); + response.setSoeList(datas); + response.setTotal(result.getData().getTotal()); + return response; + } + + /** + * 获取处理数据ID集合 + * @return + */ + private List getAlarmHandleIds() { + List handles = handleService.list(); + if(CollectionUtil.isEmpty(handles)){ + return null; + } + return handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()); + } + + /** * 告警数量:时间范围-当天 * @return */ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index e372a73..7f91502 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -787,11 +787,11 @@ public class TargetServiceImpl implements TargetService { WaterTargetVo water = new WaterTargetVo(); water.setStationName(station.getName()); if(CollectionUtil.isEmpty(pumps)){ - water.setUse(0.0); + water.setLoad(0.0); return water; } Double use = pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum(); - water.setUse(Optional.ofNullable(use).orElse(0.0)); + water.setLoad(Optional.ofNullable(use).orElse(0.0)); return water; }).sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/StAlamRecordService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/StAlamRecordService.java index 14347c1..185b123 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/StAlamRecordService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/StAlamRecordService.java @@ -1,7 +1,6 @@ package com.hnac.hzims.operational.config.service; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity; import com.hnac.hzims.operational.config.vo.FaultVo; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java index 9afdbc0..5863e84 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/StAlamRecordServiceImpl.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.fdp.feign.IFdpMonitorClient; @@ -22,6 +23,7 @@ import com.hnac.hzims.operational.config.service.StFocusPropertiesService; import com.hnac.hzims.operational.config.vo.*; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.vo.SoeDataVo; +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.util.ExcelUtil; @@ -48,6 +50,7 @@ import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat;