Merge branch 'kangsun' into 'dev'

[BO] 임가현황 리스트, 상세 작업 중 (4)

See merge request korea-research/korea-research!8
This commit is contained in:
이강선 매니저/ST
2025-06-14 11:51:48 +00:00
28 changed files with 1369 additions and 316 deletions

View File

@@ -0,0 +1,30 @@
package app.module.admin.usecase.household.getDailyRecordStatus.adapters.persistence;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyExpenseRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyForestryRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyIncomeRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyPowerRecords;
import java.util.List;
import lombok.RequiredArgsConstructor;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatus;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.GetDailyRecordStatusPortOut;
import java.util.Optional;
import org.springframework.stereotype.Repository;
@Repository
@RequiredArgsConstructor
class GetDailyRecordStatusDao implements GetDailyRecordStatusPortOut {
private final GetDailyRecordStatusMapper mapper;
@Override
public Optional<GetDailyRecordStatus> operate(GetDailyRecordStatusCmd cmd) {
List<GetDailyIncomeRecords> incomes = mapper.getDailyIncomeRecords(cmd);
List<GetDailyExpenseRecords> expenses = mapper.getDailyExpenseRecords(cmd);
List<GetDailyPowerRecords> powers = mapper.getDailyPowerRecords(cmd);
List<GetDailyForestryRecords> forestries = mapper.getDailyForestryRecords(cmd);
return Optional.of(new GetDailyRecordStatus(incomes, expenses, powers, forestries));
}
}

View File

@@ -0,0 +1,17 @@
package app.module.admin.usecase.household.getDailyRecordStatus.adapters.persistence;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyExpenseRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyForestryRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyIncomeRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyPowerRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GetDailyRecordStatusMapper {
List<GetDailyIncomeRecords> getDailyIncomeRecords(GetDailyRecordStatusCmd cmd);
List<GetDailyExpenseRecords> getDailyExpenseRecords(GetDailyRecordStatusCmd cmd);
List<GetDailyPowerRecords> getDailyPowerRecords(GetDailyRecordStatusCmd cmd);
List<GetDailyForestryRecords> getDailyForestryRecords(GetDailyRecordStatusCmd cmd);
}

View File

@@ -0,0 +1,28 @@
package app.module.admin.usecase.household.getDailyRecordStatus.adapters.web;
import app.module.admin.usecase.household.getDailyRecordStatus.adapters.web.model.GetDailyRecordStatusReqVO;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.GetDailyRecordStatusPortIn;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatus;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
class GetDailyRecordStatusController {
private final GetDailyRecordStatusPortIn portIn;
@GetMapping(path = "/api/household/dailyRecordStatus")
ResponseEntity<GetDailyRecordStatus> operate(
GetDailyRecordStatusReqVO reqVO) {
GetDailyRecordStatus recordView =
portIn.operate(new GetDailyRecordStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordSeq(),
reqVO.getRecordMonth())).orElse(null);
return ResponseEntity.status(HttpStatus.OK).body(recordView);
}
}

View File

@@ -0,0 +1,16 @@
package app.module.admin.usecase.household.getDailyRecordStatus.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordStatusReqVO {
private Long householdSeq;
private Long recordSeq;
private String recordMonth;
}

View File

@@ -0,0 +1,18 @@
package app.module.admin.usecase.household.getDailyRecordStatus.adapters.web.model;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyExpenseRecords;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyIncomeRecords;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordStatusResVO {
List<GetDailyIncomeRecords> incomes; // 수입
List<GetDailyExpenseRecords> expenses; // 지출
}

View File

@@ -0,0 +1,9 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports;
import java.util.Optional;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatus;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
public interface GetDailyRecordStatusPortIn {
Optional<GetDailyRecordStatus> operate(GetDailyRecordStatusCmd cmd);
}

View File

@@ -0,0 +1,9 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports;
import java.util.Optional;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatus;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
public interface GetDailyRecordStatusPortOut {
Optional<GetDailyRecordStatus> operate(GetDailyRecordStatusCmd cmd);
}

View File

@@ -0,0 +1,20 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application;
import lombok.RequiredArgsConstructor;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatus;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyRecordStatusCmd;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.GetDailyRecordStatusPortIn;
import app.module.admin.usecase.household.getDailyRecordStatus.ports.GetDailyRecordStatusPortOut;
import java.util.Optional;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class GetDailyRecordStatusService implements GetDailyRecordStatusPortIn {
private final GetDailyRecordStatusPortOut portOut;
@Override
public Optional<GetDailyRecordStatus> operate(GetDailyRecordStatusCmd cmd) {
return portOut.operate(cmd);
}
}

View File

@@ -0,0 +1,26 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyExpenseRecords {
private Long id;
private String inputType;
private Boolean isCredit;
private String categoryCode;
private String categorySelf;
private String sourcePurpose;
private BigDecimal quantity;
private String unitCode;
private String price;
private String estimatedValue;
private String updatedBy;
private String updatedAt;
}

View File

@@ -0,0 +1,21 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyForestryRecords {
private Long id;
private String productName;
private String usage;
private BigDecimal quantity;
private String estimatedValue;
private String updatedBy;
private String updatedAt;
}

View File

@@ -0,0 +1,29 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.joda.time.DateTime;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyIncomeRecords {
private Long id;
private String inputType;
private Boolean isCredit;
private String cropCode;
private String categoryCode;
private String categorySelf;
private String sourcePurpose;
private BigDecimal quantity;
private String unitCode;
private String price;
private String estimatedValue;
private String updatedBy;
private String updatedAt;
}

View File

@@ -0,0 +1,21 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyPowerRecords {
private Long id;
private String equipmentName;
private BigDecimal ownedHours;
private BigDecimal leasedHours;
private String updatedBy;
private String updatedAt;
}

View File

@@ -0,0 +1,18 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordStatus {
List<GetDailyIncomeRecords> incomes; // 수입
List<GetDailyExpenseRecords> expenses; // 지출
List<GetDailyPowerRecords> powers; // 동력사용시간
List<GetDailyForestryRecords> forestries; // 자가임업
}

View File

@@ -0,0 +1,16 @@
package app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordStatusCmd {
private Long householdSeq;
private Long recordSeq;
private String recordMonth;
}

View File

