|  |  |  | 
|---|
|  |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import com.dy.common.util.IDLongGenerator; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.util.Org; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.quartz.JobDataMap; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.quartz.JobExecutionException; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class StatisticsJob extends TaskJob { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Logger log = LogManager.getLogger(Test.class.getName()) ; | 
|---|
|  |  |  | private static Logger log = LogManager.getLogger(StatisticsJob.class.getName()) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String orgTag ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private StLoss stLoss ; | 
|---|
|  |  |  | private StIntake stIntake ; | 
|---|
|  |  |  | private StClient stClient ; | 
|---|
|  |  |  | private StLossAmount stLossAmount; | 
|---|
|  |  |  | private StIntakeAmount stIntakeAmount; | 
|---|
|  |  |  | private StClientAmount stClientAmount; | 
|---|
|  |  |  | private StChargeByIc stChargeByIc ; | 
|---|
|  |  |  | private StChargeByClient stChargeByClient ; | 
|---|
|  |  |  | private StConsumeByIc stConsumeByIc ; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(orgTag == null){ | 
|---|
|  |  |  | return ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stLoss = SpringContextUtil.getBean(StLoss.class); | 
|---|
|  |  |  | stIntake = SpringContextUtil.getBean(StIntake.class); | 
|---|
|  |  |  | stClient = SpringContextUtil.getBean(StClient.class); | 
|---|
|  |  |  | DataSourceContext.set(orgTag);//设置数据源 | 
|---|
|  |  |  | stLossAmount = SpringContextUtil.getBean(StLossAmount.class); | 
|---|
|  |  |  | stIntakeAmount = SpringContextUtil.getBean(StIntakeAmount.class); | 
|---|
|  |  |  | stClientAmount = SpringContextUtil.getBean(StClientAmount.class); | 
|---|
|  |  |  | stChargeByIc = SpringContextUtil.getBean(StChargeByIc.class); | 
|---|
|  |  |  | stChargeByClient = SpringContextUtil.getBean(StChargeByClient.class); | 
|---|
|  |  |  | stConsumeByIc = SpringContextUtil.getBean(StConsumeByIc.class); | 
|---|
|  |  |  | stConsumeByClient = SpringContextUtil.getBean(StConsumeByClient.class); | 
|---|
|  |  |  | if(stLoss != null && stIntake != null && stClient != null | 
|---|
|  |  |  | if(stLossAmount != null && stIntakeAmount != null && stClientAmount != null | 
|---|
|  |  |  | && stChargeByIc != null && stChargeByClient != null | 
|---|
|  |  |  | && stConsumeByIc != null && stConsumeByClient != null){ | 
|---|
|  |  |  | String yesterday = DateTime.lastXDay_yyyy_MM_dd(1) ;//得到昨天,零晨时刻统计,统计昨天的数 | 
|---|
|  |  |  | 
|---|
|  |  |  | statisticsYear = yesterdayGrp[0] ;//统计年 | 
|---|
|  |  |  | statisticsMonth = yesterdayGrp[1] ;//统计月 | 
|---|
|  |  |  | statisticsDay = yesterdayGrp[2] ;//统计日 | 
|---|
|  |  |  | statistics4DayStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, 1) ; | 
|---|
|  |  |  | statistics4DayEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; | 
|---|
|  |  |  | statistics4DayStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, statisticsDay) ; | 
|---|
|  |  |  | statistics4DayEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, statisticsDay) ; | 
|---|
|  |  |  | statistics4DayStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, statisticsDay) ; | 
|---|
|  |  |  | statistics4DayEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, statisticsDay) ; | 
|---|
|  |  |  | //统计日的量 | 
|---|
|  |  |  | 
|---|
|  |  |  | * 统计 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void doStatisticsDay(){ | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | List<Org.OrgVo> orgList = Org.OrgList ; | 
|---|
|  |  |  | if(orgList != null && orgList.size() >0){ | 
|---|
|  |  |  | for(Org.OrgVo vo : orgList){ | 
|---|
|  |  |  | DataSourceContext.set(vo.tag);//设置数据源 | 
|---|
|  |  |  | stChargeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | stChargeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | stConsumeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | stConsumeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } */ | 
|---|
|  |  |  | DataSourceContext.set(orgTag);//设置数据源 | 
|---|
|  |  |  | stChargeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | stChargeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | stConsumeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | stConsumeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | stClientAmount.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId) ; | 
|---|
|  |  |  | //stChargeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | //stChargeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartId, statistics4DayEndId); | 
|---|
|  |  |  | //stConsumeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | //stConsumeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statistics4DayStartDt, statistics4DayEndDt); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 统计 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void doStatisticsMonthAndYear(){ | 
|---|
|  |  |  | DataSourceContext.set(orgTag);//设置数据源 | 
|---|
|  |  |  | stLoss.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  | stIntake.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  | stClient.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  | stLossAmount.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  | stIntakeAmount.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  | stClientAmount.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stChargeByIc.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | stChargeByClient.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | stConsumeByIc.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | stConsumeByClient.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | //stChargeByIc.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | //stChargeByClient.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | //stConsumeByIc.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | //stConsumeByClient.statistics4MonthAndYear(statisticsYear, statisticsMonth); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|