|
@@ -87,7 +87,7 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
* @param sheetData
|
|
|
* @param sheetTableDataMap
|
|
|
*/
|
|
|
- private void echoSheet(JSONArray sheetData, Map<String, Map<String, List<Item>>> sheetTableDataMap) {
|
|
|
+ protected void echoSheet(JSONArray sheetData, Map<String, Map<String, List<Item>>> sheetTableDataMap) {
|
|
|
for (int i = 0; i < sheetData.size(); i++) {
|
|
|
JSONArray row = sheetData.getJSONArray(i);
|
|
|
for (int j = 0; j < row.size(); j++) {
|
|
@@ -102,40 +102,46 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
if (type.equals("data")) {
|
|
|
JSONObject rowColData = rowColJson.getJSONObject("data");
|
|
|
String uid = rowColData.getString("uid");
|
|
|
- if (Blank.isNotEmpty(uid)) {
|
|
|
- List<Item> itemList = sheetTableDataMap.get(tableId) != null ? sheetTableDataMap.get(tableId).get(uid) : null;
|
|
|
- if (itemList != null && !itemList.isEmpty()) {
|
|
|
- String value = itemList.get(0).getValue();
|
|
|
- rowCol.put("v", value);
|
|
|
- rowCol.put("m", value);
|
|
|
- itemList.remove(0);
|
|
|
- }
|
|
|
+ if (Blank.isEmpty(uid) || sheetTableDataMap.get(tableId) == null || sheetTableDataMap.get(tableId).get(uid) == null
|
|
|
+ || sheetTableDataMap.get(tableId).get(uid).isEmpty()) {
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
+ } else {
|
|
|
+ List<Item> itemList = sheetTableDataMap.get(tableId).get(uid);
|
|
|
+ String value = itemList.get(0).getValue();
|
|
|
+ rowCol.put("v", value);
|
|
|
+ rowCol.put("m", value);
|
|
|
+ itemList.remove(0);
|
|
|
}
|
|
|
//如果类型为时间,则存入时间
|
|
|
} else if (type.equals("datatime")) {
|
|
|
- sheetTableDataMap.get(tableId).entrySet().stream().findFirst().ifPresent(entry -> {
|
|
|
- List<Item> itemList = entry.getValue();
|
|
|
+ if (Blank.isEmpty(sheetTableDataMap.get(tableId))
|
|
|
+ || sheetTableDataMap.get(tableId).values().stream().findFirst().orElse(new ArrayList<>()).isEmpty()) {
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
+ } else {
|
|
|
+ List<Item> itemList = sheetTableDataMap.get(tableId).values().stream().findFirst().orElse(new ArrayList<>());
|
|
|
String time = itemList.get(0).getTime();
|
|
|
rowCol.put("v", time);
|
|
|
rowCol.put("m", time);
|
|
|
- });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
String v = rowCol.getString("v");
|
|
|
String regex = "^\\$\\{.*\\}$";
|
|
|
//赋值基础数据项
|
|
|
- if (v.matches(regex)) {
|
|
|
- String basicItem = v.substring(2, v.length() - 1);
|
|
|
- ReportTableBasicItemEnum reportTableBasicItemEnum = Arrays.stream(ReportTableBasicItemEnum.values())
|
|
|
- .filter(b -> b.name().equals(basicItem)).findFirst().get();
|
|
|
- if (Blank.isNotEmpty(reportTableBasicItemEnum)) {
|
|
|
- String value = reportTableBasicItemEnum.getValue();
|
|
|
- rowCol.put("v", value);
|
|
|
- rowCol.put("m", value);
|
|
|
- } else {
|
|
|
- rowCol.put("v", null);
|
|
|
- rowCol.put("m", null);
|
|
|
- }
|
|
|
+ if (v.matches(regex) && Arrays.stream(ReportTableBasicItemEnum.values())
|
|
|
+ .filter(b -> b.name().equals(v.substring(2, v.length() - 1))).findFirst().orElse(null) != null) {
|
|
|
+ String value = Objects.requireNonNull(Arrays.stream(ReportTableBasicItemEnum.values())
|
|
|
+ .filter(b -> b.name().equals(v.substring(2, v.length() - 1))).findFirst().orElse(null)).getValue();
|
|
|
+ rowCol.put("v", value);
|
|
|
+ rowCol.put("m", value);
|
|
|
+ } else {
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -408,19 +414,19 @@ public abstract class AutomaticReportTableValidate implements ReportTableValidat
|
|
|
//如果为柱状图或折线图
|
|
|
if (chartType.equals(ConstantStr.LINE_CHART) || chartType.equals(ConstantStr.BAR_CHART)) {
|
|
|
//所有时间数据,组成x轴
|
|
|
- List<String> allXaiosList = new ArrayList<>();
|
|
|
+ List<String> allAxiosList = new ArrayList<>();
|
|
|
List<List<List<String>>> serieDataList = new ArrayList<>();
|
|
|
//遍历数据项
|
|
|
for (String policyItemId : policyItemIdList) {
|
|
|
List<Item> validDataList = splitData(null, itemDataMap.get(policyItemId), sTime, eTime, valueTakingMode, bucketType, bucketValue);
|
|
|
- allXaiosList.addAll(validDataList.stream().map(Item::getTime).collect(Collectors.toList()));
|
|
|
+ allAxiosList.addAll(validDataList.stream().map(Item::getTime).collect(Collectors.toList()));
|
|
|
//生成series的数据
|
|
|
serieDataList.add(validDataList.stream().map(i ->
|
|
|
Stream.of(i.getTime(), i.getValue()).collect(Collectors.toList())
|
|
|
).collect(Collectors.toList()));
|
|
|
}
|
|
|
//得到x轴时间去重数据
|
|
|
- List<String> xAxisList = allXaiosList.stream().distinct().sorted().collect(Collectors.toList());
|
|
|
+ List<String> xAxisList = allAxiosList.stream().distinct().sorted().collect(Collectors.toList());
|
|
|
|
|
|
for (int i = 0; i < series.size(); i++) {
|
|
|
JSONObject serieJsonObject = series.getJSONObject(i);
|