Browse Source

#bug修改

zhongwei
yang_shj 2 years ago
parent
commit
a236568e0f
  1. 4
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java
  2. 1
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java
  3. 16
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java
  4. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java
  5. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java
  6. 8
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java
  7. 36
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java
  8. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java
  9. 78
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java
  10. 40
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/LevelAlarmVo.java
  11. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java
  12. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmWebSocket.java
  13. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml
  14. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java
  15. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

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

@ -36,4 +36,8 @@ public interface AbnormalAlarmConstant {
*/ */
List<Integer> SOE_TYPE_LIST = Arrays.asList(2,3,5,13,14); List<Integer> SOE_TYPE_LIST = Arrays.asList(2,3,5,13,14);
/**
* 告警等级: 0 - 1级告警 1-二级告警
*/
List<String> LEVEL_LIST = Arrays.asList("0","1");
} }

1
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/AlarmHandleEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.operational.alert.entity; package com.hnac.hzims.operational.alert.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

16
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryLevelAlarmEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.operational.alert.entity; package com.hnac.hzims.operational.alert.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -27,8 +28,17 @@ public class HistoryLevelAlarmEntity extends BaseEntity {
@ApiModelProperty("站点名称") @ApiModelProperty("站点名称")
private String stationName; private String stationName;
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("告警等级")
private String alarmLevel;
@ApiModelProperty("告警编码") @ApiModelProperty("告警编码")
private Long alarmId; private String alarmId;
@ApiModelProperty("检查点") @ApiModelProperty("检查点")
private String realId; private String realId;
@ -44,4 +54,8 @@ public class HistoryLevelAlarmEntity extends BaseEntity {
@ApiModelProperty("告警原因") @ApiModelProperty("告警原因")
private String soeExplain; private String soeExplain;
@ApiModelProperty(value = "告警是否处理")
@TableField(exist=false)
private Boolean isHandle;
} }

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java

@ -12,10 +12,7 @@ import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.core.mp.support.QueryField; import org.springblade.core.mp.support.QueryField;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
@ -26,6 +23,7 @@ import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("HZIMS_STATION") @TableName("HZIMS_STATION")
@Builder @Builder

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java

@ -41,6 +41,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
@ -346,7 +347,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
// 巡检任务ID集合 // 巡检任务ID集合
List<TaskUserEntity> taskUsers = this.taskUserService.list(new LambdaQueryWrapper<TaskUserEntity>() {{ List<TaskUserEntity> taskUsers = this.taskUserService.list(new LambdaQueryWrapper<TaskUserEntity>() {{
eq(TaskUserEntity::getUserId, user.getUserId()); eq(TaskUserEntity::getUserId, user.getUserId());
}});; }});
if(CollectionUtil.isEmpty(taskUsers)){ if(CollectionUtil.isEmpty(taskUsers)){
throw new ServiceException("巡检用户数据不存在!"); throw new ServiceException("巡检用户数据不存在!");
} }
@ -360,7 +361,7 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
List<TaskUserEntity> users = this.taskUserData(tasks.stream().map(TaskOfflineVO::getId).collect(Collectors.toList())); List<TaskUserEntity> users = this.taskUserData(tasks.stream().map(TaskOfflineVO::getId).collect(Collectors.toList()));
fileJson.add(JsonUtil.toJson(users)); fileJson.add(JsonUtil.toJson(users));
fileJson.add(JsonUtil.toJson(tasks)); fileJson.add(JsonUtil.toJson(tasks));
taskIds = tasks.stream().map(o -> o.getId()).collect(Collectors.toList()); taskIds = tasks.stream().map(BaseEntity::getId).collect(Collectors.toList());
// 巡检计划 // 巡检计划
List<PlanOfflineVO> plans = this.getPlans(tasks.stream().map(TaskOfflineVO::getPlanId).collect(Collectors.toList())); List<PlanOfflineVO> plans = this.getPlans(tasks.stream().map(TaskOfflineVO::getPlanId).collect(Collectors.toList()));
fileJson.add(JsonUtil.toJson(plans)); fileJson.add(JsonUtil.toJson(plans));

8
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/EventServiceImpl.java

