Merge branch 'kangsun' into 'dev'

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

See merge request korea-research/korea-research!3
This commit is contained in:
이강선 매니저/ST
2025-06-12 11:07:23 +00:00
25 changed files with 850 additions and 32 deletions

View File

@@ -0,0 +1,33 @@
package app.module.admin.config.application.util;
import app.module.admin.config.application.util.model.MonthOption;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Component;
@Component
public class DateUiUtil {
private static final DateTimeFormatter VALUE_FORMAT = DateTimeFormatter.ofPattern("yyyyMM");
private static final DateTimeFormatter LABEL_FORMAT = DateTimeFormatter.ofPattern("yyyy년 M월");
public static List<MonthOption> getRecentMonths(int count) {
List<MonthOption> list = new ArrayList<>();
LocalDate now = LocalDate.now();
for (int i = 0; i < count; i++) {
LocalDate date = now.minusMonths(i);
list.add(new MonthOption(
date.format(VALUE_FORMAT),
date.format(LABEL_FORMAT)
));
}
return list;
}
public static String getCurrentMonthValue() {
return LocalDate.now().format(VALUE_FORMAT);
}
}

View File

@@ -0,0 +1,13 @@
package app.module.admin.config.application.util.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class MonthOption {
private String value;
private String label;
}

View File

@@ -0,0 +1,21 @@
package app.module.admin.usecase.household.getHouseholdStatus.adapters.persistence;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import app.module.core.usecase.household.getHousehold.adapters.persistence.GetHouseholdMapper;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortOut;
import org.springframework.stereotype.Repository;
@Repository
@RequiredArgsConstructor
class GetHouseholdStatusDao implements GetHouseholdStatusPortOut {
private final GetHouseholdStatusMapper mapper;
@Override
public Optional<GetHouseholdsStatus> operate(GetHouseholdStatusCmd cmd) {
return mapper.getHouseholdStatusById(cmd);
}
}

View File

@@ -0,0 +1,12 @@
package app.module.admin.usecase.household.getHouseholdStatus.adapters.persistence;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import java.util.Optional;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GetHouseholdStatusMapper {
Optional<GetHouseholdsStatus> getHouseholdStatusById(GetHouseholdStatusCmd cmd);
}

View File

@@ -0,0 +1,9 @@
package app.module.admin.usecase.household.getHouseholdStatus.ports;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import java.util.Optional;
public interface GetHouseholdStatusPortIn {
Optional<GetHouseholdsStatus> operate(GetHouseholdStatusCmd cmd);
}

View File

@@ -0,0 +1,9 @@
package app.module.admin.usecase.household.getHouseholdStatus.ports;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import java.util.Optional;
public interface GetHouseholdStatusPortOut {
Optional<GetHouseholdsStatus> operate(GetHouseholdStatusCmd cmd);
}

View File

@@ -0,0 +1,20 @@
package app.module.admin.usecase.household.getHouseholdStatus.ports.application;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortOut;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class GetHouseholdStatusService implements GetHouseholdStatusPortIn {
private final GetHouseholdStatusPortOut portOut;
@Override
public Optional<GetHouseholdsStatus> operate(GetHouseholdStatusCmd cmd) {
return portOut.operate(cmd);
}
}

View File

@@ -0,0 +1,49 @@
package app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode
public class GetHouseholdStatus {
// 가구 일련번후
private Integer householdSeq;
// 임가번후
private String householdNum;
// 경영주명
private String householdName;
// 연령
private String householdAge;
// 가구 연락처
private String householdTel;
// 휴대폰번호
private String householdPhone;
// 실사
private String regionMainName;
// 지역
private String regionSubName;
// 세부지역
private String regionDetailName;
// 주소
private String address;
// 업종 대분류
private String industryLargeName;
// 업종 중분류1
private String industryMiddleName;
// 업종 중분류2
private String industrySubMiddleName;
// 규모/세부품목
private String industryDetailName;
// 유지여부
private Boolean isPanel;
// 비고
private Double memo;
// 조사원
private String researcherName;
// 조사원 연락처
private String researcherPhone;
}

View File

@@ -0,0 +1,14 @@
package app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetHouseholdStatusCmd {
private Integer seq;
}

View File

