|
|
@ -30,10 +30,13 @@ import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -59,9 +62,9 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
|
|
|
|
|
|
|
|
private final AlarmHandleService handleService; |
|
|
|
private final AlarmHandleService handleService; |
|
|
|
|
|
|
|
|
|
|
|
private final ISoeClient alarmClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final ISoeClient alarmClient; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
@Value("${hzims.operation.alarm.types}") |
|
|
|
private String types; |
|
|
|
private String types; |
|
|
@ -213,16 +216,16 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public AlarmReustVo alarms(AlarmParamVo param) { |
|
|
|
public AlarmReustVo alarms(AlarmParamVo param) { |
|
|
|
AlarmReustVo alarmReustVo = (AlarmReustVo) redisTemplate.opsForValue().get(param.getType() + param.getSize() + param.getCurrent()); |
|
|
|
// 查询用户权限机构
|
|
|
|
if(ObjectUtil.isNotEmpty(alarmReustVo)){ |
|
|
|
R<List<Dept>> result = sysClient.getDeptByCurrentUser(); |
|
|
|
return alarmReustVo; |
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new AlarmReustVo(); |
|
|
|
} |
|
|
|
} |
|
|
|
// 查询站点
|
|
|
|
// 查询站点
|
|
|
|
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery(); |
|
|
|
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery(); |
|
|
|
wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
if(StringUtils.isNotEmpty(param.getCode())){ |
|
|
|
wrapper.in(StationEntity::getRefDept,result.getData().stream().map(Dept::getId).collect(Collectors.toList())); |
|
|
|
wrapper.eq(StationEntity::getCode,param.getCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(wrapper); |
|
|
|
List<StationEntity> stations = stationService.list(wrapper); |
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
return new AlarmReustVo(); |
|
|
|
return new AlarmReustVo(); |
|
|
@ -237,8 +240,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
List<String> types = Arrays.asList(param.getType().split(",")); |
|
|
|
List<String> types = Arrays.asList(param.getType().split(",")); |
|
|
|
condition.setTypes(types); |
|
|
|
condition.setTypes(types); |
|
|
|
Result<HzPage<SoeData>> result = alarmClient.getByStationsAndTime(condition); |
|
|
|
Result<HzPage<SoeData>> soe = alarmClient.getByStationsAndTime(condition); |
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
if(!soe.isSuccess() || ObjectUtil.isEmpty(soe.getData()) || CollectionUtil.isEmpty(soe.getData().getRecords())){ |
|
|
|
return new AlarmReustVo(); |
|
|
|
return new AlarmReustVo(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -247,7 +250,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
|
|
|
|
|
|
|
|
// 返回数据
|
|
|
|
// 返回数据
|
|
|
|
AlarmReustVo response = new AlarmReustVo(); |
|
|
|
AlarmReustVo response = new AlarmReustVo(); |
|
|
|
List<AlarmDataVo> datas = result.getData().getRecords().stream().map(alarm -> { |
|
|
|
List<AlarmDataVo> datas = soe.getData().getRecords().stream().map(alarm -> { |
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
AlarmDataVo record = new AlarmDataVo(); |
|
|
|
// 继承类属性拷贝
|
|
|
|
// 继承类属性拷贝
|
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
|
BeanUtil.copyProperties(alarm, record); |
|
|
@ -271,10 +274,9 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
}).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) |
|
|
|
}).sorted(Comparator.comparing(AlarmDataVo::getIsHandle) |
|
|
|
.thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); |
|
|
|
.thenComparing(AlarmDataVo::getTs, Comparator.reverseOrder())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
response.setCount((int) (result.getData().getTotal() - handles.size())); |
|
|
|
response.setCount((int) (soe.getData().getTotal() - handles.size())); |
|
|
|
response.setSoeList(datas); |
|
|
|
response.setSoeList(datas); |
|
|
|
response.setTotal(result.getData().getTotal()); |
|
|
|
response.setTotal(soe.getData().getTotal()); |
|
|
|
redisTemplate.opsForValue().set(param.getType() + param.getSize() + param.getCurrent(),response,1, TimeUnit.MINUTES); |
|
|
|
|
|
|
|
return response; |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -298,20 +300,30 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<IntelligentAlarmCountVo> alarmCount() { |
|
|
|
public List<IntelligentAlarmCountVo> alarmCount() { |
|
|
|
|
|
|
|
// 查询用户权限机构
|
|
|
|
|
|
|
|
R<List<Dept>> result = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
// 步骤1.查询用户权限站点
|
|
|
|
// 步骤1.查询用户权限站点
|
|
|
|
List<StationEntity> stations = stationService.list(); |
|
|
|
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery(); |
|
|
|
|
|
|
|
wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
|
|
|
|
wrapper.in(StationEntity::getRefDept,result.getData().stream().map(Dept::getId).collect(Collectors.toList())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(wrapper); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
// 步骤2.查询告警数据
|
|
|
|
// 步骤2.查询告警数据
|
|
|
|
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); |
|
|
|
SoeQueryConditionByStation condition = new SoeQueryConditionByStation(); |
|
|
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
condition.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00", DateUtil.DATETIME_FORMATTER)); |
|
|
|
condition.setBeginTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-01 00:00:00", format)); |
|
|
|
condition.setEndTime(LocalDateTime.now()); |
|
|
|
condition.setEndTime(LocalDateTime.parse(/*DateUtil.format(new Date(), DateUtil.PATTERN_DATE) +*/ "2022-12-28 00:00:00", format)); |
|
|
|
|
|
|
|
condition.setNeedPage(false); |
|
|
|
condition.setNeedPage(false); |
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).filter(StringUtils::isNotEmpty).collect(Collectors.toList())); |
|
|
|
condition.setStationIds(stations.stream().map(StationEntity::getCode).filter(StringUtils::isNotEmpty).collect(Collectors.toList())); |
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
// nacos中配置告警类型:"0-默认", "1-系统", "2-告警", "3-故障", "4-用户操作", "5-遥测越限", "6-遥信变位", "7-注册信息",
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
// "8-信息提示", "9-设备巡检", "10-遥控操作", "11-遥测越限恢复","12-未定义","13-通讯中断","14-数据异常"
|
|
|
|
condition.setTypes(Arrays.asList(types.split(","))); |
|
|
|
condition.setTypes(Arrays.asList(types.split(","))); |
|
|
|
Result<HzPage<SoeData>> result = alarmClient.getByStationsAndTime(condition); |
|
|
|
Result<HzPage<SoeData>> soe = alarmClient.getByStationsAndTime(condition); |
|
|
|
|
|
|
|
|
|
|
|
// 步骤3. TODO 过滤已处理告警
|
|
|
|
// 步骤3. TODO 过滤已处理告警
|
|
|
|
|
|
|
|
|
|
|
@ -320,8 +332,8 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno |
|
|
|
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); |
|
|
|
IntelligentAlarmCountVo count = new IntelligentAlarmCountVo(); |
|
|
|
count.setType(type); |
|
|
|
count.setType(type); |
|
|
|
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(type)]); |
|
|
|
count.setName(AbnormalAlarmConstant.TYPE_NAMES[Integer.parseInt(type)]); |
|
|
|
if(result.isSuccess() && !ObjectUtil.isEmpty(result.getData())){ |
|
|
|
if(soe.isSuccess() && !ObjectUtil.isEmpty(soe.getData())){ |
|
|
|
count.setCount(result.getData().getRecords().stream().filter(record->type.equals(record.getSoeType())).count()); |
|
|
|
count.setCount(soe.getData().getRecords().stream().filter(record->type.equals(record.getSoeType())).count()); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
count.setCount(0L); |
|
|
|
count.setCount(0L); |
|
|
|
} |
|
|
|
} |
|
|
|