cjl
2023-12-14 6992aaf0587c09f7c511c1afd12e1519d91363d3
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?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.moral.api.mapper.AllocationMapper">
 
    <!-- 通用查询映射结果 deyt template generate -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.Allocation">
        <id column="allocation_id" property="allocationId" />
        <result column="allocation_num" property="allocationNum" />
        <result column="escalation_type" property="escalationType" />
        <result column="escalation_time" property="escalationTime" />
        <result column="pollute_position" property="pollutePosition" />
        <result column="unit_id" property="unitId" />
        <result column="pollute_type" property="polluteType" />
        <result column="change_type" property="changeType" />
        <result column="change_day" property="changeDay" />
        <result column="escalation_unit_id" property="escalationUnitId" />
        <result column="escalation_name" property="escalationName" />
        <result column="investigation_type" property="investigationType" />
        <result column="problem_describe" property="problemDescribe" />
        <result column="is_change" property="isChange" />
        <result column="change_describe" property="changeDescribe" />
        <result column="change_name" property="changeName" />
        <result column="change_time" property="changeTime" />
        <result column="check_score" property="checkScore" />
        <result column="check_describe" property="checkDescribe" />
        <result column="check_name" property="checkName" />
        <result column="check_time" property="checkTime" />
        <result column="state" property="state" />
        <result column="invalid_reason" property="invalidReason" />
        <result column="key_point" property="keyPoint" />
        <result column="latitude" property="latitude" />
        <result column="longitude" property="longitude" />
        <result column="address" property="address" />
        <result column="name" property="name" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        allocation_id, allocation_num, escalation_type, escalation_time, pollute_position, unit_id, pollute_type, change_type, change_day, escalation_unit_id, escalation_name, investigation_type, problem_describe, is_change, change_describe, change_name, change_time, check_score, check_describe, check_name, check_time, state, is_del, is_invalid, invalid_reason, create_id, create_name, create_time, update_id, update_name, update_time,latitude,longitude,address,name
    </sql>
 
    <!-- 通用查询结果列 -->
    <sql id="Allocation_Column_List">
        allocation.allocation_id, allocation.allocation_num, allocation.escalation_type, allocation.escalation_time, allocation.pollute_position, allocation.unit_id, allocation.pollute_type, allocation.change_type, allocation.change_day, allocation.escalation_unit_id, allocation.escalation_name, allocation.investigation_type, allocation.problem_describe, allocation.is_change, allocation.change_describe, allocation.change_name, allocation.change_time, allocation.check_score, allocation.check_describe, allocation.check_name, allocation.check_time, allocation.state, allocation.is_del, allocation.is_invalid, allocation.invalid_reason, allocation.create_id, allocation.create_name, allocation.create_time, allocation.update_id, allocation.update_name, allocation.update_time,allocation.key_point,allocation.latitude,allocation.longitude,allocation.address,allocation.name
    </sql>
 
 
    <select id="extOne" resultType="com.moral.api.pojo.ext.allocation.AllocationExt">
        SELECT
        <include refid="Allocation_Column_List"/>,t1.unit_name as unitName,t5.dataValue as polluteTypeName
        FROM allocation allocation
        left join responsibility_unit t1 on t1.unit_id = allocation.unit_id
        left join (SELECT t3.dataKey,t3.dataValue FROM sys_dict_data t3
        LEFT JOIN sys_dict_type t4 on t4.id = t3.dict_type_id
        where t4.name = 'contaminate') t5 on t5.dataKey = allocation.pollute_type
        where  allocation.allocation_id = #{id} and allocation.is_del = 0
    </select>
 
    <select id="extList" resultType="com.moral.api.pojo.ext.allocation.AllocationListExt">
        SELECT
        <include refid="Allocation_Column_List"/>
        FROM allocation allocation
        <where>
            1 = 1
            <if test="allocation.id != null and allocation.id != 0">
                and allocation.allocation_id = #{allocation.id} and allocation.is_del = 0
            </if>
        </where>
    </select>
 
 
    <select id="extPage" resultType="com.moral.api.pojo.ext.allocation.AllocationPageExt">
        SELECT
        <include refid="Allocation_Column_List"/>,t1.id as applyState
        FROM allocation allocation
        left join allocation_extension t1 on t1.allocation_id = allocation.allocation_id and t1.is_del =0 and t1.is_invalid = 0 and t1.state = 30
        <where>
            1 = 1 and allocation.is_del = 0
            <if test="allocation.unitId != null and allocation.unitId.size != 0">
                and allocation.unit_id in
                <foreach collection="allocation.unitId" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.polluteType != null and allocation.polluteType.size != 0">
                and allocation.pollute_type in
                <foreach collection="allocation.polluteType" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.state != null and allocation.state.size != 0">
                and allocation.state in
                <foreach collection="allocation.state" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.investigationType != null and allocation.investigationType != 0">
                and allocation.investigation_type = #{allocation.investigationType}
            </if>
            <if test="allocation.changeType != null and allocation.changeType != 0">
                and allocation.change_type = #{allocation.changeType}
            </if>
            <if test="allocation.isInvalid != null">
                and allocation.is_invalid = #{allocation.isInvalid}
            </if>
            <if test="allocation.startTime != null and allocation.startTime != '' ">
                and date(allocation.escalation_time) <![CDATA[>=]]> #{allocation.startTime}
            </if>
            <if test="allocation.endTime != null and allocation.endTime !='' ">
                and date(allocation.escalation_time) <![CDATA[<=]]>  #{allocation.endTime}
            </if>
            <if test="allocation.allocationNum != null and allocation.allocationNum !='' ">
                and allocation.allocation_num LIKE CONCAT('%',#{allocation.allocationNum},'%')
            </if>
            <if test="allocation.unitList != null and allocation.unitList.size !=0">
                and allocation.unit_id in
                <foreach collection="allocation.unitList" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
 
            </if>
        </where>
        order by allocation.escalation_time desc,allocation.allocation_id desc
    </select>
 
    <select id="extAppPage" resultType="com.moral.api.pojo.ext.allocation.AllocationPageExt">
        SELECT
        <include refid="Allocation_Column_List"/>
        FROM allocation allocation
        <where>
        1 = 1 and allocation.is_del = 0
            <if test="allocation.startTime != null and allocation.startTime != '' ">
                and date(allocation.escalation_time) <![CDATA[>=]]> #{allocation.startTime}
            </if>
            <if test="allocation.endTime != null and allocation.endTime !='' ">
                and date(allocation.escalation_time) <![CDATA[<=]]>  #{allocation.endTime}
            </if>
            <if test="allocation.stateList != null and allocation.stateList.size !=0">
                and allocation.state in
                <foreach collection="allocation.stateList" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
 
            </if>
            <if test="allocation.unitList != null and allocation.unitList.size !=0">
                and allocation.unit_id in
                <foreach collection="allocation.unitList" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
        </where>
        order by allocation.escalation_time desc,allocation.allocation_id desc
    </select>
</mapper>