feat : epost 사진 zip 처리 및 택스트 생성 처리중

master
Kurt92 2 months ago
parent 3015edc4c3
commit b6b2305e99

@ -33,7 +33,8 @@ public class EPostDto {
private String conOrg;
private String rceptId;
private String apvlNb;
private String filePath;
private String fileRecvPath;
private String fileSendPath;
private String postId;
private String addPath;
@ -196,6 +197,16 @@ public class EPostDto {
private String recevNoticeConts; // 개행→
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public static class ImgTarget {
private String mmCode;
private String conKey;
}
}

@ -140,48 +140,66 @@ public class EPostSendService {
// 사전통보 or 계도 대상에서 mmcode만 추출 (prt_gubun = '0'사전통보 || prt_gubun = 'A' 계도)
// 사전 & 계도는 사진 같이 나감.
final List<EPostDto.SendTarget.Target> cpTargets = Optional.ofNullable(cpSendEpostTargets).orElseGet(List::of);
List<String> targetCpMmCodes = cpSendTargetKeys.stream()
List<EPostDto.SendTarget.ImgTarget> cpZipTargets = cpSendTargetKeys.stream()
.filter(o -> "0".equals(o.getTgGb()) || "A".equals(o.getTgGb()))
.flatMap(o -> cpTargets.stream()
.filter(t -> Objects.equals(o.getConKey(), t.getConKey()))
.map(EPostDto.SendTarget.Target::getRecevSeq))
.filter(Objects::nonNull)
.toList();
.map(t ->
EPostDto.SendTarget.ImgTarget.builder()
.mmCode(t.getRecevSeq())
.conKey(t.getConKey())
.build()
)
)
.collect(Collectors.toUnmodifiableList());
final List<EPostDto.SendTarget.Target> epTargets = Optional.ofNullable(epSendEpostTargets).orElseGet(List::of);
List<String> targetEpMmCodes = epSendTargetKeys.stream()
List<EPostDto.SendTarget.ImgTarget> epZipTargets = epSendTargetKeys.stream()
.filter(o -> "0".equals(o.getTgGb()) || "A".equals(o.getTgGb()))
.flatMap(o -> epTargets.stream()
.filter(t -> Objects.equals(o.getConKey(), t.getConKey()))
.map(EPostDto.SendTarget.Target::getRecevSeq))
.filter(Objects::nonNull)
.toList();
.map(t ->
EPostDto.SendTarget.ImgTarget.builder()
.mmCode(t.getRecevSeq())
.conKey(t.getConKey())
.build()
)
)
.collect(Collectors.toUnmodifiableList());
// mmcode로 이미지 파일 찾아서 zip생성
try {
zipMaker.generateZipFile(targetCpMmCodes, targetEpMmCodes, setInfo);
if(!cpZipTargets.isEmpty()) zipMaker.generateZipFile(cpZipTargets, setInfo.getCpSetinfo());
if(!epZipTargets.isEmpty()) zipMaker.generateZipFile(epZipTargets, setInfo.getEpSetinfo());
} catch (Exception e) {
log.error("ZIP 파일 생성 실패 : " + e.getMessage());
}
// 택스트파일 생성
try {
textMaker.generateTextFile(cpSendEpostTargets, epSendEpostTargets, cpSendEgojiTargets, epSendEgojiTargets);
} catch (Exception e) {
log.error("ZIP 파일 생성 실패 : " + e.getMessage());
}
/** 업데이트 임시주석 */
// SendTargets 돌면서 전자고지인지 체크
// 거기서 대기상태("E") 인 얘들의 등기번호를 업데이트
// cpSendEgojiTargetKeys 등기번호 업데이트 하면 될듯
egojiNonReadTargetsUpdateTrgstNmbr(cpSendEgojiTargets, epSendEgojiTargets);
/*egojiNonReadTargetsUpdateTrgstNmbr(cpSendEgojiTargets, epSendEgojiTargets);*/
// POST_SEND_STATE 업데이트 to "1"
updateSendState(cpSendEpostTargets, epSendEpostTargets, cpSendEgojiTargets, epSendEgojiTargets);
/*updateSendState(cpSendEpostTargets, epSendEpostTargets, cpSendEgojiTargets, epSendEgojiTargets);*/
//qryRegSet POST_PROC_STT = 03, TG_POST_YN = "Y" 으로 업데이트
if(!cpSendEpostTargets.isEmpty()) ePostSendQueryDslRepository.updateSenderRegPostStt(cpQueryFactory, cpSendEpostTargets);
/*if(!cpSendEpostTargets.isEmpty()) ePostSendQueryDslRepository.updateSenderRegPostStt(cpQueryFactory, cpSendEpostTargets);
if(!cpSendEgojiTargets.isEmpty()) ePostSendQueryDslRepository.updateGojitPostYn(epQueryFactory, epSendEgojiTargets);
if(!epSendEpostTargets.isEmpty()) ePostSendQueryDslRepository.updateSenderRegPostStt(cpQueryFactory, cpSendEpostTargets);
if(!epSendEgojiTargets.isEmpty()) ePostSendQueryDslRepository.updateGojitPostYn(epQueryFactory, epSendEgojiTargets);
if(!epSendEgojiTargets.isEmpty()) ePostSendQueryDslRepository.updateGojitPostYn(epQueryFactory, epSendEgojiTargets);*/
// 택스트파일 생성
textMaker.generateTextFile(cpSendEpostTargets);
}

