| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <?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.sckw.transport.dao.KwtWaybillOrderV1Mapper">
- <select id="statistics" resultType="com.sckw.core.model.vo.TableTop"
- parameterType="com.sckw.transport.model.dto.WaybillOrderQueryDto">
- SELECT
- wo.status 'value',
- count(1) total
- from kwt_waybill_order wo
- where wo.del_flag = 0
- <if test="entId != null and entId != ''">
- and wo.ent_id = #{entId, jdbcType=VARCHAR}
- </if>
- <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
- and wo.id in (
- SELECT w_order_id from kwt_waybill_order_address where del_flag = 0
- <if test="loadCityCode != null and loadCityCode != ''">
- address_type = 1
- and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
- </if>
- <if test="unloadCityCode != null and unloadCityCode != ''">
- address_type = 2
- and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
- </if>
- )
- </if>
- <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
- or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
- and wo.id in (
- SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0
- <if test="startLoadTime != null and startLoadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endLoadTime != null and endLoadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="startUnloadTime != null and startUnloadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endUnloadTime != null and endUnloadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- )
- </if>
- <if test="startSendCarTime != null and startSendCarTime != '' " >
- and DATE( wo.create_time) <![CDATA[ >= ]]> #{startSendCarTime,jdbcType=TIMESTAMP}
- </if>
- <if test="startSendCarTime != null and startSendCarTime != '' " >
- and DATE( wo.create_time ) <![CDATA[ <= ]]> #{endSendCarTime,jdbcType=TIMESTAMP}
- </if>
- <if test="keywords != null and keywords != ''">
- and (
- wo.w_order_no like concat('%',#{keywords},'%')
- or wo.truck_no like concat('%',#{keywords},'%')
- or wo.driver_name like concat('%',#{keywords},'%')
- )
- </if>
- GROUP BY wo.status
- </select>
- <select id="findListPage" resultType="com.sckw.transport.model.vo.WaybillOrderSelectVo"
- parameterType="com.sckw.transport.model.dto.WaybillOrderQueryDto">
- SELECT
- wo.id wOrderId, wo.ent_id entId, wo.w_order_no wOrderNo, wo.truck_no truckNo, wo.driver_name driverName, wo.driver_phone driverPhone,
- wo.type, wo.create_time sendCarTime, wo.create_by createBy, wo.create_time createTime, wo.update_time updateTime, wo.status
- from kwt_waybill_order wo
- where wo.del_flag = 0
- <if test="entId != null and entId != ''">
- and wo.ent_id = #{entId, jdbcType=VARCHAR}
- </if>
- <if test="queryWstatus != null and queryWstatus != ''">
- and wo.status in (#{queryWstatus, jdbcType=VARCHAR})
- </if>
- <if test="(loadCityCode != null and loadCityCode != '') or (unloadCityCode != null and unloadCityCode != '')">
- and wo.id in (
- SELECT w_order_id from kwt_waybill_order_address where del_flag = 0
- <if test="loadCityCode != null and loadCityCode != ''">
- address_type = 1
- and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{loadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
- </if>
- <if test="unloadCityCode != null and unloadCityCode != ''">
- address_type = 2
- and left(city_code, #{loadCityCodeLevel, jdbcType=INTEGER}) = left( #{unloadCityCode, jdbcType=INTEGER}, #{loadCityCodeLevel, jdbcType=INTEGER} )
- </if>
- )
- </if>
- <if test="(startLoadTime != null and startLoadTime != '') or (endLoadTime != null and endLoadTime != '')
- or (startUnloadTime != null and startUnloadTime != '') or (endUnloadTime != null and endUnloadTime != '')">
- and wo.id in (
- SELECT w_order_id from kwt_waybill_order_subtask where del_flag = 0
- <if test="startLoadTime != null and startLoadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endLoadTime != null and endLoadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="startUnloadTime != null and startUnloadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endUnloadTime != null and endUnloadTime != ''">
- and DATE(load_time) <![CDATA[ >= ]]> #{startLoadTime,jdbcType=TIMESTAMP}
- </if>
- )
- </if>
- <if test="startSendCarTime != null and startSendCarTime != '' " >
- and DATE( wo.create_time) <![CDATA[ >= ]]> #{startSendCarTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endSendCarTime != null and endSendCarTime != '' " >
- and DATE( wo.create_time ) <![CDATA[ <= ]]> #{endSendCarTime,jdbcType=TIMESTAMP}
- </if>
- <if test="keywords != null and keywords != ''">
- and (
- wo.w_order_no like concat('%',#{keywords},'%')
- or wo.truck_no like concat('%',#{keywords},'%')
- or wo.driver_name like concat('%',#{keywords},'%')
- )
- </if>
- order by wo.update_time desc
- </select>
- <select id="findCapacityListPage" resultType="com.sckw.transport.model.vo.WaybillOrderSelectVo"
- parameterType="com.sckw.transport.model.dto.WaybillSubtaskOrderQueryDto">
- SELECT
- wo.driver_id driverId, wo.driver_name driverName, wo.driver_phone driverPhone, wo.driver_idcard driverIdcard,
- wo.truck_id truckId, wo.truck_no truckNo, count(1) count
- from kwt_waybill_order wo
- left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
- WHERE wo.del_flag = 0 and wos.del_flag = 0
- <if test="ids != null and ids != ''">
- AND wos.l_order_id IN
- <foreach collection="ids.split(',')" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="findStatisticsCountByDriver" resultType="java.util.Map">
- SELECT
- count(case when wo.status = 101 then 1 end) waitTotal,
- count(case when wo.status = 201 then 1 end) departureTotal,
- count(case when wo.status in (203, 301, 302, 401, 402) then 1 end) executeTotal,
- count(case when wo.status in (501, 502, 503, 504, 103, 202) then 1 end) endTotal
- from kwt_waybill_order wo
- where wo.del_flag = 0
- and wo.driver_id = #{driverId, jdbcType=BIGINT}
- <if test="specialEntIds != null and specialEntIds.size() > 0">
- and wo.ent_id in
- <foreach collection="specialEntIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- </if>
- </select>
- <select id="findWaybillOrderByDriver" resultType="com.sckw.transport.model.KwtWaybillOrderV1" parameterType="java.util.Map">
- SELECT
- wo.id, wo.id wOrderId, wo.ent_id entId, wo.w_order_no wOrderNo, wo.truck_no truckNo, wo.driver_name driverName, wo.driver_phone driverPhone,
- wo.type, wo.create_time sendCarTime, wo.create_time createTime, wo.update_time updateTime, wo.status
- from kwt_waybill_order wo
- left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
- where wo.del_flag = 0 and wos.del_flag = 0
- <if test="entId != null and entId != ''">
- and wo.ent_id = #{entId, jdbcType=VARCHAR}
- </if>
- <if test="specialEntIds != null and specialEntIds.size() > 0">
- and wo.ent_id in
- <foreach collection="specialEntIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- </if>
- <if test="driverId != null and driverId != ''">
- and wo.driver_id = #{driverId, jdbcType=BIGINT}
- </if>
- <if test="busStatus != null and busStatus == 1">
- and wo.status = 101
- </if>
- <if test="busStatus != null and busStatus == 2">
- and wo.status = 201
- </if>
- <if test="busStatus != null and busStatus == 3">
- and wo.status in (203, 301, 302, 401, 402)
- </if>
- <if test="busStatus != null and busStatus == 4">
- and wo.status in (103, 202, 501, 502, 503, 504)
- </if>
- <if test="month != null and month != ''">
- and LEFT(wo.create_time, 7) = #{month, jdbcType=TIMESTAMP}
- </if>
- <if test="startTime != null and startTime != ''">
- and LEFT(wo.create_time, 10) <![CDATA[ >= ]]> #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null and endTime != ''">
- and LEFT(wo.create_time, 10) <![CDATA[ <= ]]> #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="busStatus != null and busStatus == 2">
- ORDER BY wos.load_time
- </if>
- <if test="busStatus != null and busStatus == 4">
- ORDER BY CASE WHEN wo.status = 503 THEN wo.status * -1 ELSE wo.status END ASC, wo.update_time desc
- </if>
- </select>
- <select id="findCountByDriverOrTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
- SELECT
- count(case when wo.status = 502 then 1 end) totalComplete,
- count(case when wo.status not in (101, 102, 103, 202) then 1 end) totalTake,
- count(case when wo.status in (203, 301, 302, 401, 402) then 1 end) totalExecute
- from kwt_waybill_order wo
- left join kwt_waybill_order_subtask wos on wos.w_order_id = wo.id
- where wo.del_flag = 0 and wos.del_flag = 0
- <if test="driverId != null and driverId != ''">
- and wo.driver_id = #{driverId, jdbcType=BIGINT}
- </if>
- <if test="truckId != null and truckId != ''">
- and wo.truck_id = #{truckId, jdbcType=BIGINT}
- </if>
- </select>
- <select id="findAmountByDriverOrTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
- SELECT
- IFNULL(SUM(wos.load_amount), 0.0) loadAmount
- from kwt_waybill_order_subtask wos
- left join kwt_waybill_order wo on wos.w_order_id = wo.id
- where wo.del_flag = 0 and wos.del_flag = 0
- <if test="driverId != null and driverId != ''">
- and wo.driver_id = #{driverId, jdbcType=BIGINT}
- </if>
- <if test="truckId != null and truckId != ''">
- and wo.truck_id = #{truckId, jdbcType=BIGINT}
- </if>
- </select>
- <select id="findUnfinishedByTruck" resultType="com.sckw.transport.model.vo.WaybillCountVo">
- SELECT count(1) totalExecute from kwt_waybill_order wo
- where wo.del_flag = 0
- and wo.status in (101, 201, 203, 301, 302, 401, 402)
- <if test="type != null and type != ''">
- and wo.type = #{type, jdbcType=INTEGER}
- </if>
- <if test="truckId != null and truckId != ''">
- and wo.truck_id = #{truckId, jdbcType=BIGINT}
- </if>
- </select>
- <select id="findTicketCountByAddress" resultType="com.sckw.transport.model.vo.WaybillCountVo">
- SELECT
- sum(wot.amount) amount,
- MIN(wot.operate_time) loadTime,
- MAX(wot.operate_time) unloadTime
- from kwt_waybill_order_ticket wot
- left join kwt_waybill_order_address woa on woa.id = wot.w_address_id
- left join kwt_logistics_order_address loa on loa.id = woa.l_address_id
- left join kwt_logistics_order lo on lo.id = loa.l_order_id
- left join kwt_waybill_order wo on wo.id = wot.w_order_id
- where wot.del_flag = 0
- <if test="passStatus != null and passStatus != ''">
- and wo.status = 502
- </if>
- <if test="wOrderId != null and wOrderId != ''">
- and wot.w_order_id = #{wOrderId, jdbcType=BIGINT}
- </if>
- <if test="type != null and type != ''">
- and wot.type = #{type, jdbcType=VARCHAR}
- </if>
- <if test="unit != null and unit != ''">
- and wot.unit = #{unit, jdbcType=VARCHAR}
- </if>
- <if test="lAddressId != null and lAddressId != ''">
- and loa.id = #{lAddressId, jdbcType=BIGINT}
- </if>
- <if test="lOrderId != null and lOrderId != ''">
- and lo.id = #{lOrderId, jdbcType=BIGINT}
- </if>
- <if test="upperlOrderId != null and upperlOrderId != ''">
- and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, lo.pids)
- </if>
- </select>
- </mapper>
|