WorkOrderMapper.xml
10.1 KB
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
<?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="cn.com.glsx.admin.modules.mapper.WorkOrderMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.WorkOrder">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
<result column="partner_order_no" jdbcType="VARCHAR" property="partnerOrderNo"/>
<result column="order_source" jdbcType="VARCHAR" property="orderSource"/>
<result column="ref_order_id" jdbcType="INTEGER" property="refOrderId"/>
<result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
<result column="shop_contactor" jdbcType="VARCHAR" property="shopContactor"/>
<result column="shop_telephone" jdbcType="VARCHAR" property="shopTelephone"/>
<result column="shop_address" jdbcType="VARCHAR" property="shopAddress"/>
<result column="service_type" jdbcType="VARCHAR" property="serviceType"/>
<result column="service_time" jdbcType="TIMESTAMP" property="serviceTime"/>
<result column="service_apm" jdbcType="VARCHAR" property="serviceApm"/>
<result column="service_period" jdbcType="TINYINT" property="servicePeriod"/>
<result column="service_expire_time" jdbcType="TIMESTAMP" property="serviceExpireTime"/>
<result column="area" jdbcType="VARCHAR" property="area"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="district" jdbcType="VARCHAR" property="district"/>
<result column="service_address" jdbcType="VARCHAR" property="serviceAddress"/>
<result column="service_linker" jdbcType="VARCHAR" property="serviceLinker"/>
<result column="service_linker_phone" jdbcType="VARCHAR" property="serviceLinkerPhone"/>
<result column="service_explain" jdbcType="VARCHAR" property="serviceExplain"/>
<result column="need_install" jdbcType="VARCHAR" property="needInstall"/>
<result column="need_insure" jdbcType="VARCHAR" property="needInsure"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="service_provider" jdbcType="VARCHAR" property="serviceProvider"/>
<result column="service_provider_phone" jdbcType="VARCHAR" property="serviceProviderPhone"/>
<result column="mechanic_name" jdbcType="VARCHAR" property="mechanicName"/>
<result column="mechanic_phone" jdbcType="VARCHAR" property="mechanicPhone"/>
<result column="finished_remark" jdbcType="VARCHAR" property="finishedRemark"/>
<result column="notify_target" jdbcType="VARCHAR" property="notifyTarget"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, order_no, partner_order_no, order_source, ref_order_id, shop_name, area, province, city, district,
shop_contactor, shop_telephone, shop_address, service_type, service_time, service_apm, service_period, service_expire_time,
service_address, service_linker, service_linker_phone, service_explain, need_install, need_insure,
remark, `status`, service_provider, service_provider_phone, mechanic_name, mechanic_phone,
finished_remark, notify_target, del_flag, created_date, created_by, updated_date, updated_by
</sql>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_workorder
where del_flag = 0
and id = #{id}
</select>
<select id="selectByOrderNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_workorder
where del_flag = 0
and order_no = #{orderNo}
</select>
<select id="selectByPartnerOrderNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_workorder
where del_flag = 0
and partner_order_no = #{partnerOrderNo}
</select>
<select id="search" resultType="cn.com.glsx.admin.modules.model.WorkOrderDTO">
select tw.id,
tw.order_no orderNo,
tw.partner_order_no bizOrderNo,
tw.service_type serviceType,
concat(DATE_FORMAT(tw.service_time, '%Y-%m-%d'), ' ', ifnull(tw.service_apm, '')) serviceTime,
twv.lessee_name ownerName,
twv.vin,
twv.device_compose deviceCompose,
tt.tenant_name tenantName,
tw.status,
tw.service_provider serviceProvider,
tw.mechanic_name mechanicName,
concat(td.department_name,'/',tu.username) createdBy,
tw.created_date createdDate
from t_workorder tw
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join (
select tv.id,tv.workorder_id,tv.vin,tv.owner_name,group_concat(tvd.sn) sns from t_vehicle tv,t_vehicle_device tvd
where tv.id = tvd.vehicle_id and tv.del_flag = 0 and tvd.del_flag = 0 and tvd.bind_status = 0
group by tv.id
) tv on tv.workorder_id = tw.id
left join t_user tu on tu.id = tw.created_by
left join t_department td on td.id = tu.department_id
left join t_tenant tt on tt.id = tu.tenant_id
where tw.del_flag = 0
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tw.created_by,#{checkedUserIdsStr})
</if>
<if test="sDate != null and sDate != '' and eDate != null and eDate != ''">
<choose>
<when test="timeType == 1">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{sDate} and #{eDate}
</when>
<when test="timeType == 2">
and DATE_FORMAT(tw.service_time,'%Y-%m-%d') between #{sDate} and #{eDate}
</when>
</choose>
</if>
<if test="needInstall != null and needInstall !=''">
and tw.need_install = #{needInstall}
</if>
<if test="serviceType != null and serviceType !=''">
and tw.service_type = #{serviceType}
</if>
<if test="orderStatus != null">
and tw.status = #{orderStatus}
</if>
<if test="term != null and term !=''">
and (
tw.order_no like '%${term}%'
or tw.partner_order_no like '%${term}%'
or twv.lessee_name like '%${term}%'
or twv.vin like '%${term}%'
or tv.sns like '%${term}%'
)
</if>
order by tw.created_date desc
</select>
<select id="export" resultType="cn.com.glsx.admin.modules.model.export.WorkOrderExport">
select tw.id,
tw.order_no orderNo,
tw.need_install needInstall,
tw.partner_order_no bizOrderNo,
tw.service_type serviceType,
tw.service_time serviceTime,
tw.service_apm serviceApm,
twv.lessee_name ownerName,
twv.vin,
twv.device_compose deviceCompose,
tt.tenant_name tenantName,
tw.status,
tw.service_provider serviceProvider,
tw.mechanic_name mechanicName,
tu.username createdBy,
tw.created_date createdDate
from t_workorder tw
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
left join (
select tv.id,tv.workorder_id,tv.vin,tv.owner_name,group_concat(tvd.sn) sns from t_vehicle tv,t_vehicle_device tvd
where tv.id = tvd.vehicle_id and tv.del_flag = 0 and tvd.del_flag = 0 and tvd.bind_status = 0
group by tv.id
) tv on tv.workorder_id = tw.id
left join t_user tu on tu.id = tw.created_by
left join t_tenant tt on tt.id = tu.tenant_id
where tw.del_flag = 0
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tw.created_by,#{checkedUserIdsStr})
</if>
<if test="sDate != null and sDate != '' and eDate != null and eDate != ''">
<choose>
<when test="timeType == 1">
and DATE_FORMAT(tw.created_date,'%Y-%m-%d') between #{sDate} and #{eDate}
</when>
<when test="timeType == 2">
and DATE_FORMAT(tw.service_time,'%Y-%m-%d') between #{sDate} and #{eDate}
</when>
</choose>
</if>
<if test="needInstall != null and needInstall !=''">
and tw.need_install = #{needInstall}
</if>
<if test="serviceType != null and serviceType !=''">
and tw.service_type = #{serviceType}
</if>
<if test="orderStatus != null and orderStatus !=''">
and tw.status = #{orderStatus}
</if>
<if test="term != null and term !=''">
and (
tw.order_no like '%${term}%'
or tw.partner_order_no like '%${term}%'
or twv.lessee_name like '%${term}%'
or twv.vin like '%${term}%'
or tv.sns like '%${term}%'
)
</if>
order by tw.created_date desc
</select>
<select id="selectIncompleteByServiceTypeAndVin" resultMap="BaseResultMap">
select tw.*
from t_workorder tw
left join t_workorder_vehicle twv on twv.workorder_id = tw.id
where tw.del_flag = 0
and tw.status in (0, 1)
and tw.service_type = #{serviceType}
and twv.vin = #{vin} limit 1
</select>
<update id="logicDeleteById">
update t_workorder
set del_flag = -1
where id = #{id}
</update>
</mapper>