FrmrptStoveBatchStorage.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <queryMap desc = "轧管收发存">
  3. <query id = "FrmrptStoveBatchStorage.getTest" desc = "查询">
  4. <![CDATA[
  5. select JUDGE_STOVE_NO,
  6. BATCH_NO,
  7. --BATCH_GROUD_NO,
  8. sum(ORIGINAL_COUNT)ORIGINAL_COUNT,
  9. sum(ORIGINAL_AMOUNT)ORIGINAL_AMOUNT,
  10. sum(DAY_1COUNT)DAY_1COUNT,
  11. sum(DAY_1)DAY_1,
  12. sum(MONTH_1COUNT)MONTH_1COUNT,
  13. sum(MONTH_1)MONTH_1,
  14. sum(DAY_2COUNT)DAY_2COUNT,
  15. sum(DAY_2)DAY_2,
  16. sum(MONTH_2COUNT)MONTH_2COUNT,
  17. sum(MONTH_2)MONTH_2,
  18. sum(AWEIGHT)AWEIGHT,
  19. sum((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT)) as END_COUNT,
  20. sum((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT)) as END_AMOUNT,
  21. sum(MATCOUNT)MATCOUNT,
  22. sum(MATWGT)MATWGT,
  23. sum((ORIGINAL_COUNT + MONTH_1COUNT - MONTH_2COUNT - MATCOUNT)) as QUANTITYCOUNT,
  24. sum((ORIGINAL_AMOUNT + MONTH_1 - MONTH_2 + AWEIGHT - MATWGT)) as QUANTITYWGT
  25. from (select JUDGE_STOVE_NO,
  26. BATCH_NO,
  27. --BATCH_GROUD_NO,
  28. BELONG_CODE,
  29. sum(k.ORIGINAL_COUNT) as ORIGINAL_COUNT,
  30. sum(k.ORIGINAL_AMOUNT) as ORIGINAL_AMOUNT,
  31. nvl(sum(case
  32. when trunc(k.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
  33. nvl(k.inListCount, 0)
  34. end),
  35. 0) DAY_1COUNT,
  36. nvl(sum(case
  37. when trunc(k.INSTOCK_TIME) = to_date(?, 'yyyymmdd') then
  38. nvl(k.inListWgt, 0)
  39. end),
  40. 0) DAY_1,
  41. nvl(sum(case
  42. when trunc(k.INSTOCK_TIME) >=
  43. to_date(?, 'yyyymmdd') and
  44. trunc(k.INSTOCK_TIME) <=
  45. to_date(?, 'yyyymmdd') then
  46. nvl(k.inListCount, 0)
  47. end),
  48. 0) MONTH_1COUNT,
  49. nvl(sum(case
  50. when trunc(k.INSTOCK_TIME) >=
  51. to_date(?, 'yyyymmdd') and
  52. trunc(k.INSTOCK_TIME) <=
  53. to_date(?, 'yyyymmdd') then
  54. nvl(k.inListWgt, 0)
  55. end),
  56. 0) MONTH_1,
  57. nvl(sum(case
  58. when trunc(k.OUTSTOCK_TIME) =
  59. to_date(?, 'yyyymmdd') then
  60. nvl(k.outListCount, 0)
  61. end),
  62. 0) DAY_2COUNT,
  63. nvl(sum(case
  64. when trunc(k.OUTSTOCK_TIME) =
  65. to_date(?, 'yyyymmdd') then
  66. nvl(k.outListWgt, 0)
  67. end),
  68. 0) DAY_2,
  69. nvl(sum(case
  70. when trunc(k.OUTSTOCK_TIME) >=
  71. to_date(?, 'yyyymmdd') and
  72. trunc(k.OUTSTOCK_TIME) <=
  73. to_date(?, 'yyyymmdd') then
  74. nvl(k.outListCount, 0)
  75. end),
  76. 0) MONTH_2COUNT,
  77. nvl(sum(case
  78. when trunc(k.OUTSTOCK_TIME) >=
  79. to_date(?, 'yyyymmdd') and
  80. trunc(k.OUTSTOCK_TIME) <=
  81. to_date(?, 'yyyymmdd') then
  82. nvl(k.outListWgt, 0)
  83. end),
  84. 0) MONTH_2,
  85. sum(k.AWEIGHT) as AWEIGHT,
  86. sum(k.MATCOUNT) as MATCOUNT,
  87. sum(k.MATWGT) as MATWGT
  88. from (select JUDGE_STOVE_NO,
  89. BATCH_NO,
  90. --BATCH_GROUD_NO,
  91. BELONG_CODE,
  92. sum(ACT_COUNT) ORIGINAL_COUNT,
  93. sum(ACT_WEIGHT) ORIGINAL_AMOUNT,
  94. 0 inListCount,
  95. 0 inListWgt,
  96. 0 outListCount,
  97. 0 outListWgt,
  98. 0 AWEIGHT,
  99. 0 MATCOUNT,
  100. 0 MATWGT,
  101. null OUTSTOCK_TIME,
  102. null INSTOCK_TIME
  103. from ydm_zc_initial t
  104. where t.bal_year_month = ?
  105. and t.handle_log = '1'
  106. and t.belong_code = '#condtions#'
  107. group by t.judge_stove_no, t.batch_no,
  108. --t.batch_groud_no,
  109. BELONG_CODE
  110. union all
  111. SELECT JUDGE_STOVE_NO,
  112. BATCH_NO,
  113. --BATCH_GROUD_NO,
  114. BELONG_CODE,
  115. 0 ORIGINAL_COUNT,
  116. 0 ORIGINAL_AMOUNT,
  117. ACT_COUNT inListCount,
  118. ACT_WEIGHT inListWgt,
  119. 0 outListCount,
  120. 0 outListWgt,
  121. 0 AWEIGHT,
  122. 0 MATCOUNT,
  123. 0 MATWGT,
  124. null OUTSTOCK_TIME,
  125. INSTOCK_TIME INSTOCK_TIME
  126. FROM YDM_BC_INLIST
  127. WHERE INSTOCK_TYPE_CODE IN
  128. ('800701', '800702', '800704', '800706', '800707')
  129. AND TRUNC(INSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
  130. AND TRUNC(INSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
  131. and belong_code = '#condtions#'
  132. union all
  133. select JUDGE_STOVE_NO,
  134. BATCH_NO,
  135. --BATCH_GROUD_NO,
  136. BELONG_CODE,
  137. 0 ORIGINAL_COUNT,
  138. 0 ORIGINAL_AMOUNT,
  139. 0 inListCount,
  140. 0 inListWgt,
  141. ACT_COUNT outListCount,
  142. (case
  143. when PONDER_NO is null then
  144. nvl(ACT_WEIGHT, 0)
  145. else
  146. nvl(PONDER_GROSS_WT, 0)
  147. end) outListWgt,
  148. 0 AWEIGHT,
  149. 0 MATCOUNT,
  150. 0 MATWGT,
  151. OUTSTOCK_TIME OUTSTOCK_TIME,
  152. null INSTOCK_TIME
  153. from YDM_BC_OUTLIST
  154. where OUTSTOCK_TYPE_CODE = '800809'
  155. and TRUNC(OUTSTOCK_TIME) >= TO_DATE(?, 'YYYYMMDD')
  156. AND TRUNC(OUTSTOCK_TIME) <= TO_DATE(?, 'YYYYMMDD')
  157. and belong_code = '#condtions#'
  158. union all
  159. select JUDGE_STOVE_NO,
  160. BATCH_NO,
  161. --BATCH_GROUD_NO,
  162. BELONG_CODE,
  163. 0 ORIGINAL_COUNT,
  164. 0 ORIGINAL_AMOUNT,
  165. 0 inListCount,
  166. 0 inListWgt,
  167. 0 outListCount,
  168. 0 outListWgt,
  169. sum(ACT_WEIGHT) AWEIGHT,
  170. 0 MATCOUNT,
  171. 0 MATWGT,
  172. null OUTSTOCK_TIME,
  173. null INSTOCK_TIME
  174. from YDM_BC_STOCKTAKINGLIST e
  175. where TRUNC(e.stocktaking_time) >= to_date(?, 'YYYYMMDD')
  176. and TRUNC(e.stocktaking_time) <=
  177. to_date(?, 'YYYYMMDD')
  178. and e.belong_code = '#condtions#'
  179. group by JUDGE_STOVE_NO, BATCH_NO,
  180. --BATCH_GROUD_NO,
  181. BELONG_CODE
  182. union all
  183. (
  184. SELECT F.JUDGE_STOVE_NO,
  185. F.BATCH_NO,
  186. --F.BATCH_GROUD_NO,
  187. BELONG_CODE,
  188. 0 ORIGINAL_COUNT,
  189. 0 ORIGINAL_AMOUNT,
  190. 0 inListCount,
  191. 0 inListWgt,
  192. 0 outListCount,
  193. 0 outListWgt,
  194. 0 AWEIGHT,
  195. sum(F.Act_Count) MATCOUNT,
  196. sum(F.Act_Weight) MATWGT,
  197. null OUTSTOCK_TIME,
  198. null INSTOCK_TIME
  199. FROM MAT_BC_M F, YDM_BC_BUTTRESS G
  200. WHERE F.MAT_NO = G.MAT_NO
  201. AND F.PRODUCT_FLAG = '801401'
  202. AND F.belong_code = '#condtions#'
  203. group by F.Judge_Stove_No, F.Batch_No,
  204. -- F.Batch_Groud_No,
  205. F.BELONG_CODE)) k
  206. group by k.Judge_Stove_No, k.Batch_No,
  207. --k.Batch_Groud_No,
  208. BELONG_CODE) h
  209. group by JUDGE_STOVE_NO,
  210. BATCH_NO
  211. --BATCH_GROUD_NO
  212. ]]>
  213. </query>
  214. </queryMap>