From 6f8e3a7aec7d1fe389bfc62eca7a1f7823431fe0 Mon Sep 17 00:00:00 2001 From: jhseo Date: Wed, 10 Jan 2024 11:22:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=9C=EC=84=A4=20=EC=98=A4=EB=9D=BC?= =?UTF-8?q?=ED=81=B4=20DB=20=EB=A7=88=EC=8A=A4=ED=84=B0=20=EB=94=94?= =?UTF-8?q?=ED=85=8C=EC=9D=BC=20=ED=85=8C=EC=9D=B4=EB=B8=94=20Merge=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/biz/sisul/mapper/IBizSisulMapper.java | 2 + .../spring/config/SpringDocsApiConfig.java | 10 ++ .../mapper/IOtherMapper.java} | 14 +-- .../{biz => }/other/model/ElecnoticeDTO.java | 2 +- .../kr/xit/other/service/IOtherService.java | 23 ++++ .../kr/xit/other/service/OtherService.java | 61 ++++++++++ .../kr/xit/other/web/OtherController.java | 40 +++++++ .../mapper/biz/ens-sisul-mysql-mapper.xml | 27 +++++ .../mapper/other/other-oracle-mapper.xml | 112 ++++++++++++++++-- 9 files changed, 272 insertions(+), 19 deletions(-) rename mens-api/src/main/java/kr/xit/{biz/other/mapper/IBizOtherMapper.java => other/mapper/IOtherMapper.java} (61%) rename mens-api/src/main/java/kr/xit/{biz => }/other/model/ElecnoticeDTO.java (98%) create mode 100644 mens-api/src/main/java/kr/xit/other/service/IOtherService.java create mode 100644 mens-api/src/main/java/kr/xit/other/service/OtherService.java create mode 100644 mens-api/src/main/java/kr/xit/other/web/OtherController.java diff --git a/mens-api/src/main/java/kr/xit/biz/sisul/mapper/IBizSisulMapper.java b/mens-api/src/main/java/kr/xit/biz/sisul/mapper/IBizSisulMapper.java index 78b2fd0..bb6c0c8 100644 --- a/mens-api/src/main/java/kr/xit/biz/sisul/mapper/IBizSisulMapper.java +++ b/mens-api/src/main/java/kr/xit/biz/sisul/mapper/IBizSisulMapper.java @@ -8,6 +8,7 @@ import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulRequest; import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResDtlData; import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResMstData; +import kr.xit.other.model.ElecnoticeDTO.Elecnoticedtl; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; /** @@ -35,4 +36,5 @@ public interface IBizSisulMapper { Optional selectSndngResultMaster(final RsltSisulRequest dto); List selectSndngResultDetails(final RsltSisulRequest dto); + List selectOhterResult(); } diff --git a/mens-api/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java b/mens-api/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java index cf626b5..55af2b5 100644 --- a/mens-api/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java +++ b/mens-api/src/main/java/kr/xit/core/spring/config/SpringDocsApiConfig.java @@ -54,4 +54,14 @@ public class SpringDocsApiConfig { ) .build(); } + + @Bean + public GroupedOpenApi otherDoc() { + return GroupedOpenApi.builder() + .group("9. 외부DB 연계 API") + .pathsToMatch( + "/api/other/**" + ) + .build(); + } } diff --git a/mens-api/src/main/java/kr/xit/biz/other/mapper/IBizOtherMapper.java b/mens-api/src/main/java/kr/xit/other/mapper/IOtherMapper.java similarity index 61% rename from mens-api/src/main/java/kr/xit/biz/other/mapper/IBizOtherMapper.java rename to mens-api/src/main/java/kr/xit/other/mapper/IOtherMapper.java index 8db1111..399700f 100644 --- a/mens-api/src/main/java/kr/xit/biz/other/mapper/IBizOtherMapper.java +++ b/mens-api/src/main/java/kr/xit/other/mapper/IOtherMapper.java @@ -1,16 +1,14 @@ -package kr.xit.biz.other.mapper; +package kr.xit.other.mapper; -import kr.xit.biz.other.model.ElecnoticeDTO; +import kr.xit.other.model.ElecnoticeDTO.Elecnoticedtl; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; -import java.util.List; - /** *
  * description : 전자고지 파일 외부연계 mapper
  *
  * packageName : kr.xit.biz.other.mapper
- * fileName    : IBizOtherMapper
+ * fileName    : IOtherMapper
  * author      : seojh
  * date        : 2024-01-03
  * ======================================================================
@@ -21,7 +19,9 @@ import java.util.List;
  * 
*/ @Mapper -public interface IBizOtherMapper { +public interface IOtherMapper { - List selectElecnoticemst(); + Elecnoticedtl selectElecnotice(final Elecnoticedtl dto); + int saveElecnoticemst(final Elecnoticedtl dto); + int saveElecnoticedtl(final Elecnoticedtl dto); } diff --git a/mens-api/src/main/java/kr/xit/biz/other/model/ElecnoticeDTO.java b/mens-api/src/main/java/kr/xit/other/model/ElecnoticeDTO.java similarity index 98% rename from mens-api/src/main/java/kr/xit/biz/other/model/ElecnoticeDTO.java rename to mens-api/src/main/java/kr/xit/other/model/ElecnoticeDTO.java index 2632d0b..232f369 100644 --- a/mens-api/src/main/java/kr/xit/biz/other/model/ElecnoticeDTO.java +++ b/mens-api/src/main/java/kr/xit/other/model/ElecnoticeDTO.java @@ -1,4 +1,4 @@ -package kr.xit.biz.other.model; +package kr.xit.other.model; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/mens-api/src/main/java/kr/xit/other/service/IOtherService.java b/mens-api/src/main/java/kr/xit/other/service/IOtherService.java new file mode 100644 index 0000000..3a66da3 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/other/service/IOtherService.java @@ -0,0 +1,23 @@ +package kr.xit.other.service; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.other.service
+ * fileName    : IOtherService
+ * author      : seojh
+ * date        : 2024-01-04
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-01-04    seojh       최초 생성
+ *
+ * 
+ */ +public interface IOtherService { + //-------------------------------------------------------------------------------- + // merge save oracle + //-------------------------------------------------------------------------------- + String mergeData(); +} diff --git a/mens-api/src/main/java/kr/xit/other/service/OtherService.java b/mens-api/src/main/java/kr/xit/other/service/OtherService.java new file mode 100644 index 0000000..0154c3c --- /dev/null +++ b/mens-api/src/main/java/kr/xit/other/service/OtherService.java @@ -0,0 +1,61 @@ +package kr.xit.other.service; + +import kr.xit.biz.sisul.mapper.IBizSisulMapper; +import kr.xit.core.service.AbstractService; +import kr.xit.core.spring.annotation.TraceLogging; +import kr.xit.core.support.utils.Checks; +import kr.xit.other.mapper.IOtherMapper; +import kr.xit.other.model.ElecnoticeDTO.Elecnoticedtl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.other.service
+ * fileName    : OtherService
+ * author      : seojh
+ * date        : 2024-01-04
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-01-04    seojh       최초 생성
+ *
+ * 
+ */ +@Slf4j +@RequiredArgsConstructor +@Service +public class OtherService extends AbstractService implements IOtherService { + + private final IOtherMapper mapper; + private final IBizSisulMapper mapper2; + + /** + * + * @return String + */ + @Override + public String mergeData(){ + List ohterResult = mapper2.selectOhterResult(); + + for(Elecnoticedtl dto: ohterResult){ + Elecnoticedtl elecnoticedtl = mapper.selectElecnotice(dto); + + if(elecnoticedtl == null + || (elecnoticedtl != null && !Checks.checkVal(dto.getSndngprocesssttus(),"").equals(Checks.checkVal(elecnoticedtl.getSndngprocesssttus(),""))) + ){ + mapper.saveElecnoticemst(dto); + mapper.saveElecnoticedtl(dto); + } else if (!Checks.checkVal(dto.getResultcode(),""). equals(Checks.checkVal(elecnoticedtl.getResultcode(),""))) { + mapper.saveElecnoticedtl(dto); + } + } + + return "test"; + } +} diff --git a/mens-api/src/main/java/kr/xit/other/web/OtherController.java b/mens-api/src/main/java/kr/xit/other/web/OtherController.java new file mode 100644 index 0000000..5d9e281 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/other/web/OtherController.java @@ -0,0 +1,40 @@ +package kr.xit.other.web; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import kr.xit.core.model.ApiResponseDTO; +import kr.xit.core.model.IApiResponse; +import kr.xit.other.service.IOtherService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.other.web
+ * fileName    : OtherController
+ * author      : jhseo
+ * date        : 2024-01-09
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-01-09    jhseo       최초 생성
+ *
+ * 
+ */ +@Tag(name = "OtherController", description = "외부 Oracle 연계 API") +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/other/v1") +public class OtherController { + private final IOtherService service; + + @Operation(summary = "외부 Oracle 연계 요청", description = "외부 Oracle 연계 요청") + @PostMapping(value = "/merge", produces = MediaType.APPLICATION_JSON_VALUE) + public IApiResponse merge() { + String msg = service.mergeData(); + return ApiResponseDTO.success(msg); + } +} diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-sisul-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-sisul-mysql-mapper.xml index 3ec0cfc..7e82053 100644 --- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-sisul-mysql-mapper.xml +++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-sisul-mysql-mapper.xml @@ -156,4 +156,31 @@ + + diff --git a/mens-api/src/main/resources/egovframework/mapper/other/other-oracle-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/other/other-oracle-mapper.xml index e5c7ad5..b12e1f2 100644 --- a/mens-api/src/main/resources/egovframework/mapper/other/other-oracle-mapper.xml +++ b/mens-api/src/main/resources/egovframework/mapper/other/other-oracle-mapper.xml @@ -1,18 +1,108 @@ - + - + /** other-oracle-mapper|selectElecnoticemst-전자고지 파일 외부연계 마스터 조회|jhseo */ + SELECT a.unitysndngmastrid + , a.sndngco + , a.sndngprocesssttus + , a.insuser + , a.insdate + , a.upduser + , a.upddate + , b.unitysndngmastrid + , b.unitysndngdetailid + , b.sndngdt + , b.tmplatid + , b.gojidepth + , b.taxnum1 + , b.taxnum2 + , b.taxnum3 + , b.taxnum4 + , b.worker + , b.serialno + , b.recvdt + , b.readdt + , b.resultcode + FROM elecnoticemst a + LEFT OUTER JOIN elecnoticedtl b ON (a.unitysndngmastrid = b.unitysndngmastrid) + WHERE 1=1 + AND a.unitysndngmastrid = #{unitysndngmastrid} + AND b.unitysndngdetailid = #{unitysndngdetailid} + + /** other-oracle-mapper|saveElecnoticemst-전자고지 파일 외부연계 마스터 Merge|jhseo */ + MERGE + INTO elecnoticemst a + USING dual + ON (a.unitysndngmastrid = #{unitysndngmastrid}) + WHEN MATCHED THEN + UPDATE + SET a.sndngprocesssttus = #{sndngprocesssttus} + , a.upduser = #{upduser} + , a.upddate = sysdate + WHERE a.sndngprocesssttus != #{sndngprocesssttus} + WHEN NOT MATCHED THEN + INSERT (a.unitysndngmastrid + , a.sndngco + , a.sndngprocesssttus + , a.insuser + , a.insdate + ) + VALUES (#{unitysndngmastrid} + , #{sndngco} + , #{sndngprocesssttus} + , #{insuser} + , sysdate + ) + + + + + /** other-oracle-mapper|saveElecnoticedtl-전자고지 파일 외부연계 상세 Merge|jhseo */ + MERGE + INTO elecnoticedtl b + USING dual + ON (b.unitysndngmastrid = #{unitysndngmastrid} AND b.unitysndngdetailid = #{unitysndngdetailid}) + WHEN MATCHED THEN + UPDATE + SET b.readdt = #{readdt} + , b.resultcode = #{resultcode} + WHERE b.resultcode != #{resultcode} + WHEN NOT MATCHED THEN + INSERT (b.unitysndngmastrid + , b.unitysndngdetailid + , b.sndngdt + , b.tmplatid + , b.gojidepth + , b.taxnum1 + , b.taxnum2 + , b.taxnum3 + , b.taxnum4 + , b.worker + , b.serialno + , b.recvdt + , b.readdt + , b.resultcode + ) + VALUES (#{unitysndngmastrid} + , #{unitysndngdetailid} + , #{sndngdt} + , #{tmplatid} + , #{gojidepth} + , #{taxnum1} + , #{taxnum2} + , #{taxnum3} + , #{taxnum4} + , #{worker} + , #{serialno} + , #{recvdt} + , #{readdt} + , #{resultcode} + ) + +