BillingQuantityStatisticsMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yr.warehouse.admin.statistics.mapper.BillingQuantityStatisticsMapper">
  4. <select id="queryPickingBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  5. select poi.area_staff_id as areaStaffId, pod.goods_id as goodsId, SUM(pod.picking_number) as totalNum
  6. from yr_picking_order_detail as pod
  7. left join yr_picking_order_info as poi on pod.order_number = poi.order_number
  8. where poi.create_time between #{beginTime} and #{endTime}
  9. and pod.is_aggregation = 0
  10. group by poi.area_staff_id, pod.goods_id
  11. </select>
  12. <select id="queryAggregationBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  13. select api.area_staff_id as areaStaffId,
  14. apd.goods_id as goodsId,
  15. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
  16. from yr_aggregation_pick_detail as apd
  17. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  18. where api.modify_time between #{beginTime} and #{endTime}
  19. group by api.area_staff_id, apd.goods_id
  20. </select>
  21. <select id="queryUnOutStockCancelNum"
  22. resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  23. with cancel_data as (select poi.area_staff_id as areaStaffId,
  24. pod.goods_id as goodsId,
  25. IFNULL(SUM(pod.picking_number), 0) as pickingNumber
  26. from yr_picking_order_detail as pod
  27. left join yr_picking_order_info as poi on pod.order_number = poi.order_number
  28. where poi.modify_time between #{beginTime} and #{endTime}
  29. and pod.is_aggregation = 0
  30. and poi.picking_status = 3
  31. group by poi.area_staff_id, pod.goods_id
  32. union all
  33. select api.area_staff_id as areaStaffId,
  34. apd.goods_id as goodsId,
  35. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
  36. from yr_aggregation_pick_detail as apd
  37. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  38. where api.modify_time between #{beginTime} and #{endTime}
  39. and api.status = 'CANCEL')
  40. select areaStaffId, goodsId, sum(pickingNumber) as totalNum
  41. from cancel_data
  42. where areaStaffId IS NOT NULL
  43. group by areaStaffId, goodsId
  44. </select>
  45. <select id="queryOutStockCancelNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  46. with cancel_data as (select poi.area_staff_id as areaStaffId,
  47. pod.goods_id as goodsId,
  48. IFNULL(SUM(pod.picking_number), 0) as pickingNumber
  49. from yr_picking_order_detail as pod
  50. left join yr_picking_order_info as poi on pod.order_number = poi.order_number
  51. where poi.modify_time between #{beginTime} and #{endTime}
  52. and pod.is_aggregation = 0
  53. and poi.picking_status = 4
  54. group by poi.area_staff_id, pod.goods_id
  55. union all
  56. select api.area_staff_id as areaStaffId,
  57. apd.goods_id as goodsId,
  58. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
  59. from yr_aggregation_pick_detail as apd
  60. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  61. where api.modify_time between #{beginTime} and #{endTime}
  62. and api.status = 'OUT_CANCEL')
  63. select areaStaffId, goodsId, sum(pickingNumber) as totalNum
  64. from cancel_data
  65. where areaStaffId IS NOT NULL
  66. group by areaStaffId, goodsId
  67. </select>
  68. <select id="queryDriverReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  69. select roi.area_staff_id as areaStaffId, rod.goods_id as goodsId, sum(rod.real_picking_number) as totalNum
  70. from yr_replenish_order_detail as rod
  71. left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
  72. where roi.replenish_time between #{beginTime} and #{endTime}
  73. and roi.replenish_status = 2
  74. group by roi.area_staff_id, rod.goods_id
  75. </select>
  76. <select id="queryDeviceReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  77. select roi.area_staff_id as areaStaffId, sum(rod.real_picking_number) as totalNum
  78. from yr_replenish_order_detail as rod
  79. left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
  80. where roi.replenish_time between #{beginTime} and #{endTime}
  81. and roi.replenish_status = 2
  82. and rod.real_picking_number > 0
  83. group by roi.area_staff_id
  84. </select>
  85. <select id="queryDriverReturnNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  86. select oas.id as areaStaffId, wbod.productSpecId as goodsId, SUM(wbod.realBackNumber) as totalNum
  87. from yr_warehouse_back_order_detail as wbod
  88. left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
  89. left join yr_operators_area_staff as oas on wboi.replenishId = oas.accountId
  90. where wboi.backTime between #{beginTime} and #{endTime}
  91. and wboi.backStatus = 'BACK_SUCCESS'
  92. group by wboi.replenishId, wbod.productSpecId
  93. </select>
  94. <select id="queryDriverDeviceInventoryNum"
  95. resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  96. with device_stock as (select odcw.deviceId as deviceId, SUM(odcw.stockNumber) as stockNumber
  97. from yr_operators_device_cargo_way as odcw
  98. where odcw.isDelete = 'NORMAL'
  99. and odcw.goodsId > 0
  100. group by odcw.deviceId
  101. union all
  102. select odrg.deviceId as deviceId, SUM(odrg.stockNumber) as stockNumber
  103. from yr_operators_device_replace_goods as odrg
  104. where odrg.status = 'INIT'
  105. and odrg.way = 'HOLD'
  106. group by odrg.deviceId)
  107. select ods.areaStaffId as areaStaffId, sum(ds.stockNumber) as totalNum
  108. from device_stock as ds
  109. left join yr_operators_device_site as ods on ds.deviceId = ods.deviceId
  110. left join yr_operators_device as od on ds.deviceId = od.id
  111. where od.bindStatus = 'BIND'
  112. and putStatus = 'USED'
  113. group by ods.areaStaffId
  114. </select>
  115. </mapper>