pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientAmountSv.java
@@ -1,11 +1,14 @@
package com.dy.pipIrrStatistics.statistics;
import com.dy.pipIrrGlobal.daoRm.RmClientAmountDayMapper;
import com.dy.pipIrrGlobal.daoSt.StClientAmountDayMapper;
import com.dy.pipIrrGlobal.daoSt.StClientAmountMonthMapper;
import com.dy.pipIrrGlobal.daoSt.StClientAmountYearMapper;
import com.dy.pipIrrGlobal.pojoSt.StClientAmountMonth;
import com.dy.pipIrrGlobal.pojoSt.StClientAmountYear;
import com.dy.pipIrrGlobal.pojoRm.RmClientAmountDay;
import com.dy.pipIrrGlobal.pojoSt.*;
import com.dy.pipIrrGlobal.voRm.VoClientAmountDay;
import com.dy.pipIrrGlobal.voSt.VoClientAmountStatistics;
import com.dy.pipIrrGlobal.voSt.VoClientConsumeStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -24,10 +27,43 @@
    protected RmClientAmountDayMapper rmClientAmountDayDao;
    @Autowired
    protected StClientAmountDayMapper stClientAmountDayDao;
    @Autowired
    protected StClientAmountMonthMapper stClientAmountMonthDao ;
    @Autowired
    protected StClientAmountYearMapper stClientAmountYearDao ;
    /**
     * 日统计---农户用水量及金额,由纵型数据改成行型数据
     */
    @Transactional
    protected void statisticsDay(Integer statisticsYear, Integer statisticsMonth, Integer statisticsDay, Long statisticsStartId, Long statisticsEndId){
        List<VoClientAmountStatistics> list = rmClientAmountDayDao.statisticsByClient(statisticsStartId, statisticsEndId) ;
        if(list != null && list.size() > 0){
            for(VoClientAmountStatistics vo : list){
                List<StClientAmountDay> listOfDay = stClientAmountDayDao.selectByClientIdAndYearAndMonthAndDay(vo.clientId, statisticsYear, statisticsMonth) ;
                StClientAmountDay po = null ;
                if(listOfDay != null && listOfDay.size() > 0){
                    //程序逻辑控制上,集合中只有一个对象
                    po = listOfDay.get(0) ;
                }
                if(po == null){
                    po = new StClientAmountDay() ;
                    po.clientId = vo.clientId ;
                    po.year = statisticsYear ;
                    po.month = statisticsMonth ;
                }
                this.setValueOfDayOfMonth(statisticsDay, vo, po);
                if(po.id == null) {
                    stClientAmountDayDao.insert(po);
                }else{
                    stClientAmountDayDao.updateByPrimaryKeySelective(po) ;
                }
            }
        }
    }
    /**
     * 月统计---农户用水量及金额
@@ -89,4 +125,191 @@
            }
        }
    }
    private void setValueOfDayOfMonth(Integer statisticsDay, VoClientAmountStatistics vo, StClientAmountDay po){
        switch (statisticsDay) {
            case 1:
                po.amount1 = vo.amount;
                po.times1 = vo.times;
                break;
            case 2:
                po.amount2 = vo.amount;
                po.times2 = vo.times;
                break;
            case 3:
                po.amount3 = vo.amount;
                po.times3 = vo.times;
                break;
            case 4:
                po.amount4 = vo.amount;
                po.times4 = vo.times;
                break;
            case 5:
                po.amount5 = vo.amount;
                po.times5 = vo.times;
                break;
            case 6:
                po.amount6 = vo.amount;
                po.times6 = vo.times;
                break;
            case 7:
                po.amount7 = vo.amount;
                po.times7 = vo.times;
                break;
            case 8:
                po.amount8 = vo.amount;
                po.times8 = vo.times;
                break;
            case 9:
                po.amount9 = vo.amount;
                po.times9 = vo.times;
                break;
            case 10:
                po.amount10 = vo.amount;
                po.times10 = vo.times;
                break;
            case 11:
                po.amount11 = vo.amount;
                po.times11 = vo.times;
                break;
            case 12:
                po.amount12 = vo.amount;
                po.times12 = vo.times;
                break;
            case 13:
                po.amount13 = vo.amount;
                po.times13 = vo.times;
                break;
            case 14:
                po.amount14 = vo.amount;
                po.times14 = vo.times;
                break;
            case 15:
                po.amount15 = vo.amount;
                po.times15 = vo.times;
                break;
            case 16:
                po.amount16 = vo.amount;
                po.times16 = vo.times;
                break;
            case 17:
                po.amount17 = vo.amount;
                po.times17 = vo.times;
                break;
            case 18:
                po.amount18 = vo.amount;
                po.times18 = vo.times;
                break;
            case 19:
                po.amount19 = vo.amount;
                po.times19 = vo.times;
                break;
            case 20:
                po.amount20 = vo.amount;
                po.times20 = vo.times;
                break;
            case 21:
                po.amount21 = vo.amount;
                po.times21 = vo.times;
                break;
            case 22:
                po.amount22 = vo.amount;
                po.times22 = vo.times;
                break;
            case 23:
                po.amount23 = vo.amount;
                po.times23 = vo.times;
                break;
            case 24:
                po.amount24 = vo.amount;
                po.times24 = vo.times;
                break;
            case 25:
                po.amount25 = vo.amount;
                po.times25 = vo.times;
                break;
            case 26:
                po.amount26 = vo.amount;
                po.times26 = vo.times;
                break;
            case 27:
                po.amount27 = vo.amount;
                po.times27 = vo.times;
                break;
            case 28:
                po.amount28 = vo.amount;
                po.times28 = vo.times;
                break;
            case 29:
                po.amount29 = vo.amount;
                po.times29 = vo.times;
                break;
            case 30:
                po.amount30 = vo.amount;
                po.times30 = vo.times;
                break;
            case 31:
                po.amount31 = vo.amount;
                po.times31 = vo.times;
                break;
        }
    }
    private void setValueOfMonthOfYear(Integer statisticsMonth, VoClientConsumeStatistics vo, StConsumeClientMonth po){
        switch (statisticsMonth) {
            case 1:
                po.amount1 = vo.amount;
                po.times1 = vo.times;
                break;
            case 2:
                po.amount2 = vo.amount;
                po.times2 = vo.times;
                break;
            case 3:
                po.amount3 = vo.amount;
                po.times3 = vo.times;
                break;
            case 4:
                po.amount4 = vo.amount;
                po.times4 = vo.times;
                break;
            case 5:
                po.amount5 = vo.amount;
                po.times5 = vo.times;
                break;
            case 6:
                po.amount6 = vo.amount;
                po.times6 = vo.times;
                break;
            case 7:
                po.amount7 = vo.amount;
                po.times7 = vo.times;
                break;
            case 8:
                po.amount8 = vo.amount;
                po.times8 = vo.times;
                break;
            case 9:
                po.amount9 = vo.amount;
                po.times9 = vo.times;
                break;
            case 10:
                po.amount10 = vo.amount;
                po.times10 = vo.times;
                break;
            case 11:
                po.amount11 = vo.amount;
                po.times11 = vo.times;
                break;
            case 12:
                po.amount12 = vo.amount;
                po.times12 = vo.times;
                break;
        }
    }
    private void setValueOfYear(VoClientConsumeStatistics vo, StConsumeClientYear po){
        po.amount = vo.amount;
        po.times = vo.times;
    }
}