zhoupeng 1 year ago
parent
commit
1afb908ff7

+ 17 - 7
cqcy-ei/cqcy-ei-da/src/main/java/com/example/opc_da/task/OpcAsyncTask.java

@@ -334,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;
@@ -368,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);
@@ -388,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;