feat: post plus 적용

dev
gitea-관리자 1 year ago
parent e369cc4ff9
commit 9f5d361b88

@ -2,7 +2,7 @@ package kr.xit.biz.cmm.mapper;
import java.util.Optional;
import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.TmplatManage;
import kr.xit.biz.ens.model.cntc.CntcDTO;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
@ -23,7 +23,7 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
*/
@Mapper
public interface ICmmEnsFileMapper {
Optional<CmmEnsRequestDTO> findDeptInfoByTmplId(final String tmplatId);
Optional<TmplatManage> findDeptInfoByTmplId(final String tmplatId);
int insertCntcSndngMst(CntcDTO.SndngMst dto);
int insertCntcSndngDtl(CntcDTO.SndngDtl dto);
int insertCi(CmmEnsFileInfDTO.FmcInfExcelRslt dto);

@ -9,7 +9,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
@ -20,7 +19,7 @@ import kr.xit.biz.common.ApiConstants.NiceCiWrkDiv;
import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcExcelUpload;
import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcInfExcel;
import kr.xit.biz.ens.model.cmm.CmmEnsFileInfDTO.FmcInfExcelRslt;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.TmplatManage;
import kr.xit.biz.ens.model.cntc.CntcDTO;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResDataBody;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
@ -84,7 +83,7 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
// 템플릿 정보 조회
final List<FmcInfExcel> fmcExcels = parsingFmcExcel(fileReq.getFiles()[0]);
CmmEnsRequestDTO tmpDTO = mapper.findDeptInfoByTmplId(
TmplatManage tmpDTO = mapper.findDeptInfoByTmplId(
fmcExcels.get(0).getTmplatId())
.orElseThrow(() -> BizRuntimeException.create("템플릿 정보를 찾을 수 없습니다."));
@ -92,8 +91,8 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
fileReq.setSignguCode(tmpDTO.getSignguCode());
fileReq.setFfnlgCode(tmpDTO.getFfnlgCode());
fileReq.setTry1(tmpDTO.getTry1());
fileReq.setPost_dlvr_se(tmpDTO.getPost_dlvr_se());
fileReq.setPost_tmplat_code(tmpDTO.getPost_tmplat_code());
fileReq.setPostDlvrSe(tmpDTO.getPostDlvrSe());
fileReq.setPostTmplatCode(tmpDTO.getPostTmplatCode());
List<FmcInfExcelRslt> rslts = getConvertCis(fileReq, fmcExcels);
// CNTC 테이블 insert
@ -812,8 +811,8 @@ public class CmmEnsFileService extends EgovAbstractServiceImpl implements ICmmEn
+ "\"이중창\","
+ "\"칼라\","
+ "\"단면\","
+ "\""+ Checks.checkVal(fileReq.getPost_dlvr_se(),"") +"\","
+ "\""+ Checks.checkVal(fileReq.getPost_tmplat_code(),"") +"\","
+ "\""+ Checks.checkVal(fileReq.getPostDlvrSe(),"") +"\","
+ "\""+ Checks.checkVal(fileReq.getPostTmplatCode(),"") +"\","
+ "\"Y\","
+ Checks.checkVal(String.valueOf(excelCnt),"") + ","
+ "\"N\","

@ -111,18 +111,15 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi
public PpStatusResponse statusBulks(PpStatusRequest reqDTO) {
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
reqDTO.setApiKey(ktMnsInfo.getPplusApiKey());
reqDTO.setSignguCode(null);
reqDTO.setFfnlgCode(null);
reqDTO.setProfile(null);
reqDTO.setTry1(null);
CmmEnsUtils.validate(reqDTO);
final Map<String,String> headerMap = new HashMap<>();
headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
// headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, "access-token"));
// headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
// headerMap.put("client-id", "client-id");
// headerMap.put("client-tp", "10");
reqDTO.setSignguCode(null);
reqDTO.setFfnlgCode(null);
reqDTO.setProfile(null);
return webClient.exchange(
HOST + STATUS,
HttpMethod.POST,

@ -1,253 +0,0 @@
package kr.xit.ens.pplus.web;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.model.IApiResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "ApiExample", description = "Postplus(포스토피아) sample API")
@RestController
@RequestMapping("/api/ens/pplus/v1")
public class ApiExample {
private String charset = "utf-8";
private final String boundary = "===" + System.currentTimeMillis() + "===";
private static final String LINE_FEED = "\r\n";
@Operation(summary = "우편제작접수 샘플", description = "우편제작접수 샘플")
@PostMapping(value = "/apiExample", produces = MediaType.APPLICATION_JSON_VALUE)
public IApiResponse apiExample() {
// // master
// JSONArray masterCols = new JSONArray();
// masterCols.add("버전");
// masterCols.add("테스트여부");
// masterCols.add("서비스");
// masterCols.add("연계식별키");
// masterCols.add("봉투");
// masterCols.add("봉투창");
// masterCols.add("흑백칼라");
// masterCols.add("단면양면");
// masterCols.add("배달");
// masterCols.add("템플릿코드");
// masterCols.add("템플릿출력여부");
// masterCols.add("수취인수");
// masterCols.add("여백생성유무");
// masterCols.add("주소페이지유무");
// masterCols.add("맞춤자제유무");
// masterCols.add("메일머지유무");
// masterCols.add("동봉물유무");
// masterCols.add("반송여부");
// masterCols.add("스테이플러유무");
// masterCols.add("로고파일");
// masterCols.add("발송인명");
// masterCols.add("발송인우편번호");
// masterCols.add("발송인주소");
// masterCols.add("발송인상세주소");
// masterCols.add("발송인전화번호");
//
// JSONArray masterRows = new JSONArray();
// masterRows.add("v1.10"); // 버전
// masterRows.add("Y"); // 테스트여부
// masterRows.add("PST"); // 서비스
// masterRows.add("POST20230428_000001"); // 연계식별키
// masterRows.add("소봉투"); // 봉투
// masterRows.add("이중창"); // 봉투창
// masterRows.add("흑백"); // 흑백칼라
// masterRows.add("단면"); // 단면양면
// masterRows.add("일반"); // 배달
// masterRows.add(""); // 템플릿코드
// masterRows.add("N"); // 템플릿출력여부
// masterRows.add(2); // 수취인수
// masterRows.add("N"); // 여백생성유무
// masterRows.add("N"); // 주소페이지유무
// masterRows.add("N"); // 맞춤자제유무
// masterRows.add("N"); // 메일머지유무
// masterRows.add("N"); // 동봉물유무
// masterRows.add("N"); // 반송여부
// masterRows.add("N"); // 스테이플러유무
// masterRows.add("N"); // 로고파일
// masterRows.add("포스토피아"); // 발송인명
// masterRows.add("05048"); // 발송인우편번호
// masterRows.add("서울특별시 광진구 강변역로2"); // 발송인주소
// masterRows.add("서울광진우체국 B동 4층"); // 발송인상세주소
// masterRows.add("1577-8114"); // 발송인전화번호
//
// JSONObject master = new JSONObject();
// master.put("cols", masterCols);
// master.put("rows", masterRows);
//
//
// // detail
// JSONArray detailCols = new JSONArray();
// detailCols.add("순번");
// detailCols.add("이름");
// detailCols.add("우편번호");
// detailCols.add("주소");
// detailCols.add("상세주소");
// detailCols.add("전화번호");
// detailCols.add("첨부파일");
// detailCols.add("가변1");
// detailCols.add("가변2");
// detailCols.add("가변3");
// detailCols.add("가변4");
//
// JSONArray detailRows1 = new JSONArray();
// detailRows1.add("1");
// detailRows1.add("홍길동1");
// detailRows1.add("31010");
// detailRows1.add("서울특별시 광진구 강변역로2");
// detailRows1.add("서울광진우체국 B동 1층");
// detailRows1.add("01012341234");
// detailRows1.add("pstFile.pdf");
// detailRows1.add("24926737");
// detailRows1.add("2021-09-02");
// detailRows1.add("대출(고정)");
// detailRows1.add("31,000,000");
//
// JSONArray detailRows2 = new JSONArray();
// detailRows2.add("2");
// detailRows2.add("홍길동2");
// detailRows2.add("08394");
// detailRows2.add("서울특별시 광진구 강변역로2");
// detailRows2.add("서울광진우체국 B동 2층");
// detailRows2.add("01012341234");
// detailRows2.add("pstFile.pdf");
// detailRows2.add("25685047");
// detailRows2.add("2021-09-02");
// detailRows2.add("대출B(변동)");
// detailRows2.add("421,000,000");
//
// JSONArray detailRows = new JSONArray();
// detailRows.add(detailRows1);
// detailRows.add(detailRows2);
//
// JSONObject detail = new JSONObject();
// detail.put("cols", detailCols);
// detail.put("rows", detailRows);
//
// JSONObject pst = new JSONObject();
// pst.put("master", master);
// pst.put("detail", detail);
//
// // 파일생성 & 저장
// try {
// FileWriter pstFile = new FileWriter("d:/data/temp/pstFile2.json");
// pstFile.write(pst.toJSONString());
// pstFile.flush();
// pstFile.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// API 전송
URL url = null;
HttpURLConnection conn;
try {
url = new URL("https://t.postplus.co.kr/po/api/postplusPstMsrApi.do");
//url = new URL("http://localhost:8081/api/ens/pplus/v1/accept2");
//url = new URL("http://localhost:8081/api/ens/pplus/v1/accept3");
conn = (HttpURLConnection) url.openConnection();
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
conn.setRequestProperty("User-Agent", "CodeJava Agent");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
try (OutputStream ops = conn.getOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(ops, charset), true)) {
//File pstFile = new File("c:/Temp/pstFile.json");
File pstFile = new File("d:/data/temp/pstFile2.json");
//File attchFile = new File("c:/Temp/pstFile.pdf");
addParam(writer, "apiKey", "00197D16F7FE4A84E9C97F55033339FBE07FB374D7C8C94EE4C96BA7D997297AC1E9CB5F1FC50CC3C63F5285923FDAB73679A011D40CA00CE589C98858AEFFE7F64E8E0FCF59EF0DC52B548C13D16FC2BB4");
addFile(writer, ops, "pstFile", pstFile);
//addFile(writer, ops, "pstFile", attchFile);
writer.append("--" + boundary + "--").append(LINE_FEED);
writer.append(LINE_FEED).flush();
} catch (Exception e){
throw BizRuntimeException.create(e);
}
StringBuffer response = new StringBuffer();
try {
int status = conn.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
String line;
while((line = reader.readLine()) != null) {
response.append(line);
}
} catch (IOException e) {
throw BizRuntimeException.create(e);
}
conn.disconnect();
} else {
throw BizRuntimeException.create("Server returned non-OK status: " + status);
}
} catch (IOException e) {
throw BizRuntimeException.create(e);
}
return ApiResponseDTO.success(response.toString());
}
private void addParam(PrintWriter writer, String name, String value) {
writer.append("--" + boundary).append(LINE_FEED);
writer.append("Content-Disposition: form-data; name=\"" + name + "\"").append(LINE_FEED);
writer.append("Content-Type: text/plain; charset=" + charset).append(LINE_FEED);
writer.append(LINE_FEED);
writer.append(value).append(LINE_FEED);
writer.flush();
}
private void addFile(PrintWriter writer, OutputStream ops, String name, File uploadFile) {
String fileName = uploadFile.getName();
writer.append("--" + boundary).append(LINE_FEED);
writer.append("Content-Disposition: form-data; name=\"" + name+ "\"; filename=\"" + fileName + "\"").append(LINE_FEED);
writer.append("Content-Type: "+ URLConnection.guessContentTypeFromName(fileName)).append(LINE_FEED);
writer.append("Content-Transfer-Encoding: binary").append(LINE_FEED);
writer.append(LINE_FEED);
writer.flush();
try (FileInputStream is = new FileInputStream(uploadFile)) {
byte[] buffer = new byte[4096];
int bytesRead = -1;
while((bytesRead = is.read(buffer)) != -1) {
ops.write(buffer, 0, bytesRead);
}
ops.flush();
} catch (IOException e){
throw BizRuntimeException.create(e.getMessage());
}
writer.append(LINE_FEED);
writer.flush();
}
}

@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
/**
* <pre>
@ -72,27 +71,4 @@ public class PplusController {
public IApiResponse status(@RequestBody final PpStatusRequest paramDTO) {
return ApiResponseDTO.success(service.statusBulks(paramDTO));
}
@PostMapping(value = "/accept2")
public IApiResponse accept2() {
return ApiResponseDTO.success();
}
@PostMapping(value = "/accept3")
public ModelAndView accept3() {
return new ModelAndView("/index.html");
}
}

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.xit.biz.cmm.mapper.ICmmEnsFileMapper">
<select id="findDeptInfoByTmplId" resultType="kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO">
<select id="findDeptInfoByTmplId" resultType="kr.xit.biz.ens.model.cmm.TmplatManage">
/** ens-cmm-file-mysql-mapper|findDeptInfoByTmplId-템플릿ID로 부서정보 조회|seojh */
SELECT tetm.signgu_code
, tetm.ffnlg_code

@ -5,6 +5,7 @@ import java.util.Optional;
import kr.xit.biz.ens.model.EnsDTO;
import kr.xit.biz.ens.model.EnsKtBcDTO;
import kr.xit.biz.ens.model.cmm.SndngMssageParam;
import kr.xit.biz.ens.model.cmm.TmplatManage;
import kr.xit.biz.ens.model.cntc.CntcDTO;
import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkStatus;
import kr.xit.biz.ens.model.kakao.KkopayDocDTO.OneTimeToken;
@ -394,7 +395,7 @@ public interface IEnsBatchMapper {
* @return Optional<EnsDTO.TmplatManage>
* </pre>
*/
Optional<EnsDTO.TmplatManage> selectTmplat(final String tmplatId);
Optional<TmplatManage> selectTmplat(final String tmplatId);
/**
* <pre>

@ -252,76 +252,6 @@ public class EnsDTO {
*/
private String externalDocumentUuid;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public static class TmplatManage extends AuditFields implements Serializable {
/**
* 릿 ID
*/
private String tmplatId;
/**
*
*/
private String signguCode;
/**
*
*/
private String ffnlgCode;
/**
*
*/
private String sndngTyCode;
/**
* 릿
*/
private String tmplatNm;
/**
* 릿
*/
private String tmplatSj;
/**
* 릿
*/
private String tmplatCn;
/**
*
*/
private String cstmrCnterTlphonNo;
/**
* REDIRECT URL
*/
private String redirectUrl;
/**
* try1
*/
private String try1;
/**
* try2
*/
private String try2;
/**
* try3
*/
private String try3;
/**
* try2_minute
*/
private int try2Minute;
/**
* try3_minute
*/
private int try3Minute;
/**
*
*/
private String useAt;
}
@Data
@NoArgsConstructor
@AllArgsConstructor

@ -1012,9 +1012,7 @@
AND tekmd.document_binder_uuid = #{document_binder_uuid}
</select>
<select id="selectTmplat" resultType="kr.xit.biz.ens.model.EnsDTO$TmplatManage">
<select id="selectTmplat" resultType="kr.xit.biz.ens.model.cmm.TmplatManage">
/** ens-mysql-mapper|selectTmplat-템플릿정보조회|julim */
SELECT tmplat_id /* 템플릿 아이디 */
, signgu_code /* 시군구 코드 */

@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.time.LocalDateTime;
import javax.validation.constraints.Size;
import kr.xit.biz.ens.model.nice.NiceCiDTO.IpinCiResEncData;
import lombok.AllArgsConstructor;
@ -17,8 +18,6 @@ import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
/**
* <pre>
* description : DTO
@ -82,6 +81,8 @@ public class CmmEnsFileInfDTO {
@Schema(requiredMode = RequiredMode.AUTO, title = "통합발송마스터ID", example = "0", description = "통합발송마스터ID")
private String unitySndngMastrId;
private String postDlvrSe;
private String postTmplatCode;
}
@Schema(name = "FmcInfExcel", description = "시설관리공단 전자문서 발송대상 엑셀 파일 interface DTO")

@ -62,18 +62,4 @@ public class CmmEnsRequestDTO {
@Schema(requiredMode = RequiredMode.AUTO, title = "1차 발송", example = "KKO-MY-DOC")
@JsonProperty("try1")
private String try1;
/**
*
*/
@Schema(requiredMode = RequiredMode.AUTO, title = "우편 배달 구분", example = "일반")
@JsonProperty("post_dlvr_se")
private String post_dlvr_se;
/**
* 릿
*/
@Schema(requiredMode = RequiredMode.AUTO, title = "우편 템플릿 코드", example = "SISUL_TRAFFIC")
@JsonProperty("post_tmplat_code")
private String post_tmplat_code;
}

@ -0,0 +1,81 @@
package kr.xit.biz.ens.model.cmm;
import java.io.Serializable;
import kr.xit.biz.common.AuditFields;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class TmplatManage extends AuditFields implements Serializable {
/**
* 릿 ID
*/
private String tmplatId;
/**
*
*/
private String signguCode;
/**
*
*/
private String ffnlgCode;
/**
*
*/
private String sndngTyCode;
/**
* 릿
*/
private String tmplatNm;
/**
* 릿
*/
private String tmplatSj;
/**
* 릿
*/
private String tmplatCn;
/**
*
*/
private String cstmrCnterTlphonNo;
/**
* REDIRECT URL
*/
private String redirectUrl;
/**
* try1
*/
private String try1;
/**
* try2
*/
private String try2;
/**
* try3
*/
private String try3;
/**
* try2_minute
*/
private int try2Minute;
/**
* try3_minute
*/
private int try3Minute;
/**
*
*/
private String useAt;
private String postDlvrSe;
private String postTmplatCode;
}
Loading…
Cancel
Save