시군구 설정 정보 복사 기능 추가

main
이범준 7 months ago
parent 73d3bd7b5a
commit 11d7034baa

@ -13,21 +13,33 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.service.CodeQuery;
import cokr.xit.base.code.service.bean.CodeBean;
import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.base.service.bean.AdminBean;
import cokr.xit.fims.cmmn.DirectoryStructureToJson;
import cokr.xit.fims.cmmn.DirectoryStructureToJson.Node;
import cokr.xit.fims.crdn.service.ImportService;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.interfaces.smg.service.SmgService;
@Controller
@RequestMapping(name="최고관리자", value="/admin")
public class AdminController extends ApplicationController {
@Resource(name="adminBean")
private AdminBean adminBean;
@Resource(name="codeBean")
private CodeBean codeBean;
@Resource(name="smgService")
private SmgService smgService;
@ -187,4 +199,76 @@ public class AdminController extends ApplicationController {
mav.addObject("fileCn", fileCn);
return mav;
}
@GetMapping(name="시군구 추가/삭제 메인", value="/sggAddDelInfo.do")
public ModelAndView sggAddDelMain() {
ModelAndView mav = new ModelAndView();
mav.setViewName("fims/admin-sggAddDel-info");
mav.addObject("pageName","admin-sggAddDel");
return mav;
}
@GetMapping(name="백업 테이블 및 실사용 테이블 자료 조회", value="/sggBackup/list.do")
public ModelAndView getBackupList(String backupTable, String originalTable, String pkName) {
ModelAndView mav = new ModelAndView("jsonView");
List<DataObject> originalDataList = adminBean.getAllList(originalTable, pkName);
List<DataObject> backupDataList = adminBean.getAllList(backupTable, originalTable, pkName);
mav.addObject("originalDataList", originalDataList);
mav.addObject("backupDataList", backupDataList);
return mav;
}
@PostMapping(name="백업 테이블 자료를 사용 테이블로 복사", value="/sggBackup/activate.do")
public ModelAndView add(Backup backup) {
ModelAndView mav = new ModelAndView("jsonView");
boolean saved = adminBean.activate(backup);
mav.addObject("saved", saved);
return mav;
}
@PostMapping(name="사용 테이블 자료 삭제 및 백업", value="/sggBackup/deactivate.do")
public ModelAndView del(Backup backup) {
ModelAndView mav = new ModelAndView("jsonView");
boolean saved = adminBean.deactivate(backup);
mav.addObject("saved", saved);
return mav;
}
@GetMapping(name="시군구 설정 복사 메인", value="/copySggStngInfo.do")
public ModelAndView copySggStngMain() {
ModelAndView mav = new ModelAndView();
CodeQuery cq = new CodeQuery();
cq.setGroupIDs("FIM054");
List<DataObject> taskSeCdList = codeBean.getCodeList(cq);
mav.addObject("taskSeCdList", taskSeCdList);
List<DataObject> sggList = adminBean.getAllList("TB_SGG", "SGG_NM");
mav.addObject("sggList", sggList);
mav.setViewName("fims/admin-copySggStng-info");
mav.addObject("pageName","admin-copySggStng");
return mav;
}
@GetMapping(name="시군구 설정 복사", value="/copySggStng.do")
public ModelAndView copy(String taskSeCd, String srcSgg, String trgtSgg) {
ModelAndView mav = new ModelAndView("jsonView");
boolean saved = adminBean.copySggStng(taskSeCd, srcSgg, trgtSgg);
mav.addObject("saved", saved);
return mav;
}
}

@ -0,0 +1,13 @@
package cokr.xit.fims.base;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Backup {
String originalTable;
String backupTable;
String pkName;
String[] pks;
}

