From 405ffb99b5e8630aabea24b2c276fb74db4642c5 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 5 Dec 2023 18:10:03 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=9C=EB=A0=A5=EB=AC=BC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/sprt/OtptForm.java | 3 +- .../xit/fims/sprt/dao/OtptStngMapper.java | 4 + .../fims/sprt/service/bean/OtptStngBean.java | 17 ++ .../xit/fims/sprt/web/Sprt01Controller.java | 40 +++- .../cokr/xit/fims/task/web/CmnController.java | 5 +- .../sql/mapper/fims/sprt/otptStng-mapper.xml | 57 ++++++ .../WEB-INF/jsp/fims/sprt/sprt01200-main.jsp | 187 +++++++++++------- 7 files changed, 237 insertions(+), 76 deletions(-) diff --git a/src/main/java/cokr/xit/fims/sprt/OtptForm.java b/src/main/java/cokr/xit/fims/sprt/OtptForm.java index 5e538d09..d2079978 100644 --- a/src/main/java/cokr/xit/fims/sprt/OtptForm.java +++ b/src/main/java/cokr/xit/fims/sprt/OtptForm.java @@ -9,6 +9,7 @@ import lombok.Setter; @Getter @Setter public class OtptForm extends AbstractEntity { + private String otptBscId; private String sggCd; private String taskSeCd; private String sndngSeCd; @@ -16,7 +17,7 @@ public class OtptForm extends AbstractEntity { private String foldLinePstnSeCd;//접는선 위치 구분코드 private String bcrnImgPath; //배경이미지경로 private String bcrnImgFileNm; //배경이미지파일 - private String otptPhotoCnt; //출력사진수 + private String otptPhotoCnt; //출력사진 수 private List otptArtclStngList; private String[] otptFormIDs; } diff --git a/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java b/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java index ab01da31..45ea2e73 100644 --- a/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java +++ b/src/main/java/cokr/xit/fims/sprt/dao/OtptStngMapper.java @@ -19,6 +19,10 @@ public interface OtptStngMapper extends AbstractMapper { */ DataObject selectOtptBscStng(OtptStngQuery otptStngQuery); + int insertBscStng(OtptForm otptForm); + + int updateBscStng(OtptForm otptForm); + /**지정한 조건에 따라 출력 항목 설정을 조회한다.
* @param query 출력물 설정 조회 조건 * @return 출력물 설정 항목 diff --git a/src/main/java/cokr/xit/fims/sprt/service/bean/OtptStngBean.java b/src/main/java/cokr/xit/fims/sprt/service/bean/OtptStngBean.java index 8b80aadd..7f6f5c9b 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/bean/OtptStngBean.java +++ b/src/main/java/cokr/xit/fims/sprt/service/bean/OtptStngBean.java @@ -74,6 +74,23 @@ public class OtptStngBean extends AbstractComponent { return otptStngMap; } + public boolean saveOtptBscStng(OtptForm otptForm) { + + boolean result = false; + String userId = currentUser().getId(); + + if(ifEmpty(otptForm.getOtptBscId(), ()-> "").equals("")) { + otptForm.setCreatedBy(userId); + result = otptStngMapper.insertBscStng(otptForm) == 1 ? true : false; + + } else { + otptForm.setModifiedBy(userId); + result = otptStngMapper.updateBscStng(otptForm) == 1 ? true : false; + } + + return result; + } + /** 출력 요소 설정을 저장 및 삭제 처리한다. * @param otptForm 출력 설정 * @return 저장여부 diff --git a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java index 3a2ebccc..e4ea2912 100644 --- a/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java +++ b/src/main/java/cokr/xit/fims/sprt/web/Sprt01Controller.java @@ -1,5 +1,6 @@ package cokr.xit.fims.sprt.web; +import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -8,6 +9,8 @@ import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import org.apache.commons.io.FilenameUtils; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; @@ -487,11 +490,44 @@ public class Sprt01Controller extends ApplicationController { /** 출력물 설정 정보를 저장한다. * @return 저장 여부 */ - public ModelAndView saveOtptStngInfo(OtptForm otptForm) { + public ModelAndView saveOtptStngInfo(OtptForm otptForm, MultipartFile backgroundFile) { ModelAndView mav = new ModelAndView("jsonView"); boolean saved = false; - saved = otptStngBean.saveOtptArtclStng(otptForm); + if(backgroundFile != null && !backgroundFile.isEmpty()) { + String institute = currentUser().getInstitute(); + String account = currentUser().getAccount(); + ManagedUser currentUser = userMapper.getUser(account, institute); + String deptCd = currentUser.getDeptCode(); + String sggCd = globalStngMapper.selectSggCd(deptCd); + + String bgPath = "files"+File.separator+"background" + +File.separator+sggCd; + + String ext = FilenameUtils.getExtension(backgroundFile.getOriginalFilename()); + String fileName = otptForm.getTaskSeCd()+"-"+otptForm.getSndngSeCd()+"-"+otptForm.getTaskSeCd()+"."+ext; + + File workDir = new File(bgPath); + workDir.mkdirs(); + try { + String bgFullPath = bgPath + File.separator + fileName; + File newFile = new File(bgFullPath); + if(newFile.exists()) { + newFile.delete(); + } + backgroundFile.transferTo(newFile); + + otptForm.setBcrnImgPath(bgFullPath); + otptForm.setBcrnImgFileNm(backgroundFile.getOriginalFilename()); + } catch (Exception e) { + throw new RuntimeException("배경 이미지 업로드 중 오류가 발생하였습니다."); + } + } + + saved = otptStngBean.saveOtptBscStng(otptForm); + if(saved) { + saved = otptStngBean.saveOtptArtclStng(otptForm); + } mav.addObject("saved", saved); return mav; diff --git a/src/main/java/cokr/xit/fims/task/web/CmnController.java b/src/main/java/cokr/xit/fims/task/web/CmnController.java index 9607a7be..ed033abc 100644 --- a/src/main/java/cokr/xit/fims/task/web/CmnController.java +++ b/src/main/java/cokr/xit/fims/task/web/CmnController.java @@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import cokr.xit.fims.crdn.Crdn; @@ -447,8 +448,8 @@ public class CmnController { @Override @RequestMapping(name="출력물 설정 정보 저장", value=METHOD_URL.saveOtptStngInfo) - public ModelAndView saveOtptStngInfo(OtptForm otptForm) { - return super.saveOtptStngInfo(otptForm); + public ModelAndView saveOtptStngInfo(OtptForm otptForm, MultipartFile backgroundFile) { + return super.saveOtptStngInfo(otptForm, backgroundFile); } } diff --git a/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml b/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml index 77d08536..c7df5812 100644 --- a/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml +++ b/src/main/resources/sql/mapper/fims/sprt/otptStng-mapper.xml @@ -21,6 +21,63 @@ SELECT OTPT_BSC_ID AND PAPER_SE_CD = #{paperSeCd} + +/* 출력 기본 설정 등록(otptStngMapper.insertBscStng) */ + +SELECT + LPAD(CAST(IFNULL(MAX(OTPT_BSC_ID) + 1, 1) AS INT), 10, '0') + AS NEW_ID +FROM TB_OTPT_BSC_STNG + +INSERT + INTO TB_OTPT_BSC_STNG ( + OTPT_BSC_ID + , SGG_CD + , TASK_SE_CD + , SNDNG_SE_CD + , PAPER_SE_CD + , FOLD_LINE_PSTN_SE_CD + + , BCRN_IMG_PATH + , BCRN_IMG_FILE_NM + + , OTPT_PHOTO_CNT + , USE_YN + , REG_DT + , RGTR + ) VALUES ( + #{otptBscId} + , #{sggCd} + , #{taskSeCd} + , #{sndngSeCd} + , #{paperSeCd} + , #{foldLinePstnSeCd} + + , #{bcrnImgPath} + , #{bcrnImgFileNm} + + , #{otptPhotoCnt} + , 'Y' + , + , #{createdBy} + ) + + + +/* 출력 기본 설정 수정(otptStngMapper.updateBscStng) */ +UPDATE TB_OTPT_BSC_STNG + SET FOLD_LINE_PSTN_SE_CD = #{foldLinePstnSeCd} + + , BCRN_IMG_PATH = #{bcrnImgPath} + , BCRN_IMG_FILE_NM = #{bcrnImgFileNm} + + , OTPT_PHOTO_CNT = #{otptPhotoCnt} + , MDFCN_DT = + , MDFR = #{modifiedBy} + WHERE OTPT_BSC_ID = #{otptBscId} + AND USE_YN = 'Y' + + + + + + + @@ -99,16 +105,6 @@ -
- - - - - - -
- - @@ -239,14 +235,17 @@ @@ -297,7 +296,13 @@ $(document).ready(function(){ if(resp.otptGlobalStng != null){ $P.otptGlobalStng = resp.otptGlobalStng; } else { - $P.otptGlobalStng = {}; + $P.otptGlobalStng = { + OTPT_BSC_ID : "", + FOLD_LINE_PSTN_SE_CD : "", + BCRN_IMG_PATH : "", + BCRN_IMG_FILE_NM : "", + OTPT_PHOTO_CNT : "" + }; } $P.otptArtclStngMap = resp.otptArtclStngMap; @@ -317,22 +322,40 @@ $(document).ready(function(){ //출력 전역 설정 렌더링 $P.renderOtptGlobalStng = (otptGlobalStng) => { var paperSeCd = $("#frmEdit--${pageName}").find("[name='paperSeCd']").val(); + var editForm = $("#frmEdit--${pageName}"); - if(paperSeCd == "01"){ - $("#otptGlobalStng--${pageName}").append(document.getElementById("foldLinePstnTemplate--${pageName}").innerHTML); - if(otptGlobalStng.foldLinePstnSeCd == null){ - otptGlobalStng.foldLinePstnSeCd = ""; - } - - $("#frmGlobalEdit--${pageName}") - .find(":radio[name='foldLinePstnSeCd']") - .filter("[value='"+otptGlobalStng.foldLinePstnSeCd+"']") - .prop("checked", true); + //설정ID + $("#otptGlobalStng--${pageName}").append(""); + editForm.find("input[name='otptBscId']").val(otptGlobalStng.OTPT_BSC_ID); + + //접는선 위치 + $("#otptGlobalStng--${pageName}").append(document.getElementById("foldLinePstnTemplate--${pageName}").innerHTML); + if(paperSeCd == "02"){ + $("#otptGlobalStng--${pageName}").find("label").eq(3).remove(); } + if(otptGlobalStng.FOLD_LINE_PSTN_SE_CD == null){ + otptGlobalStng.FOLD_LINE_PSTN_SE_CD = ""; + } + editForm.find(":radio[name='foldLinePstnSeCd']") + .filter("[value='"+otptGlobalStng.FOLD_LINE_PSTN_SE_CD+"']") + .prop("checked", true); + //배경이미지 $("#otptGlobalStng--${pageName}").append(document.getElementById("bcrnTemplate--${pageName}").innerHTML); - $("#otptGlobalStng--${pageName}").append(document.getElementById("photoCntTemplate--${pageName}").innerHTML); + if(otptGlobalStng.BCRN_IMG_PATH == null || otptGlobalStng.BCRN_IMG_PATH == ""){ + $("#fileStatus--${pageName}").text("없음"); + $("#btnBgDown--${pageName}").attr("hidden","hidden"); + } else { + $("#fileStatus--${pageName}").text(otptGlobalStng.BCRN_IMG_FILE_NM); + $("#btnBgDown--${pageName}").removeAttr("hidden"); + } + //출력 사진 건 수 + $("#otptGlobalStng--${pageName}").append(document.getElementById("photoCntTemplate--${pageName}").innerHTML); + if(otptGlobalStng.OTPT_PHOTO_CNT == null || otptGlobalStng.OTPT_PHOTO_CNT == ""){ + otptGlobalStng.OTPT_PHOTO_CNT = 0; + } + editForm.find("input[name='otptPhotoCnt']").val(otptGlobalStng.OTPT_PHOTO_CNT); } //출력 요소 그리드 렌더링 @@ -437,6 +460,7 @@ $(document).ready(function(){ } } + //출력 요소 선택 $P.choiceOtptArtclNm = () => { $("#dropdownUniqueAdd--${pageName}").html(""); @@ -580,7 +604,7 @@ $(document).ready(function(){ }); } - + //출력 요소 변경 $P.fnChangeComponent = (selectElement) => { if($("#tbodyMultiple--${pageName}").find(selectElement).length <= 0){ return; @@ -615,55 +639,46 @@ $(document).ready(function(){ } - $P.getRowData = (tbodyId, query) => { + //출력 요소 설정 값 추출 + $P.getRowData = (tbodyId, formData) => { var rowArr = []; $("#"+tbodyId+" tr").each(function(){ - var otptFormId = this.dataset.key; - var otptArtclNm = $($P.fnGetElement(this,"otptArtclNm")).val(); - var leftPstn = $($P.fnGetElement(this,"leftPstn")).val(); - var topPstn = $($P.fnGetElement(this,"topPstn")).val(); - var widthSz = $($P.fnGetElement(this,"widthSz")).val(); - var heightSz = $($P.fnGetElement(this,"heightSz")).val(); - var textSort = $($P.fnGetElement(this,"textSort")).val(); - var fontNm = $($P.fnGetElement(this,"fontNm")).val(); - var fontSz = $($P.fnGetElement(this,"fontSz")).val(); - var fontColor = $($P.fnGetElement(this,"fontColor")).val(); - var fontStyle = $($P.fnGetElement(this,"fontStyle")).val(); - var otptArtclOrdr = $($P.fnGetElement(this,"otptArtclOrdr")).val(); + var row = {}; + + row.otptFormId = this.dataset.key; + row.otptArtclNm = $($P.fnGetElement(this,"otptArtclNm")).val(); + row.leftPstn = $($P.fnGetElement(this,"leftPstn")).val(); + row.topPstn = $($P.fnGetElement(this,"topPstn")).val(); + row.widthSz = $($P.fnGetElement(this,"widthSz")).val(); + row.heightSz = $($P.fnGetElement(this,"heightSz")).val(); + row.textSort = $($P.fnGetElement(this,"textSort")).val(); + row.fontNm = $($P.fnGetElement(this,"fontNm")).val(); + row.fontSz = $($P.fnGetElement(this,"fontSz")).val(); + row.fontColor = $($P.fnGetElement(this,"fontColor")).val(); + row.fontStyle = $($P.fnGetElement(this,"fontStyle")).val(); + row.otptArtclOrdr = $($P.fnGetElement(this,"otptArtclOrdr")).val(); + + row.sggCd = formData.get("sggCd"); + row.taskSeCd = formData.get("taskSeCd"); + row.sndngSeCd = formData.get("sndngSeCd"); + row.paperSeCd = formData.get("paperSeCd"); - var row = { - otptFormId : otptFormId, - otptArtclNm : otptArtclNm, - leftPstn : leftPstn, - topPstn : topPstn, - widthSz : widthSz, - heightSz : heightSz, - textSort : textSort, - fontNm : fontNm, - fontSz : fontSz, - fontColor : fontColor, - fontStyle : fontStyle, - otptArtclOrdr : otptArtclOrdr, - - sggCd : query.sggCd, - taskSeCd : query.taskSeCd, - sndngSeCd : query.sndngSeCd, - paperSeCd : query.paperSeCd - }; rowArr.push(row); }); return rowArr; } + //출력 설정 저장 $P.fnSave = () => { - var ff = new FimsFormFields("#frmEdit--${pageName}"); - var query = ff.get(); - var rowArr1 = $P.getRowData("tbodyUnique--${pageName}", query); - var rowArr2 = $P.getRowData("tbodyMultiple--${pageName}", query); - var rowArr = [...rowArr1, ...rowArr2]; + //출력물 전역설정 + var formData = new FormData(document.getElementById("frmEdit--sprt01200-main")); + //출력 요소 설정 + var rowArr1 = $P.getRowData("tbodyUnique--${pageName}", formData); + var rowArr2 = $P.getRowData("tbodyMultiple--${pageName}", formData); + var rowArr = [...rowArr1, ...rowArr2]; for(var i=0; i { if(resp.saved){ if(!$("#viewSample--${pageName}").is(":checked")){ dialog.alert("저장되었습니다."); } - $("#frmSearch--${pageName}").find("[name='sggCd']").val(query.sggCd); - $("#frmSearch--${pageName}").find("[name='taskSeCd']").val(query.taskSeCd); - $("#frmSearch--${pageName}").find("[name='sndngSeCd']").val(query.sndngSeCd); - $("#frmSearch--${pageName}").find("[name='paperSeCd']").val(query.paperSeCd); + var ff = new FimsFormFields("#frmEdit--${pageName}").get(); + $("#frmSearch--${pageName}").find("[name='sggCd']").val(ff.sggCd); + $("#frmSearch--${pageName}").find("[name='taskSeCd']").val(ff.taskSeCd); + $("#frmSearch--${pageName}").find("[name='sndngSeCd']").val(ff.sndngSeCd); + $("#frmSearch--${pageName}").find("[name='paperSeCd']").val(ff.paperSeCd); $("#btnLoad--${pageName}").click(); @@ -699,6 +718,7 @@ $(document).ready(function(){ }); } + //샘플파일 생성 $P.fnMakeSampleFile = () => { var formFields = new FimsFormFields("#frmEdit--${pageName}"); @@ -734,6 +754,7 @@ $(document).ready(function(){ } + //배경이미지 출력 순서 고정 $P.validForBackground = (eventInfo) => { if(eventInfo.clickedButtonType == "up"){ if($P.fnGetElement(eventInfo.siblingRow,"otptArtclNm").value == "background"){ @@ -751,6 +772,30 @@ $(document).ready(function(){ return true; }; + $P.fnBgDown = () => { + var a = document.createElement("a"); + a.href = $P.otptGlobalStng.BCRN_IMG_PATH; + a.download = $P.otptGlobalStng.BCRN_IMG_FILE_NM; + document.getElementById("tempArea--${pageName}").appendChild(a); + a.click(); + document.getElementById("tempArea--${pageName}").removeChild(a); + } + + $P.fnBgUpload = (fileElement) => { + if(fileElement.files == null || fileElement.files.length == 0){ + if($P.otptGlobalStng.BCRN_IMG_PATH == null || $P.otptGlobalStng.BCRN_IMG_PATH == ""){ + $("#fileStatus--sprt01200-main").text("없음"); + $("#btnBgDown--${pageName}").attr("hidden","hidden"); + } else { + $("#fileStatus--sprt01200-main").text($P.otptGlobalStng.BCRN_IMG_FILE_NM); + $("#btnBgDown--${pageName}").removeAttr("hidden"); + } + } else { + $("#fileStatus--sprt01200-main").text("이미지 변경됨"); + $("#btnBgDown--${pageName}").attr("hidden","hidden"); + } + } + $("#theadUnique--${pageName}").html($("#theadTr--${pageName}")[0].innerHTML); $("#theadMultiple--${pageName}").html($("#theadTr--${pageName}")[0].innerHTML);