地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?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.javaweb.geo.mapper.ProjectMapper">
    
    <resultMap type="Project" id="ProjectResult">
        <result property="ids"    column="ids"    />
        <result property="address"    column="address"    />
        <result property="city"    column="city"    />
        <result property="code"    column="code"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyName"    column="company_name"    />
        <result property="createTime"    column="create_time"    />
         <result property="endTime"    column="end_time"    />
        <result property="district"    column="district"    />
        <result property="fullName"    column="full_name"    />
        <result property="laborUnit"    column="labor_unit"    />
        <result property="leader"    column="leader"    />
        <result property="leaderName"    column="leader_name"    />
        <result property="owner"    column="owner"    />
        <result property="province"    column="province"    />
        <result property="serialNumber"    column="serial_number"    />
        <result property="describe"    column="describe"    />
        <result property="status"    column="status"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="statusChangeUser"    column="status_change_user"    />
        <result property="statusChangeReason"    column="status_change_reason"    />
        <result property="dataSource"    column="data_source"    />
    </resultMap>
 
    <sql id="selectProjectVo">
        select ids, address, city, code, company_id, create_time,end_time, district, full_name, labor_unit, leader, owner, province, serial_number, 'describe', status, is_deleted, status_change_user, status_change_reason, data_source from js_project
   
    </sql>
 
    <select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
        <!-- <include refid="selectProjectVo"/>-->
        select
        p.ids,
        p.address,
        p.city,
        p.code,
        p.company_id,
        c.full_name AS company_name,
        p.create_time,
        p.end_time,
        p.district,
        p.full_name,
        p.labor_unit,
        p.leader,
        u.real_name AS leader_name,
        p.owner,
        p.province,
        p.serial_number,
        'p.describe',
        p.status,
        p.is_deleted,
        p.status_change_user,
        p.status_change_reason,
        p.data_source
        FROM
        js_project p
        LEFT JOIN js_company_user u ON p.leader = u.ids
        LEFT JOIN js_company c ON p.company_id = c.ids
        <where>
            p.is_deleted='0'
            <if test="address != null  and address != ''"> and p.address = #{address}</if>
            <if test="city != null "> and p.city = #{city}</if>
            <if test="code != null  and code != ''"> and p.code = #{code}</if>
            <if test="companyId != null "> and p.company_id = #{companyId}</if>
            <if test="district != null  and district != ''"> and p.district = #{district}</if>
            <if test="fullName != null  and fullName != ''"> and p.full_name like concat('%', #{fullName}, '%')</if>
            <if test="laborUnit != null  and laborUnit != ''"> and p.labor_unit = #{laborUnit}</if>
            <if test="leader != null  and leader != ''"> and p.leader = #{leader}</if>
            <if test="owner != null  and owner != ''"> and p.owner = #{owner}</if>
            <if test="province != null  and province != ''"> and p.province = #{province}</if>
            <if test="serialNumber != null  and serialNumber != ''"> and p.serial_number = #{serialNumber}</if>
            <if test="describe != null  and describe != ''"> and p.describe = #{describe}</if>
            <if test="status != null  and status != ''"> and p.status = #{status}</if>
            <if test="isDeleted != null  and isDeleted != ''"> and p.is_deleted = #{isDeleted}</if>
            ORDER BY p.create_time DESC
        </where>
    </select>
    
    <select id="selectProjectById" parameterType="String" resultMap="ProjectResult">
        select
        p.ids,
        p.address,
        p.city,
        p.code,
        p.company_id,
        c.full_name AS company_name,
        p.create_time,
        p.end_time,
        p.district,
        p.full_name,
        p.labor_unit,
        p.leader,
        u.real_name AS leader_name,
        p.owner,
        p.province,
        p.serial_number,
        'p.describe',
        p.status,
        p.is_deleted,
        p.status_change_user,
        p.status_change_reason,
        p.data_source
        FROM
        js_project p
        LEFT JOIN js_company_user u ON p.leader = u.ids
        LEFT JOIN js_company c ON p.company_id = c.ids
        WHERE  p.is_deleted='0' and  p.ids = #{ids}
    </select>
    
    <select id="selectProjectBySerialNumber" resultMap="ProjectResult">
       <include refid="selectProjectVo"/>
        where  serial_number = #{serialNumber} and is_deleted='0'
    </select>
 
    <select id="selectAllProjectNum" resultType="java.lang.Long">
        SELECT count(ids) FROM js_project WHERE is_deleted = '0'
    </select>
 
    <select id="selectProjectNum" resultType="java.lang.Long">
        SELECT count(ids) FROM js_project WHERE `status` = '0' AND is_deleted = '0'
    </select>
 
    <select id="proExceptionList" resultMap="ProjectResult">
        SELECT
             p.ids,
             p.full_name,
             c.full_name as company_name,
             u.real_name as leader_name
        FROM
            js_project p,
            js_company_user u,
            js_company c
        WHERE
            p.leader = u.ids
            AND p.company_id = c.ids
            AND p.is_deleted = '0'
          AND p.ids = ANY ( SELECT project_id FROM js_handle_exception WHERE is_delete = '0' GROUP BY project_id )
    </select>
 
    <insert id="insertProject" parameterType="Project">
        insert into js_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">ids,</if>
            <if test="address != null  and address != ''">address,</if>
            <if test="city != null ">city,</if>
            <if test="code != null  and code != ''">code,</if>
            <if test="companyId != null ">company_id,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="district != null  and district != ''">district,</if>
            <if test="fullName != null  and fullName != ''">full_name,</if>
            <if test="laborUnit != null  and laborUnit != ''">labor_unit,</if>
            <if test="leader != null  and leader != ''">leader,</if>
            <if test="owner != null  and owner != ''">owner,</if>
            <if test="province != null  and province != ''">province,</if>
            <if test="serialNumber != null  and serialNumber != ''">serial_number,</if>
            <if test="describe != null  and describe != ''">`describe`,</if>
            <if test="status != null  and status != ''">status,</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted,</if>
            <if test="statusChangeUser != null  and statusChangeUser != ''">status_change_user,</if>
            <if test="statusChangeReason != null  and statusChangeReason != ''">status_change_reason,</if>
            <if test="dataSource != null  and dataSource != ''">data_source,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ids != null  and ids != ''">#{ids},</if>
            <if test="address != null  and address != ''">#{address},</if>
            <if test="city != null ">#{city},</if>
            <if test="code != null  and code != ''">#{code},</if>
            <if test="companyId != null ">#{companyId},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="district != null  and district != ''">#{district},</if>
            <if test="fullName != null  and fullName != ''">#{fullName},</if>
            <if test="laborUnit != null  and laborUnit != ''">#{laborUnit},</if>
            <if test="leader != null  and leader != ''">#{leader},</if>
            <if test="owner != null  and owner != ''">#{owner},</if>
            <if test="province != null  and province != ''">#{province},</if>
            <if test="serialNumber != null  and serialNumber != ''">#{serialNumber},</if>
            <if test="describe != null  and describe != ''">#{describe},</if>
            <if test="status != null  and status != ''">#{status},</if>
            <if test="isDeleted != null  and isDeleted != ''">#{isDeleted},</if>
            <if test="statusChangeUser != null  and statusChangeUser != ''">#{statusChangeUser},</if>
            <if test="statusChangeReason != null  and isDeleted != ''">#{statusChangeReason},</if>
            <if test="dataSource != null  and dataSource != ''">#{dataSource},</if>
         </trim>
    </insert>
 
    <update id="updateProject" parameterType="Project">
        update js_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="address != null  and address != ''">address = #{address},</if>
            <if test="city != null ">city = #{city},</if>
            <if test="code != null  and code != ''">code = #{code},</if>
            <if test="companyId != null ">company_id = #{companyId},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="district != null  and district != ''">district = #{district},</if>
            <if test="fullName != null  and fullName != ''">full_name = #{fullName},</if>
            <if test="laborUnit != null  and laborUnit != ''">labor_unit = #{laborUnit},</if>
            <if test="leader != null  and leader != ''">leader = #{leader},</if>
            <if test="owner != null  and owner != ''">owner = #{owner},</if>
            <if test="province != null  and province != ''">province = #{province},</if>
            <if test="serialNumber != null  and serialNumber != ''">serial_number = #{serialNumber},</if>
            <if test="describe != null  and describe != ''">`describe` = #{describe},</if>
            <if test="status != null  and status != ''">status = #{status},</if>
            <if test="isDeleted != null  and isDeleted != ''">is_deleted = #{isDeleted},</if>
            <if test="statusChangeUser != null  and statusChangeUser != ''">status_change_user = #{statusChangeUser},</if>
            <if test="statusChangeReason != null  and statusChangeReason != ''">status_change_reason = #{statusChangeReason},</if>
            <if test="dataSource != null  and dataSource != ''">data_source = #{dataSource},</if>
        </trim>
        where ids = #{ids}
    </update>
 
    <delete id="deleteProjectById" parameterType="String">
        delete from js_project where ids = #{ids}
    </delete>
 
    <delete id="deleteProjectByIds" parameterType="String">
        delete from js_project where ids in 
        <foreach item="ids" collection="array" open="(" separator="," close=")">
            #{ids}
        </foreach>
    </delete>
    
</mapper>