|
@@ -636,99 +636,102 @@ public class ReportTableTask {
|
|
|
//获取手动报表相关的统计图以及统计图数据项信息
|
|
|
List<ReportChart> reportChartList = reportTableDao.getReportChartList(reportTableId);
|
|
|
//获取手动报表所有表格数据项和统计图的数据源信息
|
|
|
- List<DataSource> tableDataSourceList = reportTableDao.getReportDataSource(reportTableId);
|
|
|
- if (Blank.isNotEmpty(tableDataSourceList)) {
|
|
|
- for (DataSource dataSource : tableDataSourceList) {
|
|
|
+ List<Integer> itemIdList = reportTableDao.getTableItemId(reportTableId);
|
|
|
+ if (Blank.isNotEmpty(itemIdList)) {
|
|
|
+ List<DataSource> tableDataSourceList = reportTableDao.getReportDataSource(itemIdList);
|
|
|
+ if (Blank.isNotEmpty(tableDataSourceList)) {
|
|
|
+ for (DataSource dataSource : tableDataSourceList) {
|
|
|
// if (Blank.isEmpty(dataSource.getIpPassword())) {
|
|
|
// continue;
|
|
|
// }
|
|
|
- dataSource = DataSource.convertPassword(dataSource);
|
|
|
- //查看手动报表中的数据项,哪些是属于这个数据源的
|
|
|
- DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
|
|
|
- //如果数据源是OpcUa则转接到OpcUa读取数据,并通过json返回
|
|
|
- if (OpcUtil.isOpcUa(dataSourceType.getDataSourceTypeKey())) {
|
|
|
- JSONObject[] jsonObjects = restTemplate.postForObject(opcUaUrl + "/reportTable/getReportTableById/" + reportTableId, new HttpEntity<>(dataSource, new HttpHeaders()), JSONObject[].class);
|
|
|
- if (jsonObjects != null) {
|
|
|
- for (JSONObject jsonObject : jsonObjects) {
|
|
|
- Integer itemId = jsonObject.getInteger("itemId");
|
|
|
- if (Blank.isNotEmpty(reportTableItemList)) {
|
|
|
- for (int i = 0; i < reportTableItemList.size(); i++) {
|
|
|
- ReportTableItem reportTableItem = reportTableItemList.get(i);
|
|
|
- if (itemId.equals(reportTableItem.getItemId())) {
|
|
|
- reportTableItemList.get(i).setValueList(
|
|
|
- jsonObject.getString(reportTableItem.getValueType().equals(ConstantStr.CALCULATED_VALUE) ? "dataValue" : "dataOrgValue")
|
|
|
- );
|
|
|
+ dataSource = DataSource.convertPassword(dataSource);
|
|
|
+ //查看手动报表中的数据项,哪些是属于这个数据源的
|
|
|
+ DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
|
|
|
+ //如果数据源是OpcUa则转接到OpcUa读取数据,并通过json返回
|
|
|
+ if (OpcUtil.isOpcUa(dataSourceType.getDataSourceTypeKey())) {
|
|
|
+ JSONObject[] jsonObjects = restTemplate.postForObject(opcUaUrl + "/reportTable/getReportTableById/" + reportTableId, new HttpEntity<>(dataSource, new HttpHeaders()), JSONObject[].class);
|
|
|
+ if (jsonObjects != null) {
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ Integer itemId = jsonObject.getInteger("itemId");
|
|
|
+ if (Blank.isNotEmpty(reportTableItemList)) {
|
|
|
+ for (int i = 0; i < reportTableItemList.size(); i++) {
|
|
|
+ ReportTableItem reportTableItem = reportTableItemList.get(i);
|
|
|
+ if (itemId.equals(reportTableItem.getItemId())) {
|
|
|
+ reportTableItemList.get(i).setValueList(
|
|
|
+ jsonObject.getString(reportTableItem.getValueType().equals(ConstantStr.CALCULATED_VALUE) ? "dataValue" : "dataOrgValue")
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (Blank.isNotEmpty(reportChartList)) {
|
|
|
- for (int i = 0; i < reportChartList.size(); i++) {
|
|
|
- ReportChart reportChart = reportChartList.get(i);
|
|
|
- boolean flage = (reportChart.getValueType()).equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- List<ReportChartItem> reportChartItemList = reportChart.getReportChartItemList();
|
|
|
- if (Blank.isNotEmpty(reportChartItemList)) {
|
|
|
- for (int j = 0; j < reportChartItemList.size(); j++) {
|
|
|
- ReportChartItem reportChartItem = reportChartItemList.get(j);
|
|
|
- if (itemId.equals(reportChartItem.getItemId())) {
|
|
|
- reportChartItemList.get(j).setValueList(
|
|
|
- jsonObject.getString(flage ? "dataValue" : "dataOrgValue")
|
|
|
- );
|
|
|
+ if (Blank.isNotEmpty(reportChartList)) {
|
|
|
+ for (int i = 0; i < reportChartList.size(); i++) {
|
|
|
+ ReportChart reportChart = reportChartList.get(i);
|
|
|
+ boolean flage = (reportChart.getValueType()).equals(ConstantStr.CALCULATED_VALUE);
|
|
|
+ List<ReportChartItem> reportChartItemList = reportChart.getReportChartItemList();
|
|
|
+ if (Blank.isNotEmpty(reportChartItemList)) {
|
|
|
+ for (int j = 0; j < reportChartItemList.size(); j++) {
|
|
|
+ ReportChartItem reportChartItem = reportChartItemList.get(j);
|
|
|
+ if (itemId.equals(reportChartItem.getItemId())) {
|
|
|
+ reportChartItemList.get(j).setValueList(
|
|
|
+ jsonObject.getString(flage ? "dataValue" : "dataOrgValue")
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ reportChartList.get(i).setReportChartItemList(reportChartItemList);
|
|
|
}
|
|
|
- reportChartList.get(i).setReportChartItemList(reportChartItemList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else if (OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey())) {
|
|
|
- //获取这个数据源下,报表和统计图的所有数据项
|
|
|
- List<Item> itemList = reportTableDao.getItemListByDataSource(reportTableId, dataSource);
|
|
|
- List<String> itemReadNameList = new ArrayList<>();
|
|
|
- for (Item item : itemList) {
|
|
|
- itemReadNameList.add(item.getItemReadName());
|
|
|
- }
|
|
|
- String[] items = itemReadNameList.toArray(new String[]{});
|
|
|
- List<DataModel> dataModelList = dataModelDao.getDmListByItemList(itemList);
|
|
|
- Map<String, DataModel> map = DataModel.genMap(itemList, dataModelList);
|
|
|
- //读取同一个opcDa数据源下,所有项的实时数据
|
|
|
- List<JSONObject> jsonObjects = manualReportReadReal(dataSource, items, map);
|
|
|
- if (Blank.isNotEmpty(jsonObjects)) {
|
|
|
- for (JSONObject jsonObject : jsonObjects) {
|
|
|
- String itemReadName = jsonObject.getString("itemReadName");
|
|
|
- for (int i = 0; i < itemList.size(); i++) {
|
|
|
- Item item = itemList.get(i);
|
|
|
- if (itemReadName.equals(item.getItemReadName())) {
|
|
|
- Integer itemId = item.getId();
|
|
|
- if (Blank.isNotEmpty(reportTableItemList)) {
|
|
|
- for (int j = 0; j < reportTableItemList.size(); j++) {
|
|
|
- ReportTableItem reportTableItem = reportTableItemList.get(j);
|
|
|
- if (itemId.equals(reportTableItem.getItemId())) {
|
|
|
- reportTableItemList.get(j).setValueList(
|
|
|
- jsonObject.getString(reportTableItem.getValueType().equals(ConstantStr.CALCULATED_VALUE) ? "dataValue" : "dataOrgValue")
|
|
|
- );
|
|
|
+ } else if (OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey())) {
|
|
|
+ //获取这个数据源下,报表和统计图的所有数据项
|
|
|
+ List<Item> itemList = reportTableDao.getItemListByDataSource(reportTableId, dataSource);
|
|
|
+ List<String> itemReadNameList = new ArrayList<>();
|
|
|
+ for (Item item : itemList) {
|
|
|
+ itemReadNameList.add(item.getItemReadName());
|
|
|
+ }
|
|
|
+ String[] items = itemReadNameList.toArray(new String[]{});
|
|
|
+ List<DataModel> dataModelList = dataModelDao.getDmListByItemList(itemList);
|
|
|
+ Map<String, DataModel> map = DataModel.genMap(itemList, dataModelList);
|
|
|
+ //读取同一个opcDa数据源下,所有项的实时数据
|
|
|
+ List<JSONObject> jsonObjects = manualReportReadReal(dataSource, items, map);
|
|
|
+ if (Blank.isNotEmpty(jsonObjects)) {
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ String itemReadName = jsonObject.getString("itemReadName");
|
|
|
+ for (int i = 0; i < itemList.size(); i++) {
|
|
|
+ Item item = itemList.get(i);
|
|
|
+ if (itemReadName.equals(item.getItemReadName())) {
|
|
|
+ Integer itemId = item.getId();
|
|
|
+ if (Blank.isNotEmpty(reportTableItemList)) {
|
|
|
+ for (int j = 0; j < reportTableItemList.size(); j++) {
|
|
|
+ ReportTableItem reportTableItem = reportTableItemList.get(j);
|
|
|
+ if (itemId.equals(reportTableItem.getItemId())) {
|
|
|
+ reportTableItemList.get(j).setValueList(
|
|
|
+ jsonObject.getString(reportTableItem.getValueType().equals(ConstantStr.CALCULATED_VALUE) ? "dataValue" : "dataOrgValue")
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (Blank.isNotEmpty(reportChartList)) {
|
|
|
- for (int j = 0; j < reportChartList.size(); j++) {
|
|
|
- ReportChart reportChart = reportChartList.get(j);
|
|
|
- boolean flage = (reportChart.getValueType()).equals(ConstantStr.CALCULATED_VALUE);
|
|
|
- List<ReportChartItem> reportChartItemList = reportChart.getReportChartItemList();
|
|
|
- if (Blank.isNotEmpty(reportChartItemList)) {
|
|
|
- for (int k = 0; k < reportChartItemList.size(); k++) {
|
|
|
- ReportChartItem reportChartItem = reportChartItemList.get(k);
|
|
|
- if (itemId.equals(reportChartItem.getItemId())) {
|
|
|
- reportChartItemList.get(k).setValueList(
|
|
|
- jsonObject.getString(flage ? "dataValue" : "dataOrgValue")
|
|
|
- );
|
|
|
+ if (Blank.isNotEmpty(reportChartList)) {
|
|
|
+ for (int j = 0; j < reportChartList.size(); j++) {
|
|
|
+ ReportChart reportChart = reportChartList.get(j);
|
|
|
+ boolean flage = (reportChart.getValueType()).equals(ConstantStr.CALCULATED_VALUE);
|
|
|
+ List<ReportChartItem> reportChartItemList = reportChart.getReportChartItemList();
|
|
|
+ if (Blank.isNotEmpty(reportChartItemList)) {
|
|
|
+ for (int k = 0; k < reportChartItemList.size(); k++) {
|
|
|
+ ReportChartItem reportChartItem = reportChartItemList.get(k);
|
|
|
+ if (itemId.equals(reportChartItem.getItemId())) {
|
|
|
+ reportChartItemList.get(k).setValueList(
|
|
|
+ jsonObject.getString(flage ? "dataValue" : "dataOrgValue")
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ reportChartList.get(j).setReportChartItemList(reportChartItemList);
|
|
|
}
|
|
|
- reportChartList.get(j).setReportChartItemList(reportChartItemList);
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
}
|