Merge branch 'susu' into dev

# Conflicts:
#	front/src/main/resources/static/assets/scripts/common.ui.js
#	front/src/main/resources/static/assets/styles/style.css
This commit is contained in:
주수현
2025-07-08 14:19:36 +09:00
28 changed files with 9536 additions and 26 deletions

View File

@@ -52,7 +52,7 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
List<UICodeElement> RegionSubCodeList = uiCodeListMapper.findByParentId("code.region.sub");
List<UICodeElement> RegionDetailCodeList = uiCodeListMapper.findByLikeId("code.region.detail");
List<UICodeElement> IndustryLargeCodeList = uiCodeListMapper.findByParentId("code.industry.large");
List<UICodeElement> IndustryMiddleCodeList = uiCodeListMapper.findByParentId("code.industry.middle");
List<UICodeElement> IndustryMiddleCodeList = uiCodeListMapper.findByLikeId("code.industry.middle");
List<String> errorList = new ArrayList<>();
// 첫 번째 행은 헤더로 간주하고 스킵
@@ -63,7 +63,6 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
CheckHouseholdNum checkHouseholdNum = checkHouseholdNumMapper.checkHouseholdNum(new CheckHouseholdNumCmd(getCellValue(row.getCell(0)))).orElse(null);
ExcelUploadContactVO contactVO = getDivisionContact(row.getCell(3));
// 데이터 누락 warn
if(!checkHouseholdNum.getIsDuplicated() && contactVO != null) {
int flag = 0;
ExcelCreateHouseholdVO household = new ExcelCreateHouseholdVO();
@@ -113,10 +112,6 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
success += flag;
if(flag == 0){
errorList.add(household.getHouseholdNum());
}
if(cmd.getRoleIds() != null && !cmd.getRoleIds().isEmpty()) {
createHouseholdMapper.createHouseholdHasRole(AuditUtil.create(new CreateHouseholdHasRoleCmd(cmd.getSeq(), cmd.getRoleIds())));
}
@@ -124,6 +119,9 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
if(cmd.getResearcherSeq() != null) {
createHouseholdMapper.createResearcherHasHousehold(AuditUtil.create(new CreateResearcherHasHouseholdCmd(cmd.getSeq(), cmd.getResearcherSeq())));
}
} else {
errorList.add(getCellValue(row.getCell(0)));
log.warn("[ EXCEL 누락 ] 임가번호={} 핸드폰번호={}",getCellValue(row.getCell(0)),getCellValue(row.getCell(3)));
}
}
workbook.close();

View File

