@ -67,7 +67,7 @@
update logpm_distribution_stock_article
set hand_quantity = hand_quantity - #{allNum}
where id = #{articleId}
and hand_quantity - #{allNum} >= 0
and hand_quantity - #{allNum} >= 0
</update>
<select id= "likeOrderSelfNumbering" resultMap= "distributionStockArticleResultMap" >
@ -360,47 +360,47 @@
<select id= "fingListByServiceNumber" resultType= "java.util.Map" >
SELECT ldsa.service_number serviceNum,
ldsa.order_code orderCode,
1 goodsType,
ldsa.total_number totalNum,
count(ldpl.id) num
ldsa.order_code orderCode,
1 goodsType,
ldsa.total_number totalNum,
count(ldpl.id) num
FROM logpm_distribution_stock_article ldsa
left join logpm_distribution_parcel_list ldpl on ldpl.stock_article_id = ldsa.id
left join logpm_warehouse_tray_goods lwtg
on ldpl.order_package_code = lwtg.association_value and lwtg.association_type = 3
left join logpm_warehouse_updown_goods lwug
on ldpl.order_package_code = lwug.association_value and lwug.association_type = 3
left join logpm_distribution_parcel_list ldpl on ldpl.stock_article_id = ldsa.id
left join logpm_warehouse_tray_goods lwtg
on ldpl.order_package_code = lwtg.association_value and lwtg.association_type = 3
left join logpm_warehouse_updown_goods lwug
on ldpl.order_package_code = lwug.association_value and lwug.association_type = 3
WHERE ldsa.is_deleted = 0
AND ldsa.service_number = #{serviceNumber}
AND ldsa.warehouse_id = #{warehouseId}
and lwtg.id is null
and lwug.id is null
AND ldsa.service_number = #{serviceNumber}
AND ldsa.warehouse_id = #{warehouseId}
and lwtg.id is null
and lwug.id is null
group by ldsa.service_number,
ldsa.order_code,
ldsa.total_number
ldsa.order_code,
ldsa.total_number
HAVING count(ldpl.id) > 0
</select>
<select id= "findShelfNumByOrderCodeAndWarehouseId" resultType= "java.util.Map" >
SELECT ldsa.service_number serviceNum,
ldsa.order_code orderCode,
1 goodsType,
ldsa.total_number totalNum,
count(ldpl.id) num
ldsa.order_code orderCode,
1 goodsType,
ldsa.total_number totalNum,
count(ldpl.id) num
FROM logpm_distribution_stock_article ldsa
left join logpm_distribution_parcel_list ldpl on ldpl.stock_article_id = ldsa.id
left join logpm_warehouse_tray_goods lwtg
on ldpl.order_package_code = lwtg.association_value and lwtg.association_type = 3
left join logpm_warehouse_updown_goods lwug
on ldpl.order_package_code = lwug.association_value and lwug.association_type = 3
left join logpm_distribution_parcel_list ldpl on ldpl.stock_article_id = ldsa.id
left join logpm_warehouse_tray_goods lwtg
on ldpl.order_package_code = lwtg.association_value and lwtg.association_type = 3
left join logpm_warehouse_updown_goods lwug
on ldpl.order_package_code = lwug.association_value and lwug.association_type = 3
WHERE ldsa.is_deleted = 0
AND ldsa.order_code = #{orderCode}
AND ldsa.warehouse_id = #{warehouseId}
and lwtg.id is null
and lwug.id is null
AND ldsa.order_code = #{orderCode}
AND ldsa.warehouse_id = #{warehouseId}
and lwtg.id is null
and lwug.id is null
group by ldsa.service_number,
ldsa.order_code,
ldsa.total_number
ldsa.order_code,
ldsa.total_number
HAVING count(ldpl.id) > 0
</select>
@ -757,24 +757,24 @@
</where>
</select>
<select id= "getZeroOrderDetail" resultType= "com.logpm.distribution.vo.DistributionParcelNumberVO" >
SELECT ldpn.id AS id,
ldpn.stock_article_id AS stockArticleId,
ldpn.parcel_list_id AS parcelListId,
ldpl.firsts AS firsts,
ldpl.warehouse AS warehouse,
ldpl.order_code AS orderCode,
ldpl.service_number AS serviceNumber,
ldpl.brand_name AS brandName,
ldpn.quantity AS quantity,
ldpn.hand_quantity AS handQuantity,
ldpn.delivery_quantity AS deliveryQuantity,
ldpn.outbound_quantity AS outboundQuantity,
ldpn.signin_quantity AS signinQuantity,
(ldpn.hand_quantity - ldpn.delivery_quantity) AS reservationNum,
ldpn.quantity AS `number`
SELECT ldpn.id AS id,
ldpn.stock_article_id AS stockArticleId,
ldpn.parcel_list_id AS parcelListId,
ldpl.firsts AS firsts,
ldpl.warehouse AS warehouse,
ldpl.order_code AS orderCode,
ldpl.service_number AS serviceNumber,
ldpl.brand_name AS brandName,
ldpn.quantity AS quantity,
ldpn.hand_quantity AS handQuantity,
ldpn.delivery_quantity AS deliveryQuantity,
ldpn.outbound_quantity AS outboundQuantity,
ldpn.signin_quantity AS signinQuantity,
(ldpn.hand_quantity - ldpn.delivery_quantity) AS reservationNum,
ldpn.quantity AS `number`
FROM logpm_distribution_stock_article AS ldsa
LEFT JOIN logpm_distribution_parcel_list AS ldpl ON ldsa.id = ldpl.stock_article_id
LEFT JOIN logpm_distribution_parcel_number AS ldpn ON ldpn.parcel_list_id = ldpl.id
LEFT JOIN logpm_distribution_parcel_list AS ldpl ON ldsa.id = ldpl.stock_article_id
LEFT JOIN logpm_distribution_parcel_number AS ldpn ON ldpn.parcel_list_id = ldpl.id
WHERE ldsa.id = #{stockArticleId}
</select>
<select id= "exportDistributionStockArticle"
@ -922,21 +922,21 @@
update logpm_distribution_stock_article
set grounding_status = #{groundingStatus}
where order_code = #{orderCode}
AND warehouse_id = #{warehouseId}
AND warehouse_id = #{warehouseId}
</update>
<update id= "submitHandleNumByOrderId" >
update logpm_distribution_stock_article
set hand_quantity = hand_quantity - #{subNum}
where id = #{articleId}
and hand_quantity - #{subNum} > = 0
and hand_quantity - #{subNum} > = 0
</update>
<update id= "updateCustomerInfoByOrderCode" >
update logpm_distribution_stock_article
set customer_name = #{customerName},
customer_telephone = #{customerPhone},
customer_address = #{customerRoad}
set customer_name = #{customerName},
customer_telephone = #{customerPhone},
customer_address = #{customerRoad}
where order_code = #{orderCode}
</update>
@ -949,15 +949,15 @@
UPDATE logpm_distribution_stock_article
SET hand_quantity = (hand_quantity - 1)
WHERE id = #{orderId}
AND is_deleted = 0
AND hand_quantity >= 0
AND is_deleted = 0
AND hand_quantity >= 0
</update>
<update id= "augmentHandQuantity" >
UPDATE logpm_distribution_stock_article
SET hand_quantity = (hand_quantity + #{augmentNum})
WHERE id = #{orderId}
AND is_deleted = 0
AND hand_quantity >= 0
AND is_deleted = 0
AND hand_quantity >= 0
</update>
@ -965,7 +965,7 @@
update logpm_distribution_stock_article
set incoming_num = incoming_num + #{num}
where id = #{orderId}
and incoming_num + #{num} < = total_number
and incoming_num + #{num} < = total_number
</update>
<update id= "augmentDeliveryQuantity" >
UPDATE logpm_distribution_stock_article
@ -974,44 +974,44 @@
</update>
<select id= "findZeroListByWarehouseId" resultType= "com.alibaba.fastjson.JSONObject" >
select ldsa.waybill_number waybillNo,
ldsa.order_code orderCode,
lww.create_time createTime,
lww.destination destination,
lww.destination_warehouse_name destinationWarehouseName,
lww.shipper shipper,
lww.shipper_name shipperName,
lww.consignee consignee,
lww.consignee_name consigneeName,
lww.goods_name goodsName,
lww.total_count totalNum,
lww.total_weight weight,
lww.total_volume volume,
ldsa.hand_quantity stockNum,
lww.customer_train customerTrain,
lww.total_freight,
lww.total_count,
lww.remark remark,
ROUND(lww.total_freight / lww.total_count, 2) price
select ldsa.waybill_number waybillNo,
ldsa.order_code orderCode,
lww.create_time createTime,
lww.destination destination,
lww.destination_warehouse_name destinationWarehouseName,
lww.shipper shipper,
lww.shipper_name shipperName,
lww.consignee consignee,
lww.consignee_name consigneeName,
lww.goods_name goodsName,
lww.total_count totalNum,
lww.total_weight weight,
lww.total_volume volume,
ldsa.hand_quantity stockNum,
lww.customer_train customerTrain,
lww.total_freight,
lww.total_count,
lww.remark remark,
ROUND(lww.total_freight / lww.total_count, 2) price
from logpm_distribution_stock_article ldsa
left join logpm_warehouse_waybill lww on lww.waybill_no = ldsa.waybill_number
left join logpm_warehouse_waybill lww on lww.waybill_no = ldsa.waybill_number
where ldsa.is_zero = 1
and ldsa.warehouse_id = #{warehouseId}
and ldsa.warehouse_id = #{warehouseId}
</select>
<select id= "getStockArticleQueryQuantity" resultType= "com.logpm.distribution.entity.DistributionStockArticleEntity" >
select sum((
select COUNT(ldl.id)
from logpm_distribution_loadscan ldl
where ldl.package_id = ldpl.id
and ldl.signfor_state = 2
)) signinQuantity,
sum((
select COUNT(ldl.id)
from logpm_distribution_loadscan ldl
where ldl.package_id = ldpl.id
and ldl.signfor_state = 1
)) deliveryQuantity
select COUNT(ldl.id)
from logpm_distribution_loadscan ldl
where ldl.package_id = ldpl.id
and ldl.signfor_state = 2
)) signinQuantity,
sum((
select COUNT(ldl.id)
from logpm_distribution_loadscan ldl
where ldl.package_id = ldpl.id
and ldl.signfor_state = 1
)) deliveryQuantity
from logpm_distribution_parcel_list ldpl
where ldpl.stock_article_id = #{id}
</select>
@ -1120,52 +1120,52 @@
</select>
<select id= "findUpDownStockupZeroByOrderCodeAndWarehouseId"
resultType="com.logpm.distribution.vo.UpDownStockupAreaVO">
SELECT ldsa.waybill_number AS waybillCode,
0 AS enterNum,
ldsa.mall_id AS marketId,
ldsa.mall_name AS marketName,
1 AS associationType,
ldsa.order_code AS associationValue,
ldsa.order_code AS orderCode,
ldsa.id AS orderId,
ldsa.id AS associationId,
ldsa.total_number AS num,
2 AS goods_type,
#{warehouseId} AS warehouseId,
ldsa.description_goods AS goodsName
SELECT ldsa.waybill_number AS waybillCode,
0 AS enterNum,
ldsa.mall_id AS marketId,
ldsa.mall_name AS marketName,
1 AS associationType,
ldsa.order_code AS associationValue,
ldsa.order_code AS orderCode,
ldsa.id AS orderId,
ldsa.id AS associationId,
ldsa.total_number AS num,
2 AS goods_type,
#{warehouseId} AS warehouseId,
ldsa.description_goods AS goodsName
FROM logpm_distribution_stock_article AS ldsa
WHERE ldsa.order_code = #{orderCode}
AND ldsa.warehouse_id = #{warehouseId}
AND ldsa.warehouse_id = #{warehouseId}
</select>
<select id= "getOrderListByWaybill"
resultType="java.lang.Long">
SELECT id
FROM logpm_distribution_stock_article
WHERE FIND_IN_SET(#{waybillNumber}, waybill_number) > 0
AND waybill_number is not null
AND waybill_number != ''
AND waybill_number is not null
AND waybill_number != ''
</select>
<update id= "submitHandleNumAndTotalNumberByOrderId" >
update logpm_distribution_stock_article
set total_number = total_number - #{subNum},
hand_quantity = hand_quantity - #{subNum},
incoming_num = incoming_num - #{subNum}
set total_number = total_number - #{subNum},
hand_quantity = hand_quantity - #{subNum},
incoming_num = incoming_num - #{subNum}
where id = #{articleId}
</update>
<select id= "findShowOrderCodeData" resultType= "com.alibaba.fastjson.JSONObject" >
select ldsa.order_code orderCode,
ldsa.consignee_unit consigneeUnit,
ldsa.consignee_person consigneePerson,
ldsa.consignee_mobile consigneeMobile,
ldsa.waybill_number waybillNo,
ldsa.total_number totalNumber,
ldsa.description_goods descriptionGoods,
ldsa.customer_name customerName,
ldsa.customer_telephone customerTelephone,
ldsa.customer_address customerAddress,
IFNULL(ldsa.remark, '') remark
select ldsa.order_code orderCode,
ldsa.consignee_unit consigneeUnit,
ldsa.consignee_person consigneePerson,
ldsa.consignee_mobile consigneeMobile,
ldsa.waybill_number waybillNo,
ldsa.total_number totalNumber,
ldsa.description_goods descriptionGoods,
ldsa.customer_name customerName,
ldsa.customer_telephone customerTelephone,
ldsa.customer_address customerAddress,
IFNULL(ldsa.remark, '') remark
from logpm_distribution_stock_article ldsa
where ldsa.id = #{orderId}
</select>
@ -1174,112 +1174,77 @@
ldsa.id AS id,
ldsa.waybill_number AS waybillNumber,
ldsa.service_number AS serviceNumber,
ldsa.order_code orderCode,
ldsa.mall_name mallName,
ldsa.warehouse warehouseName,
ldsa.warehouse_entry_time warehouseEntryTime,
ldsa.consignee_unit consigneeUnit,
ldsa.consignee_person consigneePerson,
ldsa.total_number totalNumber,
ldsa.hand_quantity handQuantity,
ldsa.brand brand,
CASE ldsa.order_status
WHEN 70 THEN '部分签收'
WHEN 80 THEN '已签收'
ELSE
'未知'
END orderStatusName,
CASE ldsa.is_zero
WHEN 0 THEN '否'
WHEN 1 THEN '是'
ELSE
'未知'
END isZeroName,
CASE ldsa.reservation_status
WHEN 10 THEN '待预约'
WHEN 20 THEN '部分预约'
WHEN 30 THEN '已预约'
END orderReservationStatusName,
CASE ldsa.is_zero
WHEN 0 THEN IF(ldsa.total_number =(SELECT SUM(quantity) FROM logpm_distribution_parcel_list WHERE
stock_article_id = ldsa.id),'是','否')
WHEN 1 THEN IF(ldsa.total_number =(SELECT SUM(quantity) FROM logpm_distribution_parcel_number WHERE
stock_article_id = ldsa.id),'是','否')
END isCompleteSet,
CASE ldsa.type_service
WHEN 1 THEN '商配'
WHEN 2 THEN '市配'
WHEN 3 THEN '自提'
WHEN 4 THEN '三方中转'
END typeServiceName,
IFNULL(( SELECT SUM( loaded_nub ) FROM logpm_distribution_loadscan WHERE order_id = ldsa.id AND scan_status != 1
), 0 ) AS deliveryNumber,
IFNULL(( SELECT SUM( received_quantity ) FROM logpm_distribution_loadscan WHERE order_id = ldsa.id AND
scan_status != 1 ), 0 ) AS signForNumber,
IFNULL(( SELECT SUM( stock_quantity ) FROM logpm_distribution_stock WHERE stock_article = ldsa.id ), 0 ) AS
ldsa.order_code AS orderCode,
ldsa.mall_name AS mallName,
ldsa.warehouse AS warehouseName,
ldsa.consignee_unit AS consigneeUnit,
ldsa.consignee_person AS consigneePerson,
ldsa.total_number AS totalNumber,
ldsa.hand_quantity AS handQuantity,
ldsa.brand AS brand,
ldsa.delivery_quantity as deliveryNumber,
ldsa.signin_quantity AS signForNumber,
IFNULL((SELECT sum(stock_quantity) FROM logpm_distribution_stock WHERE stock_article = ldsa.id),0) AS
stockUpNumber,
IFNULL(( SELECT SUM( reservation_num ) FROM logpm_distribution_reservation_stockarticle WHERE stock_article_id =
ldsa.id AND stock_article_status!= 2), 0 ) AS reservationNumber,
IF(GROUP_CONCAT(t.msg) is not null,GROUP_CONCAT(t.msg),IFNULL(GROUP_CONCAT(y.msg),null)) AS reservationInfo,
GROUP_CONCAT(DISTINCT IFNULL( m.mssg,'')) AS deliveryListInfo,
ldsa.create_time As createTime,
ldsa.create_user As createUser,
m.signing_time AS signinTime,
GROUP_CONCAT(DISTINCT IFNULL( m.driverName,'')) AS driverName,
GROUP_CONCAT(DISTINCT IFNULL( m.vehicleName,'')) AS vehicleName,
GROUP_CONCAT(DISTINCT IFNULL( m.examine_user_name,'')) AS examineUserNames,
k.earliestWarehouseEntryTime AS earliestWarehouseEntryTime,
GROUP_CONCAT(t.reservation_id) AS reservationIds,
j.scanSigningTime AS scanSigningTime
FROM
logpm_distribution_stock_article AS ldsa
LEFT JOIN (
SELECT
ldrs.stock_article_id,
ldr.id AS reservation_id,
CONCAT( ldr.reservation_code, '(', ldrs.reservation_num, ')' ) AS msg
FROM
logpm_distribution_reservation_stockarticle AS ldrs
LEFT JOIN logpm_distribution_reservation ldr ON ldrs.reservation_id = ldr.id
AND ldrs.stock_article_status != 2
AND ldr.reservation_status != 40
AND (ldr.reservation_num + ldr.reservation_stock_list_num) > 0
) AS t ON ldsa.id = t.stock_article_id
LEFT JOIN (
SELECT
ldbs.stock_article_id,
CONCAT( ldbl.pickup_batch, '(', IFNULL( SUM( ldbp.packet_number ), 0 ), ')' ) AS msg
FROM
logpm_distrilbution_bill_stock AS ldbs
LEFT JOIN logpm_distrilbution_bill_lading AS ldbl ON ldbs.bill_lading_id = ldbl.id
LEFT JOIN logpm_distrilbution_bill_package AS ldbp ON ldbp.bill_lading_id = ldbs.bill_lading_id
AND ldbp.stock_article_id = ldbs.stock_article_id
) AS y ON ldsa.id = y.stock_article_id
LEFT JOIN (
SELECT
ldrs.stock_article_id,
ldr.id AS reservation_id,
CONCAT( lddl.train_number, '(', ldrs.reservation_num, ')' ) AS mssg,
CONCAT( lds.examine_user_name ) AS examine_user_name,
CONCAT( lddl.driver_name ) AS driverName,
CONCAT( lddl.vehicle_name ) AS vehicleName,
MAX(lds.signing_time) AS signing_time
ldsa.create_time AS createTime,
ldsa.create_user AS createUser,
CASE
ldsa.order_status
WHEN 70 THEN
'部分签收'
WHEN 80 THEN
'已签收' ELSE '未知'
END AS orderStatusName,
CASE
ldsa.is_zero
WHEN 0 THEN
'否'
WHEN 1 THEN
'是' ELSE '未知'
END AS isZeroName,
CASE
ldsa.reservation_status
WHEN 10 THEN
'待预约'
WHEN 20 THEN
'部分预约'
WHEN 30 THEN
'已预约'
END AS orderReservationStatusName,
CASE
ldsa.is_zero
WHEN 0 THEN
IF
( ldsa.total_number = ( SELECT sum( quantity ) FROM logpm_distribution_parcel_list WHERE stock_article_id =
ldsa.id ), '是', '否' )
WHEN 1 THEN
IF
( ldsa.total_number = ( SELECT sum( quantity ) FROM logpm_distribution_parcel_number WHERE stock_article_id =
ldsa.id ), '是', '否' )
END AS isCompleteSet,
CASE
ldsa.type_service
WHEN 1 THEN
'商配'
WHEN 2 THEN
'市配'
WHEN 3 THEN
'自提'
WHEN 4 THEN
'三方中转'
END AS typeServiceName,
min( ldpl.create_time ) earliestWarehouseEntryTime,
max( ldpl.create_time ) warehouseEntryTime,
MIN( ldl.signing_time ) scanSigningTime,
MAX( ldl.scan_time ) signinTime
FROM
logpm_distribution_reservation_stockarticle AS ldrs
LEFT JOIN logpm_distribution_reservation ldr ON ldrs.reservation_id = ldr.id
AND ldrs.stock_article_status != 2
AND (ldr.reservation_num + ldr.reservation_stock_list_num) > 0
LEFT JOIN
logpm_distribution_signfor As lds ON lds.reservation_id = ldr.id
LEFT JOIN logpm_distribution_delivery_list AS lddl ON lds.delivery_id = lddl.id
GROUP BY ldr.id
) AS m ON ldsa.id = m.stock_article_id AND t.reservation_id = m.reservation_id
LEFT JOIN ( SELECT stock_article_id, min( create_time ) AS earliestWarehouseEntryTime FROM
logpm_distribution_parcel_list GROUP BY stock_article_id) AS k ON k.stock_article_id = ldsa.id
LEFT JOIN ( SELECT order_id, max( signing_time ) AS scanSigningTime FROM logpm_distribution_loadscan WHERE
scan_status != 1 AND signfor_state = 2 GROUP BY order_id ) AS j ON j.order_id = ldsa.id
logpm_distribution_loadscan ldl
LEFT JOIN logpm_distribution_stock_article ldsa ON ldsa.id = ldl.order_id
LEFT JOIN logpm_distribution_parcel_list ldpl ON ldpl.stock_article_id = ldsa.id
left JOIN logpm_distribution_reservation ldr on ldr.id = ldl.reservation_id
<where >
ldsa.order_status in ('70','80')
ldl.signfor_state = 2
and ldsa.order_status in ('70','80')
<if test= "param.waybillNumber != null and param.waybillNumber != ''" >
AND ldsa.waybill_number like concat(#{param.waybillNumber},"%")
</if>
@ -1304,79 +1269,141 @@
<if test= "param.consigneeUnit != null and param.consigneeUnit != ''" >
AND ldsa.consignee_unit like concat(#{param.consigneeUnit},"%")
</if>
<if test= "param.deliveryListInfo != null and param.deliveryListInfo != '' " >
AND m.mssg like concat(#{param.deliveryListInfo},"%" )
<if test= "param.earliestWarehouseEntryTime != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') = date_format(#{param.earliestWarehouseEntryTime},'%y%m%d%' )
</if>
<if test= "param.driverName != null and param.driverName != '' " >
AND m.driverName like concat(#{param.driverName},"%" )
<if test= "param.warehouseEntryTime != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') = date_format(#{param.warehouseEntryTime},'%y%m%d%' )
</if>
<if test= "param.examineUserNames != null and param.examineUserNames != '' " >
AND m.examine_user_name like concat(#{param.examineUserNames},"%" )
<if test= "param.scanSigningTime != null " >
AND date_format(ldl.signing_time ,'%y%m%d%') = date_format(#{param.scanSigningTime},'%y%m%d%' )
</if>
<if test= "param.reservationInfo != null and param.reservationInfo != ''" >
AND t.msg like concat(#{param.reservationInfo},"%")
<if test= "param.warehouseEntryTimeStart != null and param.warehouseEntryTimeEnd != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') BETWEEN date_format(#{param.warehouseEntryTimeStart},'%y%m%d%') AND date_format(#{param.warehouseEntryTimeEnd},'%y%m%d%')
</if>
<if test= "param.warehouseId != null and param.warehouseId != '' " >
AND ldsa.warehouse_id = #{param.warehouseId}
<if test= "param.scanSigningTimeStart != null and param.scanSigningTimeEnd != null " >
AND date_format(ldl.signing_time ,'%y%m%d%') BETWEEN date_format(#{param.scanSigningTimeStart},'%y%m%d%') AND date_format(#{param.scanSigningTimeEnd},'%y%m%d%')
</if>
<if test= "param.warehouseIdList != null and param.warehouseId != ''" >
AND ldsa.warehouse_id IN
<foreach collection= "param.warehouseIdList" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "param.orderCodeNumList != null and param.orderCodeNumList != ''" >
AND ldsa.order_code in
<foreach collection= "param.orderCodeNumList" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "param.waybillNumList != null and param.waybillNumList != ''" >
AND ldsa.waybill_number in
<foreach collection= "param.waybillNumList" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</where>
GROUP BY
ldl.order_id,ldl.reservation_id
UNION ALL
SELECT
ldsa.id AS id,
ldsa.waybill_number AS waybillNumber,
ldsa.service_number AS serviceNumber,
ldsa.order_code AS orderCode,
ldsa.mall_name AS mallName,
ldsa.warehouse AS warehouseName,
ldsa.consignee_unit AS consigneeUnit,
ldsa.consignee_person AS consigneePerson,
ldsa.total_number AS totalNumber,
ldsa.hand_quantity AS handQuantity,
ldsa.brand AS brand,
ldsa.delivery_quantity as deliveryNumber,
ldsa.signin_quantity AS signForNumber,
IFNULL((SELECT sum(stock_quantity) FROM logpm_distribution_stock WHERE stock_article = ldsa.id),0) AS
stockUpNumber,
ldsa.create_time AS createTime,
ldsa.create_user AS createUser,
CASE
ldsa.order_status
WHEN 70 THEN
'部分签收'
WHEN 80 THEN
'已签收' ELSE '未知'
END AS orderStatusName,
CASE
ldsa.is_zero
WHEN 0 THEN
'否'
WHEN 1 THEN
'是' ELSE '未知'
END AS isZeroName,
CASE
ldsa.reservation_status
WHEN 10 THEN
'待预约'
WHEN 20 THEN
'部分预约'
WHEN 30 THEN
'已预约'
END AS orderReservationStatusName,
CASE
ldsa.is_zero
WHEN 0 THEN
IF
( ldsa.total_number = ( SELECT sum( quantity ) FROM logpm_distribution_parcel_list WHERE stock_article_id =
ldsa.id ), '是', '否' )
WHEN 1 THEN
IF
( ldsa.total_number = ( SELECT sum( quantity ) FROM logpm_distribution_parcel_number WHERE stock_article_id =
ldsa.id ), '是', '否' )
END AS isCompleteSet,
CASE
ldsa.type_service
WHEN 1 THEN
'商配'
WHEN 2 THEN
'市配'
WHEN 3 THEN
'自提'
WHEN 4 THEN
'三方中转'
END AS typeServiceName,
min( ldpl.create_time ) earliestWarehouseEntryTime,
max( ldpl.create_time ) warehouseEntryTime,
MIN( ldbls.create_time ) scanSigningTime,
MAX( ldbls.create_time ) signinTime
FROM
logpm_distribution_bill_lading_scan AS ldbls
LEFT JOIN logpm_distribution_stock_article ldsa ON ldsa.id = ldbls.stock_article_id
LEFT JOIN logpm_distribution_parcel_list ldpl ON ldpl.stock_article_id = ldsa.id
LEFT JOIN logpm_distrilbution_bill_lading AS ldbl ON ldbls.bill_lading_id = ldbl.id
<where >
ldsa.order_status in ('70','80')
<if test= "param.waybillNumber != null and param.waybillNumber != ''" >
AND ldsa.waybill_number like concat(#{param.waybillNumber},"%")
</if>
<if test= " param.startDate != null " > and ldsa.warehouse_entry_time between #{param.startDate} and
#{param.entDate}
<if test= "param.serviceNumber != null and param.serviceNumber != ''" >
AND ldsa.service_number like concat(#{param.serviceNumber},"%")
</if>
<if test= " param.warehouseEntryTime != null " > and DATE(ldsa.warehouse_entry_time) =
#{param.warehouseEntryTime}
<if test= "param.orderCode != null and param.orderCode != ''" >
AND ldsa.order_code like concat(#{param.orderCode},"%")
</if>
<if test= " param.createTime != null " > and DATE(ldsa.create_time) =
#{param.createTime}
<if test= "param.warehouseName != null and param.warehouseName != ''" >
AND ldsa.warehouse like concat(#{param.warehouseName},"%")
</if>
<if test= " param.signinTime != null " > and DATE(m.signing_time) =
#{param.signinTime}
<if test= "param.mallName != null and param.mallName != ''" >
AND ldsa.mall_name like concat(#{param.mallName},"%")
</if>
<if test= " param.earliestWarehouseEntryTime != null " > and DATE(k.earliestWarehouseEntryTime) =
#{param.earliestWarehouseEntryTime}
<if test= "param.brand != null and param.brand != ''" >
AND ldsa.brand like concat("%",#{param.brand},"%")
</if>
<if test= " param.scanSigningTime != null " > and DATE(j.scanSigningTime) =
#{param.scanSigningTime}
<if test= "param.consigneePerson != null and param.consigneePerson != ''" >
AND ldsa.consignee_person like concat(#{param.consigneePerson},"%")
</if>
<if test= " param.warehouseEntryTimeStart != null " > and DATE(k.earliestWarehouseEntryTime) >
#{param.warehouseEntryTimeStart}
<if test= "param.consigneeUnit != null and param.consigneeUnit != ''" >
AND ldsa.consignee_unit like concat(#{param.consigneeUnit},"%")
</if>
<if test= " param.warehouseEntryTimeEnd != null " > and DATE(k.earliestWarehouseEntryTime) <
#{param.warehouseEntryTimeEnd}
<if test= "param.earliestWarehouseEntryTime != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') = date_format(#{param.earliestWarehouseEntryTime},'%y%m%d%')
</if>
<if test= " param.signingTimeStart != null " > and DATE(m.signing_time) > =
#{param.signingTimeStart}
<if test= "param.warehouseEntryTime != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') = date_format(#{param.warehouseEntryTime},'%y%m%d%')
</if>
<if test= " param.signingTimeEnd != null " > and DATE(m.signing_time) < =
#{param.signingTimeEnd}
<if test= "param.scanS igningTime != null " >
AND date_format(ldbls.create_time ,'%y%m%d%') = date_format(#{param.scanSigningTime},'%y%m%d%')
</if>
<if test= " param.scanSigningTimeStart != null " > and DATE(j.scanSigningTime) > =
#{param.scanSigningTimeStart}
<if test= "param.warehouseEntryTimeStart != null and param.warehouseEntryTimeEnd != null " >
AND date_format(ldpl.create_time ,'%y%m%d%') BETWEEN date_format(#{param.warehouseEntryTimeStart},'%y%m%d%') AND date_format(#{param.warehouseEntryTimeEnd},'%y%m%d%')
</if>
<if test= " param.scanSigningTimeEnd != null " > and DATE(j.scanSigningTime) < =
#{param.scanSigningTimeEnd}
<if test= "param.scanSigningTimeStart != null and param.scanSigningTimeEnd != null " >
AND date_format(ldbls.create_time ,'%y%m%d%') BETWEEN date_format(#{param.scanSigningTimeStart},'%y%m%d%') AND date_format( #{param.scanSigningTimeEnd},'%y%m%d%')
</if>
</where>
GROUP BY
ldsa.id
ldbl s.stock_ article_id,ldbls .bill_lading_ id
</select>
<select id= "selectAdvance" resultType= "java.util.Map" >
SELECT dealer_name, dealer_code
@ -1392,9 +1419,9 @@
<update id= "updateCustomerAllByOrderCode" >
update logpm_distribution_stock_article
set
customer_name = #{data.customerName},
customer_telephone=#{data.customerPhone},
customer_address=#{data.customerAddress}
customer_name = #{data.customerName},
customer_telephone=#{data.customerPhone},
customer_address=#{data.customerAddress}
where reservation_status = '10'
<if test= "data.orderCode != null and data.orderCode != ''" >
and order_code = #{data.orderCode}
@ -1437,6 +1464,29 @@
#{item}
</foreach>
</select>
<select id= "signforListDetail" resultType= "com.logpm.distribution.vo.DistributionSignforStockArticleVO" >
SELECT
ldr.id,
ldr.reservation_code,
ldrs.reservation_num,
lds.examine_user_name AS '审核人',
lds.signing_time AS '审核时间',
lddl.train_number,
lddl.vehicle_name,
lddl.driver_name
FROM
logpm_distribution_reservation_stockarticle AS ldrs
LEFT JOIN logpm_distribution_reservation AS ldr ON ldrs.reservation_id = ldr.id
LEFT JOIN logpm_distribution_signfor AS lds ON ldr.id = lds.reservation_id
LEFT JOIN logpm_distribution_delivery_list AS lddl ON lds.delivery_id = lddl.id
WHERE
ldrs.stock_article_id = #{orderId}
AND ldrs.is_deleted = 0
AND ldrs.stock_article_status != 2
AND lds.signing_status = 2
GROUP BY
ldrs.reservation_id
</select>
</mapper>