Browse Source

Merge branch 'zhc' into jwy

jwy
review512jwy@163.com 1 month ago
parent
commit
3773842426
  1. 10
      data-center-business-controller/buildPush-staging.sh
  2. 6
      data-center-business-controller/src/main/resources/db/migration/V68__ba_status_history.sql
  3. 126
      data-center-business-service/src/main/java/com/techsor/datacenter/business/service/SyncTrendsStatsService.java

10
data-center-business-controller/buildPush-staging.sh

@ -2,10 +2,10 @@
# 注意ThenaQuery中 350行左右的【测试】和【正式】是否正确 # 注意ThenaQuery中 350行左右的【测试】和【正式】是否正确
# 注意CommonOpt中的S3注释是否开启(测试时注释掉以避免网络问题) # 注意CommonOpt中的S3注释是否开启(测试时注释掉以避免网络问题)
aws configure set aws_access_key_id AKIAQNYBBSGDVT3VF4ON aws configure set aws_access_key_id AKIAVSKFRQDPNWHJDSHL
aws configure set aws_secret_access_key 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 aws configure set aws_secret_access_key DqGyOiVFKI50/Ix+cjvj25vPL2tC7NJrJ7fqzn/g
aws configure set default.region ap-northeast-1 aws configure set default.region ap-northeast-1
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 029530100103.dkr.ecr.ap-northeast-1.amazonaws.com aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 382934810846.dkr.ecr.ap-northeast-1.amazonaws.com
docker build -t 029530100103.dkr.ecr.ap-northeast-1.amazonaws.com/aeon/spf-business-stg:latest --build-arg JAR_FILE=target/data-center-business-controller-0.0.1-SNAPSHOT.jar --build-arg LIB_DIR=target/lib --build-arg CONFIG_DIR=target/config . docker build -t 382934810846.dkr.ecr.ap-northeast-1.amazonaws.com/aeon/spf-business-stg:latest --build-arg JAR_FILE=target/data-center-business-controller-0.0.1-SNAPSHOT.jar --build-arg LIB_DIR=target/lib --build-arg CONFIG_DIR=target/config .
docker push 029530100103.dkr.ecr.ap-northeast-1.amazonaws.com/aeon/spf-business-stg:latest docker push 382934810846.dkr.ecr.ap-northeast-1.amazonaws.com/aeon/spf-business-stg:latest

6
data-center-business-controller/src/main/resources/db/migration/V68__ba_status_history.sql

@ -0,0 +1,6 @@
CREATE TABLE `ba_status_history` (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`device_info_id` INT NOT NULL,
`is_running` INT NULL,
`update_ts` VARCHAR(45) NULL,
PRIMARY KEY (`id`));

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("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();
} }
/** /**

Loading…
Cancel
Save