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

403 lines
12 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.fpiMgt.intelligenceNetwork.mapper.IntelligenceNetworkMapper">
<sql id="selectOperationPlanListWhere">
<where>
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
and op.wrt_user_seq = #{wrtUserSeq}
</if>
<if test='opName != null and opName != ""'>
and op.op_name like '%'||#{opName}||'%'
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
and op.wrt_organ = #{wrtOrgan}
</if>
<if test='opState != null and opState != ""'>
and op.op_state = #{opState}
</if>
<if test='startDate != null and startDate != ""'>
and op.wrt_dt >= #{startDate}::date
</if>
<if test='endDate != null and endDate != ""'>
and op.wrt_dt &lt;= #{endDate}::date+1
</if>
<if test="downOrganCdList != null">
and op.wrt_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
<if test='userType != null and userType != ""'>
<if test='userType == "normalStayList"'>
and op_state in ('DST002')
</if>
<if test='userType == "normalCommitList"'>
and op_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "sectionCommitList"'>
and op_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "managerStayList"'>
and op_state in ('DST002')
</if>
<if test='userType == "managerCommitList"'>
and op_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
</if>
</where>
</sql>
<select id="selectOperationPlanList" resultType="OperationPlan" parameterType="OperationPlan">
select op.op_key,
op_name,
op_birth,
op_position,
op_phone,
op_rank,
op_state as status,
(select item_value from code_mgt where item_cd = op_state) as op_state,
wrt_user_seq,
(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_user_grd) as wrt_user_grd,
wrt_user_nm,
wrt_dt,
b.fileCnt
from operation_plan op
left outer join (select op_key,
count(file_seq) as fileCnt
from operation_plan_file
group by op_key) b
on op.op_key = b.op_key
<include refid="selectOperationPlanListWhere"></include>
order by op.op_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectOperationPlanListCnt" resultType="Integer" parameterType="OperationPlan">
select count(*)
from operation_plan op
<include refid="selectOperationPlanListWhere"></include>
</select>
<select id="selectAffairCnt" resultType="IntelligenceAnalyze" parameterType="IntelligenceAnalyze">
select sum("AAR001"+"AAR003"+"AAR004"+"AAR006"+"AAR008") as total_cnt,
sum("AAR001") as special_cnt,
sum("AAR003") as middle_cnt,
sum("AAR004") as tong_cnt,
sum("AAR006") as jo_cnt,
sum("AAR008") as mu_cnt
from(
select ab.affair_key,
case
when ar.affair_rate = 'AAR001' then 1
else 0
end as "AAR001",
case
when ar.affair_rate = 'AAR003' then 1
else 0
end as "AAR003",
case
when ar.affair_rate = 'AAR004' then 1
else 0
end as "AAR004",
case
when ar.affair_rate = 'AAR006' then 1
else 0
end as "AAR006",
case
when ar.affair_rate = 'AAR008' then 1
else 0
end as "AAR008"
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and ab.affair_category = 'CAT216'
and ab.affair_key in
<foreach collection="affairList" item="affairKey" separator="," open="(" close=")">
#{affairKey}
</foreach>
and (ar.organ_up != 'T' or ar.organ_up is null)
) a
</select>
<sql id="selectIntelligenceAnalyzeListWhere">
<where>
<if test='wrtUserSeq != null and wrtUserSeq != ""'>
and wrt_user_seq = #{wrtUserSeq}
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
and wrt_organ = #{wrtOrgan}
</if>
<if test='iaState != null and iaState != ""'>
and ia_state = #{iaState}
</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>
<if test="downOrganCdList != null">
and wrt_organ in
<foreach collection="downOrganCdList" item="organCd" separator="," open="(" close=")">
#{organCd}
</foreach>
</if>
<if test='userType != null and userType != ""'>
<if test='userType == "normalStayList"'>
and ia_state in ('DST002')
</if>
<if test='userType == "normalCommitList"'>
and ia_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "sectionCommitList"'>
and ia_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
<if test='userType == "managerStayList"'>
and ia_state in ('DST002')
</if>
<if test='userType == "managerCommitList"'>
and ia_state in ('DST003', 'DST004', 'DST005', 'DST006')
</if>
</if>
</where>
</sql>
<select id="selectIntelligenceAnalyzeList" resultType="IntelligenceAnalyze" parameterType="IntelligenceAnalyze">
select ia_key,
ia_sdate,
ia_edate,
sum("AAR001"+"AAR003"+"AAR004"+"AAR006"+"AAR008") as total_cnt,
sum("AAR001") as special_cnt,
sum("AAR003") as middle_cnt,
sum("AAR004") as tong_cnt,
sum("AAR006") as jo_cnt,
sum("AAR008") as mu_cnt,
fi_cnt,
(fa_cnt+work_cnt+arrest_cnt) as ia_total,
fa_cnt,
work_cnt,
arrest_cnt,
wrt_dt,
(select item_value from code_mgt where item_cd = ia_state) as ia_state,
wrt_organ,
wrt_user_seq,
(select item_value from code_mgt where item_cd = wrt_user_grd) as wrt_user_grd,
wrt_user_nm
from(
(select ia.ia_key,
iata.affair_key,
ia_sdate,
ia_edate,
fi_cnt,
fa_cnt,
work_cnt,
arrest_cnt,
wrt_dt,
ia_state,
wrt_organ,
wrt_user_seq,
wrt_user_grd,
wrt_user_nm
from intelligence_analyze ia,
intelligence_analyze_to_affair iata
where ia.ia_key = iata.ia_key) a left join
(select ab.affair_key,
case
when ar.affair_rate = 'AAR001' then 1
else 0
end as "AAR001",
case
when ar.affair_rate = 'AAR003' then 1
else 0
end as "AAR003",
case
when ar.affair_rate = 'AAR004' then 1
else 0
end as "AAR004",
case
when ar.affair_rate = 'AAR006' then 1
else 0
end as "AAR006",
case
when ar.affair_rate = 'AAR008' then 1
else 0
end as "AAR008"
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and ab.affair_category = 'CAT216'
and (ar.organ_up != 'T' or ar.organ_up is null))b
on a.affair_key = b.affair_key
)
<include refid="selectIntelligenceAnalyzeListWhere"></include>
group by ia_key,ia_sdate,ia_edate,fi_cnt,fa_cnt,work_cnt,arrest_cnt,wrt_dt,ia_state,wrt_organ,wrt_user_seq, wrt_user_grd,wrt_user_nm
order by ia_key desc
</select>
<select id="selectIntelligenceAnalyzeListCnt" resultType="Integer" parameterType="IntelligenceAnalyze">
select count(*)
from(
select ia_key,
ia_sdate,
ia_edate,
sum("AAR001"+"AAR003"+"AAR004"+"AAR006"+"AAR008") as total_cnt,
sum("AAR001") as special_cnt,
sum("AAR003") as middle_cnt,
sum("AAR004") as tong_cnt,
sum("AAR006") as jo_cnt,
sum("AAR008") as mu_cnt,
fi_cnt,
(fa_cnt+work_cnt+arrest_cnt) as ia_total,
fa_cnt,
work_cnt,
arrest_cnt,
wrt_dt,
ia_state,
wrt_organ,
wrt_user_seq,
wrt_user_grd,
wrt_user_nm
from(
(select ia.ia_key,
iata.affair_key,
ia_sdate,
ia_edate,
fi_cnt,
fa_cnt,
work_cnt,
arrest_cnt,
wrt_dt,
ia_state,
wrt_organ,
wrt_user_seq,
wrt_user_grd,
wrt_user_nm
from intelligence_analyze ia,
intelligence_analyze_to_affair iata
where ia.ia_key = iata.ia_key) a left join
(select ab.affair_key,
case
when ar.affair_rate = 'AAR001' then 1
else 0
end as "AAR001",
case
when ar.affair_rate = 'AAR003' then 1
else 0
end as "AAR003",
case
when ar.affair_rate = 'AAR004' then 1
else 0
end as "AAR004",
case
when ar.affair_rate = 'AAR006' then 1
else 0
end as "AAR006",
case
when ar.affair_rate = 'AAR008' then 1
else 0
end as "AAR008"
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and ab.affair_category = 'CAT216'
and (ar.organ_up != 'T' or ar.organ_up is null))b
on a.affair_key = b.affair_key
)
<include refid="selectIntelligenceAnalyzeListWhere"></include>
group by ia_key,ia_sdate,ia_edate,fi_cnt,fa_cnt,work_cnt,arrest_cnt,wrt_dt,ia_state,wrt_organ,wrt_user_seq, wrt_user_grd,wrt_user_nm
order by ia_key desc
)a
</select>
<select id="selectIntelligenceAnalyze" resultType="IntelligenceAnalyze" parameterType="IntelligenceAnalyze">
select ia_key,
ia_sdate,
ia_edate,
sum("AAR001"+"AAR003"+"AAR004"+"AAR006"+"AAR008") as total_cnt,
sum("AAR001") as special_cnt,
sum("AAR003") as middle_cnt,
sum("AAR004") as tong_cnt,
sum("AAR006") as jo_cnt,
sum("AAR008") as mu_cnt,
fi_cnt,
(fa_cnt+work_cnt+arrest_cnt) as ia_total,
fa_cnt,
work_cnt,
arrest_cnt,
foreign_affairs,
"work",
arrest_offenders,
analysis_evaluation,
measures,
wrt_dt,
ia_state,
wrt_organ,
wrt_user_seq,
(select item_value from code_mgt where item_cd = wrt_user_grd) as wrt_user_grd,
wrt_user_nm
from(
(select ia.ia_key,
iata.affair_key,
ia_sdate,
ia_edate,
fi_cnt,
fa_cnt,
work_cnt,
arrest_cnt,
foreign_affairs,
"work",
arrest_offenders,
analysis_evaluation,
measures,
wrt_dt,
ia_state,
wrt_organ,
wrt_user_seq,
wrt_user_grd,
wrt_user_nm
from intelligence_analyze ia,
intelligence_analyze_to_affair iata
where ia.ia_key = iata.ia_key) a left join
(select ab.affair_key,
case
when ar.affair_rate = 'AAR001' then 1
else 0
end as "AAR001",
case
when ar.affair_rate = 'AAR003' then 1
else 0
end as "AAR003",
case
when ar.affair_rate = 'AAR004' then 1
else 0
end as "AAR004",
case
when ar.affair_rate = 'AAR006' then 1
else 0
end as "AAR006",
case
when ar.affair_rate = 'AAR008' then 1
else 0
end as "AAR008"
from affair_board ab,
affair_rating ar
where ab.affair_key = ar.affair_key
and ab.affair_category = 'CAT216'
and (ar.organ_up != 'T' or ar.organ_up is null))b
on a.affair_key = b.affair_key
)
where ia_key = #{iaKey}
group by ia_key,ia_sdate,ia_edate,fi_cnt,fa_cnt,work_cnt,arrest_cnt, foreign_affairs,"work",arrest_offenders,analysis_evaluation,measures,wrt_dt,ia_state,wrt_organ,wrt_user_seq, wrt_user_grd,wrt_user_nm
</select>
<select id="selectIntelligenceAnalyzeAffairKey" resultType="Integer" parameterType="IntelligenceAnalyze">
select affair_key
from intelligence_analyze_to_affair
where ia_key = #{iaKey}
</select>
</mapper>