동적 검색 관련 유틸리티 추가

main
이범준 1 year ago
parent 278af34db7
commit 115b5daf01

@ -16,6 +16,9 @@ public class CrdnQuery extends QueryRequest {
private static final long serialVersionUID = 1L;
private String mainOption;
private String subOption;
private String grid;
private String thisDay;
private String currentUserId;
@ -43,6 +46,24 @@ public class CrdnQuery extends QueryRequest {
private String crdnInptSeCd;
private String cvlcptPrcsCd;
public String getMainOption() {
return ifEmpty(mainOption, () -> null);
}
public <T extends CrdnQuery> T setMainOption(String mainOption) {
this.mainOption = mainOption;
return self();
}
public String getSubOption() {
return ifEmpty(subOption, () -> null);
}
public <T extends CrdnQuery> T setSubOption(String subOption) {
this.subOption = subOption;
return self();
}
public String getGrid() {
return ifEmpty(grid, () -> null);
}

@ -172,41 +172,26 @@ SELECT C.CRDN_ID <!-- 단속 ID -->
AND C.CRDN_STTS_CD = '01'
<if test="by != null and by != '' and term != null">
<choose>
<when test="by == 'crdnRegSeCd'">
AND FN_GET_CODE_NM('FIM026', C.CRDN_REG_SE_CD) LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'cvlcptAplcntNm'">
AND CC.CVLCPT_APLCNT_NM LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'cvlcptPrcsPicNm'">
AND CC.CVLCPT_PRCS_PIC_NM LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'cvlcptPrcsPicTelno'">
AND CC.CVLCPT_PRCS_PIC_TELNO LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'cvlcptRcptYmd'">
AND CC.CVLCPT_RCPT_YMD = REPLACE(#{term},'-','')
</when>
<when test="by == 'cvlcptPrcsPrnmntDt'">
AND SUBSTR(CC.CVLCPT_PRCS_PRNMNT_DT,1,8) = REPLACE(#{term},'-','')
</when>
<when test="by == 'crdnYmd'">
AND C.CRDN_YMD = REPLACE(#{term},'-','')
</when>
<when test="by == 'atchFileCnt'">
AND C.ATCH_FILE_CNT = #{term}
</when>
<when test="by == 'vltnArtcl'">
AND (SELECT VLTN_ARTCL FROM TB_VLTN_INFO WHERE VLTN_ID = C.VLTN_ID) LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'cvlcptRcptNo'">
AND CC.CVLCPT_RCPT_NO LIKE CONCAT('%', #{term}, '%')
</when>
<when test="by == 'vhrno'">
AND C.VHRNO LIKE CONCAT('%', #{term}, '%')
<when test="mainOption == 'codeValue' or mainOption == 'match' or mainOption == 'ymd'">
<include refid="dynamicSearch.start" />
<choose>
<when test="by == 'crdnRegSeCd'">C.CRDN_REG_SE_CD</when>
<when test="by == 'cvlcptAplcntNm'">CC.CVLCPT_APLCNT_NM</when>
<when test="by == 'cvlcptPrcsPicNm'">CC.CVLCPT_PRCS_PIC_NM</when>
<when test="by == 'cvlcptPrcsPicTelno'">CC.CVLCPT_PRCS_PIC_TELNO</when>
<when test="by == 'cvlcptRcptYmd'">CC.CVLCPT_RCPT_YMD</when>
<when test="by == 'cvlcptPrcsPrnmntDt'">CC.CVLCPT_PRCS_PRNMNT_DT</when>
<when test="by == 'crdnYmd'">C.CRDN_YMD</when>
<when test="by == 'atchFileCnt'">C.ATCH_FILE_CNT</when>
<when test="by == 'cvlcptRcptNo'">CC.CVLCPT_RCPT_NO</when>
<when test="by == 'vhrno'">C.VHRNO</when>
</choose>
<include refid="dynamicSearch.center" />#{term}<include refid="dynamicSearch.end" />
</when>
<otherwise>
<if test="by == 'vltnArtcl'">
AND (SELECT VLTN_ARTCL FROM TB_VLTN_INFO WHERE VLTN_ID = C.VLTN_ID) LIKE CONCAT('%', #{term}, '%')
</if>
</otherwise>
</choose>
</if>

@ -0,0 +1,29 @@
<?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="dynamicSearch">
<sql id="start">
<if test="mainOption == 'codeValue'"> AND FN_GET_CODE_NM(#{subOption},</if>
<if test="mainOption == 'match'"> AND </if>
<if test="mainOption == 'ymd'"> AND SUBSTR(</if>
</sql>
<sql id="center">
<if test="mainOption == 'codeValue'">) LIKE CONCAT('%',</if>
<if test="mainOption == 'match'">
<if test="subOption == 'perfect'"> = </if>
<if test="subOption == 'part'"> LIKE CONCAT('%',</if>
</if>
<if test="mainOption == 'ymd'">,1,8) = REPLACE(</if>
</sql>
<sql id="end">
<if test="mainOption == 'codeValue'">, '%')</if>
<if test="mainOption == 'match'">
<if test="subOption == 'perfect'"></if>
<if test="subOption == 'part'">, '%')</if>
</if>
<if test="mainOption == 'ymd'">,'-','')</if>
</sql>
</mapper>

@ -49,6 +49,8 @@
<div class="col-6">
<input type="hidden" id="by--${pageName}" name="by" />
<input type="text" id="byOutput--${pageName}" class="form-control" readonly value="동적 검색" />
<input type="hidden" id="mainOption--${pageName}" name="mainOption" />
<input type="hidden" id="subOption--${pageName}" name="subOption" />
<input type="text" id="term--${pageName}" name="term" class="form-control" />
</div>
</div>
@ -77,19 +79,20 @@
<table id="DataTables_Table_0--${pageName}"
class="datatables-ajax table table-bordered dataTable no-footer">
<thead id="crdnThead--${pageName}">
<tr data-by="by--${pageName}" data-by-output="byOutput--${pageName}">
<tr data-by="by--${pageName}" data-by-output="byOutput--${pageName}"
data-main-option="mainOption--${pageName}" data-sub-option="subOption--${pageName}">
<th width="80">No.</th>
<th width="80" onclick="searchFromGridTitle('CRDN_REG_SE_CD',this.innerText);">등록구분</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_APLCNT_NM',this.innerText);">신고자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PIC_NM',this.innerText);">담당자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PIC_TELNO',this.innerText);">담당자전화번호</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_RCPT_YMD',this.innerText);">접수일자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PRNMNT_DT',this.innerText);">처리기한</th>
<th width="80" onclick="searchFromGridTitle('CRDN_YMD','위반일자');">위반일시</th>
<th width="80" onclick="searchFromGridTitle('ATCH_FILE_CNT',this.innerText);">사진건수</th>
<th width="80" onclick="searchFromGridTitle('CRDN_REG_SE_CD',this.innerText,'codeValue','FIM026');">등록구분</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_APLCNT_NM',this.innerText,'match','part');">신고자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PIC_NM',this.innerText,'match','part');">담당자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PIC_TELNO',this.innerText,'match','part');">담당자전화번호</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_RCPT_YMD',this.innerText,'ymd');">접수일자</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_PRCS_PRNMNT_DT',this.innerText,'ymd');">처리기한</th>
<th width="80" onclick="searchFromGridTitle('CRDN_YMD','위반일자','ymd');">위반일시</th>
<th width="80" onclick="searchFromGridTitle('ATCH_FILE_CNT',this.innerText,'match','perfect');">사진건수</th>
<th width="80" onclick="searchFromGridTitle('VLTN_ARTCL',this.innerText);">위반내용</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_RCPT_NO',this.innerText);">접수번호</th>
<th width="80" onclick="searchFromGridTitle('VHRNO',this.innerText);">차량번호</th>
<th width="80" onclick="searchFromGridTitle('CVLCPT_RCPT_NO',this.innerText,'match','part');">접수번호</th>
<th width="80" onclick="searchFromGridTitle('VHRNO',this.innerText,'match','part');">차량번호</th>
</tr>
</thead>
<tbody id="crdnTbody--${pageName}"></tbody>

@ -32,6 +32,8 @@
<div class="col-6">
<input type="hidden" id="by--${pageName}" name="by" />
<input type="text" id="byOutput--${pageName}" class="form-control" readonly value="동적 검색" />
<input type="hidden" id="mainOption--${pageName}" name="mainOption" />
<input type="hidden" id="subOption--${pageName}" name="subOption" />
<input type="text" id="term--${pageName}" name="term" class="form-control" />
</div>
</div>
@ -57,7 +59,9 @@
<table id="DataTables_Table_0--${pageName}"
class="datatables-ajax table table-bordered dataTable no-footer" >
<thead>
<tr id="crdnTheadTr--${pageName}" data-by="by--${pageName}" data-by-output="byOutput--${pageName}">
<tr id="crdnTheadTr--${pageName}"
data-by="by--${pageName}" data-by-output="byOutput--${pageName}"
data-main-option="mainOption--${pageName}" data-sub-option="subOption--${pageName}">
<th width="80">No.</th>
<th width="80" onclick="searchFromGridTitle('CRDN_INPT_SE_CD',this.innerText);">자료출처</th>
<th width="80" onclick="searchFromGridTitle('CRDN_YMD','위반일자');">위반일시</th>

@ -46,6 +46,8 @@
<div class="col-12">
<input type="hidden" id="by--${pageName}" name="by" />
<input type="text" id="byOutput--${pageName}" class="form-control" readonly value="동적 검색" />
<input type="hidden" id="mainOption--${pageName}" name="mainOption" />
<input type="hidden" id="subOption--${pageName}" name="subOption" />
<input type="text" id="term--${pageName}" name="term" class="form-control" />
</div>
</div>
@ -70,7 +72,9 @@
<table id="DataTables_Table_0--${pageName}"
class="datatables-ajax table table-bordered dataTable no-footer">
<thead>
<tr id="crdnTheadTr--${pageName}" data-by="by--${pageName}" data-by-output="byOutput--${pageName}">
<tr id="crdnTheadTr--${pageName}"
data-by="by--${pageName}" data-by-output="byOutput--${pageName}"
data-main-option="mainOption--${pageName}" data-sub-option="subOption--${pageName}">
<th width="80">No.</th>
<th width="80" onclick="searchFromGridTitle('RDUCT_YMD',this.innerText);">감액일자</th>
<th width="80" onclick="searchFromGridTitle('RDUCT_RSN_CD',this.innerText);">감액사유</th>

@ -1,12 +1,17 @@
function searchFromGridTitle(byValue, byOutputValue){
function searchFromGridTitle(byValue, byOutputValue, mainOption, subOption){
var trDataset = event.target.parentElement.dataset;
var byElementId = trDataset.by;
var byOutputElementId = trDataset.byOutput;
var mainOptionElementId = trDataset.mainOption;
var subOptionElementId = trDataset.subOption;
document.getElementById(byElementId).value = snakeToCamel(byValue);
document.getElementById(byOutputElementId).value = byOutputValue + " 검색";
document.getElementById(mainOptionElementId).value = mainOption;
document.getElementById(subOptionElementId).value = subOption;
}

Loading…
Cancel
Save