Merge branch 'susu' into dev

This commit is contained in:
주수현
2025-07-23 14:28:10 +09:00
10 changed files with 104 additions and 72 deletions

View File

@@ -128,9 +128,6 @@
<div class="component-btns bottom-btn-group"> <div class="component-btns bottom-btn-group">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button class="btn" onclick="showAdminExcelUploadModal();" type="button">
<span class="btn-txt">엑셀 업로드</span>
</button>
<!-- <button class="btn" onclick="goExcel();" type="button"><span class="btn-txt" th:unless="${activeProfile != 'local'}">엑셀 다운로드</span></button>--> <!-- <button class="btn" onclick="goExcel();" type="button"><span class="btn-txt" th:unless="${activeProfile != 'local'}">엑셀 다운로드</span></button>-->
<button class="btn" onclick="location.href='/settings/admins/create';" type="button"><span class="btn-txt">등록</span></button> <button class="btn" onclick="location.href='/settings/admins/create';" type="button"><span class="btn-txt">등록</span></button>
<button class="btn" onclick="goRemove();" type="button"><span class="btn-txt">삭제</span></button> <button class="btn" onclick="goRemove();" type="button"><span class="btn-txt">삭제</span></button>
@@ -138,7 +135,6 @@
</div> </div>
</section> </section>
<div th:replace="admin/modal/modal-admin-excel:: modalFragment"></div>
</form> </form>
</section> </section>
@@ -214,61 +210,6 @@
// f.submit(); // f.submit();
// } // }
function showAdminExcelUploadModal() {
const modal = document.querySelector(".modal-admin-excel");
const fileInput = document.getElementById("file");
if (fileInput) {
fileInput.value = '';
}
modal.ui.open();
}
const uploadAdminExcel = () => {
event.preventDefault();
const fileInput = document.getElementById('file');
if (fileInput.files.length === 0) {
alert('업로드할 엑셀 파일을 선택해주세요.');
return;
}
let formData = new FormData();
formData.append('file', fileInput.files[0]);
$.ajax({
method: 'POST',
url: '/api/settings/admin/excelUpload',
data: formData,
contentType: false, // * 중요 *
processData: false, // * 중요 *
enctype: 'multipart/form-data', // * 중요 *
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
},
statusCode: {
400:() => {
ajaxUtil._hideWaiting();
alert("잘못된 엑셀파일입니다.");
document.querySelector(".modal-admin-excel").ui.close();
},
500: () => {
ajaxUtil._hideWaiting();
alert("엑셀 업로드에 실패하였습니다.");
document.querySelector(".modal-admin-excel").ui.close();
}
}
});
};
const closeModal = () => {
document.querySelector(".modal-admin-excel").ui.close();
};
</script> </script>
</section> </section>

View File

@@ -3,12 +3,12 @@
layout:decorate="~{layout/layout}"> layout:decorate="~{layout/layout}">
<div class="layer-wrap" th:fragment="modalFragment"> <div class="layer-wrap" th:fragment="modalFragment">
<div class="component-modal modal01 modal-admin-excel" id="test" data-props-dimm-click="true" data-state="close"> <div class="component-modal modal01 modal-researcher-excel" id="test" data-props-dimm-click="true" data-state="close">
<div class="modal-dimm"></div> <div class="modal-dimm"></div>
<div class="modal-frame"> <div class="modal-frame">
<div class="modal-container type-small"> <div class="modal-container type-small">
<div class="modal-header"> <div class="modal-header">
<h3 class="modal-tit" >관리자 등록 엑셀업로드</h3> <h3 class="modal-tit">조사원 등록 엑셀업로드</h3>
</div> </div>
<div class="modal-content"> <div class="modal-content">
<div class="modal-content-inner"> <div class="modal-content-inner">
@@ -19,7 +19,7 @@
</label> </label>
<div class="component-btns bottom-btn-group" th:fragment="modalButtons"> <div class="component-btns bottom-btn-group" th:fragment="modalButtons">
<div class="btns-row align-right"> <div class="btns-row align-right">
<button type="button" class="btn btn-primary" onclick="uploadAdminExcel()"> <button type="button" class="btn btn-primary" onclick="uploadExcel()">
<span class="btn-txt">등록</span> <span class="btn-txt">등록</span>
</button> </button>
</div> </div>

View File

