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

108 lines
3.5 KiB
XML
Raw Normal View History

2023-01-04 09:28:18 +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.main.counterIntelligence.activityCase.mapper.ActivityCaseMapper">
<sql id="selectActivityCaseListWhere">
<where>
2023-03-06 10:15:03 +00:00
<if test='receiptKey != null and receiptKey != ""'>
and a.receipt_key = #{receiptKey}
</if>
<if test='receiptNum != null and receiptNum != ""'>
and a.receipt_num like '%'||#{receiptNum}||'%'
</if>
2023-01-04 09:28:18 +00:00
<if test='wrtUserNm != null and wrtUserNm != ""'>
and a.wrt_user_nm like '%'||#{wrtUserNm}||'%'
</if>
<if test='wrtOrgan != null and wrtOrgan != ""'>
and a.wrt_organ = #{wrtOrgan}
</if>
2023-03-06 10:15:03 +00:00
<if test='dateSelector == "reportDate"'>
2023-01-04 09:28:18 +00:00
<if test='startDate != null and startDate != ""'>
2023-03-06 10:15:03 +00:00
and b.report_date >= #{startDate}::date
2023-01-04 09:28:18 +00:00
</if>
<if test='endDate != null and endDate != ""'>
2023-03-06 10:15:03 +00:00
and b.report_date &lt;= #{endDate}::date+1
2023-01-04 09:28:18 +00:00
</if>
</if>
<if test='dateSelector == "wrtDt"'>
<if test='startDate != null and startDate != ""'>
2023-03-06 10:15:03 +00:00
and b.wrt_dt >= #{startDate}::date
2023-01-04 09:28:18 +00:00
</if>
<if test='endDate != null and endDate != ""'>
2023-03-06 10:15:03 +00:00
and b.wrt_dt &lt;= #{endDate}::date+1
2023-01-04 09:28:18 +00:00
</if>
</if>
</where>
</sql>
2023-03-06 10:15:03 +00:00
<select id="selectActivityCaseList" parameterType="ActivityCaseBoard" resultType="ActivityCaseBoard">
select a.receipt_key,
a.receipt_num ,
a.wrt_organ ,
a.wrt_part ,
a.wrt_user_seq ,
a.wrt_user_grd ,
a.wrt_user_nm ,
b.case_key ,
b.case_num ,
b.report_date ,
b.case_type ,
b.title,
b.wrt_dt,
c.apprvCnt,
c.allCnt,
d.fileCnt
from activity_case a
inner join activity_case_info b
on a.receipt_key = b.receipt_key
inner join (
select case_key,
count(apprv_yn = 'Y' or apprv_yn = 'N') as apprvCnt,
count(*) as allCnt
from activity_case_apprv
group by case_key
) c on b.case_key = c.case_key
inner join (
select case_key, count(*) as fileCnt
from activity_case_file
group by case_key
) d on b.case_key = d.case_key
2023-01-04 09:28:18 +00:00
<include refid="selectActivityCaseListWhere"></include>
2023-03-06 10:15:03 +00:00
ORDER BY b.wrt_dt DESC
2023-01-04 09:28:18 +00:00
LIMIT #{rowCnt} OFFSET #{firstIndex}
</select>
2023-03-06 10:15:03 +00:00
<select id="selectActivityCaseCnt" parameterType="ActivityCaseBoard" resultType="int">
2023-01-04 09:28:18 +00:00
select count(*)
2023-03-06 10:15:03 +00:00
from activity_case a
inner join activity_case_info b
on a.receipt_key = b.receipt_key
inner join (
select case_key,
count(apprv_yn = 'Y' or apprv_yn = 'N') as apprvCnt,
count(*) as allCnt
from activity_case_apprv
group by case_key
) c on b.case_key = c.case_key
inner join (
select case_key, count(*) as fileCnt
from activity_case_file
group by case_key
) d on b.case_key = d.case_key
2023-01-04 09:28:18 +00:00
<include refid="selectActivityCaseListWhere"></include>
</select>
2023-03-06 10:15:03 +00:00
<select id="selectReceiptNum" resultType="int" parameterType="int">
select count(*)+1
from activity_case
where receipt_num like #{year}||'%'
</select>
<select id="selectCaseNum" resultType="int" parameterType="hashMap">
select count(*)+1
from activity_case a
inner join activity_case_info b
on a.receipt_key = b.receipt_key
where a.receipt_num = #{receiptNum}
and b.case_num like #{year}||'%'
</select>
2023-01-04 09:28:18 +00:00
</mapper>