FAISP/src/main/resources/mybatisMapper/UserInfoMapper.xml

539 lines
18 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dbnt.faisp.main.userInfo.mapper.UserInfoMapper">
<sql id="selectUserInfoWhere">
<where>
<choose>
<when test='userStatus != null and userStatus != ""'>
user_status = #{userStatus}
</when>
<otherwise>
user_status = 'USC003'
</otherwise>
</choose>
<if test='userId != null and userId != ""'>
and user_id like '%'||#{userId}||'%'
</if>
<if test='userNm != null and userNm != ""'>
and user_nm like '%'||#{userNm}||'%'
</if>
<if test='ogCd != null and ogCd != ""'>
and og_cd = #{ogCd}
</if>
<if test='ofcCd != null and ofcCd != ""'>
and ofc_cd = #{ofcCd}
</if>
<if test='titleCd != null and titleCd != ""'>
and title_cd = #{titleCd}
</if>
<if test='userRole == "ROLE_ADMIN,ROLE_SUB_ADMIN,ROLE_USER"'>
and user_role like '%ROLE_USER'
</if>
<if test='userRole == "ROLE_SUB_ADMIN,ROLE_USER"'>
and (user_role = 'ROLE_SUB_ADMIN,ROLE_USER' or user_role = 'ROLE_USER')
</if>
<if test="downOrganCdList != null">
and og_cd in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
</where>
</sql>
<select id="selectUserInfoList" resultType="UserInfo" parameterType="UserInfo">
select user_seq,
dic_code,
user_id,
user_nm,
user_role,
email,
og_cd,
ofc_cd,
title_cd,
wrt_dt
from user_info
<include refid="selectUserInfoWhere"></include>
order by og_cd, ofc_cd, title_cd desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectUserInfoListCnt" resultType="int" parameterType="UserInfo">
select count(*)
from user_info
<include refid="selectUserInfoWhere"></include>
</select>
<select id="selectManagerList" resultType="com.dbnt.faisp.util.ParamMap" parameterType="com.dbnt.faisp.util.ParamMap">
select user_seq,
user_id,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
user_nm
from user_info
where og_cd = #{ogCd}
and user_status = 'USC003'
order by user_nm asc
</select>
<select id="selectDashboardConfigList" resultType="DashboardConfig" parameterType="int">
select a.menu_key ,
a.cat1_cd ,
a.cat2_cd ,
a.cat3_cd ,
a.menu_url ,
b.order_num
from menu_mgt a
inner join dashboard_config b
on a.menu_key = b.menu_key
where b.user_seq = #{userSeq}
order by b.order_num
</select>
<sql id="selectPoliceListWhere">
<where>
user_status = #{userStatus}
and og_cd in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
<if test="ogCd != null and ogCd != ''">
and og_cd = #{ogCd}
</if>
<if test="sex != null and sex != ''">
and sex = #{sex}
</if>
<if test="userNm != null and userNm != ''">
and user_nm like '%'||#{userNm}||'%'
</if>
</where>
</sql>
<select id="selectPoliceList" resultType="UserInfo" parameterType="UserInfo">
select (ROW_NUMBER() OVER(order by user_nm desc)) AS rownum,
a.user_seq,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
user_nm,
og_cd,
(select item_value from code_mgt where item_cd = og_cd) as organ_nm,
(select item_value from code_mgt where item_cd = ofc_cd) as ofc_cd,
birth_date,
(select item_value from code_mgt where item_cd = sex) as sex,
police_in_date,
title_in_date,
ofc_in_date,
duty_cd,
(select item_value from code_mgt where item_cd = outturn_cd) as outturn_cd,
(select item_value from code_mgt where item_cd = job_in_cd) as job_in_cd,
wrt_dt,
b.crc001Sum,
b.crc002Sum,
b.crc003Sum,
b.crc004Sum,
b.crc005Sum,
b.crc006Sum,
b.lastCareerWrtDt
from user_info a
left outer join (
select user_seq,
sum(case when career_cd = 'CRC001' then work_month else 0 end) as crc001Sum,
sum(case when career_cd = 'CRC002' then work_month else 0 end) as crc002Sum,
sum(case when career_cd = 'CRC003' then work_month else 0 end) as crc003Sum,
sum(case when career_cd = 'CRC004' then work_month else 0 end) as crc004Sum,
sum(case when career_cd = 'CRC005' then work_month else 0 end) as crc005Sum,
sum(case when career_cd = 'CRC006' then work_month else 0 end) as crc006Sum,
max(wrt_dt) as lastCareerWrtDt
from (
select user_seq,
career_seq,
career_cd,
coalesce(work_month, (EXTRACT(YEAR FROM AGE(now()::date, start_date)) * 12 + EXTRACT(MONTH FROM AGE(now()::date, start_date)))) as work_month,
wrt_dt
from user_career ) aa
group by user_seq
) b on a.user_seq = b.user_seq
<include refid="selectPoliceListWhere"></include>
order by rownum desc
<if test='excel != "Y"'>
limit #{rowCnt} offset #{firstIndex}
</if>
</select>
<select id="selectPoliceListCnt" resultType="Integer" parameterType="UserInfo">
select count(*)
from(
select user_seq,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
user_nm,
og_cd,
(select item_value from code_mgt where item_cd = og_cd) as organ_nm,
(select item_value from code_mgt where item_cd = ofc_cd) as ofc_cd,
birth_date,
(select item_value from code_mgt where item_cd = sex) as sex,
police_in_date,
title_in_date,
ofc_in_date,
(select item_value from code_mgt where item_cd = outturn_cd) as outturn_cd,
(select item_value from code_mgt where item_cd = job_in_cd) as job_in_cd,
wrt_dt
from user_info
<include refid="selectPoliceListWhere"></include>
order by user_seq desc
) a
</select>
<select id="selectPoliceEducationList" resultType="UserInfo" parameterType="UserInfo">
select (ROW_NUMBER() OVER(order by user_nm desc)) AS rownum,
a.user_seq,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
user_nm,
og_cd,
(select item_value from code_mgt where item_cd = og_cd) as organ_nm,
(select item_value from code_mgt where item_cd = ofc_cd) as ofc_cd,
birth_date,
(select item_value from code_mgt where item_cd = sex) as sex,
police_in_date,
title_in_date,
ofc_in_date,
duty_cd,
(select item_value from code_mgt where item_cd = outturn_cd) as outturn_cd,
(select item_value from code_mgt where item_cd = job_in_cd) as job_in_cd,
wrt_dt,
b.lastEduWrtDt,
c.edu_name,
c.edu_sdate,
c.edu_edate,
c.edu_ra
from user_info a
left outer join (
select user_seq,
max(wrt_dt) as lastEduWrtDt
from user_edu
group by user_seq
) b on a.user_seq = b.user_seq
left outer join (
select aa.user_seq,
aa.edu_seq,
aa.edu_name,
aa.edu_sdate,
aa.edu_edate,
aa.edu_ra
from user_edu aa inner join (select user_seq, max(edu_edate) as edu_edate from user_edu group by user_seq) ab
on aa.user_seq = ab.user_seq and aa.edu_edate = ab.edu_edate
) c on a.user_seq = c.user_seq
<include refid="selectPoliceListWhere"></include>
order by rownum desc
<if test='excel != "Y"'>
limit #{rowCnt} offset #{firstIndex}
</if>
</select>
<select id="selectPoliceEducationListCnt" resultType="Integer" parameterType="UserInfo">
select count(*)
from(
select (ROW_NUMBER() OVER(order by user_nm desc)) AS rownum,
a.user_seq,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
user_nm,
og_cd,
(select item_value from code_mgt where item_cd = og_cd) as organ_nm,
(select item_value from code_mgt where item_cd = ofc_cd) as ofc_cd,
birth_date,
(select item_value from code_mgt where item_cd = sex) as sex,
police_in_date,
title_in_date,
ofc_in_date,
duty_cd,
(select item_value from code_mgt where item_cd = outturn_cd) as outturn_cd,
(select item_value from code_mgt where item_cd = job_in_cd) as job_in_cd,
wrt_dt,
b.lastEduWrtDt,
c.edu_name,
c.edu_sdate,
c.edu_edate,
c.edu_ra
from user_info a
left outer join (
select user_seq,
max(wrt_dt) as lastEduWrtDt
from user_edu
group by user_seq
) b on a.user_seq = b.user_seq
left outer join (
select aa.user_seq,
aa.edu_seq,
aa.edu_name,
aa.edu_sdate,
aa.edu_edate,
aa.edu_ra
from user_edu aa inner join (select user_seq, max(edu_edate) as edu_edate from user_edu group by user_seq) ab
on aa.user_seq = ab.user_seq and aa.edu_edate = ab.edu_edate
) c on a.user_seq = c.user_seq
<include refid="selectPoliceListWhere"></include>
order by rownum desc
)d
</select>
<select id="selectPoliceHisList" resultType="UserInfoHistory" parameterType="UserInfoHistory">
select user_seq,
version_no,
(select item_value from code_mgt where item_cd = wrt_organ) as wrt_organ,
(select item_value from code_mgt where item_cd = wrt_part) as wrt_part,
(select item_value from code_mgt where item_cd = wrt_title) as wrt_title,
wrt_nm,
wrt_dt
from user_info_history
where user_seq = #{userSeq}
order by version_no desc
</select>
<select id="selectPersonnelStatusList" parameterType="PersonnelStatus" resultType="PersonnelStatus">
select
case
when a.year is null then #{year}
else a.year
end as year,
case
when a.og_cd is null then c.organ_cd
else a.og_cd
end as og_cd,
a.version_no,
jt007_max,
jt007_now,
jt006_max,
jt006_now,
jt005_max,
jt005_now,
jt004_max,
jt004_now,
jt003_max,
jt003_now,
jt002_max,
jt002_now,
jt001_max,
jt001_now,
wrt_organ,
wrt_part,
wrt_user_seq,
wrt_user_grd,
wrt_user_nm,
wrt_dt
from personnel_status a
inner join (select year, og_cd, max(version_no) as version_no
from personnel_status
group by year, og_cd) b
on a.year = b.year and a.og_cd = b.og_cd and a.version_no = b.version_no
right outer join organ_config c
on a.og_cd = c.organ_cd and a.year = #{year}
where c.organ_cd in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by c.organ_type, c.parent_organ, c.organ_cd
</select>
<select id="nowPersonnelStatus" resultType="PersonnelStatus" parameterType="string">
select a.og_cd,
sum(case
when a.title_cd = 'JT001' then 1
else 0
end) as jt001Now,
sum(case
when a.title_cd = 'JT002' then 1
else 0
end) as jt002Now,
sum(case
when a.title_cd = 'JT003' then 1
else 0
end) as jt003Now,
sum(case
when a.title_cd = 'JT004' then 1
else 0
end) as jt004Now,
sum(case
when a.title_cd = 'JT005' then 1
else 0
end) as jt005Now,
sum(case
when a.title_cd = 'JT006' then 1
else 0
end) as jt006Now,
sum(case
when a.title_cd = 'JT007' then 1
else 0
end) as jt007Now
from user_info a
where a.user_status = 'USC003'
and a.og_cd = #{ogCd}
group by a.og_cd
order by a.og_cd
</select>
<select id="selectPoliceInfo" resultType="UserInfo" parameterType="Integer">
select user_seq,
user_nm,
dic_code,
(select item_value from code_mgt where item_cd = title_cd) as title_cd,
(select item_value from code_mgt where item_cd = og_cd) as og_cd,
(select item_value from code_mgt where item_cd = ofc_cd) as ofc_cd,
(select item_value from code_mgt where item_cd = sex) as sex,
birth_date,
(select item_value from code_mgt where item_cd = language_cd) as language_cd
from user_info
where user_seq = #{userSeq}
</select>
<select id="selectEduList" resultType="UserEdu" parameterType="UserEdu">
select edu_seq,
user_seq,
edu_name,
edu_sdate,
edu_edate,
edu_ra,
(select item_value from code_mgt where item_cd = wrt_organ) as wrt_organ,
(select item_value from code_mgt where item_cd = wrt_part) as wrt_part,
(select item_value from code_mgt where item_cd = wrt_title) as wrt_title,
wrt_user_seq,
wrt_nm,
wrt_dt
from user_edu
where user_seq = #{userSeq}
order by edu_seq desc
</select>
<sql id="selectRequestLogListWhere">
<where>
user_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
<if test='contactIp != null and contactIp != ""'>
and contact_ip like '%'||#{contactIp}||'%'
</if>
<if test='requestUrl != null and requestUrl != ""'>
and request_url like '%'||#{requestUrl}||'%'
</if>
<if test='requestMethod != null and requestMethod != ""'>
and request_method = #{requestMethod}
</if>
<if test='userBelong != null and userBelong != ""'>
and user_belong like '%'||#{userBelong}||'%'
</if>
<if test='startDate != null and startDate != ""'>
and wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and wrt_dt &lt;= #{endDate}::date+1
</if>
</where>
</sql>
<select id="selectRequestLogList" resultType="UserRequestLog" parameterType="UserRequestLog">
select *
from user_request_log
<include refid="selectRequestLogListWhere"></include>
order by ul_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectRequestLogListCnt" resultType="int" parameterType="UserRequestLog">
select count(*)
from user_request_log
<include refid="selectRequestLogListWhere"></include>
</select>
<sql id="selectInoutLogListWhere">
<where>
user_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
<if test='contactIp != null and contactIp != ""'>
and contact_ip like '%'||#{contactIp}||'%'
</if>
<if test='inoutType != null and inoutType != ""'>
and inout_type = #{inoutType}
</if>
<if test='userBelong != null and userBelong != ""'>
and user_belong like '%'||#{userBelong}||'%'
</if>
<if test='startDate != null and startDate != ""'>
and wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and wrt_dt &lt;= #{endDate}::date+1
</if>
</where>
</sql>
<select id="selectInoutLogList" resultType="UserInoutLog" parameterType="UserInoutLog">
select *
from user_inout_log
<include refid="selectInoutLogListWhere"></include>
order by inout_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectInoutLogListCnt" resultType="int" parameterType="UserInoutLog">
select count(*)
from user_inout_log
<include refid="selectInoutLogListWhere"></include>
</select>
<sql id="selectAlarmListWhere">
<where>
<if test='userSeq != null and userSeq != 0'>
and a.user_seq = #{userSeq}
</if>
<if test='viewYn != null and viewYn != ""'>
and a.view_yn = #{viewYn}
</if>
<if test='cat1Cd != null and cat1Cd != ""'>
and b.cat1_cd = #{cat1Cd}
</if>
<if test='cat2Cd != null and cat2Cd != ""'>
and b.cat2_cd = #{cat2Cd}
</if>
<if test='cat3Cd != null and cat3Cd != ""'>
and b.cat3_cd = #{cat3Cd}
</if>
<if test='alarmMsg != null and alarmMsg != ""'>
and a.alarm_msg like '%'||#{alarmMsg}||'%'
</if>
<if test='startDate != null and startDate != ""'>
And a.wrt_dt >= #{startDate}::DATE
</if>
<if test='endDate != null and endDate != ""'>
AND a.wrt_dt &lt;= #{endDate}::DATE+1
</if>
</where>
</sql>
<select id="selectAlarmList" resultType="UserAlarm" parameterType="UserAlarm">
select a.alarm_key ,
a.user_seq ,
a.menu_key ,
a.ref_doc_key ,
b.cat1_cd,
b.cat2_cd,
b.cat3_cd,
a.alarm_msg ,
a.view_yn ,
a.wrt_dt
from user_alarm a
inner join menu_mgt b on a.menu_key = b.menu_key
<include refid="selectAlarmListWhere"></include>
order by wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectAlarmListCnt" resultType="int" parameterType="UserAlarm">
select count(*)
from user_alarm a
inner join menu_mgt b on a.menu_key = b.menu_key
<include refid="selectAlarmListWhere"></include>
</select>
<select id="selectUserInfo" resultType="Integer" parameterType="UserInfo">
select user_seq
from user_info
where dic_code = #{dicCode}
and user_id = #{userId}
and user_nm = #{userNm}
and phone_no = #{phoneNo}
</select>
</mapper>