@ -0,0 +1,30 @@
package cokr.xit.fims.base.dao;
import java.util.List;
import java.util.Map;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.fims.base.Backup;
import cokr.xit.foundation.component.AbstractMapper;
import cokr.xit.foundation.data.DataObject;
@Mapper("adminMapper")
public interface AdminMapper extends AbstractMapper {
List<DataObject> selectAllList(Map<String, String> map);
int insertOriginalData(Backup backup);
int deleteOriginalData(Backup backup);
int insertBackupData(Backup backup);
int deleteBackupData(Backup backup);
int copyTask(Map<String, Object> param);
List<String> selectVltnList(Map<String, Object> param);
int copyVltn(Map<String, Object> param);
}

@ -0,0 +1,72 @@
package cokr.xit.fims.base.service.bean;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import cokr.xit.fims.base.Backup;
import cokr.xit.fims.base.dao.AdminMapper;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.DataObject;
@Component("adminBean")
public class AdminBean extends AbstractComponent {
@Resource(name = "adminMapper")
private AdminMapper adminMapper;
public List<DataObject> getAllList(String originalTable, String pkName) {
Map<String,String> map = new HashMap<String,String>();
map.put("originalTable", originalTable);
map.put("pkName", pkName);
return adminMapper.selectAllList(map);
}
public List<DataObject> getAllList(String backupTable, String originalTable, String pkName) {
Map<String,String> map = new HashMap<String,String>();
map.put("originalTable", originalTable);
map.put("backupTable", backupTable);
map.put("pkName", pkName);
return adminMapper.selectAllList(map);
}
public boolean activate(Backup backup) {
return adminMapper.insertOriginalData(backup) > 0;
}
public boolean deactivate(Backup backup) {
adminMapper.deleteBackupData(backup);
int result1 = adminMapper.insertBackupData(backup);
int result2 = adminMapper.deleteOriginalData(backup);
return ((result1 != 0) && (result1 == result2));
}
public boolean copySggStng(String taskSeCd, String srcSgg, String trgtSgg) {
Map<String, Object> param = new HashMap<>();
param.put("taskSeCd",taskSeCd);
param.put("srcSgg",srcSgg);
param.put("trgtSgg",trgtSgg);
adminMapper.copyTask(param);
List<String> vltnCds = adminMapper.selectVltnList(param);
if(vltnCds == null || vltnCds.isEmpty()) {
return true;
}
param.put("vltnCds", vltnCds);
int result2 = adminMapper.copyVltn(param);
if(result2 == vltnCds.size()) {
return true;
} else {
return false;
}
}
}

