[FO] 일계부 유효성 일괄 체크
This commit is contained in:
@@ -118,6 +118,13 @@ public class RecordCalendarDao implements RecordCalendarPortOut {
|
||||
return refineList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDataNoneCountBySomeDayAfter(RecordCalendarCmd command) {
|
||||
int dataNoneCount = recordCalendarMapper.getDataNoneCountBySomeDayAfter(command);
|
||||
|
||||
return dataNoneCount != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정월의 일 그룹 조회
|
||||
*
|
||||
|
||||
@@ -33,4 +33,12 @@ public interface RecordCalendarMapper {
|
||||
* @return 월별 작성 상태
|
||||
*/
|
||||
MonthlyStatusDto getMonthlyStatus(RecordCalendarCmd command);
|
||||
|
||||
/**
|
||||
* 3일전 ~ 15일전 미등록된 데이터 개수 조회
|
||||
*
|
||||
* @param command 검색 조건
|
||||
* @return 미등록 건 수
|
||||
*/
|
||||
Integer getDataNoneCountBySomeDayAfter(RecordCalendarCmd command);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package app.module.front.usecase.daily.calendar.adapters.web;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.adapters.web.model.RecordCalendarUIReqVO;
|
||||
import app.module.front.usecase.daily.calendar.ports.RecordCalendarPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/calendar")
|
||||
public class RecordCalendarUIController {
|
||||
private final RecordCalendarPortIn recordCalendarPortIn;
|
||||
|
||||
@GetMapping(path = "")
|
||||
public String index(Model model) {
|
||||
@@ -21,7 +23,7 @@ public class RecordCalendarUIController {
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
|
||||
// TODO : 현재 날짜로부터 3일 이전 날짜에 등록하지 않은 날이 있을 경우
|
||||
model.addAttribute("dataNone", recordCalendarPortIn.getDataNoneCountBySomeDayAfter(reqVO));
|
||||
|
||||
return "record/calendar";
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package app.module.front.usecase.daily.calendar.adapters.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyUIReqVO;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -10,7 +12,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class RecordCalendarUIReqVO extends DailyUIReqVO {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RecordCalendarUIReqVO.class);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.front.usecase.daily.calendar.ports;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.adapters.web.model.RecordCalendarUIReqVO;
|
||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendar;
|
||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendarCmd;
|
||||
|
||||
@@ -7,4 +8,6 @@ import java.util.List;
|
||||
|
||||
public interface RecordCalendarPortIn {
|
||||
List<RecordCalendar> operate(RecordCalendarCmd command);
|
||||
|
||||
boolean getDataNoneCountBySomeDayAfter(RecordCalendarUIReqVO reqVO);
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ import java.util.List;
|
||||
|
||||
public interface RecordCalendarPortOut {
|
||||
List<RecordCalendar> operate(RecordCalendarCmd command);
|
||||
|
||||
boolean getDataNoneCountBySomeDayAfter(RecordCalendarCmd command);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.module.front.usecase.daily.calendar.ports.application;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.adapters.web.model.RecordCalendarUIReqVO;
|
||||
import app.module.front.usecase.daily.calendar.ports.RecordCalendarPortIn;
|
||||
import app.module.front.usecase.daily.calendar.ports.RecordCalendarPortOut;
|
||||
import app.module.front.usecase.daily.calendar.ports.application.domain.RecordCalendar;
|
||||
@@ -18,4 +19,9 @@ public class RecordCalendarService implements RecordCalendarPortIn {
|
||||
public List<RecordCalendar> operate(RecordCalendarCmd command) {
|
||||
return portOut.operate(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDataNoneCountBySomeDayAfter(RecordCalendarUIReqVO reqVO) {
|
||||
return portOut.getDataNoneCountBySomeDayAfter(new RecordCalendarCmd(reqVO.getSearchMonth(), reqVO.getHouseholdSeq(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class DailyExpenseUIController {
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("expenseList", expenseList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.EXPENSE));
|
||||
|
||||
return "record/expense/index";
|
||||
}
|
||||
@@ -110,6 +109,8 @@ public class DailyExpenseUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.EXPENSE);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class DailyFarmingUIController {
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("farmingList", farmingList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.FARMING));
|
||||
|
||||
return "record/farming/index";
|
||||
}
|
||||
@@ -110,6 +109,8 @@ public class DailyFarmingUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.FARMING);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class DailyForestryUIController {
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("forestryList", forestryList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.FORESTRY));
|
||||
|
||||
return "record/forestry/index";
|
||||
}
|
||||
@@ -110,6 +109,8 @@ public class DailyForestryUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.FORESTRY);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class DailyIncomeUIController {
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("incomeList", incomeList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.INCOME));
|
||||
|
||||
return "record/income/index";
|
||||
}
|
||||
@@ -110,6 +109,8 @@ public class DailyIncomeUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.INCOME);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class DailyPowerUIController {
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("powerList", powerList);
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.POWER));
|
||||
|
||||
return "record/power/index";
|
||||
}
|
||||
@@ -105,6 +104,8 @@ public class DailyPowerUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.POWER);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class DailyRecordDao implements DailyRecordPortOut {
|
||||
@Override
|
||||
public DailyRecordDto detail(GetDailyRecordCmd command) {
|
||||
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(command);
|
||||
if (detail != null && !detail.isUpdated()) {
|
||||
if (detail != null && detail.getStartDate() == null) {
|
||||
try {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
@@ -36,6 +36,10 @@ public class DailyRecordDao implements DailyRecordPortOut {
|
||||
formatDate = beforeSdf.parse(command.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
||||
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
|
||||
if (detail.getStartDate().getMonth() != detail.getEndDate().getMonth()) {
|
||||
// 종료일의 달이 변경되면 시작일=종료일 처리
|
||||
detail.setEndDate(detail.getStartDate());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[DateParse] target={}", detail.getStartDay(), e);
|
||||
}
|
||||
|
||||
@@ -4,16 +4,14 @@ import app.module.front.usecase.daily.record.adapters.web.model.DailySort;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.adapters.web.model.DailyTargetStatus;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class DailyRecordDto {
|
||||
// household_seq, record_month, day_group_no, start_date, end_date
|
||||
// , all_status, income_status, work_status, expense_status, power_status, forestry_status
|
||||
// , created_at, created_by, is_deleted
|
||||
|
||||
private String recordMonth;
|
||||
private Integer groupNo;
|
||||
private Integer startDay;
|
||||
@@ -30,14 +28,63 @@ public class DailyRecordDto {
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
|
||||
/**
|
||||
* 마지막 일 여부
|
||||
*/
|
||||
private boolean lastDay;
|
||||
/**
|
||||
* 자가농업 항목 오픈 여부
|
||||
*/
|
||||
private boolean farmingOpen;
|
||||
/**
|
||||
* 특정일의 데이터 등록 대상 항목
|
||||
*/
|
||||
private List<DailySort> targetList;
|
||||
/**
|
||||
* 현재 단계
|
||||
*/
|
||||
private DailySort currentStep;
|
||||
|
||||
public boolean isUpdated() {
|
||||
return this.id != null;
|
||||
/**
|
||||
* 마지막 일 여부
|
||||
* @return true=마지막 일, false=마지막 일 아님
|
||||
*/
|
||||
public boolean isLastDay() {
|
||||
if (endDate != null) {
|
||||
LocalDate lastDate = endDate.withDayOfMonth(endDate.lengthOfMonth());
|
||||
|
||||
return endDate == lastDate;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNextStep(DailySort currentStep) {
|
||||
/**
|
||||
* 자가농업 항목 오픈 여부
|
||||
* [정책] 자가농업 생산물 중 자가소비량은 7일차 등록일에만 노출 및 선택, 21일 이후는 마지막 날
|
||||
* @return true=대상, false=대상 아님
|
||||
*/
|
||||
public boolean isFarmingOpen() {
|
||||
return groupNo == 4 || groupNo == 8 || groupNo == 12 || isLastDay();
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터 수정 가능 여부
|
||||
* [정책] 15일전까지 데이터 수정 가능(등록도 불가)
|
||||
* @return true=수정 가능, false=수정 불가
|
||||
*/
|
||||
public boolean isModifiable() {
|
||||
LocalDate limitStart = LocalDate.now().minusDays(15);
|
||||
|
||||
return (limitStart.isBefore(startDate) || limitStart.isEqual(startDate) || limitStart.isEqual(endDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 다음 단계로 이동될 단계 조회
|
||||
*
|
||||
* @return 다음 단계명
|
||||
*/
|
||||
public String getNextStep() {
|
||||
String returnValue = null;
|
||||
if (targetList != null) {
|
||||
int index = 0;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class DailyRecordService implements DailyRecordPortIn {
|
||||
reqVO.getHouseholdSeq()));
|
||||
|
||||
if (dailyRecord != null) {
|
||||
// TODO : 이전 다음을 체크하기 위함
|
||||
List<DailySort> targetList = new ArrayList<>();
|
||||
if (this.isTarget(dailyRecord.getIncomeStatus())) {
|
||||
targetList.add(DailySort.INCOME);
|
||||
@@ -55,19 +54,15 @@ public class DailyRecordService implements DailyRecordPortIn {
|
||||
dailyRecord.setTargetList(targetList);
|
||||
}
|
||||
|
||||
// TODO : 마지막날 건의사항 모달 팝업 뜨는 것
|
||||
LocalDate lastDate = dailyRecord.getEndDate().withDayOfMonth(dailyRecord.getEndDate().lengthOfMonth());
|
||||
log.debug("lastDate: {}", lastDate);
|
||||
|
||||
if (dailyRecord.getEndDate() == lastDate) {
|
||||
dailyRecord.setLastDay(true);
|
||||
} else {
|
||||
dailyRecord.setLastDay(false);
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터 등록 대상 여부
|
||||
*
|
||||
* @param status 상태
|
||||
* @return true=대상, false=대상 아님
|
||||
*/
|
||||
private boolean isTarget(DailyTargetStatus status) {
|
||||
return DailyTargetStatus.TARGET.equals(status) || DailyTargetStatus.TODAY_NONE.equals(status);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DailyWorkUIController {
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("workList", workList);
|
||||
model.addAttribute("nextStep", dailyRecord.getNextStep(DailySort.WORK));
|
||||
model.addAttribute("moveStep", !"update".equals(searchType));
|
||||
|
||||
return "record/work/index";
|
||||
}
|
||||
@@ -108,6 +108,8 @@ public class DailyWorkUIController {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
dailyRecord.setCurrentStep(DailySort.WORK);
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user