| | |
| | | |
| | | |
| | | <select id="queryApplyReassignList" resultType="map"> |
| | | select |
| | | a.id as id, |
| | | DATE_FORMAT(a.insertTime, '%Y年%m月%d日%H:%i') as applyTime, |
| | | if(a.orderType = 1, c.startAddress, b.startAddress) as startAddress, |
| | | if(a.orderType = 1, c.endAddress, b.endAddress) as endAddress, |
| | | CONCAT(d.`name`, '-', f.carLicensePlate) applyDriver, |
| | | CONCAT(e.`name`, '-', g.carLicensePlate) 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_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) |
| | | 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 -- 假设t_order_transfer表有startAddress和endAddress字段 |
| | | 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 -- 同样假设t_order_transfer表有这些字段 |
| | | 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) -- 确保联接条件正确处理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); -- 更新WHERE子句以包含orderType=7 |
| | | <if test="null != companyId"> |
| | | and if(d.franchiseeId is null or d.franchiseeId = 0, d.companyId = #{companyId}, d.franchiseeId = #{companyId}) |
| | | </if> |