Merge branch 'dev' into deploy-dev-admin

This commit is contained in:
kangsunlee
2025-07-21 13:31:59 +09:00
21 changed files with 188 additions and 51 deletions

View File

@@ -6,11 +6,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication @SpringBootApplication
@EnableCaching @EnableCaching
@EnableScheduling
@ComponentScan(basePackages = "app.module") @ComponentScan(basePackages = "app.module")
public class AdminApplication extends SpringBootServletInitializer { public class AdminApplication extends SpringBootServletInitializer {

View File

@@ -3,7 +3,9 @@ package app.module.admin.config.application.batch;
import app.module.admin.usecase.batchLog.ports.BatchLogPortIn; import app.module.admin.usecase.batchLog.ports.BatchLogPortIn;
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType; import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
import app.module.core.config.application.logging.SafeLogger; import app.module.core.config.application.logging.SafeLogger;
import java.net.UnknownHostException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -21,16 +23,24 @@ public class BatchLogRunner {
return; return;
} }
String hostName;
try {
hostName = java.net.InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
hostName = "UNKNOWN";
safeLogger.warn("호스트 이름 조회 실패", e);
}
// 실행 로그 insert (RUNNING) // 실행 로그 insert (RUNNING)
Long logId = batchLogPortIn.create(batchType); Long logId = batchLogPortIn.create(batchType, hostName);
try { try {
action.run(); action.run();
// 성공 처리 // 성공 처리
batchLogPortIn.update(logId, "SUCCESS", null); batchLogPortIn.update(logId, hostName,"SUCCESS", null);
} catch (Exception e) { } catch (Exception e) {
// 실패 처리 // 실패 처리
batchLogPortIn.update(logId, "FAIL", e.getMessage()); batchLogPortIn.update(logId, hostName,"FAIL", e.getMessage());
safeLogger.error("[{}] 배치 실패: {}", batchType.name(), e.getMessage(), e); safeLogger.error("[{}] 배치 실패: {}", batchType.name(), e.getMessage(), e);
} }
} }

View File

@@ -0,0 +1,21 @@
package app.module.admin.config.application.bean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
@EnableScheduling
public class SchedulingConfig {
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(5);
scheduler.setThreadNamePrefix("scheduled-task-");
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setAwaitTerminationSeconds(60);
return scheduler;
}
}

View File

@@ -19,14 +19,19 @@ class BatchLogDao implements BatchLogPortOut {
} }
@Override @Override
public Long create(BatchLogType type) { public Long create(BatchLogType type, String hostName) {
BatchLogCmd cmd = new BatchLogCmd(null, type.name(), "RUNNING", LocalDateTime.now()); BatchLogCmd cmd = new BatchLogCmd(null, type.name(), "RUNNING", LocalDateTime.now(), hostName);
mapper.create(cmd); mapper.create(cmd);
return cmd.getId(); return cmd.getId();
} }
@Override @Override
public void update(Long id, String status, String errorMessage) { public void createError(BatchLogType type, String hostName, String status, String errorMessage) {
mapper.update(id, status, errorMessage); mapper.createError(type.name(), hostName, status, errorMessage);
}
@Override
public void update(Long id, String hostName, String status, String errorMessage) {
mapper.update(id, hostName, status, errorMessage);
} }
} }

View File

@@ -7,5 +7,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface BatchLogMapper { public interface BatchLogMapper {
boolean exists(String type); boolean exists(String type);
Long create(BatchLogCmd cmd); Long create(BatchLogCmd cmd);
void update(Long id, String status, String errorMessage); Long createError(String type, String hostName, String status, String errorMessage);
void update(Long id, String hostName, String status, String errorMessage);
} }

View File

@@ -4,6 +4,7 @@ import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
public interface BatchLogPortIn { public interface BatchLogPortIn {
boolean exists(BatchLogType type); boolean exists(BatchLogType type);
Long create(BatchLogType type); Long create(BatchLogType type, String hostName);
void update(Long id, String status, String errorMessage); void createError(BatchLogType type, String hostName, String status, String errorMessage);
void update(Long id, String hostName, String status, String errorMessage);
} }

