|
|
@ -173,10 +173,10 @@ public class SyncTrendsStatsService { |
|
|
|
|
|
|
|
|
log.info("end sync trends stats"); |
|
|
log.info("end sync trends stats"); |
|
|
//
|
|
|
//
|
|
|
log.info("begin to sync aurora trends stats"); |
|
|
// log.info("begin to sync aurora trends stats");
|
|
|
AuroraDeviceTrendStats deviceTrendsStatsAlter = new AuroraDeviceTrendStats(); |
|
|
// AuroraDeviceTrendStats deviceTrendsStatsAlter = new AuroraDeviceTrendStats();
|
|
|
handleExternalSync(apikey,now, Long.valueOf(iter),deviceTrendsStatsAlter); |
|
|
// handleExternalSync(apikey,now, Long.valueOf(iter),deviceTrendsStatsAlter);
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
// DataSourceContextHolder.clearCurrentDataSourceKey();
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -264,65 +264,65 @@ public class SyncTrendsStatsService { |
|
|
*/ |
|
|
*/ |
|
|
@Scheduled(cron = "${schedule.cron.expression}") |
|
|
@Scheduled(cron = "${schedule.cron.expression}") |
|
|
public void syncAuroraTrendsData() { |
|
|
public void syncAuroraTrendsData() { |
|
|
String requestId =UUID.randomUUID().toString(); |
|
|
// String requestId =UUID.randomUUID().toString();
|
|
|
MDC.put("requestId", requestId); |
|
|
// MDC.put("requestId", requestId);
|
|
|
ZonedDateTime todayMidnight = getMidnightInTokyo(); |
|
|
// ZonedDateTime todayMidnight = getMidnightInTokyo();
|
|
|
ZonedDateTime yesterdayMidnight = todayMidnight.minusDays(1); |
|
|
// ZonedDateTime yesterdayMidnight = todayMidnight.minusDays(1);
|
|
|
|
|
|
//
|
|
|
List<Integer> companyIdList=new ArrayList<>(); |
|
|
// List<Integer> companyIdList=new ArrayList<>();
|
|
|
String sql="\t\tSELECT\n" + |
|
|
// String sql="\t\tSELECT\n" +
|
|
|
"\t\t\tbcom.id,\n" + |
|
|
// "\t\t\tbcom.id,\n" +
|
|
|
"\t\t\tbcom.company_name companyName\n" + |
|
|
// "\t\t\tbcom.company_name companyName\n" +
|
|
|
"\t\tFROM\n" + |
|
|
// "\t\tFROM\n" +
|
|
|
"\t\t\tdata_center_aeon_admin.basic_company bcom\n" + |
|
|
// "\t\t\tdata_center_aeon_admin.basic_company bcom\n" +
|
|
|
"\t\tWHERE bcom.flag != 1"; |
|
|
// "\t\tWHERE bcom.flag != 1";
|
|
|
|
|
|
//
|
|
|
jdbcTemplate.query(sql,rs->{ |
|
|
// jdbcTemplate.query(sql,rs->{
|
|
|
companyIdList.add(rs.getInt("id")); |
|
|
// companyIdList.add(rs.getInt("id"));
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
//
|
|
|
companyIdList.stream().forEach(iter->{ |
|
|
// companyIdList.stream().forEach(iter->{
|
|
|
//Get Top company's Apikey, for further query Aurora info use.
|
|
|
// //Get Top company's Apikey, for further query Aurora info use.
|
|
|
Long topCompanyId = dataSourceInterceptor.getTopCompanyId(iter.toString()); |
|
|
// Long topCompanyId = dataSourceInterceptor.getTopCompanyId(iter.toString());
|
|
|
String apikey=basicCompanyMapperExt.getApikeyByCompanyId(topCompanyId).getApikey(); |
|
|
// String apikey=basicCompanyMapperExt.getApikeyByCompanyId(topCompanyId).getApikey();
|
|
|
DeviceTrendsStatsInfoAuroraDTO resultDTO = fetchDataFromAurora(apikey,yesterdayMidnight, todayMidnight, Long.valueOf(iter)); |
|
|
// DeviceTrendsStatsInfoAuroraDTO resultDTO = fetchDataFromAurora(apikey,yesterdayMidnight, todayMidnight, Long.valueOf(iter));
|
|
|
DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_" + iter); |
|
|
// DataSourceContextHolder.setCurrentDataSourceKey("dataSourceForCompany_" + iter);
|
|
|
|
|
|
//
|
|
|
if (resultDTO != null) { |
|
|
// if (resultDTO != null) {
|
|
|
AuroraTrendsStatsTotal auroraTrendsStatsTotal = new AuroraTrendsStatsTotal(); |
|
|
// AuroraTrendsStatsTotal auroraTrendsStatsTotal = new AuroraTrendsStatsTotal();
|
|
|
auroraTrendsStatsTotal.setReceiverDeviceId(0L); |
|
|
// auroraTrendsStatsTotal.setReceiverDeviceId(0L);
|
|
|
if (resultDTO.getRecieverDeviceIdDelta() != null){ |
|
|
// if (resultDTO.getRecieverDeviceIdDelta() != null){
|
|
|
auroraTrendsStatsTotal.setSenderDeviceId(resultDTO.getSenderDeviceIdDelta()); |
|
|
// auroraTrendsStatsTotal.setSenderDeviceId(resultDTO.getSenderDeviceIdDelta());
|
|
|
}else { |
|
|
// }else {
|
|
|
auroraTrendsStatsTotal.setSenderDeviceId(0L); |
|
|
// auroraTrendsStatsTotal.setSenderDeviceId(0L);
|
|
|
} |
|
|
// }
|
|
|
if (resultDTO.getSenderDispatchDelta() != null){ |
|
|
// if (resultDTO.getSenderDispatchDelta() != null){
|
|
|
auroraTrendsStatsTotal.setDispatch(resultDTO.getSenderDispatchDelta()); |
|
|
// auroraTrendsStatsTotal.setDispatch(resultDTO.getSenderDispatchDelta());
|
|
|
}else { |
|
|
// }else {
|
|
|
auroraTrendsStatsTotal.setDispatch(0L); |
|
|
// auroraTrendsStatsTotal.setDispatch(0L);
|
|
|
} |
|
|
// }
|
|
|
if (resultDTO.getSenderAlertDelta() != null){ |
|
|
// if (resultDTO.getSenderAlertDelta() != null){
|
|
|
auroraTrendsStatsTotal.setAlert(Long.valueOf(resultDTO.getSenderAlertDelta())); |
|
|
// auroraTrendsStatsTotal.setAlert(Long.valueOf(resultDTO.getSenderAlertDelta()));
|
|
|
}else { |
|
|
// }else {
|
|
|
auroraTrendsStatsTotal.setAlert(0L); |
|
|
// auroraTrendsStatsTotal.setAlert(0L);
|
|
|
} |
|
|
// }
|
|
|
if (resultDTO.getSenderAlertCancelDelta() != null){ |
|
|
// if (resultDTO.getSenderAlertCancelDelta() != null){
|
|
|
auroraTrendsStatsTotal.setAlertCancel(Long.valueOf(resultDTO.getSenderAlertCancelDelta())); |
|
|
// auroraTrendsStatsTotal.setAlertCancel(Long.valueOf(resultDTO.getSenderAlertCancelDelta()));
|
|
|
}else{ |
|
|
// }else{
|
|
|
auroraTrendsStatsTotal.setAlertCancel(0L); |
|
|
// auroraTrendsStatsTotal.setAlertCancel(0L);
|
|
|
} |
|
|
// }
|
|
|
if (resultDTO.getBuildingIdCount() != null){ |
|
|
// if (resultDTO.getBuildingIdCount() != null){
|
|
|
auroraTrendsStatsTotal.setSenderBuilding(Long.valueOf(resultDTO.getBuildingIdCount())); |
|
|
// auroraTrendsStatsTotal.setSenderBuilding(Long.valueOf(resultDTO.getBuildingIdCount()));
|
|
|
}else{ |
|
|
// }else{
|
|
|
auroraTrendsStatsTotal.setSenderBuilding(0L); |
|
|
// auroraTrendsStatsTotal.setSenderBuilding(0L);
|
|
|
} |
|
|
// }
|
|
|
auroraTrendsStatsTotal.setCreatedDate(Date.from(yesterdayMidnight.toInstant())); |
|
|
// auroraTrendsStatsTotal.setCreatedDate(Date.from(yesterdayMidnight.toInstant()));
|
|
|
this.auroraTrendsStatsTotalMapper.insert(auroraTrendsStatsTotal); |
|
|
// this.auroraTrendsStatsTotalMapper.insert(auroraTrendsStatsTotal);
|
|
|
} |
|
|
// }
|
|
|
DataSourceContextHolder.clearCurrentDataSourceKey(); |
|
|
// DataSourceContextHolder.clearCurrentDataSourceKey();
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
//
|
|
|
MDC.clear(); |
|
|
// MDC.clear();
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|