@@ -97,11 +97,15 @@
<div class="component-btns bottom-btn-group" > <div class="component-btns bottom-btn-group" >
<div class="btns-row align-right"> <div class="btns-row align-right">
<button class="btn" onclick="showExcelUploadModal();" type="button">
<span class="btn-txt">엑셀 업로드</span>
</button>
<button type="button" class="btn" onclick="goExcel();"> <button type="button" class="btn" onclick="goExcel();">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span> <span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
</button> </button>
</div> </div>
</div> </div>
<div th:replace="researcher/modal/modal-researcher-excel:: modalFragment"></div>
</form> </form>
</section> </section>
@@ -238,6 +242,61 @@
}); });
} }
} }
function showExcelUploadModal() {
const modal = document.querySelector(".modal-researcher-excel");
const fileInput = document.getElementById("file");
if (fileInput) {
fileInput.value = '';
}
modal.ui.open();
}
const uploadExcel = () => {
event.preventDefault();
const fileInput = document.getElementById('file');
if (fileInput.files.length === 0) {
alert('업로드할 엑셀 파일을 선택해주세요.');
return;
}
let formData = new FormData();
formData.append('file', fileInput.files[0]);
$.ajax({
method: 'POST',
url: '/api/settings/admin/excelUpload',
data: formData,
contentType: false, // * 중요 *
processData: false, // * 중요 *
enctype: 'multipart/form-data', // * 중요 *
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert("총 "+res.total+"건 중에 "+res.success+"건 등록되었습니다.");
},
statusCode: {
400:() => {
ajaxUtil._hideWaiting();
alert("잘못된 엑셀파일입니다.");
document.querySelector(".modal-researcher-excel").ui.close();
},
500: () => {
ajaxUtil._hideWaiting();
alert("엑셀 업로드에 실패하였습니다.");
document.querySelector(".modal-researcher-excel").ui.close();
}
}
});
};
const closeModal = () => {
document.querySelector(".modal-researcher-excel").ui.close();
};
</script> </script>
</section> </section>

View File

@@ -42,4 +42,9 @@ public final class CommonConstants {
*/ */
public static final String VALID_CODE_NOTBLANK = "valid.common.required"; public static final String VALID_CODE_NOTBLANK = "valid.common.required";
/**
* 핸드폰 번호 규칙
*/
public static final String PHONE_REGEX = "^01([0|1|6|7|8|9])-?([0-9]{3,4})-?([0-9]{4})$";
} }

View File

@@ -1,7 +1,9 @@
package app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence; package app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence;
import app.module.core.config.application.logging.SafeLogger;
import app.module.core.config.application.util.AuditUtil; import app.module.core.config.application.util.AuditUtil;
import app.module.core.config.application.util.CommonUtil; import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.constants.CommonConstants;
import app.module.core.usecase.admin.checkAdminId.persistence.CheckAdminIdMapper; import app.module.core.usecase.admin.checkAdminId.persistence.CheckAdminIdMapper;
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelAdminCreateVO; import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelAdminCreateVO;
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelResultVO; import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelResultVO;
@@ -13,6 +15,7 @@ import app.module.core.usecase.uicode.list.adapters.persistence.UICodeListMapper
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement; import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -21,11 +24,14 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut { class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
SafeLogger safeLogger = new SafeLogger(LoggerFactory.getLogger(ExcelSaveAdminIdDao.class));
@Value("${spring.profiles.active}") @Value("${spring.profiles.active}")
private String activeProfiles; private String activeProfiles;
@@ -42,6 +48,8 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
Integer success = 0; Integer success = 0;
List<UICodeElement> uiCodeElementList = uiCodeListMapper.findByParentId("code.region.main", CommonUtil.getLoginUserRole(),activeProfiles); List<UICodeElement> uiCodeElementList = uiCodeListMapper.findByParentId("code.region.main", CommonUtil.getLoginUserRole(),activeProfiles);
List<String> errorList = new ArrayList<>();
// 첫 번째 행은 헤더로 간주하고 스킵 // 첫 번째 행은 헤더로 간주하고 스킵
for (int i = 1; i <= sheet.getLastRowNum(); i++) { for (int i = 1; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i); Row row = sheet.getRow(i);
@@ -57,7 +65,14 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
Integer duplicate = checkAdminIdMapper.checkAdminId(admin.getId()); Integer duplicate = checkAdminIdMapper.checkAdminId(admin.getId());
if(duplicate == 0) { if(duplicate == 0
&& !admin.getId().isEmpty()
&& admin.getId().matches(CommonConstants.ADMIN_ID_REGEX)
&& !admin.getRoleId().isEmpty()
&& !admin.getPassword().isEmpty()
&& admin.getPassword().matches(CommonConstants.ADMIN_PASSWORD_REGEX)
&& !admin.getPhone().isEmpty()
&& admin.getPhone().matches(CommonConstants.PHONE_REGEX) ) {
SaveAdminCmd cmd = new SaveAdminCmd( SaveAdminCmd cmd = new SaveAdminCmd(
null, null,
admin.getId(), admin.getId(),
@@ -76,6 +91,18 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
saveAdminMapper.insertAdminHasRoles( saveAdminMapper.insertAdminHasRoles(
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), admin.getRoleId()))); AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), admin.getRoleId())));
} }
}else{
errorList.add(admin.getId());
safeLogger.warn(
"[EXCEL 누락] 관리자 아이디={} 필수 필드 누락: duplicate={}, role={}, name={}, password={}, regionMainCode={}, phone={} ",
admin.getId(),
duplicate == 0,
admin.getRoleId(),
admin.getName(),
admin.getPassword(),
admin.getRegionMainCode(),
admin.getPhone()
);
} }
} }
@@ -99,7 +126,7 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
case "관리자" -> "ROLE_ADMIN"; case "관리자" -> "ROLE_ADMIN";
case "지방실사" -> "ROLE_LOCAL_INSPECTOR"; case "지방실사" -> "ROLE_LOCAL_INSPECTOR";
case "조사원" -> "ROLE_RESEARCHER"; case "조사원" -> "ROLE_RESEARCHER";
default -> ""; default -> null;
}; };
} }
@@ -108,7 +135,7 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
return uiCodeElementList.stream().filter(code -> code.getCodeText().equals(cell.getStringCellValue().trim())) return uiCodeElementList.stream().filter(code -> code.getCodeText().equals(cell.getStringCellValue().trim()))
.findFirst() .findFirst()
.map(UICodeElement::getId).orElse(""); .map(UICodeElement::getId).orElse(null);
} }
} }

