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

450 lines
14 KiB
XML
Raw Normal View History

2022-09-28 07:56:31 +00:00
<?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.fipTarget.mapper.FipTargetMapper">
<select id="selectPartInfoManagerList" resultType="com.dbnt.faisp.util.ParamMap" parameterType="com.dbnt.faisp.util.ParamMap">
select user_seq,
user_id
user_name
from user_info
where og_cd in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by user_nm asc
</select>
<select id="selectPartInfoList" resultType="PartInfo" parameterType="PartInfo">
select pi.pi_seq,
version_no,
(select item_value from code_mgt where item_cd = mgt_organ) as mgt_organ,
land_police,
(select item_value from code_mgt where item_cd = mp_work_type) as mp_work_type,
mp_people_cnt,
mp_description,
(select item_value from code_mgt where item_cd = pl_work_type) as pl_work_type,
pl_people_cnt,
pl_description,
(select user_nm from user_info where user_seq = pi_user_seq ) as pi_manager_name,
2022-09-29 08:55:12 +00:00
terminal_nm,
2022-09-28 07:56:31 +00:00
rent_type,
rent_price,
utility_type,
utility_price,
wrt_dt
from part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
2022-10-05 05:25:34 +00:00
and mgt_organ in
2022-09-28 07:56:31 +00:00
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
2022-09-29 08:55:12 +00:00
<if test='mgtOrgan != null and mgtOrgan != ""'>
and mgt_organ = #{mgtOrgan}
</if>
<if test='landPolice != null and landPolice != ""'>
and land_police LIKE CONCAT('%', #{landPolice}, '%')
</if>
<if test='mpWorkType != null and mpWorkType != ""'>
and mp_work_type = #{mpWorkType}
</if>
<if test='plWorkType != null and plWorkType != ""'>
and pl_work_type = #{plWorkType}
</if>
<if test='terminalNm != null and terminalNm != ""'>
and terminal_nm LIKE CONCAT('%', #{terminalNm}, '%')
</if>
<if test='startDate != null and startDate != ""'>
and to_char(wrt_dt, 'YYYY-MM-DD') = #{startDate}
</if>
2022-09-28 07:56:31 +00:00
order by wrt_dt desc
<if test='excel != "Y"'>
2022-09-29 08:55:12 +00:00
limit #{rowCnt} offset #{firstIndex}
</if>
2022-09-28 07:56:31 +00:00
</select>
<select id="selectPartInfoListCnt" resultType="int" parameterType="PartInfo">
select count(*)
from(
select pi.pi_seq,
version_no,
mgt_organ,
land_police,
mp_work_type,
mp_people_cnt,
mp_description,
pl_work_type,
pl_people_cnt,
pl_description,
(select user_nm from user_info where user_seq = pi_user_seq ) as pi_manager_name,
2022-09-29 08:55:12 +00:00
terminal_nm,
2022-09-28 07:56:31 +00:00
rent_type,
rent_price,
utility_type,
utility_price,
wrt_dt
from part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
2022-10-05 05:25:34 +00:00
and mgt_organ in
2022-09-28 07:56:31 +00:00
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
2022-09-29 08:55:12 +00:00
<if test='mgtOrgan != null and mgtOrgan != ""'>
and mgt_organ = #{mgtOrgan}
</if>
<if test='landPolice != null and landPolice != ""'>
and land_police LIKE CONCAT('%', #{landPolice}, '%')
</if>
<if test='mpWorkType != null and mpWorkType != ""'>
and mp_work_type = #{mpWorkType}
</if>
<if test='plWorkType != null and plWorkType != ""'>
and pl_work_type = #{plWorkType}
</if>
<if test='terminalNm != null and terminalNm != ""'>
and terminal_nm LIKE CONCAT('%', #{terminalNm}, '%')
</if>
<if test='startDate != null and startDate != ""'>
and to_char(wrt_dt, 'YYYY-MM-DD') = #{startDate}
</if>
2022-09-28 07:56:31 +00:00
order by wrt_dt desc
) a
</select>
2022-09-29 08:55:12 +00:00
<select id="selectWorkTypeTotal" resultType="com.dbnt.faisp.util.ParamMap" parameterType="PartInfo">
select sum(mp_sangju) as mp_sangju,
sum(mp_sangju_cnt) as mp_sangju_total,
sum(mp_bsangju) as mp_bsangju,
sum(mp_bsangju_cnt) as mp_bsangju_total,
sum(mp_closure) as mp_closure,
sum(mp_closure_cnt) as mp_closure_total,
sum(pl_sangju) as pl_sangju,
sum(pl_sangju_cnt) as pl_sangju_total,
sum(pl_bsangju) as pl_bsangju,
sum(pl_bsangju_cnt) as pl_bsangju_total,
sum(pl_closure) as pl_closure,
sum(pl_closure_cnt) as pl_closure_total
from(
select case
when mp_work_type = 'PIS001' then coalesce(mp_people_cnt,0)
else 0
end as mp_sangju_cnt,
case
when mp_work_type = 'PIS002' then coalesce(mp_people_cnt,0)
else 0
end as mp_bsangju_cnt,
case
when mp_work_type = 'PIS003' then coalesce(mp_people_cnt,0)
else 0
end as mp_closure_cnt,
case
when pl_work_type = 'PIS001' then coalesce(pl_people_cnt,0)
else 0
end as pl_sangju_cnt,
case
when pl_work_type = 'PIS002' then coalesce(pl_people_cnt,0)
else 0
end as pl_bsangju_cnt,
case
when pl_work_type = 'PIS003' then coalesce(pl_people_cnt,0)
else 0
end as pl_closure_cnt,
case
when mp_work_type = 'PIS001' then 1
else 0
end as mp_sangju,
case
when mp_work_type = 'PIS002' then 1
else 0
end as mp_bsangju,
case
when mp_work_type = 'PIS003' then 1
else 0
end as mp_closure,
case
when pl_work_type = 'PIS001' then 1
else 0
end as pl_sangju,
case
when pl_work_type = 'PIS002' then 1
else 0
end as pl_bsangju,
case
when pl_work_type = 'PIS003' then 1
else 0
end as pl_closure
from part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
2022-10-05 05:25:34 +00:00
and mgt_organ in
2022-09-29 08:55:12 +00:00
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
<if test='mgtOrgan != null and mgtOrgan != ""'>
and mgt_organ = #{mgtOrgan}
</if>
<if test='landPolice != null and landPolice != ""'>
and land_police LIKE CONCAT('%', #{landPolice}, '%')
</if>
<if test='mpWorkType != null and mpWorkType != ""'>
and mp_work_type = #{mpWorkType}
</if>
<if test='plWorkType != null and plWorkType != ""'>
and pl_work_type = #{plWorkType}
</if>
<if test='terminalNm != null and terminalNm != ""'>
and terminal_nm LIKE CONCAT('%', #{terminalNm}, '%')
</if>
<if test='startDate != null and startDate != ""'>
and to_char(wrt_dt, 'YYYY-MM-DD') = #{startDate}
</if>
group by pi.pi_seq, version_no
) a
</select>
<select id="selectPartInfo" resultType="PartInfo" parameterType="PartInfo">
select pi.pi_seq,
version_no,
mgt_organ,
land_police,
mp_work_type,
mp_people_cnt,
mp_description,
pl_work_type,
pl_people_cnt,
pl_description,
pi_user_seq,
(select user_nm from user_info where user_seq = pi_user_seq ) as pi_manager_name,
terminal_nm,
rent_type,
rent_price,
utility_type,
utility_price,
wrt_dt
from part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and pi.pi_seq = #{piSeq}
</select>
<select id="selectPartInfoFile" resultType="PartInfoFile" parameterType="PartInfo">
select file_seq,
pif.pi_seq,
version_no,
orig_nm,
conv_nm,
file_extn,
file_size,
file_path
from part_info_file pif,
(select pi_seq,max(version_no) as lastVer
from part_info_file group by pi_seq) b
where pif.pi_seq = b.pi_seq
and pif.version_no = b.lastVer
and pif.pi_seq = #{piSeq}
</select>
<select id="selectPartInfoSeq" resultType="PartInfo" parameterType="PartInfo">
select pi_seq,
version_no,
wrt_nm,
wrt_dt
from part_info
where pi_seq = #{piSeq}
order by version_no desc
</select>
<select id="selectPartInfoHistoryView" resultType="PartInfo" parameterType="PartInfo">
select pi_seq,
version_no,
(select item_value from code_mgt where item_cd = mgt_organ) as mgt_organ,
land_police,
(select item_value from code_mgt where item_cd = mp_work_type) as mp_work_type,
mp_people_cnt,
mp_description,
(select item_value from code_mgt where item_cd = pl_work_type) as pl_work_type,
pl_people_cnt,
pl_description,
pi_user_seq,
(select user_nm from user_info where user_seq = pi_user_seq ) as pi_manager_name,
terminal_nm,
case
when rent_type = 'Y' then '유상'
when rent_type = 'N' then '무상'
else null
end as rent_type,
rent_price,
case
when utility_type = 'Y' then '유상'
when utility_type = 'N' then '무상'
else null
end as utility_type,
utility_price,
wrt_dt
from part_info
where pi_seq = #{piSeq}
and version_no = #{versionNo}
</select>
<select id="selectPartInfoFileHistoryView" resultType="PartInfoFile" parameterType="PartInfo">
select file_seq,
pi_seq,
version_no,
orig_nm,
conv_nm,
file_extn,
file_size,
file_path
from part_info_file
where pi_seq = #{piSeq}
and version_no = #{versionNo}
</select>
2022-10-05 05:25:34 +00:00
<select id="selectPartInfoFirstId" resultType="String" parameterType="int">
select wrt_nm
from part_info
where pi_seq = #{piSeq}
order by version_no asc
limit 1
</select>
<select id="selectTerminalName" resultType="com.dbnt.faisp.util.ParamMap" parameterType="PartWork">
select pi.pi_seq,
terminal_nm
from part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by terminal_nm asc
</select>
<select id="selectPartWorkList" resultType="PartWork" parameterType="PartWork">
select pw.pw_seq,
pw.pi_seq ,
pi.terminal_nm,
pw.wrt_nm,
pw.work_dt,
pw.save_yn,
work_type,
case
when pw.work_type = 'CH' then 'O'
end as work_type_ch,
case
when pw.work_type = 'POCI' then 'O'
end as work_type_poci,
case
when pw.work_type = 'SRI' then 'O'
end as work_type_sri,
case
when pw.work_type = 'JI' then 'O'
end as work_type_ji,
case
when pw.work_type = 'MT' then 'O'
end as work_type_mt,
case
when pw.work_type = 'ETC' then 'O'
end as work_type_etc,
pw.description,
(select count(*) from part_work_file pwf where pw.pw_seq = pwf.pw_seq and pw.pi_seq = pwf.pi_seq) as file_cnt,
pw.wrt_dt
from part_work pw,
part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pw.pi_seq = pi.pi_seq
and pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and pi.mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by wrt_dt desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectPartWorkListCnt" resultType="int" parameterType="PartWork">
select count(*)
from(
select pw.pw_seq,
pw.pi_seq ,
pi.terminal_nm,
pw.wrt_nm,
pw.work_dt,
pw.save_yn,
work_type,
case
when pw.work_type = 'CH' then 'O'
end as work_type_ch,
case
when pw.work_type = 'POCI' then 'O'
end as work_type_poci,
case
when pw.work_type = 'SRI' then 'O'
end as work_type_sri,
case
when pw.work_type = 'JI' then 'O'
end as work_type_ji,
case
when pw.work_type = 'MT' then 'O'
end as work_type_mt,
case
when pw.work_type = 'ETC' then 'O'
end as work_type_etc,
pw.description,
(select count(*) from part_work_file pwf where pw.pw_seq = pwf.pw_seq and pw.pi_seq = pwf.pi_seq) as file_cnt,
pw.wrt_dt
from part_work pw,
part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pw.pi_seq = pi.pi_seq
and pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and pi.mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by wrt_dt desc
) a
</select>
<select id="selectPartWorkInfo" resultType="PartWork" parameterType="PartWork">
select pw.pw_seq,
pw.pi_seq ,
pi.terminal_nm,
pw.wrt_nm,
pw.work_dt,
pw.save_yn,
pw.work_info,
work_type,
pw.description,
pw.wrt_dt
from part_work pw,
part_info pi,
(select pi_seq,max(version_no) as lastVer
from part_info group by pi_seq) b
where pw.pi_seq = pi.pi_seq
and pi.pi_seq = b.pi_seq
and pi.version_no = b.lastVer
and pw.pw_seq = #{pwSeq}
and pw.pi_seq = #{piSeq}
</select>
2022-09-28 07:56:31 +00:00
</mapper>