@@ -22,10 +22,12 @@ public class RemoveDailyDao implements RemoveDailyPortOut {
if (DailySort.INCOME.equals(command.getCurrentStep())) {
mapper.removeDailyIncome(command);
mapper.removeDailyIncomeReceipt(command);
} else if (DailySort.WORK.equals(command.getCurrentStep())) {
mapper.removeDailyWork(command);
} else if (DailySort.EXPENSE.equals(command.getCurrentStep())) {
mapper.removeDailyExpense(command);
mapper.removeDailyExpenseReceipt(command);
} else if (DailySort.POWER.equals(command.getCurrentStep())) {
mapper.removeDailyPower(command);
} else if (DailySort.FORESTRY.equals(command.getCurrentStep())) {

View File

@@ -11,6 +11,12 @@ public interface RemoveDailyMapper {
*/
void removeDailyIncome(RemoveDailyCmd command);
/**
* 특정일의 수입 영수증 전체 삭제
* @param command 검색 조건
*/
void removeDailyIncomeReceipt(RemoveDailyCmd command);
/**
* 특정일의 임업노동 투입 전체 삭제
* @param command 검색 조건
@@ -23,6 +29,12 @@ public interface RemoveDailyMapper {
*/
void removeDailyExpense(RemoveDailyCmd command);
/**
* 특정일의 지출 영수증 전체 삭제
* @param command 검색 조건
*/
void removeDailyExpenseReceipt(RemoveDailyCmd command);
/**
* 동력 사용시간 전체 삭제
* @param command 검색 조건

View File

@@ -14,6 +14,19 @@
</if>
</select>
<select id="removeDailyIncomeReceipt">
<if test="removeIds != null and removeIds != ''">
update receipt_has_record set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and type = 'INCOME'
and receipt_type_id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<select id="removeDailyWork">
<if test="removeIds != null and removeIds != ''">
update daily_work set
@@ -38,6 +51,19 @@
</if>
</select>
<select id="removeDailyExpenseReceipt">
<if test="removeIds != null and removeIds != ''">
update receipt_has_record set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and type = 'EXPENSE'
and receipt_type_id IN
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<select id="removeDailyPower">
<if test="removeIds != null and removeIds != ''">
update daily_power set

View File

@@ -1,6 +1,9 @@
package app.module.core.config.application.util;
import app.module.core.usecase.file.getFile.adapters.persistence.GetFileMapper;
import app.module.core.usecase.file.getFile.ports.application.domain.GetFile;
import app.module.core.usecase.file.saveToStorage.ports.application.strategy.SftpConnector;
import app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSchException;
@@ -18,6 +21,8 @@ import java.nio.file.Paths;
public class SftpFileDeleteUtil {
private final SftpConnector sftpConnector;
private final GetFileMapper getFileMapper;
private final UpdateFileMapper updateFileMapper;
@Value("${path.upload.sftp.public}")
private String publicPath;
@@ -64,6 +69,47 @@ public class SftpFileDeleteUtil {
}
}
public void deleteRealFile(Long deleteFileId) throws JSchException, SftpException {
GetFile deleteFile = getFileMapper.findById(deleteFileId).orElseThrow();
updateFileMapper.deleteReceiptFile(deleteFileId,CommonUtil.getLoginUsername());
if (deleteFile == null || deleteFile.getPath() == null || deleteFile.getName() == null) {
log.error("Invalid file information: {}", deleteFile);
throw new IllegalArgumentException("Invalid file information");
}
// 경로 검증 및 생성
String filePath = constructSafeFilePath(deleteFile.getPath(), deleteFile.getName());
log.info("Attempting to delete file from SFTP: {}", filePath);
// SFTP 연결 확인 및 재연결
if (!sftpConnector.isConnected()) {
log.warn("SFTP connection lost, attempting to reconnect");
sftpConnector.connect();
}
ChannelSftp channelSftp = sftpConnector.getChannelSftp();
if (channelSftp == null) {
log.error("SFTP channel is not initialized");
throw new SftpException(ChannelSftp.SSH_FX_NO_CONNECTION, "SFTP channel is not initialized");
}
// 파일 삭제
try {
channelSftp.stat(filePath); // 파일 존재 여부 확인
channelSftp.rm(filePath);
log.info("File deleted successfully from SFTP: {}", filePath);
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
log.warn("File does not exist on SFTP: {}", filePath);
} else {
log.error("Failed to delete file from SFTP: {}, error: {}", filePath, e.getMessage(), e);
throw e;
}
}
}
/**
* 경로 조작 방지를 위해 안전한 파일 경로 생성
*/

View File

@@ -3,6 +3,7 @@ package app.module.core.usecase.file.updateFile.adapters.persistence;
import app.module.core.usecase.file.updateFile.ports.application.domain.UpdateUploadFileParam;
import app.module.core.usecase.file.updateFile.ports.application.domain.UploadFileDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -10,5 +11,6 @@ import java.util.List;
public interface UpdateFileMapper {
List<UploadFileDto> findDeleteFileList(UpdateUploadFileParam uploadFile);
void deleteFile(UpdateUploadFileParam uploadFile);
void deleteReceiptFile(@Param("fileId") Long fileId,@Param("deletedUserId") String deletedUserId);
void updateFile(UploadFileDto uploadFile);
}

View File

@@ -16,7 +16,7 @@
type,
file_length,
ocr,
daily_record_seq,
mapping_id,
<include refid="common.fields.CreateUpdateBaseColumns"/>
) VALUES(
#{id},

View File

@@ -36,6 +36,15 @@
</if>
</update>
<update id="deleteReceiptFile">
UPDATE upload_file
SET deleted_by = #{deletedUserId},
deleted_at = now(),
is_deleted = true
WHERE is_deleted = false
and id = #{fileId}
</update>
<update id="updateFile" >
UPDATE upload_file
SET mapping_id = #{mappingId},

View File

@@ -1,12 +1,18 @@
package app.module.front.usecase.daily.expense.adapters.persistence;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.config.application.util.SftpFileDeleteUtil;
import app.module.core.usecase.file.updateFile.adapters.persistence.UpdateFileMapper;
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
import app.module.front.usecase.daily.expense.ports.DailyExpensePortOut;
import app.module.front.usecase.daily.expense.ports.application.domain.CreateDailyExpenseCmd;
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import java.util.List;
@@ -41,6 +47,7 @@ public class DailyExpenseDao implements DailyExpensePortOut {
Integer existCount = dailyExpenseMapper.getRecordExistCount(findCmd);
if (existCount != 0) {
dailyExpenseMapper.removeDailyExpense(command);
dailyExpenseMapper.removeDailyExpenseReceipt(command);
log.debug("[RemoveDailyExpense] record={}", command);
}

View File

@@ -4,7 +4,6 @@ import app.module.front.usecase.daily.expense.ports.application.domain.CreateDai
import app.module.front.usecase.daily.expense.adapters.persistence.model.DailyExpenseDto;
import app.module.front.usecase.daily.expense.ports.application.domain.GetDailyExpenseCmd;
import app.module.front.usecase.daily.expense.ports.application.domain.RemoveDailyExpenseCmd;
import app.module.front.usecase.daily.expense.adapters.web.model.DailyExpenseUIReqVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -47,4 +46,11 @@ public interface DailyExpenseMapper {
* @param command 삭제 데이터
*/
void removeDailyExpense(RemoveDailyExpenseCmd command);
/**
* 일계부 지출 영수증 삭제
*
* @param command 삭제 데이터
*/
void removeDailyExpenseReceipt(RemoveDailyExpenseCmd command);
}

View File

@@ -41,7 +41,7 @@ public class DailyIncomeDao implements DailyIncomePortOut {
Integer existCount = dailyIncomeMapper.getRecordExistCount(findCmd);
if (existCount != 0) {
dailyIncomeMapper.removeDailyIncome(command);
dailyIncomeMapper.removeDailyIncomeReceipt(command);
log.debug("[RemoveDailyIncome] record={}", command);
}
}

View File

@@ -46,4 +46,11 @@ public interface DailyIncomeMapper {
* @param command 삭제 데이터
*/
void removeDailyIncome(RemoveDailyIncomeCmd command);
/**
* 일계부 수입 영수증 삭제
*
* @param command 삭제 데이터
*/
void removeDailyIncomeReceipt(RemoveDailyIncomeCmd command);
}

View File

@@ -1,6 +1,7 @@
package app.module.front.usecase.daily.receipt.adapters.persistence;
import app.module.core.config.application.annotation.CreateCommand;
import app.module.core.config.application.util.CommonUtil;
import app.module.front.usecase.daily.receipt.adapters.web.model.CreateReceiptHasFileReqVO;
import app.module.front.usecase.daily.receipt.ports.DailyReceiptPortOut;
import lombok.RequiredArgsConstructor;
@@ -22,4 +23,10 @@ public class DailyReceiptDao implements DailyReceiptPortOut {
public void insertReceiptMappingFile(CreateReceiptHasFileReqVO command) {
dailyReceiptMapper.insertReceiptMappingFile(command);
}
@Override
public Integer selectReceiptCount(String inputType) {
return dailyReceiptMapper.selectReceiptCount(inputType, CommonUtil.getLoginUsername());
}
}

View File

@@ -2,6 +2,7 @@ package app.module.front.usecase.daily.receipt.adapters.persistence;
import app.module.front.usecase.daily.receipt.adapters.web.model.CreateReceiptHasFileReqVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
@@ -16,4 +17,13 @@ public interface DailyReceiptMapper {
*/
Integer insertReceiptMappingFile(CreateReceiptHasFileReqVO command);
/**
* 일계부 수입 파일 매핑
*
* @param inputType 수입/지출
* @param userId 사용자 아이디
* @return 중복 개수
*/
Integer selectReceiptCount(@Param("inputType") String inputType,@Param("userId")String userId);
}

View File

@@ -13,6 +13,7 @@ import app.module.front.usecase.daily.expense.adapters.web.model.CreateDailyExpe
import app.module.front.usecase.daily.expense.ports.DailyExpensePortIn;
import app.module.front.usecase.daily.income.adapters.web.model.CreateDailyIncomeReqVO;
import app.module.front.usecase.daily.income.adapters.web.model.DailyInputType;
import app.module.front.usecase.daily.income.adapters.web.model.RemoveDailyIncomeReqVO;
import app.module.front.usecase.daily.income.ports.DailyIncomePortIn;
import app.module.front.usecase.daily.receipt.adapters.web.model.*;
import app.module.front.usecase.daily.receipt.ports.DailyReceiptPortIn;
@@ -25,7 +26,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.http.*;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
@@ -105,7 +105,7 @@ public class DailyReceiptController {
/**
* 일계부 영수증 수입 등록 처리
* 일계부 영수증 수입/수출 등록 처리
*
* @param searchMonth 검색 월(yyyyMM)
* @param groupNo 검색 그룹
@@ -196,6 +196,15 @@ public class DailyReceiptController {
return ResponseEntity.status(HttpStatus.OK).body("");
}
/**
* 일계부 영수증 개수 확인
*
*/
@GetMapping(path = "/{inputType}/count")
ResponseEntity<?> receiptCount(@PathVariable("inputType") String inputType) {
return ResponseEntity.status(HttpStatus.OK).body( dailyReceiptPortIn.selectReceiptCount(inputType));
}
/**
* 일계부 유효성 체크 및 데이터 조회
*

View File

@@ -6,9 +6,15 @@ import app.module.front.usecase.daily.receipt.adapters.web.model.CreateReceiptHa
public interface DailyReceiptPortIn {
/**
* 일계부 수입 파일 매핑 추가
* 일계부 영수증 파일 매핑 추가
*
*/
void insertReceiptMappingFile(CreateReceiptHasFileReqVO formVO);
/**
* 일계부 영수증 파일 개수
*
*/
Integer selectReceiptCount(String inputType);
}

View File

@@ -12,4 +12,12 @@ public interface DailyReceiptPortOut {
* @param command 수입 영수증 매핑 검색 조건
*/
void insertReceiptMappingFile(CreateReceiptHasFileReqVO command);
/**
* 일계부 수입 영수증 매핑
*
* @param inputType 수출/수입
*/
Integer selectReceiptCount(String inputType);
}

View File

@@ -16,4 +16,11 @@ public class DailyReceiptService implements DailyReceiptPortIn {
public void insertReceiptMappingFile(CreateReceiptHasFileReqVO formVO) {
portOut.insertReceiptMappingFile(formVO);
}
@Override
public Integer selectReceiptCount(String inputType) {
return portOut.selectReceiptCount(inputType);
}
}

View File

@@ -69,4 +69,14 @@
</if>
</update>
<update id="removeDailyExpenseReceipt">
update receipt_has_record set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and type = 'EXPENSE'
<if test="id != null and id != ''">
and receipt_type_id = #{id}
</if>
</update>
</mapper>

View File

@@ -70,4 +70,14 @@
</if>
</update>
<update id="removeDailyIncomeReceipt">
update receipt_has_record set
<include refid="common.fields.DeleteBaseSet"/>
where is_deleted = false
and type = 'INCOME'
<if test="id != null and id != ''">
and receipt_type_id = #{id}
</if>
</update>
</mapper>

View File

@@ -17,4 +17,12 @@
)
</insert>
<select id="selectReceiptCount">
select count(*)
from receipt_has_record
where created_by = #{userId}
and created_at = CURRENT_DATE
and type = #{inputType}
</select>
</mapper>

File diff suppressed because one or more lines are too long

View File

@@ -330,6 +330,5 @@ var ajaxUtil = {
ajaxUtil.loadingStatus = true;
// TODO : 로딩바 활성화
document.querySelector('#loadingBar').style.display = 'block';
debugger
},
};

View File

@@ -5,7 +5,7 @@
<body>
<div id="wrap">
<div class="loading" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<div class="loading dimmed" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<section th:replace="~{common/components :: header(true)}"></section>
<div id="container" layout:fragment="content">

View File

@@ -5,7 +5,7 @@
<body>
<div id="wrap">
<div class="loading" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<div class="loading dimmed" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<section th:replace="~{common/components :: header(true)}"></section>
<div id="container" layout:fragment="content">

View File

@@ -5,7 +5,7 @@
<body>
<div id="wrap">
<div class="loading" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<div class="loading dimmed" id="loadingBar" style="display: none"><i class="ico-spinner" aria-hidden="true"></i></div>
<section th:replace="~{common/components :: header(false)}"></section>
<div id="container" layout:fragment="content">

View File

@@ -206,6 +206,7 @@
<!--/* 영수증 등록 s */-->
<div id="modelOcr" style="display: none;">
<section class="form-group">
<input type="hidden" id="countOcr"/>
<div class="segment-label">
<p class="label-txt">
영수증 첨부

View File

@@ -248,10 +248,36 @@
$('#modelOcr').hide();
$('#btnOcr').removeClass('active');
} else {
$('#modelSelf').hide();
$('#btnSelf').removeClass('active');
$('#modelOcr').show();
$('#btnOcr').addClass('active');
ajaxUtil._ajaxSyncMethod(
'/api/record/receipt/INCOME/count',
{},
(response) => { // 성공
if(response < 3) {
debugger
$('#modelSelf').hide();
$('#btnSelf').removeClass('active');
$('#modelOcr').show();
$('#btnOcr').addClass('active');
$('#countOcr').val(response);
}else{
etUI.dialog.alert({
title: '',
message: '영수증은 일일 최대 3개 등록 가능합니다.',
type: 'alert',
callback: function () {
},
});
}
},
function (code, rstData) { // 실패
console.log("error : ", code);
},
'get',
'json'
);
}
},
createVaild() {
@@ -272,14 +298,25 @@
);
},
addFileInput() {
// 새로운 input type="file" 요소 생성
const countOcr = $('#countOcr').val();
if(uploadedReceipt.length === 3 - countOcr ){
etUI.dialog.alert({
title: '',
message: '영수증은 일일 최대 3개 등록 가능합니다.',
type: 'alert',
callback: function () {
},
});
return;
}
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = 'image/*';
fileInput.style.display = 'none';
fileInput.name = 'file';
// 파일 선택 시 이벤트 처리
// 파일 선택
fileInput.addEventListener('change', (event) => {
const files = event.target.files;
const previewContainer = $('#file-upload-container');
@@ -330,7 +367,6 @@
`);
previewContainer.append(fileItem);
// 파일 정보와 서버 응답 저장
uploadedReceipt.push({
fileId: fileItemId,
file: file,
@@ -383,8 +419,8 @@
const receiptDataList = uploadedReceipt;
if (!receiptDataList.length) {
etUI.dialog.alert({
title: '등록 실패',
message: '등록할 영수증 데이터가 없습니다.',
title: '',
message: '최소 1개의 영수증을 등록해주셔야 합니다.',
type: 'alert',
callback: function () {
},