|
|
|
@ -168,7 +168,6 @@ public class IotMonitoringDataJob { |
|
|
|
lastWorkingStatState.update(machineWorkingStat); |
|
|
|
lastPwStatState.update(machinePwrStat); |
|
|
|
Long reportTime = receivedEvent.getReportTime(); |
|
|
|
Long accJobCount = receivedEvent.getAccJobCount(); |
|
|
|
// 1树根 0机智云 |
|
|
|
Integer dataSource = receivedEvent.getDataSource(); |
|
|
|
// 当前数据 |
|
|
|
@ -303,7 +302,7 @@ public class IotMonitoringDataJob { |
|
|
|
if (value == null) { |
|
|
|
value = new DeviceTotalData(); |
|
|
|
// 从es中获取 |
|
|
|
DeviceMonitoringData deviceMonitoringData = queryLatestDeviceMonitoringData(event.getMachineIotMac(), null); |
|
|
|
DeviceMonitoringData deviceMonitoringData = queryLatestDeviceMonitoringData(event.getMachineIotMac()); |
|
|
|
if (deviceMonitoringData != null) { |
|
|
|
value.setJobDurationTotal(deviceMonitoringData.getAccJobCountDuration()); |
|
|
|
value.setJobTotal(deviceMonitoringData.getAccJobCount()); |
|
|
|
@ -322,29 +321,6 @@ public class IotMonitoringDataJob { |
|
|
|
} |
|
|
|
// 是否日期是当天的,否则需要更新当天工作时长和当天工作量 |
|
|
|
if (LocalDate.parse(value.getCurrLocalDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).isBefore(localDate)) { |
|
|
|
// 先从es中拿昨天最新的 |
|
|
|
/*DeviceMonitoringData deviceMonitoringData = queryLatestDeviceMonitoringData(event.getMachineIotMac(), |
|
|
|
LocalDateTime.of(localDate, LocalTime.MIN).atZone(ZoneOffset.of("+8")).toEpochSecond()); |
|
|
|
if (deviceMonitoringData != null) { |
|
|
|
data.setJobTotal(deviceMonitoringData.getAccJobCount()); |
|
|
|
data.setJobDurationTotal(deviceMonitoringData.getAccJobCountDuration()); |
|
|
|
data.setTheDayJobDuration(deviceMonitoringData.getCurrJobDuration()); |
|
|
|
data.setTheDayJobCount(deviceMonitoringData.getCurrJobCount()); |
|
|
|
data.setCurrLocalDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
data.setLastBootTime(deviceMonitoringData.getLastBootTime()); |
|
|
|
data.setReportTime(deviceMonitoringData.getReportTime()); |
|
|
|
data.setTheDayDuration(0L); |
|
|
|
} else { |
|
|
|
// value有值,但是日期不对,说明到了第二天,那么,只需要对当天数据清零即可 |
|
|
|
data.setJobTotal(value.getJobTotal()); |
|
|
|
data.setJobDurationTotal(value.getJobDurationTotal()); |
|
|
|
data.setTheDayJobDuration(0L); |
|
|
|
data.setTheDayJobCount(0L); |
|
|
|
data.setCurrLocalDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
data.setLastBootTime(value.getLastBootTime()); |
|
|
|
data.setTheDayDuration(0L); |
|
|
|
data.setReportTime(reportTime); |
|
|
|
}*/ |
|
|
|
// value有值,但是日期不对,说明到了第二天,那么,只需要对当天数据清零即可 |
|
|
|
value.setTheDayJobDuration(0L); |
|
|
|
value.setTheDayJobCount(0L); |
|
|
|
@ -415,15 +391,12 @@ public class IotMonitoringDataJob { |
|
|
|
return deviceTotalData; |
|
|
|
} |
|
|
|
|
|
|
|
private DeviceMonitoringData queryLatestDeviceMonitoringData(Long machineIotMac, Long reportTime) { |
|
|
|
private DeviceMonitoringData queryLatestDeviceMonitoringData(Long machineIotMac) { |
|
|
|
|
|
|
|
try { |
|
|
|
// 构建查询条件(注意:termQuery 支持多种格式查询,如 boolean、int、double、string 等,这里使用的是 string 的查询) |
|
|
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
|
|
|
searchSourceBuilder.query(QueryBuilders.termQuery("machineIotMac", machineIotMac)); |
|
|
|
if (reportTime != null) { |
|
|
|
searchSourceBuilder.query(QueryBuilders.rangeQuery("reportTime").lt(reportTime)); |
|
|
|
} |
|
|
|
searchSourceBuilder.sort("reportTime", SortOrder.DESC); |
|
|
|
searchSourceBuilder.size(1); |
|
|
|
// 创建查询请求对象,将查询对象配置到其中 |
|
|
|
|