<?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">
|
<!--
|
* @title: 裁判文书网案件信息表
|
* @description: 自定义sql,请自行实现业务逻辑
|
* @company: hugeinfo
|
* @author: huangh
|
* @time:2024-12-10 17:13:00
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.knowledge.dao.mapper.CpwsCaseInfoMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.knowledge.domain.po.CpwsCaseInfo">
|
<result property="cpwsCaseInfoId" column="cpws_case_info_id"/>
|
<result property="cpwsCaseTextId" column="cpws_case_text_id"/>
|
<result property="plaintiff" column="plaintiff"/>
|
<result property="defendant" column="defendant"/>
|
<result property="caseNumber" column="case_number"/>
|
<result property="caseName" column="case_name"/>
|
<result property="court" column="court"/>
|
<result property="region" column="region"/>
|
<result property="caseType" column="case_type"/>
|
<result property="trialProcedure" column="trial_procedure"/>
|
<result property="caseReason" column="case_reason"/>
|
<result property="caseReasonId" column="case_reason_id"/>
|
<result property="deleteStatus" column="delete_status"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="judgmentDate" column="judgment_date"/>
|
<result property="publicationDate" column="publication_date"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>ai.cpws_case_info_20241230</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
cpws_case_info_id,cpws_case_text_id,plaintiff,defendant,case_number,case_name,court,region,case_type,trial_procedure,case_reason,case_reason_id,delete_status,create_time,update_time,judgment_date,publication_date
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.cpwsCaseTextId != null">cpws_case_text_id = #{entity.cpwsCaseTextId},</if>
|
<if test="entity.plaintiff != null">plaintiff = #{entity.plaintiff},</if>
|
<if test="entity.defendant != null">defendant = #{entity.defendant},</if>
|
<if test="entity.caseNumber != null">case_number = #{entity.caseNumber},</if>
|
<if test="entity.caseName != null">case_name = #{entity.caseName},</if>
|
<if test="entity.court != null">court = #{entity.court},</if>
|
<if test="entity.region != null">region = #{entity.region},</if>
|
<if test="entity.caseType != null">case_type = #{entity.caseType},</if>
|
<if test="entity.trialProcedure != null">trial_procedure = #{entity.trialProcedure},</if>
|
<if test="entity.caseReason != null">case_reason = #{entity.caseReason},</if>
|
<if test="entity.caseReasonId != null">case_reason_id = #{entity.caseReasonId},</if>
|
<if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus},</if>
|
<if test="entity.createTime != null">create_time = #{entity.createTime},</if>
|
<if test="entity.updateTime != null">update_time = #{entity.updateTime},</if>
|
<if test="entity.judgmentDate != null">judgment_date = #{entity.judgmentDate},</if>
|
<if test="entity.publicationDate != null">publication_date = #{entity.publicationDate}</if>
|
</sql>
|
<!-- 条件 -->
|
<sql id="where-part">
|
<if test="terms != null">
|
<where>
|
<if test="terms.cpwsCaseTextId != null and terms.cpwsCaseTextId !=''">
|
and cpws_case_text_id = #{terms.cpwsCaseTextId}
|
</if>
|
<if test="terms.plaintiff != null and terms.plaintiff !=''">
|
and plaintiff = #{terms.plaintiff}
|
</if>
|
<if test="terms.defendant != null and terms.defendant !=''">
|
and defendant = #{terms.defendant}
|
</if>
|
<if test="terms.caseNumber != null and terms.caseNumber !=''">
|
and case_number = #{terms.caseNumber}
|
</if>
|
<if test="terms.caseName != null and terms.caseName !=''">
|
and case_name = #{terms.caseName}
|
</if>
|
<if test="terms.court != null and terms.court !=''">
|
and court = #{terms.court}
|
</if>
|
<if test="terms.region != null and terms.region !=''">
|
and region = #{terms.region}
|
</if>
|
<if test="terms.caseType != null and terms.caseType !=''">
|
and case_type = #{terms.caseType}
|
</if>
|
<if test="terms.trialProcedure != null and terms.trialProcedure !=''">
|
and trial_procedure = #{terms.trialProcedure}
|
</if>
|
<if test="terms.caseReason != null and terms.caseReason !=''">
|
and case_reason = #{terms.caseReason}
|
</if>
|
<if test="terms.caseReasonId != null and terms.caseReasonId !=''">
|
and case_reason_id = #{terms.caseReasonId}
|
</if>
|
<if test="terms.createTime != null and terms.createTime !=''">
|
and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
|
</if>
|
<if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
|
and (DATE_FORMAT(create_time,'%Y-%m-%d') >= #{terms.createStart}
|
and DATE_FORMAT(create_time,'%Y-%m-%d') <= #{terms.createEnd})
|
</if>
|
<if test="terms.updateTime != null and terms.updateTime !=''">
|
and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
|
</if>
|
<if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
|
and (DATE_FORMAT(update_time,'%Y-%m-%d') >= #{terms.updateStart}
|
and DATE_FORMAT(update_time,'%Y-%m-%d') <= #{terms.updateEnd})
|
</if>
|
<if test="terms.deleteStatus == null or terms.deleteStatus ==''">
|
and delete_status = '1'
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and delete_status = #{terms.deleteStatus}
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 更新对象 -->
|
<update id="updateCpwsCaseInfo">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
cpws_case_info_id = #{entity.cpwsCaseInfoId}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateCpwsCaseInfoTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteCpwsCaseInfo">
|
delete from
|
<include refid="table-name" />
|
where cpws_case_info_id = #{id}
|
</delete>
|
<!-- 根据条件查询 -->
|
<select id="listTerms" resultMap="dataResult">
|
select
|
<include refid="column-part"/>
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
|
|
<!-- 分页表 -->
|
<sql id='table-name-page'>
|
ai.cpws_case_info c
|
<if test="terms.courtName != null and terms.courtName !=''">
|
JOIN
|
ai.cpws_court_info ci ON c.court = ci.name
|
</if>
|
<if test="terms.causeName != null and terms.causeName !=''">
|
JOIN
|
ai.cpws_cause_info cci ON c.case_reason = cci.name
|
</if>
|
<if test="terms.cpwsCauseIds != null and !terms.cpwsCauseIds.isEmpty()">
|
JOIN
|
ai.cpws_cause_info cci ON c.case_reason = cci.name
|
</if>
|
</sql>
|
|
<!-- 分页条件 -->
|
<sql id="where-part-page">
|
<if test="terms != null">
|
<where>
|
<if test="terms.caseName != null and terms.caseName !=''">
|
and c.case_name = #{terms.caseName}
|
</if>
|
<if test="terms.caseReason != null and terms.caseReason !=''">
|
and c.case_reason = #{terms.caseReason}
|
</if>
|
<if test="terms.judgmentStart != null and terms.judgmentStart !='' and terms.judgmentEnd != null and terms.judgmentEnd !=''">
|
and (DATE_FORMAT(c.judgment_date,'%Y-%m-%d') >= #{terms.judgmentStart}
|
and DATE_FORMAT(c.judgment_date,'%Y-%m-%d') <= #{terms.judgmentEnd})
|
</if>
|
<if test="terms.publicationStart != null and terms.publicationStart !='' and terms.publicationEnd != null and terms.publicationEnd !=''">
|
and (DATE_FORMAT(c.publication_date,'%Y-%m-%d') >= #{terms.publicationStart}
|
and DATE_FORMAT(c.publication_date,'%Y-%m-%d') <= #{terms.publicationEnd})
|
</if>
|
<if test="terms.deleteStatus == null or terms.deleteStatus ==''">
|
and c.delete_status = '1'
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and c.delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.courtName != null and terms.courtName !=''">
|
<if test="terms.courtLevel == 1">
|
and ci.prov_name = #{terms.courtName}
|
</if>
|
<if test="terms.courtLevel == 2">
|
and ci.intermediate_name = #{terms.courtName}
|
</if>
|
<if test="terms.courtLevel == 3">
|
and ci.basic_name = #{terms.courtName}
|
</if>
|
</if>
|
<if test="terms.causeName != null and terms.causeName !=''">
|
<if test="terms.causeLevel == 1">
|
and cci.primary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 2">
|
and cci.secondary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 3">
|
and cci.tertiary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 4">
|
and cci.quaternary_cause_name = #{terms.causeName}
|
</if>
|
</if>
|
<if test="terms.keyword != null and terms.keyword !=''">
|
and case_name like concat('%',#{terms.keyword},'%')
|
</if>
|
<if test="terms.areaCourtLevel == 2 and terms.areaCourtName != null and terms.areaCourtName !=''">
|
and ci.prov_name = #{terms.areaCourtName}
|
</if>
|
<if test="terms.cpwsCauseIds != null and !terms.cpwsCauseIds.isEmpty()">
|
and (
|
cci.primary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.secondary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.tertiary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.quaternary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
)
|
</if>
|
</where>
|
</if>
|
</sql>
|
|
<sql id="column-part-page">
|
cpws_case_info_id,cpws_case_text_id,case_name,court,case_reason,judgment_date
|
</sql>
|
<!-- 结果集 -->
|
<resultMap id="dataResult-page" type="cn.huge.module.knowledge.domain.dto.CpwsCaseinfoDTO">
|
<result property="cpwsCaseInfoId" column="cpws_case_info_id"/>
|
<result property="cpwsCaseTextId" column="cpws_case_text_id"/>
|
<result property="caseName" column="case_name"/>
|
<result property="court" column="court"/>
|
<result property="caseReason" column="case_reason"/>
|
<result property="judgmentDate" column="judgment_date"/>
|
</resultMap>
|
|
<!-- 根据条件统计 -->
|
<select id="countTerms" resultType="java.lang.Long">
|
select
|
COUNT(1)
|
from
|
<include refid="table-name-page" />
|
<include refid="where-part-page"/>
|
</select>
|
|
<!-- 根据条件分页查询 -->
|
<select id="pageTerms" resultMap="dataResult-page">
|
SELECT
|
<include refid="column-part-page"/>
|
FROM
|
<include refid="table-name-page" />
|
<include refid="where-part-page"/>
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
isnull(${s.property}), ${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by isnull(c.create_time), c.create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
<!-- 单项统计-结果集 -->
|
<resultMap id="dataResult-oneCount" type="cn.huge.module.knowledge.domain.dto.CategoryCountDTO">
|
<!-- <result property="category" column="category"/>-->
|
<result property="name" column="name"/>
|
<result property="count" column="count"/>
|
</resultMap>
|
|
<!-- 年份统计条件 -->
|
<sql id="where-part-year">
|
<if test="terms != null">
|
<where>
|
<if test="terms.caseName != null and terms.caseName !=''">
|
and c.case_name = #{terms.caseName}
|
</if>
|
<if test="terms.caseReason != null and terms.caseReason !=''">
|
and c.case_reason = #{terms.caseReason}
|
</if>
|
<if test="terms.judgmentStart != null and terms.judgmentStart !='' and terms.judgmentEnd != null and terms.judgmentEnd !=''">
|
and (DATE_FORMAT(c.judgment_time,'%Y-%m-%d') >= #{terms.judgmentStart}
|
and DATE_FORMAT(c.judgment_time,'%Y-%m-%d') <= #{terms.judgmentEnd})
|
</if>
|
<if test="terms.publicationStart != null and terms.publicationStart !='' and terms.publicationEnd != null and terms.publicationEnd !=''">
|
and (DATE_FORMAT(c.publication_time,'%Y-%m-%d') >= #{terms.publicationStart}
|
and DATE_FORMAT(c.publication_time,'%Y-%m-%d') <= #{terms.publicationEnd})
|
</if>
|
<if test="terms.deleteStatus == null or terms.deleteStatus ==''">
|
and c.delete_status = '1'
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and c.delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.courtName != null and terms.courtName !=''">
|
<if test="terms.courtLevel == 1">
|
and ci.prov_name = #{terms.courtName}
|
</if>
|
<if test="terms.courtLevel == 2">
|
and ci.intermediate_name = #{terms.courtName}
|
</if>
|
<if test="terms.courtLevel == 3">
|
and ci.basic_name = #{terms.courtName}
|
</if>
|
</if>
|
<if test="terms.causeName != null and terms.causeName !=''">
|
<if test="terms.causeLevel == 1">
|
and cci.primary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 2">
|
and cci.secondary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 3">
|
and cci.tertiary_cause_name = #{terms.causeName}
|
</if>
|
<if test="terms.causeLevel == 4">
|
and cci.quaternary_cause_name = #{terms.causeName}
|
</if>
|
</if>
|
<if test="terms.areaCourtLevel == 2 and terms.areaCourtName != null and terms.areaCourtName !=''">
|
and ci.prov_name = #{terms.areaCourtName}
|
</if>
|
<if test="terms.cpwsCauseIds != null and !terms.cpwsCauseIds.isEmpty()">
|
and (
|
cci.primary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.secondary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.tertiary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
or cci.quaternary_cause in
|
<foreach item="id" index="index" collection="terms.cpwsCauseIds"
|
open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
)
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 年份统计 -->
|
<select id="yearCount" resultMap="dataResult-oneCount">
|
SELECT
|
<!-- "year" as category,-->
|
YEAR(c.judgment_date) AS name,
|
COUNT(c.cpws_case_info_id) AS count
|
FROM
|
<include refid="table-name-page" />
|
<include refid="where-part-page"/>
|
GROUP BY
|
YEAR(c.judgment_date)
|
ORDER BY
|
name
|
</select>
|
<!-- 区域统计 -->
|
<select id="areaCount" resultMap="dataResult-oneCount">
|
SELECT
|
<if test="terms.areaCourtLevel == null">
|
ci.prov_name AS name,
|
</if>
|
<if test="terms.areaCourtLevel == 1">
|
ci.prov_name AS name,
|
</if>
|
<if test="terms.areaCourtLevel == 2">
|
ci.intermediate_name AS name,
|
</if>
|
COUNT(c.cpws_case_info_id) AS count
|
FROM
|
<include refid="table-name-page"/>
|
JOIN
|
ai.cpws_court_info ci ON c.court = ci.name
|
<include refid="where-part-page"/>
|
GROUP BY
|
<!-- <if test="terms.areaCourtLevel != null">-->
|
<!-- </if>-->
|
<if test="terms.areaCourtLevel == 1 or terms.areaCourtLevel == null">
|
ci.prov_name
|
</if>
|
<if test="terms.areaCourtLevel == 2">
|
ci.intermediate_name
|
</if>
|
ORDER BY
|
name
|
</select>
|
|
<!-- 单项统计-结果集 -->
|
<resultMap id="dataResult-dictionary" type="cn.huge.module.knowledge.domain.dto.DictionaryDTO">
|
<result property="value" column="value"/>
|
<result property="name" column="name"/>
|
<result property="count" column="count"/>
|
</resultMap>
|
|
<!-- 区域统计-全数据树形结构 -->
|
<select id="areaCountAll" resultMap="dataResult-dictionary">
|
SELECT
|
ci.intermediate_name AS name,
|
COUNT(c.cpws_case_info_id) AS count,
|
ci.prov_name AS value
|
FROM
|
<include refid="table-name-page"/>
|
JOIN
|
ai.cpws_court_info ci ON c.court = ci.name
|
<include refid="where-part-page"/>
|
GROUP BY ci.intermediate_name,ci.prov_name
|
ORDER BY name
|
</select>
|
|
<!-- 根据ID查询案件标题 -->
|
<select id="getCaseTitleById" resultMap="dataResult">
|
SELECT cpws_case_info_id, case_name
|
FROM <include refid="table-name"/>
|
WHERE cpws_case_info_id = #{id} AND delete_status = '1'
|
</select>
|
|
</mapper>
|