|  |  |  | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.daoSt.StClientAmountYearMapper; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.pojoSt.*; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | List<StClientAmountDay> listOfDay = stClientAmountDayDao.selectByYearAndMonthAndDay(statisticsYear, statisticsMonth) ; | 
|---|
|  |  |  | 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) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | StClientAmountDay po = this.getDayDataOfClient(listOfDay, vo.clientId) ; | 
|---|
|  |  |  | if(po == null){ | 
|---|
|  |  |  | po = new StClientAmountDay() ; | 
|---|
|  |  |  | po.clientId = vo.clientId ; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | protected void statisticsMonth(Integer statisticsYear, Integer statisticsMonth, Long statisticsStartId, Long statisticsEndId){ | 
|---|
|  |  |  | List<VoClientAmountStatistics> list = rmClientAmountDayDao.statisticsByClient(statisticsStartId, statisticsEndId) ; | 
|---|
|  |  |  | List<VoClientAmountStatistics> list = stClientAmountDayDao.statisticsByClient(statisticsYear, statisticsMonth) ; | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | List<StClientAmountMonth> listOfMonth = stClientAmountMonthDao.selectByYear(statisticsYear) ; | 
|---|
|  |  |  | for(VoClientAmountStatistics vo : list){ | 
|---|
|  |  |  | List<StClientAmountMonth> listOfMonth = stClientAmountMonthDao.selectByClientIdAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; | 
|---|
|  |  |  | StClientAmountMonth po = null ; | 
|---|
|  |  |  | if(listOfMonth != null && listOfMonth.size() > 0){ | 
|---|
|  |  |  | //程序逻辑控制上,集合中只有一个对象 | 
|---|
|  |  |  | po = listOfMonth.get(0) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | StClientAmountMonth po = this.getMonthDataOfClient(listOfMonth, vo.clientId) ; | 
|---|
|  |  |  | if(po == null) { | 
|---|
|  |  |  | po = new StClientAmountMonth(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | po.clientId = vo.clientId ; | 
|---|
|  |  |  | po.year = statisticsYear ; | 
|---|
|  |  |  | po.month = statisticsMonth ; | 
|---|
|  |  |  | po.amount = vo.amount; | 
|---|
|  |  |  | po.money = vo.money ; | 
|---|
|  |  |  | this.setValueOfMonthOfYear(statisticsMonth, vo, po) ; | 
|---|
|  |  |  | if(po.id == null) { | 
|---|
|  |  |  | stClientAmountMonthDao.insert(po); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | protected void statisticsYear(Integer statisticsYear){ | 
|---|
|  |  |  | List<VoClientAmountStatistics> list = stClientAmountMonthDao.statisticsByClient(statisticsYear) ; | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | List<StClientAmountYear> listOfYear = stClientAmountYearDao.selectByYear(statisticsYear) ; | 
|---|
|  |  |  | for(VoClientAmountStatistics vo : list){ | 
|---|
|  |  |  | List<StClientAmountYear> listOfYear = stClientAmountYearDao.selectByClientIdAndYear(vo.clientId, statisticsYear) ; | 
|---|
|  |  |  | StClientAmountYear po = null ; | 
|---|
|  |  |  | if(listOfYear != null && listOfYear.size() > 0){ | 
|---|
|  |  |  | //程序逻辑控制上,集合中只有一个对象 | 
|---|
|  |  |  | po = listOfYear.get(0) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | StClientAmountYear po = this.getYearDataOfClient(listOfYear, vo.clientId) ; | 
|---|
|  |  |  | if(po == null) { | 
|---|
|  |  |  | po = new StClientAmountYear(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | po.clientId = vo.clientId ; | 
|---|
|  |  |  | po.year = statisticsYear ; | 
|---|
|  |  |  | po.amount = vo.amount; | 
|---|
|  |  |  | po.amount = vo.amount ; | 
|---|
|  |  |  | po.money = vo.money ; | 
|---|
|  |  |  | po.times = vo.times ; | 
|---|
|  |  |  | if(po.id == null) { | 
|---|
|  |  |  | stClientAmountYearDao.insert(po); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private StClientAmountDay getDayDataOfClient(List<StClientAmountDay> list, Long clientId){ | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(StClientAmountDay po : list){ | 
|---|
|  |  |  | if(po.clientId.longValue() == clientId.longValue()){ | 
|---|
|  |  |  | //程序逻辑控制上,集合中只有一个对象 | 
|---|
|  |  |  | return po; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private StClientAmountMonth getMonthDataOfClient(List<StClientAmountMonth> list, Long clientId){ | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(StClientAmountMonth po : list){ | 
|---|
|  |  |  | if(po.clientId.longValue() == clientId.longValue()){ | 
|---|
|  |  |  | //程序逻辑控制上,集合中只有一个对象 | 
|---|
|  |  |  | return po; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private StClientAmountYear getYearDataOfClient(List<StClientAmountYear> list, Long clientId){ | 
|---|
|  |  |  | if(list != null && list.size() > 0){ | 
|---|
|  |  |  | for(StClientAmountYear po : list){ | 
|---|
|  |  |  | if(po.clientId.longValue() == clientId.longValue()){ | 
|---|
|  |  |  | //程序逻辑控制上,集合中只有一个对象 | 
|---|
|  |  |  | return po; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void setValueOfMonthOfYear(Integer statisticsMonth, VoClientConsumeStatistics vo, StConsumeClientMonth po){ | 
|---|
|  |  |  | private void setValueOfMonthOfYear(Integer statisticsMonth, VoClientAmountStatistics vo, StClientAmountMonth po){ | 
|---|
|  |  |  | switch (statisticsMonth) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | po.amount1 = vo.money; | 
|---|
|  |  |  | po.amount1 = vo.amount; | 
|---|
|  |  |  | po.money1 = vo.money; | 
|---|
|  |  |  | po.times1 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | po.amount2 = vo.money; | 
|---|
|  |  |  | po.amount2 = vo.amount; | 
|---|
|  |  |  | po.money2 = vo.money; | 
|---|
|  |  |  | po.times2 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | po.amount3 = vo.money; | 
|---|
|  |  |  | po.amount3 = vo.amount; | 
|---|
|  |  |  | po.money3 = vo.money; | 
|---|
|  |  |  | po.times3 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | po.amount4 = vo.money; | 
|---|
|  |  |  | po.amount4 = vo.amount; | 
|---|
|  |  |  | po.money4 = vo.money; | 
|---|
|  |  |  | po.times4 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | po.amount5 = vo.money; | 
|---|
|  |  |  | po.amount5 = vo.amount; | 
|---|
|  |  |  | po.money5 = vo.money; | 
|---|
|  |  |  | po.times5 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 6: | 
|---|
|  |  |  | po.amount6 = vo.money; | 
|---|
|  |  |  | po.amount6 = vo.amount; | 
|---|
|  |  |  | po.money6 = vo.money; | 
|---|
|  |  |  | po.times6 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 7: | 
|---|
|  |  |  | po.amount7 = vo.money; | 
|---|
|  |  |  | po.amount7 = vo.amount; | 
|---|
|  |  |  | po.money7 = vo.money; | 
|---|
|  |  |  | po.times7 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 8: | 
|---|
|  |  |  | po.amount8 = vo.money; | 
|---|
|  |  |  | po.amount8 = vo.amount; | 
|---|
|  |  |  | po.money8 = vo.money; | 
|---|
|  |  |  | po.times8 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 9: | 
|---|
|  |  |  | po.amount9 = vo.money; | 
|---|
|  |  |  | po.amount9 = vo.amount; | 
|---|
|  |  |  | po.money9 = vo.money; | 
|---|
|  |  |  | po.times9 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 10: | 
|---|
|  |  |  | po.amount10 = vo.money; | 
|---|
|  |  |  | po.amount10 = vo.amount; | 
|---|
|  |  |  | po.money10 = vo.money; | 
|---|
|  |  |  | po.times10 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 11: | 
|---|
|  |  |  | po.amount11 = vo.money; | 
|---|
|  |  |  | po.amount11 = vo.amount; | 
|---|
|  |  |  | po.money11 = vo.money; | 
|---|
|  |  |  | po.times11 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 12: | 
|---|
|  |  |  | po.amount12 = vo.money; | 
|---|
|  |  |  | po.amount12 = vo.amount; | 
|---|
|  |  |  | po.money12 = vo.money; | 
|---|
|  |  |  | po.times12 = vo.times; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void setValueOfYear(VoClientConsumeStatistics vo, StConsumeClientYear po){ | 
|---|
|  |  |  | po.amount = vo.money; | 
|---|
|  |  |  | po.times = vo.times; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|