@ -38,7 +38,7 @@ public class EpostSetinfoService {
private final DataSource epDataSource;
public EPostDto.SetInfo findSetInfo() {
// 기본정보
// EPOST 기본정보
CpSetinfoId cpInfoId = CpSetinfoId.builder()
.codeName(env.getProperty("e-post.info.cp.codeName"))
.groupCode(env.getProperty("e-post.info.cp.groupCode"))
@ -50,7 +50,7 @@ public class EpostSetinfoService {
.detailCode(env.getProperty("e-post.info.ep.detailCode"))
.build();
// Epost정보
// Epost DOC 정보
CpSetinfoId cpDocId = CpSetinfoId.builder()
.codeName(env.getProperty("e-post.docCode.cp.codeName"))
.groupCode(env.getProperty("e-post.docCode.cp.groupCode"))
@ -142,9 +142,10 @@ public class EpostSetinfoService {
.conOrg(trimOrNull(ePostDocInfo.getStrValue1()))
.rceptId(trimOrNull(ePostDocInfo.getStrValue2()))
.apvlNb(trimOrNull(ePostDocInfo.getStrValue3()))
.filePath(trimOrNull(ePostDocInfo.getStrValue4()))
.postId(trimOrNull(ePostDocInfo.getStrValue5()))
.addPath(trimOrNull(ePostDocInfo.getStrValue6()))
.fileRecvPath(trimOrNull(ePostDocInfo.getStrValue7()))
.fileSendPath(trimOrNull(ePostDocInfo.getStrValue8()))
.docCodes(findDocCodes(ePostDocInfo))
.build();
}

@ -14,9 +14,14 @@ public class TextMaker {
String s(String v){ return v==null? "": v.replace("|",""); }
String t(String v){ return v==null? "": v.replace("\r","").replace("\n","\\n").replace("|",""); }
public void generateTextFile(List<EPostDto.SendTarget.Target> cpSendTargets) {
public void generateTextFile(List<EPostDto.SendTarget.Target> cpSendEpostTargets,
List<EPostDto.SendTarget.Target> epSendEpostTargets,
List<EPostDto.SendTarget.Target> cpSendEgojiTargets,
List<EPostDto.SendTarget.Target> epSendEgojiTargets
) {
// cpSendTargets을
log.info(epSendEpostTargets.toString());
}

@ -1,5 +1,6 @@
package com.worker.util.zipFileMaker;
import com.worker.domain.entity.CpSetinfo;
import com.worker.scheduler.epost.dto.EPostDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -18,35 +19,35 @@ public class ZipMaker {
/**
* CP/EP .jpeg ZIP .
*/
public void generateZipFile(List<String> cpMmCodes, List<String> epMmCodes, EPostDto.SetInfo setInfo) throws IOException {
public void generateZipFile(List<EPostDto.SendTarget.ImgTarget> zipTargets, CpSetinfo setInfo) throws IOException {
//todo : 이거 잠시 멈추고 setinfo 쪽 다시 손보자. epostSetinfoService.findSetInfo()
//todo : 여기에 굳이 뎁스 딥하게 나누지말고 필요한 정보들만 하나의 dto로 만들면 될듯 EPostInfo 이거처럼
Objects.requireNonNull(setInfo, "setInfo is null");
String cpPath = setInfo.getCpSetinfo().getStrValue5();
String epPath = setInfo.getEpSetinfo().getStrValue5();
String cpZipPath = setInfo.getCpSetinfo().getStrValue4();
String epZipPath = setInfo.getCpSetinfo().getStrValue4();
String path = setInfo.getStrValue8() + setInfo.getStrValue5();
String cpBackupPath = setInfo.getStrValue10();
// ZIP 저장 디렉토리 없으면 생성
File cpZipFile = new File(cpZipPath);
File epZipFile = new File(epZipPath);
File zipFile = new File(path);
try {
FileOutputStream fosCp = new FileOutputStream(cpZipFile);
FileOutputStream fosEp = new FileOutputStream(epZipFile);
ZipOutputStream zosCp = new ZipOutputStream(fosCp);
ZipOutputStream zosEp = new ZipOutputStream(fosEp);
FileOutputStream fos = new FileOutputStream(zipFile);
ZipOutputStream zos = new ZipOutputStream(fos);
// 1) CP
for (String code : safeList(cpMmCodes)) {
List<File> files = findExistingJpegs(cpPath, code);
addFilesToZip(zosCp, files, code + "/");
for (EPostDto.SendTarget.ImgTarget target : safeList(zipTargets)) {
List<File> files = findExistingJpegs(path, target.getMmCode());
addFilesToZip(zos, files, target.getConKey() + "/");
}
// 2) EP
for (String code : safeList(epMmCodes)) {
List<File> files = findExistingJpegs(epPath, code);
addFilesToZip(zosEp, files, code + "/");
}
// // 2) EP
// for (String code : safeList(zipTargets)) {
// List<File> files = findExistingJpegs(epPath, code);
// addFilesToZip(zosEp, files, code + "/");
// }
log.info("집 객체추가");
} catch(Exception e) {
log.error("ZIP 객체 생성 실패 : " + e.getMessage());
}

@ -43,7 +43,7 @@ spring:
scheduler:
smg:
enabled: false
enabled: true
epost:
enabled: true
tax-sunap:
@ -56,11 +56,11 @@ esb:
cp:
codeName: WORKER
groupCode: INFO
detailCode: DEV
detailCode: LOCAL
ep:
codeName: WORKER
groupCode: INFO
detailCode: DEV
detailCode: LOCAL
tax-else:
protocol: http://

Loading…
Cancel
Save