BillingQuantityStatisticsMapper.xml 7.6 KB

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