@ -92,13 +92,13 @@ public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEnti
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean addTaskEvent(EventAddVO eventVO){ public boolean addTaskEvent(EventAddVO eventVO){
BladeUser user = AuthUtil.getUser();
//第一次登记时,需领用任务 //第一次登记时,需领用任务
if(!AuthUtil.isAdministrator()){ if(!AuthUtil.isAdministrator()){
ITaskService taskService = SpringUtil.getBean(ITaskService.class); ITaskService taskService = SpringUtil.getBean(ITaskService.class);
TaskEntity taskEntity = taskService.getById(eventVO.getTaskId()); TaskEntity taskEntity = taskService.getById(eventVO.getTaskId());
TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery() TaskUserEntity taskUserEntity = taskUserService.getOne(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).eq(TaskUserEntity::getUserId,user == null ? eventVO.getUserId() : user.getUserId()));
.eq(TaskUserEntity::getTaskId,eventVO.getTaskId())
.eq(TaskUserEntity::getUserId,eventVO.getUserId()));
if(taskUserEntity==null){ if(taskUserEntity==null){
throw new ServiceException("该任务已被别人领取"); throw new ServiceException("该任务已被别人领取");
} }
@ -107,7 +107,7 @@ public class EventServiceImpl extends BaseServiceImpl<TaskEventMapper, EventEnti
taskUserEntity.setClaimTime(LocalDateTime.now()); taskUserEntity.setClaimTime(LocalDateTime.now());
taskUserService.updateById(taskUserEntity); taskUserService.updateById(taskUserEntity);
if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){//如果是抢占任务,删除能够抢占此任务的其他人 if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(taskEntity.getMethod())){//如果是抢占任务,删除能够抢占此任务的其他人
taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).ne(TaskUserEntity::getUserId,taskUserEntity.getUserId())); taskUserService.remove(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId,eventVO.getTaskId()).ne(TaskUserEntity::getId,taskUserEntity.getUserId()));
} }
} }
} }

36
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java