View File

@@ -4,6 +4,7 @@ import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
public interface BatchLogPortOut { public interface BatchLogPortOut {
boolean exists(BatchLogType type); boolean exists(BatchLogType type);
Long create(BatchLogType type); Long create(BatchLogType type, String hostName);
void update(Long id, String status, String errorMessage); void createError(BatchLogType type, String hostName, String status, String errorMessage);
void update(Long id, String hostName, String status, String errorMessage);
} }

View File

@@ -17,12 +17,17 @@ class BatchLogService implements BatchLogPortIn {
} }
@Override @Override
public Long create(BatchLogType type) { public Long create(BatchLogType type, String hostName) {
return portOut.create(type); return portOut.create(type, hostName);
} }
@Override @Override
public void update(Long id, String status, String errorMessage) { public void createError(BatchLogType type, String hostName, String status, String errorMessage) {
portOut.update(id, status, errorMessage); portOut.createError(type, hostName, status, errorMessage);
}
@Override
public void update(Long id, String hostName, String status, String errorMessage) {
portOut.update(id, hostName, status, errorMessage);
} }
} }

View File

@@ -16,4 +16,5 @@ public class BatchLogCmd {
private String type; private String type;
private String status; private String status;
private LocalDateTime startAt; private LocalDateTime startAt;
private String hostName;
} }

View File

@@ -10,4 +10,5 @@ public interface CreateHouseholdMapper {
Integer createHousehold(CreateHouseholdOutCmd outCmd); Integer createHousehold(CreateHouseholdOutCmd outCmd);
void createHouseholdHasRole(CreateHouseholdHasRoleCmd cmd); void createHouseholdHasRole(CreateHouseholdHasRoleCmd cmd);
void createResearcherHasHousehold(CreateResearcherHasHouseholdCmd cmd); void createResearcherHasHousehold(CreateResearcherHasHouseholdCmd cmd);
void createHouseholdMonthlyInputStatus();
} }

View File