@@ -0,0 +1,31 @@
package app.module.admin.usecase.household.getHouseholdStatusUI;
import app.module.admin.config.application.util.DateUiUtil;
import app.module.admin.usecase.household.getHouseholdStatus.ports.GetHouseholdStatusPortIn;
import app.module.admin.usecase.household.getHouseholdStatus.ports.application.domain.GetHouseholdStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import app.module.admin.usecase.household.getHouseholdStatusUI.model.GetHouseholdStatusUIReqVO;
@Controller
@RequiredArgsConstructor
class GetHouseholdStatusUIController {
private final GetHouseholdStatusPortIn portIn;
@GetMapping(path = "/household/households/{seq}")
String operate(
@PathVariable Integer seq,
Model model,
@ModelAttribute("reqVO") GetHouseholdStatusUIReqVO reqVO) {
model.addAttribute("householdInfo", portIn.operate(new GetHouseholdStatusCmd(seq)).orElse(null));
model.addAttribute("monthList", DateUiUtil.getRecentMonths(13));
model.addAttribute("currentMonth", DateUiUtil.getCurrentMonthValue());
return "household/households/{seq}";
}
}

View File

@@ -0,0 +1,13 @@
package app.module.admin.usecase.household.getHouseholdStatusUI.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetHouseholdStatusUIReqVO {
}

View File

@@ -1,5 +1,6 @@
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.persistence;
import java.util.List;
import lombok.RequiredArgsConstructor;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
@@ -12,9 +13,14 @@ import org.springframework.stereotype.Repository;
@Repository
@RequiredArgsConstructor
class GetHouseholdsStatusDao implements GetHouseholdsStatusPortOut {
private final GetHouseholdsStatusMapper mapper;
@Override
public Page<GetHouseholdsStatus> operate(Pageable pageable, GetHouseholdsStatusCmd cmd) {
return new PageImpl<>(null, null, 0);
List<GetHouseholdsStatus> householdsStatus = mapper.getHouseholdsStatus(pageable, cmd);
return new PageImpl<>(householdsStatus, pageable,
householdsStatus.isEmpty() ? 0 : householdsStatus.get(0).getTotal());
}
}

View File

@@ -9,6 +9,6 @@ import org.springframework.data.domain.Pageable;
@Mapper
public interface GetHouseholdsStatusMapper {
List<GetHouseholdsStatus> getHouseholdsStatus(@Param("pageable")Pageable pageable, @Param("cmd") GetHouseholdsStatusCmd cmd);
List<GetHouseholdsStatus> getHouseholdsStatus(@Param("pageable") Pageable pageable,
@Param("cmd") GetHouseholdsStatusCmd cmd);
}

View File

@@ -0,0 +1,48 @@
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.web;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.GetHouseholdsStatusPortIn;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
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.getHouseholdsStatus.adapters.web.model.GetHouseholdsStatusReqVO;
import app.module.admin.usecase.household.getHouseholdsStatus.adapters.web.model.GetHouseholdsStatusResVO;
@RestController
@RequiredArgsConstructor
class GetHouseholdsStatusController {
private final GetHouseholdsStatusPortIn portIn;
@GetMapping(path = "/api/household/households")
ResponseEntity<Page<GetHouseholdsStatus>> operate(
@PageableDefault(size = 10) Pageable pageable,
GetHouseholdsStatusReqVO reqVO) {
return ResponseEntity.status(HttpStatus.OK).body(
portIn.operate(pageable,
new GetHouseholdsStatusCmd(
reqVO.getRecordMonth(),
reqVO.getOwnerField(),
reqVO.getOwnerValue(),
reqVO.getRegionMainCode(),
reqVO.getRegionSubCode(),
reqVO.getRegionDetailCode(),
reqVO.getIndustryLargeCode(),
reqVO.getIndustryMiddleCode(),
reqVO.getProgressType() != null ? reqVO.getProgressType().name() : null,
reqVO.getIsFirstVisited(),
reqVO.getIsSecondVisited(),
reqVO.getIsGiftSent(),
reqVO.getResearcherField(),
reqVO.getResearcherValue(),
reqVO.getIsPanel()
))
);
}
}

View File

