提取对象直接get(“对象的key”)
private static BigDecimal collectNum(List<Map<Object, Object>> collect) {
BigDecimal diffSum = BigDecimal.ZERO; // 用于存储差值的总和
for (Map<Object, Object> entry : collect) {
Object startPosObj = entry.get("start_pos");
Object endPosObj = entry.get("end_pos");
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);
}
}
return diffSum;
}