Browse Source

关闭除receiver和sender在redis中的数据量统计以外其他的统计数据,尤其是aurora相关的

zhc
zhczyx@163.com 1 month ago
parent
commit
e8f30d5ff0
  1. 126
      data-center-business-service/src/main/java/com/techsor/datacenter/business/service/SyncTrendsStatsService.java

126
data-center-business-service/src/main/java/com/techsor/datacenter/business/service/SyncTrendsStatsService.java

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

Loading…
Cancel
Save