[CORE] 일계부 enum, util 이동
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package app.module.core.config.application.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum DailySort {
|
||||
INCOME("수입"),
|
||||
WORK("임업노동 투입"),
|
||||
EXPENSE("지출"),
|
||||
POWER("동력 사용시간"),
|
||||
FORESTRY("임업생산물 중 자가소비량"),
|
||||
FARMING("농업생산물 중 자가소비량"),
|
||||
;
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.core.config.application.enums;
|
||||
|
||||
public enum DailyStatus {
|
||||
/**
|
||||
* 미완료
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* 등록 없음
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.core.config.application.enums;
|
||||
|
||||
public enum DailyTargetStatus {
|
||||
/**
|
||||
* 등록 대상 (테이터 건 수 체크)
|
||||
*/
|
||||
TARGET,
|
||||
/**
|
||||
* 금일 없음 (데이터 건 수 체크하지 않음)
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 대상 아님
|
||||
*/
|
||||
NONE,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package app.module.core.config.application.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DailyUtil {
|
||||
|
||||
/**
|
||||
* int -> localdate
|
||||
* @param month 월(yyyyMM)
|
||||
* @param day 일(d)
|
||||
* @return LocalDate
|
||||
*/
|
||||
public LocalDate getDayToLocalDate(String month, int day) {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
|
||||
try {
|
||||
Date formatDate = beforeSdf.parse(month + String.format("%02d", day));
|
||||
|
||||
return LocalDate.parse(afterSdf.format(formatDate));
|
||||
} catch (Exception e) {
|
||||
log.warn("[DailyUtil][getDayToLocalDate] month={}, day={}", month, day, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 마지막 일 여부
|
||||
*
|
||||
* @param searchDate 종료일(yyyy-MM-dd)
|
||||
* @return true=마지막 일, false=마지막 일 아님
|
||||
*/
|
||||
public boolean isLastDay(LocalDate searchDate) {
|
||||
if (searchDate != null) {
|
||||
LocalDate lastDate = searchDate.withDayOfMonth(searchDate.lengthOfMonth());
|
||||
|
||||
return searchDate == lastDate;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 마지막 일 조회
|
||||
*
|
||||
* @param searchDate 검색일
|
||||
* @return 마지막 일
|
||||
*/
|
||||
public int getLastDay(LocalDate searchDate) {
|
||||
if (searchDate != null) {
|
||||
return searchDate.withDayOfMonth(searchDate.lengthOfMonth()).getDayOfMonth();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 자가농업 항목 오픈 여부
|
||||
* [정책] 자가농업 생산물 중 자가소비량은 7일차 등록일에만 노출 및 선택, 21일 이후는 마지막 날
|
||||
*
|
||||
* @param groupNo 그룹번호
|
||||
* @param endDate 종료일
|
||||
* @return true=대상, false=대상 아님
|
||||
*/
|
||||
public boolean isFarmingOpen(int groupNo, LocalDate endDate) {
|
||||
return groupNo == 4 || groupNo == 8 || groupNo == 12 || isLastDay(endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터 수정 가능 여부
|
||||
* [정책] 15일전까지 데이터 수정 가능(등록도 불가)
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return true=수정 가능, false=수정 불가
|
||||
*/
|
||||
public boolean isModifiable(LocalDate startDate, LocalDate endDate) {
|
||||
// TODO : 15일로 변경, 테스트를 위해 30일로 진행중
|
||||
LocalDate limitStart = LocalDate.now().minusDays(30);
|
||||
log.debug("isModifiable @@limitStart: {}, startDate: {}, endDate: {}", limitStart, startDate, endDate);
|
||||
|
||||
return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate) || limitStart.isEqual(endDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터 등록 가능 여부
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public boolean isRegisterPossible(LocalDate startDate, LocalDate endDate) {
|
||||
// TODO : 15일로 변경, 테스트를 위해 60일로 진행중
|
||||
LocalDate limitStart = LocalDate.now().minusDays(60);
|
||||
log.debug("isRegisterPossible @@limitStart: {}, startDate: {}, endDate: {}", limitStart, startDate, endDate);
|
||||
|
||||
return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user