Browse Source

更新

feature_hph_新增rabbitmq_sink
1049970895@qniao.cn 3 years ago
parent
commit
7863984832
2 changed files with 23 additions and 4 deletions
  1. 17
      src/main/java/com/qniao/iot/IotMonitoringDataJob.java
  2. 10
      src/test/java/Demo2.java

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

@ -2,6 +2,7 @@ package com.qniao.iot;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db; import cn.hutool.db.Db;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
@ -168,6 +169,10 @@ public class IotMonitoringDataJob {
lastWorkingStatState.update(machineWorkingStat); lastWorkingStatState.update(machineWorkingStat);
lastPwStatState.update(machinePwrStat); lastPwStatState.update(machinePwrStat);
Long reportTime = receivedEvent.getReportTime(); Long reportTime = receivedEvent.getReportTime();
String reportTimeStr = StrUtil.toString(reportTime);
if(reportTimeStr.length() == 10) {
reportTime = reportTime * 1000;
}
// 1树根 0机智云 // 1树根 0机智云
Integer dataSource = receivedEvent.getDataSource(); Integer dataSource = receivedEvent.getDataSource();
// 当前数据 // 当前数据
@ -201,15 +206,21 @@ public class IotMonitoringDataJob {
if (lastWorkingStat == 1) { if (lastWorkingStat == 1) {
// 如果上次是工作中那就进行累加 // 如果上次是工作中那就进行累加
if (lastReportTime != null) { if (lastReportTime != null) {
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration);
/*nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration);
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration); nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration);
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);*/
if (dataSource == 1) { if (dataSource == 1) {
// 树根 // 树根
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration);
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration);
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);
nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount()); nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount());
nowDeviceState.setJobTotal(onData.getJobTotal() + receivedEvent.getCurrJobCount()); nowDeviceState.setJobTotal(onData.getJobTotal() + receivedEvent.getCurrJobCount());
} else { } 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.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrJobCount());
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrJobCount()); nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrJobCount());
} }
@ -226,6 +237,7 @@ public class IotMonitoringDataJob {
deviceTotalDataStat.update(nowDeviceState); deviceTotalDataStat.update(nowDeviceState);
} else { } else {
if (machineWorkingStat.equals(1)) { if (machineWorkingStat.equals(1)) {
// 工作
if (dataSource == 1) { if (dataSource == 1) {
// 树根今日当前数 + 这次信息点距离上次信息点生产的数量 // 树根今日当前数 + 这次信息点距离上次信息点生产的数量
nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount()); nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount());
@ -241,6 +253,7 @@ public class IotMonitoringDataJob {
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration); nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);
nowDeviceState.setReportTime(reportTime); nowDeviceState.setReportTime(reportTime);
} else { } else {
// 待机或开机
nowDeviceState = lastedDeviceState; nowDeviceState = lastedDeviceState;
} }
deviceTotalDataStat.update(nowDeviceState); deviceTotalDataStat.update(nowDeviceState);

10
src/test/java/Demo2.java

@ -1,3 +1,4 @@
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
@ -16,8 +17,13 @@ public class Demo2 {
System.out.println(data);*/ System.out.println(data);*/
LocalDate reportDate = new java.util.Date(1660531324418L)
/*LocalDate reportDate = new java.util.Date(1660531324418L)
.toInstant().atOffset(ZoneOffset.of("+8")).toLocalDate(); .toInstant().atOffset(ZoneOffset.of("+8")).toLocalDate();
System.out.println(reportDate);
System.out.println(reportDate);*/
Long a = 1660570366L;
System.out.println(StrUtil.toString(a).length());
System.out.println(a * 1000);
} }
} }
Loading…
Cancel
Save