diff --git a/src/main/java/cokr/xit/fims/base/AdminController.java b/src/main/java/cokr/xit/fims/base/AdminController.java index f1e655c1..386bc5d8 100644 --- a/src/main/java/cokr/xit/fims/base/AdminController.java +++ b/src/main/java/cokr/xit/fims/base/AdminController.java @@ -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 originalDataList = adminBean.getAllList(originalTable, pkName); + List 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 taskSeCdList = codeBean.getCodeList(cq); + mav.addObject("taskSeCdList", taskSeCdList); + + List 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; + } } diff --git a/src/main/java/cokr/xit/fims/base/Backup.java b/src/main/java/cokr/xit/fims/base/Backup.java new file mode 100644 index 00000000..a96db785 --- /dev/null +++ b/src/main/java/cokr/xit/fims/base/Backup.java @@ -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; +} diff --git a/src/main/java/cokr/xit/fims/base/dao/AdminMapper.java b/src/main/java/cokr/xit/fims/base/dao/AdminMapper.java new file mode 100644 index 00000000..01ef1d02 --- /dev/null +++ b/src/main/java/cokr/xit/fims/base/dao/AdminMapper.java @@ -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 selectAllList(Map map); + + int insertOriginalData(Backup backup); + + int deleteOriginalData(Backup backup); + + int insertBackupData(Backup backup); + + int deleteBackupData(Backup backup); + + int copyTask(Map param); + + List selectVltnList(Map param); + + int copyVltn(Map param); +} diff --git a/src/main/java/cokr/xit/fims/base/service/bean/AdminBean.java b/src/main/java/cokr/xit/fims/base/service/bean/AdminBean.java new file mode 100644 index 00000000..a12acccb --- /dev/null +++ b/src/main/java/cokr/xit/fims/base/service/bean/AdminBean.java @@ -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 getAllList(String originalTable, String pkName) { + Map map = new HashMap(); + map.put("originalTable", originalTable); + map.put("pkName", pkName); + return adminMapper.selectAllList(map); + } + + public List getAllList(String backupTable, String originalTable, String pkName) { + Map map = new HashMap(); + 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 param = new HashMap<>(); + param.put("taskSeCd",taskSeCd); + param.put("srcSgg",srcSgg); + param.put("trgtSgg",trgtSgg); + + adminMapper.copyTask(param); + + List 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; + } + + } +} diff --git a/src/main/resources/sql/mapper/fims/admin-mapper.xml b/src/main/resources/sql/mapper/fims/admin-mapper.xml new file mode 100644 index 00000000..f9c5506a --- /dev/null +++ b/src/main/resources/sql/mapper/fims/admin-mapper.xml @@ -0,0 +1,124 @@ + + + + + + + +INSERT + INTO ${originalTable} +SELECT * + FROM ${backupTable} + WHERE ${pkName} IN (#{pk}) + + + +DELETE + FROM ${backupTable} + WHERE ${pkName} IN (#{pk}) + + + +INSERT + INTO ${backupTable} +SELECT * + FROM ${originalTable} + WHERE ${pkName} IN (#{pk}) + + + +DELETE + FROM ${originalTable} + WHERE ${pkName} IN (#{pk}) + + + +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} + + + + + + + SELECT + LPAD(CAST(IFNULL(MAX(VLTN_ID) + 1, 1) AS INT), 10, '0') + AS NEW_ID + FROM TB_VLTN + + INSERT + INTO TB_VLTN + SELECT (CASE B.VLTN_CD + + WHEN #{vltnCd} THEN LPAD(CAST(${vltnId}+${index} AS INT), 10, '0') + + 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 (#{vltnCd}) + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/fims/admin-copySggStng-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/admin-copySggStng-info.jsp new file mode 100644 index 00000000..7b5b51c4 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/fims/admin-copySggStng-info.jsp @@ -0,0 +1,64 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%> +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp index a1bc995d..cd82366c 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/admin-main.jsp @@ -51,7 +51,12 @@ - +
+
+ + +
+
@@ -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(); }); diff --git a/src/main/webapp/WEB-INF/jsp/fims/admin-sggAddDel-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/admin-sggAddDel-info.jsp new file mode 100644 index 00000000..bc49f0ce --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/fims/admin-sggAddDel-info.jsp @@ -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"%> +
+
+
+

시군구 백업

+ +
+ +
+ +
+ +
+
+ + +
+
+ +
+

시군구

+ +
+ +
+ +
+ + +
+ + +
+ + + + + + \ No newline at end of file