@@ -0,0 +1,39 @@
package app.module.admin.usecase.household.getDailyRecordsStatus.adapters.web;
import app.module.admin.usecase.household.getDailyRecordsCount.ports.GetDailyRecordsCountPortIn;
import app.module.admin.usecase.household.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount;
import app.module.admin.usecase.household.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCountCmd;
import app.module.admin.usecase.household.getDailyRecordsStatus.ports.GetDailyRecordsStatusPortIn;
import app.module.admin.usecase.household.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
import app.module.admin.usecase.household.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatusCmd;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import app.module.admin.usecase.household.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusReqVO;
import app.module.admin.usecase.household.getDailyRecordsStatus.adapters.web.model.GetDailyRecordsStatusResVO;
@RestController
@RequiredArgsConstructor
class GetDailyRecordsStatusController {
private final GetDailyRecordsStatusPortIn getDailyRecordsStatusPortIn;
private final GetDailyRecordsCountPortIn getDailyRecordsCountPortIn;
@GetMapping(path = "/api/household/dailyRecordsStatus")
ResponseEntity<?> operate(
GetDailyRecordsStatusReqVO reqVO) {
List<GetDailyRecordsStatus> dailyRecords =
getDailyRecordsStatusPortIn.operate(
new GetDailyRecordsStatusCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth()));
GetDailyRecordsCount summary =
getDailyRecordsCountPortIn.operate(
new GetDailyRecordsCountCmd(reqVO.getHouseholdSeq(), reqVO.getRecordMonth())).orElse(null);
return ResponseEntity.status(HttpStatus.OK)
.body(new GetDailyRecordsStatusResVO(summary, dailyRecords));
}
}

View File

@@ -0,0 +1,15 @@
package app.module.admin.usecase.household.getDailyRecordsStatus.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordsStatusReqVO {
private Long householdSeq;
private String recordMonth;
}

View File

@@ -0,0 +1,18 @@
package app.module.admin.usecase.household.getDailyRecordsStatus.adapters.web.model;
import app.module.admin.usecase.household.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount;
import app.module.admin.usecase.household.getDailyRecordsStatus.ports.application.domain.GetDailyRecordsStatus;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordsStatusResVO {
private GetDailyRecordsCount summary; // 등록 현황 요약
private List<GetDailyRecordsStatus> dailyRecords; // 일계부 등록 현황
}

View File

