|
@@ -3,11 +3,10 @@ package com.example.opc_da.task;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.example.opc_common.entity.*;
|
|
|
-import com.example.opc_common.enums.ResultEnum;
|
|
|
-import com.example.opc_common.exception.CustomException;
|
|
|
import com.example.opc_common.util.Blank;
|
|
|
import com.example.opc_common.util.ConstantStr;
|
|
|
import com.example.opc_common.util.DateUtil;
|
|
|
+import com.example.opc_da.dao.DataSourceDao;
|
|
|
import com.example.opc_da.dao.ItemGroupDao;
|
|
|
import com.example.opc_da.dao.RawDataDao;
|
|
|
import com.example.opc_da.dao.ReportTableDao;
|
|
@@ -47,6 +46,9 @@ public class OpcAsyncTask {
|
|
|
private ReportTableDao reportTableDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private DataSourceDao dataSourceDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private AsyncAsyncTask asyncAsyncTask;
|
|
|
|
|
|
@Value("${opc_ua_server.address}")
|
|
@@ -92,403 +94,138 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 此接口,只有事件驱动任务才会调用,其他地方不调用
|
|
|
+ * 通过传入的数据组id,将同一数据源的所有数据组,都设置为一样的状态
|
|
|
*
|
|
|
- * @param itemList
|
|
|
- * @param dataSourceId
|
|
|
- * @param dataIndex
|
|
|
+ * @param itemGroupId
|
|
|
*/
|
|
|
- public void packageEventTable(List<Item> itemList, Integer dataSourceId, Long dataIndex) {
|
|
|
- if (Blank.isNotEmpty(itemList)) {
|
|
|
- Item item_ = itemList.get(0);
|
|
|
- Integer itemGroupId = item_.getItemGroupId();
|
|
|
- //获取原始数据表中,满足记录的数据
|
|
|
- List<Long> indexList = rawDataDao.getEventMeetIndexList(itemGroupId, dataSourceId, itemList, dataIndex, ConstantStr.IS_RECORD);
|
|
|
- if (Blank.isNotEmpty(indexList)) {
|
|
|
- //查看此数据组是否在事件驱动报表中被配置
|
|
|
- List<String> tableIdList = reportTableDao.getTableByItemId(itemList, ConstantStr.EVENT_DRIVEN_REPORT);
|
|
|
- if (Blank.isNotEmpty(tableIdList)) {
|
|
|
- for (int i = 0; i < tableIdList.size(); i++) {
|
|
|
- String tableId = tableIdList.get(i);
|
|
|
- ReportTable reportTable = reportTableDao.getReportTableById(tableId);
|
|
|
- Integer tableTemplateId = reportTable.getTableTemplateId();
|
|
|
- TableTemplate tableTemplate = reportTableDao.getTableTemplateById(tableTemplateId);
|
|
|
- Integer eventNum = tableTemplate.getEventNum();
|
|
|
- String chTableId = reportTableDao.getEventChTableId(tableId);
|
|
|
- List<TableTemplateTableItem> tableTemplateItemList = reportTableDao.getTttiByTemplateId(tableTemplateId);
|
|
|
- TableTemplateTableItem tableTemplateTableItem = tableTemplateItemList.get(0);
|
|
|
- //判断哪些符合驱动报表,并将符合的index返回回来
|
|
|
- List<CursorRawData> cursorRawDataList1 = rawDataDao.getEventRealIndexList(itemGroupId, dataSourceId, tableTemplateTableItem.getItemId(), indexList);
|
|
|
- List<Long> realIndexList = new ArrayList<>();
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList1)) {
|
|
|
- //获取缓存中存在的时间
|
|
|
- Object o = redisUtil.get(itemGroupId + ConstantStr.EVENT_DRIVEN_REPORT_STR);
|
|
|
- if (Blank.isNotEmpty(o)) {
|
|
|
- String timeStr = o.toString();
|
|
|
- for (int j = 0; j < cursorRawDataList1.size(); j++) {
|
|
|
- CursorRawData cursorRawData = cursorRawDataList1.get(i);
|
|
|
- if (j == 0) {
|
|
|
- if (!timeStr.equals(cursorRawData.getDataValueTime())) {
|
|
|
- realIndexList.add(cursorRawData.getDataIndex());
|
|
|
- }
|
|
|
- } else {
|
|
|
- realIndexList.add(cursorRawData.getDataIndex());
|
|
|
- }
|
|
|
- if (j == cursorRawDataList1.size() - 1) {
|
|
|
- //生成缓存时间
|
|
|
- redisUtil.set(itemGroupId + ConstantStr.EVENT_DRIVEN_REPORT_STR, cursorRawData.getDataValueTime());
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int j = 0; j < cursorRawDataList1.size(); j++) {
|
|
|
- CursorRawData cursorRawData = cursorRawDataList1.get(i);
|
|
|
- realIndexList.add(cursorRawData.getDataIndex());
|
|
|
- if (j == cursorRawDataList1.size() - 1) {
|
|
|
- //生成缓存时间
|
|
|
- redisUtil.set(itemGroupId + ConstantStr.EVENT_DRIVEN_REPORT_STR, cursorRawData.getDataValueTime());
|
|
|
- }
|
|
|
- }
|
|
|
+ public void changeSameDataSourceState(Integer itemGroupId, Integer runState) {
|
|
|
+ //获取数据组信息,并通过数据组的数据源id查询相应的数据源
|
|
|
+ ItemGroup itemGroup = itemGroupDao.getItemGroupById(itemGroupId);
|
|
|
+ DataSource dataSource = dataSourceDao.getDataSourceById(itemGroup.getDataSourceId());
|
|
|
+ //通过数据源的clsId和ip查询出所有相同的数据源
|
|
|
+ List<DataSource> dataSourceList = dataSourceDao.getDataSourceByclsIdAndIp(dataSource.getClsId(), dataSource.getIpAddress());
|
|
|
+ if (runState == ConstantStr.EXCEPT_STOP_UP) {
|
|
|
+ //将此数据源下的所有运行的数据组(状态为1),修改为状态为2
|
|
|
+ itemGroupDao.updateItemGroupState(dataSourceList, ConstantStr.START_UP, ConstantStr.EXCEPT_STOP_UP);
|
|
|
+ } else if (runState == ConstantStr.START_UP) {
|
|
|
+ //将此数据源下的所有运行的数据组(状态为2),修改为状态为1
|
|
|
+ itemGroupDao.updateItemGroupState(dataSourceList, ConstantStr.EXCEPT_STOP_UP, ConstantStr.START_UP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成事件驱动报表的数据项信息,并保存到redis中
|
|
|
+ *
|
|
|
+ * @param tttItemList 报表模板数据项信息
|
|
|
+ * @param dataMap 数据组数据
|
|
|
+ * @param reportTableId 报表id
|
|
|
+ * @param tableTemplateId 模板id
|
|
|
+ */
|
|
|
+ public void genEventItem(List<TableTemplateTableItem> tttItemList, Map<String, CursorRawData> dataMap,
|
|
|
+ String reportTableId, Integer tableTemplateId) {
|
|
|
+ if (Blank.isNotEmpty(tttItemList)) {
|
|
|
+ for (TableTemplateTableItem tttItem : tttItemList) {
|
|
|
+ String itemReadName = tttItem.getItemReadName();
|
|
|
+ Integer valueType = tttItem.getValueType();
|
|
|
+ //从存入的键值对中,拿出对应数据项的数据
|
|
|
+ CursorRawData cursorRawData = dataMap.get(itemReadName);
|
|
|
+ //如果有报表id,说明是新增数据项信息,反之,则是更新原本的数据项信息
|
|
|
+ if (Blank.isNotEmpty(reportTableId)) {
|
|
|
+ //生成对应的报表数据项信息
|
|
|
+ ReportTableItem reportTableItem = new ReportTableItem(
|
|
|
+ reportTableId, tttItem.getItemId(), tttItem.getValueType(), tttItem.getXaxis(), tttItem.getYaxis(), tttItem.getStandby(),
|
|
|
+ valueType.equals(ConstantStr.CALCULATED_VALUE) ? cursorRawData.getDataValue() : cursorRawData.getOrgDataValue(),
|
|
|
+ cursorRawData.getDataValueTime(), cursorRawData.getDataIndex().toString()
|
|
|
+ );
|
|
|
+ redisUtil.set(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + tttItem.getItemReadName(), reportTableItem);
|
|
|
+ } else {
|
|
|
+ ReportTableItem reportTableItem =
|
|
|
+ (ReportTableItem) redisUtil.get(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + itemReadName);
|
|
|
+ reportTableItem.setValueList(reportTableItem.getValueList() + "," +
|
|
|
+ (valueType.equals(ConstantStr.CALCULATED_VALUE) ? cursorRawData.getDataValue() : cursorRawData.getOrgDataValue()));
|
|
|
+ reportTableItem.setValueTimeList(reportTableItem.getValueTimeList() + "," + cursorRawData.getDataValueTime());
|
|
|
+ reportTableItem.setValueIndexList(reportTableItem.getValueIndexList() + "," + cursorRawData.getDataIndex());
|
|
|
+ redisUtil.set(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + itemReadName, reportTableItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将按条件读取的数据组数据,组装为事件驱动报表
|
|
|
+ *
|
|
|
+ * @param cursorRawDataList 条件读取的数据组数据
|
|
|
+ * @param tableTemplateList 此数据组包含的报表模板
|
|
|
+ * @param reportTableMap <报表模板对应的报表id,报表模板对应的主报表>
|
|
|
+ */
|
|
|
+ public void packageEventTable(List<CursorRawData> cursorRawDataList, List<TableTemplate> tableTemplateList,
|
|
|
+ Map<Integer, ReportTable> reportTableMap) {
|
|
|
+ if (Blank.isNotEmpty(tableTemplateList) && Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
+ //将传入的数据,组装为<键,值>的方式
|
|
|
+ Map<String, CursorRawData> dataMap = crdListToMap(cursorRawDataList);
|
|
|
+ //遍历所有报表模板
|
|
|
+ for (TableTemplate tableTemplate : tableTemplateList) {
|
|
|
+ Integer eventNum = tableTemplate.getEventNum();
|
|
|
+ Integer tableTemplateId = tableTemplate.getId();
|
|
|
+ //获取此模板的主报表
|
|
|
+ ReportTable reportTable = reportTableMap.get(tableTemplateId);
|
|
|
+ //从redis中获取此时主报表的启停状态
|
|
|
+ Boolean flag = (Boolean) redisUtil.get(ConstantStr.TABLE_ID + reportTable.getId());
|
|
|
+ if (Blank.isEmpty(flag) || !flag) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获取此时事件驱动报表最新报表的当前数量值
|
|
|
+ Object currentNum = redisUtil.get(ConstantStr.CURRENT_NUM + tableTemplateId);
|
|
|
+ if (Blank.isEmpty(currentNum)) {
|
|
|
+ //生成新的子报表
|
|
|
+ String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
+ asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, 0);
|
|
|
+ redisUtil.set(ConstantStr.CURRENT_NUM, 1);
|
|
|
+ //获取事件驱动报表中所有的数据项信息
|
|
|
+ List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|
|
|
+ if (Blank.isNotEmpty(tttItemList)) {
|
|
|
+ //生成新的报表数据项信息
|
|
|
+ genEventItem(tttItemList, dataMap, id, tableTemplateId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果两者相等,将上一次的数据异步存入到数据库,并生成新的子报表
|
|
|
+ if (eventNum == (int) currentNum) {
|
|
|
+ //从redis中取出数据
|
|
|
+ List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|
|
|
+ if (Blank.isNotEmpty(tttItemList)) {
|
|
|
+ List<ReportTableItem> reportTableItemList = new ArrayList<>();
|
|
|
+ for (TableTemplateTableItem tttItem : tttItemList) {
|
|
|
+ reportTableItemList.add((ReportTableItem) redisUtil.get(tableTemplateId + ConstantStr.REPORT_TABLE_ITEM + tttItem.getItemReadName()));
|
|
|
}
|
|
|
+ //将所有报表数据项信息存入到数据库
|
|
|
+ asyncAsyncTask.addReportTableItemList(reportTableItemList);
|
|
|
}
|
|
|
- if (Blank.isNotEmpty(realIndexList)) {
|
|
|
- int size = realIndexList.size();
|
|
|
- if (Blank.isEmpty(chTableId)) {
|
|
|
- //如果没有子报表,则新增报表,则只需要生成新报表,并向新报表添加数据即可
|
|
|
- //如果模板设置的数量大于等于当前拿数据的数量,则只需要添加一张新报表存储数据即可
|
|
|
- if (eventNum >= size) {
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, size);
|
|
|
- //根据索引进行排序,将数据丢到相应的位置
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, realIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //如果模板设置的数量小于当前拿数据的数量
|
|
|
- //如果余数为0,则添加商的数量条数的新报表
|
|
|
- //如果余数不为0,则添加商的数量+1条数的新报表
|
|
|
- //商
|
|
|
- int discuss = size / eventNum;
|
|
|
- //余数
|
|
|
- int remainder = size % eventNum;
|
|
|
- if (remainder == 0) {
|
|
|
- for (int j = 0; j < discuss; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, dataIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int j = 0; j < discuss + 1; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- if (j != discuss) {
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int k = 0; k < remainder; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, j == discuss ? remainder : eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, dataIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //如果已经存在子报表
|
|
|
- ReportTable chReportTable = reportTableDao.getReportTableById(chTableId);
|
|
|
- Integer currentNum = chReportTable.getCurrentNum();
|
|
|
- //如果最新的子报表的数量为模板设置的条数,则上次添加刚好完毕,需要添加新报表。
|
|
|
- if (currentNum == eventNum) {
|
|
|
- if (eventNum >= size) {
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, size);
|
|
|
- //根据索引进行排序,将数据丢到相应的位置
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, realIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //商
|
|
|
- int discuss = size / eventNum;
|
|
|
- //余数
|
|
|
- int remainder = size % eventNum;
|
|
|
- if (remainder == 0) {
|
|
|
- for (int j = 0; j < discuss; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, dataIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int j = 0; j < discuss + 1; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- if (j != discuss) {
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int k = 0; k < remainder; k++) {
|
|
|
- dataIndexList.add(realIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, j == discuss ? remainder : eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, dataIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //如果不等于,则需要修改原来最后的一张报表,往里面继续加数据,加到模板的条数为止
|
|
|
- int difference = eventNum - currentNum;
|
|
|
- //如果这次获取到的条数,小于旧子报表差的条数,则只需要修改旧子报表即可
|
|
|
- if (size <= difference) {
|
|
|
- if (reportTableDao.updateReportTableNum(chTableId, currentNum + size) <= 0) {
|
|
|
- throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "修改失败");
|
|
|
- }
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- ReportTableItem reportTableItem = reportTableDao.getReportTableItem(chTableId, itemId, null);
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, realIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursorAdd(cursorRawDataList, reportTableItem.getValueList(), reportTableItem.getValueTimeList(), reportTableItem.getValueIndexList());
|
|
|
- reportTableDao.updateReportTableItem(new ReportTableItem(
|
|
|
- reportTableItem.getId(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //如果获取到的数量大于旧子报表差的条数,先将旧子报表差的条数补齐
|
|
|
- int newSize = size - difference;
|
|
|
- List<Long> oldIndexList = new ArrayList<>();
|
|
|
- List<Long> newIndexList = new ArrayList<>();
|
|
|
- for (int j = 0; j < size; j++) {
|
|
|
- if (j < difference) {
|
|
|
- oldIndexList.add(realIndexList.get(j));
|
|
|
- } else {
|
|
|
- newIndexList.add(realIndexList.get(j));
|
|
|
- }
|
|
|
- }
|
|
|
- if (reportTableDao.updateReportTableNum(chTableId, currentNum + difference) <= 0) {
|
|
|
- throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "修改失败");
|
|
|
- }
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- ReportTableItem reportTableItem = reportTableDao.getReportTableItem(chTableId, itemId, null);
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, oldIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursorAdd(cursorRawDataList, reportTableItem.getValueList(), reportTableItem.getValueTimeList(), reportTableItem.getValueIndexList());
|
|
|
- reportTableDao.updateReportTableItem(new ReportTableItem(
|
|
|
- reportTableItem.getId(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- //旧子报表添加完毕,执行添加新报表
|
|
|
- if (eventNum >= newSize) {
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, newSize);
|
|
|
- //根据索引进行排序,将数据丢到相应的位置
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, newIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- //商
|
|
|
- int discuss = newSize / eventNum;
|
|
|
- //余数
|
|
|
- int remainder = newSize % eventNum;
|
|
|
- if (remainder == 0) {
|
|
|
- for (int j = 0; j < discuss; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(newIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, newIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int j = 0; j < discuss + 1; j++) {
|
|
|
- List<Long> dataIndexList = new ArrayList<>();
|
|
|
- if (j != discuss) {
|
|
|
- for (int k = 0; k < eventNum; k++) {
|
|
|
- dataIndexList.add(newIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int k = 0; k < remainder; k++) {
|
|
|
- dataIndexList.add(newIndexList.get(j * eventNum + k));
|
|
|
- }
|
|
|
- }
|
|
|
- String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
- asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, j == discuss ? remainder : eventNum);
|
|
|
- //根据索引进行排序,并添加数据
|
|
|
- for (TableTemplateTableItem t : tableTemplateItemList) {
|
|
|
- Integer itemId = t.getItemId();
|
|
|
- Integer valueType = t.getValueType();
|
|
|
- Boolean flage = valueType.equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- Item item = itemGroupDao.getItemById(itemId);
|
|
|
- if (Blank.isEmpty(item)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<CursorRawData> cursorRawDataList = rawDataDao.getEventDataList(itemGroupId, dataSourceId, itemId, dataIndexList);
|
|
|
- if (Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
- Map<String, String> map = ReportTask.genEventCursor(cursorRawDataList);
|
|
|
- reportTableDao.addReportTableItem(new ReportTableItem(
|
|
|
- id, itemId, valueType, t.getXaxis(), t.getYaxis(), t.getStandby(), map.get(flage ? "valueList" : "orgValueList"), map.get("valueTimeList"), map.get("valueIndexList")
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //生成新的子报表
|
|
|
+ String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
+ asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.EVENT_GENERATE_REPORT, 0);
|
|
|
+ redisUtil.set(ConstantStr.CURRENT_NUM, 1);
|
|
|
+ //获取事件驱动报表中所有的数据项信息
|
|
|
+ if (Blank.isNotEmpty(tttItemList)) {
|
|
|
+ //生成新的报表数据项信息
|
|
|
+ genEventItem(tttItemList, dataMap, id, tableTemplateId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果两者不相等,则数量还有达到设置的最大值,只需要更新报表数据项信息
|
|
|
+ List<TableTemplateTableItem> tttItemList = tableTemplate.getTableTemplateItemList();
|
|
|
+ if (Blank.isNotEmpty(tttItemList)) {
|
|
|
+ redisUtil.set(ConstantStr.CURRENT_NUM, (int) redisUtil.get(ConstantStr.CURRENT_NUM) + 1);
|
|
|
+ genEventItem(tttItemList, dataMap, null, tableTemplateId);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //删除刚才被添加完毕的index的数据
|
|
|
- rawDataDao.delEventByIndexList(itemGroupId, dataSourceId, dataIndex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 将临时集合数据转换为Map
|
|
|
+ * 将临时集合数据转换为Map,将数据组的临时数据,转换为Map<数据项真实读值名称,临时数据>
|
|
|
*
|
|
|
- * @param cursorRawDataList
|
|
|
+ * @param cursorRawDataList 数据组同一批次的临时数据
|
|
|
* @return
|
|
|
*/
|
|
|
public static Map<String, CursorRawData> crdListToMap(List<CursorRawData> cursorRawDataList) {
|
|
@@ -519,6 +256,17 @@ public class OpcAsyncTask {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据传入的信息,生成设备报表相应的报表数据项信息
|
|
|
+ *
|
|
|
+ * @param tableTemplateId 报表模板id
|
|
|
+ * @param itemReadName 数据项实际读值名称
|
|
|
+ * @param dataValue 数据项值
|
|
|
+ * @param dataTime 数据项时间
|
|
|
+ * @param index 数据项索引
|
|
|
+ * @param timeItemType 开始,结束
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ReportTableItem genDeviceItem(Integer tableTemplateId, String itemReadName, String dataValue, String dataTime, Long index, Integer timeItemType) {
|
|
|
if (Blank.isNotEmpty(timeItemType)) {
|
|
|
ReportTableItem reportTableItem =
|
|
@@ -541,13 +289,27 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //设备报表因为开关变化一次时间很长,所以redis中数据如果更新,考虑将数据更新到数据库,防止数据丢失
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设备报表因为开关变化一次时间很长,所以redis中数据如果更新,考虑将数据更新到数据库,防止数据丢失
|
|
|
+ *
|
|
|
+ * @param cursorRawDataList 数据组读取一次的数据
|
|
|
+ * @param tableTemplateList 数据组启动前配置好的报表模板
|
|
|
+ * @param ttIdMap <报表模板id,<报表模板对应的数据项名称,报表模板对应的数据项信息>>
|
|
|
+ * @param itemReadMap <基础数据项id,基础数据项读值名称>
|
|
|
+ * @param reportTableMap <报表模板对应的设备报表id,报表模板对应的设备报表>
|
|
|
+ * @param index 索引,第几次读值
|
|
|
+ */
|
|
|
public void packDeviceTable(List<CursorRawData> cursorRawDataList, List<TableTemplate> tableTemplateList,
|
|
|
Map<Integer, Map<String, TableTemplateTableItem>> ttIdMap, Map<Integer, String> itemReadMap,
|
|
|
Map<Integer, ReportTable> reportTableMap, Long index) {
|
|
|
+ //将传入的数据,组装为<键,值>的方式
|
|
|
Map<String, CursorRawData> dataMap = crdListToMap(cursorRawDataList);
|
|
|
if (Blank.isNotEmpty(tableTemplateList) && Blank.isNotEmpty(cursorRawDataList)) {
|
|
|
+ //遍历所有报表模板
|
|
|
for (TableTemplate tableTemplate : tableTemplateList) {
|
|
|
+ //拿到报表模板的开始数据项id,开始数据项阈值,最大数量,报表模板id,结束数据项id,结束数据项阈值
|
|
|
+ //并从数据项map中将真实读值名称取出来
|
|
|
Integer startItemId = tableTemplate.getStartItemId();
|
|
|
String startValue = tableTemplate.getStartValue();
|
|
|
Integer eventNum = tableTemplate.getEventNum();
|
|
@@ -556,6 +318,13 @@ public class OpcAsyncTask {
|
|
|
Integer endItemId = tableTemplate.getEndItemId();
|
|
|
String endValue = tableTemplate.getEndValue();
|
|
|
String endItemName = itemReadMap.get(endItemId);
|
|
|
+ //获取此模板的主报表
|
|
|
+ ReportTable reportTable = reportTableMap.get(tableTemplateId);
|
|
|
+ //从redis中获取此时主报表的启停状态
|
|
|
+ Boolean flag = (Boolean) redisUtil.get(ConstantStr.TABLE_ID + reportTable.getId());
|
|
|
+ if (Blank.isEmpty(flag) || !flag) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//获取开始数据项的数据
|
|
|
CursorRawData startCrData = dataMap.get(startItemName);
|
|
|
//如果开始数据项的数据等于,设定的开始值
|
|
@@ -586,8 +355,6 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
//如果值为0,则需要新增一张报表
|
|
|
if (startNum == 0) {
|
|
|
- //获取此模板的主报表
|
|
|
- ReportTable reportTable = reportTableMap.get(tableTemplateId);
|
|
|
//生成新的子报表
|
|
|
String id = IdUtil.createSnowflake(1, 1).nextId() + "";
|
|
|
asyncAsyncTask.addHaveKeyChReport(reportTable, id, ConstantStr.DEVICE_GENERATE_REPORT, 0);
|
|
@@ -748,7 +515,7 @@ public class OpcAsyncTask {
|
|
|
Integer itemGroupId = item_.getItemGroupId();
|
|
|
int remainder = itemGroupId % ConstantStr.SUB_TABLE_NUM;
|
|
|
//从临时数据表中,满足记录的数据
|
|
|
- List<Long> indexList = rawDataDao.getMeetIndexList(itemGroupId, dataSourceId, itemList, sqlCurrentYmdh, ConstantStr.IS_RECORD);
|
|
|
+ List<Long> indexList = rawDataDao.getMeetIndexList(itemGroupId, dataSourceId, itemList, sqlCurrentYmdh);
|
|
|
if (Blank.isNotEmpty(indexList)) {
|
|
|
for (Item item : itemList) {
|
|
|
//从临时表中获取相应数据项的数据
|
|
@@ -762,16 +529,14 @@ public class OpcAsyncTask {
|
|
|
List<Boolean> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
dataList.add(JSON.parseObject(cursorRawData.getOrgDataValue(), Boolean.class));
|
|
|
dataList.add(JSON.parseObject(cursorRawData.getDataValue(), Boolean.class));
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
} else {
|
|
|
try {
|
|
@@ -779,32 +544,28 @@ public class OpcAsyncTask {
|
|
|
List<BigDecimal> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
orgDataList.add(JSON.parseObject(cursorRawData.getOrgDataValue(), BigDecimal.class));
|
|
|
dataList.add(JSON.parseObject(cursorRawData.getDataValue(), BigDecimal.class));
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
} catch (Exception e) {
|
|
|
List<String> orgDataList = new ArrayList<>();
|
|
|
List<String> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
orgDataList.add(cursorRawData.getOrgDataValue());
|
|
|
dataList.add(cursorRawData.getDataValue());
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
}
|
|
|
}
|
|
@@ -829,7 +590,7 @@ public class OpcAsyncTask {
|
|
|
Integer itemGroupId = item_.getItemGroupId();
|
|
|
int remainder = itemGroupId % ConstantStr.SUB_TABLE_NUM;
|
|
|
//从临时数据表中,满足记录的数据
|
|
|
- List<Long> indexList = rawDataDao.getMeetIndexList(itemGroupId, dataSourceId, itemList, sqlCurrentYmdh, ConstantStr.IS_RECORD);
|
|
|
+ List<Long> indexList = rawDataDao.getMeetIndexList(itemGroupId, dataSourceId, itemList, sqlCurrentYmdh);
|
|
|
if (Blank.isNotEmpty(indexList)) {
|
|
|
for (Item item : itemList) {
|
|
|
//从临时表中获取相应数据项的数据
|
|
@@ -843,16 +604,14 @@ public class OpcAsyncTask {
|
|
|
List<Boolean> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
orgDataList.add(JSON.parseObject(cursorRawData.getOrgDataValue(), Boolean.class));
|
|
|
dataList.add(JSON.parseObject(cursorRawData.getDataValue(), Boolean.class));
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
} else {
|
|
|
try {
|
|
@@ -860,32 +619,28 @@ public class OpcAsyncTask {
|
|
|
List<BigDecimal> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
orgDataList.add(JSON.parseObject(cursorRawData.getOrgDataValue(), BigDecimal.class));
|
|
|
dataList.add(JSON.parseObject(cursorRawData.getDataValue(), BigDecimal.class));
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
} catch (Exception e) {
|
|
|
List<String> orgDataList = new ArrayList<>();
|
|
|
List<String> dataList = new ArrayList<>();
|
|
|
List<String> dataTimeList = new ArrayList<>();
|
|
|
List<Long> dataIndexList = new ArrayList<>();
|
|
|
- List<Integer> isRecordList = new ArrayList<>();
|
|
|
for (CursorRawData cursorRawData : cursorRawDataList) {
|
|
|
orgDataList.add(cursorRawData.getOrgDataValue());
|
|
|
dataList.add(cursorRawData.getDataValue());
|
|
|
dataTimeList.add(cursorRawData.getDataValueTime());
|
|
|
dataIndexList.add(cursorRawData.getDataIndex());
|
|
|
- isRecordList.add(cursorRawData.getIsRecord());
|
|
|
}
|
|
|
RawData rawData = new RawData(itemGroupId, dataSourceId, itemName, dataType, JSON.toJSONString(orgDataList), JSON.toJSONString(dataList),
|
|
|
- JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, JSON.toJSONString(isRecordList), new Date());
|
|
|
+ JSON.toJSONString(dataTimeList), JSON.toJSONString(dataIndexList), sqlCurrentYmdh, new Date());
|
|
|
rawDataDao.addRawData(remainder, rawData);
|
|
|
}
|
|
|
}
|