ApprovalMapper.xml
6.79 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
<?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.ApprovalMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.Approval">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="biz_id" jdbcType="INTEGER" property="bizId"/>
<result column="biz_type" jdbcType="TINYINT" property="bizType"/>
<result column="status" jdbcType="TINYINT" property="status"/>
<result column="node" jdbcType="INTEGER" property="node"/>
<result column="node_name" jdbcType="VARCHAR" property="nodeName"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="version" jdbcType="INTEGER" property="version"/>
<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, biz_id, biz_type, `status`, node, node_name, remark, version, del_flag, created_date,
created_by, updated_date, updated_by, `result`
</sql>
<delete id="logicDeleteById">
update t_approval set del_flag=1 where id=#{id}
</delete>
<select id="findAppByUser" resultMap="BaseResultMap">
select * from t_approval
and created_by in
<foreach collection="userlist" item="userId" index="index" open="(" close=")" separator=",">
#{userId}
</foreach>
</select>
<select id="search" resultType="cn.com.glsx.admin.modules.model.ApprovalDto">
select
app.id as approvalId,
app.biz_type as bizType,
td.dict_label as busType,
tu.username as username,
app.status as status,
app.created_date as createdDate
from t_approval app
left join t_vehicle tvd on app.biz_id = tvd.id and tvd.del_flag = 0
left join t_user tu on app.created_by = tu.id and tu.del_flag = 0
left join t_dict_data td on app.biz_type=td.dict_value
where app.del_flag = 0 and app.status in (1,2,3) and td.dict_type='approval_bustype'
<if test="approvalSearch.status == 1 ">
and app.status=1
</if>
<if test="approvalSearch.status ==2 ">
and app.status in (2,3)
</if>
<if test="approvalSearch.busType !=null and approvalSearch.busType != ''">
and app.biz_type=#{approvalSearch.busType}
</if>
ORDER BY app.created_date desc
</select>
<select id="searchVehiclelicApp" resultType="cn.com.glsx.admin.modules.model.VehicleApproDto">
SELECT
t5.id as approvalId,
t1.id as vehicleId,
t6.username AS shopName,
t6.account AS shopCode,
t4.shop_level AS shopLevel,
t1.vin,
t1.created_by as createdBy,
t1.inner_color AS innerColor,
t1.color AS color,
t1.model_name AS modelName,
t1.vehicle_type AS vehicleType,
t1.config_desc AS configDesc,
t1.sale_manager as saleManager,
t1.license_plate as licensePlate,
t1.sale_manager_phone as saleManagerPhone,
t1.remark as velRemark,
t5.status as approvalStatus,
(select dict_label from t_dict_data where dict_value=t5.status and dict_type = 'approval_status') AS approvalResult,
t5.remark as remark,
t5.created_date as submitTime
FROM
t_approval t5
LEFT JOIN t_vehicle t1 ON t1.ID = t5.biz_id
LEFT JOIN t_trial_drive_shop t4 ON t1.created_by = t4.created_by
LEFT JOIN t_user t6 ON t6.id = t1.created_by
left join t_electric_fence t7 on t4.fence_id=t7.id
WHERE
t1.del_flag = 0
and t5.status in (1,2,3)
and t5.biz_type=2
and t5.id in(select max(id) from t_approval group by biz_id)
<if test="search.approvalStatus !=null and search.approvalStatus != ''">
and t5.status=#{search.approvalStatus}
</if>
<if test="search.keywords !=null and search.keywords != ''">
and (t6.username like concat('%',#{search.keywords},'%')
or t6.account like concat('%',#{search.keywords},'%')
or t7.fence_name like concat('%',#{search.keywords},'%')
)
</if>
GROUP BY
t5.biz_id
ORDER BY t5.created_date desc
</select>
<select id="searchFenceApp" resultType="cn.com.glsx.admin.modules.model.FenceApproDto">
select
app.id as approvalId,
t6.username AS shopName,
t6.account AS shopCode,
shop.shop_level AS shopLevel,
tvd.created_by as createdBy,
app.remark as remark,
tvd.fence_name as fenceName,
tvd.biz_fence_type as fenceTypeId,
app.status as approvalStatus,
td.dict_label as approvalResult,
app.biz_id as bizId,
if(tvd.fence_id is null,'1','2') as isAdd
from t_approval app
left join t_electric_fence_copy tvd on app.biz_id = tvd.id and tvd.del_flag = 0
left join t_trial_drive_shop shop on tvd.created_by=shop.created_by
LEFT JOIN t_user t6 ON t6.id = tvd.created_by
left join t_dict_data td on app.status=td.dict_value
where app.del_flag = 0 and app.status in (1,2,3) and td.dict_type='approval_status'
AND APP.biz_type=1 and t6.username is not null
<if test="search.approvalStatus !=null and search.approvalStatus != ''">
and app.status=#{search.approvalStatus}
</if>
<if test="search.keywords !=null and search.keywords != ''">
and (t6.username like concat('%',#{search.keywords},'%')
or t6.account like concat('%',#{search.keywords},'%')
or tvd.fence_name like concat('%',#{search.keywords},'%')
)
</if>
GROUP BY
app.id
ORDER BY app.created_date desc
</select>
<select id="selectByTypeAndId" resultMap="BaseResultMap"
parameterType="cn.com.glsx.admin.modules.entity.Approval">
select * from t_approval
where
del_flag = 0 and status in (1,2)
and biz_type=#{approval.bizType}
and biz_id=#{approval.bizId}
</select>
<select id="selectbyId" resultMap="BaseResultMap"
parameterType="cn.com.glsx.admin.modules.entity.Approval">
select * from t_approval
where
del_flag = 0 and status=1 and id=#{approval.id}
</select>
</mapper>