@@ -10,6 +10,7 @@ import lombok.Setter;
@AllArgsConstructor
@EqualsAndHashCode
public class GetDailyRecordsStatus {
private Long id;
private String dayGroup;
private RecordStatusType allStatusType;
private String incomeStatus;

View File

@@ -9,7 +9,6 @@ public enum RecordStatusType {
WAITING("대기"),
DONE("작성완료"),
INCOMPLETE("미완료"),
NONE("등록없음"),
EMPTY("미작성");
private final String desc;

View File

@@ -41,7 +41,7 @@ public class GetHouseholdStatus {
// 유지여부
private Boolean isPanel;
// 비고
private Double memo;
private String memo;
// 조사원
private String researcherName;
// 조사원 연락처

View File

@@ -19,8 +19,6 @@ import app.module.admin.usecase.household.getHouseholdStatusUI.model.GetHousehol
@RequiredArgsConstructor
class GetHouseholdStatusUIController {
private final GetHouseholdStatusPortIn getHouseholdStatusPortIn;
private final GetDailyRecordsStatusPortIn getDailyRecordsStatusPortIn;
private final GetDailyRecordsCountPortIn getDailyRecordsCountPortIn;
@GetMapping(path = "/household/households/{seq}")
String operate(
@@ -35,13 +33,6 @@ class GetHouseholdStatusUIController {
// 임가 상세 정보
model.addAttribute("householdInfo",
getHouseholdStatusPortIn.operate(new GetHouseholdStatusCmd(seq)).orElse(null));
// TODO : 비동기호출로 변경하기
// model.addAttribute("dailyRecords",
// getDailyRecordsStatusPortIn.operate(new GetDailyRecordsStatusCmd(seq, "202506")));
// model.addAttribute("dailyRecordsCount",
// getDailyRecordsCountPortIn.operate(new GetDailyRecordsCountCmd(seq, "202506"))
// .orElse(null));
return "household/households/{seq}";
}

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace="app.module.admin.usecase.household.getDailyRecordStatus.adapters.persistence.GetDailyRecordStatusMapper">
<select id="getDailyIncomeRecords"
resultType="app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyIncomeRecords">
/* getDailyIncomeRecords : 일계부 등록 현황 상세 수입 조회 */
SELECT di.id, /* 수입 id */
di.input_type, /* 입력구분 */
di.is_credit, /* 외상판매여부 */
di.crop_code, /* 재배형태 코드 */
di.category_code, /* 수입 종류 코드 */
di.category_self, /* 수입 종류(직접입력) */
di.source_purpose, /* 수입원(용도) */
di.quantity, /* 수량 */
di.unit_code, /* 단위 */
di.price, /* 현금 */
di.estimated_value, /* 현물평가액 */
di.updated_by, /* 최종수정자 */
di.updated_at /* 최종수정날짜 */
FROM daily_record dr
JOIN daily_income di ON dr.id = di.daily_record_seq
WHERE dr.household_seq = #{householdSeq}
AND dr.id = #{recordSeq}
AND dr.record_month = #{recordMonth}
AND di.is_deleted = false
</select>
<select id="getDailyExpenseRecords"
resultType="app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyExpenseRecords">
/* getDailyExpenseRecords : 일계부 등록 현황 상세 지출 조회 */
SELECT de.id, /* 지출 id */
de.input_type, /* 입력구분 */
de.is_credit, /* 외상판매여부 */
de.category_code, /* 재배형태 코드 */
de.category_self, /* 지출 종류 코드 */
de.source_purpose, /* 지출원(용도) */
de.quantity, /* 수량 */
de.unit_code, /* 단위 */
de.price, /* 현금 */
de.estimated_value, /* 현물평가액 */
de.updated_by, /* 최종수정자 */
de.updated_at /* 최종수정날짜 */
FROM daily_record dr
JOIN daily_expense de ON dr.id = de.daily_record_seq
WHERE dr.household_seq = #{householdSeq}
AND dr.id = #{recordSeq}
AND dr.record_month = #{recordMonth}
AND de.is_deleted = false
</select>
<select id="getDailyPowerRecords"
resultType="app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyPowerRecords">
/* getDailyPowerRecords : 일계부 등록 현황 상세 동력사용시간 조회 */
select dp.id,
dp.equipment_name,
dp.owned_hours,
dp.leased_hours,
dp.updated_by,
dp.updated_at
from daily_record dr
join daily_power dp on dr.id = dp.daily_record_seq
WHERE dr.household_seq = #{householdSeq}
AND dr.id = #{recordSeq}
AND dr.record_month = #{recordMonth}
AND dp.is_deleted = false
</select>
<select id="getDailyForestryRecords"
resultType="app.module.admin.usecase.household.getDailyRecordStatus.ports.application.domain.GetDailyForestryRecords">
/* getDailyForestryRecords : 일계부 등록 현황 상세 자가임업 생산물 중 자가소비량 조회 */
SELECT df.id,
df.product_name,
df.usage,
df.quantity,
df.unit_code,
df.estimated_value,
df.updated_by,
df.updated_at
FROM daily_record dr
JOIN daily_forestry df on dr.id = df.daily_record_seq
WHERE dr.household_seq = #{householdSeq}
AND dr.id = #{recordSeq}
AND dr.record_month = #{recordMonth}
AND df.is_deleted = false
</select>
</mapper>

View File

@@ -6,53 +6,37 @@
<select id="getDailyRecordsCount"
resultType="app.module.admin.usecase.household.getDailyRecordsCount.ports.application.domain.GetDailyRecordsCount">
/* getDailyRecordsCount : 일계부 상태 요약 및 진행률 조회 */
WITH data_counts AS (
SELECT
dr.id,
COUNT(DISTINCT di.id) AS income_cnt,
COUNT(DISTINCT dw.id) AS work_cnt,
COUNT(DISTINCT de.id) AS expense_cnt,
COUNT(DISTINCT dfs.id) AS forestry_cnt
FROM daily_record dr
LEFT JOIN daily_income di ON di.daily_record_seq = dr.id AND di.is_deleted = false
LEFT JOIN daily_work dw ON dw.daily_record_seq = dr.id AND dw.is_deleted = false
LEFT JOIN daily_expense de ON de.daily_record_seq = dr.id AND de.is_deleted = false
LEFT JOIN daily_forestry dfs ON dfs.daily_record_seq = dr.id AND dfs.is_deleted = false
WHERE dr.household_seq = #{householdSeq}
AND dr.record_month = #{recordMonth}
AND dr.is_deleted = false
GROUP BY dr.id
WITH month_check AS (
SELECT #{recordMonth} = TO_CHAR(CURRENT_DATE, 'YYYYMM') AS is_current_month
),
record_status AS (
SELECT
CASE
WHEN ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING' /* 대기 */
WHEN dr.all_status = 'DONE' THEN 'DONE' /* 작성완료 */
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE' /* 미완료 */
WHEN dr.all_status = 'TODAY_NONE' THEN 'NONE' /* 등록없음 */
ELSE 'EMPTY' /* 미작성 */
END AS all_status
CASE
/* 현재 월이고 오늘 이후인 경우만 WAITING */
WHEN mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING'
WHEN dr.all_status IN ('DONE', 'TODAY_NONE') THEN 'DONE'
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE'
WHEN dr.all_status IS NULL THEN 'EMPTY'
ELSE 'EMPTY'
END AS all_status
FROM daily_day_group ddg
LEFT JOIN daily_record dr ON ddg.group_no = dr.day_group_no
AND dr.household_seq = #{householdSeq}
AND dr.record_month = #{recordMonth}
AND dr.is_deleted = false
CROSS JOIN month_check mc
LEFT JOIN daily_record dr ON ddg.group_no = dr.day_group_no
AND dr.household_seq = #{householdSeq}
AND dr.record_month = #{recordMonth}
AND dr.is_deleted = false
)
SELECT
COUNT(*) FILTER (WHERE all_status = 'DONE') AS done_count,
COUNT(*) FILTER (WHERE all_status = 'EMPTY') AS empty_count,
COUNT(*) FILTER (WHERE all_status = 'INCOMPLETE') AS incomplete_count,
COUNT(*) FILTER (WHERE all_status = 'WAITING') AS waiting_count,
ROUND(
100.0 *
COUNT(*) FILTER (WHERE all_status = 'DONE')
/ NULLIF(
(SELECT COUNT(*)
FROM daily_day_group
WHERE end_day &lt;= EXTRACT(DAY FROM CURRENT_DATE)), 0
),
2
) AS progress_percent
COUNT(*) FILTER (WHERE all_status = 'DONE') AS done_count,
COUNT(*) FILTER (WHERE all_status = 'EMPTY') AS empty_count,
COUNT(*) FILTER (WHERE all_status = 'INCOMPLETE') AS incomplete_count,
COUNT(*) FILTER (WHERE all_status = 'WAITING') AS waiting_count,
ROUND(
100.0 *
COUNT(*) FILTER (WHERE all_status = 'DONE')
/ NULLIF(COUNT(*) FILTER (WHERE all_status != 'WAITING'), 0),
2
) AS progress_percent
FROM record_status
</select>
</mapper>

View File

@@ -12,7 +12,7 @@
COUNT(DISTINCT di.id) AS income_cnt,
COUNT(DISTINCT dw.id) AS work_cnt,
COUNT(DISTINCT de.id) AS expense_cnt,
COUNT(DISTINCT dr.id) AS power_cnt,
COUNT(DISTINCT dp.id) AS power_cnt,
COUNT(DISTINCT dfs.id) AS forestry_cnt
FROM daily_record dr
LEFT JOIN daily_income di ON di.daily_record_seq = dr.id AND di.is_deleted = false
@@ -25,23 +25,27 @@
AND dr.record_month = #{recordMonth}
AND dr.is_deleted = false
GROUP BY dr.id
),
month_check AS (
SELECT #{recordMonth} = TO_CHAR(CURRENT_DATE, 'YYYYMM') AS is_current_month
)
SELECT
dr.id AS id,
ddg.start_day || CASE WHEN ddg.start_day = ddg.end_day THEN '' ELSE '-' || ddg.end_day END AS day_group,
CASE
WHEN ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING' /* 대기 */
WHEN dr.all_status = 'DONE' THEN 'DONE' /* 작성완료 */
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE' /* 미완료 */
WHEN dr.all_status = 'TODAY_NONE' THEN 'NONE' /* 등록없음 */
ELSE 'EMPTY' /* 미작성 */
WHEN mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE) THEN 'WAITING' /* 대기 */
WHEN dr.all_status IN ('DONE', 'TODAY_NONE') THEN 'DONE' /* 작성완료 */
WHEN dr.all_status = 'WAITING' THEN 'INCOMPLETE' /* 미완료 */
ELSE 'EMPTY' /* 미작성 */
END AS all_status,
get_status(ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.income_status, dc.income_cnt) AS income_status,
get_status(ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.work_status, dc.work_cnt) AS work_status,
get_status(ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.expense_status, dc.expense_cnt) AS expense_status,
get_status(ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.power_status, dc.power_cnt) AS power_status,
get_status(ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.forestry_status, dc.forestry_cnt) AS forestry_status
fn_get_status(mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.income_status, dc.income_cnt) AS income_status,
fn_get_status(mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.work_status, dc.work_cnt) AS work_status,
fn_get_status(mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.expense_status, dc.expense_cnt) AS expense_status,
fn_get_status(mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.power_status, dc.power_cnt) AS power_status,
fn_get_status(mc.is_current_month AND ddg.end_day > EXTRACT(DAY FROM CURRENT_DATE), dr.forestry_status, dc.forestry_cnt) AS forestry_status
-- TODO : 농업 자가소비량 테이블 수정 후 추가
FROM daily_day_group ddg
CROSS JOIN month_check mc
LEFT JOIN daily_record dr ON ddg.group_no = dr.day_group_no
AND dr.household_seq = #{householdSeq}
AND dr.record_month = #{recordMonth}

View File

@@ -81,14 +81,13 @@
</choose>
</if>
<choose>
<when test="cmd.userRole != null and cmd.userRole != 'ROLE_ADMIN'">
/* 지역 검색 : 지방실사 또는 조사원 */
/* 실사 검색 : 지방실사 또는 조사원 */
AND hvr.regionMainCode = #{cmd.userRegionMainCode}
</when>
<when test="cmd.regionMainCode != null and cmd.regionMainCode != ''">
/* 지역 검색 : 관리자 */
/* 실사 검색 : 관리자 */
AND hvr.regionMainCode = #{cmd.regionMainCode}
</when>
</choose>

View File

@@ -12,148 +12,291 @@
<input name="userRole" th:value="${userRole}" type="hidden"/>
<input name="userRegionMainCode" th:value="${userRegionMainCode}" type="hidden"/>
<div>
<label>입력월</label>
<select name="recordMonth" th:field="*{recordMonth}">
<option th:each="month : ${monthList}"
th:value="${month.value}"
th:text="${month.label}"
th:selected="${month.value == currentMonth}">
</option>
</select>
<div class="content-inner">
<!-- 필터 영역 -->
<section class="filter-wrap">
<div class="form-area">
<!-- 연/월 -->
<div class="input-group">
<div class="input-label">
<p class="label-txt">
연/월
</p>
</div>
<div class="component-select">
<select class="select-list" name="recordMonth" th:field="*{recordMonth}" required>
<option th:each="month : ${monthList}"
th:value="${month.value}"
th:text="${month.label}"
th:selected="${month.value == currentMonth}">
</option>
</select>
</div>
</div>
<label>경영주</label>
<select name="ownerField" th:field="*{ownerField}">
<option value="">전체</option>
<option value="name">이름</option>
<option value="phone">전화번호</option>
</select>
<input type="text" name="ownerValue" placeholder="" th:field="*{ownerValue}">
<!-- 경영주 -->
<div class="input-group">
<div class="input-label">
<p class="label-txt">
경영주
</p>
</div>
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="ownerField" th:field="*{ownerField}">
<option value="">전체</option>
<option value="name">이름</option>
<option value="phone">전화번호</option>
</select>
</div>
<div class="component-input">
<div class="input-field">
<input type="text" id="temp_input_0001" name="ownerValue" th:field="*{ownerValue}" placeholder="이름 입력">
</div>
</div>
</div>
</div>
<label>실사</label>
<select name="regionMainCode" th:field="*{regionMainCode}">
<option value="">전체</option>
<option th:each="item : ${regionMainList}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
<div class="input-group">
<div class="d-flex">
<div class="component-select">
<div class="input-label">
<p class="label-txt">
실사
</p>
</div>
<select class="select-list" name="regionMainCode" th:field="*{regionMainCode}">
<option value="">전체</option>
<option th:each="item : ${regionMainList}"
th:value="${item.id}"
th:text="${item.codeText}">
</select>
</div>
<div class="component-select">
<div class="input-label">
<p class="label-txt">
지역
</p>
</div>
<select class="select-list" name="regionSubCode" th:field="*{regionSubCode}">
<option value="">전체</option>
<option th:each="item : ${regionSubList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
<div class="component-select">
<div class="input-label">
<p class="label-txt">
세부지역
</p>
</div>
<select class="select-list" name="regionDetailCode" th:field="*{regionDetailCode}">
<option value="">전체</option>
<option th:each="item : ${regionDetailList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</div>
</div>
<label>지역</label>
<select name="regionSubCode" th:field="*{regionSubCode}">
<option value="">전체</option>
<option th:each="item : ${regionSubList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
<div class="input-group">
<div class="d-flex">
<div class="component-select">
<div class="input-label">
<p class="label-txt">
업종 대분류
</p>
</div>
<select class="select-list" name="industryLargeCode" th:field="*{industryLargeCode}">
<option value="">전체</option>
<option th:each="item : ${industryLargeList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
<div class="component-select">
<div class="input-label">
<p class="label-txt">
업종 중분류
</p>
</div>
<select class="select-list" name="industryMiddleCode" th:field="*{industryMiddleCode}">
<option value="">전체</option>
<option th:each="item : ${industryMiddleList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</div>
</div>
<label>세부지역</label>
<select name="regionDetailCode" th:field="*{regionDetailCode}">
<option value="">전체</option>
<option th:each="item : ${regionDetailList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
<div class="input-group">
<div class="component-select">
<div class="input-label">
<p class="label-txt">
일계부 현황
</p>
</div>
<select class="select-list" name="progressType" th:field="*{progressType}">
<option value="">전체</option>
<option value="PROGRESS_25">25% 미만</option>
<option value="PROGRESS_50">25~50% 미만</option>
<option value="PROGRESS_75">50~75% 미만</option>
<option value="PROGRESS_75_UP">75% 이상</option>
<option value="PROGRESS_100">100% 완료</option>
</select>
</div>
</div>
<label>업종 대분류</label>
<select name="industryLargeCode" th:field="*{industryLargeCode}">
<option value="">전체</option>
<option th:each="item : ${industryLargeList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
<div class="input-group">
<div class="d-flex">
<div class="component-select">
<div class="input-label">
<p class="label-txt">
당일 1차 방문
</p>
</div>
<select class="select-list" name="isFirstVisited" th:field="*{isFirstVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
</div>
<div class="component-select">
<div class="input-label">
<p class="label-txt">
당월 2차 방문
</p>
</div>
<select class="select-list" name="isSecondVisited" th:field="*{isSecondVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
</div>
<div class="component-select">
<div class="input-label">
<p class="label-txt">
답례품 방문
</p>
</div>
<select class="select-list" name="isGiftSent" th:field="*{isGiftSent}">
<option value="">전체</option>
<option value="true">전달</option>
<option value="false">미전달</option>
</select>
</div>
</div>
</div>
<label>업종 중분류</label>
<select name="industryMiddleCode" th:field="*{industryMiddleCode}">
<option value="">전체</option>
<option th:each="item : ${industryMiddleList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
<div class="input-group">
<div class="input-label">
<p class="label-txt">
조사원
</p>
</div>
<div class="d-flex">
<div class="component-select">
<select class="select-list" name="researcherField" th:field="*{researcherField}">
<option value="">전체</option>
<option value="name">이름</option>
<option value="phone">전화번호</option>
</select>
</div>
<div class="component-input">
<div class="input-field">
<input type="text" id="temp_input_0002" name="researcherValue" placeholder="이름 입력" th:field="*{researcherValue}">
</div>
</div>
</div>
</div>
<label>일계부 현황</label>
<select name="progressType" th:field="*{progressType}">
<option value="">전체</option>
<option value="PROGRESS_25">25% 미만</option>
<option value="PROGRESS_50">25~50% 미만</option>
<option value="PROGRESS_75">50~75% 미만</option>
<option value="PROGRESS_75_UP">75% 이상</option>
<option value="PROGRESS_100">100% 완료</option>
</select>
<div class="input-group">
<div class="input-label">
<p class="label-txt">
패널 유지 여부
</p>
</div>
<div class="component-select">
<select class="select-list" name="isPanel" th:field="*{isPanel}">
<option value="">전체</option>
<option value="true">유지</option>
<option value="false">비유지</option>
</select>
</div>
</div>
<label>당월 1차 방문</label>
<select name="isFirstVisited" th:field="*{isFirstVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
</div>
<label>당월 2차 방문</label>
<select name="isSecondVisited" th:field="*{isSecondVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
<!-- 버튼 그룹 -->
<div class="component-btns">
<div class="btns-row">
<button type="button" class="btn" onclick="location.href = location.pathname">
<span class="btn-txt">초기화</span>
</button>
<button type="submit" class="btn btn-primary">
<span class="btn-txt">검색</span>
</button>
</div>
</div>
</section>
<label>답례품 전달</label>
<select name="isGiftSent" th:field="*{isGiftSent}">
<option value="">전체</option>
<option value="true">전달</option>
<option value="false">미전달</option>
</select>
<section>
<p class="input-label" style="font-size: 16px;">총 <span id="totalElements">0</span>건</p>
<!-- 테이블 영역 -->
<table>
<thead>
<tr>
<th>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_0003" name="temp_checkbox_0001">
</label>
</div>
</th>
<th>임가번호</th>
<th>이름</th>
<th>전화번호</th>
<th>실사</th>
<th>지역</th>
<th>세부지역</th>
<th>업종(대분류)</th>
<th>업종(중분류)</th>
<th>당월 일계부 현황</th>
<th>당월 1차 일가방문</th>
<th>당월 2차 일가방문</th>
<th>답례품 전달</th>
<th class="hide-role-researcher">조사원</th>
<th class="hide-role-researcher">조사원 휴대전화</th>
</tr>
</thead>
<tbody id="listTBody">
<span class="hide-role-researcher">
<label>조사원</label>
<select name="researcherField" th:field="*{researcherField}">
<option value="">전체</option>
<option value="name">이름</option>
<option value="phone">전화번호</option>
</select>
<input type="text" name="researcherValue" placeholder="" th:field="*{researcherValue}">
</span>
</tbody>
</table>
</section>
<label>패널 유지 여부</label>
<select name="isPanel" th:field="*{isPanel}">
<option value="">전체</option>
<option value="true">유지</option>
<option value="false">비유지</option>
</select>
<!-- 페이지네이션 -->
<div class="row paging"></div>
<div>
<button type="reset" onclick="location.href = location.pathname">초기화</button>
<button type="submit">검색</button>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn">
<span class="btn-txt">임가 등록</span>
</button>
<button type="button" class="btn">
<span class="btn-txt">조사원 매핑</span>
</button>
</div>
</div>
</div>
<p>총 <span id="totalElements">100</span>건</p>
<table border="1" style="width: 100%; ">
<thead>
<tr>
<th style="width: 40px;"><input type="checkbox"></th>
<th style="width: 80px;">임가번호</th>
<th style="width: 80px;">경영주명</th>
<th style="width: 120px;">휴대전화</th>
<th style="width: 60px;">실사</th>
<th style="width: 100px;">지역</th>
<th style="width: 100px;">세부지역</th>
<th style="width: 120px;">업종 대분류</th>
<th style="width: 120px;">업종 중분류</th>
<th style="width: 120px;">당월 일계부 현황</th>
<th style="width: 100px;">1차 방문일</th>
<th style="width: 100px;">2차 방문일</th>
<th style="width: 100px;">답례품 전달</th>
<th style="width: 80px;" class="hide-role-researcher">조사원</th>
<th style="width: 120px;" class="hide-role-researcher">조사원 휴대전화</th>
</tr>
</thead>
<tbody id="listTBody">
</tbody>
</table>
</form>
<div class="row paging"></div>
<div>
<!-- <button>엑셀 다운로드</button>-->
<!-- <button>임가 등록</button>-->
@@ -187,18 +330,24 @@
tbody.append(
`
<tr>
<td><input type="checkbox"></td>
<td><a href="/household/households/${ct.householdSeq}">${ct.householdNum}</a></td> <!-- 임가번호 -->
<td>${ct.householdName}</td> <!-- 경영주 이름 -->
<td>${ct.householdPhone}</td> <!-- 경영주 번호 -->
<td>${ct.regionMainName}</td> <!-- 실사 -->
<td>${ct.regionSubName}</td> <!-- 지역 -->
<td>${ct.regionDetailName}</td> <!-- 세부지역 -->
<td>${isEmpty(ct.industryLargeName)}</td> <!-- 업종 대분류 -->
<td>${isEmpty(ct.industryMiddleName)}</td> <!-- 업종 중분류1 -->
<td>${ct.progressPercent}%</td> <!-- 임가 진행 상황 -->
<td>${isEmpty(ct.firstVisitDate)}</td> <!-- 1차방문날짜 -->
<td>${isEmpty(ct.secondVisitDate)}</td> <!-- 2차방문날짜 -->
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${ct.householdSeq}" name="temp_checkbox_000${ct.householdSeq}">
</label>
</div>
</td>
<td class="underline"><a href="/household/households/${ct.householdSeq}">${ct.householdNum}</a></td><!-- 임가번호 -->
<td class="underline"><a href="/household/households/${ct.householdSeq}">${ct.householdName}</a></td><!-- 경영주 이름 -->
<td>${ct.householdPhone}</td><!-- 경영주 번호 -->
<td>${ct.regionMainName}</td><!-- 실사 -->
<td>${ct.regionSubName}</td><!-- 지역 -->
<td>${ct.regionDetailName}</td><!-- 세부지역 -->
<td>${isEmpty(ct.industryLargeName)}</td><!-- 업종 대분류 -->
<td>${isEmpty(ct.industryMiddleName)}</td><!-- 업종 중분류1 -->
<td>${ct.progressPercent}%</td><!-- 임가 진행 상황 -->
<td>${isEmpty(ct.firstVisitDate)}</td><!-- 1차방문날짜 -->
<td>${isEmpty(ct.secondVisitDate)}</td><!-- 2차방문날짜 -->
<td>${ct.isGiftSent ? "전달" : "미전달"}</td> <!-- 답례품 -->
<td class="hide-role-researcher">${isEmpty(ct.researcherName)}</td> <!-- 조사원이름 -->
<td class="hide-role-researcher">${isEmpty(ct.researcherPhone)}</td> <!-- 조사원번호 -->

View File

@@ -3,120 +3,609 @@
layout:decorate="~{layout/layout}">
<section layout:fragment="content">
<!-- 1. 상단 정보 -->
<form autocomplete="off" method="get" name="reqForm">
<div>
<table>
<tr>
<th>임가번호</th>
<td th:text="${householdInfo.householdNum}">16750</td>
<th>경영주</th>
<td th:text="${householdInfo.householdName}">홍길동</td>
<th>연령</th>
<td th:text="${householdInfo.householdAge}">75</td>
</tr>
<tr>
<th>가구 연락처</th>
<td th:text="${householdInfo.householdTel}">031-0000-0000</td>
<th>휴대전화</th>
<td th:text="${householdInfo.householdPhone}">010-0000-0000</td>
<th>실사</th>
<td th:text="${householdInfo.regionMainName}">서울</td>
</tr>
<tr>
<th>지역</th>
<td th:text="${householdInfo.regionSubName}">31. 경기도</td>
<th>세부지역</th>
<td th:text="${householdInfo.regionDetailName}">9. 경기</td>
<th>주소</th>
<td th:text="${householdInfo.address}">경기 성남시 분당구 삼평대로...</td>
</tr>
<tr>
<th>업종 대분류</th>
<td th:text="${householdInfo.industryLargeName}">40. 수실류재배업</td>
<th>업종 중분류1</th>
<td th:text="${householdInfo.industryMiddleName}">42. 대추재배업</td>
<th>업종 중분류2</th>
<td th:text="${householdInfo.industrySubMiddleName != null ? householdInfo.industrySubMiddleName : ''}">42. 대추재배업</td>
<th>규모/세부품목</th>
<td th:text="${householdInfo.industryDetailName != null ? householdInfo.industryDetailName : ''}">52_1. 조경수</td>
</tr>
<tr>
<th>조사원</th>
<td th:text="${householdInfo.researcherName}">김조사</td>
<th>조사원 연락처</th>
<td th:text="${householdInfo.researcherPhone}">010-1111-1111</td>
<th>유지여부</th>
<td th:text="${householdInfo.isPanel ? '1. 유지' : '2. 탈락'}">1. 유지</td>
</tr>
<tr>
<th>비고</th>
<td colspan="5" th:text="${householdInfo.memo}">비고 텍스트</td>
</tr>
</table>
<input type="hidden" name="householdSeq" th:value="${seq}">
<div class="content-inner">
<section>
<table class="type-form confirm">
<tbody>
<tr>
<th>임가번호</th>
<td>
<span th:text="${householdInfo.householdNum}">16750</span>
</td>
<th>경영주</th>
<td>
<span th:text="${householdInfo.householdName}">홍길동</span>
</td>
<th>연령</th>
<td>
<span th:text="${householdInfo.householdAge}">75</span>
</td>
</tr>
<tr>
<th>가구 연락처</th>
<td>
<span th:text="${householdInfo.householdTel}">031-0000-0000</span>
</td>
<th>휴대폰 번호</th>
<td>
<span th:text="${householdInfo.householdPhone}">010-0000-0000</span>
</td>
</tr>
<tr>
<th>실사</th>
<td>
<span th:text="${householdInfo.regionMainName}">서울</span>
</td>
<th>지역</th>
<td>
<span th:text="${householdInfo.regionSubName}">31.경기도</span>
</td>
<th>세부 지역</th>
<td>
<span th:text="${householdInfo.regionDetailName}">9.경기</span>
</td>
</tr>
<tr>
<th>전체 주소</th>
<td>
<span th:text="${householdInfo.address}">경기도 성남시 분당구 산성대로 OOOO</span>
</td>
</tr>
<tr>
<th>업종 대분류</th>
<td>
<span th:text="${householdInfo.industryLargeName}">40. 수실류재배업</span>
</td>
<th>업종 중분류1</th>
<td>
<span th:text="${householdInfo.industryMiddleName}">42. 대추재배업</span>
</td>
<th>업종 중분류2</th>
<td>
<span th:text="${householdInfo.industrySubMiddleName != null ? householdInfo.industrySubMiddleName : '-'}">52_1. 조경수</span>
</td>
</tr>
<tr>
<th>규모/세부품목</th>
<td>
<span th:text="${householdInfo.industryDetailName != null ? householdInfo.industryDetailName : '-'}">52_1_1. 조경수</span>
</td>
</tr>
<tr>
<th>담당 조사원</th>
<td>
<span th:text="${householdInfo.researcherName != null ? householdInfo.researcherName : '-'}">김조사</span>
</td>
<th>담당조사원 연락처</th>
<td>
<span th:text="${householdInfo.researcherPhone != null ? householdInfo.researcherPhone : '-'}">010-0000-0000</span>
</td>
<th>유지여부</th>
<td class="radio-group">
<span th:text="${householdInfo.isPanel ? '1. 유지' : '2. 탈락'}">1.유지</span>
</td>
</tr>
<tr>
<th>비고</th>
<td class="radio-group">
<span th:text="${householdInfo.memo != null ? householdInfo.memo : '-'}">-</span>
</td>
</tr>
</tbody>
</table>
<div class="component-btns bottom-btn-group">
<div class="btns-row align-right">
<button type="button" class="btn">
<span class="btn-txt">조사원 매핑</span>
</button>
<button type="button" class="btn btn-primary">
<span class="btn-txt">수정</span>
</button>
</div>
</div>
</section>
<section>
<div class="component-tab" data-active="tab1">
<div class="tab-head">
<button type="button" class="tab-label select-tab" data-tab-type="daily-record" data-tab-value="tab1">일계부 등록 현황</button>
<button type="button" class="tab-label select-tab" data-tab-type="forest-product" data-tab-value="tab2">임산물 현황</button>
<button type="button" class="tab-label select-tab" data-tab-type="bank-auto-transfer" data-tab-value="tab3">은행자동이체 내역</button>
<button type="button" class="tab-label select-tab" data-tab-type="household-visit" data-tab-value="tab4">임가방문정보</button>
<div class="component-select select-date">
<select class="select-list" name="recordMonth" required onchange="onRecordMonthChange();">
<option th:each="m : ${monthList}"
th:value="${m.value}"
th:text="${m.label}">2025년 5월</option>
</select>
</div>
</div>
<div class="tab-body">
<div class="tab-content daily-record" data-tab-value="tab1">
<!-- 일계부 등록 현황 리스트 -->
<div class="daily-record-content daily-record-list">
<div>
<span>작성완료: <span id="doneCount">0</span></span>
<span>미작성: <span id="emptyCount">0</span></span>
<span>미완료: <span id="incompleteCount">0</span></span>
<span>대기: <span id="waitingCount">0</span></span>
<span> 현황: <span id="progressPercent">0</span>%</span>
</div>
<div class="content-inner">
<table>
<thead>
<tr>
<th>입력날짜</th>
<th>완료상태</th>
<th>수입</th>
<th>노동투입</th>
<th>지출</th>
<th>동력사용시간</th>
<th>임업 자가소비량</th>
<!-- <th>농업 자가소비량</th>-->
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!-- 일계부 등록 현황 상세 -->
<div class="daily-record-content daily-record-detail" style="display: none;">
<div class="content-inner">
<table id="table-income">
<thead>
<tr>
<th colspan="10">수입 (<span id="incomeCount">0</span>건)</th>
</tr>
</thead>
<thead>
<!-- <tr>-->
<!-- <th colspan="10">수입</th>-->
<!-- </tr>-->
<tr>
<th>선택</th>
<th>외상판매</th>
<th>재배형태</th>
<th>수입의 종류</th>
<th>수입원</th>
<th>수량</th>
<th>단위</th>
<th>현금(원)</th>
<th>현물평가액</th>
<th>최종 수정자</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- 지출 -->
<div class="content-inner">
<table id="table-expense">
<thead>
<tr>
<th colspan="9">지출 (<span id="expenseCount">0</span>건)</th>
</tr>
</thead>
<thead>
<tr>
<th>선택</th>
<th>외상 또는 카드구입</th>
<th>지출의 종류</th>
<th>용도</th>
<th>수량</th>
<th>단위</th>
<th>현금(원)</th>
<th>현물평가액</th>
<th>최종 수정자</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- 동력사용시간 -->
<div class="content-inner">
<table id="table-power">
<thead>
<tr>
<th colspan="5">동력사용시간 (<span id="powerCount">0</span>건)</th>
</tr>
</thead>
<thead>
<tr>
<th>선택</th>
<th>명칭</th>
<th>자가 사용시간</th>
<th>임가 사용시간</th>
<th>최종 수정자</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<!-- 자가임업 -->
<div class="content-inner">
<table id="table-forestry">
<thead>
<tr>
<th colspan="7">자가임업 생산물 중 자가소비량 (<span id="forestryCount">0</span>건)</th>
</tr>
</thead>
<thead>
<tr>
<th>선택</th>
<th>생산물</th>
<th>용도</th>
<th>수량</th>
<th>단위</th>
<th>현물평가액</th>
<th>최종 수정자</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-content" data-tab-value="tab2">
<div class="content-inner">
</div>
</div>
<div class="tab-content" data-tab-value="tab3">
<div class="content-inner">
</div>
</div>
<div class="tab-content" data-tab-value="tab4">
<div class="content-inner">
</div>
</div>
</div>
</div>
<div class="component-btns bottom-btn-group">
<div class="btns-row two-col">
<div class="btns-col-1">
<button type="button" class="btn" onclick="location.href='/household/households'">
<span class="btn-txt">목록</span>
</button>
</div>
<div class="btns-col-2 align-right">
<button type="button" class="btn">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn">
<span class="btn-txt">인쇄 <i class="ico-print" aria-hidden="true"></i></span>
</button>
</div>
</div>
</div>
</section>
</div>
</form>
<!-- 2. 버튼 -->
<div style="">
<button>수정</button>
<button>조사원 매핑</button>
</div>
<!-- 3. 탭 -->
<div style="margin-top: 50px;">
<button class="tab daily-record">일계부 등록 현황</button>
<button class="tab forest-product">임산물 현황</button>
<button class="tab bank-auto-transfer">은행자동이체 내역</button>
<button class="tab household-visit">임가방문정보</button>
<select name="recordMonth">
<option
th:each="m : ${monthList}" th:value="${m.value}" th:text="${m.label}">2025년 5월</option>
</select>
</div>
<!-- 4. 테이블 -->
<div class="table daily-record">
<span>
<span>작성완료: <span>0</span></span>
<span>미작성: <span>0</span></span>
<span>미완료: <span>0</span></span>
<span>대기: <span>0</span></span>
<span> 현황: <span>0</span>%</span>
</span>
<table border="1" style="margin-top: 50px;">
<thead>
<tr>
<th>입력날짜</th>
<th>완료상태</th>
<th>수입</th>
<th>노동투입</th>
<th>지출</th>
<th>동력사용시간</th>
<th>입업자가소비량</th>
<!-- <th>농업자가소비량</th>-->
</tr>
</thead>
<tbody>
<tr>
<td>1-2</td>
<td>작성완료</td>
<td>4건</td>
<td>등록없음</td>
<td>등록없음</td>
<td>2건</td>
<td>2건</td>
<!-- <td>대상아님</td>-->
</tr>
</tbody>
</table>
</div>
</section>
<section layout:fragment="script">
<script th:inline="javascript">
<script>
// 일계부 완료상태
const statusInfoMap = {
DONE: {
label: '작성완료',
className: 'green'
},
INCOMPLETE: {
label: '미완료',
className: 'light-green'
},
EMPTY: {
label: '미작성',
className: 'border'
},
WAITING: {
label: '대기',
className: 'gray'
}
};
</script>
<script>
$(document).ready(() => {
getDailyRecords();
});
$('.select-tab').on('click', function () {
getTabData(this.dataset.tabType);
});
</script>
<script>
// 날짜선택
const onRecordMonthChange = () => {
const selectedTab = document.querySelector('.tab-label[aria-selected="true"]');
if (!selectedTab) return;
getTabData(selectedTab.dataset.tabType);
}
const getTabData = (tabType) => {
switch (tabType) {
case 'daily-record': // 일계부 등록 현황
console.log("일계부 등록 현황");
getDailyRecords();
break;
case 'forest-product': // 임산물 현황
console.log("임산물 현황");
// getForestProductStatus();
break;
case 'bank-auto-transfer': // 은행자동이체내역
console.log("은행자동이체내역");
// getAutoTransferStatus();
break;
case 'household-visit': // 임가방문정보
console.log("임가방문정보");
// getVisitStatus();
break;
}
}
</script>
<script th:inline="javascript">
// 일계부 등록 현황 리스트 조회
const getDailyRecords = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/household/dailyRecordsStatus',
data: {
householdSeq: f.householdSeq.value,
recordMonth: f.recordMonth.value
},
success(response) {
console.log("일계부 현황 리스트 조회 : ", response);
const listArea = $('.tab-content .daily-record-list');
const detailArea = $('.tab-content .daily-record-detail');
const tbody = listArea.find('tbody');
detailArea.hide();
listArea.show();
tbody.empty();
$('#doneCount').text(response.summary.doneCount);
$('#emptyCount').text(response.summary.emptyCount);
$('#incompleteCount').text(response.summary.incompleteCount);
$('#waitingCount').text(response.summary.waitingCount);
$('#progressPercent').text(response.summary.progressPercent);
let tmpl = '';
$(response.dailyRecords).each((idx, item) => {
tmpl +=
`
<tr>
<td class="underline"><a href="javascript:void(0);" onclick="getDailyRecordsView(${item.id});">${item.dayGroup}</a></td>
<td>
<span class="tag ${statusInfoMap[item.allStatusType].className}">
${statusInfoMap[item.allStatusType].label}
</span>
</td> <!-- 완료상태 -->
<td>${item.incomeStatus}</td><!-- 수입 -->
<td>${item.workStatus}</td><!-- 노동투입 -->
<td>${item.expenseStatus}</td><!-- 지출 -->
<td>${item.powerStatus}</td><!-- 동력사용시간 -->
<td>${item.forestryStatus}</td><!-- 임업 자가소비량 -->
<!-- <td>${item.forestryStatus}</td>&lt;!&ndash; 농업 자가소비량 &ndash;&gt;-->
</tr>
`;
});
tbody.append(tmpl);
}
});
}
// 임산물 등록 현황 상세
const getDailyRecordsView = (id) => {
if(id == null) {
alert('등록 내역이 없습니다.');
return;
}
const f = document.reqForm;
const listArea = $('.tab-content .daily-record-list');
const detailArea = $('.tab-content .daily-record-detail');
listArea.hide();
detailArea.show();
$.ajax({
method: 'GET',
url: '/api/household/dailyRecordStatus',
data: {
householdSeq: f.householdSeq.value,
recordSeq: id,
recordMonth: f.recordMonth.value
},
success(response) {
console.log("일계부 등록 상세 데이터~ : ", response);
gridIncomeTable(response.incomes);
gridExpenseTable(response.expenses);
gridPowerTable(response.powers);
gridForestryTable(response.forestries);
}
});
}
// 수입 테이블 그리기
const gridIncomeTable = (data) => {
const tbody = $('#table-income tbody');
tbody.empty();
$('#incomeCount').text(data.length);
if(data.length === 0) {
noData(tbody, 10);
return;
}
let tmpl = '';
$(data).each((idx, item) => {
tmpl +=
`
<tr>
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
</label>
</div>
</td>
<td>외상판매</td> <!-- 외상판매 -->
<td>재배형태</td><!-- 재배형태 -->
<td>수입의 종류</td><!-- 수입의 종류 -->
<td>수입원</td><!-- 수입원 -->
<td>수량</td><!-- 수량 -->
<td>단위</td><!-- 단위 -->
<td>현금(원)</td><!-- 현금(원) -->
<td>현물평가액</td><!-- 현물평가액 -->
<td>최종 수정자</td><!-- 최종 수정자 -->
</tr>
`;
});
tbody.append(tmpl);
}
// 지출 테이블 그리기
const gridExpenseTable = (data) => {
const tbody = $('#table-expense tbody');
tbody.empty();
$('#expenseCount').text(data.length);
if(data.length === 0) {
noData(tbody, 9);
return;
}
let tmpl = '';
$(data).each((idx, item) => {
tmpl +=
`
<tr>
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
</label>
</div>
</td>
<td>외상 또는 카드구입</td> <!-- 외상 또는 카드구입 -->
<td>지출의 종류</td><!-- 지출의 종류 -->
<td>용도</td><!-- 용도 -->
<td>수량</td><!-- 수량 -->
<td>단위</td><!-- 단위 -->
<td>현금(원)</td><!-- 현금(원) -->
<td>현물평가액</td><!-- 현물평가액 -->
<td>최종 수정자</td><!-- 최종 수정자 -->
</tr>
`;
});
tbody.append(tmpl);
}
// 동력사용시간 테이블 그리기
const gridPowerTable = (data) => {
const tbody = $('#table-power tbody');
tbody.empty();
$('#powerCount').text(data.length);
if(data.length === 0) {
noData(tbody, 5);
return;
}
let tmpl = '';
$(data).each((idx, item) => {
tmpl +=
`
<tr>
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
</label>
</div>
</td>
<td>명칭</td> <!-- 명칭 -->
<td>자가 사용시간</td><!-- 자가 사용시간 -->
<td>임가 사용시간</td><!-- 임가 사용시간 -->
<td>최종 수정자</td><!-- 최종 수정자 -->
</tr>
`;
});
tbody.append(tmpl);
}
// 자가임업 테이블 그리기
const gridForestryTable = (data) => {
const tbody = $('#table-forestry tbody');
tbody.empty();
$('#forestryCount').text(data.length);
if(data.length === 0) {
noData(tbody, 7);
return;
}
let tmpl = '';
$(data).each((idx, item) => {
tmpl +=
`
<tr>
<td>
<div class="component-input">
<label class="checkbox-inner">
<input type="checkbox" id="temp_checkbox_000${item.id}" name="temp_checkbox_000${item.id}" value="${item.id}">
</label>
</div>
</td>
<td>생산물</td> <!-- 생산물 -->
<td>용도</td><!-- 용도 -->
<td>수량</td><!-- 수량 -->
<td>단위</td><!-- 단위 -->
<td>현물평가액</td><!-- 현물평가액 -->
<td>최종 수정자</td><!-- 최종 수정자 -->
</tr>
`;
});
tbody.append(tmpl);
}
const noData = (target, length) => {
$(target).append(`<tr><td colspan="${length}" style="text-align: center;">등록없음</td></tr>`);
}
</script>
</section>