wuzeyu
2024-12-27 f5f8138f4f50eedd3598a9073956f0afa56e7139
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StClientSv.java
@@ -30,36 +30,62 @@
    protected StClientAmountYearMapper stClientAmountYearDao ;
    /**
     * 月统计---漏损
     * 月统计---农户用水量及金额
     */
    @Transactional
    protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth, Long statisticsStartId, Long statisticsEndId){
        List<VoClientAmountStatistics> list = rmClientAmountDayDao.statisticsByClient(statisticsStartId, statisticsEndId) ;
        if(list != null && list.size() > 0){
            for(VoClientAmountStatistics vo : list){
                StClientAmountMonth po = new StClientAmountMonth() ;
                List<StClientAmountMonth> listOfMonth = stClientAmountMonthDao.selectByClientIdAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ;
                StClientAmountMonth po = null ;
                if(listOfMonth != null && listOfMonth.size() > 0){
                    //程序逻辑控制上,集合中只有一个对象
                    po = listOfMonth.get(0) ;
                }
                if(po == null) {
                    po = new StClientAmountMonth();
                }
                po.clientId = vo.clientId ;
                po.year = statisticsYear ;
                po.month = statisticsMonth ;
                po.amount = vo.amount;
                stClientAmountMonthDao.insert(po) ;
                po.money = vo.money ;
                if(po.id == null) {
                    stClientAmountMonthDao.insert(po);
                }else{
                    stClientAmountMonthDao.updateByPrimaryKey(po) ;
                }
            }
        }
    }
    /**
     * 年统计---漏损
     * 年统计---农户用水量及金额
     */
    @Transactional
    protected void statisticsYear(Integer statisticsYear){
        List<VoClientAmountStatistics> list = stClientAmountMonthDao.statisticsByClient(statisticsYear) ;
        if(list != null && list.size() > 0){
            for(VoClientAmountStatistics vo : list){
                StClientAmountYear po = new StClientAmountYear() ;
                List<StClientAmountYear> listOfYear = stClientAmountYearDao.selectByClientIdAndYear(vo.clientId, statisticsYear) ;
                StClientAmountYear po = null ;
                if(listOfYear != null && listOfYear.size() > 0){
                    //程序逻辑控制上,集合中只有一个对象
                    po = listOfYear.get(0) ;
                }
                if(po == null) {
                    po = new StClientAmountYear();
                }
                po.clientId = vo.clientId ;
                po.year = statisticsYear ;
                po.amount = vo.amount;
                stClientAmountYearDao.insert(po) ;
                po.money = vo.money ;
                if(po.id == null) {
                    stClientAmountYearDao.insert(po);
                }else{
                    stClientAmountYearDao.updateByPrimaryKey(po) ;
                }
            }
        }
    }