데이터 초기화 스케줄 처리 추가
This commit is contained in:
@@ -8,5 +8,6 @@ public enum SchedulerType {
|
||||
LAND_AUCTION,
|
||||
BATTLE_EVENT,
|
||||
WEB3,
|
||||
LAND_OWNER_CHANGES
|
||||
LAND_OWNER_CHANGES,
|
||||
DATA_INITIALIZE
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.caliverse.admin.scheduler.polling;
|
||||
|
||||
import com.caliverse.admin.domain.response.DataResponse;
|
||||
import com.caliverse.admin.global.common.code.CommonCode;
|
||||
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||
import com.caliverse.admin.scheduler.SchedulerManager;
|
||||
import com.caliverse.admin.scheduler.entity.SchedulerType;
|
||||
import com.caliverse.admin.domain.RabbitMq.MessageHandlerService;
|
||||
@@ -13,6 +16,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.batch.core.JobParameters;
|
||||
// import org.springframework.batch.core.JobParametersBuilder;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -46,12 +52,22 @@ public class ScheduleRunnerPolling {
|
||||
private ExcelUtils excelUtils;
|
||||
|
||||
private final SchedulerManager schedulerManager;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfile;
|
||||
|
||||
@Scheduled(cron = "7 * * * * *")
|
||||
public void landOwnerChangesJob(){
|
||||
schedulerManager.executeScheduler(SchedulerType.LAND_OWNER_CHANGES);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "1 * * * * *")
|
||||
public void dataInitializeJob(){
|
||||
if(activeProfile.equals("live")){
|
||||
return;
|
||||
}
|
||||
schedulerManager.executeScheduler(SchedulerType.DATA_INITIALIZE);
|
||||
}
|
||||
|
||||
/*
|
||||
매일 UTC 기준 00시 50분 00초에 실행, (한국 시간 9시 50분) 30분에 돌릴경우 데이터가 다 넘어 오지 않는 경우 있어서 수정처리
|
||||
이게 가장 먼저 실행 되어야 한다.
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.caliverse.admin.scheduler.polling.service;
|
||||
|
||||
import com.caliverse.admin.domain.entity.DataInit;
|
||||
import com.caliverse.admin.domain.entity.EInitDataType;
|
||||
import com.caliverse.admin.domain.entity.LandAuction;
|
||||
import com.caliverse.admin.domain.entity.LandOwnerChange;
|
||||
import com.caliverse.admin.domain.request.LandRequest;
|
||||
import com.caliverse.admin.domain.service.DataService;
|
||||
import com.caliverse.admin.domain.service.LandService;
|
||||
import com.caliverse.admin.domain.service.UserGameSessionService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbDataService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbLandAuctionService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbLandService;
|
||||
import com.caliverse.admin.dynamodb.service.DynamodbService;
|
||||
import com.caliverse.admin.scheduler.CommonScheduler;
|
||||
import com.caliverse.admin.scheduler.entity.SchedulerType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DataInitializeScheduler extends CommonScheduler {
|
||||
|
||||
private final DataService dataService;
|
||||
private final DynamodbDataService dynamodbDataService;
|
||||
private final LandService landService;
|
||||
private final DynamodbLandAuctionService dynamodbLandAuctionService;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfile;
|
||||
|
||||
public DataInitializeScheduler(DataService dataService, DynamodbDataService dynamodbDataService, LandService landService, DynamodbLandAuctionService dynamodbLandAuctionService) {
|
||||
this.dataService = dataService;
|
||||
this.dynamodbDataService = dynamodbDataService;
|
||||
this.landService = landService;
|
||||
this.dynamodbLandAuctionService = dynamodbLandAuctionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal() {
|
||||
List<DataInit> scheduleList = dataService.getScheduleDataInitList();
|
||||
|
||||
scheduleList.forEach(dataInit -> {
|
||||
EInitDataType dataType = dataInit.getDataType();
|
||||
dataService.updateStatus(dataInit.getId(), DataInit.DATA_INIT_STATUS.RUNNING);
|
||||
switch (dataType) {
|
||||
case LandAuction -> initLandAuction(dataInit.getCreateDt());
|
||||
case LandOwned -> initLandOwner(dataInit.getCreateDt());
|
||||
case LandDesc -> initLandDesc();
|
||||
}
|
||||
dataService.updateStatus(dataInit.getId(), DataInit.DATA_INIT_STATUS.FINISH);
|
||||
});
|
||||
}
|
||||
|
||||
private void initLandAuction(LocalDateTime createDt){
|
||||
List<LandAuction> landAuctions = landService.getAllLandAuctionList();
|
||||
landAuctions.forEach(landAuction -> {
|
||||
dataService.initLandAuction(landAuction);
|
||||
dynamodbLandAuctionService.initLandAuction(landAuction.getLandId(), landAuction.getAuctionSeq(), landAuction.getBidderGuid());
|
||||
});
|
||||
//치트로 있는 데이터 삭제
|
||||
dynamodbDataService.InitDataLandAuction();
|
||||
}
|
||||
|
||||
private void initLandDesc(){
|
||||
dynamodbDataService.InitDataLandDesc();
|
||||
}
|
||||
|
||||
private void initLandOwner(LocalDateTime createDt){
|
||||
List<LandOwnerChange> landOwnerChanges = landService.getAllLandOwnerChangesList();
|
||||
landOwnerChanges.forEach(dataService::initLandOwned);
|
||||
dynamodbDataService.InitDataLandOwned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerType getSchedulerType() {
|
||||
return SchedulerType.DATA_INITIALIZE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user