BillingQuantityStatisticsMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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
  9. poi.picking_time is not null
  10. and poi.picking_time between #{beginTime} and #{endTime}
  11. and pod.is_aggregation = 0
  12. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  13. <foreach collection="areaStaffIds" item="areaStaffId" open="and poi.area_staff_id in (" separator=","
  14. close=")">
  15. #{areaStaffId}
  16. </foreach>
  17. </if>
  18. group by poi.area_staff_id, pod.goods_id
  19. </select>
  20. <select id="queryAggregationBillingQuantity" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  21. select api.area_staff_id as areaStaffId,
  22. apd.goods_id as goodsId,
  23. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as totalNum
  24. from yr_aggregation_pick_detail as apd
  25. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  26. where
  27. api.picking_time is not null
  28. and api.picking_time between #{beginTime} and #{endTime}
  29. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  30. <foreach collection="areaStaffIds" item="areaStaffId" open="and api.area_staff_id in (" separator=","
  31. close=")">
  32. #{areaStaffId}
  33. </foreach>
  34. </if>
  35. group by api.area_staff_id, apd.goods_id
  36. </select>
  37. <select id="queryUnOutStockCancelNum"
  38. resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  39. with cancel_data as (select poi.area_staff_id as areaStaffId,
  40. pod.goods_id as goodsId,
  41. IFNULL(SUM(pod.picking_number), 0) as pickingNumber
  42. from yr_picking_order_detail as pod
  43. left join yr_picking_order_info as poi on pod.order_number = poi.order_number
  44. where poi.modify_time between #{beginTime} and #{endTime}
  45. and pod.is_aggregation = 0
  46. and poi.picking_status = 3
  47. group by poi.area_staff_id, pod.goods_id
  48. union all
  49. select api.area_staff_id as areaStaffId,
  50. apd.goods_id as goodsId,
  51. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
  52. from yr_aggregation_pick_detail as apd
  53. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  54. where api.modify_time between #{beginTime} and #{endTime}
  55. and api.status = 'CANCEL')
  56. select areaStaffId, goodsId, sum(pickingNumber) as totalNum
  57. from cancel_data
  58. where areaStaffId IS NOT NULL
  59. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  60. <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
  61. close=")">
  62. #{areaStaffId}
  63. </foreach>
  64. </if>
  65. group by areaStaffId, goodsId
  66. </select>
  67. <select id="queryOutStockCancelNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  68. with cancel_data as (select poi.area_staff_id as areaStaffId,
  69. pod.goods_id as goodsId,
  70. IFNULL(SUM(pod.picking_number), 0) as pickingNumber
  71. from yr_picking_order_detail as pod
  72. left join yr_picking_order_info as poi on pod.order_number = poi.order_number
  73. where poi.modify_time between #{beginTime} and #{endTime}
  74. and pod.is_aggregation = 0
  75. and poi.picking_status = 4
  76. group by poi.area_staff_id, pod.goods_id
  77. union all
  78. select api.area_staff_id as areaStaffId,
  79. apd.goods_id as goodsId,
  80. IFNULL(sum(apd.picking_number), 0) + IFNULL(sum(apd.more_number), 0) as pickingNumber
  81. from yr_aggregation_pick_detail as apd
  82. left join yr_aggregation_pick_info as api on apd.order_number = api.order_number
  83. where api.modify_time between #{beginTime} and #{endTime}
  84. and api.status = 'OUT_CANCEL')
  85. select areaStaffId, goodsId, sum(pickingNumber) as totalNum
  86. from cancel_data
  87. where areaStaffId IS NOT NULL
  88. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  89. <foreach collection="areaStaffIds" item="areaStaffId" open="and areaStaffId in (" separator=","
  90. close=")">
  91. #{areaStaffId}
  92. </foreach>
  93. </if>
  94. group by areaStaffId, goodsId
  95. </select>
  96. <select id="queryDriverReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  97. with replenish_data as (
  98. select
  99. roi.area_staff_id as areaStaffId,
  100. rod.goods_id as goodsId,
  101. sum(rod.real_picking_number) as totalNum
  102. from yr_replenish_order_detail as rod
  103. left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
  104. where roi.replenish_time between #{beginTime} and #{endTime}
  105. and roi.replenish_status = 2
  106. group by roi.area_staff_id, rod.goods_id)
  107. select rd.areaStaffId as areaStaffId,
  108. rd.goodsId as goodsId,
  109. rd.totalNum as totalNum
  110. from replenish_data as rd
  111. <where>
  112. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  113. <foreach collection="areaStaffIds" item="areaStaffId" open="and rd.areaStaffId in (" separator=","
  114. close=")">
  115. #{areaStaffId}
  116. </foreach>
  117. </if>
  118. </where>
  119. </select>
  120. <select id="queryDeviceReplenishNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  121. select
  122. roi.area_staff_id as areaStaffId,
  123. sum(rod.real_picking_number) as totalNum
  124. from yr_replenish_order_detail as rod
  125. left join yr_replenish_order_info as roi on rod.order_number = roi.order_number
  126. where roi.replenish_time between #{beginTime} and #{endTime}
  127. and roi.replenish_status = 2
  128. and rod.real_picking_number > 0
  129. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  130. <foreach collection="areaStaffIds" item="areaStaffId" open="and roi.area_staff_id in (" separator=","
  131. close=")">
  132. #{areaStaffId}
  133. </foreach>
  134. </if>
  135. group by roi.area_staff_id
  136. </select>
  137. <select id="queryDriverReturnNum" resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  138. select oas.id as areaStaffId, wbod.productSpecId as goodsId, wbod.realBackNumber as totalNum
  139. from yr_warehouse_back_order_detail as wbod
  140. left join yr_warehouse_back_order_info as wboi on wbod.backOrderId = wboi.id
  141. left join (select id, accountId
  142. from yr_operators_area_staff
  143. where isDelete = 'NORMAL'
  144. group by accountId) as oas on oas.accountId = wboi.replenishId
  145. where wboi.backTime between #{beginTime} and #{endTime}
  146. and wboi.backStatus = 'BACK_SUCCESS'
  147. and wboi.sourceBack = 'DRIVER'
  148. <if test="areaStaffIds != null and areaStaffIds.size > 0">
  149. <foreach collection="areaStaffIds" item="areaStaffId" open="and oas.id in (" separator=","
  150. close=")">
  151. #{areaStaffId}
  152. </foreach>
  153. </if>
  154. group by wboi.replenishId, wbod.productSpecId
  155. </select>
  156. <select id="queryDriverDeviceInventoryNum"
  157. resultType="com.yr.warehouse.admin.replenish.vo.DriverGoodsOrderNumVo">
  158. with device_stock as (select odcw.deviceId as deviceId, SUM(odcw.stockNumber) as stockNumber
  159. from yr_operators_device_cargo_way as odcw
  160. where odcw.isDelete = 'NORMAL'
  161. and odcw.goodsId > 0
  162. group by odcw.deviceId
  163. union all
  164. select odrg.deviceId as deviceId, SUM(odrg.stockNumber) as stockNumber
  165. from yr_operators_device_replace_goods as odrg
  166. where odrg.status = 'INIT'
  167. and odrg.way = 'HOLD'
  168. group by odrg.deviceId)
  169. select ods.areaStaffId as areaStaffId, sum(ds.stockNumber) as totalNum
  170. from device_stock as ds
  171. left join yr_operators_device as od on ds.deviceId = od.id
  172. left join yr_operators_device_site as ods on ds.deviceId = ods.deviceId
  173. where od.putStatus = 'USED'
  174. group by ods.areaStaffId
  175. </select>
  176. </mapper>