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

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

@ -1,6 +1,36 @@
package cokr.xit.fims.base; 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.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 @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; 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") @RequestMapping(name="설정정보 조회",value="/stngInfo.do")
public ModelAndView getStngInfo(String type) { public ModelAndView getStngInfo(String type) {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");

@ -12,9 +12,9 @@ public interface StngMapper extends AbstractMapper {
/** . /** .
* @param userId ID * @param userId ID
* @return * @return
*/ */
String selectDefaultTask(String userId); DataObject selectDefaultTask(String userId);
/** . /** .
* @param userId ID * @param userId ID
@ -40,4 +40,16 @@ public interface StngMapper extends AbstractMapper {
*/ */
int updateDtbnActno(Map<String, String> params); 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; return;
} }
String defaultTask = stngMapper.selectDefaultTask(userInfo.getId()); DataObject defaultTask = stngMapper.selectDefaultTask(userInfo.getId());
if(defaultTask == null) { if(defaultTask == null) {
userInfo.getInfo().put("defaultTask", ""); userInfo.getInfo().put("defaultTask", "");
} else { } 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"> <!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"> <mapper namespace="cokr.xit.fims.cmmn.dao.StngMapper">
<select id="selectDefaultTask" parameterType="string" resultType="string"> <select id="selectDefaultTask" parameterType="string" resultType="dataobject">
/* 사용자 기본업무 조회 (stngMapper.selectDefaultTask) */ /* 사용자 기본업무 조회 (stngMapper.selectDefaultTask) */
SELECT TM.TASK_SE_CD SELECT TM.TASK_MTCHG_ID
, TM.TASK_SE_CD
FROM TB_TASK_MTCHG TM FROM TB_TASK_MTCHG TM
WHERE TM.USER_ID = #{userId} WHERE TM.USER_ID = #{userId}
AND TM.USE_YN = 'Y' AND TM.USE_YN = 'Y'
@ -60,4 +61,39 @@ UPDATE TB_DEPT
WHERE DEPT_CD = #{deptCd} WHERE DEPT_CD = #{deptCd}
</update> </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> </mapper>

@ -39,14 +39,8 @@
<div class="modal-dialog modal-sm" role="document"> <div class="modal-dialog modal-sm" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body" style="min-height:10em; min-width:30%;"> <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> <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> </span>
</div> </div>
</div> </div>
@ -72,15 +66,9 @@
pageObject.childReq = []; pageObject.childReq = [];
pageObject.parentRes = []; pageObject.parentRes = [];
var ALL_TASK = { var ALL_TASK = {};
"PVS" : "주정차위반",
"BPV" : "전용차로위반",
"DPV" : "장애인전용",
"ECA" : "전기차주차",
"TPV" : "밤샘주차위반",
"DVS" : "미세먼지"
};
var MY_INFO = {}; var MY_INFO = {};
var PARAM_TASK = "${param.taskSeCd}";
function getBrowserName() { function getBrowserName() {
var agent = navigator.userAgent.toUpperCase(); var agent = navigator.userAgent.toUpperCase();
@ -112,6 +100,74 @@
break; 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} ${functions}
${topScript} ${topScript}
@ -121,12 +177,11 @@
$(function(){ $(function(){
${onload} ${onload}
ajax.get({ fnGetAllTask()
url:wctx.url("/user/myInfo.do"), .then(() => {
data : {}, return fnGetMyInfo();
success : resp => { })
.then(() => {
MY_INFO = resp.myInfo;
var msg = ""; var msg = "";
var available = true; var available = true;
@ -160,7 +215,7 @@
return; return;
} }
//사용자별 선택가능한 업무 라디오버튼 렌더링 //사용자별 선택가능한 업무 렌더링
for(var i=0; i < MY_INFO.info.taskForUser.length; i++){ for(var i=0; i < MY_INFO.info.taskForUser.length; i++){
var taskCd = MY_INFO.info.taskForUser[i]; var taskCd = MY_INFO.info.taskForUser[i];
var taskNm = ALL_TASK[taskCd]; var taskNm = ALL_TASK[taskCd];
@ -171,19 +226,13 @@
radio += "<label for='taskSeCd"+(i+1)+"--top'>"+taskNm+"</label>"; radio += "<label for='taskSeCd"+(i+1)+"--top'>"+taskNm+"</label>";
radio += "</span>"; radio += "</span>";
$("#taskSeCd--Top").append(radio); $("#taskSeCd--Top").append(radio);
}
//업무선택 모달 다이얼로그 var button = `<button type="button" class="btn btn-xl btn-primary" onclick="fnSelectDefaultTask('`
if(MY_INFO.info.defaultTask == null || MY_INFO.info.defaultTask == ""){ +taskCd
//$("#selectTaskModal").modal("show"); +`');">`
//return; +taskNm
} +`</button>`;
$("#selectTaskButtons").append(button);
//업무 체크
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(){ $("#layout-navbar input[name='taskSeCd']").on("click", function(){
$("#userNav--top").click(); $("#userNav--top").click();
@ -191,15 +240,15 @@
return false; return false;
}); });
//좌측상단제목 //업무선택 모달 다이얼로그
var checkedId = $("#layout-navbar input[name='taskSeCd']:checked")[0].id; if(MY_INFO.info.defaultTask == null || MY_INFO.info.defaultTask == ""){
var checkedText = $("label[for='"+checkedId+"']").text(); $("#selectTaskModal").modal("show");
$("#home").html("과태료통합관리시스템<br/>("+checkedText+")"); return;
} else {
//대시보드 로드 initIndexPage(PARAM_TASK, MY_INFO.info.defaultTask);
${dashboardScript} return;
} }
}); });
}); });
</script> </script>

Loading…
Cancel
Save