전투이벤트 중지 항목도 종료일자 지나면 상태종료 변경

종료된지 한달이상된 전투이벤트,이벤트우편 dynamodb 정보 삭제
전투이벤트 id 운영툴 기준으로 변경
This commit is contained in:
2025-06-18 14:38:43 +09:00
parent 1784c750f3
commit 4de51b663d
18 changed files with 208 additions and 16 deletions

View File

@@ -61,7 +61,8 @@ public enum HISTORYTYPEDETAIL {
NICKNAME_REGISTRY_DELETE("닉네임 레지스트리 삭제"),
NICKNAME_REGISTRY_ADD("닉네임 레지스트리 등록"),
NICKNAME_UPDATE("닉네임 수정"),
DATA_INIT_ADD("데이터 초기화 등록")
DATA_INIT_ADD("데이터 초기화 등록"),
SYSTEM_META_MAIL_DELETE("시스템 메타 메일 삭제"),
;
private String historyTypeDetail;
HISTORYTYPEDETAIL(String type) {

View File

@@ -156,13 +156,14 @@ public class BattleEventService {
.build();
}
int next_event_id = dynamodbBattleEventService.getEventId() + 1;
battleEventRequest.setEventId(next_event_id);
// int next_event_id = dynamodbBattleEventService.getEventId() + 1;
// battleEventRequest.setEventId(next_event_id);
int result = battleMapper.postBattleEvent(battleEventRequest);
log.info("AdminToolDB BattleEvent Save: {}", battleEventRequest);
long battle_event_id = battleEventRequest.getId();
battleEventRequest.setEventId((int) battle_event_id);
HashMap<String,String> map = new HashMap<>();
map.put("id",String.valueOf(battle_event_id));

View File

@@ -1,11 +1,15 @@
package com.caliverse.admin.dynamodb.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SystemMessage {
@JsonProperty("LanguageType")
private Integer languageType;

View File

@@ -3,11 +3,12 @@ package com.caliverse.admin.dynamodb.repository;
import com.caliverse.admin.domain.entity.BattleEvent;
import com.caliverse.admin.domain.request.BattleEventRequest;
import com.caliverse.admin.dynamodb.domain.doc.BattleEventDoc;
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
public interface BattleEventRepository extends DynamoDBRepository<BattleEventDoc> {
int findEventId();
void insert(BattleEventRequest battleEventRequest);
void update(BattleEventRequest battleEventRequest);
void delete(BattleEventRequest battleEventRequest);
DynamodbOperationResult delete(String id);
void updateStop(BattleEvent battleEvent);
}

View File

@@ -5,6 +5,8 @@ import com.caliverse.admin.domain.entity.HISTORYTYPEDETAIL;
import com.caliverse.admin.domain.request.BattleEventRequest;
import com.caliverse.admin.dynamodb.domain.atrrib.BattleEventAttrib;
import com.caliverse.admin.dynamodb.domain.doc.BattleEventDoc;
import com.caliverse.admin.dynamodb.domain.doc.SystemMetaMailDoc;
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
import com.caliverse.admin.dynamodb.entity.EDayOfWeekType;
import com.caliverse.admin.dynamodb.entity.EOncePeriodRangeType;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
@@ -172,8 +174,37 @@ public class BattleEventRepositoryImpl extends BaseDynamoDBRepository<BattleEven
}
@Override
public void delete(BattleEventRequest battleEventRequest) {
return;
public DynamodbOperationResult delete(String id) {
try{
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
.sortValue(id)
.build();
BattleEventDoc doc = findById(key);
if(doc != null) {
Key detailKey = Key.builder()
.partitionValue(doc.getPK())
.sortValue(doc.getSK())
.build();
delete(detailKey);
log.info("BattleEventDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
dynamodbHistoryLogService.deleteHistoryLog(
HISTORYTYPEDETAIL.BATTLE_EVENT_DELETE,
HISTORYTYPEDETAIL.BATTLE_EVENT_DELETE.name(),
doc
);
return new DynamodbOperationResult(true, "", doc);
}
return new DynamodbOperationResult(true, "null", doc);
}catch (Exception e){
log.error("delete BattleEventDoc Error: {}", e.getMessage());
return new DynamodbOperationResult(false, e.getMessage(), null);
}
}
@Override

View File

@@ -44,8 +44,6 @@ public class LandAuctionRegistryRepositoryImpl extends BaseDynamoDBRepository<La
LandAuctionRegistryDoc latestDoc = docs.stream().min((doc1, doc2) -> doc2.getSK().compareTo(doc1.getSK()))
.orElse(null);
if(latestDoc == null) return 0;
LandAuctionRegistryAttrib attrib = latestDoc.getAttribValue();
return attrib.getAuctionNumber();

View File

@@ -4,7 +4,9 @@ import com.caliverse.admin.domain.entity.Event;
import com.caliverse.admin.domain.entity.HISTORYTYPEDETAIL;
import com.caliverse.admin.domain.entity.Message;
import com.caliverse.admin.dynamodb.domain.atrrib.SystemMetaMailAttrib;
import com.caliverse.admin.dynamodb.domain.doc.LandAuctionRegistryDoc;
import com.caliverse.admin.dynamodb.domain.doc.SystemMetaMailDoc;
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
import com.caliverse.admin.dynamodb.repository.BaseDynamoDBRepository;
import com.caliverse.admin.dynamodb.repository.SystemMetaMailRepository;
import com.caliverse.admin.dynamodb.service.DynamoDBOperations;
@@ -17,6 +19,7 @@ import com.caliverse.admin.mongodb.service.DynamodbHistoryLogService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import software.amazon.awssdk.enhanced.dynamodb.Key;
import java.time.LocalDateTime;
@@ -69,4 +72,38 @@ public class SystemMetaMailRepositoryImpl extends BaseDynamoDBRepository<SystemM
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.DYNAMODB_CONNECTION_ERROR.getMessage());
}
}
@Override
public DynamodbOperationResult delete(String id) {
try{
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_SYSTEM_MAIL)
.sortValue(id)
.build();
SystemMetaMailDoc doc = findById(key);
if(doc != null) {
Key detailKey = Key.builder()
.partitionValue(doc.getPK())
.sortValue(doc.getSK())
.build();
delete(detailKey);
log.info("SystemMetaMailDoc Delete Success: {}", objectMapper.writeValueAsString(doc));
dynamodbHistoryLogService.deleteHistoryLog(
HISTORYTYPEDETAIL.SYSTEM_META_MAIL_DELETE,
HISTORYTYPEDETAIL.SYSTEM_META_MAIL_DELETE.name(),
doc
);
return new DynamodbOperationResult(true, "", doc);
}
return new DynamodbOperationResult(true, "null", doc);
}catch (Exception e){
log.error("oldMetaMailClear SystemMetaMailDoc Error: {}", e.getMessage());
return new DynamodbOperationResult(false, e.getMessage(), null);
}
}
}

