diff --git a/src/main/java/cokr/xit/fims/base/dao/OgdpMapper.java b/src/main/java/cokr/xit/fims/base/dao/OgdpMapper.java index c6c0dd27..9c53f502 100644 --- a/src/main/java/cokr/xit/fims/base/dao/OgdpMapper.java +++ b/src/main/java/cokr/xit/fims/base/dao/OgdpMapper.java @@ -69,76 +69,6 @@ public interface OgdpMapper extends AbstractMapper { """; - /**모든 기관,부서 목록을 반환한다.
- * @param - * @return 기관,부서 목록 - */ - @Select(SQLUtil.SCRIPT_START+""" - /* 전체 기관,부서 목록 조회(ogdpMapper.selectAllOgdpList) */ - SELECT CONCAT(A.INST_CD,'/',B.DEPT_CD) AS OGDP_CD - , CONCAT(A.SGG_NM, ' / ', A.INST_NM, ' : ', B.DEPT_NM) AS OGDP_NM - , A.INST_CD - , A.INST_NM - , B.DEPT_CD - , B.DEPT_NM - , A.SGG_CD - , A.SGG_NM - FROM TB_SGG A - LEFT OUTER JOIN TB_DEPT B ON (A.INST_CD = B.INST_CD) - UNION - SELECT ('default/default') AS OGDP_CD - , CONCAT('기본 시군구',' / ','기본 기관', ' : ', '기본 부서') AS OGDP_NM - , 'default' AS INST_CD - , '기본 기관' AS INST_NM - , 'default' AS DEPT_CD - , '기본 부서' AS DEPT_NM - , 'default' AS SGG_CD - , '기본 시군구' AS SGG_NM - FROM DUAL - """+SQLUtil.SCRIPT_END) - List selectAllOgdpList(); - - /**사용가능한 기관,부서 목록을 반환한다.
- * @param stringMap - * @param - * @return 기관,부서 목록 - */ - @Select(SQLUtil.SCRIPT_START+""" - /* 사용가능한 기관,부서 목록 조회(ogdpMapper.selectAbleOgdpList) */ - SELECT CONCAT(A.INST_CD,'/',B.DEPT_CD) AS OGDP_CD - , CONCAT(A.SGG_NM, ' / ', A.INST_NM, ' : ', B.DEPT_NM) AS OGDP_NM - , A.INST_CD - , A.INST_NM - , B.DEPT_CD - , B.DEPT_NM - , A.SGG_CD - , A.SGG_NM - FROM TB_SGG A - LEFT OUTER JOIN TB_DEPT B ON (A.INST_CD = B.INST_CD) - - - WHERE A.SGG_CD = #{sggCd} - - - - WHERE A.SGG_CD = #{currentUser.user.orgID} - - - UNION - SELECT 'default/default' AS OGDP_CD - , CONCAT('기본 시군구',' / ','기본 기관', ' : ', '기본 부서') AS OGDP_NM - , 'default' AS INST_CD - , '기본 기관' AS INST_NM - , 'default' AS DEPT_CD - , '기본 부서' AS DEPT_NM - , 'default' AS SGG_CD - , '기본 시군구' AS SGG_NM - FROM DUAL - - - - """+SQLUtil.SCRIPT_END) - List selectAbleOgdpList(Map params); @Select(SQLUtil.SCRIPT_START+""" diff --git a/src/main/java/cokr/xit/fims/base/service/bean/OgdpBean.java b/src/main/java/cokr/xit/fims/base/service/bean/OgdpBean.java index 8e01a198..95ba7941 100644 --- a/src/main/java/cokr/xit/fims/base/service/bean/OgdpBean.java +++ b/src/main/java/cokr/xit/fims/base/service/bean/OgdpBean.java @@ -1,6 +1,7 @@ package cokr.xit.fims.base.service.bean; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -8,7 +9,11 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; +import cokr.xit.base.user.DepartmentQuery; +import cokr.xit.base.user.SigunguQuery; import cokr.xit.base.user.dao.UserMapper; +import cokr.xit.base.user.service.bean.DepartmentBean; +import cokr.xit.base.user.service.bean.SigunguBean; import cokr.xit.fims.base.FimsDepartment; import cokr.xit.fims.base.FimsSigungu; import cokr.xit.fims.base.OgdpQuery; @@ -21,7 +26,11 @@ import cokr.xit.foundation.data.DataObject; @Component("ogdpBean") public class OgdpBean extends AbstractBean { + @Resource(name="sigunguBean") + private SigunguBean sigunguBean; + @Resource(name="departmentBean") + private DepartmentBean departmentBean; @Resource(name="ogdpMapper") private OgdpMapper ogdpMapper; @@ -31,11 +40,75 @@ public class OgdpBean extends AbstractBean { public Object selectAllOgdpList() { - return ogdpMapper.selectAllOgdpList(); + List ogdpList = new ArrayList<>(); + List sggs = sigunguBean.getSigunguList(new SigunguQuery()); + for(DataObject sgg : sggs) { + List depts = departmentBean.getDepartmentList(new DepartmentQuery().setSggID(sgg.string("SGG_CD"))); + for(DataObject dept : depts) { + DataObject ogdp = new DataObject(); + ogdp.put("SGG_CD", sgg.string("SGG_CD")); + ogdp.put("SGG_NM", sgg.string("SGG_NM")); + ogdp.put("INST_CD", sgg.string("INST_CD")); + ogdp.put("INST_NM", sgg.string("INST_NM")); + ogdp.put("DEPT_CD", dept.string("DEPT_CD")); + ogdp.put("DEPT_NM", dept.string("DEPT_NM")); + ogdp.put("OGDP_CD", sgg.string("INST_CD") + "/" + dept.string("DEPT_CD")); + ogdp.put("OGDP_NM", sgg.string("SGG_NM") + " / " + sgg.string("INST_NM") + " : " + dept.string("DEPT_NM")); + ogdpList.add(ogdp); + } + } + DataObject sysAdmin = new DataObject(); + sysAdmin.put("SGG_CD", "default"); + sysAdmin.put("SGG_NM", "기본 시군구"); + sysAdmin.put("INST_CD", "default"); + sysAdmin.put("INST_NM", "기본 기관"); + sysAdmin.put("DEPT_CD", "default"); + sysAdmin.put("DEPT_NM", "기본 부서"); + sysAdmin.put("OGDP_CD", "default/default"); + sysAdmin.put("OGDP_NM", "기본 시군구 / 기본 기관 : 기본 부서"); + ogdpList.add(sysAdmin); + + return ogdpList; } - public List selectAbleOgdpList(DataObject params) { - return ogdpMapper.selectAbleOgdpList(params); + public List selectAbleOgdpList(boolean anonymous, String sggCd) { + List ogdpList = new ArrayList<>(); + SigunguQuery sggQuery = new SigunguQuery(); + if(anonymous) { + sggQuery.setSggIDs(sggCd); + } else if(!currentUser().getInstitute().equals("default")){ + sggQuery.setSggIDs(currentUser().getOrgID()); + } + List sggs = sigunguBean.getSigunguList(sggQuery); + for(DataObject sgg : sggs) { + List depts = departmentBean.getDepartmentList(new DepartmentQuery().setSggID(sgg.string("SGG_CD"))); + for(DataObject dept : depts) { + DataObject ogdp = new DataObject(); + ogdp.put("SGG_CD", sgg.string("SGG_CD")); + ogdp.put("SGG_NM", sgg.string("SGG_NM")); + ogdp.put("INST_CD", sgg.string("INST_CD")); + ogdp.put("INST_NM", sgg.string("INST_NM")); + ogdp.put("DEPT_CD", dept.string("DEPT_CD")); + ogdp.put("DEPT_NM", dept.string("DEPT_NM")); + ogdp.put("OGDP_CD", sgg.string("INST_CD") + "/" + dept.string("DEPT_CD")); + ogdp.put("OGDP_NM", sgg.string("SGG_NM") + " / " + sgg.string("INST_NM") + " : " + dept.string("DEPT_NM")); + ogdpList.add(ogdp); + } + } + + if(!anonymous && currentUser().getInstitute().equals("default")) { + DataObject sysAdmin = new DataObject(); + sysAdmin.put("SGG_CD", "default"); + sysAdmin.put("SGG_NM", "기본 시군구"); + sysAdmin.put("INST_CD", "default"); + sysAdmin.put("INST_NM", "기본 기관"); + sysAdmin.put("DEPT_CD", "default"); + sysAdmin.put("DEPT_NM", "기본 부서"); + sysAdmin.put("OGDP_CD", "default/default"); + sysAdmin.put("OGDP_NM", "기본 시군구 / 기본 기관 : 기본 부서"); + ogdpList.add(sysAdmin); + } + return ogdpList; } public int countUser(String sggCd) { diff --git a/src/main/java/cokr/xit/fims/base/web/MainController.java b/src/main/java/cokr/xit/fims/base/web/MainController.java index 63aabf53..e94843e9 100644 --- a/src/main/java/cokr/xit/fims/base/web/MainController.java +++ b/src/main/java/cokr/xit/fims/base/web/MainController.java @@ -105,10 +105,7 @@ public class MainController extends cokr.xit.base.web.MainController { mav.addObject("allOgdpList", ogdpBean.selectAllOgdpList()); - DataObject params = new DataObject(); - params.set("anonymous", "Y"); - params.set("sggCd", sggCd); - List ableOgdpList = ogdpBean.selectAbleOgdpList(params); + List ableOgdpList = ogdpBean.selectAbleOgdpList(true, sggCd); mav.addObject("ableOgdpList", ableOgdpList); mav.addObject("userInfo", "{}"); diff --git a/src/main/java/cokr/xit/fims/base/web/UserController.java b/src/main/java/cokr/xit/fims/base/web/UserController.java index 6bab1561..d6c7bea3 100644 --- a/src/main/java/cokr/xit/fims/base/web/UserController.java +++ b/src/main/java/cokr/xit/fims/base/web/UserController.java @@ -57,8 +57,7 @@ public class UserController extends cokr.xit.base.user.web.UserController ableOgdpList = ogdpBean.selectAbleOgdpList(params); + List ableOgdpList = ogdpBean.selectAbleOgdpList(false, currentUser().getOrgID()); mav.addObject("ableOgdpList", ableOgdpList); return mav; @@ -119,8 +118,8 @@ public class UserController extends cokr.xit.base.user.web.UserController ableOgdpList = ogdpBean.selectAbleOgdpList(params); + + List ableOgdpList = ogdpBean.selectAbleOgdpList(false, currentUser().getOrgID()); mav.addObject("ableOgdpList", ableOgdpList); return mav;