@@ -0,0 +1,44 @@
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.web.model;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.ProgressType;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetHouseholdsStatusReqVO {
// 연월
private String recordMonth;
// 경영주 검색 필드 (전체, 경영주명, 전화번호)
private String ownerField;
// 경영주 검색어
private String ownerValue;
// 실사
private String regionMainCode;
// 지역
private String regionSubCode;
// 세부지역
private String regionDetailCode;
// 업종 대분류
private String industryLargeCode;
// 업종 중분류1
private String industryMiddleCode;
// 당월 일계부 현황 (전체, 25% 미만, 25~50% 미만, 50~75% 미만, 75% 이상, 100% 완료)
private ProgressType progressType;
// 당월 1차 방문 여부
private Boolean isFirstVisited;
// 당월 2차 방문 여부
private Boolean isSecondVisited;
// 답례품 전달
private Boolean isGiftSent;
// 조사원 검색 필드 (전체, 이름, 전화번호)
private String researcherField;
// 조사원 검색어
private String researcherValue;
// 패널 유지 여부
private Boolean isPanel;
}

View File

@@ -0,0 +1,13 @@
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetHouseholdsStatusResVO {
}

View File

@@ -3,11 +3,12 @@ package app.module.admin.usecase.household.getHouseholdsStatus.ports.application
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class GetHouseholdsStatus {
private Integer householdSeq;
@@ -19,9 +20,12 @@ public class GetHouseholdsStatus {
private String regionDetailName;
private String industryLargeName;
private String industryMiddleName;
private Boolean isPanel;
private Double progressPercent;
private String firstVisitDate;
private String secondVisitDate;
private Boolean isGiftSent;
private String researcherName;
private String researcherPhone;
private Integer total;
}

View File

@@ -11,7 +11,7 @@ import lombok.Setter;
@EqualsAndHashCode
public class GetHouseholdsStatusCmd {
// 연월
private String month;
private String recordMonth;
// 경영주 검색 필드 (전체, 경영주명, 전화번호)
private String ownerField;
// 경영주 검색어
@@ -27,7 +27,7 @@ public class GetHouseholdsStatusCmd {
// 업종 중분류1
private String industryMiddleCode;
// 당월 일계부 현황 (전체, 25% 미만, 25~50% 미만, 50~75% 미만, 75% 이상, 100% 완료)
private ProgressType progress;
private String progressType;
// 당월 1차 방문 여부
private Boolean isFirstVisited;
// 당월 2차 방문 여부
@@ -38,4 +38,6 @@ public class GetHouseholdsStatusCmd {
private String researcherField;
// 조사원 검색어
private String researcherValue;
// 패널 유지 여부
private Boolean isPanel;
}

View File

@@ -1,6 +1,9 @@
package app.module.admin.usecase.household.getHouseholdsStatusUI;
import app.module.admin.config.application.util.DateUiUtil;
import app.module.admin.usecase.household.getHouseholdsStatusUI.model.GetHouseholdsUIReqVO;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -10,12 +13,29 @@ import org.springframework.web.bind.annotation.ModelAttribute;
@Controller
@RequiredArgsConstructor
class GetHouseholdsStatusUIController {
private final UICodeListPortIn uiCodeListPortIn;
@GetMapping(path = "/household/households")
String operate(
Model model,
@ModelAttribute("reqVO") GetHouseholdsUIReqVO reqVO) {
// 로그인한 관리자 역할
model.addAttribute("userRole", CommonUtil.getLoginUserRole());
// 실사
model.addAttribute("regionMainList", uiCodeListPortIn.connect("code.region.main"));
// 지역
model.addAttribute("regionSubList", uiCodeListPortIn.connect("code.region.sub"));
// 세부지역
model.addAttribute("regionDetailList", uiCodeListPortIn.connect("code.region.detail"));
// 업종 대분류
model.addAttribute("industryLargeList", uiCodeListPortIn.connect("code.industry.large"));
// 업종 중분류1
model.addAttribute("industryMiddleList", uiCodeListPortIn.connect("code.industry.middle"));
model.addAttribute("monthList", DateUiUtil.getRecentMonths(13));
model.addAttribute("currentMonth", DateUiUtil.getCurrentMonthValue());
return "household/households";
}
}

View File

@@ -1,5 +1,6 @@
package app.module.admin.usecase.household.getHouseholdsStatusUI.model;
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.ProgressType;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -10,4 +11,32 @@ import lombok.Setter;
@AllArgsConstructor
@EqualsAndHashCode
public class GetHouseholdsUIReqVO {
private Integer page;
private String sort;
private Integer size;
private String recordMonth;
private String ownerField;
private String ownerValue;
private String regionMainCode;
private String regionSubCode;
private String regionDetailCode;
private String industryLargeCode;
private String industryMiddleCode;
private ProgressType progressType;
private Boolean isFirstVisited;
private Boolean isSecondVisited;
private Boolean isGiftSent;
private String researcherField;
private String researcherValue;
private Boolean isPanel;
public Integer getPage() {
// 요청 페이지 넘버 - 초기값 `0`
return page != null ? page : 0;
}
public Integer getSize() {
// 페이지 당 아이템 수 - 초기값 `10`
return size != null ? size : 10;
}
}

View File

@@ -0,0 +1,30 @@
<?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.getHouseholdStatus.adapters.persistence.GetHouseholdStatusMapper">
<select id="getHouseholdStatusById"
resultType="app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus">
SELECT
h.seq AS householdSeq,
h.household_num AS householdNum,
h.owner_age AS householdAge,
h.tel AS householdTel,
h.phone AS householdPhone,
h.region_main_name AS regionMainName,
h.region_sub_name AS regionSubName,
h.region_detail_name AS regionDetailName,
h.address AS address,
h.industry_large_name AS industryLargeName,
h.industry_middle_name AS industryMiddleName,
h.industry_sub_middle AS industrySubMiddleName,
h.industry_detail AS industryDetailName,
h.is_panel AS isPanel,
h.memo AS memo,
r.researcher_name AS researcherName,
r.researcher_phone AS researcherPhone
FROM v_household_with_code h
LEFT JOIN v_household_researcher r ON h.seq = r.household_seq
WHERE h.seq = #{seq}
</select>
</mapper>

View File

@@ -6,29 +6,172 @@
<select id="getHouseholdsStatus"
resultType="app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus">
/* getHouseholdsStatus : 임가현황 리스트 조회 */
SELECT
h.seq AS householdSeq,
h.household_num AS householdNum,
h.owner_name AS householdName,
h.phone AS householdPhone,
h.region_main_name AS regionMainName,
h.region_sub_name AS regionSubName,
h.region_detail_name AS regionDetailName,
h.industry_large_name AS industryLargeName,
h.industry_middle_name AS industryMiddleName,
v.first_visit_date AS firstVisitDate,
v.second_visit_date AS secondVisitDate,
v.is_gift_sent AS isGiftSent,
r.researcher_name AS researcherName,
r.researcher_phone AS researcherPhone
FROM v_household_with_code h
LEFT JOIN v_household_visit v ON h.seq = v.household_seq
LEFT JOIN v_household_researcher r ON h.seq = r.household_seq
ORDER BY h.household_num asc
/* getHouseholdsStatus : 임가현황 리스트 조회 */
WITH record_progress AS (
SELECT ROUND(
100.0 *
(SELECT COUNT(*)
FROM daily_record
WHERE record_month = #{cmd.recordMonth} AND all_status = 'DONE')
/ NULLIF(
(SELECT COUNT(*)
FROM daily_day_group
WHERE end_day &lt;= EXTRACT(DAY FROM CURRENT_DATE)), 0
),
1
) AS progress_percent
) /* 일계부 입력 진행 완료 퍼센테이지 (이번달 작성 완료일 수 / 현재날짜 기준 전체 입력 가능 날짜 수) */
-- TODO : where 조건절 추가
SELECT
hvr.*,
COUNT(*) OVER () AS total
FROM (
SELECT
h.seq AS householdSeq,
h.household_num AS householdNum,
h.owner_name AS householdName,
h.phone AS householdPhone,
h.region_main_code AS regionMainCode,
h.region_main_name AS regionMainName,
h.region_sub_code AS regionSubCode,
h.region_sub_name AS regionSubName,
h.region_detail_code AS regionDetailCode,
h.region_detail_name AS regionDetailName,
h.industry_large_code as industryLargeCode,
h.industry_large_name AS industryLargeName,
h.industry_middle_code as industryMiddleCode,
h.industry_middle_name AS industryMiddleName,
h.is_panel AS isPanel,
ps.progress_percent AS progressPercent,
v.first_visit_date AS firstVisitDate,
v.second_visit_date AS secondVisitDate,
COALESCE(v.is_gift_sent, false) AS isGiftSent,
r.researcher_name AS researcherName,
r.researcher_phone AS researcherPhone
FROM v_household_with_code h
LEFT JOIN v_household_visit v ON h.seq = v.household_seq
LEFT JOIN v_household_researcher r ON h.seq = r.household_seq
CROSS JOIN record_progress ps
) AS hvr
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
<where>
1=1
<if test="cmd.ownerField != null and cmd.ownerField != ''">
/* 경영주 검색 */
<choose>
<when test="cmd.ownerField eq 'name'">
AND hvr.householdName ILIKE '%' || #{cmd.ownerValue} || '%'
</when>
<when test="cmd.ownerField eq 'phone'">
AND hvr.householdPhone ILIKE '%' || #{cmd.ownerValue} || '%'
</when>
</choose>
</if>
<if test="cmd.researcherField != null and cmd.researcherField != ''">
/* 조사원 검색 */
<choose>
<when test="cmd.researcherField eq 'name'">
AND hvr.researcherName ILIKE '%' || #{cmd.researcherValue} || '%'
</when>
<when test="cmd.researcherField eq 'phone'">
AND hvr.researcherPhone ILIKE '%' || #{cmd.researcherValue} || '%'
</when>
</choose>
</if>
<if test="cmd.regionMainCode != null and cmd.regionMainCode != ''">
/* 실사 검색 */
AND hvr.regionMainCode = #{cmd.regionMainCode}
</if>
<if test="cmd.regionSubCode != null and cmd.regionSubCode != ''">
/* 지역 검색 */
AND hvr.regionSubCode = #{cmd.regionSubCode}
</if>
<if test="cmd.regionDetailCode != null and cmd.regionDetailCode != ''">
/* 세부지역 검색 */
AND hvr.regionDetailCode = #{cmd.regionDetailCode}
</if>
<if test="cmd.industryLargeCode != null and cmd.industryLargeCode != ''">
/* 업종 대분류 검색 */
AND hvr.industryLargeCode = #{cmd.industryLargeCode}
</if>
<if test="cmd.industryMiddleCode != null and cmd.industryMiddleCode != ''">
/* 업종 중분류1 검색*/
AND hvr.industryMiddleCode = #{cmd.industryMiddleCode}
</if>
<if test="cmd.progressType != null and cmd.progressType != ''">
/* 일계부 현황 퍼센테이지 검색 */
<choose>
<when test="cmd.progressType eq 'PROGRESS_25'">
AND hvr.progressPercent &lt; 25
</when>
<when test="cmd.progressType eq 'PROGRESS_50'">
AND hvr.progressPercent &gt;= 25 AND hvr.progressPercent &lt; 50
</when>
<when test="cmd.progressType eq 'PROGRESS_75'">
AND hvr.progressPercent &gt;= 50 AND hvr.progressPercent &lt; 75
</when>
<when test="cmd.progressType eq 'PROGRESS_75_UP'">
AND hvr.progressPercent &gt; 75
</when>
<when test="cmd.progressType eq 'PROGRESS_100'">
AND hvr.progressPercent = 100
</when>
</choose>
</if>
<if test="cmd.isFirstVisited != null">
/* 당월 1차 방문 여부 */
<choose>
<when test="cmd.isFirstVisited">
AND hvr.firstVisitDate is not null
</when>
<when test="!cmd.isFirstVisited">
AND hvr.firstVisitDate is null
</when>
</choose>
</if>
<if test="cmd.isSecondVisited != null">
/* 당월 2차 방문 여부 */
<choose>
<when test="cmd.isSecondVisited">
AND hvr.secondVisitDate is not null
</when>
<when test="!cmd.isSecondVisited">
AND hvr.secondVisitDate is null
</when>
</choose>
</if>
<if test="cmd.isGiftSent != null">
/* 답례품 전달 여부 */
<choose>
<when test="cmd.isGiftSent">
AND hvr.isGiftSent = true
</when>
<when test="!cmd.isGiftSent">
AND hvr.isGiftSent = false
</when>
</choose>
</if>
<if test="cmd.isPanel != null">
/* 패널 유지 여부 */
<choose>
<when test="cmd.isPanel">
AND hvr.isPanel = true
</when>
<when test="!cmd.isPanel">
AND hvr.isPanel = false
</when>
</choose>
</if>
</where>
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
</select>
</mapper>

View File

@@ -3,7 +3,244 @@
layout:decorate="~{layout/layout}">
<section layout:fragment="content">
<h1>/household/households</h1>
<form autocomplete="off" method="get" name="reqForm" th:action="@{/household/households}"
th:object="${reqVO}">
<input name="page" th:field="*{page}" type="hidden"/>
<input name="size" th:field="*{size}" 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>
<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}">
<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>
<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>
<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>
<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>
<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>
<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>
<label>당월 1차 방문</label>
<select name="isFirstVisited" th:field="*{isFirstVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
<label>당월 2차 방문</label>
<select name="isSecondVisited" th:field="*{isSecondVisited}">
<option value="">전체</option>
<option value="true">방문</option>
<option value="false">미방문</option>
</select>
<label>답례품 전달</label>
<select name="isGiftSent" th:field="*{isGiftSent}">
<option value="">전체</option>
<option value="true">전달</option>
<option value="false">미전달</option>
</select>
<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}">
<label>패널 유지 여부</label>
<select name="isPanel" th:field="*{isPanel}">
<option value="">전체</option>
<option value="true">유지</option>
<option value="false">비유지</option>
</select>
<div>
<button type="reset" onclick="location.href = location.pathname">초기화</button>
<button type="submit">검색</button>
</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;">조사원</th>
<th style="width: 120px;">조사원 휴대전화</th>
</tr>
</thead>
<tbody id="listTBody">
</tbody>
</table>
</form>
<div class="row paging"></div>
<div>
<!-- <button>엑셀 다운로드</button>-->
<!-- <button>임가 등록</button>-->
<!-- <button>조사원 매핑</button>-->
</div>
</section>
<section layout:fragment="script">
<script th:inline="javascript">
// TODO : ajax 공통화 작업 후 수정해야
const getHouseholds = (pageNo) => {
const f = document.reqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/household/households',
data: dataOj,
success(response) {
console.log("response", response);
$('#totalElements').text(response.totalElements);
// List 구성하기
const tbody = $('#listTBody');
tbody.empty();
$(response.content).each((idx, ct) => {
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>${ct.isGiftSent ? "전달" : "미전달"}</td> <!-- 답례품 -->
<td>${isEmpty(ct.researcherName)}</td> <!-- 조사원이름 -->
<td>${isEmpty(ct.researcherPhone)}</td> <!-- 조사원번호 -->
</tr>
`
);
});
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="15" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
</tr>
`);
}
// Pagination 구성하기
const paging = $('.paging');
paging.empty();
paging.append(
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
(movePageNo) => {
f.page.value = movePageNo;
goSearch();
}));
}
})
}
// 최초 리스트 로드
getHouseholds(document.reqForm.page.value);
</script>
<script th:inline="javascript">
const goSearch = () => {
const f = document.reqForm;
f.method = 'GET';
f.submit();
}
</script>
<script>
function isEmpty(value, fallback = '-') {
return value !== null && value !== undefined && value !== '' ? value : fallback;
}
</script>
</section>
</html>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
layout:decorate="~{layout/layout}">
<section layout:fragment="content">
<h1>/household/households/{seq}</h1>
</section>
</html>

