parent
588d396a2b
commit
940e88eb68
@ -0,0 +1,176 @@
|
|||||||
|
package cokr.xit.fims.cmmn.web;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import cokr.xit.base.code.CommonCode;
|
||||||
|
import cokr.xit.base.user.ManagedUser;
|
||||||
|
import cokr.xit.base.user.dao.UserMapper;
|
||||||
|
import cokr.xit.base.web.ApplicationController;
|
||||||
|
import cokr.xit.fims.cmmn.OtptForm;
|
||||||
|
import cokr.xit.fims.cmmn.OtptStngQuery;
|
||||||
|
import cokr.xit.fims.cmmn.service.StngService;
|
||||||
|
import cokr.xit.fims.cmmn.service.bean.OtptStngBean;
|
||||||
|
import cokr.xit.fims.cmmn.service.bean.StngBean;
|
||||||
|
import cokr.xit.fims.crdn.dao.GlobalStngMapper;
|
||||||
|
import cokr.xit.fims.stat.dao.StatMapper;
|
||||||
|
import cokr.xit.foundation.data.DataObject;
|
||||||
|
|
||||||
|
/**설정 관리 서비스의 웹 컨트롤러
|
||||||
|
*
|
||||||
|
* <p>상세 설명:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* ============ 변경 이력 ============
|
||||||
|
* 2024-02-20 leebj 최초 작성
|
||||||
|
* ================================
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class StngController extends ApplicationController {
|
||||||
|
public static final String CLASS_URL = "/stng/stng01";
|
||||||
|
|
||||||
|
public class METHOD_URL {
|
||||||
|
public static final String
|
||||||
|
otptStngMain = "/010/main.do",
|
||||||
|
getOtptStngInfo = "/010/info.do",
|
||||||
|
saveOtptStngInfo = "/010/save.do"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Resource(name = "stngService")
|
||||||
|
private StngService stngService;
|
||||||
|
|
||||||
|
@Resource(name = "stngBean")
|
||||||
|
private StngBean stngBean;
|
||||||
|
|
||||||
|
@Resource(name = "otptStngBean")
|
||||||
|
private OtptStngBean otptStngBean;
|
||||||
|
|
||||||
|
@Resource(name = "userMapper")
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
|
@Resource(name = "globalStngMapper")
|
||||||
|
private GlobalStngMapper globalStngMapper;
|
||||||
|
|
||||||
|
@Resource(name = "statMapper")
|
||||||
|
private StatMapper statMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/** 출력물 설정 메인 화면을 연다.
|
||||||
|
* @return 출력물 설정 메인 화면
|
||||||
|
*/
|
||||||
|
public ModelAndView otptStngMain() {
|
||||||
|
ModelAndView mav = new ModelAndView("fims/stng01010-main");
|
||||||
|
mav.addObject("pageName", "stng01010");
|
||||||
|
|
||||||
|
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM054","FIM047","FIM078","FIM080");
|
||||||
|
|
||||||
|
mav.addObject("FIM047List", commonCodes.get("FIM047"));
|
||||||
|
mav.addObject("FIM054List", commonCodes.get("FIM054"));
|
||||||
|
mav.addObject("TaskListForSgg", stngBean.filterTaskSectionCodeForSgg(commonCodes.get("FIM054")));
|
||||||
|
mav.addObject("FIM078List", commonCodes.get("FIM078"));
|
||||||
|
mav.addObject("FIM080List", commonCodes.get("FIM080"));
|
||||||
|
addCodes(commonCodes, mav, "FIM047", "FIM054", "FIM078","FIM080");
|
||||||
|
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 출력물 설정 정보를 불러온다.
|
||||||
|
* @return 출력물 설정 정보
|
||||||
|
*/
|
||||||
|
public ModelAndView getOtptStngInfo(OtptStngQuery otptStngQuery) {
|
||||||
|
|
||||||
|
ModelAndView mav = new ModelAndView("jsonView");
|
||||||
|
|
||||||
|
//출력 설정 제목
|
||||||
|
String institute = currentUser().getInstitute();
|
||||||
|
String account = currentUser().getAccount();
|
||||||
|
ManagedUser currentUser = userMapper.getUser(account, institute);
|
||||||
|
String deptCd = currentUser.getDeptCode();
|
||||||
|
String sggCd = globalStngMapper.selectSggCd(deptCd);
|
||||||
|
DataObject sgg = statMapper.selectSggByCode(sggCd);
|
||||||
|
String sggNm = sgg.string("NAME");
|
||||||
|
|
||||||
|
Map<String, List<CommonCode>> commonCodes = getCodesOf("FIM054","FIM047","FIM078");
|
||||||
|
List<CommonCode> FIM047 = commonCodes.get("FIM047");
|
||||||
|
List<CommonCode> FIM054 = commonCodes.get("FIM054");
|
||||||
|
List<CommonCode> FIM078 = commonCodes.get("FIM078");
|
||||||
|
|
||||||
|
String taskSeNm = FIM054.stream().
|
||||||
|
filter(item -> item.getCode().equals(otptStngQuery.getTaskSeCd())).findFirst().get().getValue();
|
||||||
|
|
||||||
|
String sndngSeNm = FIM047.stream().
|
||||||
|
filter(item -> item.getCode().equals(otptStngQuery.getSndngSeCd())).findFirst().get().getValue();
|
||||||
|
|
||||||
|
String otptPaperSeNm = FIM078.stream().
|
||||||
|
filter(item -> item.getCode().equals(otptStngQuery.getPaperSeCd())).findFirst().get().getValue();
|
||||||
|
|
||||||
|
String otptStngTitle = "["+sggNm+", "+taskSeNm+"]"+" "+sndngSeNm+" "+"("+otptPaperSeNm+")";
|
||||||
|
mav.addObject("otptStngTitle", otptStngTitle);
|
||||||
|
|
||||||
|
//출력물 기본 설정
|
||||||
|
DataObject otptBscStng = new DataObject();
|
||||||
|
otptBscStng = otptStngBean.getOtptBscStng(otptStngQuery);
|
||||||
|
mav.addObject("otptGlobalStng", otptBscStng);
|
||||||
|
|
||||||
|
//출력 요소별 설정
|
||||||
|
Map<String,Object> otptArtclStngMap = otptStngBean.getOtptArtclStngMap(otptStngQuery);
|
||||||
|
|
||||||
|
mav.addObject("otptArtclStngMap", otptArtclStngMap);
|
||||||
|
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 출력물 설정 정보를 저장한다.
|
||||||
|
* @return 저장 여부
|
||||||
|
*/
|
||||||
|
public ModelAndView saveOtptStngInfo(OtptForm otptForm, MultipartFile backgroundFile) {
|
||||||
|
ModelAndView mav = new ModelAndView("jsonView");
|
||||||
|
boolean saved = false;
|
||||||
|
|
||||||
|
if(backgroundFile != null && !backgroundFile.isEmpty() && backgroundFile.getSize() != 0) {
|
||||||
|
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/background/"+sggCd;
|
||||||
|
|
||||||
|
String ext = FilenameUtils.getExtension(backgroundFile.getOriginalFilename());
|
||||||
|
String fileName = otptForm.getTaskSeCd()+"-"+otptForm.getSndngSeCd()+"-"+otptForm.getPaperSeCd()+"."+ext;
|
||||||
|
|
||||||
|
File workDir = new File(bgPath);
|
||||||
|
workDir.mkdirs();
|
||||||
|
try {
|
||||||
|
String bgFullPath = bgPath + "/" + 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue