feat: 시설 오라클 DB 마스터 디테일 테이블 Merge 기능 추가
parent
d1c51adbe8
commit
6f8e3a7aec
@ -1,4 +1,4 @@
|
||||
package kr.xit.biz.other.model;
|
||||
package kr.xit.other.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
@ -0,0 +1,23 @@
|
||||
package kr.xit.other.service;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.other.service
|
||||
* fileName : IOtherService
|
||||
* author : seojh
|
||||
* date : 2024-01-04
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2024-01-04 seojh 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
public interface IOtherService {
|
||||
//--------------------------------------------------------------------------------
|
||||
// merge save oracle
|
||||
//--------------------------------------------------------------------------------
|
||||
String mergeData();
|
||||
}
|
@ -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;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.other.service
|
||||
* fileName : OtherService
|
||||
* author : seojh
|
||||
* date : 2024-01-04
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2024-01-04 seojh 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@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<Elecnoticedtl> 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";
|
||||
}
|
||||
}
|
@ -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.*;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.other.web
|
||||
* fileName : OtherController
|
||||
* author : jhseo
|
||||
* date : 2024-01-09
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2024-01-09 jhseo 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
}
|
@ -1,18 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="kr.xit.biz.other.mapper.IBizOtherMapper">
|
||||
<mapper namespace="kr.xit.other.mapper.IOtherMapper">
|
||||
|
||||
<select id="selectElecnoticemst" resultType="kr.xit.biz.other.model.ElecnoticeDTO$Elecnoticemst">
|
||||
/** ens-other-oracle-mapper|selectElecnoticemst-전자고지 파일 외부연계 마스터 조회|seojh */
|
||||
SELECT UNITYSNDNGMASTRID
|
||||
, SNDNGCO
|
||||
, SNDNGPROCESSSTTUS
|
||||
, INSUSER
|
||||
, INSDATE
|
||||
, UPDUSER
|
||||
, UPDDATE
|
||||
FROM ELECNOTICEMST
|
||||
<select id="selectElecnotice" resultType="kr.xit.other.model.ElecnoticeDTO$Elecnoticedtl">
|
||||
/** 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}
|
||||
</select>
|
||||
|
||||
<insert id="saveElecnoticemst">
|
||||
/** 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
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
<insert id="saveElecnoticedtl">
|
||||
/** 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}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue