사용자별 기본업무 등록,수정 추가

main
이범준 11 months ago
parent 0b16c403b5
commit 1893949348

@ -1,6 +1,36 @@
package cokr.xit.fims.base;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.base.code.service.CodeQuery;
import cokr.xit.base.code.service.bean.CodeBean;
import cokr.xit.foundation.data.DataObject;
@Controller
public class CodeController extends cokr.xit.base.code.web.CodeController {}
public class CodeController extends cokr.xit.base.code.web.CodeController {
@Resource(name = "codeBean")
private CodeBean codeBean;
@RequestMapping(name="모든 업무구분코드 조회",value="/getAllTaskSeCd.do")
public ModelAndView getAllTaskSeCd() {
ModelAndView mav = new ModelAndView("jsonView");
CodeQuery codeQuery = new CodeQuery();
codeQuery.setGroupIDs("FIM054");
List<DataObject> taskList = codeBean.getCodeList(codeQuery);
Map<String,String> allTask = taskList.stream()
.collect(Collectors.toMap((item) -> item.string("CODE"), (item) -> item.string("CODE_VAL")));
mav.addObject("allTask", allTask);
return mav;
}
}

@ -140,6 +140,17 @@ public class UserController extends cokr.xit.base.user.web.UserController<Manage
return mav;
}
@RequestMapping(name="기본업무 저장",value="/saveDefaultTask.do")
public ModelAndView saveDefaultTask(String taskSeCd) {
ModelAndView mav = new ModelAndView("jsonView");
boolean saved = false;
saved = stngBean.saveDefaultTask(taskSeCd);
mav.addObject("saved", saved);
return mav;
}
@RequestMapping(name="설정정보 조회",value="/stngInfo.do")
public ModelAndView getStngInfo(String type) {
ModelAndView mav = new ModelAndView("jsonView");

@ -12,9 +12,9 @@ public interface StngMapper extends AbstractMapper {
/** .
* @param userId ID
* @return
* @return
*/
String selectDefaultTask(String userId);
DataObject selectDefaultTask(String userId);
/** .
* @param userId ID
@ -40,4 +40,16 @@ public interface StngMapper extends AbstractMapper {
*/
int updateDtbnActno(Map<String, String> params);
/** .
* @param params
* @return
*/
int insertDefaultTask(Map<String, String> params);
/** .
* @param params
* @return
*/
int updateDefaultTask(Map<String, String> params);
}

@ -123,13 +123,41 @@ public class StngBean extends AbstractComponent {
return;
}
String defaultTask = stngMapper.selectDefaultTask(userInfo.getId());
DataObject defaultTask = stngMapper.selectDefaultTask(userInfo.getId());
if(defaultTask == null) {
userInfo.getInfo().put("defaultTask", "");
} else {
userInfo.getInfo().put("defaultTask", defaultTask);
userInfo.getInfo().put("defaultTask", defaultTask.string("TASK_SE_CD"));
}
}
/** .
* @param taskSeCd
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean saveDefaultTask(String taskSeCd) {
DataObject info = stngMapper.selectDefaultTask(currentUser().getId());
int effected = 0;
Map<String, String> params = new HashMap<String,String>();
params.put("userId", currentUser().getId());
params.put("taskSeCd", taskSeCd);
if(info == null) {
params.put("rgtr", currentUser().getId());
effected = stngMapper.insertDefaultTask(params);
} else {
params.put("mdfr", currentUser().getId());
params.put("taskMtchgId",info.string("TASK_MTCHG_ID"));
effected = stngMapper.updateDefaultTask(params);
}
return effected == 1 ? true : false;
}
}

@ -2,9 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.fims.cmmn.dao.StngMapper">
<select id="selectDefaultTask" parameterType="string" resultType="string">
<select id="selectDefaultTask" parameterType="string" resultType="dataobject">
/* 사용자 기본업무 조회 (stngMapper.selectDefaultTask) */
SELECT TM.TASK_SE_CD
SELECT TM.TASK_MTCHG_ID
, TM.TASK_SE_CD
FROM TB_TASK_MTCHG TM
WHERE TM.USER_ID = #{userId}
AND TM.USE_YN = 'Y'
@ -60,4 +61,39 @@ UPDATE TB_DEPT
WHERE DEPT_CD = #{deptCd}
</update>
<insert id="insertDefaultTask" parameterType="map">
/* 사용자 기본 업무 등록 (stngMapper.insertDefaultTask) */
<selectKey resultType="string" keyProperty="taskMtchgId" keyColumn="NEW_ID" order="BEFORE">
SELECT
LPAD(CAST(IFNULL(MAX(TASK_MTCHG_ID) + 1, 1) AS INT), 10, '0')
AS NEW_ID
FROM TB_TASK_MTCHG
</selectKey>
INSERT
INTO TB_TASK_MTCHG (
TASK_MTCHG_ID
, USER_ID
, TASK_SE_CD
, USE_YN
, REG_DT
, RGTR
) VALUES (
#{taskMtchgId}
, #{userId}
, #{taskSeCd}
, 'Y'
, <include refid="utility.now" />
, #{rgtr}
)
</insert>
<update id="updateDefaultTask" parameterType="map">
/* 사용자 기본 업무 변경 (stngMapper.updateDefaultTask) */
UPDATE TB_TASK_MTCHG
SET MDFR = #{mdfr}
, MDFCN_DT = <include refid="utility.now" />
, TASK_SE_CD = #{taskSeCd}
WHERE TASK_MTCHG_ID = #{taskMtchgId}
</update>
</mapper>