@@ -131,6 +131,8 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
} }
} }
workbook.close(); workbook.close();
createHouseholdMapper.createHouseholdMonthlyInputStatus();
return new ExcelUploadResultVO(sheet.getLastRowNum()-1 , success, errorList); return new ExcelUploadResultVO(sheet.getLastRowNum()-1 , success, errorList);
} }
@@ -149,6 +151,20 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
if (cell == null) return null; if (cell == null) return null;
return switch (cell.getCellType()) { return switch (cell.getCellType()) {
case NUMERIC -> (int) cell.getNumericCellValue(); case NUMERIC -> (int) cell.getNumericCellValue();
case STRING -> {
try {
yield Integer.parseInt(cell.getStringCellValue().trim());
} catch (NumberFormatException e) {
yield null;
}
}
case FORMULA -> {
try {
yield (int) cell.getNumericCellValue();
} catch (Exception e) {
yield null;
}
}
default -> null; default -> null;
}; };
} }
@@ -195,7 +211,9 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
private Boolean getIsPanel(Cell cell){ private Boolean getIsPanel(Cell cell){
if (cell == null) return null; if (cell == null) return null;
String[] isPanel = cell.getStringCellValue().trim().split("\\."); String[] isPanel = cell.getStringCellValue().trim().split("\\.");
return "1".equals(isPanel[0]) || "유지".equals(isPanel[1]); if(isPanel.length == 1 ) return "1".equals(isPanel[0]) || "유지".equals(isPanel[0]);
if(isPanel.length == 2 ) return "1".equals(isPanel[0]) || "유지".equals(isPanel[1]);
return false;
} }
private Long getResearcherSeq(Cell cell){ private Long getResearcherSeq(Cell cell){

View File

@@ -1,5 +1,7 @@
package app.module.admin.usecase.schedule.autoSchedules.adapters.web; package app.module.admin.usecase.schedule.autoSchedules.adapters.web;
import app.module.admin.usecase.batchLog.ports.BatchLogPortIn;
import app.module.admin.usecase.batchLog.ports.application.domain.BatchLogType;
import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortIn; import app.module.admin.usecase.schedule.autoSchedules.ports.AutoSchedulesPortIn;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -10,9 +12,20 @@ import org.springframework.stereotype.Component;
public class AutoSchedulesController { public class AutoSchedulesController {
private final AutoSchedulesPortIn portIn; private final AutoSchedulesPortIn portIn;
private final BatchLogPortIn batchLogPortIn;
private final java.util.Set<String> runningTasks = java.util.concurrent.ConcurrentHashMap.newKeySet();
public AutoSchedulesController(AutoSchedulesPortIn portIn) { public AutoSchedulesController(AutoSchedulesPortIn portIn, BatchLogPortIn batchLogPortIn) {
this.portIn = portIn; this.portIn = portIn;
this.batchLogPortIn = batchLogPortIn;
}
private boolean isAlreadyRunning(String lockKey) {
return !runningTasks.add(lockKey);
}
private void releaseLock(String lockKey) {
runningTasks.remove(lockKey);
} }
/** /**
@@ -20,18 +33,30 @@ public class AutoSchedulesController {
* 매 월 1일 0초 마다 실행되는 스케줄러 * 매 월 1일 0초 마다 실행되는 스케줄러
*/ */
//@Scheduled(cron = "0 0 0 1 * *") //@Scheduled(cron = "0 0 0 1 * *")
@Scheduled(cron = "1 0 0 19,20 * *") @Scheduled(cron = "0 0 * * * *")
public void fetchMonthlyStatus() { public void fetchMonthlyStatus() {
String lockKey = "fetchMonthlyStatus_" + java.time.LocalDate.now();
try { try {
String host = java.net.InetAddress.getLocalHost().getHostName(); String host = java.net.InetAddress.getLocalHost().getHostName();
// 중복 실행 방지를 위한 간단한 체크
if (isAlreadyRunning(lockKey)) {
log.warn("fetchMonthlyStatus가 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
batchLogPortIn.createError(BatchLogType.MONTHLY_STATUS, host, "WARNING", "fetchMonthlyStatus가 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
return;
}
log.info("스케줄 실행 : fetchMonthlyStatus / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName()); log.info("스케줄 실행 : fetchMonthlyStatus / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName());
portIn.operate(); portIn.operate();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally {
log.info("스케줄 종료 : fetchMonthlyStatus / {}", lockKey);
releaseLock(lockKey);
} }
} }
@@ -41,16 +66,28 @@ public class AutoSchedulesController {
*/ */
@Scheduled(cron = "0 0 17 * * ?") @Scheduled(cron = "0 0 17 * * ?")
public void fetchSmsAutoSend() { public void fetchSmsAutoSend() {
String lockKey = "fetchSmsAutoSend" + java.time.LocalDate.now();
try { try {
String host = java.net.InetAddress.getLocalHost().getHostName(); String host = java.net.InetAddress.getLocalHost().getHostName();
// 중복 실행 방지를 위한 간단한 체크
if (isAlreadyRunning(lockKey)) {
log.warn("fetchSmsAutoSend 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
batchLogPortIn.createError(BatchLogType.AUTO_SMS, host, "WARNING", "fetchSmsAutoSend 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
return;
}
log.info("스케줄 실행 : fetchSmsAutoSend / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName()); log.info("스케줄 실행 : fetchSmsAutoSend / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName());
portIn.sendAutoSms(); portIn.sendAutoSms();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally {
log.info("스케줄 종료 : fetchSmsAutoSend / {}", lockKey);
releaseLock(lockKey);
} }
} }
@@ -59,18 +96,30 @@ public class AutoSchedulesController {
* 매월 16일 0시 0초에 실행되는 스케줄러 * 매월 16일 0시 0초에 실행되는 스케줄러
*/ */
// @Scheduled(cron = "0 0 0 16 * *") // @Scheduled(cron = "0 0 0 16 * *")
@Scheduled(cron = "0 0 0 19,20 * *") @Scheduled(cron = "0 0 * * * *")
public void fetchMonthlyCarryOver() { public void fetchMonthlyCarryOver() {
String lockKey = "fetchMonthlyCarryOver_" + java.time.LocalDate.now();
try { try {
String host = java.net.InetAddress.getLocalHost().getHostName(); String host = java.net.InetAddress.getLocalHost().getHostName();
// 중복 실행 방지를 위한 간단한 체크
if (isAlreadyRunning(lockKey)) {
log.warn("fetchMonthlyCarryOver가 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
batchLogPortIn.createError(BatchLogType.CARRYOVER, host, "WARNING", "fetchMonthlyCarryOver가 이미 실행 중입니다. 중복 실행을 건너뜁니다.");
return;
}
log.info("스케줄 실행 : fetchMonthlyCarryOver / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName()); log.info("스케줄 실행 : fetchMonthlyCarryOver / {} / {} / {} / {}", host, this, + System.identityHashCode(this), Thread.currentThread().getName());
portIn.monthlyCarryOver(); portIn.monthlyCarryOver();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally {
log.info("스케줄 종료 : fetchMonthlyCarryOver / {}", lockKey);
releaseLock(lockKey);
} }
} }
} }

View File

@@ -23,9 +23,9 @@ spring:
password: ENC(uBHyXdI39UzPNvYNHDGfjmMMuhN83xoP8F3wDq/S9DxizhFwbMeEqa36oZ205CBg) password: ENC(uBHyXdI39UzPNvYNHDGfjmMMuhN83xoP8F3wDq/S9DxizhFwbMeEqa36oZ205CBg)
mms: mms:
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
jdbc-url: jdbc:postgresql://15.165.180.203:5432/ko_research_hyunjoo jdbc-url: ENC(TZ7H8DIFZDbsNp3PRWbz3bkJbjsx3580ljmELMJInASgpiEH66Lb8adpjt5WGXoIdZbHetlgtEFo8F+U8XUa9fjYWNOpiZ+D99XoXJUOP3s=)
username: hyunjoo username: ENC(cNXntROGOeM115QfLlVhhBz8+qY70eTWwmwLM+7AMslWmfWTq9ZPl4pVnDopJauM)
password: hyunjoo1@#4 password: ENC(kUIzqWTu0+bqjYH4Jq9TFOOh3UwY+XVvA2OlT4VXJvxWCas66UNdGRmWDQKri5fI)
maximum-pool-size: 2 maximum-pool-size: 2
minimum-idle: 1 minimum-idle: 1

View File

@@ -19,8 +19,18 @@
SELECT nextval('batch_log_seq') SELECT nextval('batch_log_seq')
</selectKey> </selectKey>
INSERT INTO batch_log (id, type, status, start_at, created_at) INSERT INTO batch_log (id, type, status, start_at, created_at, created_host)
VALUES (#{id}, #{type}, #{status}, #{startAt}, now()) VALUES (#{id}, #{type}, #{status}, #{startAt}, now(), #{hostName})
</insert>
<!-- 에러 로그 insert -->
<insert id="createError">
<selectKey keyProperty="id" resultType="long" order="BEFORE">
SELECT nextval('batch_log_seq')
</selectKey>
INSERT INTO batch_log (id, type, status, error_message, start_at, created_at, created_host)
VALUES (#{id}, #{type}, #{status}, #{errorMessage}, now(), now(), #{hostName})
</insert> </insert>
<!-- 상태 업데이트 --> <!-- 상태 업데이트 -->
@@ -28,7 +38,8 @@
UPDATE batch_log UPDATE batch_log
SET status = #{status}, SET status = #{status},
error_message = #{errorMessage}, error_message = #{errorMessage},
end_at = now() end_at = now(),
created_host = #{hostName}
WHERE id = #{id} WHERE id = #{id}
</update> </update>
</mapper> </mapper>

View File

@@ -6,7 +6,7 @@
<select id="selectTotalPercentage"> <select id="selectTotalPercentage">
SELECT SELECT
COUNT(DISTINCT h.seq) as total_household_count, COUNT(DISTINCT h.seq) as total_household_count,
COALESCE(ROUND(AVG(cr.completion_rate), 1), 0) AS daily_percent, COALESCE(ROUND(AVG(cr.current_completion_rate), 1), 0) AS daily_percent,
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count, COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1) , 0 ) as visit_percent, COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1) , 0 ) as visit_percent,
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count, COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
@@ -27,7 +27,7 @@
<select id="selectTotalPercentageResearcher"> <select id="selectTotalPercentageResearcher">
SELECT SELECT
COUNT(DISTINCT rhh.household_seq) as total_household_count, COUNT(DISTINCT rhh.household_seq) as total_household_count,
COALESCE(ROUND(AVG(cr.completion_rate), 1), 0) AS daily_percent, COALESCE(ROUND(AVG(cr.current_completion_rate), 1), 0) AS daily_percent,
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count, COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT rhh.household_seq), 0), 1),0) as visit_percent, COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT rhh.household_seq), 0), 1),0) as visit_percent,
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count, COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
@@ -51,7 +51,7 @@
COALESCE(u.code_text, '전체') AS region_name, COALESCE(u.code_text, '전체') AS region_name,
COUNT(DISTINCT a.seq) AS researcher_count, COUNT(DISTINCT a.seq) AS researcher_count,
COUNT(DISTINCT rhh.household_seq) AS total_household_count, COUNT(DISTINCT rhh.household_seq) AS total_household_count,
COALESCE(ROUND(AVG(v.completion_rate), 1), 0) AS daily_percent, COALESCE(ROUND(AVG(v.current_completion_rate), 1), 0) AS daily_percent,
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count, COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT rhh.household_seq),0), 1),0) as visit_percent, COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq end) * 100::numeric / NULLIF(COUNT(DISTINCT rhh.household_seq),0), 1),0) as visit_percent,
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count, COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
@@ -91,7 +91,7 @@
NULLIF(a.name,'-') AS researcher_name, NULLIF(a.name,'-') AS researcher_name,
u.code_text AS region_main_code_name, u.code_text AS region_main_code_name,
COUNT(DISTINCT h.seq) AS total_household_count, COUNT(DISTINCT h.seq) AS total_household_count,
COALESCE(ROUND(AVG(cr.completion_rate), 1), 0) AS daily_percent, COALESCE(ROUND(AVG(cr.current_completion_rate), 1), 0) AS daily_percent,
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count, COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS total_visit_count,
COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1),0) AS visit_percent, COALESCE(ROUND(COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) * 100::numeric / NULLIF(COUNT(DISTINCT h.seq), 0), 1),0) AS visit_percent,
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count, COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END) AS total_gift_sent_count,
@@ -121,7 +121,7 @@
COUNT(DISTINCT a.seq) AS researcher_count, COUNT(DISTINCT a.seq) AS researcher_count,
COUNT(DISTINCT rhh.household_seq) AS household_count, COUNT(DISTINCT rhh.household_seq) AS household_count,
CASE CASE
WHEN COALESCE(AVG(v.completion_rate), 0) > 0 THEN ROUND(COALESCE(AVG(v.completion_rate), 0), 1) WHEN COALESCE(AVG(v.current_completion_rate), 0) > 0 THEN ROUND(COALESCE(AVG(v.current_completion_rate), 0), 1)
ELSE 0 ELSE 0
END AS avg_completion_rate, END AS avg_completion_rate,
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS visit_count, COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END) AS visit_count,
@@ -160,7 +160,7 @@
'전체' AS region_name, '전체' AS region_name,
COUNT(DISTINCT a.seq), COUNT(DISTINCT a.seq),
COUNT(DISTINCT rhh.household_seq), COUNT(DISTINCT rhh.household_seq),
COALESCE(ROUND(AVG(v.completion_rate), 1), 0), COALESCE(ROUND(AVG(v.current_completion_rate), 1), 0),
COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END), COUNT(DISTINCT CASE WHEN hv.id IS NOT NULL THEN hv.household_seq END),
COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END), COUNT(DISTINCT CASE WHEN hv.is_gift_sent = true THEN hv.household_seq END),
-1 as order_no -1 as order_no
@@ -202,7 +202,7 @@
parent_uicode.code_text AS region_name, parent_uicode.code_text AS region_name,
COUNT(DISTINCT rhh.household_seq) AS household_count, COUNT(DISTINCT rhh.household_seq) AS household_count,
CASE CASE
WHEN AVG(v.completion_rate) > 0 THEN ROUND(AVG(v.completion_rate), 1) WHEN AVG(v.current_completion_rate) > 0 THEN ROUND(AVG(v.current_completion_rate), 1)
ELSE 0 ELSE 0
END AS avg_completion_rate, END AS avg_completion_rate,
COUNT(DISTINCT hv_visit.household_seq) AS visit_count, COUNT(DISTINCT hv_visit.household_seq) AS visit_count,
@@ -242,7 +242,7 @@
'전체' AS region_detail_name, '전체' AS region_detail_name,
'전체' AS region_name, '전체' AS region_name,
COUNT(DISTINCT rhh.household_seq) AS household_count, COUNT(DISTINCT rhh.household_seq) AS household_count,
COALESCE(ROUND(AVG(v.completion_rate), 1), 0), COALESCE(ROUND(AVG(v.current_completion_rate), 1), 0),
COUNT(DISTINCT hv_visit.household_seq), COUNT(DISTINCT hv_visit.household_seq),
COUNT(DISTINCT hv_gift.household_seq), COUNT(DISTINCT hv_gift.household_seq),
-1 AS region_order, -1 AS region_order,