View File

@@ -608,7 +608,7 @@ 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 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;

View File

@@ -62,9 +62,9 @@
<when test="order.property eq 'endDate'">a.end_date</when> <when test="order.property eq 'endDate'">a.end_date</when>
<when test="order.property eq 'updatedBy'">a.updated_by</when> <when test="order.property eq 'updatedBy'">a.updated_by</when>
<when test="order.property eq 'updatedAt'">a.updated_at</when> <when test="order.property eq 'updatedAt'">a.updated_at</when>
<when test="order.property eq 'createdBy'">a.created_by</when> <when test="order.property eq 'createdBy'">a.created_by</when>
<when test="order.property eq 'createdAt'">a.created_at</when> <when test="order.property eq 'createdAt'">a.created_at</when>
<otherwise>a.id</otherwise> <otherwise>a.id</otherwise>
</choose> </choose>
<choose> <choose>
<when test="order.direction.toString() eq 'DESC'">DESC</when> <when test="order.direction.toString() eq 'DESC'">DESC</when>

View File

@@ -144,7 +144,7 @@
<script th:inline="javascript"> <script th:inline="javascript">
let ENV = { let ENV = {
httpUrl: { httpUrl: {
root: /*[[|/record/daily/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl', root: /*[[|/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
form: /*[[|/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl', form: /*[[|/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
create: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl', create: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
remove: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl', remove: /*[[|/api/record/expense/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',

View File

@@ -158,7 +158,7 @@
<script th:inline="javascript"> <script th:inline="javascript">
let ENV = { let ENV = {
httpUrl: { httpUrl: {
root: /*[[|/record/daily/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl', root: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}|]]*/'rootUrl',
form: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl', form: /*[[|/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'formUrl',
create: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl', create: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/form/{id}|]]*/'createUrl',
remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl', remove: /*[[|/api/record/income/${reqVO.searchMonth}/${reqVO.groupNo}/remove|]]*/'removeUrl',

View File

@@ -23,7 +23,7 @@
<p th:if="${#lists.isEmpty(workList)}">임업노동 투입 내역을 등록해 주세요.</p> <p th:if="${#lists.isEmpty(workList)}">임업노동 투입 내역을 등록해 주세요.</p>
<p th:unless="${#lists.isEmpty(workList)}">등록 내용을 확인하거나 다음 단계로 이동하세요.</p> <p th:unless="${#lists.isEmpty(workList)}">등록 내용을 확인하거나 다음 단계로 이동하세요.</p>
</hgroup> </hgroup>
-
<!--/* 신규 등록 : dailyRecord.modifiable=false 수정 기간 아님 */--> <!--/* 신규 등록 : dailyRecord.modifiable=false 수정 기간 아님 */-->
<th:block th:if="${#lists.isEmpty(workList)}"> <th:block th:if="${#lists.isEmpty(workList)}">
<button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01" <button type="button" class="btn btn-m btn-secondary btn-full button-modal01" data-testid="button-modal01"