| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <?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.aoyang.tms.mapper.TruckMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.aoyang.tms.entity.Truck">
- <id column="truck_id" property="truckId" />
- <result column="trade_type" property="tradeType" />
- <result column="org_id" property="orgId" />
- <result column="org_name" property="orgName" />
- <result column="org_short_name" property="orgShortName" />
- <result column="truck_name" property="truckName" />
- <result column="car_number" property="carNumber" />
- <result column="engine_number" property="engineNumber" />
- <result column="purchase_date" property="purchaseDate" />
- <result column="color" property="color" />
- <result column="dead_weight" property="deadWeight" />
- <result column="capacity" property="capacity" />
- <result column="manufacturer" property="manufacturer" />
- <result column="status" property="status" />
- <result column="bind_status" property="bindStatus" />
- <result column="tms_status" property="tmsStatus" />
- <result column="dept_name" property="deptName" />
- <result column="dept_id" property="deptId" />
- <result column="creater" property="creater" />
- <result column="create_date" property="createDate" />
- <result column="updater" property="updater" />
- <result column="update_date" property="updateDate" />
- <result column="frame_number" property="frameNumber" />
- <result column="trailer_number" property="trailerNumber" />
- <result column="creater_name" property="createrName" />
- <result column="updater_name" property="updaterName" />
- <result column="linked" property="linked" />
- <result column="auto_account" property="autoAccount" />
- <result column="type_name" property="typeName" />
- <result column="owner" property="owner" />
- <result column="address" property="address" />
- <result column="use_nature" property="useNature" />
- <result column="vehicle_id_code" property="vehicleIdCode" />
- <result column="register_date" property="registerDate" />
- <result column="issue_date" property="issueDate" />
- <result column="file_no" property="fileNo" />
- <result column="energy_type" property="energyType" />
- <result column="face_url" property="faceUrl" />
- <result column="back_url" property="backUrl" />
- <result column="auth_status" property="authStatus" />
- <result column="auth_date" property="authDate" />
- <result column="level" property="level" />
- <result column="com_status" property="comStatus" />
- <result column="com_contract_status" property="comContractStatus" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- truck_id, trade_type, org_id, org_name, org_short_name, truck_name, car_number, engine_number, purchase_date, color, dead_weight, capacity, manufacturer, status, bind_status, tms_status, dept_name, dept_id, creater, create_date, updater, update_date, frame_number, trailer_number, creater_name, updater_name, linked, auto_account, type_name, owner, address, use_nature, vehicle_id_code, register_date, issue_date, file_no, energy_type, face_url, back_url, auth_status, auth_date, level, com_status, com_contract_status
- </sql>
- <!-- 查询实时调度车辆列表 -->
- <select id="listTmsManageTruck" resultType="com.aoyang.tms.controller.vo.TruckOrderManageVO">
- SELECT * FROM (
- SELECT
- truck.truck_id as truckId, truck.tms_status as tmsStatus, truck.org_id as orgId, truck.org_name as orgName, truck.org_short_name as orgShortName,
- truck.car_number as carNumber, truck.trailer_number as trailerNumber, truck.dept_id as deptId, truck.dept_name as deptName,
- two.id as orderId, two.order_status as orderStatus, two.order_no as orderNo, two.type, two.spot_id as spotId, two.spot_name as spotName,
- two.shipper_id as shipperId, two.shipper_name as shipperName, two.update_date as updateDate, two.create_date as createDate, two.queue_no as queueNo, wc.id as cycleId,
- case when wc.jing_weight > 0 then 1 else 0 end as weightFlag, two.spot_id
- FROM
- truck
- left join (
- select * from tms_work_order wo where 40 > wo.order_status
- <if test="param!=null and param.loadCount == 1">
- and wo.type = 1 and wo.order_status in (10, 20, 30)
- </if>
- <if test="param!=null and param.loadGotoSpot == 1">
- and wo.type = 1 and wo.order_status = 10
- </if>
- <if test="param!=null and param.loadWait == 1">
- and wo.type = 1 and wo.order_status = 20
- </if>
- <if test="param!=null and param.loadSubmit == 1">
- and wo.type = 1 and wo.order_status = 30
- </if>
- <if test="param!=null and param.unloadCount == 1">
- and wo.type = 2 and wo.order_status in (10, 20, 30)
- </if>
- <if test="param!=null and param.unloadGotoSpot == 1">
- and wo.type = 2 and wo.order_status = 10
- </if>
- <if test="param!=null and param.unloadWait == 1">
- and wo.type = 2 and wo.order_status = 20
- </if>
- <if test="param!=null and param.unloadSubmit == 1">
- and wo.type = 2 and wo.order_status = 30
- </if>
- <if test="param!=null and param.emptyUnAllocated == 1">
- and wo.type = 1
- </if>
- <if test="param!=null and param.heavyUnAllocated == 1">
- and wo.type = 2
- </if>
- order by order_status desc, plan_reach_time asc
- ) two on truck.truck_id = two.truck_id
- left join tms_work_cycle wc on truck.truck_id = wc.truck_id and wc.status = 1
- where truck.org_id = #{param.orgId}
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!=''">
- and (truck.car_number like concat('%',#{param.carNumber},'%') or
- truck.trailer_number like concat('%',#{param.carNumber},'%'))
- </if>
- <if test="param!=null and param.shipperId!=null">
- and two.shipper_id = #{param.shipperId}
- </if>
- <if test="param!=null and param.surplusCount == 1">
- and (two.id is null or two.order_status = 0)
- </if>
- <if test="param!=null and param.unExecuted == 1">
- and two.order_status = 0
- </if>
- <if test="param!=null and param.unAllocated == 1">
- and two.id is null
- </if>
- <if test="param.loadCount == 1 or param.loadWait == 1 or param.loadGotoSpot == 1 or param.loadSubmit == 1 or
- param.unloadCount == 1 or param.unloadGotoSpot == 1 or param.unloadWait == 1 or param.unloadSubmit == 1">
- and two.id is not null
- </if>
- <if test="param!=null and param.emptyUnAllocated == 1">
- and (wc.jing_weight = 0 or wc.jing_weight is null) and two.id is null
- </if>
- <if test="param!=null and param.heavyUnAllocated == 1">
- and wc.jing_weight > 0 and two.id is null
- </if>
- group by truck.truck_id
- ) tbl
- <where>
- <if test="param != null and param.spotId != null">
- and tbl.spot_id = #{param.spotId}
- </if>
- </where>
- ORDER BY
- <choose>
- <when test="param != null and param.spotId != null">
- tbl.queueNo is null, tbl.queueNo asc
- </when>
- <when test="param != null and param.sortBy != null">
- ${param.sortBy} ${param.sortType}
- </when>
- <otherwise>
- tbl.createDate desc
- </otherwise>
- </choose>
- </select>
- <!-- 查询未派单车辆 -->
- <select id="listUnAllocatedTruck" resultType="com.aoyang.tms.entity.Truck">
- SELECT
- <include refid="Base_Column_List"/>
- FROM
- truck left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
- WHERE truck.org_id = #{orgId} and wo.id is null
- </select>
- <!-- 条件查询车辆数量 -->
- <select id="getOrgOrderCount" parameterType="com.aoyang.tms.controller.param.WorkManagePageParam" resultType="java.lang.Integer">
- SELECT count(1)
- FROM (
- select truck.truck_id from
- truck
- left join (
- select * from tms_work_order wo where 40 > wo.order_status
- order by order_status desc, plan_reach_time asc
- ) two on truck.truck_id = two.truck_id
- WHERE truck.org_id = #{param.orgId} and two.id is null
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!='' ">
- and truck.car_number = #{param.carNumber}
- </if>
- <if test="param!=null and param.shipperId!=null">
- and two.shipper_id = #{param.shipperId}
- </if>
- <if test="param!=null and param.orderStatus!=null">
- and two.order_status = #{param.orderStatus}
- </if>
- <if test="param!=null and param.type!=null">
- and two.type = #{param.type}
- </if>
- group by truck.truck_id
- ) tbl
- </select>
- <!-- 查询总运力 -->
- <select id="getTotalCount" parameterType="com.aoyang.tms.controller.param.WorkManagePageParam" resultType="java.lang.Integer">
- SELECT count(1)
- FROM (
- select truck.truck_id FROM truck
- left join (
- select * from tms_work_order wo where 40 > wo.order_status
- order by order_status desc, plan_reach_time asc
- ) two on truck.truck_id = two.truck_id
- WHERE truck.org_id = #{param.orgId}
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!='' ">
- and truck.car_number = #{param.carNumber}
- </if>
- <if test="param!=null and param.shipperId!=null">
- and two.shipper_id = #{param.shipperId}
- </if>
- group by truck.truck_id
- ) tbl
- </select>
- <!-- 查询未执行派单车辆 -->
- <select id="getUnExecutedOrderTruckCount" parameterType="com.aoyang.tms.controller.param.WorkManagePageParam" resultType="java.lang.Integer">
- SELECT count(1)
- FROM ( select truck.truck_id from truck left join tms_work_order wo on truck.truck_id = wo.truck_id and wo.order_status = 0
- WHERE truck.org_id = #{param.orgId} and wo.id is not null
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!='' ">
- and truck.car_number = #{param.carNumber}
- </if>
- <if test="param!=null and param.shipperId!=null">
- and wo.shipper_id = #{param.shipperId}
- </if>
- group by truck.truck_id ) tbl
- </select>
- <!-- 查询未派单车辆 -->
- <select id="getUnAllocatedTruckCount" parameterType="com.aoyang.tms.controller.param.WorkManagePageParam" resultType="java.lang.Integer">
- SELECT count(1)
- FROM
- truck left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
- WHERE truck.org_id = #{param.orgId} and wo.id is null
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!='' ">
- and truck.car_number = #{param.carNumber}
- </if>
- <if test="param!=null and param.shipperId!=null">
- and wo.shipper_id = #{param.shipperId}
- </if>
- </select>
- <!-- 查询未派指定类型运单车车辆 -->
- <select id="getUnAllocatedOrderCount" parameterType="com.aoyang.tms.controller.param.WorkManagePageParam" resultType="java.lang.Integer">
- SELECT count(1) FROM (
- SELECT truck.truck_id
- FROM
- truck
- left join tms_work_order wo on truck.truck_id = wo.truck_id and 40 > wo.order_status
- <if test="param.orderType == 1">
- and wo.type = #{param.orderType}
- </if>
- <if test="param.orderType == 2">
- and wo.type = #{param.orderType}
- </if>
- left join tms_work_cycle wc on truck.truck_id = wc.truck_id and wc.status = 1
- WHERE truck.org_id = #{param.orgId} and wo.id is null
- <if test="param.orderType == 1">
- and ( wc.jing_weight = 0 or wc.jing_weight is null )
- </if>
- <if test="param.orderType == 2">
- and wc.jing_weight > 0
- </if>
- <if test="param!=null and param.deptId!=null">
- and truck.dept_id = #{param.deptId}
- </if>
- <if test="param!=null and param.shipperId!=null">
- and wo.shipper_id = #{param.shipperId}
- </if>
- <if test="param!=null and param.carNumber!=null and param.carNumber!='' ">
- and truck.car_number = #{param.carNumber}
- </if>
- ) tbl
- </select>
- </mapper>
|