|
@@ -10,6 +10,7 @@ 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_common.util.JavaTypeUtil;
|
|
|
+import com.example.opc_da.dao.ItemGroupDao;
|
|
|
import com.example.opc_da.dao.RawDataDao;
|
|
|
import com.example.opc_da.dao.ReportTableDao;
|
|
|
import com.example.opc_da.util.OpcDaUtil;
|
|
@@ -40,6 +41,9 @@ public class OpcAsyncTask {
|
|
|
private RawDataDao rawDataDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ItemGroupDao itemGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
@Autowired
|
|
@@ -209,19 +213,46 @@ public class OpcAsyncTask {
|
|
|
* 事件驱动报表异步添加数据
|
|
|
*/
|
|
|
public void eventTable(Integer tableReportId, Integer dataSourceId, List<Item> itemList, String sqlCurrentYmdh) {
|
|
|
+ if (Blank.isEmpty(tableReportId, dataSourceId, itemList, sqlCurrentYmdh)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
ReportTable reportTable = reportTableDao.getReportTableById(tableReportId);
|
|
|
String reportTableData = reportTable.getReportTableData();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(reportTableData);
|
|
|
JSONArray objects = new JSONArray();
|
|
|
- if (Blank.isNotEmpty(itemList)) {
|
|
|
- Integer remainder = itemList.get(0).getItemGroupId() % 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)) {
|
|
|
- JSONObject jsonObject1 = new JSONObject();
|
|
|
- String dataType = rawData.getDataType();
|
|
|
- if (dataType.toLowerCase().equals("boolean")) {
|
|
|
- List<Boolean> dataList = JavaTypeUtil.objChangeListBool(rawData.getDataValue());
|
|
|
+ Integer remainder = itemList.get(0).getItemGroupId() % 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)) {
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ String dataType = rawData.getDataType();
|
|
|
+ if (dataType.toLowerCase().equals("boolean")) {
|
|
|
+ List<Boolean> dataList = JavaTypeUtil.objChangeListBool(rawData.getDataValue());
|
|
|
+ List<String> dataTimeList = JavaTypeUtil.objChangeListStr(rawData.getDataValueTime());
|
|
|
+ List<Long> dataIndexList = JavaTypeUtil.objChangeListLong(rawData.getDataIndex());
|
|
|
+ jsonObject1.put("itemGroupId", rawData.getItemGroupId());
|
|
|
+ jsonObject1.put("itemGroupName", itemList.get(i).getItemGroupName());
|
|
|
+ jsonObject1.put("itemName", itemList.get(i).getItemName());
|
|
|
+ jsonObject1.put("describe", Blank.isEmpty(itemList.get(i).getDescribe()) ? itemList.get(i).getItemName() : itemList.get(i).getDescribe());
|
|
|
+ jsonObject1.put("dataList", dataList);
|
|
|
+ jsonObject1.put("dataTimeList", dataTimeList);
|
|
|
+ jsonObject1.put("dataIndexList", dataIndexList);
|
|
|
+ objects.set(i, jsonObject1);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ List<BigDecimal> dataList = JavaTypeUtil.objChangeListBig(rawData.getDataValue());
|
|
|
+ List<String> dataTimeList = JavaTypeUtil.objChangeListStr(rawData.getDataValueTime());
|
|
|
+ List<Long> dataIndexList = JavaTypeUtil.objChangeListLong(rawData.getDataIndex());
|
|
|
+ jsonObject1.put("itemGroupId", rawData.getItemGroupId());
|
|
|
+ jsonObject1.put("itemGroupName", itemList.get(i).getItemGroupName());
|
|
|
+ jsonObject1.put("itemName", itemList.get(i).getItemName());
|
|
|
+ jsonObject1.put("describe", Blank.isEmpty(itemList.get(i).getDescribe()) ? itemList.get(i).getItemName() : itemList.get(i).getDescribe());
|
|
|
+ jsonObject1.put("dataList", dataList);
|
|
|
+ jsonObject1.put("dataTimeList", dataTimeList);
|
|
|
+ jsonObject1.put("dataIndexList", dataIndexList);
|
|
|
+ objects.set(i, jsonObject1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ List<String> dataList = JavaTypeUtil.objChangeListStr(rawData.getDataValue());
|
|
|
List<String> dataTimeList = JavaTypeUtil.objChangeListStr(rawData.getDataValueTime());
|
|
|
List<Long> dataIndexList = JavaTypeUtil.objChangeListLong(rawData.getDataIndex());
|
|
|
jsonObject1.put("itemGroupId", rawData.getItemGroupId());
|
|
@@ -232,32 +263,6 @@ public class OpcAsyncTask {
|
|
|
jsonObject1.put("dataTimeList", dataTimeList);
|
|
|
jsonObject1.put("dataIndexList", dataIndexList);
|
|
|
objects.set(i, jsonObject1);
|
|
|
- } else {
|
|
|
- try {
|
|
|
- List<BigDecimal> dataList = JavaTypeUtil.objChangeListBig(rawData.getDataValue());
|
|
|
- List<String> dataTimeList = JavaTypeUtil.objChangeListStr(rawData.getDataValueTime());
|
|
|
- List<Long> dataIndexList = JavaTypeUtil.objChangeListLong(rawData.getDataIndex());
|
|
|
- jsonObject1.put("itemGroupId", rawData.getItemGroupId());
|
|
|
- jsonObject1.put("itemGroupName", itemList.get(i).getItemGroupName());
|
|
|
- jsonObject1.put("itemName", itemList.get(i).getItemName());
|
|
|
- jsonObject1.put("describe", Blank.isEmpty(itemList.get(i).getDescribe()) ? itemList.get(i).getItemName() : itemList.get(i).getDescribe());
|
|
|
- jsonObject1.put("dataList", dataList);
|
|
|
- jsonObject1.put("dataTimeList", dataTimeList);
|
|
|
- jsonObject1.put("dataIndexList", dataIndexList);
|
|
|
- objects.set(i, jsonObject1);
|
|
|
- } catch (Exception e) {
|
|
|
- List<String> dataList = JavaTypeUtil.objChangeListStr(rawData.getDataValue());
|
|
|
- List<String> dataTimeList = JavaTypeUtil.objChangeListStr(rawData.getDataValueTime());
|
|
|
- List<Long> dataIndexList = JavaTypeUtil.objChangeListLong(rawData.getDataIndex());
|
|
|
- jsonObject1.put("itemGroupId", rawData.getItemGroupId());
|
|
|
- jsonObject1.put("itemGroupName", itemList.get(i).getItemGroupName());
|
|
|
- jsonObject1.put("itemName", itemList.get(i).getItemName());
|
|
|
- jsonObject1.put("describe", Blank.isEmpty(itemList.get(i).getDescribe()) ? itemList.get(i).getItemName() : itemList.get(i).getDescribe());
|
|
|
- jsonObject1.put("dataList", dataList);
|
|
|
- jsonObject1.put("dataTimeList", dataTimeList);
|
|
|
- jsonObject1.put("dataIndexList", dataIndexList);
|
|
|
- objects.set(i, jsonObject1);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -266,7 +271,8 @@ public class OpcAsyncTask {
|
|
|
ReportTable reportTable1 = new ReportTable();
|
|
|
reportTable1.setTableTemplateId(reportTable.getTableTemplateId());
|
|
|
reportTable1.setUserId(reportTable.getUserId());
|
|
|
- reportTable1.setReportTableName(reportTable.getReportTableName() + "_" + (Blank.isNotEmpty(itemList) ? itemList.get(0).getItemGroupName() : "") + "_" + DateUtil.dateChangeStr(new Date(), "yyyyMMddHHmmss"));
|
|
|
+ ItemGroup itemGroup = itemGroupDao.getItemGroupById(itemList.get(0).getItemGroupId());
|
|
|
+ reportTable1.setReportTableName(reportTable.getReportTableName() + "_" + (Blank.isNotEmpty(itemGroup) ? itemGroup.getGroupName() : "") + "_" + DateUtil.dateChangeStr(new Date(), "yyyyMMddHHmmss"));
|
|
|
reportTable1.setReportTableData(jsonObject.toJSONString());
|
|
|
reportTable1.setReportValueFormat(reportTable.getReportValueFormat());
|
|
|
reportTable1.setIsAutoReport(ConstantStr.EVENT_GENERATE_REPORT);
|