|
|
|
@ -1,34 +1,47 @@
|
|
|
|
|
package com.hnac.hzims.operational.census.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
import com.hnac.hzims.fdp.feign.IFdpMonitorClient; |
|
|
|
|
import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; |
|
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
|
import com.hnac.hzims.operational.access.service.IOperAccessTaskService; |
|
|
|
|
import com.hnac.hzims.operational.census.service.AreaDutyService; |
|
|
|
|
import com.hnac.hzims.operational.census.vo.AreaAssetDeviceVo; |
|
|
|
|
import com.hnac.hzims.operational.census.vo.AreaAssetVo; |
|
|
|
|
import com.hnac.hzims.operational.census.vo.AreaTimelyVo; |
|
|
|
|
import com.hnac.hzims.operational.config.vo.FaultVo; |
|
|
|
|
import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; |
|
|
|
|
import com.hnac.hzims.operational.main.vo.AreaDutyVo; |
|
|
|
|
import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; |
|
|
|
|
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; |
|
|
|
|
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; |
|
|
|
|
import com.hnac.hzims.operational.maintenance.service.MaintenanceService; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
import com.hnac.hzims.spare.feign.ISpareClient; |
|
|
|
|
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; |
|
|
|
|
import com.hnac.hzinfo.inspect.task.feign.IInspectTaskClient; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
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.springblade.system.entity.Dept; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Array; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -51,10 +64,19 @@ public class AreaDutyServiceImpl implements AreaDutyService {
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
private final IOperMaintenanceTaskService maintenanceService; |
|
|
|
|
|
|
|
|
|
private final IOperAccessTaskService accessTaskService; |
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
private final ISpareClient spareClient; |
|
|
|
|
|
|
|
|
|
private final IFdpMonitorClient monitorClient; |
|
|
|
|
|
|
|
|
|
private final IInspectTaskClient inspectTaskClient; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 区域值班数据 |
|
|
|
@ -63,7 +85,7 @@ public class AreaDutyServiceImpl implements AreaDutyService {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public AreaDutyVo duty(Long deptId) { |
|
|
|
|
List<AreaDutyVo> dutys = (List<AreaDutyVo>) redisTemplate.opsForValue().get(area_duty_cache_final);; |
|
|
|
|
List<AreaDutyVo> dutys = (List<AreaDutyVo>) redisTemplate.opsForValue().get(area_duty_cache_final); |
|
|
|
|
if(CollectionUtil.isEmpty(dutys)){ |
|
|
|
|
return new AreaDutyVo(); |
|
|
|
|
} |
|
|
|
@ -77,22 +99,176 @@ public class AreaDutyServiceImpl implements AreaDutyService {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<AreaTimelyVo> timely(Long deptId,Integer type) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
switch (type){ |
|
|
|
|
case 1: |
|
|
|
|
break; |
|
|
|
|
return this.early(deptId); |
|
|
|
|
case 2: |
|
|
|
|
break; |
|
|
|
|
return this.inspection(start,end,deptId); |
|
|
|
|
case 3: |
|
|
|
|
break; |
|
|
|
|
return this.overhaul(start,end,deptId); |
|
|
|
|
case 4: |
|
|
|
|
break; |
|
|
|
|
return this.maintenance(start,end,deptId); |
|
|
|
|
case 5: |
|
|
|
|
break; |
|
|
|
|
return this.regular(deptId); |
|
|
|
|
default: |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预警 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AreaTimelyVo> early(Long deptId) { |
|
|
|
|
// 查询子机构
|
|
|
|
|
R<List<Dept>> result = sysClient.getDeptChild(deptId); |
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 站点
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
.in(StationEntity::getRefDept,result.getData().stream().map(Dept::getId).collect(Collectors.toList())) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 预警信息查询
|
|
|
|
|
String response = monitorClient.getFaultList(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
if (StringUtil.isBlank(response)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
List<FaultVo> earlys = JSONArray.parseArray(response,FaultVo.class); |
|
|
|
|
if(CollectionUtil.isEmpty(earlys)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 遍历
|
|
|
|
|
return earlys.stream().map(early->{ |
|
|
|
|
AreaTimelyVo timely = new AreaTimelyVo(); |
|
|
|
|
timely.setEventId(early.getFaultId()); |
|
|
|
|
timely.setContent(early.getFinfo()); |
|
|
|
|
timely.setDeptName(early.getStation()); |
|
|
|
|
timely.setTime(early.getCreateTime()); |
|
|
|
|
int sum = this.eventToHours(LocalDateTime.parse(early.getCreateTime(),DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
timely.setSum(sum); |
|
|
|
|
timely.setColour(0); |
|
|
|
|
if(sum > 12){ |
|
|
|
|
timely.setColour(1); |
|
|
|
|
} |
|
|
|
|
return timely; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 巡检 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AreaTimelyVo> inspection(String start,String end,Long deptId) { |
|
|
|
|
List<TaskEntity> expires = inspectTaskClient.expireInspect(start,end,deptId); |
|
|
|
|
if(CollectionUtil.isEmpty(expires)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return expires.stream().map(expire->{ |
|
|
|
|
AreaTimelyVo timely = new AreaTimelyVo(); |
|
|
|
|
timely.setEventId(String.valueOf(expire.getId())); |
|
|
|
|
timely.setContent(expire.getPlanName()); |
|
|
|
|
R<Dept> result = sysClient.getDept(expire.getCreateDept()); |
|
|
|
|
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ |
|
|
|
|
timely.setDeptName(result.getData().getDeptName()); |
|
|
|
|
} |
|
|
|
|
timely.setTime(expire.getPlanEndTime().format(DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
int sum = this.eventToHours(expire.getPlanEndTime()); |
|
|
|
|
timely.setSum(sum); |
|
|
|
|
timely.setColour(0); |
|
|
|
|
if(sum < 12){ |
|
|
|
|
timely.setColour(1); |
|
|
|
|
} |
|
|
|
|
return timely; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检修 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AreaTimelyVo> overhaul(String start,String end,Long deptId) { |
|
|
|
|
List<OperAccessTaskEntity> overhauls = accessTaskService.list(Wrappers.<OperAccessTaskEntity>lambdaQuery() |
|
|
|
|
.ge(OperAccessTaskEntity::getPlanEndTime,start) |
|
|
|
|
.le(OperAccessTaskEntity::getPlanEndTime,end) |
|
|
|
|
.ne(OperAccessTaskEntity::getStatus,4) |
|
|
|
|
.like(OperAccessTaskEntity::getCreateDept,deptId) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(overhauls)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return overhauls.stream().map(overhaul->{ |
|
|
|
|
AreaTimelyVo timely = new AreaTimelyVo(); |
|
|
|
|
timely.setEventId(String.valueOf(overhaul.getId())); |
|
|
|
|
timely.setContent(overhaul.getName()); |
|
|
|
|
R<Dept> result = sysClient.getDept(overhaul.getCreateDept()); |
|
|
|
|
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ |
|
|
|
|
timely.setDeptName(result.getData().getDeptName()); |
|
|
|
|
} |
|
|
|
|
timely.setTime(DateUtil.format(overhaul.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
int sum = this.eventToHours(LocalDateTime.ofInstant(overhaul.getPlanEndTime().toInstant(), ZoneId.systemDefault())); |
|
|
|
|
timely.setSum(sum); |
|
|
|
|
timely.setColour(0); |
|
|
|
|
if(sum < 12){ |
|
|
|
|
timely.setColour(1); |
|
|
|
|
} |
|
|
|
|
return timely; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 日常维护 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AreaTimelyVo> maintenance(String start,String end,Long deptId) { |
|
|
|
|
List<OperMaintenanceTaskEntity> maintenances = maintenanceService.list(Wrappers.<OperMaintenanceTaskEntity>lambdaQuery() |
|
|
|
|
.ge(OperMaintenanceTaskEntity::getPlanEndTime,start) |
|
|
|
|
.le(OperMaintenanceTaskEntity::getPlanEndTime,end) |
|
|
|
|
.ne(OperMaintenanceTaskEntity::getFlowTaskName,"结束") |
|
|
|
|
.like(OperMaintenanceTaskEntity::getCreateDept,deptId) |
|
|
|
|
); |
|
|
|
|
if(CollectionUtil.isEmpty(maintenances)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return maintenances.stream().map(maintenance -> { |
|
|
|
|
AreaTimelyVo timely = new AreaTimelyVo(); |
|
|
|
|
timely.setEventId(String.valueOf(maintenance.getId())); |
|
|
|
|
timely.setContent(maintenance.getTitle()); |
|
|
|
|
R<Dept> result = sysClient.getDept(maintenance.getCreateDept()); |
|
|
|
|
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ |
|
|
|
|
timely.setDeptName(result.getData().getDeptName()); |
|
|
|
|
} |
|
|
|
|
timely.setTime(DateUtil.format(maintenance.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
int sum = this.eventToHours(maintenance.getPlanEndTime()); |
|
|
|
|
timely.setSum(sum); |
|
|
|
|
timely.setColour(0); |
|
|
|
|
if(sum < 12){ |
|
|
|
|
timely.setColour(1); |
|
|
|
|
} |
|
|
|
|
return timely; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 固定资产 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AreaTimelyVo> regular(Long deptId) { |
|
|
|
|
return spareClient.exceedLimit(deptId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 资产信息 |
|
|
|
@ -143,6 +319,14 @@ public class AreaDutyServiceImpl implements AreaDutyService {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 事件产生时长 |
|
|
|
|
* @param startTime |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private int eventToHours(LocalDateTime startTime) { |
|
|
|
|
// 计算投运时间与当前时间相隔天数
|
|
|
|
|
Duration dur = Duration.between(startTime, LocalDateTime.now()); |
|
|
|
|
return Math.abs((int) dur.toHours()); |
|
|
|
|
} |
|
|
|
|
} |