diff --git a/src/main/java/cokr/xit/adds/nims/BsshQuery.java b/src/main/java/cokr/xit/adds/nims/BsshQuery.java new file mode 100644 index 0000000..6b0a446 --- /dev/null +++ b/src/main/java/cokr/xit/adds/nims/BsshQuery.java @@ -0,0 +1,161 @@ +package cokr.xit.adds.nims; + +import cokr.xit.foundation.component.QueryRequest; + +/**단속 대장 정보 조회 요청 +* +*

상세 설명: +* +*

+* ============ 변경 이력 ============
+* 2023-06-23	leebj 최초 작성
+* ================================
+* 
+*/ +public class BsshQuery extends QueryRequest{ + + private static final long serialVersionUID = 1L; + + //검색조건 + private String schBsshCd; // 취급자 식별번호 + private String schBsshNm; // 취급자 명 + + //저장소 정보 + private String bsshCd; // 취급자 식별번호 + private String bsshNm; // 취급자명 + private String indutyNm; // 업종명 + private String hdntCd; // 의료업자 구분 + private String hdntNm; // 의료업자 구분명 + private String bizrno; // 사업자등록번호 + private String rprsntvNm; // 대표자 명 + private String chrgNm; // 담당자 명 + private String hptlNo; // 요양기관 기호 + private String joinYn; // 획원가입 여부 + private String bsshSttsNm; // 상태 + private String prmisnNo; // 허가 번호 + + public String getSchBsshCd() { + return ifEmpty(schBsshCd, () -> null); + } + + public T setSchBsshCd(String schBsshCd) { + this.schBsshCd = schBsshCd; + return self(); + } + + public String getSchBsshNm() { + return ifEmpty(schBsshNm, () -> null); + } + + public T setSchBsshNm(String schBsshNm) { + this.schBsshNm = schBsshNm; + return self(); + } + + public String getbsshCd() { + return ifEmpty(bsshCd, () -> null); + } + + public T setbsshCd(String bsshCd) { + this.bsshCd = bsshCd; + return self(); + } + + public String getbsshNm() { + return ifEmpty(bsshNm, () -> null); + } + + public T setbsshNm(String bsshNm) { + this.bsshNm = bsshNm; + return self(); + } + + public String getindutyNm() { + return ifEmpty(indutyNm, () -> null); + } + + public T setindutyNm(String indutyNm) { + this.indutyNm = indutyNm; + return self(); + } + + public String gethdntCd() { + return ifEmpty(hdntCd, () -> null); + } + + public T sethdntCd(String hdntCd) { + this.hdntCd = hdntCd; + return self(); + } + public String gethdntNm() { + return ifEmpty(hdntNm, () -> null); + } + + public T sethdntNm(String hdntNm) { + this.hdntNm = hdntNm; + return self(); + } + + public String getbizrno() { + return ifEmpty(bizrno, () -> null); + } + + public T setbizrno(String bizrno) { + this.bizrno = bizrno; + return self(); + } + + public String getrprsntvNm() { + return ifEmpty(rprsntvNm, () -> null); + } + + public T setrprsntvNm(String rprsntvNm) { + this.rprsntvNm = rprsntvNm; + return self(); + } + + public String getchrgNm() { + return ifEmpty(chrgNm, () -> null); + } + + public T setchrgNm(String chrgNm) { + this.chrgNm = chrgNm; + return self(); + } + + public String gethptlNo() { + return ifEmpty(hptlNo, () -> null); + } + + public T sethptlNo(String hptlNo) { + this.hptlNo = hptlNo; + return self(); + } + + public String getjoinYn() { + return ifEmpty(joinYn, () -> null); + } + + public T setjoinYn(String joinYn) { + this.joinYn = joinYn; + return self(); + } + + public String getbsshSttsNm() { + return ifEmpty(bsshSttsNm, () -> null); + } + + public T setbsshSttsNm(String bsshSttsNm) { + this.bsshSttsNm = bsshSttsNm; + return self(); + } + + public String getprmisnNo() { + return ifEmpty(prmisnNo, () -> null); + } + + public T setprmisnNo(String prmisnNo) { + this.prmisnNo = prmisnNo; + return self(); + } +} diff --git a/src/main/java/cokr/xit/adds/nims/dao/BsshMapper.java b/src/main/java/cokr/xit/adds/nims/dao/BsshMapper.java new file mode 100644 index 0000000..c1a2296 --- /dev/null +++ b/src/main/java/cokr/xit/adds/nims/dao/BsshMapper.java @@ -0,0 +1,30 @@ +package cokr.xit.adds.nims.dao; + +import java.util.List; + +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +import cokr.xit.adds.nims.BsshQuery; +import cokr.xit.foundation.component.AbstractMapper; +import cokr.xit.foundation.data.DataObject; + +/** 전자우편 안내문 정보 DAO + * + *

상세 설명: + * + *

+ * ============ 변경 이력 ============
+ * 2023-12-04	JoJH 최초 작성
+ * ================================
+ * 
+ */ +@Mapper("bsshMapper") +public interface BsshMapper extends AbstractMapper { + + /**지정한 조건에 따라 전자우편 안내문 목록을 조회하여 반환한다.
+ * @param req 전자우편 안내문 조회 조건 + * @return 전자우편 안내문 목록 + */ + List selectBsshList(BsshQuery req); + +} diff --git a/src/main/java/cokr/xit/adds/nims/service/BsshService.java b/src/main/java/cokr/xit/adds/nims/service/BsshService.java new file mode 100644 index 0000000..42b489f --- /dev/null +++ b/src/main/java/cokr/xit/adds/nims/service/BsshService.java @@ -0,0 +1,19 @@ +package cokr.xit.adds.nims.service; + +import java.util.List; + +import cokr.xit.adds.nims.BsshQuery; +import cokr.xit.foundation.data.DataObject; + +public interface BsshService { + + /** 단속자료 목록을 조회한다. + * @param query 단속자료 목록 조회 조건 + *
  • pageNum: 페이지 번호
  • + *
  • fetchSize: 페이지 목록 건수
  • + *
+ * @return 단속자료 목록 + */ + List getbsshList(BsshQuery query); + +} diff --git a/src/main/java/cokr/xit/adds/nims/service/bean/BsshtServiceBean.java b/src/main/java/cokr/xit/adds/nims/service/bean/BsshtServiceBean.java new file mode 100644 index 0000000..353070e --- /dev/null +++ b/src/main/java/cokr/xit/adds/nims/service/bean/BsshtServiceBean.java @@ -0,0 +1,145 @@ +package cokr.xit.adds.nims.service.bean; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.URL; +import java.nio.charset.Charset; + +import javax.annotation.Resource; +import javax.net.ssl.HttpsURLConnection; + +import org.springframework.stereotype.Service; +import com.fasterxml.jackson.databind.ObjectMapper; + +import cokr.xit.adds.nims.BsshQuery; +import cokr.xit.adds.nims.dao.BsshMapper; +import cokr.xit.adds.nims.service.BsshService; +import cokr.xit.foundation.component.AbstractServiceBean; +import cokr.xit.foundation.data.DataObject; + +@Service("bsshService") +public class BsshtServiceBean extends AbstractServiceBean implements BsshService { + + /** 전자우편 안내문 정보 DAO */ + @Resource(name = "bsshMapper") + private BsshMapper bsshMapper; + + @Override + public List getbsshList(BsshQuery query){ + + ObjectMapper mapper = new ObjectMapper(); + String sUrl = "http://localhost:9076/api/biz/nims/v1/getNimsBsshInfoSt"; + String sJsonData = ""; + String rtnMsg = ""; // 처리 결과 메시지 + + // Json 파라미터 설정 + sJsonData = "{ " + + " \"k\":" + "\"" + "\"" + + ", \"fg\":" + "\"1\"" + + ", \"pg\":" + "\"1\"" + + ", \"bi\":\"\"" + + ", \"hp\":\"\"" + + ", \"bn\":" + query.getSchBsshNm() + "\"" + + ", \"bc\":" + query.getSchBsshCd() + "\"" + + ", \"ymd\":\"\"" + + ", \"fg2\":\"\"1\"" + + ", \"dbSkipYn\":\"\"N\"" + + ", \"userId\":\"suji\"" + + " }"; + + rtnMsg = callHttpsJson(sUrl, "POST", sJsonData); + + return bsshMapper.selectBsshList(query); + } + + + /**지정한 조건에 따라 과태료 대장 등록 자료 일괄 조회 목록을 조회하여 반환한다. + * @param req 과태료 대장 등록 자료 일괄 조회 조회 조건 + * @return 과태료 대장 등록 자료 일괄 조회 목록 + */ + public String callHttpsJson(String sUrl, String sMethod, String sJsonData) { + // + String returnMsg = ""; + // + HttpsURLConnection httpsConn = null; + + try { + // HTTPS 통신을 위한 URL 생성 + URL url = new URL(sUrl); + + // HttpsURLConnection 객체 생성 + httpsConn = (HttpsURLConnection) url.openConnection(); + + // Content-Type + httpsConn.setRequestProperty("Content-Type", "application/json"); + // Method Setting(GET/POST) + httpsConn.setRequestMethod(sMethod); // GET, POST, DELETE + // Connection Timeout setting + httpsConn.setConnectTimeout(10000); // 컨텍션타임아웃 10초 + // Read Timeout Setting + httpsConn.setReadTimeout(10000); // 컨텐츠조회 타임아웃 10초 + + if (sMethod.equals("POST")) { + // Input setting + httpsConn.setDoInput(true); + // Output setting + httpsConn.setDoOutput(true); // 항상 갱신된내용을 가져옴 + + // POST방식으로 송신할 json 데이터 전송 + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(httpsConn.getOutputStream())); + bw.write(sJsonData); + bw.flush(); + bw.close(); + } else { + // Input setting + httpsConn.setDoInput(false); + // Output setting + httpsConn.setDoOutput(false); + } + + // HTTP 응답 코드 수신, 서버에서 보낸 응답 데이터 수신 받기 + int responseCode = httpsConn.getResponseCode(); + + Charset charset = Charset.forName("UTF-8"); + String inputLine; + StringBuffer response = new StringBuffer(); + + if (responseCode == 200) { + BufferedReader in = new BufferedReader(new InputStreamReader(httpsConn.getInputStream(), charset)); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } else { + BufferedReader in = new BufferedReader(new InputStreamReader(httpsConn.getErrorStream(), charset)); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } + + returnMsg = response.toString(); + } catch (IOException e) { + returnMsg = "IOException :" + e; + } catch (Exception e) { + returnMsg = "Exception :" + e; + } finally { + if (httpsConn != null) { + httpsConn.disconnect(); + } + } + + return returnMsg; + } +}