@ -0,0 +1,124 @@
<?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="cokr.xit.fims.base.dao.AdminMapper">
<select id="selectAllList" parameterType="map">
<choose>
<when test="backupTable != null">
SELECT *
FROM ${backupTable}
WHERE ${pkName} NOT IN (
SELECT ${pkName}
FROM ${originalTable}
)
</when>
<otherwise>
SELECT *
FROM ${originalTable}
</otherwise>
</choose>
ORDER BY ${pkName}
</select>
<insert id="insertOriginalData" parameterType="cokr.xit.fims.base.Backup">
INSERT
INTO ${originalTable}
SELECT *
FROM ${backupTable}
WHERE ${pkName} IN (<foreach collection="pks" item="pk" separator=",">#{pk}</foreach>)
</insert>
<delete id="deleteBackupData" parameterType="cokr.xit.fims.base.Backup">
DELETE
FROM ${backupTable}
WHERE ${pkName} IN (<foreach collection="pks" item="pk" separator=",">#{pk}</foreach>)
</delete>
<insert id="insertBackupData" parameterType="cokr.xit.fims.base.Backup">
INSERT
INTO ${backupTable}
SELECT *
FROM ${originalTable}
WHERE ${pkName} IN (<foreach collection="pks" item="pk" separator=",">#{pk}</foreach>)
</insert>
<delete id="deleteOriginalData" parameterType="cokr.xit.fims.base.Backup">
DELETE
FROM ${originalTable}
WHERE ${pkName} IN (<foreach collection="pks" item="pk" separator=",">#{pk}</foreach>)
</delete>
<insert id="copyTask" parameterType="map">
INSERT
INTO TB_TASK
SELECT #{trgtSgg} AS SGG_CD
, B.TASK_SE_CD
, B.TASK_SE_NM
, B.ADVNTCE_DAY_CNT
, B.ADVNTCE_RDUCT_RT
, B.WKSN_RDUCT_RT
, B.FFNLG_ADTN_YMD
, B.FFNLG_ADTN_RT
, B.FFNLG_INADTN_RT
, B.FFNLG_INADTN_MXMM_CNT
, B.NXRP_LINK_SE_CD
, B.NXRP_LINK_SE_DTL_SN
, B.USE_YN
, B.REG_DT
, B.RGTR
, B.MDFCN_DT
, B.MDFR
FROM TB_TASK B
WHERE B.SGG_CD = #{srcSgg}
AND B.TASK_SE_CD = #{taskSeCd}
</insert>
<select id="selectVltnList" parameterType="map" resultType="string">
SELECT A.VLTN_CD
FROM TB_VLTN A
WHERE A.SGG_CD = #{srcSgg}
AND A.TASK_SE_CD = #{taskSeCd}
</select>
<insert id="copyVltn" parameterType="map">
<selectKey resultType="string" keyProperty="vltnId" keyColumn="NEW_ID" order="BEFORE">
SELECT
LPAD(CAST(IFNULL(MAX(VLTN_ID) + 1, 1) AS INT), 10, '0')
AS NEW_ID
FROM TB_VLTN
</selectKey>
INSERT
INTO TB_VLTN
SELECT (CASE B.VLTN_CD
<foreach collection="vltnCds" item="vltnCd" index="index" separator=" ">
WHEN #{vltnCd} THEN LPAD(CAST(${vltnId}+${index} AS INT), 10, '0')
</foreach>
ELSE '' END) AS VLTN_ID
, #{trgtSgg} AS SGG_CD
, B.TASK_SE_CD
, B.VLTN_CD
, B.VLTN_ARTCL
, B.VLTN_LAW_NM
, B.VLTN_LAW1
, B.VLTN_LAW2
, B.VLTN_LAW_ETC
, B.ACNTG_SE_CD
, B.ACNTG_SE_NM
, B.TXITM_CD
, B.TXITM_NM
, B.OPER_ITEM_CD
, B.OPER_ITEM_NM
, B.SPCL_BIZ_CD
, B.SPCL_BIZ_NM
, B.USE_YN
, B.REG_DT
, B.RGTR
, B.MDFCN_DT
, B.MDFR
FROM TB_VLTN B
WHERE B.SGG_CD = #{srcSgg}
AND B.TASK_SE_CD = #{taskSeCd}
AND B.VLTN_CD IN (<foreach collection="vltnCds" item="vltnCd" separator=",">#{vltnCd}</foreach>)
</insert>
</mapper>

@ -0,0 +1,64 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<form id="frmEdit--${pageName}">
<div class="d-flex flex-row justify-content-evenly">
<div class="card" style="width:1000px;min-height:200px;">
<div class="row">
<div class="col-4">
<label class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">업무</label>
<select id="taskSeCd--${pageName}" name="taskSeCd" class="form-select">
<c:forEach items="${taskSeCdList}" var="item">
<option value="${item.CODE}">${item.CODE_VAL}</option>
</c:forEach>
</select>
</div>
<div class="col-4">
<label class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">소스 시군구</label>
<select id="srcSgg--${pageName}" name="srcSgg" class="form-select">
<c:forEach items="${sggList}" var="item">
<option value="${item.SGG_CD}">${item.SGG_NM}</option>
</c:forEach>
</select>
</div>
<div class="col-4">
<label class="w-px-130 bg-lighter pe-2 col-form-label text-sm-end">타겟 시군구</label>
<select id="trgtSgg--${pageName}" name="trgtSgg" class="form-select">
<c:forEach items="${sggList}" var="item">
<option value="${item.SGG_CD}">${item.SGG_NM}</option>
</c:forEach>
</select>
</div>
<div class="col-12">
<span class="float-end p-4">
<button type="button" id="btnCopyStng--${pageName}" class="btn btn-primary">업무,위반 설정 복사</button>
</span>
</div>
</div>
</div>
</div>
</form>
<script>
$("#btnCopyStng--${pageName}").on("click", function(){
if($("#srcSgg--${pageName}").val() == $("#trgtSgg--${pageName}").val()){
alert("동일한 시군구 선택 불가");
return;
}
ajax.get({
url : wctx.url("admin/copySggStng.do"),
data : {
taskSeCd : $("#taskSeCd--${pageName}").val(),
srcSgg : $("#srcSgg--${pageName}").val(),
trgtSgg : $("#trgtSgg--${pageName}").val()
},
success : (resp) => {
if(resp.saved){
alert('완료');
}
}
});
});
</script>

@ -51,7 +51,12 @@
</div>
</div>
<div class="fieldset-legend mt-4">
<div class="fieldset-legend-content fs-big" data-label="시군구 정보 백업 & 복제">
<button type="button" class="btn btn-primary" id="btnOpenSggAddDel">시군구 추가/삭제</button>
<button type="button" class="btn btn-primary" id="btnOpenCopySggStng">시군구 설정 복사</button>
</div>
</div>
</div>
</div>
@ -253,6 +258,40 @@ function fnImportFile(obj){
});
}
$("#btnOpenSggAddDel").on("click", function(){
ajax.get({
url : "/admin/sggAddDelInfo.do",
data: {},
success: (resp) => {
dialog.open({
id: "sggAddDelDialog",
title: "시군구 추가,삭제",
content: resp ,
size: "xxl",
init:() => {}
});
}
});
});
$("#btnOpenCopySggStng").on("click", function(){
ajax.get({
url : "/admin/copySggStngInfo.do",
data: {},
success: (resp) => {
dialog.open({
id: "copySggStngDialog",
title: "시군구 설정 복사",
content: resp ,
size: "xl",
init:() => {}
});
}
});
});
$(document).ready(function(){
getFileTree();
});

@ -0,0 +1,192 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
<form id="frmEdit--${pageName}">
<div class="d-flex flex-row justify-content-evenly">
<div class="card" style="width:500px;">
<h3>시군구 백업</h3>
<div class="card-datatable text-nowrap">
<div id="backupSgg-DataTables_Table_0_wrapper--${pageName}" class="dataTables_wrapper dt-bootstrap5 no-footer">
<div id="backupSgg-table-responsive--${pageName}" class="table-responsive"
style="overflow-x: scroll;height:500px;overflow-y: scroll;">
<table id="backupSgg-DataTables_Table_0--${pageName}"
class="table-layout-fixed datatables-ajax table table-bordered dataTable no-footer">
<thead class="sticky-thead">
<tr data-key="{SGG_CD}">
<th style="width: 50px;"></th>
<th style="width: 140px;" >시군구코드</th>
<th style="width: 300px;" >시군구명</th>
<th class="cmn dummy-th"></th>
</tr>
</thead>
<tbody id="backupSggTbody--${pageName}">
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="card" style="width:100px;">
<div style="display: flex;flex-direction: column;justify-content: space-evenly;height: 100%;">
<button type="button" id="btnAdd--${pageName}">추가 &gt;&gt;</button>
<button type="button" id="btnDel--${pageName}">&lt;&lt; 삭제</button>
</div>
</div>
<div class="card" style="width:500px;">
<h3>시군구</h3>
<div class="card-datatable text-nowrap">
<div id="originalSgg-DataTables_Table_0_wrapper--${pageName}" class="dataTables_wrapper dt-bootstrap5 no-footer">
<div id="originalSgg-table-responsive--${pageName}" class="table-responsive"
style="overflow-x: scroll;height:500px;overflow-y: scroll;">
<table id="originalSgg-DataTables_Table_0--${pageName}"
class="table-layout-fixed datatables-ajax table table-bordered dataTable no-footer">
<thead class="sticky-thead">
<tr data-key="{SGG_CD}">
<th style="width: 50px;"></th>
<th style="width: 140px;" >시군구코드</th>
<th style="width: 300px;" >시군구명</th>
<th class="cmn dummy-th"></th>
</tr>
</thead>
<tbody id="originalSggTbody--${pageName}">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</form>
<template id="sggRow--${pageName}">
<tr data-key="{SGG_CD}">
<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center cmn">
<input type="checkbox" value="{SGG_CD}" />
</td>
<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center cmn">{SGG_CD}</td>
<td onclick="{onclick}" ondblclick="{ondblclick}" class="text-center cmn">{SGG_NM}</td>
<td class="dummy-td cmn"></td>
</tr>
</template>
<template id="sggNotFound--${pageName}">
<tr>
<td valign="top" colspan="14" class="dataTables_empty text-center">
정보를 찾지 못했습니다.
</td>
</tr>
</template>
<script>
pageObject['${pageName}'] = {};
pageObject['${pageName}'].originalDataset = new Dataset({
keymapper : info => info ? info.SGG_CD : ""
});
pageObject['${pageName}'].backupDataset = new Dataset({
keymapper : info => info ? info.SGG_CD : ""
});
function fnRenderBackupAndOriginal(list,tbodyId,dataset){
$("#"+tbodyId).html("");
if(list != null && list.length > 0){
dataset.setData(list);
} else {
dataset.setData([]);
}
var empty = dataset.empty;
var notFound = [document.getElementById("sggNotFound--${pageName}").innerHTML];
var found = document.getElementById("sggRow--${pageName}").innerHTML;
var replacer = (str, dataItem) => str.replace(/{onclick}/gi, "");
var trs = empty ? notFound : dataset.inStrings(found, replacer);
$("#"+tbodyId).html(trs.join());
}
function getBackupAndOriginalDataList(){
ajax.get({
url : wctx.url("/admin/sggBackup/list.do"),
data : {
originalTable : "TB_SGG",
backupTable : "TB_SGG_ORG",
pkName : "SGG_CD"
},
success : (resp) => {
fnRenderBackupAndOriginal(resp.originalDataList,"originalSggTbody--${pageName}", pageObject['${pageName}'].originalDataset);
fnRenderBackupAndOriginal(resp.backupDataList,"backupSggTbody--${pageName}", pageObject['${pageName}'].backupDataset);
}
});
}
$("#btnAdd--${pageName}").on("click", function(){
var checked = $("#backupSggTbody--${pageName}").find("input[type='checkbox']:checked");
if(checked.length < 1){
return;
}
var arr = [];
checked.each(function(){
arr.push(this.value);
});
ajax.post({
url : wctx.url("/admin/sggBackup/activate.do"),
data : {
originalTable : "TB_SGG",
backupTable : "TB_SGG_ORG",
pkName : "SGG_CD",
pks : arr.join(",")
},
success : (resp) => {
if(resp.saved){
getBackupAndOriginalDataList();
}
}
});
});
$("#btnDel--${pageName}").on("click", function(){
var checked = $("#originalSggTbody--${pageName}").find("input[type='checkbox']:checked");
if(checked.length < 1){
return;
}
var arr = [];
checked.each(function(){
arr.push(this.value);
});
ajax.post({
url : wctx.url("/admin/sggBackup/deactivate.do"),
data : {
originalTable : "TB_SGG",
backupTable : "TB_SGG_ORG",
pkName : "SGG_CD",
pks : arr.join(",")
},
success : (resp) => {
if(resp.saved){
getBackupAndOriginalDataList();
}
}
});
});
$(document).ready(function(){
getBackupAndOriginalDataList();
});
</script>
Loading…
Cancel
Save