|
|
@ -1,13 +1,35 @@
|
|
|
|
package kr.xit.ens.pplus.service;
|
|
|
|
package kr.xit.ens.pplus.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
|
|
|
|
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptReqDataDtl;
|
|
|
|
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptReqDataMst;
|
|
|
|
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptReqDataStruct;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptRequest;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptRequest;
|
|
|
|
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpAcceptRequestStruct;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpCommonResponse;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpCommonResponse;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusRequest;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusRequest;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResponse;
|
|
|
|
import kr.xit.biz.ens.model.pplus.PplusDTO.PpStatusResponse;
|
|
|
|
import kr.xit.core.spring.util.ApiWebClientUtil;
|
|
|
|
import kr.xit.core.spring.util.ApiWebClientUtil;
|
|
|
|
|
|
|
|
import kr.xit.core.support.utils.FileUtil;
|
|
|
|
|
|
|
|
import kr.xit.core.support.utils.JsonUtils;
|
|
|
|
|
|
|
|
import kr.xit.ens.kt.cmm.CmmKtMmsUtils;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
|
|
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
|
|
|
|
|
|
|
import org.json.simple.JSONArray;
|
|
|
|
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* <pre>
|
|
|
|
* <pre>
|
|
|
@ -24,18 +46,158 @@ import org.springframework.stereotype.Service;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* </pre>
|
|
|
|
* </pre>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class PplusService extends EgovAbstractServiceImpl implements IPplusService {
|
|
|
|
public class PplusService extends EgovAbstractServiceImpl implements IPplusService {
|
|
|
|
|
|
|
|
@Value("${file.cmm.temp-path}")
|
|
|
|
|
|
|
|
private String FILE_TEMP_PATH;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${contract.pplus.host}")
|
|
|
|
|
|
|
|
private String HOST;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${contract.pplus.api.accept}")
|
|
|
|
|
|
|
|
private String ACCEPT;
|
|
|
|
|
|
|
|
|
|
|
|
private final ApiWebClientUtil webClient;
|
|
|
|
private final ApiWebClientUtil webClient;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PpCommonResponse accept(PpAcceptRequest reqDTO) {
|
|
|
|
public PpCommonResponse accept(PpAcceptRequest reqDTO) {
|
|
|
|
|
|
|
|
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getKtMnsInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
|
|
|
|
|
|
|
|
reqDTO.setApiKey(ktMnsInfo.getPplusApiKey());
|
|
|
|
|
|
|
|
JSONObject mstJson = makePpAcceptMstData();
|
|
|
|
|
|
|
|
JSONObject dtlJson = makePpAcceptDtlData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PpAcceptRequestStruct reqDataDTO = PpAcceptRequestStruct.builder()
|
|
|
|
|
|
|
|
.master(PpAcceptReqDataStruct.builder()
|
|
|
|
|
|
|
|
.cols(JsonUtils.toJson(mstJson.get("cols")))
|
|
|
|
|
|
|
|
.rows(JsonUtils.toJson(mstJson.get("rows")))
|
|
|
|
|
|
|
|
.build())
|
|
|
|
|
|
|
|
.detail(PpAcceptReqDataStruct.builder()
|
|
|
|
|
|
|
|
.cols(JsonUtils.toJson(dtlJson.get("cols")))
|
|
|
|
|
|
|
|
.rows(JsonUtils.toJson(dtlJson.get("rows")))
|
|
|
|
|
|
|
|
.build())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String reqDataJsonStr = JsonUtils.toJson(reqDataDTO);
|
|
|
|
|
|
|
|
log.debug(reqDataJsonStr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileUtil.saveFile(FILE_TEMP_PATH,"pstFile.json", reqDataJsonStr.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
|
|
MultipartFile pstFile = FileUtil.createMutipartFile("pstFile.json", FILE_TEMP_PATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MultipartFile> pstFiles = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pstFiles.add(pstFile);
|
|
|
|
|
|
|
|
if(ObjectUtils.isNotEmpty(reqDTO.getPstFile())) pstFiles.add(reqDTO.getPstFile());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Map<String,String> headerMap = new HashMap<>();
|
|
|
|
|
|
|
|
headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE);
|
|
|
|
|
|
|
|
// headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
|
|
|
|
|
|
|
// headerMap.put("client-id", "client-id");
|
|
|
|
|
|
|
|
// headerMap.put("client-tp", "10");
|
|
|
|
|
|
|
|
// headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, "access-token"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return webClient.exchangeFile(
|
|
|
|
|
|
|
|
HOST + ACCEPT,
|
|
|
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
|
|
|
pstFiles,
|
|
|
|
|
|
|
|
"pstFile.json",
|
|
|
|
|
|
|
|
PpCommonResponse.class,
|
|
|
|
|
|
|
|
headerMap
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
String reqJson = JsonUtils.toJson(reqDTO);
|
|
|
|
|
|
|
|
reqDTO.setSignguCode(null);
|
|
|
|
|
|
|
|
reqDTO.setFfnlgCode(null);
|
|
|
|
|
|
|
|
String reqJson2 = JsonUtils.toJson(reqDTO);
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PpStatusResponse status(PpStatusRequest reqDTO) {
|
|
|
|
public PpStatusResponse status(PpStatusRequest reqDTO) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject makePpAcceptMstData(){
|
|
|
|
|
|
|
|
PpAcceptReqDataMst mst = PpAcceptReqDataMst.builder()
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
//CmmEnsUtils.validate(mst);
|
|
|
|
|
|
|
|
return JsonUtils.extractObjKeyValue(mst, "cols", "rows");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private JSONObject makePpAcceptDtlData(){
|
|
|
|
|
|
|
|
JSONArray arrJson = new JSONArray();
|
|
|
|
|
|
|
|
PpAcceptReqDataDtl dtl = PpAcceptReqDataDtl.builder()
|
|
|
|
|
|
|
|
.순번("1")
|
|
|
|
|
|
|
|
.이름("홍길동")
|
|
|
|
|
|
|
|
.우편번호("05048")
|
|
|
|
|
|
|
|
.주소("서울특별시 광진구 강변로역2")
|
|
|
|
|
|
|
|
.이미지갯수(1)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CmmEnsUtils.validate(dtl);
|
|
|
|
|
|
|
|
JSONObject dtlJson = JsonUtils.toObjByObj(dtl, JSONObject.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 가변인자 처리
|
|
|
|
|
|
|
|
for(int i=0; i<2; i++) {
|
|
|
|
|
|
|
|
JSONObject json = new JSONObject(dtlJson);
|
|
|
|
|
|
|
|
json.put("f1", "d1-"+i);
|
|
|
|
|
|
|
|
json.put("f2", "d2-"+i);
|
|
|
|
|
|
|
|
json.put("f3", "d3-"+i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arrJson.add(json);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return JsonUtils.extractJsonArrayKeyValue(net.sf.json.JSONArray.fromObject(arrJson), "cols", "rows");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
List<PpAcceptReqDataDtl> dtls = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PpAcceptReqDataDtl dtl = PpAcceptReqDataDtl.builder()
|
|
|
|
|
|
|
|
.순번("1")
|
|
|
|
|
|
|
|
.이름("홍길동")
|
|
|
|
|
|
|
|
.우편번호("05048")
|
|
|
|
|
|
|
|
.주소("서울특별시 광진구 강변로역2")
|
|
|
|
|
|
|
|
.이미지갯수(1)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
dtls.add(dtl);
|
|
|
|
|
|
|
|
dtls.add(dtl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject dtlJson = JsonUtils.extractJsonArrayKeyValue(net.sf.json.JSONArray.fromObject(dtls), "cols", "rows");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray arrDtlColsJson = (JSONArray)dtlJson.get("cols");
|
|
|
|
|
|
|
|
JSONArray tmpArr = new JSONArray();
|
|
|
|
|
|
|
|
tmpArr.add("f1");
|
|
|
|
|
|
|
|
tmpArr.add("f2");
|
|
|
|
|
|
|
|
tmpArr.add("f3");
|
|
|
|
|
|
|
|
arrDtlColsJson.addAll(tmpArr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray arrDtlRowsJson = (JSONArray)dtlJson.get("rows");
|
|
|
|
|
|
|
|
for(int i=0; i<arrDtlRowsJson.size(); i++) {
|
|
|
|
|
|
|
|
JSONArray tmpArr1 = new JSONArray();
|
|
|
|
|
|
|
|
tmpArr1.add("d"+i);
|
|
|
|
|
|
|
|
tmpArr1.add("d"+i);
|
|
|
|
|
|
|
|
tmpArr1.add("d"+i);
|
|
|
|
|
|
|
|
((JSONArray)arrDtlRowsJson.get(i)).addAll(tmpArr1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|