luodangjia
2024-12-10 31ce6be2d56798d9509e6d90335999064351f7f3
DispatchOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/ReassignMapper.xml
@@ -33,13 +33,13 @@
        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字段
        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 -- 同样假设t_order_transfer表有这些字段
        WHEN a.orderType = 7 THEN t.endAddress
        ELSE NULL
        END AS endAddress,
        CONCAT(d.name, '-', f.carLicensePlate) AS applyDriver,
@@ -49,17 +49,17 @@
        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_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); -- 更新WHERE子句以包含orderType=7
        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))
            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)
@@ -72,31 +72,47 @@
    <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, c.startAddress) as startAddress,
        if(a.orderType = 1, b.endAddress, c.endAddress) as endAddress,
        if(a.orderType = 1, b.state, c.state) 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_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)
        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>