View File

@@ -4,9 +4,11 @@ import com.caliverse.admin.domain.entity.Event;
import com.caliverse.admin.domain.entity.Item;
import com.caliverse.admin.domain.entity.Message;
import com.caliverse.admin.dynamodb.domain.doc.SystemMetaMailDoc;
import com.caliverse.admin.dynamodb.entity.DynamodbOperationResult;
import java.util.List;
public interface SystemMetaMailRepository extends DynamoDBRepository<SystemMetaMailDoc> {
void insert(Event event);
DynamodbOperationResult delete(String id);
}

View File

@@ -2,11 +2,24 @@ package com.caliverse.admin.dynamodb.service;
import com.caliverse.admin.domain.entity.BattleEvent;
import com.caliverse.admin.domain.request.BattleEventRequest;
import com.caliverse.admin.dynamodb.domain.atrrib.BattleEventAttrib;
import com.caliverse.admin.dynamodb.domain.atrrib.SystemMetaMailAttrib;
import com.caliverse.admin.dynamodb.domain.doc.BattleEventDoc;
import com.caliverse.admin.dynamodb.domain.doc.SystemMetaMailDoc;
import com.caliverse.admin.dynamodb.entity.EOncePeriodRangeType;
import com.caliverse.admin.dynamodb.repository.BattleEventRepository;
import com.caliverse.admin.global.common.annotation.DynamoDBTransaction;
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
import com.caliverse.admin.global.common.utils.CommonUtils;
import com.caliverse.admin.global.common.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import software.amazon.awssdk.enhanced.dynamodb.Key;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
@Service
@RequiredArgsConstructor
@@ -33,4 +46,33 @@ public class DynamodbBattleEventService {
battleEventRepository.updateStop(battleEvent);
}
@DynamoDBTransaction
public void oldBattleEventClear(){
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_BATTLE_EVENT)
.build();
List<BattleEventDoc> eventList = battleEventRepository.findAll(key);
eventList.forEach(event -> {
try {
BattleEventAttrib attrib = CommonUtils.stringByObject(event.getAttribValue(), BattleEventAttrib.class);
EOncePeriodRangeType oncePeriodRangeType = attrib.getOncePeriodType();
LocalDateTime startTime = DateUtils.stringToDateTime(attrib.getStartDay());
LocalDateTime expiredTime = LocalDateTime.now().minusMonths(1);
if (Objects.requireNonNull(oncePeriodRangeType) == EOncePeriodRangeType.NONE) {
if (startTime.isBefore(expiredTime)) {
battleEventRepository.delete(event.getSK());
}
} else {
LocalDateTime endDate = DateUtils.stringToDateTime(attrib.getEndDate());
if (endDate.isBefore(expiredTime)) {
battleEventRepository.delete(event.getSK());
}
}
}catch (Exception e){
log.error("oldSystemMetaMail Clear Fail: {}",e.getMessage());
}
});
}
}