View File

@@ -93,4 +93,8 @@
<include refid="common.fields.CreateUpdateBaseValues"/> <include refid="common.fields.CreateUpdateBaseValues"/>
) )
</insert> </insert>
<select id="createHouseholdMonthlyInputStatus">
select fn_monthly_input_status()
</select>
</mapper> </mapper>

View File

@@ -74,6 +74,7 @@
ajaxUtil._hideWaiting(); // 로딩바 hide ajaxUtil._hideWaiting(); // 로딩바 hide
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다."); alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
document.querySelector(".modal-excel-household").ui.close();
}, },
statusCode: { statusCode: {
422: (res) => { 422: (res) => {

View File

@@ -401,6 +401,7 @@ CREATE TABLE batch_log (
end_at TIMESTAMP, end_at TIMESTAMP,
error_message VARCHAR(2000), error_message VARCHAR(2000),
created_at TIMESTAMP DEFAULT now(), created_at TIMESTAMP DEFAULT now(),
created_host VARCHAR(100),
CONSTRAINT batch_log_pkey PRIMARY KEY (id) CONSTRAINT batch_log_pkey PRIMARY KEY (id)
); );
@@ -412,6 +413,7 @@ COMMENT ON COLUMN batch_log.start_at IS '배치 시작 시간';
COMMENT ON COLUMN batch_log.end_at IS '배치 종료 시간'; COMMENT ON COLUMN batch_log.end_at IS '배치 종료 시간';
COMMENT ON COLUMN batch_log.error_message IS '에러 메시지 (실패한 경우)'; COMMENT ON COLUMN batch_log.error_message IS '에러 메시지 (실패한 경우)';
COMMENT ON COLUMN batch_log.created_at IS '생성일'; COMMENT ON COLUMN batch_log.created_at IS '생성일';
COMMENT ON COLUMN batch_log.created_host IS '생성HOST';
@@ -564,7 +566,7 @@ AS SELECT daily_record.household_seq,
-- ============================================ -- ============================================
-- DROP VIEW public.v_household_monthly_target_days; -- DROP VIEW public.v_household_monthly_target_days;
CREATE OR REPLACE VIEW public.v_household_monthly_target_days CREATE OR REPLACE VIEW public.v_household_monthly_target_days
AS WITH param_matrix AS ( as WITH param_matrix AS (
SELECT h.seq AS household_seq, SELECT h.seq AS household_seq,
r.record_month, r.record_month,
EXTRACT(day FROM date_trunc('month'::text, to_date(r.record_month::text, 'YYYYMM'::text)::timestamp with time zone) + '1 mon -1 days'::interval)::integer AS last_day EXTRACT(day FROM date_trunc('month'::text, to_date(r.record_month::text, 'YYYYMM'::text)::timestamp with time zone) + '1 mon -1 days'::interval)::integer AS last_day
@@ -575,7 +577,8 @@ AS WITH param_matrix AS (
) )
SELECT p.household_seq, SELECT p.household_seq,
p.record_month, p.record_month,
count(*) AS total_day_groups count(*) AS total_day_groups,
case when to_char(CURRENT_DATE,'YYYYMM')::text = p.record_month then sum(case when to_char(CURRENT_DATE,'dd')::integer >= g.start_day then 1 else 0 end)else count(*) end as current_day_groups
FROM param_matrix p FROM param_matrix p
JOIN daily_day_group g ON g.start_day <= p.last_day JOIN daily_day_group g ON g.start_day <= p.last_day
GROUP BY p.household_seq, p.record_month; GROUP BY p.household_seq, p.record_month;
@@ -675,14 +678,16 @@ AS WITH ranked_visits AS (
-- ============================================ -- ============================================
-- DROP VIEW public.v_monthly_completion_rate; -- DROP VIEW public.v_monthly_completion_rate;
CREATE OR REPLACE VIEW public.v_monthly_completion_rate CREATE OR REPLACE VIEW public.v_monthly_completion_rate
AS SELECT d.household_seq, as SELECT d.household_seq,
d.record_month, d.record_month,
COALESCE(c.completed_day_groups, 0::bigint) AS completed_day_groups, COALESCE(c.completed_day_groups, 0::bigint) AS completed_day_groups,
d.total_day_groups, d.total_day_groups,
round(COALESCE(c.completed_day_groups, 0::bigint)::numeric * 100::numeric / NULLIF(d.total_day_groups, 0)::numeric, 3) AS completion_rate round(COALESCE(c.completed_day_groups, 0::bigint)::numeric * 100::numeric / NULLIF(d.total_day_groups, 0)::numeric, 3) AS completion_rate,
FROM v_household_monthly_target_days d d.current_day_groups,
round(COALESCE(c.completed_day_groups, 0::bigint)::numeric * 100::numeric / NULLIF(d.current_day_groups, 0)::numeric, 3) AS current_completion_rate
FROM v_household_monthly_target_days d
LEFT JOIN v_household_monthly_completed_days c ON d.household_seq = c.household_seq AND d.record_month::text = c.record_month::text LEFT JOIN v_household_monthly_completed_days c ON d.household_seq = c.household_seq AND d.record_month::text = c.record_month::text
ORDER BY d.household_seq, d.record_month; ORDER BY d.household_seq, d.record_month;
-- ============================================ -- ============================================

View File

@@ -35,7 +35,7 @@ public class DailyForestryService implements DailyForestryPortIn {
@Override @Override
public List<DailyForestryDto> list(DailyForestryUIReqVO reqVO) { public List<DailyForestryDto> list(DailyForestryUIReqVO reqVO) {
return this.getRefineList(reqVO, false); return this.getRefineList(reqVO, true);
} }
@Override @Override

View File

@@ -13,7 +13,8 @@
<ul class="product-col-list"> <ul class="product-col-list">
<li th:each="item : ${list.content}" <li th:each="item : ${list.content}"
th:classappend="${item.forestProductStatus != MonthStatus.NONE} ? ' complete'"> th:class="|${item?.forestProductStatus == MonthStatus.REGISTERED ? 'complete' :
item?.forestProductStatus == MonthStatus.NOTHING ? 'complete-nodata' : ''}|">
<a th:href="@{/info/monthly/create/{id}(id=${item.id})}"> <a th:href="@{/info/monthly/create/{id}(id=${item.id})}">
<p class="list-tit" th:text="${item.koreanMonth}"></p> <p class="list-tit" th:text="${item.koreanMonth}"></p>
<span class="tag" th:text="${item.forestProductStatus.desc}"></span> <span class="tag" th:text="${item.forestProductStatus.desc}"></span>

View File

@@ -49,7 +49,7 @@
<div id="tel1Id" class="component-select bottom-sheet" <div id="tel1Id" class="component-select bottom-sheet"
th:data-props-default="${userInfo.tel1}" data-props-type="bottomSheet"> th:data-props-default="${userInfo.tel1}" data-props-type="bottomSheet">
<input type="hidden" name="tel1" th:field="*{tel1}" data-type="select"> <input type="hidden" id="tel1" name="tel1" th:value="${userInfo.tel1}" data-type="select">
<button type="button" class="select-box"> <button type="button" class="select-box">
<span class="select-txt"></span> <span class="select-txt"></span>
</button> </button>
@@ -345,7 +345,7 @@
ENV.module.confirmPopup = document.querySelector(".confirmPopup").ui; ENV.module.confirmPopup = document.querySelector(".confirmPopup").ui;
const $selectTel = document.querySelector('#tel1Id'); const $selectTel = document.querySelector('#tel1Id');
ENV.select.selectTel = new etUI.components.SelectBox(); ENV.select.selectTel = $selectTel.ui;
ENV.select.selectTel.core.init($selectTel, { ENV.select.selectTel.core.init($selectTel, {
selectItemCallback({selectValue, dataValue}){ selectItemCallback({selectValue, dataValue}){
document.querySelector('#tel1').value = dataValue; document.querySelector('#tel1').value = dataValue;
@@ -375,10 +375,14 @@
const errors = []; const errors = [];
if (!form.ownerName.value) errors.push({field: 'ownerName', message: '이름을 입력해 주세요.'}); if (!form.ownerName.value) errors.push({field: 'ownerName', message: '이름을 입력해 주세요.'});
if (!form.ownerAge.value) errors.push({field: 'ownerAge', message: '연령을 입력해 주세요.'}); if (!form.ownerAge.value) errors.push({field: 'ownerAge', message: '연령을 입력해 주세요.'});
if (form.ownerAge.value < 0 || form.ownerAge.value > 120) errors.push({field: 'ownerAge', message: '연령은 0세이상 120세 이하이어야 합니다.'}); if (form.ownerAge.value < 0 || form.ownerAge.value > 120) errors.push({field: 'ownerAge', message: '연령은 0세이상 120세 이하이어야 합니다.'});
if (form.tel1.value || form.tel2.value || form.tel3.value) { if (form.tel1.value || form.tel2.value || form.tel3.value) {
if (!form.tel1.value || !form.tel2.value || !form.tel3.value) { if (!form.tel1.value || !form.tel2.value || !form.tel3.value) {
errors.push({ field: 'tel1', message: '가구 연락처를 모두 입력해 주세요.' }); if (!form.tel1.value || !form.tel2.value) {
errors.push({ field: 'tel2', message: '가구 연락처를 모두 입력해 주세요.' });
} else {
errors.push({ field: 'tel3', message: '가구 연락처를 모두 입력해 주세요.' });
}
} else { } else {
const telRegex = /^(0[2-7][0-9]?)$/; // 지역번호 (예: 02, 031, 032 등) const telRegex = /^(0[2-7][0-9]?)$/; // 지역번호 (예: 02, 031, 032 등)
if (!telRegex.test(form.tel1.value)) errors.push({ field: 'tel1', message: '가구 연락처를 입력해주세요' }); // 유효한 지역번호를 선택해 주세요. if (!telRegex.test(form.tel1.value)) errors.push({ field: 'tel1', message: '가구 연락처를 입력해주세요' }); // 유효한 지역번호를 선택해 주세요.