소스 검색

修改bug 7246及占比、环比合计的计算

wangxingwang 6 년 전
부모
커밋
856e3c289d

+ 5 - 0
src/main/java/com/yihu/quota/controller/QuotaReportController.java

@ -253,6 +253,11 @@ public class QuotaReportController extends BaseController {
                }
            }
        }
        int size = dataList.size();
        if (size > 0 && dataList.get(size - 1).containsValue("合计")) {
            dataList = dataList.subList(0, size - 1);
        }
        return dataList;
    }

+ 38 - 0
src/main/java/com/yihu/quota/service/quota/BaseStatistsService.java

@ -209,6 +209,7 @@ public class BaseStatistsService {
                map.put(firstColumnField, secondMap.get(firstColumnField));
                for(int i = 0 ;i < moleDimensions.length ; i++){
                    map.put(moleDimensions[i], secondMap.get(moleDimensions[i]).toString());
                    map.put(moleDimensions[i] + "Code", secondMap.get(moleDimensions[i] + "Code").toString());
                }
                double point = 0;
                double secondResultVal = Double.valueOf(secondMap.get("result") == null ? "0" : secondMap.get(resultField).toString());
@ -458,6 +459,21 @@ public class BaseStatistsService {
                }
            }
        }
        Double moleVal = caculateResult(moleList);
        Double denoVal = caculateResult(denoList);
        if (0 != denoVal) {
            Map<String, Object> map = new HashMap<>();
            double result = 0;
            if(operation == 1) {
                result = (moleVal / denoVal) * operationValue;
            } else if(operation == 2) {
                result = (moleVal / denoVal) / operationValue;
            }
            map.put("result", basesicUtil.decimalPointHandle(result));
            map.put("firstColumn", "合计");
            map.put(dimension, "合计");
            divisionResultList.add(map);
        }
        return  divisionResultList;
    }
@ -1495,6 +1511,16 @@ public class BaseStatistsService {
                }
            }
        }
        Double moleVal = caculateResult(moleList);
        Double denoVal = caculateResult(denoList);
        if (0 != denoVal) {
            Map<String, Object> map = new HashMap<>();
            double result = (moleVal - denoVal) / denoVal * operationValue;
            map.put("result", basesicUtil.decimalPointHandle(result));
            map.put("firstColumn", "合计");
            map.put(dimension, "合计");
            divisionResultList.add(map);
        }
        return  divisionResultList;
    }
@ -1905,4 +1931,16 @@ public class BaseStatistsService {
        return filters;
    }
    public Double caculateResult(List<Map<String, Object>> listMap) {
        Map<String, Double> map = new HashMap<>();
        map.put("result", 0d);
        listMap.forEach(item -> {
            item.forEach((k,v) -> {
                if ("result".equals(k)) {
                    map.put("result", map.get("result") + Double.parseDouble(v + ""));
                }
            });
        });
        return map.get("result");
    }
}