Browse Source

更新

feature_hph_新增rabbitmq_sink
1049970895@qniao.cn 3 years ago
parent
commit
d293500fd9
1 changed files with 10 additions and 45 deletions
  1. 55
      src/main/java/com/qniao/iot/IotMonitoringDataJob.java

55
src/main/java/com/qniao/iot/IotMonitoringDataJob.java

@ -150,40 +150,21 @@ public class IotMonitoringDataJob {
// 如果当前消息的时间大于等于上次消息的时间才进行处理 // 如果当前消息的时间大于等于上次消息的时间才进行处理
Integer machinePwrStat = receivedEvent.getMachinePwrStat(); Integer machinePwrStat = receivedEvent.getMachinePwrStat();
Integer machineWorkingStat = receivedEvent.getMachineWorkingStat(); Integer machineWorkingStat = receivedEvent.getMachineWorkingStat();
// 1树根 0机智云
Integer dataSource = receivedEvent.getDataSource();
// 当前数据 // 当前数据
DeviceTotalData nowDeviceState = new DeviceTotalData(); DeviceTotalData nowDeviceState = new DeviceTotalData();
nowDeviceState.setMachinePwrStat(machinePwrStat); nowDeviceState.setMachinePwrStat(machinePwrStat);
nowDeviceState.setMachineWorkingStat(machineWorkingStat); nowDeviceState.setMachineWorkingStat(machineWorkingStat);
LocalDate localDate = new Date(reportTime).toLocalDate(); LocalDate localDate = new Date(reportTime).toLocalDate();
// 直接通过两个消息的时间差进行计算毫秒
Long workingDuration = reportTime - lastedDeviceState.getReportTime();
// 转为秒
workingDuration = workingDuration / 1000;
if (machinePwrStat.equals(0)) { if (machinePwrStat.equals(0)) {
// 关机 // 关机
if (lastPwStat != 0) { if (lastPwStat != 0) {
if (lastWorkingStat == 1) { if (lastWorkingStat == 1) {
// 如果上次是工作状态那么需要记录产量和生产时间 // 如果上次是工作状态那么需要记录产量和生产时间
if (dataSource == 1) {
// 树根
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration);
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration);
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);
Long lastJobTotal = lastedDeviceState.getJobTotal();
Long accJobCount = receivedEvent.getAccJobCount();
// 直接往上累加
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + (accJobCount - lastJobTotal));
nowDeviceState.setJobTotal(accJobCount);
} else {
// 机智云
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + receivedEvent.getCurrJobDuration());
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + receivedEvent.getCurrJobDuration());
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + receivedEvent.getCurrJobDuration());
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrJobCount());
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrJobCount());
}
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + receivedEvent.getCurrDuration());
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + receivedEvent.getCurrDuration());
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + receivedEvent.getCurrDuration());
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrCount());
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrCount());
} else { } else {
nowDeviceState = lastedDeviceState; nowDeviceState = lastedDeviceState;
} }
@ -199,32 +180,16 @@ public class IotMonitoringDataJob {
// 开机 // 开机
if (machineWorkingStat.equals(1)) { if (machineWorkingStat.equals(1)) {
// 工作 // 工作
if (dataSource == 1) {
// 树根今日当前数 + 这次信息点距离上次信息点生产的数量
Long lastJobTotal = lastedDeviceState.getJobTotal();
Long accJobCount = receivedEvent.getAccJobCount();
// 直接往上类
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + (accJobCount - lastJobTotal));
nowDeviceState.setJobTotal(receivedEvent.getAccJobCount());
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration);
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);
} else {
// 机智云
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrJobCount());
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrJobCount());
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + receivedEvent.getCurrJobDuration());
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + receivedEvent.getCurrJobDuration());
}
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrCount());
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrCount());
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + receivedEvent.getCurrDuration());
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + receivedEvent.getCurrDuration());
} else { } else {
// 待机 // 待机
nowDeviceState = lastedDeviceState; nowDeviceState = lastedDeviceState;
} }
// 设置开机时长待机也要进行累加所以放这里 // 设置开机时长待机也要进行累加所以放这里
if (dataSource == 1) {
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration);
} else {
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + receivedEvent.getCurrJobDuration());
}
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + receivedEvent.getCurrDuration());
nowDeviceState.setCurrLocalDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); nowDeviceState.setCurrLocalDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
nowDeviceState.setLastBootTime(lastBootTime); nowDeviceState.setLastBootTime(lastBootTime);
nowDeviceState.setReportTime(reportTime); nowDeviceState.setReportTime(reportTime);

Loading…
Cancel
Save