feat: 엑셀 업로드 전자우편일 경우 tb_ens_post_plus_json 테이블 insert

dev
sjh88 1 year ago
parent ea472a303e
commit 940342cc48

@ -27,4 +27,5 @@ public interface ICmmEnsFileMapper {
int insertCntcSndngMst(CntcDTO.SndngMst dto);
int insertCntcSndngDtl(CntcDTO.SndngDtl dto);
int insertCi(CmmEnsFileInfDTO.FmcInfExcelRslt dto);
int insertPostPlusJson(CntcDTO.PostPlusJson dto);
}

@ -77,29 +77,26 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
public String fmcExcelUpload(FmcExcelUpload fileReq) {
final Set<ConstraintViolation<FmcExcelUpload>> errors = validator.validate(fileReq);
if (!errors.isEmpty()) {
throw BizRuntimeException.create(errors.stream()
.map(row -> String.format("%s=%s", row.getPropertyPath(), row.getMessageTemplate()))
.toList().toString());
}
// 템플릿 정보 조회
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
CmmEnsRequestDTO tmpDTO = mapper.findDeptInfoByTmplId(
fmcExcels.get(0).getTmplatId())
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
// TODO :: CI 변환
// Ci 변환
fileReq.setSignguCode(tmpDTO.getSignguCode());
fileReq.setFfnlgCode(tmpDTO.getFfnlgCode());
fileReq.setTry1(tmpDTO.getTry1());
List<FmcInfExcelRslt> rslts = getConvertCis(fileReq, fmcExcels);
// TODO :: CNTC 테이블 insert
// CNTC 테이블 insert
String msg = makeCntc(rslts, fmcExcels, fileReq);
// TODO :: POST-PLUS(전자우편) 일 경우 tb_ens_post_plus_json 테이블 insert
fileReq.setSndngCo(fmcExcels.size());
fileReq.setUnitySndngMastrId(UUID.randomUUID().toString().replaceAll("-", ""));
@ -289,9 +286,10 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
private String makeCntc(final List<FmcInfExcelRslt> rslts, final List<FmcInfExcel> fmcExcels, FmcExcelUpload fileReq){
int mst = 0;
int errCnt = 0;
String mpc = null;
final int excelCnt = fmcExcels.size();
final String register = StringUtils.defaultString(fileReq.getRegister(),"");
String unitySndngMastrId = "";
String register = StringUtils.defaultString(fileReq.getRegister(),"");
for(FmcInfExcelRslt dto : rslts){
if(StringUtils.isEmpty(String.join("", dto.getCi1(), dto.getCi2()))){
@ -315,19 +313,42 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
.register(register)
.build()
);
mst++;
}
String mpc = "";
switch (StringUtils.defaultString(fileReq.getSignguCode(), "")) {
case "88328":
mpc = jsonCn1(dto);
break;
case "88316":
mpc = jsonCn2(dto);
break;
default:
break;
mst++;
// POST-PLUS(전자우편) 일 경우 tb_ens_post_plus_json 테이블 insert
if("POST-PLUS".equals(fileReq.getTry1())){
String ppJson[] = PPJson(Integer.toString(mst),dto);
mapper.insertPostPlusJson(
CntcDTO.PostPlusJson.builder()
.unitySndngDetailId(dto.getUnitySndngDetailId())
.signguCode(fileReq.getSignguCode())
.ffnlgCode(fileReq.getFfnlgCode())
.serviceCd("PST")
.conKey(unitySndngMastrId)
.sn(Integer.toString(mst))
.masterCols(ppJson[0])
.masterRows(ppJson[1])
.detailCols(ppJson[2])
.detailRows(ppJson[3])
.taxNum1(dto.getTaxNum1())
.taxNum2(dto.getTaxNum2())
.taxNum3(dto.getTaxNum3())
.taxNum4(dto.getTaxNum4())
.register(register)
.build()
);
}else {
switch (fileReq.getSignguCode()) {
case "88328":
mpc = jsonCn1(dto);
break;
case "88316":
mpc = jsonCn2(dto);
break;
default:
break;
}
}
//CNTC detail 생성
mapper.insertCntcSndngDtl(
@ -662,4 +683,88 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
+"}";
return jsonCn;
}
private String[] PPJson(String no, FmcInfExcel dto){
String[] returnJson = new String[4];
returnJson[0] = "["
+ "\"버전\",\"테스트여부\",\"서비스\",\"연계식별키\",\"봉투\","
+ "\"봉투창\",\"흑백칼라\",\"단면양면\",\"배달\",\"템플릿코드\","
+ "\"템플릿출력여부\",\"페이지수\",\"동봉물페이지수\",\"수취인수\",\"주소페이지유무\","
+ "\"맞춤자제유무\",\"메일머지유무\",\"반송여부\",\"스테이플러유무\",\"발송인명\","
+ "\"발송인우편번호\",\"발송인주소\",\"발송인상세주소\",\"발송인전화번호\""
+ "]";
returnJson[1] = "["
+ "\"v1.10\","
+ "\"Y\","
+ "\"PST\","
+ "\"TEST20230221_000001\","
+ "\"소봉투\","
+ "\"이중창\","
+ "\"칼라\","
+ "\"양면\","
+ "\"일반\","
+ "\"001\","
+ "\"Y\","
+ "1,"
+ "0,"
+ "1,"
+ "\"N\","
+ "\"Y\","
+ "\"N\","
+ "\"N\","
+ "\"N\","
+ "\""+ Checks.checkVal(dto.getSenderNm(),"") +"\","
+ "\""+ Checks.checkVal(dto.getSenderZipNo(),"") +"\","
+ "\""+ Checks.checkVal(dto.getSenderAddr(),"") +"\","
+ "\""+ Checks.checkVal(dto.getSenderDetailAddr(),"") +"\","
+ "\""+ Checks.checkVal(dto.getSenderTelno(),"") +"\""
+ "]";
returnJson[2] = "["
+ "\"순번\",\"수취인 명\",\"수취인 우편번호\",\"수취인 주소\",\"수취인 상세주소\","
+ "\"수취인 전화번호\",\"고지서 구분명\",\"고지서 명\",\"고지서 상세명\",\"QR 바코드\","
+ "\"부과대상\",\"기관번호\",\"세목\",\"납세년월기\",\"과세번호\","
+ "\"부과내역1\",\"부과내역2\",\"납부금액명1\",\"납부금액상세명1\",\"납부금액상세명2\","
+ "\"납부금액상세명3\",\"납기구분1\",\"납기구분2\",\"납기내기한\",\"납기내금액1\","
+ "\"납기내금액2\",\"납기내금액3\",\"납기내금액4\",\"납기내합계액\",\"출력일자\","
+ "\"담당자\",\"우리가상계좌\",\"신한가상계좌\",\"하나가상계좌\""
+ "]";
returnJson[3] = "["
+ "\""+ no +"\","
+ "\""+ Checks.checkVal(dto.getRecevNm(),"") +"\","
+ "\""+ Checks.checkVal(dto.getRecevZipNo(),"") +"\","
+ "\""+ Checks.checkVal(dto.getRecevAddr(),"") +"\","
+ "\""+ Checks.checkVal(dto.getRecevDetailAddr(),"") +"\","
+ "\""+ Checks.checkVal(dto.getRecevTelno(),"") +"\","
+ "\""+ Checks.checkVal(dto.getGojiGubun(),"") +"\","
+ "\""+ Checks.checkVal(dto.getGojiNm(),"") +"\","
+ "\""+ Checks.checkVal(dto.getGojiDetailNm(),"") +"\","
+ "\""+ Checks.checkVal(dto.getQrBarcode(),"") +"\","
+ "\""+ Checks.checkVal(dto.getBuTarget(),"") +"\","
+ "\""+ Checks.checkVal(dto.getTaxNum1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getTaxNum2(),"") +"\","
+ "\""+ Checks.checkVal(dto.getTaxNum3(),"") +"\","
+ "\""+ Checks.checkVal(dto.getTaxNum4(),"") +"\","
+ "\""+ Checks.checkVal(dto.getBuContent1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getBuContent2(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmountNm1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmountDetailNm1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmountDetailNm2(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmountDetailNm3(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapGubun1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapGubun2(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapPd(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmount1(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmount2(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmount3(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmount4(),"") +"\","
+ "\""+ Checks.checkVal(dto.getNapAmountTotal(),"") +"\","
+ "\""+ Checks.checkVal(dto.getPrtDe(),"") +"\","
+ "\""+ Checks.checkVal(dto.getWorker(),"") +"\","
+ "\""+ Checks.checkVal(dto.getWVacct(),"") +"\","
+ "\""+ Checks.checkVal(dto.getSVacct(),"") +"\","
+ "\""+ Checks.checkVal(dto.getHVacct(),"") +"\""
+ "]";
return returnJson;
}
}

@ -6,6 +6,7 @@
/** ens-cmm-file-mysql-mapper|findDeptInfoByTmplId-템플릿ID로 부서정보 조회|seojh */
SELECT tetm.signgu_code
, tetm.ffnlg_code
, tetm.try1
FROM tb_ens_tmplat_manage tetm
WHERE tmplat_id = #{tmplatId}
</select>
@ -85,5 +86,44 @@
, #{register}
)
</insert>
<insert id="insertPostPlusJson">
/** ens-cmm-file-mysql-mapper|insertPostPlusJson-포스트 플러스 json 생성|seojh */
INSERT
INTO tb_ens_post_plus_json(
unity_sndng_detail_id,
signgu_code,
ffnlg_code,
service_cd,
con_key,
sn,
master_cols,
master_rows,
detail_cols,
detail_rows,
tax_num1,
tax_num2,
tax_num3,
tax_num4,
regist_dt,
register
) VALUES (
#{unitySndngDetailId}
, #{signguCode}
, #{ffnlgCode}
, #{serviceCd}
, #{conKey}
, #{sn}
, #{masterCols}
, #{masterRows}
, #{detailCols}
, #{detailRows}
, #{taxNum1}
, #{taxNum2}
, #{taxNum3}
, #{taxNum4}
, now()
, #{register}
)
</insert>
</mapper>

@ -55,4 +55,11 @@ public class CmmEnsRequestDTO {
@Schema(requiredMode = RequiredMode.AUTO, title = "profile", example = "local")
@JsonProperty("profile")
private String profile;
/**
* 1
*/
@Schema(requiredMode = RequiredMode.AUTO, title = "1차 발송", example = "KKO-MY-DOC")
@JsonProperty("try1")
private String try1;
}

@ -201,4 +201,68 @@ public class CntcDTO {
*/
private String documentBinderUuid;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public static class PostPlusJson extends AuditFields implements Serializable {
/**
* id
*/
private String unitySndngDetailId;
/**
*
*/
private String signguCode;
/**
*
*/
private String ffnlgCode;
/**
*
*/
private String serviceCd;
/**
*
*/
private String conKey;
/**
*
*/
private String sn;
/**
* master_cols
*/
private String masterCols;
/**
* master_rows
*/
private String masterRows;
/**
* detail_cols
*/
private String detailCols;
/**
* detail_rows
*/
private String detailRows;
/**
*
*/
private String taxNum1;
/**
*
*/
private String taxNum2;
/**
*
*/
private String taxNum3;
/**
*
*/
private String taxNum4;
}
}

Loading…
Cancel
Save