<?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.stylefeng.guns.modular.system.dao.ReassignMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Reassign">
|
<id column="id" property="id"/>
|
<result column="orderType" property="orderType"/>
|
<result column="orderId" property="orderId"/>
|
<result column="originalDriverId" property="originalDriverId"/>
|
<result column="originalCarId" property="originalCarId"/>
|
<result column="insertTime" property="insertTime"/>
|
<result column="nowDriverId" property="nowDriverId"/>
|
<result column="nowCarId" property="nowCarId"/>
|
<result column="money" property="money"/>
|
<result column="payType" property="payType"/>
|
<result column="payTime" property="payTime"/>
|
<result column="payOrder" property="payOrder"/>
|
<result column="state" property="state"/>
|
<result column="reason" property="reason"/>
|
<result column="remark" property="remark"/>
|
<result column="reviewer" property="reviewer"/>
|
<result column="reviewerType" property="reviewerType"/>
|
<result column="completeTime" property="completeTime"/>
|
</resultMap>
|
|
|
|
<select id="queryApplyReassignList" resultType="map">
|
SELECT
|
a.id AS id,
|
DATE_FORMAT(a.insertTime, '%Y年%m月%d日%H:%i') AS applyTime,
|
CASE
|
WHEN a.orderType = 1 THEN c.startAddress
|
WHEN a.orderType = 3 THEN b.startAddress
|
WHEN a.orderType = 7 THEN t.startAddress
|
ELSE NULL
|
END AS startAddress,
|
CASE
|
WHEN a.orderType = 1 THEN c.endAddress
|
WHEN a.orderType = 3 THEN b.endAddress
|
WHEN a.orderType = 7 THEN t.endAddress
|
ELSE NULL
|
END AS endAddress,
|
CONCAT(d.name, '-', f.carLicensePlate) AS applyDriver,
|
CONCAT(e.name, '-', g.carLicensePlate) AS nowDriver,
|
a.state AS state,
|
a.orderType AS orderType
|
FROM t_reassign a
|
LEFT JOIN t_order_cross_city b ON (a.orderId = b.id AND a.orderType = 3)
|
LEFT JOIN t_order_private_car c ON (a.orderId = c.id AND a.orderType = 1)
|
LEFT JOIN t_order_transfer t ON (a.orderId = t.id AND a.orderType = 7)
|
LEFT JOIN t_driver d ON (a.originalDriverId = d.id)
|
LEFT JOIN t_driver e ON (a.nowDriverId = e.id)
|
LEFT JOIN t_car f ON (d.carId = f.id)
|
LEFT JOIN t_car g ON (e.carId = g.id)
|
WHERE a.orderType IN (1, 3, 7)
|
<if test="null != companyId">
|
and if(d.franchiseeId is null or d.franchiseeId = 0, d.companyId = #{companyId}, d.franchiseeId = #{companyId})
|
</if>
|
<if test="state == 1">
|
and a.state in (2) and (b.state not in (10, 12) or c.state not in (10, 12) or t.state NOT IN ( 10, 12 ))
|
</if>
|
<if test="state == 2">
|
and a.state in (3, 4, 5)
|
</if>
|
order by a.insertTime desc
|
<if test="null != pageNum and null != size">
|
limit #{pageNum}, #{size}
|
</if>
|
</select>
|
|
|
<select id="queryReassignInfo" resultType="map">
|
SELECT
|
a.id AS id,
|
DATE_FORMAT( a.insertTime, '%Y.%m.%d-%H:%i' ) AS applyTime,
|
CONCAT( d.`name`, '-', e.carLicensePlate ) AS applyDriver,
|
a.reason AS reason,
|
IF
|
( a.orderType = 1, f.nickName, g.nickName ) AS `user`,
|
IF
|
(
|
a.orderType = 1,
|
DATE_FORMAT( b.travelTime, '%Y.%m.%d-%H:%i' ),
|
DATE_FORMAT( c.travelTime, '%Y.%m.%d-%H:%i' )) AS travelTime,
|
IF(a.orderType = 1, b.startAddress,
|
IF(a.orderType = 3, c.startAddress,
|
IF(a.orderType = 7, t.startAddress, NULL))) AS startAddress,
|
|
IF(a.orderType = 1, b.endAddress,
|
IF(a.orderType = 3, c.endAddress,
|
IF(a.orderType = 7, t.endAddress, NULL))) AS endAddress,
|
|
IF(a.orderType = 1, b.state,
|
IF(a.orderType = 3, c.state,
|
IF(a.orderType = 7, t.state, NULL))) AS state,
|
a.state AS `status`,
|
IF
|
( a.reviewerType = 1, i.`name`, h.`name` ) AS reviewer,
|
CONCAT( j.`name`, '-', k.carLicensePlate ) AS nowDriver,
|
a.orderType AS orderType
|
FROM
|
t_reassign a
|
LEFT JOIN t_order_private_car b ON ( a.orderId = b.id AND a.orderType = 1 )
|
LEFT JOIN t_order_cross_city c ON ( a.orderId = c.id AND a.orderType = 3 )
|
LEFT JOIN t_order_transfer t ON ( a.orderId = t.id AND a.orderType = 7 )
|
LEFT JOIN t_driver d ON ( a.originalDriverId = d.id )
|
LEFT JOIN t_car e ON ( a.originalCarId = e.id )
|
LEFT JOIN t_user f ON ( b.userId = f.id )
|
LEFT JOIN t_user g ON ( c.userId = g.id )
|
LEFT JOIN sys_user h ON ( a.reviewer = h.id AND a.reviewerType = 2 )
|
LEFT JOIN t_dispatch i ON ( a.reviewer = i.id AND a.reviewerType = 1 )
|
LEFT JOIN t_driver j ON ( a.nowDriverId = j.id )
|
LEFT JOIN t_car k ON ( a.nowCarId = k.id )
|
where a.id = #{id}
|
</select>
|
</mapper>
|