View File

@@ -1,6 +1,7 @@
-- DROP VIEW
DROP VIEW v_uicode_view_name;
DROP VIEW v_household_with_code;
DROP VIEW v_household_researcher;
-- CREATE VIEW
@@ -24,7 +25,10 @@ SELECT
h.seq,
h.household_num,
h.owner_name,
h.owner_age,
h.tel,
h.phone,
h.address,
h.region_main_code,
main.code_text AS region_main_name,
h.region_sub_code,
@@ -34,13 +38,18 @@ SELECT
h.industry_large_code,
ind_large.name AS industry_large_name,
h.industry_middle_code,
ind_middle.name AS industry_middle_name
ind_middle.name AS industry_middle_name,
h.industry_sub_middle,
h.industry_detail,
h.is_panel,
h.memo
FROM household h
LEFT JOIN uicode main ON h.region_main_code = main.id
LEFT JOIN uicode main ON h.region_main_code = main.id
LEFT JOIN v_uicode_view_name sub ON h.region_sub_code = sub.id
LEFT JOIN v_uicode_view_name detail ON h.region_detail_code = detail.id
LEFT JOIN v_uicode_view_name ind_large ON h.industry_large_code = ind_large.id
LEFT JOIN v_uicode_view_name ind_middle ON h.industry_middle_code = ind_middle.id;
LEFT JOIN v_uicode_view_name ind_middle ON h.industry_middle_code = ind_middle.id
WHERE h.is_deleted = false;
-- ============================================