吉安感知网项目-后端
linwei
2026-04-09 78ade8bf0498bb54e989fb7ebddd54a8211d0bef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?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="org.sxkj.gd.orderdata.mapper.GdDataObjectionMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="gdDataObjectionResultMap" type="org.sxkj.gd.orderdata.vo.GdDataObjectionVO">
        <result column="id" property="id"/>
        <result column="title" property="title"/>
        <result column="objection_type" property="objectionType"/>
        <result column="objection_status" property="objectionStatus"/>
        <result column="catalog_resource_name" property="catalogResourceName"/>
        <result column="submitter" property="submitter"/>
        <result column="submitter_contact" property="submitterContact"/>
        <result column="handle_unit" property="handleUnit"/>
        <result column="objection_desc" property="objectionDesc"/>
        <result column="objection_basis" property="objectionBasis"/>
        <result column="other_objection_detail" property="otherObjectionDetail"/>
        <result column="review_opinion" property="reviewOpinion"/>
        <result column="area_code" property="areaCode"/>
        <result column="attach_names" property="attachNames"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
 
    <select id="selectGdDataObjectionPage" resultMap="gdDataObjectionResultMap">
        select
        obj.id,
        obj.title,
        obj.objection_type,
        obj.objection_status,
        obj.catalog_resource_name,
        obj.submitter,
        obj.submitter_contact,
        obj.handle_unit,
        obj.objection_desc,
        obj.objection_basis,
        obj.other_objection_detail,
        obj.review_opinion,
        obj.area_code,
        obj.apply_target_dept_id,
        obj.create_user,
        obj.create_dept,
        obj.create_time,
        obj.update_user,
        obj.update_time,
        obj.status,
        obj.is_deleted,
        string_agg(da.attach_name::text, ',') as attach_names,
        bd.dept_name as create_dept_name
        from
        ja_gd_data_objection obj
        left join
        ja_gd_data_objection_attachment da
        on obj.id::text = da.objection_id::text
        and da.is_deleted = 0
        left join
        blade_dept bd on bd.id::text = obj.create_dept::text
        <where>
            obj.is_deleted = 0
            <if test="param2.title != null and param2.title != ''">
                and obj.title::text like concat('%',#{param2.title},'%')
            </if>
            <if test="param2.objectionStatus != null and param2.objectionStatus != ''">
                and obj.objection_status::text = #{param2.objectionStatus}::text
            </if>
            <if test="param2.deptList != null and param2.deptList.size > 0">
                and (
                obj.create_dept::text in
                <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
                    #{deptId}::text
                </foreach>
                or obj.apply_target_dept_id::text in
                <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")">
                    #{deptId}::text
                </foreach>
                )
            </if>
        </where>
        group by
        obj.id, obj.title, obj.objection_status, obj.create_dept,
        obj.apply_target_dept_id, obj.create_time,
        /* 只要 SELECT 里出现的非聚合字段,GROUP BY 必须加上 */
        obj.update_time,
        obj.is_deleted, bd.dept_name
    </select>
 
 
    <select id="exportGdDataObjection" resultType="org.sxkj.gd.orderdata.excel.GdDataObjectionExcel">
        SELECT * FROM ja_gd_data_objection ${ew.customSqlSegment}
    </select>
 
    <select id="getDetail" resultType="org.sxkj.gd.orderdata.vo.GdDataObjectionVO">
        SELECT
        obj.*,
        string_agg(da.attach_name::text, ',') AS attach_names,
        string_agg(da.attach_id::text, ',') AS attach_ids
        FROM
        ja_gd_data_objection obj
        LEFT JOIN
        ja_gd_data_objection_attachment da ON obj.id::text = da.objection_id::text
        <where>
            da.is_deleted = 0
            <if test="id != null">
                AND obj.id::text = #{id}::text
            </if>
        </where>
        GROUP BY
        obj.id
    </select>
 
</mapper>