|
|
@ -1,29 +1,53 @@ |
|
|
|
package com.hnac.hzims.scheduled.service.operation.report.impl; |
|
|
|
package com.hnac.hzims.scheduled.service.operation.report.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
|
|
|
|
import com.hnac.hzims.alarm.config.constants.AlarmConstants; |
|
|
|
|
|
|
|
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; |
|
|
|
|
|
|
|
import com.hnac.hzims.common.logs.utils.StringUtils; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.equipment.vo.RideDeviceVo; |
|
|
|
import com.hnac.hzims.message.dto.MailPushDto; |
|
|
|
import com.hnac.hzims.message.dto.MailPushDto; |
|
|
|
import com.hnac.hzims.message.fegin.IPushMsgClient; |
|
|
|
import com.hnac.hzims.message.fegin.IPushMsgClient; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.MaintainVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.MaintainVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.OverhaulVo; |
|
|
|
import com.hnac.hzims.operational.main.vo.OverhaulVo; |
|
|
|
import com.hnac.hzims.operational.report.vo.DutyDefectVO; |
|
|
|
import com.hnac.hzims.operational.report.entity.RunMonthEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.report.vo.*; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; |
|
|
|
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; |
|
|
|
|
|
|
|
import com.hnac.hzims.scheduled.service.equipment.DeviceService; |
|
|
|
import com.hnac.hzims.scheduled.service.equipment.PlanService; |
|
|
|
import com.hnac.hzims.scheduled.service.equipment.PlanService; |
|
|
|
import com.hnac.hzims.scheduled.service.inspect.TaskService; |
|
|
|
import com.hnac.hzims.scheduled.service.inspect.TaskService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.AccessService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.AccessService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.MaintenanceService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.PhenomenonService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.business.PhenomenonService; |
|
|
|
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.plate.DataService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.report.ReportService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.report.ReportService; |
|
|
|
|
|
|
|
import com.hnac.hzims.scheduled.service.operation.report.RunMonService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.station.StationService; |
|
|
|
import com.hnac.hzims.scheduled.service.operation.station.StationService; |
|
|
|
import com.hnac.hzims.scheduled.service.safeproduct.MonthService; |
|
|
|
import com.hnac.hzims.scheduled.service.safeproduct.MonthService; |
|
|
|
import com.hnac.hzims.scheduled.service.safeproduct.TrialService; |
|
|
|
import com.hnac.hzims.scheduled.service.safeproduct.TrialService; |
|
|
|
import com.hnac.hzims.scheduled.service.ticket.TicketService; |
|
|
|
import com.hnac.hzims.scheduled.service.ticket.TicketService; |
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; |
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.PointData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; |
|
|
|
|
|
|
|
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.inspect.task.vo.DutyInspectTaskVO; |
|
|
|
import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
@ -58,19 +82,44 @@ import java.util.stream.Collectors; |
|
|
|
public class ReportServiceImpl implements ReportService { |
|
|
|
public class ReportServiceImpl implements ReportService { |
|
|
|
|
|
|
|
|
|
|
|
private final PlanService planService; |
|
|
|
private final PlanService planService; |
|
|
|
|
|
|
|
|
|
|
|
private final TaskService taskService; |
|
|
|
private final TaskService taskService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final DataService dataService; |
|
|
|
|
|
|
|
|
|
|
|
private final TrialService trialService; |
|
|
|
private final TrialService trialService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final MonthService monthService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RunMonService runMonService; |
|
|
|
|
|
|
|
|
|
|
|
private final AccessService accessService; |
|
|
|
private final AccessService accessService; |
|
|
|
|
|
|
|
|
|
|
|
private final TicketService ticketService; |
|
|
|
private final TicketService ticketService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final DeviceService deviceService; |
|
|
|
|
|
|
|
|
|
|
|
private final StationService stationService; |
|
|
|
private final StationService stationService; |
|
|
|
private final MonthService monthService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final PhenomenonService phenomenonService; |
|
|
|
private final PhenomenonService phenomenonService; |
|
|
|
|
|
|
|
|
|
|
|
private final MaintenanceService maintenanceService; |
|
|
|
private final MaintenanceService maintenanceService; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISoeClient soeClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final SoeDataClient soeDataClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IPushMsgClient pushMsgClient; |
|
|
|
private final IPushMsgClient pushMsgClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
private final static String recent_year_cache_final = "hzims:operation:key:power:data"; |
|
|
|
private final static String recent_year_cache_final = "hzims:operation:key:power:data"; |
|
|
|
|
|
|
|
|
|
|
|
public final static String wind_recent_year_cache = "hzims:operation:wind:power:data"; |
|
|
|
public final static String wind_recent_year_cache = "hzims:operation:wind:power:data"; |
|
|
@ -568,4 +617,439 @@ public class ReportServiceImpl implements ReportService { |
|
|
|
pushDto.setCreateDept(dept.getId()); |
|
|
|
pushDto.setCreateDept(dept.getId()); |
|
|
|
pushMsgClient.sendMail(pushDto); |
|
|
|
pushMsgClient.sendMail(pushDto); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 运行月报告 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void runMonthReport(String param) { |
|
|
|
|
|
|
|
// 查询接入站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(StationEntity::getDataOrigin,HomePageConstant.DATA_ORIGIN) |
|
|
|
|
|
|
|
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
|
|
|
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
|
|
|
// 查询站点设备
|
|
|
|
|
|
|
|
List<RideDeviceVo> devices = deviceService.rideDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
|
|
|
List<RunMonthEntity> runs = new ArrayList<>(); |
|
|
|
|
|
|
|
stations.forEach(station->{ |
|
|
|
|
|
|
|
RunMonthEntity run = new RunMonthEntity(); |
|
|
|
|
|
|
|
run.setStationCode(station.getCode()); |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
//calendar.setTime(new Date());
|
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
|
|
|
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM")); |
|
|
|
|
|
|
|
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stationDevices)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 运行数据
|
|
|
|
|
|
|
|
run.setRunData(this.runData(station.getCode(),stationDevices,plans)); |
|
|
|
|
|
|
|
// 告警数据
|
|
|
|
|
|
|
|
run.setAlarmData(this.alarmData(station.getCode())); |
|
|
|
|
|
|
|
// 月度运行曲线
|
|
|
|
|
|
|
|
run.setCurveData(this.curveData(stationDevices)); |
|
|
|
|
|
|
|
// TODO 运行数据分析
|
|
|
|
|
|
|
|
// TODO 运行建议及其他
|
|
|
|
|
|
|
|
runs.add(run); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
runMonService.saveBatch(runs); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 运行数据 |
|
|
|
|
|
|
|
* @param devices |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String runData(String stationCode,List<RideDeviceVo> devices,List<PlanGenerationEntity> plans) { |
|
|
|
|
|
|
|
List<RunDataVo> runs = new ArrayList<>(); |
|
|
|
|
|
|
|
devices.forEach(device->{ |
|
|
|
|
|
|
|
RunDataVo run = new RunDataVo(); |
|
|
|
|
|
|
|
run.setDeviceCode(device.getNumber()); |
|
|
|
|
|
|
|
run.setDeviceName(device.getName()); |
|
|
|
|
|
|
|
// 运行时长
|
|
|
|
|
|
|
|
run.setRunHours(this.runHours(device)); |
|
|
|
|
|
|
|
// 月发电量
|
|
|
|
|
|
|
|
run.setGenerate(this.generate(0,device.getNumber(),device.getRide())); |
|
|
|
|
|
|
|
// 年发电量
|
|
|
|
|
|
|
|
run.setGenerateYear(this.generate(1,device.getNumber(),device.getRide())); |
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
|
|
|
run.setPlan(this.planGenerate(0,stationCode,plans)); |
|
|
|
|
|
|
|
// 年计划发电量
|
|
|
|
|
|
|
|
run.setPlanYear(this.planGenerate(1,stationCode,plans)); |
|
|
|
|
|
|
|
runs.add(run); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return JSONObject.toJSONString(runs); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 实际发电量 |
|
|
|
|
|
|
|
* @param type |
|
|
|
|
|
|
|
* @param deviceCode |
|
|
|
|
|
|
|
* @param ride |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Double generate(int type,String deviceCode,int ride) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
//calendar.setTime(new Date());
|
|
|
|
|
|
|
|
String end = null,start = null; |
|
|
|
|
|
|
|
int cycleType = 5; |
|
|
|
|
|
|
|
switch (type){ |
|
|
|
|
|
|
|
case 0 : |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1 : |
|
|
|
|
|
|
|
cycleType = 6; |
|
|
|
|
|
|
|
end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Double.valueOf(dataService.periodTargetFloat(start,end,5,cycleType,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 计划发电量 |
|
|
|
|
|
|
|
* @param type |
|
|
|
|
|
|
|
* @param stationCode |
|
|
|
|
|
|
|
* @param plans |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Double planGenerate(int type, String stationCode,List<PlanGenerationEntity> plans) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
//calendar.setTime(new Date());
|
|
|
|
|
|
|
|
if(type == 0){ |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
String time = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time)) |
|
|
|
|
|
|
|
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String time = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time)) |
|
|
|
|
|
|
|
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取运行数据 |
|
|
|
|
|
|
|
* @param device |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Double runHours(EmInfoEntity device) { |
|
|
|
|
|
|
|
MultiAnalyzeCodePO analyze = new MultiAnalyzeCodePO(); |
|
|
|
|
|
|
|
analyze.setDeviceCode(device.getNumber()); |
|
|
|
|
|
|
|
analyze.setSignages(Collections.singletonList(HomePageConstant.ACTIVE_POWER)); |
|
|
|
|
|
|
|
List<AnalyzeCodeBySignagesVO> signages = dataService.analyzeCodeBySignages(Collections.singletonList(analyze)); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(signages)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 监测点
|
|
|
|
|
|
|
|
String realId = signages.get(0).getRealId(); |
|
|
|
|
|
|
|
if(StringUtils.isEmpty(realId)){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 确定查询时间范围: 年、月
|
|
|
|
|
|
|
|
Date startDate,endDate; |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
//calendar.setTime(new Date());
|
|
|
|
|
|
|
|
endDate = calendar.getTime(); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
|
|
|
|
|
|
|
startDate = calendar.getTime(); |
|
|
|
|
|
|
|
return this.getRunConvertData(realId,startDate,endDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取时间范围内运行时长 |
|
|
|
|
|
|
|
* @param realId |
|
|
|
|
|
|
|
* @param startDate |
|
|
|
|
|
|
|
* @param endDate |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Double getRunConvertData(String realId, Date startDate, Date endDate) { |
|
|
|
|
|
|
|
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); |
|
|
|
|
|
|
|
originalDataQuery.setRealId(realId); |
|
|
|
|
|
|
|
originalDataQuery.setBeginTime(startDate); |
|
|
|
|
|
|
|
originalDataQuery.setEndTime(endDate); |
|
|
|
|
|
|
|
originalDataQuery.setLimit(100000); |
|
|
|
|
|
|
|
originalDataQuery.setPage(1); |
|
|
|
|
|
|
|
// 查询时间范围开关机监测点历史数据
|
|
|
|
|
|
|
|
Result<HzPage<PointData>> result = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); |
|
|
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 开机运行时长
|
|
|
|
|
|
|
|
long time = this.getRunTime(result.getData().getRecords(),startDate,endDate); |
|
|
|
|
|
|
|
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取运行时长 |
|
|
|
|
|
|
|
* @param result |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private long getRunTime(List<PointData> result,Date startDate,Date endDate) { |
|
|
|
|
|
|
|
if(result.size() == 1){ |
|
|
|
|
|
|
|
// 一直开机
|
|
|
|
|
|
|
|
if(Double.parseDouble(result.get(0).getValue()) > 0){ |
|
|
|
|
|
|
|
return endDate.getTime() - startDate.getTime(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 一直关机
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
long time=0; |
|
|
|
|
|
|
|
// 遍历累计开机时长
|
|
|
|
|
|
|
|
for(int i = 0; i< result.size() ; i++){ |
|
|
|
|
|
|
|
// 记录为开机状态 就计算到下次关机的时间差
|
|
|
|
|
|
|
|
if(Double.parseDouble(result.get(i).getValue()) <= 0){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// 遍历至最后一条数据,累计至当前时间
|
|
|
|
|
|
|
|
if(i == result.size() - 1){ |
|
|
|
|
|
|
|
endTime = endDate; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
time += endTime.getTime() - startTime.getTime(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return time; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 告警数据 |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String alarmData(String code) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-1); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
// HZ3000:故障告警
|
|
|
|
|
|
|
|
List<RunAlarmVo> alarms = this.hz3000Alarm(code,start,end); |
|
|
|
|
|
|
|
// FIXME 设备实例:一级告警
|
|
|
|
|
|
|
|
// FDP智能预警
|
|
|
|
|
|
|
|
// alarms.addAll(this.intelligentEarly(code,start,end));
|
|
|
|
|
|
|
|
return JSONObject.toJSONString(alarms); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询hz3000告警 |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<RunAlarmVo> hz3000Alarm(String code,String start,String end) { |
|
|
|
|
|
|
|
SoeQueryConditionByStation query = new SoeQueryConditionByStation(); |
|
|
|
|
|
|
|
query.setStationIds(Collections.singletonList(code)); |
|
|
|
|
|
|
|
query.setTypes(Collections.singletonList(AlarmHandleConstant.FAULT)); |
|
|
|
|
|
|
|
query.setBeginTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
|
|
|
query.setEndTime(LocalDateTime.parse(end,DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
|
|
|
query.setNeedPage(false); |
|
|
|
|
|
|
|
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query); |
|
|
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.getData().getRecords().stream().collect(Collectors.groupingBy(SoeData::getSoeExplain)).entrySet().stream().map(entry->{ |
|
|
|
|
|
|
|
RunAlarmVo alarm = new RunAlarmVo(); |
|
|
|
|
|
|
|
alarm.setAlarmTime(DateUtil.format(entry.getValue().stream().sorted(Comparator.comparing(SoeData::getTs)).collect(Collectors.toList()).get(0).getTs(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
alarm.setDeviceName(entry.getValue().get(0).getDeviceName()); |
|
|
|
|
|
|
|
alarm.setContent(entry.getKey()); |
|
|
|
|
|
|
|
alarm.setType(String.valueOf(AlarmConstants.FAULT)); |
|
|
|
|
|
|
|
alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1)); |
|
|
|
|
|
|
|
return alarm; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 智能预警 |
|
|
|
|
|
|
|
* @param code |
|
|
|
|
|
|
|
* @param start |
|
|
|
|
|
|
|
* @param end |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<RunAlarmVo> intelligentEarly(String code, String start, String end) { |
|
|
|
|
|
|
|
StbAnalysisDTO param = new StbAnalysisDTO(); |
|
|
|
|
|
|
|
param.setStartTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
|
|
|
param.setEndTime(LocalDateTime.parse(end, DateUtil.DATETIME_FORMATTER)); |
|
|
|
|
|
|
|
param.setStation(code); |
|
|
|
|
|
|
|
param.setPage(0); |
|
|
|
|
|
|
|
param.setPageSize(100000); |
|
|
|
|
|
|
|
Result<HzPage<StbAnalysisVO>> result = soeDataClient.pageStbAnalysis(param); |
|
|
|
|
|
|
|
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getContent)).entrySet().stream().map(entry->{ |
|
|
|
|
|
|
|
RunAlarmVo alarm = new RunAlarmVo(); |
|
|
|
|
|
|
|
alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs()); |
|
|
|
|
|
|
|
alarm.setDeviceName(entry.getValue().get(0).getDevicename()); |
|
|
|
|
|
|
|
alarm.setContent(entry.getKey()); |
|
|
|
|
|
|
|
alarm.setType(String.valueOf(AlarmConstants.EARLY)); |
|
|
|
|
|
|
|
alarm.setCount(entry.getValue().size()); |
|
|
|
|
|
|
|
return alarm; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 运行曲线 |
|
|
|
|
|
|
|
* @param devices |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String curveData(List<RideDeviceVo> devices) { |
|
|
|
|
|
|
|
List<CurveDataVo> curveDatas = devices.stream().map(device->{ |
|
|
|
|
|
|
|
CurveDataVo curveData = new CurveDataVo(); |
|
|
|
|
|
|
|
curveData.setDeviceCode(device.getNumber()); |
|
|
|
|
|
|
|
curveData.setDeviceName(device.getName()); |
|
|
|
|
|
|
|
// 负荷曲线
|
|
|
|
|
|
|
|
curveData.setLoadCurve(this.curve(this.attribute(0),device.getNumber())); |
|
|
|
|
|
|
|
// 轴承温度曲线
|
|
|
|
|
|
|
|
curveData.setBearingTempCurve(this.curve(this.attribute(1),device.getNumber())); |
|
|
|
|
|
|
|
// 定子温度曲线
|
|
|
|
|
|
|
|
curveData.setStatorTempCurve(this.curve(this.attribute(2),device.getNumber())); |
|
|
|
|
|
|
|
return curveData; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return JSONObject.toJSONString(curveDatas); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取曲线数据 |
|
|
|
|
|
|
|
* @param attributes |
|
|
|
|
|
|
|
* @param deviceCode |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<CurveAttributeVo> curve(List<AttributeVo> attributes, String deviceCode) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
//calendar.setTime(new Date());
|
|
|
|
|
|
|
|
calendar.setTime(DateUtil.parse("2024-01-01 00:00:00",DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-1); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-1); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
List<CurveAttributeVo> curveAttributes = new ArrayList<>(); |
|
|
|
|
|
|
|
attributes.forEach(attribute -> { |
|
|
|
|
|
|
|
CurveAttributeVo signage = new CurveAttributeVo(); |
|
|
|
|
|
|
|
signage.setAttribute(attribute.getSignage()); |
|
|
|
|
|
|
|
signage.setAttributeName(attribute.getSignageName()); |
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> records = dataService.periodTargetData(start,end,3,3,deviceCode,attribute.getSignage()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(records)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
signage.setCurves(records.stream().map(record -> { |
|
|
|
|
|
|
|
CurveVo curve = new CurveVo(); |
|
|
|
|
|
|
|
Date date = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
|
|
|
if(date.getDate() > 9){ |
|
|
|
|
|
|
|
curve.setTime("0" + date.getDay()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
curve.setTime(date.getDay() + ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtil.isEmpty(record.getVal())){ |
|
|
|
|
|
|
|
curve.setValue(0.0); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
curve.setValue(Double.valueOf(record.getVal())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return curve; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
curveAttributes.add(signage); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return curveAttributes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 曲线属性获取 |
|
|
|
|
|
|
|
* @param attributeType |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<AttributeVo> attribute(int attributeType) { |
|
|
|
|
|
|
|
List<AttributeVo> attributes = new ArrayList<>(); |
|
|
|
|
|
|
|
switch (attributeType){ |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
AttributeVo attribute = new AttributeVo(); |
|
|
|
|
|
|
|
attribute.setSignage(HomePageConstant.ACTIVE_POWER); |
|
|
|
|
|
|
|
attribute.setSignageName("负荷"); |
|
|
|
|
|
|
|
attributes.add(attribute); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttributeVo upper_temp = new AttributeVo(); |
|
|
|
|
|
|
|
upper_temp.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_TEMP); |
|
|
|
|
|
|
|
upper_temp.setSignageName("上导轴承瓦温1"); |
|
|
|
|
|
|
|
attributes.add(upper_temp); |
|
|
|
|
|
|
|
AttributeVo oil_tem = new AttributeVo(); |
|
|
|
|
|
|
|
oil_tem.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP); |
|
|
|
|
|
|
|
oil_tem.setSignageName("上导轴承油槽温度"); |
|
|
|
|
|
|
|
attributes.add(oil_tem); |
|
|
|
|
|
|
|
AttributeVo thrust_tem = new AttributeVo(); |
|
|
|
|
|
|
|
thrust_tem.setSignage(HomePageConstant.THRUST_BEARING_TEMP); |
|
|
|
|
|
|
|
thrust_tem.setSignageName("推力轴瓦温度1"); |
|
|
|
|
|
|
|
attributes.add(thrust_tem); |
|
|
|
|
|
|
|
AttributeVo lower_tem = new AttributeVo(); |
|
|
|
|
|
|
|
lower_tem.setSignage(HomePageConstant.LOWER_GUIDE_BEARING_TEMP); |
|
|
|
|
|
|
|
lower_tem.setSignageName("下导轴承瓦温1"); |
|
|
|
|
|
|
|
attributes.add(lower_tem); |
|
|
|
|
|
|
|
AttributeVo tank_tem = new AttributeVo(); |
|
|
|
|
|
|
|
tank_tem.setSignage(HomePageConstant.LOWER_GUIDE_OIL_TANK_TEMP); |
|
|
|
|
|
|
|
tank_tem.setSignageName("下导油槽温度"); |
|
|
|
|
|
|
|
attributes.add(tank_tem); |
|
|
|
|
|
|
|
AttributeVo tile_tem = new AttributeVo(); |
|
|
|
|
|
|
|
tile_tem.setSignage(HomePageConstant.WATER_GUIDE_TILE_TEMP); |
|
|
|
|
|
|
|
tile_tem.setSignageName("水导瓦温"); |
|
|
|
|
|
|
|
attributes.add(tile_tem); |
|
|
|
|
|
|
|
AttributeVo water_tem = new AttributeVo(); |
|
|
|
|
|
|
|
water_tem.setSignage(HomePageConstant.WATER_GUIDE_OIL_TANK_TEMP); |
|
|
|
|
|
|
|
water_tem.setSignageName("水导油槽温度"); |
|
|
|
|
|
|
|
attributes.add(water_tem); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
AttributeVo A_tem = new AttributeVo(); |
|
|
|
|
|
|
|
A_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP); |
|
|
|
|
|
|
|
A_tem.setSignageName("A相铁芯温度1"); |
|
|
|
|
|
|
|
attributes.add(A_tem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttributeVo B_tem = new AttributeVo(); |
|
|
|
|
|
|
|
B_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP); |
|
|
|
|
|
|
|
B_tem.setSignageName("B相铁芯温度1"); |
|
|
|
|
|
|
|
attributes.add(B_tem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AttributeVo C_tem = new AttributeVo(); |
|
|
|
|
|
|
|
C_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP); |
|
|
|
|
|
|
|
C_tem.setSignageName("C相铁芯温度1"); |
|
|
|
|
|
|
|
attributes.add(C_tem); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return attributes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |