연계 방식 case에 따른 처리 소스 추가

main
이범준 4 months ago
parent 1219d728f6
commit 14536865b4

@ -1,5 +1,6 @@
package cokr.xit.fims.cvlc.service.bean; package cokr.xit.fims.cvlc.service.bean;
import java.net.http.HttpResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -10,6 +11,11 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.FileQuery;
import cokr.xit.base.file.service.bean.FileBean; import cokr.xit.base.file.service.bean.FileBean;
import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CmmnUtil;
@ -33,10 +39,13 @@ import cokr.xit.fims.sprt.Sprt;
import cokr.xit.fims.sprt.service.bean.MediaBean; import cokr.xit.fims.sprt.service.bean.MediaBean;
import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import cokr.xit.foundation.web.WebClient;
import cokr.xit.interfaces.disabledparking.service.bean.DisabledParkingBean; import cokr.xit.interfaces.disabledparking.service.bean.DisabledParkingBean;
@Service("crdnCvlcptService") @Service("crdnCvlcptService")
public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService { public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService {
@Resource(name="objectMapper")
private ObjectMapper objectMapper;
@Resource(name="fileBean") @Resource(name="fileBean")
private FileBean fileBean; private FileBean fileBean;
@ -463,8 +472,28 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv
} }
if(!vehicleResultMap.containsKey(vhrno)) { if(!vehicleResultMap.containsKey(vhrno)) {
DataObject inquireResult;
DataObject inquireResult = disabledParkingBean.getParkingInfo(crdnInfo.string("VHRNO"));
if(1 != 1) { //TODO:별도서비스여부
String LINK_SRVC_PROTOCOL_IP_PORT = "http://127.0.0.1:9078";
HttpResponse<String> apiRslt = new WebClient().post(request -> {
request.contentType(WebClient.Request.ContentType.JSON);
request.uri(LINK_SRVC_PROTOCOL_IP_PORT+"/intf/disabledParking/parkingInfo");
request.data("vehicleNo", crdnInfo.string("VHRNO"));
});
String rslt = apiRslt.body();
try {
inquireResult = objectMapper.readValue(rslt, new TypeReference<DataObject>() {});
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonProcessingException e) {
e.printStackTrace();
}
} else {
inquireResult = disabledParkingBean.getParkingInfo(crdnInfo.string("VHRNO"));
}
String parkingPsblYn = inquireResult.string("PARKING_PSBL_YN"); String parkingPsblYn = inquireResult.string("PARKING_PSBL_YN");
String bohunParkingPsblYn = inquireResult.string("BOHUN_PARKING_PSBL_YN"); String bohunParkingPsblYn = inquireResult.string("BOHUN_PARKING_PSBL_YN");

@ -7,6 +7,7 @@ import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
@ -27,6 +28,7 @@ import javax.net.ssl.X509TrustManager;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import cokr.xit.base.code.CommonCode; import cokr.xit.base.code.CommonCode;
@ -56,6 +58,11 @@ import cokr.xit.fims.nxrp.support.OnlyImageMaker;
import cokr.xit.foundation.component.AbstractBean; import cokr.xit.foundation.component.AbstractBean;
import cokr.xit.foundation.data.DataObject; import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.filejob.JobConf; import cokr.xit.interfaces.filejob.JobConf;
import cokr.xit.interfaces.lntris.basic.a.LntrisA01;
import cokr.xit.interfaces.lntris.basic.a.LntrisA01.A01Response;
import cokr.xit.interfaces.lntris.basic.a.LntrisA03;
import cokr.xit.interfaces.lntris.basic.a.LntrisA03.A03Response;
import cokr.xit.interfaces.lntris.basic.a.service.LntrisAService;
/** Bean /** Bean
* *
@ -70,6 +77,12 @@ import cokr.xit.interfaces.filejob.JobConf;
@Component("nisIndivBean") @Component("nisIndivBean")
public class NisIndivBean extends AbstractBean { public class NisIndivBean extends AbstractBean {
@Resource(name="objectMapper")
private ObjectMapper objectMapper;
@Resource(name = "lntrisAService")
private LntrisAService lntrisAService;
/** 과태료 대장 단속 정보 등록 정보 DAO */ /** 과태료 대장 단속 정보 등록 정보 DAO */
@Resource(name = "nisA01Mapper") @Resource(name = "nisA01Mapper")
private NisA01Mapper nisA01Mapper; private NisA01Mapper nisA01Mapper;
@ -279,23 +292,41 @@ public class NisIndivBean extends AbstractBean {
a01.setCreatedBy(userInfo.string("USER_ID")); a01.setCreatedBy(userInfo.string("USER_ID"));
a01.setModifiedBy(userInfo.string("USER_ID")); a01.setModifiedBy(userInfo.string("USER_ID"));
// 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록 // 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록
ObjectMapper mapper = new ObjectMapper(); if(1 == 1) { //TODO:별도연계서비스여부
String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a01/register"; // create String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a01/register"; // create
String sJsonData = "";
// Json 파라미터 설정 ObjectMapper mapper = new ObjectMapper();
try {
sJsonData = "{ " String sJsonData = "";
+ " \"taskSeCd\":" + "\"" + a01.getTaskSeCd() + "\""
+ ", \"msg\":" + mapper.writeValueAsString(a01) // Json 파라미터 설정
+ " }"; try {
} catch (IOException e) { sJsonData = "{ "
throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback + " \"taskSeCd\":" + "\"" + a01.getTaskSeCd() + "\""
} + ", \"msg\":" + mapper.writeValueAsString(a01)
+ " }";
} catch (IOException e) {
throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback
}
// 연계 서비스 호출 후 메세지 return
rtnMsg = callHttpsJson(sUrl, "POST", sJsonData);
} else {
LntrisA01.A01ReqDetail rd = (LntrisA01.A01ReqDetail) this.convert(a01, LntrisA01.A01ReqDetail.class);
List<A01Response> res = lntrisAService.registerA01s(a01.getTaskSeCd(), List.of(rd));
// 연계 서비스 호출 후 메세지 return A01Response res0 = !res.isEmpty() ? res.get(0) : null;
rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); try {
rtnMsg = objectMapper.writeValueAsString(res0);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
return rtnMsg; return rtnMsg;
} }
@ -360,22 +391,42 @@ public class NisIndivBean extends AbstractBean {
a03Rqst.setLinkMngKey(req.getLinkMngKey()); // 연계관리키 시군구코드 + 단속 ID + 년월일시분초 a03Rqst.setLinkMngKey(req.getLinkMngKey()); // 연계관리키 시군구코드 + 단속 ID + 년월일시분초
// 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록 // 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록
ObjectMapper mapper = new ObjectMapper(); if(1 == 1) { //TODO:별도연계서비스여부
String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a03/info"; // create String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a03/info"; // create
String sJsonData = "";
// Json 파라미터 설정 ObjectMapper mapper = new ObjectMapper();
try { String sJsonData = "";
sJsonData = "{ "
+ " \"taskSeCd\":" + "\"" + a03Rqst.getTaskSeCd() + "\"" // Json 파라미터 설정
+ ", \"msg\":" + mapper.writeValueAsString(a03Rqst) try {
+ " }"; sJsonData = "{ "
} catch (IOException e) { + " \"taskSeCd\":" + "\"" + a03Rqst.getTaskSeCd() + "\""
throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback + ", \"msg\":" + mapper.writeValueAsString(a03Rqst)
} + " }";
} catch (IOException e) {
throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback
}
// 연계 서비스 호출 후 메세지 return
rtnMsg = callHttpsJson(sUrl, "POST", sJsonData);
} else {
// 연계 서비스 호출 후 메세지 return LntrisA03.A03ReqDetail rd = new LntrisA03.A03ReqDetail();
rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); rd.setSgbCd(a03Rqst.getSgbCd());
rd.setFinScrgAcbKey(a03Rqst.getFinScrgAcbKey());
rd.setLinkMngKey(a03Rqst.getLinkMngKey());
rd.setLinkTrgtCd(a03Rqst.getLinkTrgtCd());
A03Response res = lntrisAService.getA03(a03Rqst.getTaskSeCd(), rd);
try {
rtnMsg = objectMapper.writeValueAsString(res);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
return rtnMsg; return rtnMsg;
} }
@ -700,4 +751,17 @@ public class NisIndivBean extends AbstractBean {
return rtnMsg; return rtnMsg;
} }
private Object convert(Object s, Class<? extends Object> t) {
DataObject convert = new DataObject();
DataObject convert2 = new DataObject();
convert = objectMapper.convertValue(s, DataObject.class);
Field[] fs = t.getDeclaredFields();
for(Field f : fs) {
String fn = f.getName();
String val = convert.string(fn);
convert2.set(fn, val);
}
return objectMapper.convertValue(convert2, t);
}
} }

Loading…
Cancel
Save