yang_shj
11 months ago
8 changed files with 141 additions and 25 deletions
@ -0,0 +1,12 @@ |
|||||||
|
package com.hnac.hzims.business.interruption.constants; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface InterruptionConstants { |
||||||
|
|
||||||
|
List<String> INTERRUPTION_TYPE = Arrays.asList("13","14"); |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package com.hnac.hzims.scheduled.mapper.alarm; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.hnac.hzims.business.interruption.entity.InterruptionEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface InterruptionAlrmMapper extends BaseMapper<InterruptionEntity> { |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package com.hnac.hzims.scheduled.service.alarm; |
||||||
|
|
||||||
|
import com.hnac.hzims.business.interruption.entity.InterruptionEntity; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface InterruptionAlarmService extends BaseService<InterruptionEntity> { |
||||||
|
|
||||||
|
void interruption(String param); |
||||||
|
} |
@ -0,0 +1,87 @@ |
|||||||
|
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.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.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Calendar; |
||||||
|
import java.util.List; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@AllArgsConstructor |
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
@DS("alarm") |
||||||
|
public class InterruptionAlarmServiceImpl extends BaseServiceImpl<InterruptionAlrmMapper, InterruptionEntity> implements InterruptionAlarmService { |
||||||
|
|
||||||
|
private final StationService stationService; |
||||||
|
|
||||||
|
private final ISoeClient soeClient; |
||||||
|
|
||||||
|
/** |
||||||
|
* 数据中断告警 |
||||||
|
* @param param |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void interruption(String param) { |
||||||
|
// 查询接入站点
|
||||||
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
||||||
|
.eq(StationEntity::getDataOrigin,"0") |
||||||
|
); |
||||||
|
if(CollectionUtil.isEmpty(stations)){ |
||||||
|
return; |
||||||
|
} |
||||||
|
// 查询告警数据: 间隔10分钟
|
||||||
|
SoeQueryConditionByStation query = new SoeQueryConditionByStation(); |
||||||
|
query.setTypes(InterruptionConstants.INTERRUPTION_TYPE); |
||||||
|
query.setStationIds(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
||||||
|
Calendar calendar = Calendar.getInstance(); |
||||||
|
query.setEndTime(LocalDateTime.parse(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); |
||||||
|
calendar.add(Calendar.MINUTE,-10); |
||||||
|
query.setBeginTime(LocalDateTime.parse(DateUtil.format(calendar.getTime() , DateUtil.PATTERN_DATETIME),DateUtil.DATETIME_FORMATTER)); |
||||||
|
query.setNeedPage(false); |
||||||
|
query.setPage(1); |
||||||
|
query.setLimit(1000); |
||||||
|
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query); |
||||||
|
// 未查询到告警信息
|
||||||
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())) { |
||||||
|
return; |
||||||
|
} |
||||||
|
// 中断告警数据
|
||||||
|
List<SoeData> soes = result.getData().getRecords(); |
||||||
|
// 查询当天数据中断告警记录
|
||||||
|
List<InterruptionEntity> saves = this.saveInterruptions(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询当天数据中断告警记录 |
||||||
|
* @param stations |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private List<InterruptionEntity> saveInterruptions(List<String> stations) { |
||||||
|
this.list(Wrappers.<InterruptionEntity>lambdaQuery()); |
||||||
|
return new ArrayList<>(); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue