출력물 설정 수정

main
이범준 12 months ago
parent 98295e3b6e
commit 405ffb99b5

@ -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<OtptArtclStng> otptArtclStngList;
private String[] otptFormIDs;
}

@ -19,6 +19,10 @@ public interface OtptStngMapper extends AbstractMapper {
*/
DataObject selectOtptBscStng(OtptStngQuery otptStngQuery);
int insertBscStng(OtptForm otptForm);
int updateBscStng(OtptForm otptForm);
/** .<br />
* @param query
* @return

@ -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

@ -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;
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;

@ -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);
}
}

@ -21,6 +21,63 @@ SELECT OTPT_BSC_ID
AND PAPER_SE_CD = #{paperSeCd}
</select>
<insert id="insertBscStng" parameterType="cokr.xit.fims.sprt.OtptForm">
/* 출력 기본 설정 등록(otptStngMapper.insertBscStng) */
<selectKey resultType="string" keyProperty="otptBscId" keyColumn="NEW_ID" order="BEFORE">
SELECT
LPAD(CAST(IFNULL(MAX(OTPT_BSC_ID) + 1, 1) AS INT), 10, '0')
AS NEW_ID
FROM TB_OTPT_BSC_STNG
</selectKey>
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
<if test="bcrnImgPath != null and bcrnImgPath != ''">
, BCRN_IMG_PATH
, BCRN_IMG_FILE_NM
</if>
, OTPT_PHOTO_CNT
, USE_YN
, REG_DT
, RGTR
) VALUES (
#{otptBscId}
, #{sggCd}
, #{taskSeCd}
, #{sndngSeCd}
, #{paperSeCd}
, #{foldLinePstnSeCd}
<if test="bcrnImgPath != null and bcrnImgPath != ''">
, #{bcrnImgPath}
, #{bcrnImgFileNm}
</if>
, #{otptPhotoCnt}
, 'Y'
, <include refid="utility.now" />
, #{createdBy}
)
</insert>
<update id="updateBscStng" parameterType="cokr.xit.fims.sprt.OtptForm">
/* 출력 기본 설정 수정(otptStngMapper.updateBscStng) */
UPDATE TB_OTPT_BSC_STNG
SET FOLD_LINE_PSTN_SE_CD = #{foldLinePstnSeCd}
<if test="bcrnImgPath != null and bcrnImgPath != ''">
, BCRN_IMG_PATH = #{bcrnImgPath}
, BCRN_IMG_FILE_NM = #{bcrnImgFileNm}
</if>
, OTPT_PHOTO_CNT = #{otptPhotoCnt}
, MDFCN_DT = <include refid="utility.now" />
, MDFR = #{modifiedBy}
WHERE OTPT_BSC_ID = #{otptBscId}
AND USE_YN = 'Y'
</update>
<select id="selectOtptArtclStngList" parameterType="cokr.xit.fims.sprt.OtptStngQuery" resultType="dataobject">
/* 출력 항목 설정 조회(otptStngMapper.selectOtptArtclStngList) */
SELECT OTPT_FORM_ID

@ -40,7 +40,13 @@
<div class="d-flex justify-content-between">
<span id="currentOtpt--${pageName}" class="bg-lighter h3" style="min-height:30px;">
</span>
<form id="frmGlobalEdit--${pageName}">
<form id="frmEdit--${pageName}">
<input type="hidden" name="sggCd" />
<input type="hidden" name="taskSeCd" />
<input type="hidden" name="sndngSeCd" />
<input type="hidden" name="paperSeCd" />
<input type="text" name="dialogId" hidden />
<span id="otptGlobalStng--${pageName}">
</span>
</form>
@ -99,16 +105,6 @@
</div>
</div>
<form id="frmEdit--${pageName}" name="frmEdit">
<input type="hidden" name="sggCd" />
<input type="hidden" name="taskSeCd" />
<input type="hidden" name="sndngSeCd" />
<input type="hidden" name="paperSeCd" />
<input type="text" name="dialogId" hidden />
</form>
<span id="tempArea--${pageName}" hidden></span>
</div>
</div>
@ -239,14 +235,17 @@
<template id="bcrnTemplate--${pageName}">
<span class="px-2">
<label class="col-form-label bg-lighter px-2">배경이미지</label>
<button type="button">배경이미지</button>
<output id="fileStatus--${pageName}"></output>
<button type="button" onclick="$(this).next().click();">업로드</button>
<input type="file" name="backgroundFile" accept="image/*" hidden onchange="pageObject['${pageName}'].fnBgUpload(this);" />
<button type="button" id="btnBgDown--${pageName}" onclick="pageObject['${pageName}'].fnBgDown();">다운로드</button>
</span>
</template>
<template id="photoCntTemplate--${pageName}">
<span class="px-2">
<label class="col-form-label bg-lighter px-2">사진 출력</label>
<input type="text" name="otptPhotoCnt" class="form-control w-px-50" /> 장
<input type="number" name="otptPhotoCnt" class="form-control w-px-50" min="0" max="6" /> 장
</span>
</template>
@ -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"){
//설정ID
$("#otptGlobalStng--${pageName}").append("<input type='hidden' name='otptBscId' />");
editForm.find("input[name='otptBscId']").val(otptGlobalStng.OTPT_BSC_ID);
//접는선 위치
$("#otptGlobalStng--${pageName}").append(document.getElementById("foldLinePstnTemplate--${pageName}").innerHTML);
if(otptGlobalStng.foldLinePstnSeCd == null){
otptGlobalStng.foldLinePstnSeCd = "";
if(paperSeCd == "02"){
$("#otptGlobalStng--${pageName}").find("label").eq(3).remove();
}
$("#frmGlobalEdit--${pageName}")
.find(":radio[name='foldLinePstnSeCd']")
.filter("[value='"+otptGlobalStng.foldLinePstnSeCd+"']")
.prop("checked", true);
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 = {
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
};
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");
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<rowArr.length; i++){
if(rowArr[i].otptArtclNm == ""){
alert("출력항목명을 선택하세요.");
@ -671,23 +686,27 @@ $(document).ready(function(){
}
}
query.otptArtclStngList = rowArr;
query = fnJsonToFormData(query,"otptArtclStngList");
var otptArtclStngList = fnJsonArrayToFormData(rowArr,"otptArtclStngList");
var keys = Object.keys(otptArtclStngList);
for(var i=0; i < keys.length; i++){
formData.append(keys[i], otptArtclStngList[keys[i]]);
}
ajax.post({
url : wctx.url("/sprt/sprt01/200/save.do"),
data : query,
data : formData,
contentType : false, processData : false,
success : (resp) => {
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);

Loading…
Cancel
Save