diff --git a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java index 27fa46cf..aab9ee07 100644 --- a/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java +++ b/src/main/java/cokr/xit/fims/cvlc/service/bean/CrdnCvlcptServiceBean.java @@ -1,5 +1,6 @@ package cokr.xit.fims.cvlc.service.bean; +import java.net.http.HttpResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -10,6 +11,11 @@ import javax.annotation.Resource; 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.bean.FileBean; 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.foundation.component.AbstractServiceBean; import cokr.xit.foundation.data.DataObject; +import cokr.xit.foundation.web.WebClient; import cokr.xit.interfaces.disabledparking.service.bean.DisabledParkingBean; @Service("crdnCvlcptService") public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCvlcptService { + @Resource(name="objectMapper") + private ObjectMapper objectMapper; @Resource(name="fileBean") private FileBean fileBean; @@ -463,8 +472,28 @@ public class CrdnCvlcptServiceBean extends AbstractServiceBean implements CrdnCv } if(!vehicleResultMap.containsKey(vhrno)) { - - DataObject inquireResult = disabledParkingBean.getParkingInfo(crdnInfo.string("VHRNO")); + DataObject inquireResult; + + if(1 != 1) { //TODO:별도서비스여부 + + String LINK_SRVC_PROTOCOL_IP_PORT = "http://127.0.0.1:9078"; + + HttpResponse 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() {}); + } 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 bohunParkingPsblYn = inquireResult.string("BOHUN_PARKING_PSBL_YN"); diff --git a/src/main/java/cokr/xit/fims/nxrp/service/bean/NisIndivBean.java b/src/main/java/cokr/xit/fims/nxrp/service/bean/NisIndivBean.java index 3393f473..d26fbafe 100644 --- a/src/main/java/cokr/xit/fims/nxrp/service/bean/NisIndivBean.java +++ b/src/main/java/cokr/xit/fims/nxrp/service/bean/NisIndivBean.java @@ -7,6 +7,7 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.lang.reflect.Field; import java.net.URL; import java.nio.charset.Charset; import java.security.cert.CertificateException; @@ -27,6 +28,7 @@ import javax.net.ssl.X509TrustManager; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; 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.data.DataObject; 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 * @@ -70,6 +77,12 @@ import cokr.xit.interfaces.filejob.JobConf; @Component("nisIndivBean") public class NisIndivBean extends AbstractBean { + @Resource(name="objectMapper") + private ObjectMapper objectMapper; + + @Resource(name = "lntrisAService") + private LntrisAService lntrisAService; + /** 과태료 대장 단속 정보 등록 정보 DAO */ @Resource(name = "nisA01Mapper") private NisA01Mapper nisA01Mapper; @@ -279,23 +292,41 @@ public class NisIndivBean extends AbstractBean { a01.setCreatedBy(userInfo.string("USER_ID")); a01.setModifiedBy(userInfo.string("USER_ID")); + // 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록 - ObjectMapper mapper = new ObjectMapper(); - String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a01/register"; // create - String sJsonData = ""; + if(1 == 1) { //TODO:별도연계서비스여부 + String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a01/register"; // create - // Json 파라미터 설정 - try { - sJsonData = "{ " - + " \"taskSeCd\":" + "\"" + a01.getTaskSeCd() + "\"" - + ", \"msg\":" + mapper.writeValueAsString(a01) - + " }"; - } catch (IOException e) { - throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback - } + ObjectMapper mapper = new ObjectMapper(); + + String sJsonData = ""; + + // Json 파라미터 설정 + try { + sJsonData = "{ " + + " \"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 res = lntrisAService.registerA01s(a01.getTaskSeCd(), List.of(rd)); - // 연계 서비스 호출 후 메세지 return - rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); + A01Response res0 = !res.isEmpty() ? res.get(0) : null; + try { + rtnMsg = objectMapper.writeValueAsString(res0); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + } return rtnMsg; } @@ -360,22 +391,42 @@ public class NisIndivBean extends AbstractBean { a03Rqst.setLinkMngKey(req.getLinkMngKey()); // 연계관리키 시군구코드 + 단속 ID + 년월일시분초 // 차세대 세외수입 연계 서비스 호출 - A01 과태료 대장 단속 정보 등록 - ObjectMapper mapper = new ObjectMapper(); - String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a03/info"; // create - String sJsonData = ""; + if(1 == 1) { //TODO:별도연계서비스여부 + String sUrl = deptInfo.string("NXRP_LINK_SRVC_URL") + "/intf/lntris/a03/info"; // create - // Json 파라미터 설정 - try { - sJsonData = "{ " - + " \"taskSeCd\":" + "\"" + a03Rqst.getTaskSeCd() + "\"" - + ", \"msg\":" + mapper.writeValueAsString(a03Rqst) - + " }"; - } catch (IOException e) { - throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback - } + ObjectMapper mapper = new ObjectMapper(); + String sJsonData = ""; + + // Json 파라미터 설정 + try { + sJsonData = "{ " + + " \"taskSeCd\":" + "\"" + a03Rqst.getTaskSeCd() + "\"" + + ", \"msg\":" + mapper.writeValueAsString(a03Rqst) + + " }"; + } catch (IOException e) { + throw new RuntimeException("세외수입 과태료대장에 전송할 자료 생성중 오류가 발생하였습니다."); // 예외를 발생시켜서 DB Rollback + } + + // 연계 서비스 호출 후 메세지 return + rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); + + } else { - // 연계 서비스 호출 후 메세지 return - rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); + LntrisA03.A03ReqDetail rd = new LntrisA03.A03ReqDetail(); + 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; } @@ -700,4 +751,17 @@ public class NisIndivBean extends AbstractBean { return rtnMsg; } + private Object convert(Object s, Class 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); + } }