张磊磊
2023-11-09 a8f00a488561323d87dc4669d8fe4a1149fe90d8
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?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.thhy.engineering.modules.biz.engineering.mapper.SysSegmentMapper">
  <resultMap id="BaseResultMap" type="com.thhy.engineering.modules.biz.engineering.entity.SysSegment">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Mar 31 14:17:37 CST 2023.
    -->
    <id column="segment_id" jdbcType="VARCHAR" property="segmentId" />
    <result column="segment_name" jdbcType="VARCHAR" property="segmentName" />
    <result column="pro_id" jdbcType="VARCHAR" property="proId" />
    <result column="segment_admin" jdbcType="VARCHAR" property="segmentAdmin" />
    <result column="shield_enp" jdbcType="VARCHAR" property="shieldEnp" />
    <result column="station" jdbcType="VARCHAR" property="station" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
      <result column="mileage" jdbcType="VARCHAR" property="mileage" />
      <result column="unit_project_name" jdbcType="VARCHAR" property="unitProjectName" />
      <result column="start_time" jdbcType="DATE" property="startTime" />
      <result column="end_time" jdbcType="DATE" property="endTime" />
      <result column="duration" jdbcType="VARCHAR" property="duration" />
  </resultMap>
 
  <select id="segmentNameByOne" parameterType="java.lang.String" resultType="java.lang.String" >
    select segment_id from sys_segment where segment_name=#{segmentName}
    and is_use=1
  </select>
    <select id="segmentNameByProjectName" parameterType="java.lang.String" resultType="java.lang.String" >
        select segment_id from sys_segment where unit_project_name=#{unitProjectName}
        and is_use=1
    </select>
  <insert id="segmentInsert" useGeneratedKeys="true" keyProperty="segment_id">
    insert into sys_segment
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="segmentId != null">
        segment_id,
      </if>
      <if test="segmentName != null">
        segment_name,
      </if>
      <if test="proId != null">
        pro_id,
      </if>
      <if test="segmentAdmin != null">
        segment_admin,
      </if>
      <if test="shieldEnp != null">
        shield_enp,
      </if>
      <if test="station != null">
        station,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
        <if test="mileage != null">
            mileage,
        </if>
        <if test="unitProjectName != null">
            unit_project_name,
        </if>
        <if test="startTime != null">
            start_time,
        </if>
        <if test="endTime != null">
            end_time,
        </if>
        <if test="duration != null">
            duration,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="segmentId != null">
        #{segmentId,jdbcType=VARCHAR},
      </if>
      <if test="segmentName != null">
        #{segmentName,jdbcType=VARCHAR},
      </if>
      <if test="proId != null">
        #{proId,jdbcType=VARCHAR},
      </if>
      <if test="segmentAdmin != null">
        #{segmentAdmin,jdbcType=VARCHAR},
      </if>
      <if test="shieldEnp != null">
        #{shieldEnp,jdbcType=VARCHAR},
      </if>
      <if test="station != null">
        #{station,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
        <if test="mileage != null">
            #{mileage,jdbcType=VARCHAR},
        </if>
        <if test="unitProjectName != null">
            #{unitProjectName,jdbcType=VARCHAR},
        </if>
        <if test="startTime != null">
            #{startTime,jdbcType=DATE},
        </if>
        <if test="endTime != null">
            #{endTime,jdbcType=DATE},
        </if>
        <if test="duration != null">
            #{duration,jdbcType=VARCHAR},
        </if>
    </trim>
  </insert>
  <insert id="segmentNeedInsert" >
    insert into sys_segment_need
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="segmentId != null">
        segment_id,
      </if>
      <if test="needType != null">
        need_type,
      </if>
      <if test="needNum != null">
        need_num,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id},
      </if>
      <if test="segmentId != null">
        #{segmentId,jdbcType=VARCHAR},
      </if>
      <if test="needType != null">
        #{needType,jdbcType=VARCHAR},
      </if>
      <if test="needNum != null">
        #{needNum,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="segmentList" resultType="com.thhy.engineering.modules.biz.engineering.entity.SysSegment">
      select ss.segment_id as segmentId,
      ss.segment_name as segmentName,
      ss.pro_id as proId,
      ss.segment_admin as segmentAdmin,
      ss.shield_enp as shieldEnp,
      ss.station as station,
      ss.create_time as createTime,
      ss.mileage as mileage,
      ss.unit_project_name as unitProjectName,
      ss.start_time as startTime,
      ss.end_time as endTime,
      ss.duration as duration,
      COUNT(tpi.segment_id) completedQuantity,
      sp.pro_name as proName,spu.real_name as realName
      from sys_segment ss
      left join sys_project sp on ss.pro_id=sp.pro_id
      left join sys_plat_user spu on ss.segment_admin=spu.user_id
      left join (SELECT segment_id FROM t_pipe_info WHERE check_result in (1,2,3))  tpi on ss.segment_id = tpi.segment_id
 
        where ss.is_use=1
        <if test="unitProjectName!=null and unitProjectName!='' ">
          and ss.unit_project_name like concat('%',#{unitProjectName},'%')
        </if>
        <if test="segmentName!=null and segmentName!='' ">
          and ss.segment_name like concat('%',#{segmentName},'%')
        </if>
        <if test="proId!=null and proId!='' ">
            and ss.pro_id=#{proId}
        </if>
        <if test="companyId!=null and companyId!='' ">
            and sp.company_id=#{companyId}
        </if>
        GROUP BY ss.segment_id
        order by  ss.create_time desc
  </select>
  <select id="segmentInfo" parameterType="java.lang.String" resultType="com.thhy.engineering.modules.biz.engineering.entity.SysSegment">
        select
        ss.segment_id as segmentId,
         ss.segment_name as segmentName,
         ss.pro_id as proId,
         ss.segment_admin as segmentAdmin,
         ss.shield_enp as shieldEnp,
         ss.station as station,
         ss.create_time as createTime,
        ss.mileage as mileage,
        ss.unit_project_name as unitProjectName,
        ss.start_time as startTime,
        ss.end_time as endTime,
        ss.duration as duration,
        sp.pro_name,spu.real_name from sys_segment ss
        left join sys_project sp on ss.pro_id=sp.pro_id
        left join sys_plat_user spu on ss.segment_admin=spu.user_id
        where ss.is_use=1
        and ss.segment_id=#{segmentId}
  </select>
 
  <select id="segmentNeedList" parameterType="java.lang.String" resultType="com.thhy.engineering.modules.biz.engineering.entity.SysSegmentNeed">
        select ssn.segment_id as segmentId,
         ssn.need_type as needType,
         ssn.need_num as needNum,
        sd.dict_name as dictName from sys_segment_need ssn
        left join sys_dict sd on sd.dict_id=ssn.need_type
        where segment_id=#{segment_id}
 
  </select>
  <update id="segmentDel" parameterType="java.lang.String">
    update sys_segment set
    is_use=2
    where segment_id=#{segmentId}
  </update>
  <delete id="segmentNeedDel" parameterType="java.lang.String">
    delete from sys_segment_need where segment_id=#{segmentId}
  </delete>
 
  <update id="segmentUpdate">
    update sys_segment
    <set>
      <if test="segmentName != null">
        segment_name = #{segmentName,jdbcType=VARCHAR},
      </if>
      <if test="proId != null">
        pro_id = #{proId,jdbcType=VARCHAR},
      </if>
      <if test="segmentAdmin != null">
        segment_admin = #{segmentAdmin,jdbcType=VARCHAR},
      </if>
      <if test="shieldEnp != null">
        shield_enp = #{shieldEnp,jdbcType=VARCHAR},
      </if>
      <if test="station != null">
        station = #{station,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
        <if test="mileage != null">
            mileage = #{mileage,jdbcType=VARCHAR},
        </if>
        <if test="unitProjectName != null">
            unit_project_name = #{unitProjectName,jdbcType=VARCHAR},
        </if>
        <if test="startTime != null">
            start_time = #{startTime,jdbcType=DATE},
        </if>
        <if test="endTime != null">
            end_time = #{endTime,jdbcType=DATE},
        </if>
        <if test="duration != null">
            duration = #{duration,jdbcType=VARCHAR},
        </if>
    </set>
    where segment_id = #{segmentId,jdbcType=VARCHAR}
  </update>
 
</mapper>