wujianwei
2025-09-10 d68d7e5d1fe9659ea21868809dab69a814e07f04
service/src/main/resources/mapper/cwgl/KeyCollectionInfoMapper.xml
@@ -27,10 +27,11 @@
        <result property="quantity"    column="quantity"    />
        <result property="dispatchQuantity"    column="dispatch_quantity"    />
        <result property="remark"    column="remark"    />
        <result property="boxNum"    column="box_num"    />
    </resultMap>
    <sql id="selectKeyCollectionInfoVo">
        select thisTab.id, thisTab.customer_name, thisTab.carrier, thisTab.dispatch_no, thisTab.driver_name, thisTab.driver_mobile, thisTab.license_plate_number, thisTab.order_time, thisTab.order_created_time, thisTab.dispatch_created_time, thisTab.key_collection_time, thisTab.estimated_departure_time, thisTab.required_arrival_time, thisTab.consignor_address, thisTab.consignee_address, thisTab.main_driver, thisTab.point_num, thisTab.transport_mode, thisTab.assistant_driver, thisTab.quantity, thisTab.dispatch_quantity, thisTab.remark from key_collection_info AS thisTab
        select thisTab.id, thisTab.customer_name, thisTab.carrier, thisTab.dispatch_no, thisTab.driver_name, thisTab.driver_mobile, thisTab.license_plate_number, thisTab.order_time, thisTab.order_created_time, thisTab.dispatch_created_time, thisTab.key_collection_time, thisTab.estimated_departure_time, thisTab.required_arrival_time, thisTab.consignor_address, thisTab.consignee_address, thisTab.main_driver, thisTab.point_num, thisTab.transport_mode, thisTab.assistant_driver, thisTab.quantity, thisTab.dispatch_quantity, thisTab.remark, thisTab.box_num from key_collection_info AS thisTab
    </sql>
    <sql id="selectKeyCollectionInfoVoCount">
        select count(0) from key_collection_info as thisTab
@@ -56,6 +57,7 @@
        <if test="transportMode != null  and transportMode != ''"> and thisTab.transport_mode = #{transportMode}</if>
        <if test="assistantDriver != null  and assistantDriver != ''"> and thisTab.assistant_driver = #{assistantDriver}</if>
        <if test="quantity != null "> and thisTab.quantity = #{quantity}</if>
        <if test="boxNum != null "> and thisTab.box_num = #{boxNum}</if>
        <if test="dispatchQuantity != null "> and thisTab.dispatch_quantity = #{dispatchQuantity}</if>
    </sql>
@@ -80,52 +82,52 @@
        order by thisTab.id desc
    </select>
    <select id="selectCwData" resultType="com.ruoyi.cwgl.domain.KeyCollectionInfo">
