|
@@ -56,13 +56,6 @@ public class OpcAsyncTask {
|
|
|
private String opcUaUrl;
|
|
|
|
|
|
/**
|
|
|
- * 异步生成事件驱动报表
|
|
|
- */
|
|
|
- public void eventDiverReport() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 新增一条临时数据
|
|
|
*
|
|
|
* @param rawData
|
|
@@ -189,22 +182,9 @@ public class OpcAsyncTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void addEventRawData(Integer id, RawData rawData) {
|
|
|
- if (Blank.isNotEmpty(id) && Blank.isNotEmpty(rawData)) {
|
|
|
- Integer remainder = id % ConstantStr.SUB_TABLE_NUM;
|
|
|
-// rawDataDao.addRawData(id, remainder, rawData);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增原始数据集合
|
|
|
- *
|
|
|
- * @param rawDataList
|
|
|
- */
|
|
|
- public void addRawDataList(Integer id, List<RawData> rawDataList) {
|
|
|
- if (Blank.isNotEmpty(id) && Blank.isNotEmpty(rawDataList)) {
|
|
|
- Integer remainder = id % ConstantStr.SUB_TABLE_NUM;
|
|
|
- rawDataDao.addRawDataList(id, remainder, rawDataList);
|
|
|
+ public void addEventRawData( RawData rawData) {
|
|
|
+ if ( Blank.isNotEmpty(rawData)) {
|
|
|
+ rawDataDao.addEventRawData(rawData);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -271,85 +251,7 @@ public class OpcAsyncTask {
|
|
|
/**
|
|
|
* 事件驱动报表异步添加数据
|
|
|
*/
|
|
|
- public void eventTable(Integer tableReportId, BigDecimal value, String currentDate) {
|
|
|
- ReportTable reportTable = reportTableDao.getReportTableById(tableReportId);
|
|
|
- String reportTableData = reportTable.getReportTableData();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(reportTableData);
|
|
|
- JSONArray objects = jsonObject.getJSONArray("tables");
|
|
|
- if (Blank.isNotEmpty(objects)) {
|
|
|
- JSONObject jsonObject1 = objects.getJSONObject(0);
|
|
|
- JSONArray objects1 = jsonObject1.getJSONArray("eventDataList");
|
|
|
- JSONObject object = new JSONObject();
|
|
|
- object.put("date", currentDate);
|
|
|
- object.put("value", value);
|
|
|
- objects1.add(object);
|
|
|
- objects.set(0, jsonObject1);
|
|
|
- jsonObject.put("tables", objects);
|
|
|
- reportTable.setReportTableData(jsonObject.toJSONString());
|
|
|
- //将新数据加到与那里的data里面,并更新
|
|
|
- reportTableDao.updateReportTable(reportTable);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void addEventTable(Integer tableReportId, List<BigDecimal> eventDataValueList, List<String> eventDataValueTimeList) {
|
|
|
- ReportTable reportTable = reportTableDao.getReportTableById(tableReportId);
|
|
|
- String reportTableData = reportTable.getReportTableData();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(reportTableData);
|
|
|
- JSONArray objects = jsonObject.getJSONArray("tables");
|
|
|
- if (Blank.isEmpty(objects)) {
|
|
|
- ReportTable reportTable1 = new ReportTable();
|
|
|
- reportTable1.setTableTemplateId(reportTable.getTableTemplateId());
|
|
|
- reportTable1.setUserId(reportTable.getUserId());
|
|
|
- reportTable1.setReportTableName(reportTable.getReportTableName() + "_" + DateUtil.dateChangeStr(new Date(), "yyyyMMddHHmmss"));
|
|
|
- reportTable1.setReportTableData(jsonObject.toJSONString());
|
|
|
- reportTable1.setReportValueFormat(reportTable.getReportValueFormat());
|
|
|
- reportTable1.setIsAutoReport(ConstantStr.EVENT_GENERATE_REPORT);
|
|
|
- reportTable1.setVersion(reportTable.getVersion());
|
|
|
- reportTableDao.addReportTable(reportTable1);
|
|
|
- TableAutoLog tableAutoLog = new TableAutoLog();
|
|
|
- tableAutoLog.setAutoTableId(reportTable.getId());
|
|
|
- tableAutoLog.setAutoChTableId(reportTable1.getId());
|
|
|
- reportTableDao.addTableAutoLog(tableAutoLog);
|
|
|
- if (Blank.isNotEmpty(reportTable.getUserGroupList())) {
|
|
|
- reportTableDao.addTableUserGroup(reportTable1.getId(), reportTable.getUserGroupList());
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject jsonObject1 = objects.getJSONObject(0);
|
|
|
- JSONArray objects1 = jsonObject1.getJSONArray("item");
|
|
|
- JSONObject jsonObject2 = new JSONObject();
|
|
|
- jsonObject2.put("dataList", eventDataValueList);
|
|
|
- jsonObject2.put("dataTimeList", eventDataValueTimeList);
|
|
|
- objects1.set(0, jsonObject2);
|
|
|
- objects.set(0, jsonObject1);
|
|
|
- jsonObject.put("tables", objects);
|
|
|
- ReportTable reportTable1 = new ReportTable();
|
|
|
- reportTable1.setTableTemplateId(reportTable.getTableTemplateId());
|
|
|
- reportTable1.setUserId(reportTable.getUserId());
|
|
|
- reportTable1.setReportTableName(reportTable.getReportTableName() + "_" + DateUtil.dateChangeStr(new Date(), "yyyyMMddHHmmss"));
|
|
|
- reportTable1.setReportTableData(jsonObject.toJSONString());
|
|
|
- reportTable1.setReportValueFormat(reportTable.getReportValueFormat());
|
|
|
- reportTable1.setIsAutoReport(ConstantStr.EVENT_GENERATE_REPORT);
|
|
|
- reportTable1.setVersion(reportTable.getVersion());
|
|
|
- reportTableDao.addReportTable(reportTable1);
|
|
|
- TableAutoLog tableAutoLog = new TableAutoLog();
|
|
|
- tableAutoLog.setAutoTableId(reportTable.getId());
|
|
|
- tableAutoLog.setAutoChTableId(reportTable1.getId());
|
|
|
- reportTableDao.addTableAutoLog(tableAutoLog);
|
|
|
- if (Blank.isNotEmpty(reportTable.getUserGroupList())) {
|
|
|
- reportTableDao.addTableUserGroup(reportTable1.getId(), reportTable.getUserGroupList());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void addEventTable1(Integer tableReportId, Integer itemGroupId, Map<String, JSONObject> map) {
|
|
|
- for (String item : map.keySet()) {
|
|
|
- JSONObject jsonObject = map.get(item);
|
|
|
- Object dataList = jsonObject.get("dataList");
|
|
|
- Object dataTimeList = jsonObject.get("dataTimeList");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void addEventTable2(Integer dataSourceId, Integer tableReportId, List<Item> itemList, String sqlCurrentYmdh) {
|
|
|
+ public void eventTable(Integer dataSourceId, Integer tableReportId, List<Item> itemList, String sqlCurrentYmdh) {
|
|
|
ReportTable reportTable = reportTableDao.getReportTableById(tableReportId);
|
|
|
String reportTableData = reportTable.getReportTableData();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(reportTableData);
|
|
@@ -380,17 +282,30 @@ public class OpcAsyncTask {
|
|
|
Integer itemGroupId = item.getItemGroupId();
|
|
|
Integer remainder = itemGroupId % ConstantStr.SUB_TABLE_NUM;
|
|
|
for (int i = 0; i < itemList.size(); i++) {
|
|
|
- RawData rawData = rawDataDao.getRawDataList(itemList.get(i), remainder, dataSourceId, sqlCurrentYmdh);
|
|
|
- if (Blank.isNotEmpty(rawData)) {
|
|
|
+ List<RawData> rawDataList = rawDataDao.getEventRawDataList(itemList.get(i), remainder, dataSourceId, sqlCurrentYmdh);
|
|
|
+ if (Blank.isNotEmpty(rawDataList)) {
|
|
|
JSONObject jsonObject2 = new JSONObject();
|
|
|
+ RawData rawData = rawDataList.get(0);
|
|
|
String dataType = rawData.getDataType();
|
|
|
if (dataType.toLowerCase().equals("boolean")) {
|
|
|
- jsonObject2.put("dataList", JSON.parseObject(rawData.getDataValueTime(), Boolean[].class));
|
|
|
+ List<Boolean> dataList = new ArrayList<>();
|
|
|
+ for (RawData rawData1 : rawDataList) {
|
|
|
+ dataList.add(JSON.parseObject(rawData1.getDataValue(), Boolean.class));
|
|
|
+ }
|
|
|
+ jsonObject2.put("dataList", dataList);
|
|
|
} else {
|
|
|
try {
|
|
|
- jsonObject2.put("dataList", JSON.parseObject(rawData.getDataValueTime(), BigDecimal[].class));
|
|
|
+ List<BigDecimal> dataList = new ArrayList<>();
|
|
|
+ for (RawData rawData1 : rawDataList) {
|
|
|
+ dataList.add(JSON.parseObject(rawData1.getDataValue(), BigDecimal.class));
|
|
|
+ }
|
|
|
+ jsonObject2.put("dataList", dataList);
|
|
|
} catch (Exception e) {
|
|
|
- jsonObject2.put("dataList", JSON.parseObject(rawData.getDataValueTime(), String[].class));
|
|
|
+ List<String> dataList = new ArrayList<>();
|
|
|
+ for (RawData rawData1 : rawDataList) {
|
|
|
+ dataList.add(rawData1.getDataValue());
|
|
|
+ }
|
|
|
+ jsonObject2.put("dataList", dataList);
|
|
|
}
|
|
|
}
|
|
|
jsonObject2.put("dataTimeList", JSON.parseObject(rawData.getDataValueTime(), String[].class));
|