1、一个springboot模块只能有一个listener,所以删除OrgListener.java
2、IC卡充值和消费日、月、年自动化统计,农户充值和消费日、月、年自动化统计中数据库查询一般返回list的bug修改
| | |
| | | public class Test extends TaskJob{ |
| | | |
| | | private static Logger log = LogManager.getLogger(Test.class.getName()) ; |
| | | // |
| | | // public static void main(String[] args) throws Exception{ |
| | | //// SchedulerTaskSupport.addSecondlyJob("test", "testGroup", Test.class, null, 10, 1, 2) ; |
| | | //// SchedulerTaskSupport.addMinutelyJob("test", "testGroup", Test.class, null, 1, 1, -1) ; |
| | | //// SchedulerTaskSupport.addDailyJob("test", "testGroup", Test.class, null, 11, 16) ; |
| | | //// SchedulerTaskSupport.addWeeklyJob("test", "testGroup", Test.class, null, 6, 11, 34) ; |
| | | //// SchedulerTaskSupport.addWorkingDayInWeekJob("test", "testGroup", Test.class, null, 11, 41) ; |
| | | //// SchedulerTaskSupport.addMonthlyJob("test", "testGroup", Test.class, null, 25, 11, 44) ; |
| | | // |
| | | // HashMap<String , Object> jobDataMap = new HashMap<String , Object>() ; |
| | | // jobDataMap.put("123", "test123") ; |
| | | // |
| | | // SchedulerTaskSupport.addSecondlyJob("test", "testGroup", Test.class, jobDataMap, 10, 1, 2) ; |
| | | // } |
| | | |
| | | public static void main(String[] args) throws Exception{ |
| | | // SchedulerTaskSupport.addSecondlyJob("test", "testGroup", Test.class, null, 10, 1, 2) ; |
| | | // SchedulerTaskSupport.addMinutelyJob("test", "testGroup", Test.class, null, 1, 1, -1) ; |
| | | // SchedulerTaskSupport.addDailyJob("test", "testGroup", Test.class, null, 11, 16) ; |
| | | // SchedulerTaskSupport.addWeeklyJob("test", "testGroup", Test.class, null, 6, 11, 34) ; |
| | | // SchedulerTaskSupport.addWorkingDayInWeekJob("test", "testGroup", Test.class, null, 11, 41) ; |
| | | // SchedulerTaskSupport.addMonthlyJob("test", "testGroup", Test.class, null, 25, 11, 44) ; |
| | | |
| | | HashMap<String , Object> jobDataMap = new HashMap<String , Object>() ; |
| | | jobDataMap.put("123", "test123") ; |
| | | |
| | | SchedulerTaskSupport.addSecondlyJob("test", "testGroup", Test.class, jobDataMap, 10, 1, 2) ; |
| | | } |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext ctx) throws JobExecutionException { |
| | |
| | | * @param month 某月 |
| | | * @return |
| | | */ |
| | | StClientAmountMonth selectByClientIdAndYearAndMonth(@Param("clientId")Long clientId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | List<StClientAmountMonth> selectByClientIdAndYearAndMonth(@Param("clientId")Long clientId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | |
| | | /** |
| | | * update record selective |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 17:03 |
| | |
| | | * @param year 某年 |
| | | * @return |
| | | */ |
| | | StClientAmountYear selectByClientIdAndYear(@Param("clientId")Long clientId, @Param("year")Integer year) ; |
| | | List<StClientAmountYear> selectByClientIdAndYear(@Param("clientId")Long clientId, @Param("year")Integer year) ; |
| | | |
| | | /** |
| | | * update record selective |
| | |
| | | * @param month 某月 |
| | | * @return |
| | | */ |
| | | StIntakeAmountMonth selectByIntakeIdAndYearAndMonth(@Param("intakeId")Long intakeId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | List<StIntakeAmountMonth> selectByIntakeIdAndYearAndMonth(@Param("intakeId")Long intakeId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | |
| | | |
| | | /** |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 16:38 |
| | |
| | | * @param year 某年 |
| | | * @return |
| | | */ |
| | | StIntakeAmountYear selectByIntakeIdAndYear(@Param("intakeId")Long intakeId, @Param("year")Integer year) ; |
| | | List<StIntakeAmountYear> selectByIntakeIdAndYear(@Param("intakeId")Long intakeId, @Param("year")Integer year) ; |
| | | |
| | | /** |
| | | * update record selective |
| | |
| | | * @param month 某月 |
| | | * @return |
| | | */ |
| | | StLossMonth selectByIntakeIdAndYearAndMonth(@Param("intakeId")Long intakeId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | List<StLossMonth> selectByIntakeIdAndYearAndMonth(@Param("intakeId")Long intakeId, @Param("year")Integer year, @Param("month")Integer month) ; |
| | | |
| | | /** |
| | | * update record selective |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 15:18 |
| | |
| | | * @param year 某年 |
| | | * @return |
| | | */ |
| | | StLossYear selectByIntakeIdAndYear(@Param("intakeId")Long intakeId, @Param("year")Integer year) ; |
| | | List<StLossYear> selectByIntakeIdAndYear(@Param("intakeId")Long intakeId, @Param("year")Integer year) ; |
| | | |
| | | /** |
| | | * update record selective |
| | |
| | | @Data |
| | | public class VoIntakeLossStatistics { |
| | | public Long intakeId ; |
| | | @JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT, pattern="0.00" ) |
| | | public Double amount; |
| | | } |
| | |
| | | |
| | | |
| | | <select id="statisticsByIntake" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics"> |
| | | select intake_id, sum(amount) as amount |
| | | select intake_id as intakeId, |
| | | sum(amount) as amount |
| | | from st_loss_month |
| | | where `year` = #{year,jdbcType=INTEGER} |
| | | group by intake_id |
| | |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | <select id="selectByIntakeIdAndYear" resultMap="BaseResultMap"> |
| | | <select id="selectByIntakeIdAndYear" resultType="com.dy.pipIrrGlobal.pojoSt.StLossYear"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | |
| | | List<VoClientRechargeStatistics> list = seRechargeHistoryMapper.statisticsByClient(statisticsStartId, statisticsEndId) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientRechargeStatistics vo : list){ |
| | | StRechargeClientDay po = this.stRechargeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; |
| | | List<StRechargeClientDay> listOfDay = this.stRechargeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; |
| | | StRechargeClientDay po = null ; |
| | | if(listOfDay != null && listOfDay.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfDay.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeClientDay() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoClientRechargeStatistics> list = stRechargeClientDayMapper.statisticsByClient(statisticsYear, statisticsMonth) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientRechargeStatistics vo : list){ |
| | | StRechargeClientMonth po = this.stRechargeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | List<StRechargeClientMonth> listOfMonth = this.stRechargeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | StRechargeClientMonth po = null ; |
| | | if(listOfMonth != null && listOfMonth.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeClientMonth() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoClientRechargeStatistics> list = stRechargeClientMonthMapper.statisticsByClient(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientRechargeStatistics vo : list){ |
| | | StRechargeClientYear po = this.stRechargeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | List<StRechargeClientYear> listOfYear = this.stRechargeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | StRechargeClientYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeClientYear() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcRechargeStatistics> list = seRechargeHistoryMapper.statisticsByIc(statisticsStartId, statisticsEndId) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcRechargeStatistics vo : list){ |
| | | StRechargeIcDay po = this.stRechargeIcDayMapper.selectByClientAndCardAndYearAndMonth(vo.clientId, vo.cardId, statisticsYear, statisticsMonth) ; |
| | | List<StRechargeIcDay> listOfDay = this.stRechargeIcDayMapper.selectByClientAndCardAndYearAndMonth(vo.clientId, vo.cardId, statisticsYear, statisticsMonth) ; |
| | | StRechargeIcDay po = null ; |
| | | if(listOfDay != null && listOfDay.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfDay.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeIcDay() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcRechargeStatistics> list = stRechargeIcDayMapper.statisticsByIc(statisticsYear, statisticsMonth) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcRechargeStatistics vo : list){ |
| | | StRechargeIcMonth po = this.stRechargeIcMonthMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | List<StRechargeIcMonth> listOfMonth = this.stRechargeIcMonthMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | StRechargeIcMonth po = null ; |
| | | if(listOfMonth != null && listOfMonth.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeIcMonth() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcRechargeStatistics> list = stRechargeIcMonthMapper.statisticsByIc(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcRechargeStatistics vo : list){ |
| | | StRechargeIcYear po = this.stRechargeIcYearMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | List<StRechargeIcYear> listOfYear = this.stRechargeIcYearMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | StRechargeIcYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StRechargeIcYear() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoClientAmountStatistics> list = rmClientAmountDayDao.statisticsByClient(statisticsStartId, statisticsEndId) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientAmountStatistics vo : list){ |
| | | StClientAmountMonth po = stClientAmountMonthDao.selectByClientIdAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; |
| | | 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(); |
| | | } |
| | |
| | | List<VoClientAmountStatistics> list = stClientAmountMonthDao.statisticsByClient(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientAmountStatistics vo : list){ |
| | | StClientAmountYear po = stClientAmountYearDao.selectByClientIdAndYear(vo.clientId, statisticsYear) ; |
| | | 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(); |
| | | } |
| | |
| | | List<VoClientConsumeStatistics> list = rmOpenCloseValveHistoryMapper.statisticsByClient(statisticsStartDt, statisticsEndDt) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientConsumeStatistics vo : list){ |
| | | StConsumeClientDay po = this.stConsumeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; |
| | | List<StConsumeClientDay> listOfDay = this.stConsumeClientDayMapper.selectByClientAndYearAndMonth(vo.clientId, statisticsYear, statisticsMonth) ; |
| | | StConsumeClientDay po = null ; |
| | | if(listOfDay != null && listOfDay.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfDay.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeClientDay() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoClientConsumeStatistics> list = stConsumeClientDayMapper.statisticsByClient(statisticsYear, statisticsMonth) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientConsumeStatistics vo : list){ |
| | | StConsumeClientMonth po = this.stConsumeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | List<StConsumeClientMonth> listOfMonth = this.stConsumeClientMonthMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | StConsumeClientMonth po = null ; |
| | | if(listOfMonth != null && listOfMonth.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeClientMonth() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoClientConsumeStatistics> list = stConsumeClientMonthMapper.statisticsByClient(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoClientConsumeStatistics vo : list){ |
| | | StConsumeClientYear po = this.stConsumeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | List<StConsumeClientYear> listOfYear = this.stConsumeClientYearMapper.selectByClientAndYear(vo.clientId, statisticsYear) ; |
| | | StConsumeClientYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeClientYear() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcConsumeStatistics> list = rmOpenCloseValveHistoryMapper.statisticsByIc(statisticsStartDt, statisticsEndDt) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcConsumeStatistics vo : list){ |
| | | StConsumeIcDay po = this.stConsumeIcDayMapper.selectByClientAndCardAndYearAndMonth(vo.clientId, vo.cardId, statisticsYear, statisticsMonth) ; |
| | | List<StConsumeIcDay> listOfDay = this.stConsumeIcDayMapper.selectByClientAndCardAndYearAndMonth(vo.clientId, vo.cardId, statisticsYear, statisticsMonth) ; |
| | | StConsumeIcDay po = null ; |
| | | if(listOfDay != null && listOfDay.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfDay.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeIcDay() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcConsumeStatistics> list = stConsumeIcDayMapper.statisticsByIc(statisticsYear, statisticsMonth) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcConsumeStatistics vo : list){ |
| | | StConsumeIcMonth po = this.stConsumeIcMonthMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | List<StConsumeIcMonth> listOfMonth = this.stConsumeIcMonthMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | StConsumeIcMonth po = null ; |
| | | if(listOfMonth != null && listOfMonth.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeIcMonth() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | List<VoIcConsumeStatistics> list = stConsumeIcMonthMapper.statisticsByIc(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIcConsumeStatistics vo : list){ |
| | | StConsumeIcYear po = this.stConsumeIcYearMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | List<StConsumeIcYear> listOfYear = this.stConsumeIcYearMapper.selectByClientAndCardAndYear(vo.clientId, vo.cardId, statisticsYear) ; |
| | | StConsumeIcYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StConsumeIcYear() ; |
| | | po.clientId = vo.clientId ; |
| | |
| | | import com.dy.pipIrrGlobal.daoSt.StIntakeAmountYearMapper; |
| | | import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth; |
| | | import com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear; |
| | | import com.dy.pipIrrGlobal.pojoSt.StLossYear; |
| | | import com.dy.pipIrrGlobal.voSt.VoIntakeAmountStatistics; |
| | | import com.dy.pipIrrGlobal.voSt.VoIntakeLossStatistics; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | List<VoIntakeAmountStatistics> list = rmIntakeAmountDayDao.statisticsByIntake(statisticsStartId, statisticsEndId) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIntakeAmountStatistics vo : list){ |
| | | StIntakeAmountMonth po = this.stIntakeAmountMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ; |
| | | List<StIntakeAmountMonth> listOfMonth = this.stIntakeAmountMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ; |
| | | StIntakeAmountMonth po = null ; |
| | | if(listOfMonth != null && listOfMonth.size() > 0) { |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0); |
| | | } |
| | | if(po == null){ |
| | | po = new StIntakeAmountMonth() ; |
| | | } |
| | |
| | | List<VoIntakeAmountStatistics> list = stIntakeAmountMonthDao.statisticsByIntake(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIntakeAmountStatistics vo : list){ |
| | | StIntakeAmountYear po = stIntakeAmountYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ; |
| | | List<StIntakeAmountYear> listOfYear = stIntakeAmountYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ; |
| | | StIntakeAmountYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0) { |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0); |
| | | } |
| | | if(po == null){ |
| | | po = new StIntakeAmountYear() ; |
| | | } |
| | |
| | | List<VoIntakeLossStatistics> list = rmLossDayDao.statisticsByIntake(statisticsStartId, statisticsEndId) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIntakeLossStatistics vo : list){ |
| | | StLossMonth po = this.stLossMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ; |
| | | List<StLossMonth> listOfMonth = this.stLossMonthDao.selectByIntakeIdAndYearAndMonth(vo.intakeId, statisticsYear, statisticsMonth) ; |
| | | StLossMonth po = null ; |
| | | if (listOfMonth != null && listOfMonth.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfMonth.get(0) ; |
| | | } |
| | | if(po == null){ |
| | | po = new StLossMonth() ; |
| | | } |
| | |
| | | List<VoIntakeLossStatistics> list = stLossMonthDao.statisticsByIntake(statisticsYear) ; |
| | | if(list != null && list.size() > 0){ |
| | | for(VoIntakeLossStatistics vo : list){ |
| | | StLossYear po = this.stLossYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ; |
| | | List<StLossYear> listOfYear = this.stLossYearDao.selectByIntakeIdAndYear(vo.intakeId, statisticsYear) ; |
| | | StLossYear po = null ; |
| | | if(listOfYear != null && listOfYear.size() > 0){ |
| | | //程序逻辑控制上,集合中只有一个对象 |
| | | po = listOfYear.get(0) ; |
| | | } |
| | | if(po == null) { |
| | | po = new StLossYear(); |
| | | } |
| | |
| | | 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.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | |
| | |
| | | |
| | | private static Logger log = LogManager.getLogger(Test.class.getName()) ; |
| | | |
| | | private String orgTag ; |
| | | |
| | | private StLoss stLoss ; |
| | | private StIntake stIntake ; |
| | | private StClient stClient ; |
| | |
| | | private Integer statisticsYear; |
| | | private Integer statisticsMonth; |
| | | private Integer statisticsDay; |
| | | private Long statisticsStartId ; |
| | | private Long statisticsEndId ; |
| | | private Date statisticsStartDt ; |
| | | private Date statisticsEndDt ; |
| | | private Long statistics4DayStartId ; |
| | | private Long statistics4DayEndId ; |
| | | private Date statistics4DayStartDt ; |
| | | private Date statistics4DayEndDt ; |
| | | private Long statistics4MonthYearStartId ; |
| | | private Long statistics4MonthYearEndId ; |
| | | //private Date statistics4MonthYearStartDt ; |
| | | //private Date statistics4MonthYearEndDt ; |
| | | |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext ctx) throws JobExecutionException { |
| | | JobDataMap jobDataMap = ctx.getJobDetail().getJobDataMap() ; |
| | | if(jobDataMap != null){ |
| | | orgTag = (String)jobDataMap.get(StatisticsListener.orgKey) ; |
| | | } |
| | | if(orgTag == null){ |
| | | return ; |
| | | } |
| | | stLoss = SpringContextUtil.getBean(StLoss.class); |
| | | stIntake = SpringContextUtil.getBean(StIntake.class); |
| | | stClient = SpringContextUtil.getBean(StClient.class); |
| | |
| | | statisticsYear = yesterdayGrp[0] ;//统计年 |
| | | statisticsMonth = yesterdayGrp[1] ;//统计月 |
| | | statisticsDay = yesterdayGrp[2] ;//统计日 |
| | | statisticsStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, 1) ; |
| | | statisticsEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statisticsStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, statisticsDay) ; |
| | | statisticsEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, statisticsDay) ; |
| | | statistics4DayStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, 1) ; |
| | | statistics4DayEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statistics4DayStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, statisticsDay) ; |
| | | statistics4DayEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, statisticsDay) ; |
| | | //统计日的量 |
| | | doStatisticsDay() ; |
| | | |
| | |
| | | String statisticsYyyy_mm = DateTime.lastMonth_ym() ; //统计年月 |
| | | statisticsYear = Integer.parseInt(statisticsYyyy_mm.substring(0, 4)) ;//统计年 |
| | | statisticsMonth = Integer.parseInt(statisticsYyyy_mm.substring(5, 7)) ;//统计月 |
| | | statisticsStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, 1) ; |
| | | statisticsEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statisticsStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, 1) ; |
| | | statisticsEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statistics4MonthYearStartId = IDLongGenerator.generateOneDayStartId(statisticsYear, statisticsMonth, 1) ; |
| | | statistics4MonthYearEndId = IDLongGenerator.generateOneDayEndId(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | //statistics4MonthYearStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, 1) ; |
| | | //statistics4MonthYearEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | }else{ |
| | | //统计本月的 |
| | | statisticsYear = ymd[0] ;//统计年 |
| | | statisticsMonth = ymd[1] ;//统计月 |
| | | statisticsStartId = IDLongGenerator.generateOneDayStartId(ymd[0], ymd[1], 1) ; |
| | | statisticsEndId = IDLongGenerator.generateOneDayEndId(ymd[0], ymd[1], DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statisticsStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, 1) ; |
| | | statisticsEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | statistics4MonthYearStartId = IDLongGenerator.generateOneDayStartId(ymd[0], ymd[1], 1) ; |
| | | statistics4MonthYearEndId = IDLongGenerator.generateOneDayEndId(ymd[0], ymd[1], DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | //statistics4MonthYearStartDt = DateTime.startOfDay(statisticsYear, statisticsMonth, 1) ; |
| | | //statistics4MonthYearEndDt = DateTime.endOfDay(statisticsYear, statisticsMonth, DateTime.endDayOfMonth(statisticsYear, statisticsMonth)) ; |
| | | } |
| | | doStatisticsMonthAndYear() ; |
| | | }else{ |
| | |
| | | * 统计 |
| | | */ |
| | | 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, statisticsStartId, statisticsEndId); |
| | | stChargeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statisticsStartId, statisticsEndId); |
| | | stConsumeByIc.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statisticsStartDt, statisticsEndDt); |
| | | stConsumeByClient.statistics4Day(statisticsYear, statisticsMonth, statisticsDay, statisticsStartDt, statisticsEndDt); |
| | | 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); |
| | | } |
| | | /** |
| | | * 统计 |
| | | */ |
| | | private void doStatisticsMonthAndYear(){ |
| | | List<Org.OrgVo> orgList = Org.OrgList ; |
| | | if(orgList != null && orgList.size() >0){ |
| | | for(Org.OrgVo vo : orgList){ |
| | | DataSourceContext.set(vo.tag);//设置数据源 |
| | | stLoss.statistics(statisticsYear, statisticsMonth, statisticsStartId, statisticsEndId) ; |
| | | stIntake.statistics(statisticsYear, statisticsMonth, statisticsStartId, statisticsEndId) ; |
| | | stClient.statistics(statisticsYear, statisticsMonth, statisticsStartId, statisticsEndId) ; |
| | | DataSourceContext.set(orgTag);//设置数据源 |
| | | stLoss.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; |
| | | stIntake.statistics(statisticsYear, statisticsMonth, statistics4MonthYearStartId, statistics4MonthYearEndId) ; |
| | | stClient.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); |
| | | } |
| | | } |
| | |
| | | package com.dy.pipIrrStatistics.statistics; |
| | | import com.dy.common.schedulerTask.SchedulerTaskSupport; |
| | | import com.dy.pipIrrGlobal.util.Org; |
| | | import com.dy.pipIrrGlobal.util.OrgListenerSupport; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.core.io.ResourceLoader; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/22 14:39 |
| | | * @Description |
| | | */ |
| | | |
| | | import com.dy.common.schedulerTask.SchedulerTaskSupport; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 监听器,实现功能:在系统启动时初始化,向数据库中插入数据 |
| | | * 本监听器不能采用ServletContextListener方式,因为Servlet上下文Context创建后 |
| | | * Spring容器并没有创建完,而本类中用了Spring容器中的Bean,即*Dao 。 |
| | | * 所以采用了Spring事件监听器来实现 |
| | | */ |
| | | @Component |
| | | public class StatisticsListener implements ApplicationListener<ApplicationReadyEvent> { |
| | | public class StatisticsListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> { |
| | | |
| | | private static Logger log = LogManager.getLogger(StatisticsListener.class.getName()) ; |
| | | |
| | | protected static final String orgKey = "tag" ; |
| | | private static final String JobName = "statisticsJob" ; |
| | | private static final String JobGroupName = "statisticsGroup" ; |
| | | private static final Integer ThreadPoolMaxCount = 1 ;//线程池线程最大个数 |
| | |
| | | @Value("${auto-statistics.startMinute: 5}") |
| | | protected Integer startMinute;//统计开始分钟 |
| | | |
| | | |
| | | @Autowired |
| | | protected ResourceLoader resourceLoader ; |
| | | |
| | | /** |
| | | * SpringBoot容器已经准备好了,执行下面方法 |
| | | * @param event 事件 |
| | |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try{ |
| | | super.init(resourceLoader); |
| | | this.start(event); |
| | | }catch (Exception e){ |
| | | log.error("注册统计定时任务出错", e); |
| | |
| | | if(startHour < 0 || startHour > 5){ |
| | | startHour = 0 ; |
| | | } |
| | | SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount, ThreadPoolPriority); |
| | | SchedulerTaskSupport.addDailyJob(JobName, JobGroupName, StatisticsJob.class, null, startHour, startMinute ) ; |
| | | List<Org.OrgVo> orgList = Org.OrgList ; |
| | | if(orgList != null && orgList.size() >0){ |
| | | SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount * orgList.size(), ThreadPoolPriority); |
| | | for(Org.OrgVo vo : orgList){ |
| | | HashMap<String , Object> jobDataMap = new HashMap<String , Object>() ; |
| | | jobDataMap.put(orgKey, vo.tag) ; |
| | | SchedulerTaskSupport.addDailyJob(JobName + vo.tag, JobGroupName, StatisticsJob.class, jobDataMap, startHour, startMinute ) ; |
| | | } |
| | | } |
| | | } |
| | | } |