Forráskód Böngészése

[update] 日统计司机设备回仓错误问题修复

miajio 2 hete
szülő
commit
97e6b9c264

+ 30 - 7
warehouse-admin-data/src/main/resources/mapper/statistics/BillingQuantityStatisticsMapper.xml

@@ -92,13 +92,36 @@
     </select>
 
     <select id="queryDriverReturnNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
-        select oas.id as areaStaffId, wbod.productSpecId as goodsId, SUM(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 yr_operators_area_staff as oas on wboi.replenishId = oas.accountId
-        where wboi.backTime between #{beginTime} and #{endTime}
-          and wboi.backStatus = 'BACK_SUCCESS'
-        group by wboi.replenishId, wbod.productSpecId
+        with driver_back as (select oas.id                   as areaStaffId,
+                                    wbod.productSpecId       as goodsId,
+                                    SUM(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
+                                                 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'
+                             group by wboi.replenishId, wbod.productSpecId),
+             device_back as (select wboi.areaStaffId    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
+                             where wboi.backTime between #{beginTime} and #{endTime}
+                               and wboi.backStatus = 'BACK_SUCCESS'
+                               and wboi.sourceBack = 'DEVICE'
+                             group by wboi.areaStaffId, wbod.productSpecId)
+        select areaStaffId, goodsId, sum(totalNum) as totalNum
+        from (select areaStaffId, goodsId, totalNum
+              from driver_back
+              where areaStaffId is not null
+              union all
+              select areaStaffId, goodsId, totalNum
+              from device_back
+              where areaStaffId is not null) as c
+        group by areaStaffId, goodsId
     </select>
     <select id="queryDriverDeviceInventoryNum"
             resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">