|
|
@@ -5,117 +5,169 @@
|
|
|
<select id="queryPickingBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
select poi.area_staff_id as areaStaffId, pod.goods_id as goodsId, SUM(pod.picking_number) as totalNum
|
|
|
from yr_picking_order_detail as pod
|
|
|
- left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
+ left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
where
|
|
|
poi.picking_time is not null
|
|
|
and poi.picking_time between #{beginTime} and #{endTime}
|
|
|
and pod.is_aggregation = 0
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and poi.area_staff_id in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by poi.area_staff_id, pod.goods_id
|
|
|
</select>
|
|
|
|
|
|
<select id="queryAggregationBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
- select api.area_staff_id as areaStaffId,
|
|
|
- apd.goods_id as goodsId,
|
|
|
- IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
|
|
|
+ select api.area_staff_id as areaStaffId,
|
|
|
+ apd.goods_id as goodsId,
|
|
|
+ IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
|
|
|
from yr_aggregation_pick_detail as apd
|
|
|
- left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
+ left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
where
|
|
|
- api.picking_time is not null
|
|
|
+ api.picking_time is not null
|
|
|
and api.picking_time between #{beginTime} and #{endTime}
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and api.area_staff_id in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by api.area_staff_id, apd.goods_id
|
|
|
</select>
|
|
|
|
|
|
<select id="queryUnOutStockCancelNum"
|
|
|
resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
- with cancel_data as (select poi.area_staff_id as areaStaffId,
|
|
|
- pod.goods_id as goodsId,
|
|
|
- IFNULL(SUM(pod.picking_number), 0) as pickingNumber
|
|
|
- from yr_picking_order_detail as pod
|
|
|
- left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
- where poi.modify_time between #{beginTime} and #{endTime}
|
|
|
- and pod.is_aggregation = 0
|
|
|
- and poi.picking_status = 3
|
|
|
- group by poi.area_staff_id, pod.goods_id
|
|
|
- union all
|
|
|
- select api.area_staff_id as areaStaffId,
|
|
|
- apd.goods_id as goodsId,
|
|
|
- IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
|
|
|
- from yr_aggregation_pick_detail as apd
|
|
|
- left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
- where api.modify_time between #{beginTime} and #{endTime}
|
|
|
- and api.status = 'CANCEL')
|
|
|
+ with cancel_data as (select poi.area_staff_id as areaStaffId,
|
|
|
+ pod.goods_id as goodsId,
|
|
|
+ IFNULL(SUM(pod.picking_number), 0) as pickingNumber
|
|
|
+ from yr_picking_order_detail as pod
|
|
|
+ left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
+ where poi.modify_time between #{beginTime} and #{endTime}
|
|
|
+ and pod.is_aggregation = 0
|
|
|
+ and poi.picking_status = 3
|
|
|
+ group by poi.area_staff_id, pod.goods_id
|
|
|
+ union all
|
|
|
+ select api.area_staff_id as areaStaffId,
|
|
|
+ apd.goods_id as goodsId,
|
|
|
+ IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
|
|
|
+ from yr_aggregation_pick_detail as apd
|
|
|
+ left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
+ where api.modify_time between #{beginTime} and #{endTime}
|
|
|
+ and api.status = 'CANCEL')
|
|
|
select areaStaffId, goodsId, sum(pickingNumber) as totalNum
|
|
|
from cancel_data
|
|
|
where areaStaffId IS NOT NULL
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by areaStaffId, goodsId
|
|
|
</select>
|
|
|
<select id="queryOutStockCancelNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
- with cancel_data as (select poi.area_staff_id as areaStaffId,
|
|
|
- pod.goods_id as goodsId,
|
|
|
- IFNULL(SUM(pod.picking_number), 0) as pickingNumber
|
|
|
- from yr_picking_order_detail as pod
|
|
|
- left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
- where poi.modify_time between #{beginTime} and #{endTime}
|
|
|
- and pod.is_aggregation = 0
|
|
|
- and poi.picking_status = 4
|
|
|
- group by poi.area_staff_id, pod.goods_id
|
|
|
- union all
|
|
|
- select api.area_staff_id as areaStaffId,
|
|
|
- apd.goods_id as goodsId,
|
|
|
- IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
|
|
|
- from yr_aggregation_pick_detail as apd
|
|
|
- left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
- where api.modify_time between #{beginTime} and #{endTime}
|
|
|
- and api.status = 'OUT_CANCEL')
|
|
|
+ with cancel_data as (select poi.area_staff_id as areaStaffId,
|
|
|
+ pod.goods_id as goodsId,
|
|
|
+ IFNULL(SUM(pod.picking_number), 0) as pickingNumber
|
|
|
+ from yr_picking_order_detail as pod
|
|
|
+ left join yr_picking_order_info as poi on pod.order_number = poi.order_number
|
|
|
+ where poi.modify_time between #{beginTime} and #{endTime}
|
|
|
+ and pod.is_aggregation = 0
|
|
|
+ and poi.picking_status = 4
|
|
|
+ group by poi.area_staff_id, pod.goods_id
|
|
|
+ union all
|
|
|
+ select api.area_staff_id as areaStaffId,
|
|
|
+ apd.goods_id as goodsId,
|
|
|
+ IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
|
|
|
+ from yr_aggregation_pick_detail as apd
|
|
|
+ left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
|
|
|
+ where api.modify_time between #{beginTime} and #{endTime}
|
|
|
+ and api.status = 'OUT_CANCEL')
|
|
|
select areaStaffId, goodsId, sum(pickingNumber) as totalNum
|
|
|
from cancel_data
|
|
|
where areaStaffId IS NOT NULL
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by areaStaffId, goodsId
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDriverReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
+ with replenish_data as (
|
|
|
select
|
|
|
- IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as areaStaffId,
|
|
|
- rod.goods_id as goodsId,
|
|
|
- sum(rod.real_picking_number) as totalNum
|
|
|
+ IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as
|
|
|
+ areaStaffId,
|
|
|
+ rod.goods_id as goodsId,
|
|
|
+ sum(rod.real_picking_number) as totalNum
|
|
|
from yr_replenish_order_detail as rod
|
|
|
- left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
|
|
|
- left join (select id, accountId
|
|
|
- from yr_operators_area_staff
|
|
|
- where isDelete = 'NORMAL'
|
|
|
- group by accountId) as oas on roi.replenish_user_id = oas.accountId
|
|
|
+ left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
|
|
|
+ left join (select id, accountId
|
|
|
+ from yr_operators_area_staff
|
|
|
+ where isDelete = 'NORMAL'
|
|
|
+ group by accountId) as oas on roi.replenish_user_id = oas.accountId
|
|
|
where roi.replenish_time between #{beginTime} and #{endTime}
|
|
|
- and roi.replenish_status = 2
|
|
|
+ and roi.replenish_status = 2
|
|
|
group by oas.id, rod.goods_id
|
|
|
+ )
|
|
|
+ select rd.areaStaffId as areaStaffId,
|
|
|
+ rd.goodsId as goodsId,
|
|
|
+ rd.totalNum as totalNum
|
|
|
+ from replenish_data as rd
|
|
|
+ <where>
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and rd.areaStaffId in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDeviceReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
select
|
|
|
- IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as areaStaffId,
|
|
|
- sum(rod.real_picking_number) as totalNum
|
|
|
+ IF(roi.replenish_user_id != roi.replenish_account_id, IFNULL(oas.id, roi.area_staff_id), roi.area_staff_id) as
|
|
|
+ areaStaffId,
|
|
|
+ sum(rod.real_picking_number) as totalNum
|
|
|
from yr_replenish_order_detail as rod
|
|
|
- left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
|
|
|
- left join (select id, accountId
|
|
|
- from yr_operators_area_staff
|
|
|
- where isDelete = 'NORMAL'
|
|
|
- group by accountId) as oas on roi.replenish_user_id = oas.accountId
|
|
|
+ left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
|
|
|
+ left join (select id, accountId
|
|
|
+ from yr_operators_area_staff
|
|
|
+ where isDelete = 'NORMAL'
|
|
|
+ group by accountId) as oas on roi.replenish_user_id = oas.accountId
|
|
|
where roi.replenish_time between #{beginTime} and #{endTime}
|
|
|
- and roi.replenish_status = 2
|
|
|
- and rod.real_picking_number > 0
|
|
|
+ and roi.replenish_status = 2
|
|
|
+ and rod.real_picking_number > 0
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and roi.area_staff_id in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by roi.area_staff_id
|
|
|
</select>
|
|
|
|
|
|
<select id="queryDriverReturnNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
|
|
|
select oas.id as areaStaffId, wbod.productSpecId as goodsId, wbod.realBackNumber as totalNum
|
|
|
from yr_warehouse_back_order_detail as wbod
|
|
|
- left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
|
|
|
- left join (select id, accountId
|
|
|
- from yr_operators_area_staff
|
|
|
- where isDelete = 'NORMAL'
|
|
|
- group by accountId) as oas on oas.accountId = wboi.replenishId
|
|
|
+ left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
|
|
|
+ left join (select id, accountId
|
|
|
+ from yr_operators_area_staff
|
|
|
+ where isDelete = 'NORMAL'
|
|
|
+ group by accountId) as oas on oas.accountId = wboi.replenishId
|
|
|
where wboi.backTime between #{beginTime} and #{endTime}
|
|
|
- and wboi.backStatus = 'BACK_SUCCESS'
|
|
|
- and wboi.sourceBack = 'DRIVER'
|
|
|
+ and wboi.backStatus = 'BACK_SUCCESS'
|
|
|
+ and wboi.sourceBack = 'DRIVER'
|
|
|
+ <if test="areaStaffIds != null and areaStaffIds.size > 0">
|
|
|
+ <foreach collection="areaStaffIds" item="areaStaffId" open="and oas.id in (" separator=","
|
|
|
+ close=")">
|
|
|
+ #{areaStaffId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
group by wboi.replenishId, wbod.productSpecId
|
|
|
</select>
|
|
|
<select id="queryDriverDeviceInventoryNum"
|