View File

@@ -10,6 +10,7 @@ import com.caliverse.admin.domain.request.LandRequest;
import com.caliverse.admin.dynamodb.domain.atrrib.*;
import com.caliverse.admin.dynamodb.domain.doc.MailDoc;
import com.caliverse.admin.dynamodb.domain.doc.MailJsonDoc;
import com.caliverse.admin.dynamodb.domain.doc.SystemMetaMailDoc;
import com.caliverse.admin.dynamodb.dto.PageResult;
import com.caliverse.admin.dynamodb.entity.KeyParam;
import com.caliverse.admin.dynamodb.repository.*;
@@ -18,6 +19,7 @@ import com.caliverse.admin.global.common.constants.AdminConstants;
import com.caliverse.admin.global.common.constants.CommonConstants;
import com.caliverse.admin.global.common.constants.DynamoDBConstants;
import com.caliverse.admin.global.common.utils.CommonUtils;
import com.caliverse.admin.global.common.utils.DateUtils;
import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
import com.caliverse.admin.logs.logservice.LogServiceHelper;
import com.caliverse.admin.logs.logservice.indicators.IndicatorsMoneyService;
@@ -28,6 +30,7 @@ import org.springframework.stereotype.Service;
import software.amazon.awssdk.enhanced.dynamodb.Key;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -142,4 +145,24 @@ public class DynamodbMailService {
mailRepository.deleteMailItem(key, itemId, count, newCount);
}
}
@DynamoDBTransaction
public void oldSystemMetaMailClear(){
Key key = Key.builder()
.partitionValue(DynamoDBConstants.PK_KEY_SYSTEM_MAIL)
.build();
List<SystemMetaMailDoc> mailList = systemMetaMailRepository.findAll(key);
mailList.forEach(mail -> {
try {
SystemMetaMailAttrib attrib = CommonUtils.stringByObject(mail.getAttribValue(), SystemMetaMailAttrib.class);
LocalDateTime endTime = DateUtils.stringISOToLocalDateTime(attrib.getEndTime());
LocalDateTime expiredTime = LocalDateTime.now().minusMonths(1);
if(endTime.isBefore(expiredTime)){
systemMetaMailRepository.delete(mail.getSK());
}
}catch (Exception e){
log.error("oldSystemMetaMail Clear Fail: {}",e.getMessage());
}
});
}
}

View File

@@ -313,7 +313,7 @@ public class CommonUtils {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(string, valueType);
} catch (JsonProcessingException e) {
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage() + " : " + e.getMessage());
}
}
@@ -322,7 +322,7 @@ public class CommonUtils {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage() + " : " + e.getMessage());
}
}
@@ -331,7 +331,7 @@ public class CommonUtils {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readTree(data);
} catch (JsonProcessingException e) {
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage() + " : " + e.getMessage());
}
}

View File

