left join logpm_trunkline_advance lta on lta.id = ltad.advance_id
left join logpm_distribution_parcel_list ldpl on ltad.order_package_code = ldpl.order_package_code
left join (
left join (select ldpl.* from logpm_distribution_parcel_list ldpl
join (
select pl.order_package_code,
max(pl.update_time) updateTime
from logpm_distribution_parcel_list pl
left join logpm_trunkline_advance_detail ad on ad.order_package_code = pl.order_package_code
where 1=1
<iftest="param.orderCode != null and param.orderCode != '' ">
and LOCATE(#{param.orderCode}, pl.order_code) > 0
</if>
<iftest="param.waybillNo != null and param.waybillNo != '' ">
and ad.waybill_no = #{param.waybillNo}
and pl.waybill_no = #{param.waybillNo}
</if>
<iftest="param.trainNumber != null and param.trainNumber != '' ">
and ad.train_number = #{param.trainNumber}
and pl.train_number = #{param.trainNumber}
</if>
<iftest="param.serviceNumber != null and param.serviceNumber != '' ">
and ad.service_num = #{param.serviceNumber}
and pl.service_number = #{param.serviceNumber}
</if>
<iftest="param.orderPackageCode != null and param.orderPackageCode != '' ">
and LOCATE(#{param.orderPackageCode},ad.order_package_code) > 0
and LOCATE(#{param.orderPackageCode},pl.order_package_code) > 0
</if>
group by pl.order_package_code
) tmax on tmax.order_package_code = ldpl.order_package_code and ldpl.update_time = tmax.updateTime
left join logpm_warehouse_tray_goods lwtg on lwtg.association_value = ldpl.order_package_code and lwtg.warehouse_id = ldpl.warehouse_id
) tmax on tmax.order_package_code = ldpl.order_package_code and ldpl.update_time = tmax.updateTime) t on t.order_package_code = ltad.order_package_code
left join logpm_warehouse_tray_goods lwtg on lwtg.association_value = t.order_package_code and lwtg.warehouse_id = t.warehouse_id
left join logpm_warehouse_tray lwt on lwtg.tray_id = lwt.id
left join logpm_trunkline_cars_load_scan ltcls on ltcls.scan_code = ldpl.order_package_code
left join (
select cls.scan_code,
max(cls.update_time) cupdateTime
from logpm_trunkline_cars_load_scan cls
group by cls.scan_code
) cmax on cmax.scan_code = ldpl.order_package_code and cmax.cupdateTime = ltcls.update_time
left join logpm_distribution_loadscan ldl on ldl.order_package_code = ldpl.order_package_code and ldl.scan_status != 1 and ldl.is_deleted = 0
left join (select ltcls.* from logpm_trunkline_cars_load_scan ltcls
join (
select cls.scan_code,
max(cls.update_time) cupdateTime
from logpm_trunkline_cars_load_scan cls
group by cls.scan_code
) cmax on cmax.scan_code = ltcls.scan_code and cmax.cupdateTime = ltcls.update_time) m on m.scan_code = t.order_package_code
left join logpm_distribution_loadscan ldl on ldl.order_package_code = t.order_package_code and ldl.scan_status != 1 and ldl.is_deleted = 0
left join logpm_distribution_delivery_list lddl on lddl.id = ldl.delivery_id
where 1=1
<iftest="param.orderCode != null and param.orderCode != '' ">
@ -312,7 +311,7 @@
and ltad.brand = #{param.brand}
</if>
<iftest="param.trunklineCarsNo != null and param.trunklineCarsNo != '' ">
and ltcls.load_code = #{param.trunklineCarsNo}
and m.load_code = #{param.trunklineCarsNo}
</if>
<iftest="param.deliveryTrainNumber != null and param.deliveryTrainNumber != '' ">
and lddl.train_number = #{param.deliveryTrainNumber}