可以更好的统计数值,更加精准
BigDecimal diffSum = BigDecimal.ZERO; // 用于存储差值的总和
for (Map<Object, Object> entry : collect) {
Object startPosObj = entry.get("start_pos");
Object endPosObj = entry.get("end_pos");
System.out.println("startPosObj" + startPosObj);
System.out.println("endPosObj" + endPosObj);
if (endPosObj != null && startPosObj != null) {
BigDecimal startPos = new BigDecimal(startPosObj.toString());
BigDecimal endPos = new BigDecimal(endPosObj.toString());
BigDecimal diff = endPos.subtract(startPos);
diffSum = diffSum.add(diff);
}
}
System.out.println("end_pos - start_pos的差值总和:" + diffSum);