@ -5,10 +5,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity; import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity;
import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.service.AlarmHandleService; import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity;
import com.hnac.hzims.operational.alert.service.AlarmMergeService; import com.hnac.hzims.operational.alert.service.*;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
import com.hnac.hzims.operational.alert.service.LevelAlarmService;
import com.hnac.hzims.operational.alert.vo.AlarmMergeVo; import com.hnac.hzims.operational.alert.vo.AlarmMergeVo;
import com.hnac.hzims.operational.config.vo.MessageParamVo; import com.hnac.hzims.operational.config.vo.MessageParamVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -39,12 +37,12 @@ public class AlertMerageServiceImpl implements AlarmMergeService {
private final IStationService stationService; private final IStationService stationService;
private final LevelAlarmService levelAlarmService;
private final AlarmHandleService alarmHandleService; private final AlarmHandleService alarmHandleService;
private final HistoryAbnormalAlarmService faultAlarmService; private final HistoryAbnormalAlarmService faultAlarmService;
private final HistoryLevelAlarmService levelAlarmService;
/** /**
* 根据用户获取hz3000事故告警平台一级告警二级告警 * 根据用户获取hz3000事故告警平台一级告警二级告警
* @param param * @param param
@ -95,12 +93,32 @@ public class AlertMerageServiceImpl implements AlarmMergeService {
alarm.setDate(fault.getStartTime()); alarm.setDate(fault.getStartTime());
alarm.setRealId(fault.getRealId()); alarm.setRealId(fault.getRealId());
alarm.setAlarmCode(String.valueOf(fault.getAlarmId())); alarm.setAlarmCode(String.valueOf(fault.getAlarmId()));
alarm.setType(AbnormalAlarmConstant.WEBSOCKET_FAULT); alarm.setType(fault.getType());
return alarm; return alarm;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }
// hz3000事故告警 // 等级告警
// faultAlarmService.list(); List<HistoryLevelAlarmEntity> levels = levelAlarmService.list(Wrappers.<HistoryLevelAlarmEntity>lambdaQuery()
.in(HistoryLevelAlarmEntity::getAlarmLevel,AbnormalAlarmConstant.LEVEL_LIST)
.in(HistoryLevelAlarmEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.in(HistoryLevelAlarmEntity::getType, AbnormalAlarmConstant.TYPE_LIST)
.between(HistoryLevelAlarmEntity::getCreateTime,start,end)
);
if(CollectionUtil.isNotEmpty(levels)){
alarms.addAll(levels.stream().filter(l -> CollectionUtil.isEmpty(handles)
|| !handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(l.getAlarmId())).
map(level->{
AlarmMergeVo alarm = new AlarmMergeVo();
alarm.setStationCode(level.getStationId());
alarm.setStationName(level.getStationName());
alarm.setContent(level.getSoeExplain());
alarm.setDate(level.getAlarmTime());
alarm.setRealId(level.getRealId());
alarm.setAlarmCode(level.getAlarmId());
alarm.setType(level.getType());
return alarm;
}).collect(Collectors.toList()));
}
return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmMergeVo::getDate)).collect(Collectors.toList()))); return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmMergeVo::getDate)).collect(Collectors.toList())));
} }

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryLevelAlarmServiceImpl.java

@ -37,7 +37,7 @@ public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl<HistoryLevelAl
private final IStationService stationService; private final IStationService stationService;
private final AlarmHandleService handleServicel; private final AlarmHandleService handleService;
/** /**
* 列表查询 * 列表查询
@ -56,7 +56,17 @@ public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl<HistoryLevelAl
if(ObjectUtil.isNotEmpty(entity.getStationId())){ if(ObjectUtil.isNotEmpty(entity.getStationId())){
wrapper.eq(HistoryLevelAlarmEntity::getStationId, entity.getStationId()); wrapper.eq(HistoryLevelAlarmEntity::getStationId, entity.getStationId());
} }
return super.page(Condition.getPage(query), wrapper); IPage<HistoryLevelAlarmEntity> page = super.page(Condition.getPage(query), wrapper);
List<HistoryLevelAlarmEntity> records = page.getRecords();
// 步骤2. 过滤已处理等級告警
LambdaQueryWrapper<AlarmHandleEntity> 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, records.stream().map(HistoryLevelAlarmEntity::getStationId).collect(Collectors.toList()));
handleWarpper.in(AlarmHandleEntity::getAlarmId,records.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList()));
List<AlarmHandleEntity> handles = handleService.list();
page.setRecords(records.stream().peek(record-> record.setIsHandle(CollectionUtil.isNotEmpty(handles) || handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(record.getAlarmId()))).collect(Collectors.toList()));
return page;
} }
/** /**
@ -76,7 +86,7 @@ public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl<HistoryLevelAl
handleWarpper.between(AlarmHandleEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00", handleWarpper.between(AlarmHandleEntity::getCreateTime, DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00",
DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME));
handleWarpper.in(AlarmHandleEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); handleWarpper.in(AlarmHandleEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
List<AlarmHandleEntity> handles = handleServicel.list(); List<AlarmHandleEntity> handles = handleService.list();
// 步骤2.查询告警数据 // 步骤2.查询告警数据
LambdaQueryWrapper<HistoryLevelAlarmEntity> wrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<HistoryLevelAlarmEntity> wrapper = new LambdaQueryWrapper();
@ -93,7 +103,7 @@ public class HistoryLevelAlarmServiceImpl extends BaseServiceImpl<HistoryLevelAl
return AbnormalAlarmConstant.TYPE_LIST.stream().map(type->{ return AbnormalAlarmConstant.TYPE_LIST.stream().map(type->{
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); IntelligentAlarmCountVo count = new IntelligentAlarmCountVo();
count.setType(type); count.setType(type);
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.valueOf(type)]); count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(type)]);
if(CollectionUtil.isEmpty(levels)){ if(CollectionUtil.isEmpty(levels)){
count.setCount(0L); count.setCount(0L);
}else{ }else{

78
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/LevelAlarmServiceImpl.java

@ -2,9 +2,14 @@ package com.hnac.hzims.operational.alert.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant;
import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity;
import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService;
import com.hnac.hzims.operational.alert.service.LevelAlarmService; import com.hnac.hzims.operational.alert.service.LevelAlarmService;
import com.hnac.hzims.operational.config.vo.LevelAlarmVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -14,7 +19,9 @@ import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -29,6 +36,9 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
private final IStationService stationService; private final IStationService stationService;
private final IMainSystemMonitoringService deviceService;
private final HistoryLevelAlarmService historyLevelAlarmService;
/** /**
* 定时发送消息内容 * 定时发送消息内容
@ -45,10 +55,7 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
Map<String,String> map = new ConcurrentHashMap<>(); Map<String,String> map = new ConcurrentHashMap<>();
map.put("projectIds",stations.stream().map(StationEntity::getCode).collect(Collectors.joining(","))); map.put("projectIds",stations.stream().map(StationEntity::getCode).collect(Collectors.joining(",")));
map.put("type", AbnormalAlarmConstant.LEVEL_TYPE_LIST); map.put("type", AbnormalAlarmConstant.LEVEL_TYPE_LIST);
Calendar calendar = Calendar.getInstance(); map.put("startTime", DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00");
calendar.setTime(new Date());
calendar.add(Calendar.SECOND,-30);
map.put("startTime", DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME));
return JSONObject.toJSONString(map); return JSONObject.toJSONString(map);
} }
@ -60,10 +67,67 @@ public class LevelAlarmServiceImpl implements LevelAlarmService {
@Override @Override
public void receiveMessage(String message) { public void receiveMessage(String message) {
// 对象转换 // 对象转换
List<LevelAlarmVo> alarms = JSONObject.parseArray(message,LevelAlarmVo.class);
if(CollectionUtil.isEmpty(alarms)){
return;
}
// 站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE));
if(CollectionUtil.isEmpty(stations)){
throw new ServiceException("level send message is null");
}
// 设备
List<EminfoAndEmParamVo> devices = deviceService.getEmInfoList();
// 查询当天已经记录的告警
List<HistoryLevelAlarmEntity> historys = historyLevelAlarmService.list(Wrappers.<HistoryLevelAlarmEntity>lambdaQuery()
.ge(HistoryLevelAlarmEntity::getCreateTime,DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00")
);
// 数据过滤
List<HistoryLevelAlarmEntity> entitys = alarms.stream().filter(alarm -> CollectionUtil.isEmpty(historys) || !historys.stream().map(HistoryLevelAlarmEntity::getAlarmId).collect(Collectors.toList()).contains(alarm.getId())).map(item->{
HistoryLevelAlarmEntity entity = new HistoryLevelAlarmEntity();
entity.setAlarmId(item.getId());
entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"));
entity.setType(String.valueOf(item.getType()));
entity.setRealId(item.getSignage());
entity.setSoeExplain(item.getName());
entity.setDeviceCode(item.getDevicecode());
entity.setDeviceName(item.getDevicename());
entity.setAlarmLevel(String.valueOf(item.getLevel()));
// 根据设备找站点
if(CollectionUtil.isNotEmpty(devices)){
// 找到设备
List<EminfoAndEmParamVo> alarmDevices = devices.stream().filter(device->device.getEmCode().equals(item.getDevicecode())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(alarmDevices)){
// 找到站点
List<StationEntity> alarmStations = stations.stream().filter(station->station.getRefDept().equals(alarmDevices.get(0).getCreateDept())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(alarmStations)){
entity.setStationId(alarmStations.get(0).getCode());
entity.setStationName(alarmStations.get(0).getName());
}
}
}
return entity;
}).collect(Collectors.toList());
if(CollectionUtil.isEmpty(entitys)){
return;
}
// 查询近10分钟记录告警 // 批量保存
historyLevelAlarmService.saveBatch(entitys);
// 消息推送
this.sendAlarmMessage(entitys);
}
// 保存 /**
* 告警消息推送
* @param entitys
*/
private void sendAlarmMessage(List<HistoryLevelAlarmEntity> entitys) {
} }
} }

