재부과 신규로직 init

dev
박성영 3 months ago
parent e5974bcca6
commit f726af08ae

@ -647,24 +647,26 @@ public class FileUtil {
* @return
* @throws IOException
*/
public boolean copyFile(String sourcePath, String targetPath) throws IOException {
if (sourcePath == null || targetPath == null) {
public boolean copyFile(String sourcePath, String uploadDir, String targetPath) throws IOException {
if (sourcePath == null || targetPath == null || uploadDir == null) {
throw new IOException("원본 또는 대상 파일 경로가 null입니다.");
}
File sourceFile = new File(sourcePath);
File targetFile = new File(targetPath);
File sourceFile = new File(uploadPath + File.separator + sourcePath);
File targetFile = new File(uploadPath + File.separator + targetPath);
// 원본 파일 존재 여부 확인
if (!sourceFile.exists()) {
throw new IOException("원본 파일이 존재하지 않습니다: " + sourcePath);
throw new IOException("원본 파일이 존재하지 않습니다: " + uploadPath + File.separator + sourcePath);
}
// 원본 파일이 일반 파일인지 확인
if (!sourceFile.isFile()) {
throw new IOException("원본이 일반 파일이 아닙니다: " + sourcePath);
throw new IOException("원본이 일반 파일이 아닙니다: " + uploadPath + File.separator + sourcePath);
}
createDirectoryIfNotExists( uploadPath + File.separator + uploadDir);
// 대상 디렉토리 생성
File targetDir = targetFile.getParentFile();
if (targetDir != null && !targetDir.exists()) {

@ -110,7 +110,7 @@ public class CrdnRelevyController {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "400", description = "잘못된 요청")
})
public ResponseEntity<?> saveRelevy(@RequestBody CrdnRelevyVO relevyVO) {
public ResponseEntity<?> saveRelevy(@ModelAttribute CrdnRelevyVO relevyVO) {
log.debug("재부과 저장 요청: {}", relevyVO);

@ -1,6 +1,7 @@
package go.kr.project.crdn.crndRegistAndView.main.service.impl;
import egovframework.exception.MessageException;
import egovframework.util.DateUtil;
import egovframework.util.FileUtil;
import go.kr.project.crdn.crndRegistAndView.main.mapper.CrdnRegistAndViewMapper;
import go.kr.project.crdn.crndRegistAndView.main.mapper.CrdnRelevyMapper;
@ -10,9 +11,11 @@ import go.kr.project.crdn.crndRegistAndView.main.service.CrdnRegistAndViewServic
import go.kr.project.crdn.crndRegistAndView.main.service.CrdnRelevyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -46,6 +49,15 @@ public class CrdnRelevyServiceImpl implements CrdnRelevyService {
private final CrdnRegistAndViewService crdnRegistAndViewService;
private final FileUtil fileUtil;
/** 날짜 유틸리티 */
private final DateUtil dateUtil;
@Value("${file.upload.sub-dirs.crdn-act-photo}")
String atcFileStorePath;
@Value("${file.upload.sub-dirs.crdn-actn-photo}")
String atcnFileStorePath;
@Override
public CrdnRelevyVO selectCrdnPstnInfoOne(CrdnRelevyVO crdnRelevyVO) {
@ -164,7 +176,7 @@ public class CrdnRelevyServiceImpl implements CrdnRelevyService {
private void copyPhysicalFile(CrdnPhotoVO srcPhoto, CrdnRelevyVO relevyVO) {
try {
// 원본 파일 전체 경로 구성
String srcFilePath = srcPhoto.getCrdnPhotoPath() + "/" + srcPhoto.getCrdnPhotoNm();
String srcFilePath = srcPhoto.getCrdnPhotoPath() + File.separator + srcPhoto.getCrdnPhotoNm();
// UUID를 이용한 새로운 저장 파일명 생성 (기존 로직 사용)
String fileExt = "";
@ -174,12 +186,12 @@ public class CrdnRelevyServiceImpl implements CrdnRelevyService {
}
String newStrgFileNm = UUID.randomUUID() + "." + fileExt;
// 새로운 파일 경로 구성 (동일한 디렉토리 구조 유지)
String newFilePath = srcPhoto.getCrdnPhotoPath(); // 동일한 경로 사용
String targetFilePath = newFilePath + "/" + newStrgFileNm;
// 신규파일은 새로운 경로에 저장
String uploadDir = generateUploadDirectoryPath(srcPhoto);
String targetFilePath = uploadDir + File.separator + newStrgFileNm;
// 물리적 파일 복사
boolean copySuccess = fileUtil.copyFile(srcFilePath, targetFilePath);
boolean copySuccess = fileUtil.copyFile(srcFilePath, uploadDir, targetFilePath);
if (copySuccess) {
// 복사된 파일 정보로 데이터베이스 업데이트
@ -189,12 +201,11 @@ public class CrdnRelevyServiceImpl implements CrdnRelevyService {
updateParams.put("newCrdnNo", relevyVO.getNewCrdnNo());
updateParams.put("crdnPhotoSn", srcPhoto.getCrdnPhotoSn());
updateParams.put("crdnPhotoNm", newStrgFileNm);
updateParams.put("crdnPhotoPath", uploadDir);
int updateResult = relevyMapper.updateRelevyPhotoInfo(updateParams);
if (updateResult <= 0) {
throw new MessageException("첨부파일 정보 업데이트 실패: " + srcPhoto.getOrgnlPhotoNm());
}
log.debug("파일 복사 성공: {} -> {}", srcFilePath, targetFilePath);
} else {
throw new MessageException("파일 복사 실패: " + srcPhoto.getOrgnlPhotoNm());
@ -209,6 +220,22 @@ public class CrdnRelevyServiceImpl implements CrdnRelevyService {
}
}
// 행위사진, 조치사진 경로 추출
private String generateUploadDirectoryPath(CrdnPhotoVO srcPhoto) {
String uploadPath = atcFileStorePath;
// 년월 정보 추출
String yearMonth = dateUtil.getCurrentYearMonth();
// 년월 디렉토리를 포함한 경로 생성
String crdnPhotoSeCd = srcPhoto.getCrdnPhotoSeCd();
if( "1".equals(crdnPhotoSeCd) ){ //행위사진
uploadPath = atcFileStorePath;
}else if( "2".equals(crdnPhotoSeCd) ){ //조치사진
uploadPath = atcnFileStorePath;
}
String uploadDir = uploadPath + File.separator + yearMonth;
return uploadDir;
}
/**
* 퀀 .

@ -105,8 +105,8 @@ file:
bbs-notice: bbs/notice # 공지사항 sample 파일 저장 경로
bbs-post: bbs/post # 게시판 파일 저장 경로
html-editor: common/html_editor # HTML 에디터 파일 저장 경로
crdn-act-photo: crdn/act # 단속행위 사진
crdn-actn-photo: crdn/actn # 단속행위 조치 사진
crdn-act-photo: crdn-act-photo # 단속행위 사진
crdn-actn-photo: crdn-actn-photo # 단속행위 조치 사진
# Juso API configuration
juso:

@ -71,7 +71,7 @@ server:
timeout: 60m # 세션 타임아웃을 60분으로 증가
cookie:
http-only: true
secure: true # 개발환경에서는 false, 운영환경에서는 true
secure: false # 개발환경에서는 false, 운영환경에서는 true
same-site: lax
tracking-modes: cookie
@ -105,8 +105,8 @@ file:
bbs-notice: bbs/notice # 공지사항 sample 파일 저장 경로
bbs-post: bbs/post # 게시판 파일 저장 경로
html-editor: common/html_editor # HTML 에디터 파일 저장 경로
crdn-act-photo: crdn/act # 단속행위 사진
crdn-actn-photo: crdn/actn # 단속행위 조치 사진
crdn-act-photo: crdn-act-photo # 단속행위 사진
crdn-actn-photo: crdn-actn-photo # 단속행위 조치 사진
# Juso API configuration
juso:

@ -112,8 +112,8 @@ file:
bbs-notice: bbs/notice # 공지사항 sample 파일 저장 경로
bbs-post: bbs/post # 게시판 파일 저장 경로
html-editor: common/html_editor # HTML 에디터 파일 저장 경로
crdn-act-photo: crdn/act # 단속행위 사진
crdn-actn-photo: crdn/actn # 단속행위 조치 사진
crdn-act-photo: crdn-act-photo # 단속행위 사진
crdn-actn-photo: crdn-actn-photo # 단속행위 조치 사진
# Juso API configuration
juso:

@ -89,7 +89,7 @@
RELEVY_YN, /* 재부과 여부 - 'Y' */
AGRVTN_LEVY_TRGT_YN, /* 가중 부과 대상 여부 */
CRDN_PRCS_STTS_CD, /* 단속 처리 상태 코드 - 30 (시정명령) */
CRDN_PRCS_YMD, /* 단속 처리 일자 - 현재 일자 */
CRDN_PRCS_YMD, /* 단속 처리 일자 */
REG_DT,
RGTR,
DEL_YN
@ -108,7 +108,7 @@
'Y', /* 재부과 여부 */
AGRVTN_LEVY_TRGT_YN,
'30', /* 시정명령 상태 */
NOW(), /* 현재 일자 */
CRDN_PRCS_YMD, /* 단속 처리 일자 */
NOW(),
#{rgtr},
'N'
@ -120,7 +120,7 @@
<!-- 위치 정보 복사 -->
<insert id="insertCrdnPstnInfo" parameterType="CrdnRelevyVO">
/ CrdnRelevyMapper.insertCrdnPstnInfo : 위치 정보 복사 /
/* CrdnRelevyMapper.insertCrdnPstnInfo : 위치 정보 복사 */
INSERT INTO tb_pstn_info (
PSTN_INFO_ID,
CRDN_YR,
@ -200,9 +200,9 @@
)
SELECT
LPAD(NEXTVAL(seq_ownr_info_id), 10, '0'),
SGG_CD,
#{newCrdnYr},
#{newCrdnNo},
SGG_CD,
PSTN_INFO_ID,
OWNR_ID,
NOW(),
@ -398,7 +398,8 @@
<update id="updateRelevyPhotoInfo" parameterType="map">
/* CrdnRelevyMapper.updateRelevyPhotoInfo : 재부과 첨부파일 정보 업데이트 */
UPDATE tb_crdn_photo
SET CRDN_PHOTO_NM = #{crdnPhotoNm}
SET CRDN_PHOTO_NM = #{crdnPhotoNm},
CRDN_PHOTO_PATH = #{crdnPhotoPath}
WHERE CRDN_YR = #{newCrdnYr}
AND CRDN_NO = #{newCrdnNo}
AND CRDN_PHOTO_SN = #{crdnPhotoSn}

Loading…
Cancel
Save