forked from github/dataease
fix(视图): 快速计算累加空指针
This commit is contained in:
parent
7b85f11a11
commit
8f65581420
@ -1515,7 +1515,11 @@ public class ChartViewService {
|
||||
preDataItems.forEach(preDataItem -> {
|
||||
String[] groupStackAxisArr = Arrays.copyOfRange(preDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||
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 -> {
|
||||
String[] groupStackAxisArr = Arrays.copyOfRange(curDataItem, finalXAxisBase.size(), finalSubEndIndex);
|
||||
@ -1532,10 +1536,14 @@ public class ChartViewService {
|
||||
final int index = dataIndex;
|
||||
final AtomicReference<BigDecimal> accumValue = new AtomicReference<>(new BigDecimal(0));
|
||||
data.forEach(item -> {
|
||||
BigDecimal curVal = new BigDecimal(item[index]);
|
||||
BigDecimal curAccumValue = accumValue.get().add(curVal);
|
||||
String val = item[index];
|
||||
BigDecimal curAccumValue = accumValue.get();
|
||||
if (!StringUtils.isBlank(val)) {
|
||||
BigDecimal curVal = new BigDecimal(val);
|
||||
curAccumValue = curAccumValue.add(curVal);
|
||||
accumValue.set(curAccumValue);
|
||||
}
|
||||
item[index] = curAccumValue.toString();
|
||||
accumValue.set(curAccumValue);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user