@ -192,14 +192,14 @@
) inventoryNub,
(
SELECT
COALESCE (sum(lds.loaded_number), 0)
COALESCE (sum(lds.loaded_number), 0) + COALESCE (sum(lds.loadedin_number), 0)
FROM
logpm_distribution_signfor lds
WHERE
lddl.id = lds.delivery_id
) scannedNumber,
(SELECT
COALESCE (sum(lds.received_quantity), 0)
COALESCE (sum(lds.received_quantity), 0) + COALESCE (sum(lds.receivedin_quantity), 0)
FROM
logpm_distribution_signfor lds
WHERE
@ -219,6 +219,12 @@
<if test= "param.trainNumber != null and param.trainNumber!=''" >
and lddl.train_number like concat('%',#{param.trainNumber},'%')
</if>
<if test= "param.trainNumberList != null " >
and lddl.train_number IN
<foreach collection= "param.trainNumberList" item= "train" open= "(" close= ")" separator= "," >
#{train}
</foreach>
</if>
<if test= "param.warehouseIdList != null and @org.apache.commons.collections4.CollectionUtils@isNotEmpty(param.warehouseIdList)" >
and lddl.warehouse_id in
<foreach collection= "param.warehouseIdList" item= "item" open= "(" close= ")" separator= "," >
@ -270,6 +276,9 @@
<if test= "param.taskTime!=null and param.taskTime!=''" >
and date_format(lddl.task_time,'%y%m%d%') = date_format(#{param.taskTime},'%y%m%d%')
</if>
<if test= "param.taskTimeStart!=null and param.taskTimeStart!=''" >
and date_format(lddl.task_time,'%y%m%d%') BETWEEN #{param.taskTimeStart} AND #{param.taskTimeEnd}
</if>
</where>
GROUP BY lddl.id ,
lddl.train_number ,
@ -307,119 +316,263 @@
</select>
<select id= "exportDistributionDeliveryList" resultType= "com.logpm.distribution.vo.DistributionDeliveryListVO" >
SELECT DISTINCT
lddl.train_number AS trainNumber,
lddl.task_time AS taskTime,
ldr.warehouse_id AS warehouseId,
ldr.consignee AS consignee,
ldr.mall_name AS mallName,
CASE
lddl.kind
WHEN 1 THEN
'自主配送'
WHEN 2 THEN
'三方配送'
END kindName,
CASE
lddl.type
WHEN 1 THEN
'商配'
WHEN 2 THEN
'市配'
END deliveryTypeName,
IF
( lddl.kind = 1, GROUP_CONCAT( DISTINCT ldds.driver_name ), lddt.driver_name ) AS driverName,
IF
( lddl.kind = 1, GROUP_CONCAT( DISTINCT ldds.driver_phone ), lddt.driver_phone ) AS driverPhone,
IF
( lddl.kind = 1, GROUP_CONCAT( DISTINCT ldds.vehicle_nub ), lddt.vehicle_num ) AS vehicleNum,
lddl.distribution_company,
CASE
lddl.delivery_status
WHEN 1 THEN
'待配送'
WHEN 2 THEN
'配送中'
WHEN 3 THEN
'已完成'
END deliveryStatusName,
lddl.customers_number AS customersNumber,
lddl.order_number AS orderNumber,
lddl.delivery_number AS deliveryNumber,
lddl.inventory_nub AS inventoryNub,
<select id= "exportDistributionDeliveryList" resultType= "com.logpm.distribution.excel.DistributionDeliveryListExcel" >
SELECT
lddl.id id,
lww.name AS warehouseName,
lddl.train_number trainNumber,
lddl.warehouse_name warehouseName,
lddl.warehouse_id warehouseId,
lddl.vehicle_name vehicle,
lddl.driver_name driver,
lddl.vehicle_id vehicleId,
lddl.driver_id driverId,
lddl.distribution_company distributionCompany,
lddl.delivery_status deliveryStatus,
lddl.delivery_list_loading_status deliveryListLoadingStatus,
GROUP_CONCAT(y.order_code) AS orderCode,
CASE lddl.kind
WHEN 1 THEN '自主配送'
WHEN 2 THEN '三方配送'
ELSE
'其他'
END kind,
CASE lddl.type
WHEN 1 THEN '商配'
WHEN 2 THEN '市配'
END type,
CASE lddl.delivery_status
WHEN 1 THEN '待配送'
WHEN 2 THEN '配送中'
WHEN 3 THEN '已完成'
ELSE
'其他'
END state,
(
SELECT
GROUP_CONCAT(
DISTINCT ldsu.forklift_name SEPARATOR ','
)
FROM
logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
JOIN logpm_distribution_stockup_info ldsi ON ldr.id = ldsi.reservation_id
JOIN logpm_distribution_stockup ldsu ON ldsu.id = ldsi.stockup_id
WHERE
lds.delivery_id = lddl.id
) forkliftName,
lddl.create_time createTime,
(
SELECT
COALESCE (COUNT(*), 0)
FROM
logpm_distribution_signfor lds INNER JOIN logpm_distribution_reservation AS ldr ON lds.reservation_id = ldr.id
WHERE
lds.delivery_id = lddl.id and ldr.reservation_status != '40' AND (ldr.reservation_num + ldr.reservation_stock_list_num) > 0
) customersNumber,
lddl.price price,
lddl.added_services_id addedServicesId,
(
SELECT
COALESCE (COUNT(*), 0)
FROM
logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
JOIN logpm_distribution_reservation_stockarticle ldrs ON ldrs.reservation_id = ldr.id
WHERE
lds.delivery_id = lddl.id and ldrs.stock_article_status != 2
) orderNumber,
(
SELECT
COALESCE (sum(ldr.reservation_num), 0)
FROM
logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
WHERE
lds.delivery_id = lddl.id and ldr.reservation_status != '40'
) deliveryNumber,
(
SELECT
COALESCE (
sum(
ldr.reservation_stock_list_num
),
0
)
FROM
logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
WHERE
lds.delivery_id = lddl.id
) reservationStockListNum,
(
SELECT
GROUP_CONCAT(
DISTINCT lds.loader_name SEPARATOR ','
)
FROM
logpm_distribution_signfor ldsf
JOIN logpm_distribution_reservation ldr ON ldr.id = ldsf.reservation_id
JOIN logpm_distribution_stockup_info AS ldsi ON ldr.id = ldsi.reservation_id
INNER JOIN logpm_distribution_stockup AS lds ON ldsi.stockup_id = lds.id
WHERE
ldsf.delivery_id = lddl.id
) loadingTeamName,
(
SELECT
GROUP_CONCAT(
DISTINCT lds.fix_time SEPARATOR ','
)
FROM
logpm_distribution_signfor ldsf
JOIN logpm_distribution_reservation ldr ON ldr.id = ldsf.reservation_id
JOIN logpm_distribution_stockup_info AS ldsi ON ldr.id = ldsi.reservation_id
INNER JOIN logpm_distribution_stockup AS lds ON ldsi.stockup_id = lds.id
WHERE
ldsf.delivery_id = lddl.id
-- ) leadTime,
-- lds.delivery_id = lddl.id
) reservationId,
lddl.order_id orderId,
lddl.fee fee,
lddl.task_time taskTime,
lddl.loading_time loadingTime,
lddl.note_number noteNumber,
lddl.source source,
(
SELECT
COALESCE (sum(lds.loaded_number + lds.loadedin_number), 0)
COALESCE (
sum(
ldr.reservation_stock_list_num
),
0
)
FROM
logpm_distribution_signfor lds
JOIN logpm_distribution_reservation ldr ON lds.reservation_id = ldr.id
WHERE
lds.delivery_id = lddl.id
) inventoryNub,
(
SELECT
COALESCE (sum(lds.loaded_number), 0) + COALESCE (sum(lds.loadedin_number), 0)
FROM
logpm_distribution_signfor lds
WHERE
lddl.id = lds.delivery_id
) scannedNumber,
(SELECT
COALESCE (sum(lds.received_quantity + receivedin_quantity), 0)
COALESCE (sum(lds.received_quantity), 0) + COALESCE (sum(lds. receivedin_quantity), 0)
FROM
logpm_distribution_signfor lds
WHERE
lddl.id = lds.delivery_id
) signingNumber,
GROUP_CONCAT( lddl.loading_team_name, lddl.unloading_team_name ) AS handlingCrew
GROUP_CONCAT(DISTINCT ldr.consignee SEPARATOR ',') consignee,
GROUP_CONCAT(DISTINCT ldr.mall_name SEPARATOR ',') mallName,
(SELECT group_concat( DISTINCT ldsa.order_code SEPARATOR ',' ) FROM logpm_distribution_delivery_list lddll LEFT JOIN logpm_distribution_signfor lds ON lddll.id = lds.delivery_id LEFT JOIN logpm_distribution_reservation_stockarticle AS ldrs ON lds.reservation_id = ldrs.reservation_id AND ldrs.stock_article_status != 2 LEFT JOIN logpm_distribution_stock_article AS ldsa ON ldrs.stock_article_id = ldsa.id WHERE lddll.id = lddl.id GROUP BY lddl.id ) AS orderCode
FROM logpm_distribution_delivery_list lddl
LEFT JOIN (
SELECT
lddl.id,
a.consignee AS consignee,
a.mall_name AS mallName,
FROM
logpm_distribution_delivery_list AS lddl
LEFT JOIN logpm_distribution_signfor AS lds ON lddl.id = lds.delivery_id AND lds.is_deleted = 0
LEFT JOIN logpm_distribution_reservation AS ldr ON lds.reservation_id = ldr.id AND ldr.is_deleted = 0
LEFT JOIN logpm_distribution_delivery_self AS ldds ON ldds.delivery_id = lddl.id AND ldds.is_deleted = 0
LEFT JOIN logpm_distribution_delivery_tripartite AS lddt ON ldds.delivery_id = lddl.id AND lddt.is_deleted = 0
<where >
lddl.is_deleted = 0
<if test= " params.ids != null" >
AND lddl.id in
<foreach collection= "params.ids" item= "item" index= "index" open= "(" separator= "," close= ")" >
#{item}
</foreach>
</if>
<if test= " params.trainNumber != '' and params.trainNumber != null" >
AND lddl.train_number like concat('%',#{params.trainNumber},'%')
</if>
<if test= " params.clineName != '' and params.clineName != null" >
AND ldr.consignee like concat('%',#{params.clineName},'%')
</if>
<if test= " params.mallName != '' and params.mallName != null" >
AND ldr.mall_name like concat('%',#{params.mallName},'%')
</if>
<if test= " params.type != '' and params.type != null" >
AND lddl.type = #{params.type}
</if>
<if test= " params.kind != '' and params.kind != null" >
AND lddl.kind = #{params.kind}
</if>
<if test= " params.vehicleName != '' and params.vehicleName != null" >
AND ldds.vehicle_nub like concat('%',#{params.vehicleName},'%')
</if>
<if test= " params.driverName != '' and params.driverName != null" >
AND ldds.driver_name like concat('%',#{params.driverName},'%')
</if>
<if test= " params.distributionCompany != '' and params.distributionCompany != null" >
AND ldds.distribution_company like concat('%',#{params.distributionCompany},'%')
</if>
<if test= " params.taskTime != '' and params.taskTime != null" >
AND ldds.task_time like concat('%',#{params.taskTime},'%')
</if>
<if test= " params.deliveryStatus != '' and params.deliveryStatus != null" >
AND lddl.delivery_status =#{params.deliveryStatus}
</if>
<if test= " params.warehouseId != '' and params.warehouseId != null" >
AND lddl.warehouse_id =#{params.warehouseId}
</if>
<if test= " params.warehouseIds != null " >
AND lddl.warehouse_id IN
<foreach collection= "params.warehouseIds" item= "warehouseId" open= "(" close= ")" separator= "," >
#{warehouseId}
</foreach>
</if>
</where>
logpm_distribution_delivery_list lddl
LEFT JOIN logpm_distribution_signfor lds ON lddl.id = lds.delivery_id
LEFT JOIN logpm_distribution_reservation ldr ON ldr.id = lds.reservation_id
WHERE
IF
( lddl.delivery_number IS NULL, 0, lddl.delivery_number ) +
IF
( lddl.inventory_nub IS NULL, 0, lddl.inventory_nub ) > 0
AND ( lddl.customers_number > 0 AND ldr.reservation_num + ldr.reservation_stock_list_num ) > 0
AND lds.is_deleted = 0 AND lddl.is_deleted = 0 AND ldr.is_deleted = 0
GROUP BY
lddl.id
) AS a On a.id = lddl.id
LEFT JOIN (SELECT lddl.id,ldsa.order_code FROM logpm_distribution_delivery_list lddl
LEFT JOIN logpm_distribution_signfor lds ON lddl.id = lds.delivery_id
LEFT JOIN logpm_distribution_reservation_stockarticle AS ldrs ON lds.reservation_id = ldrs.reservation_id AND ldrs.stock_article_status != 2
LEFT JOIN logpm_distribution_stock_article AS ldsa ON ldrs.stock_article_id = ldsa.id ) AS y ON y.id = lddl.id
LEFT JOIN logpm_warehouse_warehouse AS lww ON lddl.warehouse_id = lww.id
<where >
lddl.is_deleted = 0
AND (IF(lddl.delivery_number is null ,0,lddl.delivery_number) + IF(lddl.inventory_nub is null ,0,lddl.inventory_nub)) > 0
AND (lddl.customers_number > 0 AND ldr.reservation_num + ldr.reservation_stock_list_num) >0
<if test= "param.trainNumber != null and param.trainNumber!=''" >
and lddl.train_number like concat('%',#{param.trainNumber},'%')
</if>
<if test= "param.warehouseIdList != null and @org.apache.commons.collections4.CollectionUtils@isNotEmpty(param.warehouseIdList)" >
and lddl.warehouse_id in
<foreach collection= "param.warehouseIdList" item= "item" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "param.warehouseName != null and param.warehouseName!=''" >
and lddl.warehouse_name like concat('%',#{param.warehouseName},'%')
</if>
<if test= "param.clineName != null and param.clineName!=''" >
and a.consignee like concat('%',#{param.clineName},'%')
</if>
<if test= "param.mallName != null and param.mallName!=''" >
and a.mall_name like concat('%',#{param.mallName},'%')
</if>
<if test= "param.vehicleName != null and param.vehicleName!=''" >
and lddl.vehicle_name like concat('%',#{param.vehicleName},'%')
</if>
<if test= "param.driverName != null and param.driverName!=''" >
and lddl.driver_name like concat('%',#{param.driverName},'%')
</if>
<if test= "param.loadingTeamName != null and param.loadingTeamName!=''" >
and lddl.loading_team_name like concat('%',#{param.loadingTeamName},'%')
</if>
<if test= "param.orderCode != null and param.orderCode!=''" >
and y.order_code like concat('%',#{param.orderCode},'%')
</if>
<if test= "param.kind != null and param.kind!=''" >
and lddl.kind = #{param.kind}
</if>
<if test= "param.distributionCompany != null and param.distributionCompany!=''" >
and lddl.distribution_company = #{param.distributionCompany}
</if>
<if test= "param.type != null and param.type!=''" >
and lddl.type = #{param.type}
</if>
<if test= "param.deliveryStatus != null and param.deliveryStatus!=''" >
and lddl.delivery_status = #{param.deliveryStatus}
</if>
<if test= "param.createTime_query!=null and param.createTime_query!=''" >
and date_format(lddl.create_time,'%y%m%d%') = date_format(#{param.createTime_query},'%y%m%d%')
</if>
<if test= "param.leadTime!=null and param.leadTime!=''" >
and date_format(lddl.lead_time,'%y%m%d%') = date_format(#{param.leadTime},'%y%m%d%')
</if>
<if test= "param.loadingTime!=null and param.loadingTime!=''" >
and date_format(lddl.loading_time,'%y%m%d%') = date_format(#{param.loadingTime},'%y%m%d%')
</if>
<if test= "param.taskTime!=null and param.taskTime!=''" >
and date_format(lddl.task_time,'%y%m%d%') = date_format(#{param.taskTime},'%y%m%d%')
</if>
<if test= "param.taskTimeStart!=null and param.taskTimeStart!=''" >
and date_format(lddl.task_time,'%y%m%d%') BETWEEN #{param.taskTimeStart} AND #{param.taskTimeEnd}
</if>
</where>
GROUP BY lddl.id ,
lddl.train_number,
lddl.warehouse_name ,
lddl.warehouse_id ,
lddl.type ,
lddl.kind ,
lddl.vehicle_name ,
lddl.driver_name ,
lddl.vehicle_id ,
lddl.driver_id ,
lddl.distribution_company ,
lddl.delivery_status ,
lddl.delivery_list_loading_status
ORDER BY
lddl.create_time DESC
</select>
<select id= "selectBycommercialNub" resultType= "java.lang.Integer" >
SELECT COALESCE(COUNT(*), 0) FROM logpm_distribution_delivery_list lddl