@ -39,14 +39,8 @@
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-body" style="min-height:10em; min-width:30%;">
<span class="row g-3" style="display: flex;flex-direction:column">
<span id="selectTaskButtons" class="row g-3" style="display: flex;flex-direction:column">
<div style="text-align:center" class="h3 fw-bold">업무를 선택하세요.</div>
<button type="button" class="btn btn-xl btn-primary">주정차</button>
<button type="button" class="btn btn-xl btn-primary">전용차로</button>
<button type="button" class="btn btn-xl btn-primary">장애인</button>
<button type="button" class="btn btn-xl btn-primary">전기차</button>
<button type="button" class="btn btn-xl btn-primary">밤샘주차</button>
<button type="button" class="btn btn-xl btn-primary">미세먼지</button>
</span>
</div>
</div>
@ -72,15 +66,9 @@
pageObject.childReq = [];
pageObject.parentRes = [];
var ALL_TASK = {
"PVS" : "주정차위반",
"BPV" : "전용차로위반",
"DPV" : "장애인전용",
"ECA" : "전기차주차",
"TPV" : "밤샘주차위반",
"DVS" : "미세먼지"
};
var ALL_TASK = {};
var MY_INFO = {};
var PARAM_TASK = "${param.taskSeCd}";
function getBrowserName() {
var agent = navigator.userAgent.toUpperCase();
@ -112,6 +100,74 @@
break;
}
async function fnGetAllTask(){
return new Promise((resolve, reject) => {
$.ajax({
type: "get",
url: wctx.url("/code/getAllTaskSeCd.do"),
data: {},
dataType: 'json',
success: function(resp, textStatus, jqXHR) {
ALL_TASK = resp.allTask;
resolve({resp, textStatus, jqXHR});
},
error: function(jqXHR, textStatus, error) {
}
});
});
};
async function fnGetMyInfo(){
return new Promise((resolve, reject) => {
$.ajax({
type: "get",
url: wctx.url("/user/myInfo.do"),
data: {},
dataType: 'json',
success: function(resp, textStatus, jqXHR) {
MY_INFO = resp.myInfo;
resolve({resp, textStatus, jqXHR});
},
error: function(jqXHR, textStatus, error) {
}
});
});
};
function fnSelectDefaultTask(taskSeCd){
ajax.get({
url : wctx.url("/user/saveDefaultTask.do"),
data : {
"taskSeCd" : taskSeCd
},
success : (resp) => {
if(resp.saved){
$("#selectTaskModal").modal("hide");
initIndexPage(PARAM_TASK, taskSeCd);
}
}
});
}
function initIndexPage(paramTask, userDefaultTask){
if(paramTask != "" || $("#layout-navbar").find("input[name='taskSeCd'][value='"+paramTask+"']").length > 0){
$("#layout-navbar input[name='taskSeCd'][value='"+paramTask+"']").prop("checked", true);
} else if(userDefaultTask != "" || $("#layout-navbar").find("input[name='taskSeCd'][value='"+userDefaultTask+"']").length > 0){
$("#layout-navbar input[name='taskSeCd'][value='"+userDefaultTask+"']").prop("checked", true);
} else {
$("#layout-navbar input[name='taskSeCd']").eq(0).prop("checked", true);
}
//좌측상단제목
var checkedId = $("#layout-navbar input[name='taskSeCd']:checked")[0].id;
var checkedText = $("label[for='"+checkedId+"']").text();
$("#home").html("과태료통합관리시스템<br/>("+checkedText+")");
//대시보드 로드
${dashboardScript}
}
${functions}
${topScript}
@ -121,86 +177,79 @@
$(function(){
${onload}
ajax.get({
url:wctx.url("/user/myInfo.do"),
data : {},
success : resp => {
MY_INFO = resp.myInfo;
var msg = "";
var available = true;
if(MY_INFO.user.status == "A" || MY_INFO.user.status == "D" || MY_INFO.user.locked == "Y"){
if(MY_INFO.user.status == "A"){
msg = "계정이 미승인 상태입니다.";
} else if(MY_INFO.user.status == "D"){
msg = "삭제된 계정입니다.";
} else if(MY_INFO.user.locked == "Y"){
msg = "잠금처리된 계정입니다.";
}
available = false;
}
fnGetAllTask()
.then(() => {
return fnGetMyInfo();
})
.then(() => {
var msg = "";
var available = true;
if(MY_INFO.user.status == "A" || MY_INFO.user.status == "D" || MY_INFO.user.locked == "Y"){
if(MY_INFO.user.status == "A"){
msg = "계정이 미승인 상태입니다.";
} else if(MY_INFO.user.status == "D"){
msg = "삭제된 계정입니다.";
} else if(MY_INFO.user.locked == "Y"){
msg = "잠금처리된 계정입니다.";
}
available = false;
}
if(!(MY_INFO.info.isAdmin) && !(MY_INFO.info.hasTaskAuth)){
msg = "계정에 부여된 업무권한이 없습니다.";
available = false;
}
if(msg != ""){
alert(msg);
}
//로그아웃
if(!available){
var form = $("<form action=\"/logout.do\", method=\"POST\">");
$("<input name=\"${_csrf.parameterName}\" value=\"${_csrf.token}\" type=\"hidden\">").appendTo(form);
form.appendTo("body").submit();
return;
}
//사용자별 선택가능한 업무 라디오버튼 렌더링
for(var i=0; i < MY_INFO.info.taskForUser.length; i++){
var taskCd = MY_INFO.info.taskForUser[i];
var taskNm = ALL_TASK[taskCd];
var radio = "";
radio += "<span>";
radio += "<input type='radio' id='taskSeCd"+(i+1)+"--top' name='taskSeCd' value='"+taskCd+"' title='"+taskNm+"' />";
radio += "<label for='taskSeCd"+(i+1)+"--top'>"+taskNm+"</label>";
radio += "</span>";
$("#taskSeCd--Top").append(radio);
}
//업무선택 모달 다이얼로그
if(MY_INFO.info.defaultTask == null || MY_INFO.info.defaultTask == ""){
//$("#selectTaskModal").modal("show");
//return;
}
//업무 체크
if("${param.taskSeCd}" == "" || $("#layout-navbar").find("input[name='taskSeCd'][value='${param.taskSeCd}']").length == 0){
$("#layout-navbar input[name='taskSeCd'][value='DPV']").prop("checked", true);
} else {
$("#layout-navbar input[name='taskSeCd'][value='${param.taskSeCd}']").prop("checked", true);
}
$("#layout-navbar input[name='taskSeCd']").on("click", function(){
$("#userNav--top").click();
window.open(wctx.url("/")+"?taskSeCd="+this.value, "_blank", "");
return false;
});
//좌측상단제목
var checkedId = $("#layout-navbar input[name='taskSeCd']:checked")[0].id;
var checkedText = $("label[for='"+checkedId+"']").text();
$("#home").html("과태료통합관리시스템<br/>("+checkedText+")");
//대시보드 로드
${dashboardScript}
}
});
if(!(MY_INFO.info.isAdmin) && !(MY_INFO.info.hasTaskAuth)){
msg = "계정에 부여된 업무권한이 없습니다.";
available = false;
}
if(msg != ""){
alert(msg);
}
//로그아웃
if(!available){
var form = $("<form action=\"/logout.do\", method=\"POST\">");
$("<input name=\"${_csrf.parameterName}\" value=\"${_csrf.token}\" type=\"hidden\">").appendTo(form);
form.appendTo("body").submit();
return;
}
//사용자별 선택가능한 업무 렌더링
for(var i=0; i < MY_INFO.info.taskForUser.length; i++){
var taskCd = MY_INFO.info.taskForUser[i];
var taskNm = ALL_TASK[taskCd];
var radio = "";
radio += "<span>";
radio += "<input type='radio' id='taskSeCd"+(i+1)+"--top' name='taskSeCd' value='"+taskCd+"' title='"+taskNm+"' />";
radio += "<label for='taskSeCd"+(i+1)+"--top'>"+taskNm+"</label>";
radio += "</span>";
$("#taskSeCd--Top").append(radio);
var button = `<button type="button" class="btn btn-xl btn-primary" onclick="fnSelectDefaultTask('`
+taskCd
+`');">`
+taskNm
+`</button>`;
$("#selectTaskButtons").append(button);
}
$("#layout-navbar input[name='taskSeCd']").on("click", function(){
$("#userNav--top").click();
window.open(wctx.url("/")+"?taskSeCd="+this.value, "_blank", "");
return false;
});
//업무선택 모달 다이얼로그
if(MY_INFO.info.defaultTask == null || MY_INFO.info.defaultTask == ""){
$("#selectTaskModal").modal("show");
return;
} else {
initIndexPage(PARAM_TASK, MY_INFO.info.defaultTask);
return;
}
});
});
</script>

Loading…
Cancel
Save