|
|
|
@ -2,28 +2,19 @@ package com.hnac.hzims.scheduled.service.alarm.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.hnac.hzims.business.interruption.constants.InterruptionConstants; |
|
|
|
|
import com.hnac.hzims.alarm.config.entity.AlarmEntity; |
|
|
|
|
import com.hnac.hzims.business.interruption.entity.InterruptionEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
import com.hnac.hzims.scheduled.mapper.alarm.InterruptionAlrmMapper; |
|
|
|
|
import com.hnac.hzims.scheduled.service.alarm.InterruptionAlarmService; |
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.station.StationService; |
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.ISoeClient; |
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.domian.SoeData; |
|
|
|
|
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -36,5 +27,27 @@ import java.util.stream.Collectors;
|
|
|
|
|
@DS("alarm") |
|
|
|
|
public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAlrmMapper, InterruptionEntity> implements InterruptionAlarmService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询站点数据中断 |
|
|
|
|
* @param codes |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<String> aborts(List<String> codes) { |
|
|
|
|
List<InterruptionEntity> alarms = this.list(Wrappers.<InterruptionEntity>lambdaQuery() |
|
|
|
|
.in(InterruptionEntity::getStationId,codes) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(alarms)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return alarms.stream().collect(Collectors.groupingBy(InterruptionEntity::getStationId)).values().stream().map(alarmEntities -> { |
|
|
|
|
// 站点最近的一条数据中断、数据异常告警
|
|
|
|
|
InterruptionEntity alarm = alarmEntities.stream().sorted(Comparator.comparing(InterruptionEntity::getCreateTime).reversed()).collect(Collectors.toList()).get(0); |
|
|
|
|
// 状态为中断
|
|
|
|
|
if (alarm.getStatus().equals(0)) { |
|
|
|
|
return alarm.getStationId(); |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
}).filter(StringUtil::isNotBlank).distinct().collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
} |