forked from github/dataease
Merge pull request #8779 from dataease/pr@dev@fix_accumulate_npe
fix(视图): 快速计算累加空指针
This commit is contained in:
commit
0db8470972
@ -1515,7 +1515,11 @@ public class ChartViewService {
|
|||||||
preDataItems.forEach(preDataItem -> {
|
preDataItems.forEach(preDataItem -> {
|
||||||
String[] groupStackAxisArr = Arrays.copyOfRange(preDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
String[] groupStackAxisArr = Arrays.copyOfRange(preDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||||
String groupStackAxis = StringUtils.join(groupStackAxisArr, '-');
|
String groupStackAxis = StringUtils.join(groupStackAxisArr, '-');
|
||||||
preDataMap.put(groupStackAxis, new BigDecimal(preDataItem[finalDataIndex]));
|
String preVal = preDataItem[finalDataIndex];
|
||||||
|
if (StringUtils.isBlank(preVal)) {
|
||||||
|
preVal = "0";
|
||||||
|
}
|
||||||
|
preDataMap.put(groupStackAxis, new BigDecimal(preVal));
|
||||||
});
|
});
|
||||||
curDataItems.forEach(curDataItem -> {
|
curDataItems.forEach(curDataItem -> {
|
||||||
String[] groupStackAxisArr = Arrays.copyOfRange(curDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
String[] groupStackAxisArr = Arrays.copyOfRange(curDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||||
@ -1532,10 +1536,14 @@ public class ChartViewService {
|
|||||||
final int index = dataIndex;
|
final int index = dataIndex;
|
||||||
final AtomicReference<BigDecimal> accumValue = new AtomicReference<>(new BigDecimal(0));
|
final AtomicReference<BigDecimal> accumValue = new AtomicReference<>(new BigDecimal(0));
|
||||||
data.forEach(item -> {
|
data.forEach(item -> {
|
||||||
BigDecimal curVal = new BigDecimal(item[index]);
|
String val = item[index];
|
||||||
BigDecimal curAccumValue = accumValue.get().add(curVal);
|
BigDecimal curAccumValue = accumValue.get();
|
||||||
|
if (!StringUtils.isBlank(val)) {
|
||||||
|
BigDecimal curVal = new BigDecimal(val);
|
||||||
|
curAccumValue = curAccumValue.add(curVal);
|
||||||
|
accumValue.set(curAccumValue);
|
||||||
|
}
|
||||||
item[index] = curAccumValue.toString();
|
item[index] = curAccumValue.toString();
|
||||||
accumValue.set(curAccumValue);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user