@@ -32,6 +32,10 @@ public class DateUtils {
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
}
public static LocalDateTime stringToDateTime(String str){
return LocalDateTime.parse(str, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
}
public static LocalDateTime stringToLocalDateTime(String date){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return LocalDateTime.parse(date, formatter);

View File

@@ -104,7 +104,7 @@ public class DynamicScheduler {
map.put("status", change_status);
battleEventService.updateBattleEventStatus(map);
}
}else if(status.equals(BattleEvent.BATTLE_STATUS.RUNNING)){
}else if(status.equals(BattleEvent.BATTLE_STATUS.RUNNING) || status.equals(BattleEvent.BATTLE_STATUS.STOP)){
if(!(!now.isBefore(todayStart) && !now.isAfter(todayEnd))){
if(!baseDate.isBefore(end_dt.toLocalDate())){
change_status = BattleEvent.BATTLE_STATUS.END;

View File

@@ -1,5 +1,6 @@
package com.caliverse.admin.scheduler;
import com.caliverse.admin.domain.service.DiagnosisService;
import com.caliverse.admin.dynamodb.service.DynamodbService;
import com.caliverse.admin.global.common.constants.AdminConstants;
import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
@@ -31,24 +32,36 @@ public class OneTimeSchedule implements CommandLineRunner {
@Autowired private IndicatorsMetaverseServerService metaverseServerService;
@Autowired private IndicatorsUserCreateService userCreateService;
@Autowired private IndicatorsUserLoginService userLoginService;
@Autowired private IndicatorsCurrencyService currencyService;
@Autowired private DiagnosisService diagnosisService;
@Autowired private DynamodbService dynamodbService;
@Override
public void run(String... args) throws Exception {
log.info("=== OneTimeSchedule starting ===");
try{
log.info("Starting OneTimeSchedule");
// dynamodbService.saveUserMoney(); //유저별 재화 데이터 저장
LocalDate startDate = LocalDate.of(2024, 8, 28);
// LocalDate currentDate = LocalDate.of(2025, 1, 31);
// LocalDate startDate = LocalDate.of(2025, 4, 1);
// LocalDate currentDate = LocalDate.of(2025, 5, 1);
LocalDate currentDate = LocalDate.now();
//
log.info("Processing dates from {} to {}", startDate, currentDate);
for (LocalDate date = startDate; !date.isAfter(currentDate); date = date.plusDays(1)) {
log.info("Processing date: {}", date);
StartEndTime dayStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_DAY_NUM);
StartEndTime weekStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_WEEK_NUM);
StartEndTime monthStartEndTime = LogServiceHelper.getCurrentLogSearchEndTime(date, AdminConstants.STAT_MONTH_NUM);
log.info("Date: {}, StartTime: {}, EndTime: {}", date, dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
// currencyService.collectCurrency(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
// userLoginService.collectUserLogin(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
// userCreateService.collectUserCreate(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime());
// metaverseServerService.collectMetaverseServerCount(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime(), 13);
@@ -63,9 +76,9 @@ public class OneTimeSchedule implements CommandLineRunner {
// ugqCreateService.collectUGQCreateCount(dayStartEndTime.getStartTime(), dayStartEndTime.getEndTime()); //체크
}
log.info("=== OneTimeSchedule completed successfully ===");
}catch (Exception e){
log.error(e.getMessage());
log.error("OneTimeSchedule execution failed", e);
}
}
}

View File

@@ -5,6 +5,7 @@ import com.caliverse.admin.logs.Indicatordomain.StartEndTime;
import com.caliverse.admin.logs.logservice.LogServiceHelper;
import com.caliverse.admin.logs.logservice.indicators.*;
import com.caliverse.admin.scheduler.SchedulerManager;
import com.caliverse.admin.scheduler.batch.service.DataClearService;
import com.caliverse.admin.scheduler.batch.service.LogCompressService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -22,6 +23,7 @@ public class ScheduleRunnerBatch {
private final SchedulerManager schedulerManager;
@Autowired private LogCompressService logService;
@Autowired private DataClearService dataClearService;
@Autowired private IndicatorsUserCreateService userCreateService;
@Autowired private IndicatorsUserLoginService userLoginService;
@@ -33,6 +35,12 @@ public class ScheduleRunnerBatch {
logService.compressLastMonthLogs();
}
//오래된 데이터 삭제
@Scheduled(cron = "00 05 00 1 * ?") // 매월 1일에 실행
public void oldDataClear(){
dataClearService.oldDataClear();
}
@Scheduled(cron = "00 30 0 * * *") // 매일 UTC 기준 00시 30분 00초에 실행
public void userCreateScheduler() {
StartEndTime startEndTime = LogServiceHelper.getCurrentLogSearchEndTime(AdminConstants.STAT_DAY_NUM);

View File

@@ -0,0 +1,5 @@
package com.caliverse.admin.scheduler.batch.service;
public interface DataClearService {
void oldDataClear();
}

View File

@@ -0,0 +1,22 @@
package com.caliverse.admin.scheduler.batch.service.impl;
import com.caliverse.admin.dynamodb.service.DynamodbBattleEventService;
import com.caliverse.admin.dynamodb.service.DynamodbMailService;
import com.caliverse.admin.scheduler.batch.service.DataClearService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@AllArgsConstructor
public class DataClearServiceImpl implements DataClearService {
private final DynamodbMailService dynamodbMailService;
private final DynamodbBattleEventService dynamodbBattleEventService;
@Override
public void oldDataClear() {
dynamodbMailService.oldSystemMetaMailClear();
dynamodbBattleEventService.oldBattleEventClear();
}
}

View File

@@ -360,7 +360,7 @@
, config_id
, reward_group_id
FROM battle_event
WHERE (status = 'WAIT' or status = 'RUNNING' or status = 'REGISTER')
WHERE (status = 'WAIT' or status = 'RUNNING' or status = 'REGISTER' or status = 'STOP')
AND deleted = 0
</select>