| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?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.KwtWaybillOrderMapper">
- <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtWaybillOrder">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="ent_id" jdbcType="BIGINT" property="entId"/>
- <result column="l_order_id" jdbcType="BIGINT" property="lOrderId"/>
- <result column="w_order_no" jdbcType="VARCHAR" property="wOrderNo"/>
- <result column="truck_no" jdbcType="VARCHAR" property="truckNo"/>
- <result column="type" jdbcType="VARCHAR" property="type"/>
- <result column="driver_id" jdbcType="BIGINT" property="driverId"/>
- <result column="driver_name" jdbcType="VARCHAR" property="driverName"/>
- <result column="driver_phone" jdbcType="VARCHAR" property="driverPhone"/>
- <result column="driver_idcard" jdbcType="VARCHAR" property="driverIdcard"/>
- <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount"/>
- <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
- <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
- <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
- <result column="create_by" jdbcType="BIGINT" property="createBy"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
- <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
- </resultMap>
- <sql id="Base_Column_List">
- id
- , ent_id, l_order_id, w_order_no, truck_no, driver_id, entrust_amount, unload_amount,
- load_amount, deficit_amount, remark, `status`, create_by, create_time, update_by,
- update_time, del_flag,start_time,end_time
- </sql>
- <select id="selectWaybillOrderCarList" resultType="com.sckw.transport.model.dto.OrderCarDTO">
- SELECT a.id as wOrderId,
- a.w_order_no as wOrderNo,
- a.driver_id as driverId,
- a.driver_name as driverName,
- a.driver_phone as driverPhone,
- a.driver_idcard as driverCard,
- a.truck_no as truckNo,
- a.l_order_id as lOrderId,
- b.l_order_no as lOrderNo,
- b.t_order_id as tOrderId,
- b.t_order_no as tOrderNo
- FROM kwt_waybill_order a
- LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
- WHERE a.del_flag = '0'
- and b.del_flag = '0'
- and b.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
- , #{pageSize}
- </select>
- <select id="selectWaybillOrderCarCount" resultType="java.lang.Long">
- SELECT count(a.id)
- FROM kwt_waybill_order a
- LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
- WHERE a.del_flag = '0'
- and b.del_flag = '0'
- and b.t_order_id = #{id,jdbcType=VARCHAR}
- </select>
- <select id="selectDriverOrder" resultType="java.lang.Long">
- SELECT a.l_order_id as lOrderId
- FROM kwt_waybill_order a
- LEFT JOIN kwt_waybill_order_track b ON a.id = b.w_order_id
- AND a.del_flag = '0'
- AND b.del_flag = '0'
- AND a.type='0'
- <where>
- <if test="id != null and id !=''">
- a.driver_id = #{id,jdbcType=BIGINT}
- </if>
- <if test="status != null and status.size() > 0">
- AND a.`status` IN
- <foreach collection="status" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- group by lOrderId
- </select>
- <select id="getWaybillData" resultType="com.sckw.transport.model.vo.WaybillDetailVO">
- </select>
- <select id="selectWaybillRelate" resultType="com.sckw.transport.model.dto.WayBillDetailDTO">
- SELECT `order`.`id` AS `wOrderId`,
- `order`.`w_order_no` AS `wOrderNo`,
- `order`.`truck_no` AS `truckNo`,
- `order`.`entrust_amount` AS `entrustAmount`,
- `order`.`truck_id` AS `truckId`,
- `order`.`driver_id` AS `driverId`,
- `order`.`driver_name` AS `driverName`,
- `order`.`driver_phone` AS `driverPhone`,
- `order`.`driver_idcard` AS `driverIdcard`,
- `order`.`type`,
- `order`.`start_time` AS `startTime`,
- `order`.`end_time` AS `endTime`,
- `order`.`create_by` AS `createBy`,
- `logistics`.`id` AS `lOrderId`,
- `logistics`.`l_order_no` AS `lOrderNo`,
- `logistics`.`price_type` AS `priceType`,
- `goods`.`goods_name` AS goodsName
- FROM `kwt_waybill_order` `order`
- LEFT JOIN `kwt_logistics_order` `logistics` ON `logistics`.`id` = `order`.`l_order_id`
- LEFT JOIN `kwt_logistics_order_goods` `goods` ON `goods`.`l_order_id` = `order`.`l_order_id`
- WHERE `order`.`id` = #{id,jdbcType=BIGINT}
- </select>
- <select id="statistics" resultType="com.sckw.mongo.model.TableTops">
- SELECT count(a.id) AS total
- FROM kwt_waybill_order a
- LEFT JOIN kwt_waybill_order_track b ON a.id = b.w_order_id
- AND a.del_flag = '0'
- AND b.del_flag = '0'
- <where>
- <if test="id != null and id !=''">
- a.driver_id = #{id,jdbcType=BIGINT}
- </if>
- <if test="status != null and status.size() > 0">
- AND b.`status` IN
- <foreach collection="status" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectDataByLorderId" resultType="int">
- SELECT
- COUNT(b.id)
- FROM
- kwt_waybill_order a
- LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
- AND a.del_flag = 0
- AND b.del_flag = 0
- <where>
- <if test="id != null and id !=''">
- and b.id = #{id}
- </if>
- <if test="statusList != null and statusList.size() >0">
- AND a.`status` IN
- <foreach collection="statusList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="findWaybillOrderCount" resultType="com.sckw.transport.model.vo.WaybillCountVo" parameterType="java.util.Map">
- SELECT
- IFNULL(SUM(wo.entrust_amount), 0.0) entrustAmount, IFNULL(SUM(wo.load_amount), 0.0) loadAmount,
- IFNULL(SUM(wo.unload_amount), 0.0) unloadAmount, IFNULL(SUM(wo.deficit_amount), 0.0) deficitAmount,
- MIN(wot1.time) loadTime, MAX(wot2.time) unloadTime
- from kwt_waybill_order wo
- left join kwt_waybill_order_ticket wot1 on wot1.w_order_id = wo.id and wot1.type = 1 and wot1.del_flag = 0
- left join kwt_waybill_order_ticket wot2 on wot2.w_order_id = wo.id and wot2.type = 2 and wot2.del_flag = 0
- left join kwt_logistics_order lo on lo.id = wo.l_order_id
- where wo.del_flag = 0 and lo.del_flag = 0
- <if test="lOrderId != null and lOrderId != ''">
- and lo.id = #{lOrderId, jdbcType=BIGINT}
- </if>
- <if test="passStatus != null and passStatus != ''">
- and wo.status = 8
- </if>
- <if test="loadCountStatus != null and loadCountStatus != ''">
- and wo.status in (5, 6, 7, 8, 12)
- </if>
- <if test="unloadCountStatus != null and unloadCountStatus != ''">
- and wo.status in (7, 8, 12)
- </if>
- <if test="upperlOrderId != null and upperlOrderId != ''">
- and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
- </if>
- <if test="belowlOrderId != null and belowlOrderId != ''">
- and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
- </if>
- </select>
- <select id="selectWaybillOrderCarListGroupByTruckNo" resultType="com.sckw.transport.model.dto.OrderCarDTO">
- SELECT
- a.truck_no AS truckNo,
- COUNT( a.truck_no ) AS count,
- a.driver_id AS driverId,
- a.driver_name AS driverName,
- a.driver_phone AS driverPhone,
- a.driver_idcard AS driverCard
- FROM
- `kwt_waybill_order` a
- LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
- AND B.del_flag = 0
- AND b.del_flag = 0
- <where>
- <if test="id != null and id != ''">
- and a.l_order_id = #{id}
- </if>
- </where>
- GROUP BY
- a.truck_no
- limit #{page},#{pageSize}
- </select>
- </mapper>
|