java 代码笔记 求平均值



1.求平均值

   PageVo pageVos =
                ((BaseMonitorIndicatorsSkinsDao) this.dao).page(baseMonitorIndicatorsSkinsParamVo);
        Double single_weight = 0.0;
        Double transverse_diameter = 0.0;
        Double longitudinal_diameter = 0.0;
        Double painted = 0.0;
        Integer seed_nums = 0;
        for (BaseMonitorIndicatorsSkinsGridVo pageVo : pageVos.getData()) {

            if (null != pageVo.getSingleWeight()) {
                single_weight = single_weight + pageVo.getSingleWeight();
            }
            if (null != pageVo.getTransverseDiameter()) {
                transverse_diameter = transverse_diameter + pageVo.getTransverseDiameter();
            }
            if (null != pageVo.getPainted()) {
                painted = painted + pageVo.getPainted();
            }

            if (null != pageVo.getLongitudinalDiameter()) {
                longitudinal_diameter = longitudinal_diameter + pageVo.getLongitudinalDiameter();
            }
            if (null != pageVo.getSeedNums()) {
                seed_nums = seed_nums + pageVo.getSeedNums();
            }
        }
        if (0 < pageVos.getData().size()) {
            BaseMonitorIndicatorsSkinsGridVo monitorIndicatorsSkinsGridVo = new BaseMonitorIndicatorsSkinsGridVo();

            monitorIndicatorsSkinsGridVo.setSingleWeight(single_weight / pageVos.getData().size());
            monitorIndicatorsSkinsGridVo.setTransverseDiameter(transverse_diameter / pageVos.getData().size());
            monitorIndicatorsSkinsGridVo.setLongitudinalDiameter(longitudinal_diameter / pageVos.getData().size());
            monitorIndicatorsSkinsGridVo.setPainted(painted / pageVos.getData().size());
            monitorIndicatorsSkinsGridVo.setSeedNums(seed_nums / pageVos.getData().size());
            monitorIndicatorsSkinsGridVo.setType("平均值");
            pageVos.getData().add(monitorIndicatorsSkinsGridVo);
        }
        return GsonUtil.toJsonByDateTime24(pageVos);

  列表显示

(1).   js加入,  

 {
                header: "类型",
                field: "type",
                allowSort: true,
                width: "$field.gridWidth",
                align: "center",
                headerAlign: "center"
            },

(2). vo里面设置字段  一个type字段

(3).  sql语句加入站位

SELECT '单个' AS type,base_monitor_indicators_skins.ID,

(4).   后台拿到

monitorIndicatorsSkinsGridVo.setType("平均值");

 

你可能感兴趣的:(java)