feat: 시설 오라클 DB 마스터 디테일 테이블 Merge 기능 추가

main
jhseo 10 months ago
parent d1c51adbe8
commit 6f8e3a7aec

@ -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.RsltSisulRequest;
import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResDtlData; import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResDtlData;
import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResMstData; import kr.xit.biz.sisul.model.SisulSndngResultDTO.RsltSisulResMstData;
import kr.xit.other.model.ElecnoticeDTO.Elecnoticedtl;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
/** /**
@ -35,4 +36,5 @@ public interface IBizSisulMapper {
Optional<RsltSisulResMstData> selectSndngResultMaster(final RsltSisulRequest dto); Optional<RsltSisulResMstData> selectSndngResultMaster(final RsltSisulRequest dto);
List<RsltSisulResDtlData> selectSndngResultDetails(final RsltSisulRequest dto); List<RsltSisulResDtlData> selectSndngResultDetails(final RsltSisulRequest dto);
List<Elecnoticedtl> selectOhterResult();
} }

@ -54,4 +54,14 @@ public class SpringDocsApiConfig {
) )
.build(); .build();
} }
@Bean
public GroupedOpenApi otherDoc() {
return GroupedOpenApi.builder()
.group("9. 외부DB 연계 API")
.pathsToMatch(
"/api/other/**"
)
.build();
}
} }

@ -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 org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import java.util.List;
/** /**
* <pre> * <pre>
* description : mapper * description : mapper
* *
* packageName : kr.xit.biz.other.mapper * packageName : kr.xit.biz.other.mapper
* fileName : IBizOtherMapper * fileName : IOtherMapper
* author : seojh * author : seojh
* date : 2024-01-03 * date : 2024-01-03
* ====================================================================== * ======================================================================
@ -21,7 +19,9 @@ import java.util.List;
* </pre> * </pre>
*/ */
@Mapper @Mapper
public interface IBizOtherMapper { public interface IOtherMapper {
List<ElecnoticeDTO.Elecnoticemst> selectElecnoticemst(); Elecnoticedtl selectElecnotice(final Elecnoticedtl dto);
int saveElecnoticemst(final Elecnoticedtl dto);
int saveElecnoticedtl(final Elecnoticedtl dto);
} }

@ -1,4 +1,4 @@
package kr.xit.biz.other.model; package kr.xit.other.model;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; 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);
}
}

@ -156,4 +156,31 @@
</if> </if>
</select> </select>
<select id="selectOhterResult" resultType="kr.xit.other.model.ElecnoticeDTO$Elecnoticedtl">
SELECT tcsm.unity_sndng_mastr_id as unitysndngmastrid
, tcsm.sndng_co as sndngco
, fn_get_code_nm('ETI007', tcsm.sndng_process_sttus) as sndngprocesssttus
, 'ens' as insuser
, date_format(tcsm.regist_dt, '%Y%m%d%H%i%S') as insdate
, 'ens' as upduser
, date_format(tcsm.updt_dt, '%Y%m%d%H%i%S') as upddate
, tcsd.unity_sndng_detail_id as unitysndngdetailid
, tcsm.sndng_dt as sndngdt
, tcsm.tmplat_id as tmplatid
, '' as gojidepth
, SUBSTRING(tcsd.main_code, 1, 7) AS taxnum1
, SUBSTRING(tcsd.main_code, 8, 8) AS taxnum2
, SUBSTRING(tcsd.main_code, 16, 7) AS taxnum3
, SUBSTRING(tcsd.main_code, 23, 7) AS taxnum4
, '' as worker
, '' as serialno
, tcsr.requst_dt as recvdt
, tcsr.readng_dt as readdt
, fn_get_code_nm('ETI008', tcsr.sndng_result_sttus) as resultcode
FROM tb_cntc_sndng_mastr tcsm
INNER JOIN tb_cntc_sndng_detail tcsd ON (tcsm.unity_sndng_mastr_id = tcsd.unity_sndng_mastr_id)
LEFT OUTER JOIN tb_cntc_sndng_result tcsr ON (tcsd.unity_sndng_detail_id = tcsr.unity_sndng_detail_id)
WHERE (tcsm.sndng_process_sttus != 'close' OR (tcsm.sndng_process_sttus = 'close' AND tcsm.updt_dt > date_add(now(), interval -7 day)))
</select>
</mapper> </mapper>

@ -1,18 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "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"> <select id="selectElecnotice" resultType="kr.xit.other.model.ElecnoticeDTO$Elecnoticedtl">
/** ens-other-oracle-mapper|selectElecnoticemst-전자고지 파일 외부연계 마스터 조회|seojh */ /** other-oracle-mapper|selectElecnoticemst-전자고지 파일 외부연계 마스터 조회|jhseo */
SELECT UNITYSNDNGMASTRID SELECT a.unitysndngmastrid
, SNDNGCO , a.sndngco
, SNDNGPROCESSSTTUS , a.sndngprocesssttus
, INSUSER , a.insuser
, INSDATE , a.insdate
, UPDUSER , a.upduser
, UPDDATE , a.upddate
FROM ELECNOTICEMST , 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> </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> </mapper>

Loading…
Cancel
Save