40
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/LevelAlarmVo.java

@ -0,0 +1,40 @@
package com.hnac.hzims.operational.config.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/04/26 14:27:33
* @version 4.0.0
*/
@Data
public class LevelAlarmVo {
@ApiModelProperty(value = "主键Id")
private String id;
@ApiModelProperty(value = "告警时间")
private String ts;
@ApiModelProperty(value = "设备编码")
private String devicecode;
@ApiModelProperty(value = "设备名称")
private String devicename;
@ApiModelProperty(value = "告警内容")
private String name;
@ApiModelProperty(value = "告警类型")
private Integer type;
@ApiModelProperty(value = "告警等级")
private Integer level;
@ApiModelProperty(value = "告警发生时,设备实时数据")
private String context;
@ApiModelProperty(value = "事件标识")
private String signage;
}

26
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmRegular.java

@ -1,9 +1,8 @@
package com.hnac.hzims.operational.config.ws; package com.hnac.hzims.operational.config.ws;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.operational.alert.service.LevelAlarmService; import com.hnac.hzims.operational.alert.service.LevelAlarmService;
import com.hnac.hzims.operational.config.service.StFocusPropertiesService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@ -11,7 +10,6 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
/** /**
* 等级告警获取数据长链接 * 等级告警获取数据长链接
@ -34,30 +32,20 @@ public class LevelAlarmRegular{
@Scheduled(cron = "0/30 * * * * ?") @Scheduled(cron = "0/30 * * * * ?")
private void regular(){ private void regular(){
// 检查链接存活状态 // 检查链接存活状态
if(this.block()){ if(ObjectUtil.isNotEmpty(client) && client.isOpen()){
client.send(levelAlarmService.sendMessage()); client.send(levelAlarmService.sendMessage());
}else {
this.createClient();
} }
client = this.createClient();
} }
// 创建websocket链接 // 创建websocket链接
private LevelAlarmWebSocket createClient() { private void createClient() {
try{ try{
return new LevelAlarmWebSocket(new URI(level_wss_url)); client = new LevelAlarmWebSocket(new URI(level_wss_url));
client.connectBlocking();
}catch (Exception e){ }catch (Exception e){
log.error("level create error : {}",e.getMessage()); log.error("level create error : {}",e.getMessage());
} }
return null;
} }
// 检查链接存活状态
private boolean block() {
try{
return client.connectBlocking();
} catch (Exception e){
log.error("level block error : {}",e.getMessage());
}
return false;
}
} }

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ws/LevelAlarmWebSocket.java

@ -1,15 +1,11 @@
package com.hnac.hzims.operational.config.ws; package com.hnac.hzims.operational.config.ws;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.operational.alert.service.LevelAlarmService; import com.hnac.hzims.operational.alert.service.LevelAlarmService;
import com.hnac.hzims.operational.config.service.StAlamRecordService;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springblade.core.tool.utils.StringUtil;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
@ -48,7 +44,12 @@ public class LevelAlarmWebSocket extends WebSocketClient {
// 接收到服务器消息回调接口 // 接收到服务器消息回调接口
@Override @Override
public void onMessage(String message) { public void onMessage(String message) {
levelAlarmService.receiveMessage(message); if(StringUtil.isEmpty(message)){
log.error("levl on message is null");
}else{
// 等级告警数据处理
levelAlarmService.receiveMessage(message);
}
} }
// 与服务器链接中断回调接口 // 与服务器链接中断回调接口

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml

@ -333,7 +333,7 @@
</foreach> </foreach>
</select> </select>
<select id="getDutyDataV2" resultType="com.hnac.hzims.operational.duty.vo.DutyInfoVo"> <select id="getDutyDataV2" resultType="com.hnac.hzims.operational.duty.vo.DutyInfoVo">
SELECT DC.CLASS_NAME, DC.START_TIME, DC.END_TIME,DM.DUTY_DATE DATE_TIME,DM.ID,DM.PRE_DUTY_ID,DM.CREATE_DEPT SELECT DM.DUTY_GROUP_ID AS groupId ,DC.CLASS_NAME, DC.START_TIME, DC.END_TIME,DM.DUTY_DATE DATE_TIME,DM.ID,DM.PRE_DUTY_ID,DM.CREATE_DEPT
FROM hz_ims_duty_main DM FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC JOIN hz_ims_duty_class DC
ON DM.CLASS_ID = DC.ID ON DM.CLASS_ID = DC.ID
@ -345,7 +345,7 @@
</select> </select>
<select id="queryDutyInfo" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo"> <select id="queryDutyInfo" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo">
SELECT DM.DUTY_DATE DATE_TIME, DC.`CLASS_NAME`, DG.`GROUP_NAME`, DG.`MANAGER_ID` as managerId, DC.`START_TIME`, DC.`END_TIME` SELECT DM.ID,DM.DUTY_GROUP_ID AS dutyGroupId,DM.DUTY_DATE DATE_TIME, DC.`CLASS_NAME`, DG.`GROUP_NAME`, DG.`MANAGER_ID` as managerId, DC.`START_TIME`, DC.`END_TIME`
FROM hz_ims_duty_main DM FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID` ON DM.`CLASS_ID` = DC.`ID`
@ -357,7 +357,7 @@
limit 1; limit 1;
</select> </select>
<select id="queryDutyInfoV2" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo"> <select id="queryDutyInfoV2" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo">
SELECT DM.DUTY_DATE DATE_TIME, DC.`CLASS_NAME`, DC.`START_TIME`, DC.`END_TIME` SELECT DM.ID,DM.DUTY_GROUP_ID AS dutyGroupId,DM.DUTY_DATE DATE_TIME, DC.`CLASS_NAME`, DC.`START_TIME`, DC.`END_TIME`
FROM hz_ims_duty_main DM FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID` ON DM.`CLASS_ID` = DC.`ID`

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java

@ -96,11 +96,11 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
params.put("dutyDate", imsDutyMain.getDutyDate()); params.put("dutyDate", imsDutyMain.getDutyDate());
params.put("classId", imsDutyMain.getClassId()); params.put("classId", imsDutyMain.getClassId());
String[] dutyPersonIds = imsDutyMain.getDutyPersonIds().split("\\^"); String[] dutyPersonIds = imsDutyMain.getDutyPersonIds().split("\\^");
for (int i = 0; i < dutyPersonIds.length; i++) { for (String dutyPersonId : dutyPersonIds) {
params.put("dutyPersonIds", dutyPersonIds[i]); params.put("dutyPersonIds", dutyPersonId);
List<ImsDutyMainEntity> list = this.baseMapper.selectByPersonId(params); List<ImsDutyMainEntity> list = this.baseMapper.selectByPersonId(params);
if (list.size() > 0) { if (list.size() > 0) {
return R.fail("ID为" + dutyPersonIds[i] + "的用户在该天该班次已排过班,请重新选择"); return R.fail("ID为" + dutyPersonId + "的用户在该天该班次已排过班,请重新选择");
} }
} }
imsDutyMain.setStatus(JoinStatus.DUTY_WAIT.getStatus()); imsDutyMain.setStatus(JoinStatus.DUTY_WAIT.getStatus());
@ -493,7 +493,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
//人员ID //人员ID
List<Long> collectPerson; List<Long> collectPerson;
//负责人ID //负责人ID
Long managerId = 0l; Long managerId = 0L;
String groupName = null; String groupName = null;
if (imsSchedulingVo.getPersonType() == 1) { if (imsSchedulingVo.getPersonType() == 1) {
//查询班组信息 //查询班组信息
@ -1184,7 +1184,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
return null; return null;
} }
//修改数据结构后:分灵活排班和班组排班拿负责人 //修改数据结构后:分灵活排班和班组排班拿负责人
dutyInfoVoList = dutyInfoVoList.stream().map(s -> { dutyInfoVoList = dutyInfoVoList.stream().peek(s -> {
if (null == s.getGroupId()) { if (null == s.getGroupId()) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{
eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId());
@ -1196,7 +1196,6 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
s.setGroupName(imsDutyGroupEntity.getGroupName()); s.setGroupName(imsDutyGroupEntity.getGroupName());
s.setManagerId(imsDutyGroupEntity.getManagerId().toString()); s.setManagerId(imsDutyGroupEntity.getManagerId().toString());
} }
return s;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
dutyInfoVoList.forEach(item -> { dutyInfoVoList.forEach(item -> {
// 负责人 // 负责人
@ -1380,6 +1379,9 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl<ImsDutyMainMapper, I
* @return * @return
*/ */
private NextDutyInfoVo getUpDutyInfo(DutyInfoVo item) { private NextDutyInfoVo getUpDutyInfo(DutyInfoVo item) {
if(ObjectUtil.isEmpty(item.getPreDutyId())){
return null;
}
DutyMainInfoVo dutyMainInfoVo = this.baseMapper.queryDutyInfoV2(item.getPreDutyId()); DutyMainInfoVo dutyMainInfoVo = this.baseMapper.queryDutyInfoV2(item.getPreDutyId());
if (null == dutyMainInfoVo.getDutyGroupId()) { if (null == dutyMainInfoVo.getDutyGroupId()) {
ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{ ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper<ImsDutyMainPersonEntity>() {{

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.validation.constraints.NotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -47,6 +48,9 @@ public class ScheduledCreateTask {
private PhotovoltaicService photovoltaicService; private PhotovoltaicService photovoltaicService;
@Autowired @Autowired
private ISideHustleService regionService;
@Autowired
private IRunMonthReportService runMonthReportService; private IRunMonthReportService runMonthReportService;
@Autowired @Autowired
@ -184,7 +188,7 @@ public class ScheduledCreateTask {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
} }
//sideHustleService.loadDutyInfo(param); regionService.loadDutyInfo(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
@ -198,7 +202,7 @@ public class ScheduledCreateTask {
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
} }
//sideHustleService.deviceClassify(param); regionService.deviceClassify(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }

Loading…
Cancel
Save