|
@@ -3,15 +3,9 @@ package com.zcxk.meterreadingsystemv2.scheduled;
|
|
|
import com.alibaba.druid.util.StringUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.zcxk.meterreadingsystemv2.common.DateTimeUtil;
|
|
|
-import com.zcxk.meterreadingsystemv2.dao.DeviceDataDimMapper;
|
|
|
-import com.zcxk.meterreadingsystemv2.dao.TRemoteDataMapper;
|
|
|
-import com.zcxk.meterreadingsystemv2.dao.XdycbsjMapper;
|
|
|
-import com.zcxk.meterreadingsystemv2.dao.YhsbgxbMapper;
|
|
|
+import com.zcxk.meterreadingsystemv2.dao.*;
|
|
|
import com.zcxk.meterreadingsystemv2.dbs.DynamicDataSourceContextHolder;
|
|
|
-import com.zcxk.meterreadingsystemv2.entity.MeterReadData;
|
|
|
-import com.zcxk.meterreadingsystemv2.entity.TRemoteData;
|
|
|
-import com.zcxk.meterreadingsystemv2.entity.Xdycbsj;
|
|
|
-import com.zcxk.meterreadingsystemv2.entity.Yhsbgxb;
|
|
|
+import com.zcxk.meterreadingsystemv2.entity.*;
|
|
|
import com.zcxk.meterreadingsystemv2.service.MeterReadDataService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -50,6 +44,8 @@ public class MeterReadingScheduleTask {
|
|
|
private TRemoteDataMapper tRemoteDataMapper;
|
|
|
@Autowired
|
|
|
private MeterReadDataService meterReadDataService;
|
|
|
+ @Resource
|
|
|
+ private PushRecordMapper pushRecordMapper;
|
|
|
|
|
|
|
|
|
@Value("${spring.profiles.active}")
|
|
@@ -148,8 +144,16 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
String originName = "xp";
|
|
|
Integer customerId = 8;
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
//Integer startDate = 20200401;
|
|
|
//Integer endDate = 20200408;
|
|
|
AtomicInteger count = new AtomicInteger(0);
|
|
@@ -205,6 +209,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -231,8 +241,15 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "xingping";
|
|
|
Integer customerId = 34;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
AtomicInteger count = new AtomicInteger(0);
|
|
|
|
|
|
try {
|
|
@@ -286,6 +303,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时兴平任务异常: " + e.getMessage());
|
|
@@ -308,13 +331,20 @@ public class MeterReadingScheduleTask {
|
|
|
return;
|
|
|
}
|
|
|
//判断是否是每月的最后一天
|
|
|
- if(!LocalDate.now().isEqual(LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()))){
|
|
|
+ /*if(!LocalDate.now().isEqual(LocalDate.now().with(TemporalAdjusters.lastDayOfMonth()))){
|
|
|
log.info("不是最后一天");
|
|
|
return;
|
|
|
- }
|
|
|
+ }*/
|
|
|
String originName = "lb";
|
|
|
Integer customerId = 25;
|
|
|
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
/*Integer startDate = 20200531;
|
|
|
Integer endDate = 20200629;
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
@@ -322,9 +352,9 @@ public class MeterReadingScheduleTask {
|
|
|
|
|
|
Date date = Jdk8DateUtils.getLocalDateTimeToDate(ldt);*/
|
|
|
|
|
|
- Integer startDate = 20210401;
|
|
|
+ //Integer startDate = 20210401;
|
|
|
//Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
AtomicInteger count = new AtomicInteger(0);
|
|
|
try {
|
|
@@ -378,6 +408,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时萝北任务异常: "+ e.getMessage());
|
|
@@ -400,8 +436,16 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "suibin";
|
|
|
Integer customerId = 33;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
//Integer startDate = 20201226;
|
|
|
//Integer endDate = 20210126;
|
|
@@ -461,6 +505,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时绥滨任务异常: "+ e.getMessage());
|
|
@@ -474,7 +524,7 @@ public class MeterReadingScheduleTask {
|
|
|
/**
|
|
|
* 绥阳 每月4号推送
|
|
|
*/
|
|
|
- //@Scheduled(cron = "0 25 7 04 * ?")
|
|
|
+ @Scheduled(cron = "0 25 7 04 * ?")
|
|
|
public void suiyangTasks() {
|
|
|
log.info("开始执行绥阳定时任务");
|
|
|
if(!"prd".equals(active)){
|
|
@@ -483,8 +533,15 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "suiyang";
|
|
|
Integer customerId = 48;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
//Integer startDate = 20210303;
|
|
|
//Integer endDate = 20210401;
|
|
@@ -496,6 +553,7 @@ public class MeterReadingScheduleTask {
|
|
|
//List<MeterReadData> list = deviceDataDimMapper.getMeterReadDataByCustomerIdV2(customerId, startDate, endDate);
|
|
|
List<MeterReadData> list = meterReadDataService.getMeterReadDataByCustomerId(customerId,startDate,endDate);
|
|
|
|
|
|
+
|
|
|
DynamicDataSourceContextHolder.setDataSourceKey(originName);
|
|
|
log.info("=====service当前连接的数据库是:" + DynamicDataSourceContextHolder.getDataSourceKey());
|
|
|
|
|
@@ -540,6 +598,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时绥阳任务异常: "+ e.getMessage());
|
|
@@ -561,8 +625,15 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "balikun";
|
|
|
Integer customerId = 66;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
//Integer startDate = 20201008;
|
|
|
//Integer endDate = 20201105;
|
|
@@ -620,6 +691,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时巴里坤任务异常:" + e.getMessage());
|
|
@@ -641,8 +718,15 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "jingyang";
|
|
|
Integer customerId = 22;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusDays(-2).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
//Integer startDate = 20201008;
|
|
|
//Integer endDate = 20201105;
|
|
@@ -704,6 +788,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时泾阳任务异常:" + e.getMessage());
|
|
@@ -731,8 +821,15 @@ public class MeterReadingScheduleTask {
|
|
|
String originName = "tongjiang";
|
|
|
Integer customerId = 57;
|
|
|
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
//Integer startDate = 20201030;
|
|
|
//Integer endDate = 20201129;
|
|
@@ -790,6 +887,12 @@ public class MeterReadingScheduleTask {
|
|
|
}
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.warn("执行定时同江任务异常:"+ e.getMessage());
|
|
@@ -812,8 +915,16 @@ public class MeterReadingScheduleTask {
|
|
|
Integer customerId = 19;
|
|
|
//Integer startDate = 20200726;
|
|
|
//Integer endDate = 20200726;
|
|
|
- Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
- Integer endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+
|
|
|
+ Integer startDate = null;
|
|
|
+ Integer endDate = null;
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ PushRecord pushRecord = pushRecordMapper.findByCustomerId(customerId);
|
|
|
+ startDate = pushRecord.getLastDate();
|
|
|
+
|
|
|
+ //Integer startDate = Integer.valueOf(LocalDateTime.now().plusMonths(-1).plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
+ endDate = Integer.valueOf(LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern(DateTimeUtil.DATE_FORMAT)));
|
|
|
|
|
|
DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
log.info("=====service当前连接的数据库是:" + DynamicDataSourceContextHolder.getDataSourceKey());
|
|
@@ -852,6 +963,12 @@ public class MeterReadingScheduleTask {
|
|
|
|
|
|
}
|
|
|
log.info("=======================end list size="+list.size()+"-count="+count.get());
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceKey("smart-city");
|
|
|
+ pushRecord.setLastDate(endDate);
|
|
|
+ pushRecord.setDataSize(list.size());
|
|
|
+ pushRecord.setCountSize(count.get());
|
|
|
+ pushRecord.setUpdateDate(new Date());
|
|
|
+ pushRecordMapper.updateByPrimaryKeySelective(pushRecord);
|
|
|
}
|
|
|
log.info("end executeMeterReadIng");
|
|
|
}
|