|
@@ -42,14 +42,14 @@ public abstract class EventReportTableValidate implements ReportTableValidate {
|
|
|
* @return
|
|
|
*/
|
|
|
private static String replaceValueByScale(String value,String policyItemId,List<ReportDataPolicyItem> itemScaleList, Integer defaultScale){
|
|
|
- log.info("事件驱动报表:EventReportTableValidate.itemScaleList=" + itemScaleList.toString() + ",policyItemId=" + policyItemId);
|
|
|
+ //log.info("事件驱动报表:EventReportTableValidate.itemScaleList=" + itemScaleList.toString() + ",policyItemId=" + policyItemId);
|
|
|
Optional<ReportDataPolicyItem> first = itemScaleList.stream()
|
|
|
.filter((item) -> policyItemId.equals(item.getId().toString()))
|
|
|
.findFirst();
|
|
|
Integer scale = null;
|
|
|
if (first.isPresent()) {
|
|
|
scale = first.get().getScale();
|
|
|
- log.info("事件驱动报表:EventReportTableValidate.scale=" + scale);
|
|
|
+ //log.info("事件驱动报表:EventReportTableValidate.scale=" + scale);
|
|
|
}
|
|
|
if(Blank.isEmpty(scale)){
|
|
|
scale = defaultScale;
|
|
@@ -85,34 +85,57 @@ public abstract class EventReportTableValidate implements ReportTableValidate {
|
|
|
if (Blank.isNotEmpty(rowCol)) {
|
|
|
//能解析的数据才赋值
|
|
|
try {
|
|
|
+ String v = rowCol.getString("v");
|
|
|
+ String regex = "^\\$\\{.*\\}$";
|
|
|
+ //赋值基础数据项
|
|
|
+ if (v != null && v.matches(regex)) {
|
|
|
+ ReportTableBasicItemEnum o = Arrays.stream(ReportTableBasicItemEnum.values())
|
|
|
+ .filter(b -> b.name().equals(v.substring(2, v.length() - 1)))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (o != null) {
|
|
|
+ String value = o.getValue();
|
|
|
+ rowCol.put("v", value);
|
|
|
+ rowCol.put("m", value);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
JSONObject rowColJson = JSONObject.parseObject(rowCol.getString("celldata"));
|
|
|
String type = rowColJson.getString("type");
|
|
|
//如果类型为数据,则存入数据
|
|
|
if (type.equals("data")) {
|
|
|
JSONObject rowColData = rowColJson.getJSONObject("data");
|
|
|
String itemId = rowColData.getString("itemId");
|
|
|
- if (Blank.isNotEmpty(itemId)) {
|
|
|
- if(CollUtil.isEmpty(itemDataMap)){
|
|
|
- rowCol.put("v", null);
|
|
|
- rowCol.put("m", null);
|
|
|
- };
|
|
|
- List<Item> itemList = itemDataMap.get(itemId);
|
|
|
- if (CollUtil.isNotEmpty(itemList)) {
|
|
|
- String value = itemList.get(0).getValue();
|
|
|
- value = replaceValueByScale(value, itemId, itemScaleList, defaultScale);
|
|
|
- rowCol.put("v", value);
|
|
|
- rowCol.put("m", value);
|
|
|
- itemList.remove(0);
|
|
|
- } else {
|
|
|
- rowCol.put("v", null);
|
|
|
- rowCol.put("m", null);
|
|
|
- }
|
|
|
+ if (Blank.isEmpty(itemId)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- //如果类型为时间,则存入时间
|
|
|
- } else if (type.equals("datatime")) {
|
|
|
if(CollUtil.isEmpty(itemDataMap)){
|
|
|
rowCol.put("v", null);
|
|
|
rowCol.put("m", null);
|
|
|
+ continue;
|
|
|
+ };
|
|
|
+ List<Item> itemList = itemDataMap.get(itemId);
|
|
|
+ if (CollUtil.isEmpty(itemList)) {
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String value = itemList.get(0).getValue();
|
|
|
+ value = replaceValueByScale(value, itemId, itemScaleList, defaultScale);
|
|
|
+ rowCol.put("v", value);
|
|
|
+ rowCol.put("m", value);
|
|
|
+ itemList.remove(0);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果类型为时间,则存入时间
|
|
|
+ if (type.equals("datatime")) {
|
|
|
+ if(CollUtil.isEmpty(itemDataMap)){
|
|
|
+ rowCol.put("v", null);
|
|
|
+ rowCol.put("m", null);
|
|
|
+ continue;
|
|
|
};
|
|
|
List<Item> itemList = itemDataMap.entrySet()
|
|
|
.stream()
|
|
@@ -120,31 +143,17 @@ public abstract class EventReportTableValidate implements ReportTableValidate {
|
|
|
.map(Map.Entry::getValue)
|
|
|
.orElse(new ArrayList<>());
|
|
|
|
|
|
- if (CollUtil.isNotEmpty(itemList)) {
|
|
|
- String time = itemList.get(0).getTime();
|
|
|
- rowCol.put("v", time);
|
|
|
- rowCol.put("m", time);
|
|
|
- } else {
|
|
|
+ if (CollUtil.isEmpty(itemList)) {
|
|
|
rowCol.put("v", null);
|
|
|
rowCol.put("m", null);
|
|
|
+ continue;
|
|
|
}
|
|
|
+ String time = itemList.get(0).getTime();
|
|
|
+ rowCol.put("v", time);
|
|
|
+ rowCol.put("m", time);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- String v = rowCol.getString("v");
|
|
|
- String regex = "^\\$\\{.*\\}$";
|
|
|
- //赋值基础数据项
|
|
|
- if (v != null && v.matches(regex)) {
|
|
|
- if (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);
|
|
|
- }
|
|
|
- }
|
|
|
+ log.error("事件驱动报表解析数据出错",e);
|
|
|
}
|
|
|
}
|
|
|
}
|