배치 전반적으로 수정,

ZIP 파일 압축해제 배치 추가 테스트
multiDB
박성영 5 months ago
parent 8778338eef
commit 349a0c1ce5

@ -1,4 +1,4 @@
CREATE SEQUENCE seq_zip_file_process_log_id
CREATE SEQUENCE seq_batch_zip_file_detail_log_id
START WITH 1
INCREMENT BY 1
MINVALUE 1

@ -0,0 +1,6 @@
CREATE SEQUENCE seq_batch_zip_file_process_log_id
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 99999999
CYCLE;

@ -1,4 +1,4 @@
create table tb_zip_file_detail_log
create table tb_batch_zip_file_detail_log
(
detail_log_id varchar(12) not null comment '상세로그ID'
primary key,
@ -14,20 +14,20 @@ create table tb_zip_file_detail_log
process_time datetime default current_timestamp() null comment '처리시간',
reg_date datetime default current_timestamp() null comment '등록일시',
reg_user_id varchar(20) default 'BATCH_SYSTEM' null comment '등록자ID',
constraint fk_zip_detail_log_id
foreign key (log_id) references tb_zip_file_process_log (log_id)
constraint fk_batch_zip_detail_log_id
foreign key (log_id) references tb_batch_zip_file_process_log (log_id)
on delete cascade
)
comment 'ZIP파일처리상세로그' collate = utf8mb4_unicode_ci;
create index idx_log_id
on tb_zip_file_detail_log (log_id);
on tb_batch_zip_file_detail_log (log_id);
create index idx_file_name
on tb_zip_file_detail_log (file_name);
on tb_batch_zip_file_detail_log (file_name);
create index idx_process_status
on tb_zip_file_detail_log (process_status);
on tb_batch_zip_file_detail_log (process_status);
create index idx_is_image
on tb_zip_file_detail_log (is_image);
on tb_batch_zip_file_detail_log (is_image);

