diff --git a/src/main/java/com/kamco/cd/kamcoback/config/api/ApiResponseAdvice.java b/src/main/java/com/kamco/cd/kamcoback/config/api/ApiResponseAdvice.java index d3d959f5..72cb50bc 100644 --- a/src/main/java/com/kamco/cd/kamcoback/config/api/ApiResponseAdvice.java +++ b/src/main/java/com/kamco/cd/kamcoback/config/api/ApiResponseAdvice.java @@ -34,8 +34,7 @@ public class ApiResponseAdvice implements ResponseBodyAdvice { private final AuditLogRepository auditLogRepository; private final MenuService menuService; - @Autowired - private ObjectMapper objectMapper; + @Autowired private ObjectMapper objectMapper; public ApiResponseAdvice(AuditLogRepository auditLogRepository, MenuService menuService) { this.auditLogRepository = auditLogRepository; @@ -44,19 +43,19 @@ public class ApiResponseAdvice implements ResponseBodyAdvice { @Override public boolean supports( - MethodParameter returnType, Class> converterType) { + MethodParameter returnType, Class> converterType) { // ApiResponseDto를 반환하는 경우에만 적용 return returnType.getParameterType().equals(ApiResponseDto.class); } @Override public Object beforeBodyWrite( - Object body, - MethodParameter returnType, - MediaType selectedContentType, - Class> selectedConverterType, - ServerHttpRequest request, - ServerHttpResponse response) { + Object body, + MethodParameter returnType, + MediaType selectedContentType, + Class> selectedConverterType, + ServerHttpRequest request, + ServerHttpResponse response) { HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest(); ContentCachingRequestWrapper contentWrapper = null; @@ -71,7 +70,7 @@ public class ApiResponseAdvice implements ResponseBodyAdvice { Long userid = null; if (servletRequest.getUserPrincipal() instanceof UsernamePasswordAuthenticationToken auth - && auth.getPrincipal() instanceof CustomUserDetails customUserDetails) { + && auth.getPrincipal() instanceof CustomUserDetails customUserDetails) { userid = customUserDetails.getMember().getId(); } @@ -92,29 +91,29 @@ public class ApiResponseAdvice implements ResponseBodyAdvice { List list = menuService.getFindAll(); List result = - list.stream() - .map( - item -> { - if (item instanceof LinkedHashMap map) { - return objectMapper.convertValue(map, MenuDto.Basic.class); - } else if (item instanceof MenuDto.Basic dto) { - return dto; - } else { - throw new IllegalStateException("Unsupported cache type: " + item.getClass()); - } - }) - .toList(); + list.stream() + .map( + item -> { + if (item instanceof LinkedHashMap map) { + return objectMapper.convertValue(map, MenuDto.Basic.class); + } else if (item instanceof MenuDto.Basic dto) { + return dto; + } else { + throw new IllegalStateException("Unsupported cache type: " + item.getClass()); + } + }) + .toList(); AuditLogEntity log = - new AuditLogEntity( - userid, - ApiLogFunction.getEventType(servletRequest), - ApiLogFunction.isSuccessFail(apiResponse), - ApiLogFunction.getUriMenuInfo(result, servletRequest.getRequestURI()), - ip, - servletRequest.getRequestURI(), - ApiLogFunction.cutRequestBody(requestBody), - apiResponse.getErrorLogUid()); + new AuditLogEntity( + userid, + ApiLogFunction.getEventType(servletRequest), + ApiLogFunction.isSuccessFail(apiResponse), + ApiLogFunction.getUriMenuInfo(result, servletRequest.getRequestURI()), + ip, + servletRequest.getRequestURI(), + ApiLogFunction.cutRequestBody(requestBody), + apiResponse.getErrorLogUid()); auditLogRepository.save(log); } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngFileJobCoreService.java b/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngFileJobCoreService.java index 8832f207..c9ffa316 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngFileJobCoreService.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/core/MapSheetMngFileJobCoreService.java @@ -52,18 +52,15 @@ public class MapSheetMngFileJobCoreService { return new MapSheetMngDto.DmlReturn("success", saved.getFileUid().toString()); } - public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy){ + public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) { return mapSheetMngFileJobRepository.findByMngYyyyTargetMapSheetNotYetCount(mngYyyy); } - public void mngDataState(int mngYyyy, String mngState) - { + public void mngDataState(int mngYyyy, String mngState) { mapSheetMngFileJobRepository.mngDataState(mngYyyy, mngState); } - public Integer findNotYetMapSheetMng() - { + public Integer findNotYetMapSheetMng() { return mapSheetMngFileJobRepository.findNotYetMapSheetMng(); } - } diff --git a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/scheduler/MapSheetMngFileJobRepositoryImpl.java b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/scheduler/MapSheetMngFileJobRepositoryImpl.java index e109e2cb..bb96a4ac 100644 --- a/src/main/java/com/kamco/cd/kamcoback/postgres/repository/scheduler/MapSheetMngFileJobRepositoryImpl.java +++ b/src/main/java/com/kamco/cd/kamcoback/postgres/repository/scheduler/MapSheetMngFileJobRepositoryImpl.java @@ -35,15 +35,18 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport } @Override - public Integer findNotYetMapSheetMng(){ + public Integer findNotYetMapSheetMng() { Integer countQuery = - queryFactory - .select(mapSheetMngEntity.mngYyyy) - .from(mapSheetMngEntity) - .where(mapSheetMngEntity.mngState.eq("NOTYET") - .or(mapSheetMngEntity.mngState.eq("PROCESSING"))) - .limit(1) - .fetchOne(); + queryFactory + .select(mapSheetMngEntity.mngYyyy) + .from(mapSheetMngEntity) + .where( + mapSheetMngEntity + .mngState + .eq("NOTYET") + .or(mapSheetMngEntity.mngState.eq("PROCESSING"))) + .limit(1) + .fetchOne(); return countQuery; } @@ -121,27 +124,30 @@ public class MapSheetMngFileJobRepositoryImpl extends QuerydslRepositorySupport } @Override - public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy){ + public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) { Long countQuery = - queryFactory - .select(mapSheetMngHstEntity.mngYyyy.count()) - .from(mapSheetMngHstEntity) - .where(mapSheetMngHstEntity.mngYyyy.eq(mngYyyy) - .and(mapSheetMngHstEntity.syncState.eq("NOTYET"))) - .fetchOne(); + queryFactory + .select(mapSheetMngHstEntity.mngYyyy.count()) + .from(mapSheetMngHstEntity) + .where( + mapSheetMngHstEntity + .mngYyyy + .eq(mngYyyy) + .and(mapSheetMngHstEntity.syncState.eq("NOTYET"))) + .fetchOne(); return countQuery; } - public void mngDataState(int mngYyyy, String mngState){ + public void mngDataState(int mngYyyy, String mngState) { long updateCount = - queryFactory - .update(mapSheetMngEntity) - .set(mapSheetMngEntity.mngState, mngState) - .set(mapSheetMngEntity.syncState, mngState) - .set(mapSheetMngEntity.syncCheckState, mngState) - .where(mapSheetMngEntity.mngYyyy.eq(mngYyyy)) - .execute(); + queryFactory + .update(mapSheetMngEntity) + .set(mapSheetMngEntity.mngState, mngState) + .set(mapSheetMngEntity.syncState, mngState) + .set(mapSheetMngEntity.syncCheckState, mngState) + .where(mapSheetMngEntity.mngYyyy.eq(mngYyyy)) + .execute(); } public void mngHstDataSyncStateUpdate(MapSheetMngDto.MngHstDto updateReq) { diff --git a/src/main/java/com/kamco/cd/kamcoback/scheduler/MapSheetMngFileJobController.java b/src/main/java/com/kamco/cd/kamcoback/scheduler/MapSheetMngFileJobController.java index 99cb09a0..e2360b88 100644 --- a/src/main/java/com/kamco/cd/kamcoback/scheduler/MapSheetMngFileJobController.java +++ b/src/main/java/com/kamco/cd/kamcoback/scheduler/MapSheetMngFileJobController.java @@ -23,21 +23,25 @@ public class MapSheetMngFileJobController { if (!isSchedulerEnabled) return; Integer mng = 0; - // isFileSyncSchedulerEnabled = false; - if(mapSheetMngFileJobService.checkMngFileSync() != null) - { + // isFileSyncSchedulerEnabled = false; + if (mapSheetMngFileJobService.checkMngFileSync() != null) { mng = mapSheetMngFileJobService.checkMngFileSync(); this.isFileSyncSchedulerEnabled = true; - System.out.println("MngFileSyncJob ON --> mngYyyy : "+ mng + ", currentTime : " + System.currentTimeMillis()); - } - else{ + System.out.println( + "MngFileSyncJob ON --> mngYyyy : " + + mng + + ", currentTime : " + + System.currentTimeMillis()); + } else { this.isFileSyncSchedulerEnabled = false; - System.out.println("MngFileSyncJob OFF --> mngYyyy : "+ mng + ", currentTime : " + System.currentTimeMillis()); + System.out.println( + "MngFileSyncJob OFF --> mngYyyy : " + + mng + + ", currentTime : " + + System.currentTimeMillis()); } - } - @Scheduled(fixedDelay = 1000 * 5) public void mngFileSyncJob00() { if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return; @@ -54,7 +58,6 @@ public class MapSheetMngFileJobController { mapSheetMngFileJobService.checkMapSheetFileProcess(1, mngSyncPageSize); } - @Scheduled(fixedDelay = 1000 * 5) public void mngFileSyncJob02() { if (!isSchedulerEnabled || !isFileSyncSchedulerEnabled) return; @@ -119,8 +122,6 @@ public class MapSheetMngFileJobController { mapSheetMngFileJobService.checkMapSheetFileProcess(9, mngSyncPageSize); } - - // 3. 외부에서 플래그를 변경할 수 있는 Setter 메서드 public void setSchedulerEnabled(boolean enabled) { this.isSchedulerEnabled = enabled; diff --git a/src/main/java/com/kamco/cd/kamcoback/scheduler/service/MapSheetMngFileJobService.java b/src/main/java/com/kamco/cd/kamcoback/scheduler/service/MapSheetMngFileJobService.java index 2bf20cf9..72a7e961 100644 --- a/src/main/java/com/kamco/cd/kamcoback/scheduler/service/MapSheetMngFileJobService.java +++ b/src/main/java/com/kamco/cd/kamcoback/scheduler/service/MapSheetMngFileJobService.java @@ -45,9 +45,7 @@ public class MapSheetMngFileJobService { @Value("${file.sync-file-extention}") private String syncFileExtention; - - public Integer checkMngFileSync() - { + public Integer checkMngFileSync() { return mapSheetMngFileJobCoreService.findNotYetMapSheetMng(); } @@ -66,7 +64,7 @@ public class MapSheetMngFileJobService { SrchFilesDepthDto srchDto = new SrchFilesDepthDto(); List basicList = new ArrayList<>(); - if( mapSheetFileNotYetList.size() >= 1 ){ + if (mapSheetFileNotYetList.size() >= 1) { mngYyyy = mapSheetFileNotYetList.get(0).getMngYyyy(); } @@ -124,9 +122,9 @@ public class MapSheetMngFileJobService { if (tfwCnt == 0 && tifCnt == 0) syncState = "NOFILE"; for (FIleChecker.Basic item2 : basicList) { - //System.out.println("path: " + item2.getParentPath()); - //System.out.println("path: " + item2.getFileNm()); - //System.out.println("path: " + item2.getFullPath()); + // System.out.println("path: " + item2.getParentPath()); + // System.out.println("path: " + item2.getFileNm()); + // System.out.println("path: " + item2.getFullPath()); MapSheetMngDto.MngFileAddReq addReq = new MapSheetMngDto.MngFileAddReq(); addReq.setMngYyyy(item.getMngYyyy()); @@ -178,11 +176,9 @@ public class MapSheetMngFileJobService { if (syncState.isEmpty()) syncState = "DONE"; item.setSyncState(syncState); mngHstDataSyncStateUpdate(item); - } Long notyetCnt = this.mngDataStateDoneUpdate(mngYyyy); - } public int checkIsNoFile(List basicList) { @@ -196,16 +192,12 @@ public class MapSheetMngFileJobService { public Long mngDataStateDoneUpdate(int mngYyyy) { Long notyetCnt = 0L; - if( mngYyyy > 0 ) - { + if (mngYyyy > 0) { notyetCnt = findByMngYyyyTargetMapSheetNotYetCount(mngYyyy); - if( notyetCnt == 0 ) - { - mapSheetMngFileJobCoreService.mngDataState(mngYyyy,"DONE"); - } - else - { - mapSheetMngFileJobCoreService.mngDataState(mngYyyy,"PROCESSING"); + if (notyetCnt == 0) { + mapSheetMngFileJobCoreService.mngDataState(mngYyyy, "DONE"); + } else { + mapSheetMngFileJobCoreService.mngDataState(mngYyyy, "PROCESSING"); } } @@ -216,7 +208,6 @@ public class MapSheetMngFileJobService { return mapSheetMngFileJobCoreService.findTargetMapSheetFileList(targetNum, pageSize); } - public Long findByMngYyyyTargetMapSheetNotYetCount(int mngYyyy) { return mapSheetMngFileJobCoreService.findByMngYyyyTargetMapSheetNotYetCount(mngYyyy); }