|
@@ -191,7 +191,10 @@ public class OpcAsyncTask {
|
|
|
} else {
|
|
|
//如果两者相等,将上一次的数据异步存入到数据库,并生成新的子报表
|
|
|
if (eventNum == (int) currentNum) {
|
|
|
- asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), eventNum);
|
|
|
+ Object o = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId);
|
|
|
+ if (Blank.isNotEmpty(o)) {
|
|
|
+ asyncAsyncTask.updateReportNum(o.toString(), eventNum);
|
|
|
+ }
|
|
|
//从redis中取出数据
|
|
|
List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|
|
|
if (Blank.isNotEmpty(tttItemList)) {
|
|
@@ -207,6 +210,7 @@ public class OpcAsyncTask {
|
|
|
//生成新的子报表
|
|
|
String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, 1);
|
|
|
+ redisUtil.set(ConstantStr.TABLE_ID + tableTemplateId, id);
|
|
|
redisUtil.set(ConstantStr.CURRENT_NUM + tableTemplateId, 1);
|
|
|
//获取事件驱动报表中所有的数据项信息
|
|
|
if (Blank.isNotEmpty(tttItemList)) {
|
|
@@ -330,9 +334,16 @@ public class OpcAsyncTask {
|
|
|
continue;
|
|
|
}
|
|
|
//获取开始数据项的数据
|
|
|
+ Map<String, TableTemplateTableItem> tttItemMap = ttIdMap.get(tableTemplateId);
|
|
|
+ TableTemplateTableItem startTttItem = tttItemMap.get(startItemName + ConstantStr.START_TIME_ITEM);
|
|
|
+ Integer startValueType = startTttItem.getValueType();
|
|
|
+ Boolean valueFlag = false;
|
|
|
+ if (startValueType.equals(ConstantStr.CALCULATED_VALUE)) {
|
|
|
+ valueFlag = true;
|
|
|
+ }
|
|
|
CursorRawData startCrData = dataMap.get(startItemName);
|
|
|
//如果开始数据项的数据等于,设定的开始值
|
|
|
- if (startCrData.getDataValue().equals(startValue)) {
|
|
|
+ if ((valueFlag ? startCrData.getDataValue() : startCrData.getOrgDataValue()).equals(startValue)) {
|
|
|
//从redis中获取开始、结束时间存入redis中的长度
|
|
|
int startNum = 0;
|
|
|
int endNum = 0;
|
|
@@ -364,13 +375,10 @@ public class OpcAsyncTask {
|
|
|
asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.DEVICE_GENERATE_REPORT, 0);
|
|
|
redisUtil.set(ConstantStr.START_NUM + tableTemplateId, startNum + 1);
|
|
|
redisUtil.set(ConstantStr.TABLE_ID + tableTemplateId, id);
|
|
|
- //获取模板中开始时间对应的数据项信息
|
|
|
- Map<String, TableTemplateTableItem> tttItemMap = ttIdMap.get(tableTemplateId);
|
|
|
- TableTemplateTableItem tttItem = tttItemMap.get(startItemName + ConstantStr.START_TIME_ITEM);
|
|
|
//生成新的开始时间数据项的数据项信息,并存入到redis中
|
|
|
ReportTableItem reportTableItem = new ReportTableItem(
|
|
|
- id, startItemId, tttItem.getItemName(), tttItem.getDescribe(), ConstantStr.START_TIME_ITEM, tttItem.getValueType(), tttItem.getXaxis(), tttItem.getYaxis(),
|
|
|
- tttItem.getStandby(), startValue, startCrData.getDataValueTime(), index.toString()
|
|
|
+ id, startItemId, startTttItem.getItemName(), startTttItem.getDescribe(), ConstantStr.START_TIME_ITEM, startTttItem.getValueType(), startTttItem.getXaxis(), startTttItem.getYaxis(),
|
|
|
+ startTttItem.getStandby(), startValue, startCrData.getDataValueTime(), index.toString()
|
|
|
);
|
|
|
asyncAsyncTask.addReportTableItem(reportTableItem);
|
|
|
redisUtil.set(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + startItemName + ConstantStr.REPORT_TABLE_ITEM + ConstantStr.START_TIME_ITEM, reportTableItem);
|
|
@@ -384,8 +392,14 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
}
|
|
|
//获取结束数据项的数据
|
|
|
+ TableTemplateTableItem endTttItem = tttItemMap.get(endItemName + ConstantStr.END_TIME_ITEM);
|
|
|
+ Integer endValueType = endTttItem.getValueType();
|
|
|
+ valueFlag = false;
|
|
|
+ if (endValueType.equals(ConstantStr.CALCULATED_VALUE)) {
|
|
|
+ valueFlag = true;
|
|
|
+ }
|
|
|
CursorRawData endCrData = dataMap.get(endItemName);
|
|
|
- if (endCrData.getDataValue().equals(endValue)) {
|
|
|
+ if ((valueFlag ? endCrData.getDataValue() : endCrData.getOrgDataValue()).equals(endValue)) {
|
|
|
//从redis中获取开始、结束时间存入redis中的长度
|
|
|
int startNum = 0;
|
|
|
int endNum = 0;
|
|
@@ -416,7 +430,9 @@ public class OpcAsyncTask {
|
|
|
String id = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString();
|
|
|
redisUtil.set(ConstantStr.END_NUM + tableTemplateId, endNum + 1);
|
|
|
//修改报表当前数量
|
|
|
- asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), endNum + 1);
|
|
|
+ if (Blank.isNotEmpty(id)) {
|
|
|
+ asyncAsyncTask.updateReportNum(id, eventNum + 1);
|
|
|
+ }
|
|
|
List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|
|
|
for (TableTemplateTableItem tttItem : tttItemList) {
|
|
|
Integer timeItemType = tttItem.getTimeItemType();
|
|
@@ -444,8 +460,12 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
} else {
|
|
|
redisUtil.set(ConstantStr.END_NUM + tableTemplateId, endNum + 1);
|
|
|
+ //获取子报表中的报表主键
|
|
|
+ String id = redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString();
|
|
|
//修改报表当前数量
|
|
|
- asyncAsyncTask.updateReportNum(redisUtil.get(ConstantStr.TABLE_ID + tableTemplateId).toString(), endNum + 1);
|
|
|
+ if (Blank.isNotEmpty(id)) {
|
|
|
+ asyncAsyncTask.updateReportNum(id, eventNum + 1);
|
|
|
+ }
|
|
|
//如果此时插入的结束时间为最后一个数据
|
|
|
if ((endNum + 1) == eventNum) {
|
|
|
List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|