|
|
|
@ -5,6 +5,12 @@ import com.hnac.hzims.operational.main.constant.HomePageConstant;
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
import com.hnac.hzims.operational.main.vo.RealStationVo; |
|
|
|
|
import com.hnac.hzinfo.datasearch.PointData; |
|
|
|
|
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; |
|
|
|
|
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
import lombok.Getter; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
@ -15,7 +21,13 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.Instant; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -24,37 +36,75 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
public class CentralMonitorServiceImpl implements CentralMonitorService { |
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.monitor.station}") |
|
|
|
|
public String moniter_station_key; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取站点监控数据 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<RealStationVo> getStationMonitor() { |
|
|
|
|
// 根据用户权限获取机构
|
|
|
|
|
R<List<Dept>> R = sysClient.getDeptByCurrentUser(); |
|
|
|
|
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<Long> deptIdList = R.getData().stream().map(Dept::getId).collect(Collectors.toList()); |
|
|
|
|
List<StationEntity> list = stationService.getStationType(null, Collections.singletonList(HomePageConstant.HYDROPOWER),deptIdList); |
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<String> codeList = list.stream().map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtil.isEmpty(codeList)){ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<RealStationVo> result = (List<RealStationVo>) redisTemplate.opsForValue().get(moniter_station_key); |
|
|
|
|
if(StringUtil.isEmpty(result)){ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return result.stream().filter(o->codeList.contains(o.getStationCode())).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
private final IStationService stationService; |
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.monitor.station}") |
|
|
|
|
public String moniter_station_key; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取站点监控数据 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<RealStationVo> getStationMonitor() { |
|
|
|
|
// 根据用户权限获取机构
|
|
|
|
|
R<List<Dept>> R = sysClient.getDeptByCurrentUser(); |
|
|
|
|
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<Long> deptIdList = R.getData().stream().map(Dept::getId).collect(Collectors.toList()); |
|
|
|
|
List<StationEntity> list = stationService.getStationType(null, Collections.singletonList(HomePageConstant.HYDROPOWER), deptIdList); |
|
|
|
|
if (CollectionUtil.isEmpty(list)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<String> codeList = list.stream().map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isEmpty(codeList)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<RealStationVo> result = (List<RealStationVo>) redisTemplate.opsForValue().get(moniter_station_key); |
|
|
|
|
if (StringUtil.isEmpty(result)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return result.stream().filter(o -> codeList.contains(o.getStationCode())).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询通讯告警的最后一小时的运行数据 |
|
|
|
|
* |
|
|
|
|
* @param page 当前页 |
|
|
|
|
* @param size 每页记录数 |
|
|
|
|
* @param roleId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HzPage<PointData> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { |
|
|
|
|
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); |
|
|
|
|
originalDataQuery.setRealId(roleId); |
|
|
|
|
originalDataQuery.setLimit(size); |
|
|
|
|
LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
|
LocalDateTime endTime = startTime.minusHours(1); |
|
|
|
|
originalDataQuery.setBeginTime(this.getOriginalDate(startTime)); |
|
|
|
|
originalDataQuery.setEndTime(this.getOriginalDate(endTime)); |
|
|
|
|
Result<HzPage<PointData>> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); |
|
|
|
|
if (!originalDataByRealIds.isSuccess()) { |
|
|
|
|
throw new IllegalArgumentException("数据不存在"); |
|
|
|
|
} |
|
|
|
|
return originalDataByRealIds.getData(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* LocalDateTime 转 date |
|
|
|
|
* @param localDateTime |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static Date getOriginalDate(LocalDateTime localDateTime) { |
|
|
|
|
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant(); |
|
|
|
|
return Date.from(instant); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|