@ -1,4 +1,4 @@
create table tb_zip_file_process_log
create table tb_batch_zip_file_process_log
(
log_id varchar(12) not null comment '로그ID'
primary key,
@ -24,10 +24,10 @@ create table tb_zip_file_process_log
comment 'ZIP파일처리로그' collate = utf8mb4_unicode_ci;
create index idx_zip_file_name
on tb_zip_file_process_log (zip_file_name);
on tb_batch_zip_file_process_log (zip_file_name);
create index idx_process_status
on tb_zip_file_process_log (process_status);
on tb_batch_zip_file_process_log (process_status);
create index idx_start_time
on tb_zip_file_process_log (start_time);
on tb_batch_zip_file_process_log (start_time);

@ -6,10 +6,10 @@
## 구현된 기능
### 1. 데이터베이스 테이블
- **tb_zip_file_process_log**: ZIP 파일 처리 메인 로그 테이블
- **tb_zip_file_detail_log**: ZIP 파일 내 개별 파일 처리 상세 로그 테이블
- **seq_zip_file_process_log_id**: 메인 로그 ID 시퀀스
- **seq_zip_file_detail_log_id**: 상세 로그 ID 시퀀스
- **tb_batch_zip_file_process_log**: ZIP 파일 처리 메인 로그 테이블
- **tb_batch_zip_file_detail_log**: ZIP 파일 내 개별 파일 처리 상세 로그 테이블
- **seq_batch_zip_file_process_log_id**: 메인 로그 ID 시퀀스
- **seq_batch_zip_file_detail_log_id**: 상세 로그 ID 시퀀스
### 2. 주요 클래스
@ -79,12 +79,12 @@ ${user.home}/batch/zip/
### 1. 데이터베이스 테이블 생성
```sql
-- 시퀀스 생성
source DB-DDL/maria/ddl/xitframework/seq_zip_file_process_log_id.sql
source DB-DDL/maria/ddl/xitframework/seq_zip_file_detail_log_id.sql
source DB-DDL/maria/ddl/xitframework/seq_batch_zip_file_process_log_id.sql
source DB-DDL/maria/ddl/xitframework/seq_batch_zip_file_detail_log_id.sql
-- 테이블 생성
source DB-DDL/maria/ddl/xitframework/tb_zip_file_process_log.sql
source DB-DDL/maria/ddl/xitframework/tb_zip_file_detail_log.sql
source DB-DDL/maria/ddl/xitframework/tb_batch_zip_file_process_log.sql
source DB-DDL/maria/ddl/xitframework/tb_batch_zip_file_detail_log.sql
```
### 2. 배치 작업 등록
@ -99,13 +99,13 @@ Quartz 스케줄러를 통해 `ZipFileProcessBatchJob` 클래스를 등록하여
### 메인 처리 로그 조회
```sql
SELECT * FROM tb_zip_file_process_log
SELECT * FROM tb_batch_zip_file_process_log
ORDER BY start_time DESC;
```
### 상세 처리 로그 조회
```sql
SELECT * FROM tb_zip_file_detail_log
SELECT * FROM tb_batch_zip_file_detail_log
WHERE log_id = 'ZPFL00000001'
ORDER BY process_time ASC;
```
@ -118,7 +118,7 @@ SELECT
is_corrupted,
process_status,
error_message
FROM tb_zip_file_detail_log
FROM tb_batch_zip_file_detail_log
WHERE log_id = 'ZPFL00000001'
AND is_image = 'Y';
```
@ -132,4 +132,4 @@ WHERE log_id = 'ZPFL00000001'
1. 디렉토리 권한 확인 필요
2. 대용량 ZIP 파일 처리 시 메모리 사용량 모니터링 필요
3. 동일한 파일명의 ZIP 파일 처리 시 타임스탬프 추가하여 중복 방지
4. 배치 작업은 `@DisallowConcurrentExecution` 어노테이션으로 동시 실행 방지
4. 배치 작업은 `@DisallowConcurrentExecution` 어노테이션으로 동시 실행 방지

@ -65,6 +65,9 @@ public class ZipFileProcessBatchJob implements Job {
@Value("${batch.zip.create-date-subdir:false}")
private boolean createDateSubdir;
@Value("${batch.zip.create-zip-name-subdir:false}")
private boolean createZipNameSubdir;
// ===========================================================
// 의존성 주입
// ===========================================================
@ -355,6 +358,14 @@ public class ZipFileProcessBatchJob implements Job {
extractPath = extractPath.resolve(dateStr);
}
// ZIP 파일명으로 하위 디렉토리 생성
if (createZipNameSubdir) {
String zipFileName = zipFile.getFileName().toString();
// 확장자 제거 (.zip)
String zipNameWithoutExt = zipFileName.substring(0, zipFileName.lastIndexOf('.'));
extractPath = extractPath.resolve(zipNameWithoutExt);
}
// 추출 디렉토리 생성
if (!Files.exists(extractPath)) {
Files.createDirectories(extractPath);

@ -90,3 +90,4 @@ batch:
extract-dir: /data/xit-framework/batch/zip/extract # ZIP 파일 압축 해제 디렉토리
archive-dir: /data/xit-framework/batch/zip/archive # ZIP 파일 아카이브 디렉토리
create-date-subdir: true # yyyymmdd 하위 디렉토리 생성 여부
create-zip-name-subdir: true # ZIP 파일명으로 하위 디렉토리 생성 여부

@ -95,3 +95,4 @@ batch:
extract-dir: d:/data/xit-framework/batch/zip/extract # ZIP 파일 압축 해제 디렉토리
archive-dir: d:/data/xit-framework/batch/zip/archive # ZIP 파일 아카이브 디렉토리
create-date-subdir: true # yyyymmdd 하위 디렉토리 생성 여부
create-zip-name-subdir: true # ZIP 파일명으로 하위 디렉토리 생성 여부

@ -90,3 +90,4 @@ batch:
extract-dir: /data/xit-framework/batch/zip/extract # ZIP 파일 압축 해제 디렉토리
archive-dir: /data/xit-framework/batch/zip/archive # ZIP 파일 아카이브 디렉토리
create-date-subdir: true # yyyymmdd 하위 디렉토리 생성 여부
create-zip-name-subdir: true # ZIP 파일명으로 하위 디렉토리 생성 여부

@ -5,15 +5,15 @@
<!-- ZIP 파일 처리 상세 로그 ID 생성 -->
<select id="generateZipFileDetailLogId" resultType="String">
SELECT CONCAT('ZFDL', LPAD(NEXTVAL(seq_zip_file_detail_log_id), 8, '0'))
SELECT CONCAT('ZFDL', LPAD(NEXTVAL(seq_batch_zip_file_detail_log_id), 8, '0'))
</select>
<!-- ZIP 파일 처리 상세 로그 등록 -->
<insert id="insertZipFileDetailLog" parameterType="go.kr.project.batch.model.ZipFileDetailLogVO">
<selectKey keyProperty="detailLogId" resultType="String" order="BEFORE">
SELECT CONCAT('ZFDL', LPAD(NEXTVAL(seq_zip_file_detail_log_id), 8, '0'))
SELECT CONCAT('ZFDL', LPAD(NEXTVAL(seq_batch_zip_file_detail_log_id), 8, '0'))
</selectKey>
INSERT INTO tb_zip_file_detail_log (
INSERT INTO tb_batch_zip_file_detail_log (
detail_log_id,
log_id,
file_name,
@ -46,7 +46,7 @@
<!-- ZIP 파일 처리 상세 로그 목록 일괄 등록 -->
<insert id="insertZipFileDetailLogList" parameterType="java.util.List">
INSERT INTO tb_zip_file_detail_log (
INSERT INTO tb_batch_zip_file_detail_log (
detail_log_id,
log_id,
file_name,
@ -63,7 +63,7 @@
) VALUES
<foreach collection="list" item="item" separator=",">
(
CONCAT('ZFDL', LPAD(NEXTVAL(seq_zip_file_detail_log_id), 8, '0')),
CONCAT('ZFDL', LPAD(NEXTVAL(seq_batch_zip_file_detail_log_id), 8, '0')),
#{item.logId},
#{item.fileName},
#{item.filePath},
@ -82,13 +82,13 @@
<!-- ZIP 파일 처리 상세 로그 삭제 -->
<delete id="deleteZipFileDetailLog" parameterType="String">
DELETE FROM tb_zip_file_detail_log
DELETE FROM tb_batch_zip_file_detail_log
WHERE detail_log_id = #{detailLogId}
</delete>
<!-- 로그 ID로 ZIP 파일 처리 상세 로그 삭제 -->
<delete id="deleteZipFileDetailLogByLogId" parameterType="String">
DELETE FROM tb_zip_file_detail_log
DELETE FROM tb_batch_zip_file_detail_log
WHERE log_id = #{logId}
</delete>
@ -108,7 +108,7 @@
process_time AS processTime,
reg_date AS regDate,
reg_user_id AS regUserId
FROM tb_zip_file_detail_log
FROM tb_batch_zip_file_detail_log
WHERE detail_log_id = #{detailLogId}
</select>
@ -128,7 +128,7 @@
process_time AS processTime,
reg_date AS regDate,
reg_user_id AS regUserId
FROM tb_zip_file_detail_log
FROM tb_batch_zip_file_detail_log
WHERE log_id = #{logId}
ORDER BY process_time ASC
</select>
@ -136,7 +136,7 @@
<!-- ZIP 파일 처리 상세 로그 목록 총 개수 조회 -->
<select id="selectZipFileDetailLogListTotalCount" parameterType="go.kr.project.batch.model.ZipFileDetailLogVO" resultType="int">
SELECT COUNT(*)
FROM tb_zip_file_detail_log
FROM tb_batch_zip_file_detail_log
WHERE 1=1
<if test="logId != null and logId != ''">
AND log_id = #{logId}
@ -171,7 +171,7 @@
process_time AS processTime,
reg_date AS regDate,
reg_user_id AS regUserId
FROM tb_zip_file_detail_log
FROM tb_batch_zip_file_detail_log
WHERE 1=1
<if test="logId != null and logId != ''">
AND log_id = #{logId}
@ -194,4 +194,4 @@
</if>
</select>
</mapper>
</mapper>

@ -5,12 +5,12 @@
<!-- ZIP 파일 처리 로그 ID 생성 -->
<select id="generateZipFileProcessLogId" resultType="String">
SELECT CONCAT('ZPFL', LPAD(NEXTVAL(seq_zip_file_process_log_id), 8, '0'))
SELECT CONCAT('ZPFL', LPAD(NEXTVAL(seq_batch_zip_file_process_log_id), 8, '0'))
</select>
<!-- ZIP 파일 처리 로그 등록 -->
<insert id="insertZipFileProcessLog" parameterType="go.kr.project.batch.model.ZipFileProcessLogVO">
INSERT INTO tb_zip_file_process_log (
INSERT INTO tb_batch_zip_file_process_log (
log_id,
zip_file_name,
zip_file_path,
@ -55,7 +55,7 @@
<!-- ZIP 파일 처리 로그 수정 -->
<update id="updateZipFileProcessLog" parameterType="go.kr.project.batch.model.ZipFileProcessLogVO">
UPDATE tb_zip_file_process_log
UPDATE tb_batch_zip_file_process_log
SET
extract_path = #{extractPath},
archive_path = #{archivePath},
@ -75,7 +75,7 @@
<!-- ZIP 파일 처리 로그 삭제 -->
<delete id="deleteZipFileProcessLog" parameterType="String">
DELETE FROM tb_zip_file_process_log
DELETE FROM tb_batch_zip_file_process_log
WHERE log_id = #{logId}
</delete>
@ -101,14 +101,14 @@
reg_user_id AS regUserId,
mod_date AS modDate,
mod_user_id AS modUserId
FROM tb_zip_file_process_log
FROM tb_batch_zip_file_process_log
WHERE log_id = #{logId}
</select>
<!-- ZIP 파일 처리 로그 목록 총 개수 조회 -->
<select id="selectZipFileProcessLogListTotalCount" parameterType="go.kr.project.batch.model.ZipFileProcessLogVO" resultType="int">
SELECT COUNT(*)
FROM tb_zip_file_process_log
FROM tb_batch_zip_file_process_log
WHERE 1=1
<if test="zipFileName != null and zipFileName != ''">
AND zip_file_name LIKE CONCAT('%', #{zipFileName}, '%')
@ -140,7 +140,7 @@
reg_user_id AS regUserId,
mod_date AS modDate,
mod_user_id AS modUserId
FROM tb_zip_file_process_log
FROM tb_batch_zip_file_process_log
WHERE 1=1
<if test="zipFileName != null and zipFileName != ''">
AND zip_file_name LIKE CONCAT('%', #{zipFileName}, '%')
@ -176,11 +176,11 @@
reg_user_id AS regUserId,
mod_date AS modDate,
mod_user_id AS modUserId
FROM tb_zip_file_process_log
FROM tb_batch_zip_file_process_log
WHERE zip_file_name = #{zipFileName}
AND process_status = 'PROCESSING'
ORDER BY start_time DESC
LIMIT 1
</select>
</mapper>
</mapper>

Loading…
Cancel
Save