SELECT
   customer.`NAME` as customerName,
   bp.`NAME` as carrier,
   ts.DISPATCH_NO as dispatchNo,
   driver_m.`NAME` as driverName,
   driver_m.MOBILE as driverMobile,
   vhc.LICENSE_PLATE_NUMBER as licensePlateNumber,
   ord.ORDER_TIME as orderTime,
   ord.CREATED_TIME as orderCreatedTime,
   ts.CREATED_TIME as dispatchCreatedTime,
   now() as keyCollectionTime, -- 放请求查询到的时间
   ord.ESTIMATED_DEPARTURE_TIME as estimatedDepartureTime,
   ord.CONSIGNOR_ADDRESS_ADDR_INFO as consignorAddress,
   ord.CONSIGNEE_ADDRESS_ADDR_INFO as consigneeAddress,
   driver_m.`NAME` as mainDriver,
   ts.POINT_NUM as pointNum,
   ts.TRANSPORT_MODE as transportMode,
   driver_a.`NAME` as assistantDriver,
   ts.QUANTITY as quantity,
   ts.REQUIRED_ARRIVAL_TIME as ,
   ts.DISPATCH_QUANTITY as dispatchQuantity,
   ts.REMARK as remark,
   TIMESTAMPDIFF(HOUR, ord.ORDER_TIME, ord.CREATED_TIME) as schedulingTimeout,
   TIMESTAMPDIFF(HOUR, ord.ESTIMATED_DEPARTURE_TIME, NOW()) as keyTimeout
        SELECT
        customer.`NAME` as customerName,
        bp.`NAME` as carrier,
        ts.DISPATCH_NO as dispatchNo,
        driver_m.`NAME` as driverName,
        driver_m.MOBILE as driverMobile,
        vhc.LICENSE_PLATE_NUMBER as licensePlateNumber,
        vhc.NAME as boxNum,
        ord.ORDER_TIME as orderTime,
        ord.CREATED_TIME as orderCreatedTime,
        ts.CREATED_TIME as dispatchCreatedTime,
        now() as keyCollectionTime, -- 放请求查询到的时间
        ord.REQUIRED_DEPARTURE_TIME as estimatedDepartureTime,
        ord.CONSIGNOR_ADDRESS_ADDR_INFO as consignorAddress,
        ord.CONSIGNEE_ADDRESS_ADDR_INFO as consigneeAddress,
        driver_m.`NAME` as mainDriver,
        ts.POINT_NUM as pointNum,
        ts.TRANSPORT_MODE as transportMode,
        driver_a.`NAME` as assistantDriver,
        ts.QUANTITY as quantity,
        ts.REQUIRED_ARRIVAL_TIME as requiredArrivalTime,  -- 添加别名
        ts.DISPATCH_QUANTITY as dispatchQuantity,
        ts.REMARK as remark,
        TIMESTAMPDIFF(HOUR, ord.ORDER_TIME, ord.CREATED_TIME) as schedulingTimeout,
        TIMESTAMPDIFF(HOUR, ord.REQUIRED_DEPARTURE_TIME, NOW()) as keyTimeout
FROM
  tms_shipment ts
  left JOIN oms_order ord ON ts.DISPATCH_NO = ord.DISPATCH_CODE
  LEFT JOIN base_customer customer ON customer.ID = ord.CUSTOMER_ID
  LEFT JOIN tms_vehicle vhc ON ts.VEHICLE_ID = vhc.id
  LEFT JOIN base_provider bp ON bp.ID = ts.CARRIER_ID
  LEFT JOIN tms_driver driver_m ON driver_m.ID = ts.MAIN_DRIVER_ID
  LEFT JOIN tms_driver driver_a ON driver_a.ID = ts.ASSISTANT_DRIVER_ID
WHERE
  ts.`STATUS` = 'A'
  <if test="driverCode != null and driverCode != '' ">
      and driver_m.MOBILE = #{driverCode}
  </if>
  <if test="driverName != null and driverName != ''">
      and driver_m.NAME = #{driverName}
  </if>
ORDER BY ord.ESTIMATED_DEPARTURE_TIME asc
LIMIT 1
        FROM
        tms_shipment ts
        LEFT JOIN oms_order ord ON ts.DISPATCH_NO = ord.DISPATCH_CODE
        LEFT JOIN base_customer customer ON customer.ID = ord.CUSTOMER_ID
        LEFT JOIN tms_vehicle vhc ON ts.VEHICLE_ID = vhc.id
        LEFT JOIN base_provider bp ON bp.ID = ts.CARRIER_ID
        LEFT JOIN tms_driver driver_m ON driver_m.ID = ts.MAIN_DRIVER_ID
        LEFT JOIN tms_driver driver_a ON driver_a.ID = ts.ASSISTANT_DRIVER_ID
        WHERE
        ts.`STATUS` = 'A'
        <if test="driverCode != null and driverCode != ''">
            AND driver_m.MOBILE = #{driverCode}
        </if>
        <if test="driverName != null and driverName != ''">
            AND driver_m.NAME = #{driverName}
        </if>
        ORDER BY ord.ESTIMATED_DEPARTURE_TIME ASC
        LIMIT 1
    </select>
    <!-- 新增 -->
@@ -153,6 +155,7 @@
            <if test="quantity != null">quantity,</if>
            <if test="dispatchQuantity != null">dispatch_quantity,</if>
            <if test="remark != null">remark,</if>
            <if test="boxNum != null">box_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customerName != null">#{customerName},</if>
@@ -176,6 +179,7 @@
            <if test="quantity != null">#{quantity},</if>
            <if test="dispatchQuantity != null">#{dispatchQuantity},</if>
            <if test="remark != null">#{remark},</if>
            <if test="boxNum != null">#{boxNum},</if>
         </trim>
    </insert>