StockSaleReceiptReportMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.yh.saas.plugin.yiliangyiyun.mapper.StockSaleReceiptReportMapper">
  4. <!-- 获得销售出库统计总数 -->
  5. <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
  6. SELECT
  7. COUNT(id)
  8. FROM stock_sale_receipt_report
  9. WHERE
  10. comp_id = #{compId}
  11. and delete_flag = '0'
  12. <if test="searchType != null and searchType != ''">
  13. <if test="searchType == 2">
  14. AND amount_ing_receivable-amount_ed_receivable>0
  15. </if>
  16. <if test="searchType == 3">
  17. AND amount_ing_receivable-amount_ed_receivable=0
  18. </if>
  19. </if>
  20. <if test="contractNo != null and contractNo != ''and contractNo != '全部合同'">
  21. AND contract_no = #{contractNo}
  22. </if>
  23. <if test="processNo != null and processNo != ''">
  24. AND process_no = #{processNo}
  25. </if>
  26. <if test="startDate != null">
  27. AND (DATE_FORMAT(create_date,"%Y%m%d") &gt;=
  28. DATE_FORMAT(#{startDate},"%Y%m%d"))
  29. </if>
  30. <if test="endDate != null">
  31. AND (DATE_FORMAT(create_date,"%Y%m%d") &lt;=
  32. DATE_FORMAT(#{endDate},"%Y%m%d"))
  33. </if>
  34. </select>
  35. <!-- 获得销售出库统计列表 -->
  36. <select id="getListByCondition" parameterType="Map"
  37. resultType="com.yh.saas.plugin.yiliangyiyun.entity.StockSaleReceiptReport">
  38. SELECT
  39. id,
  40. comp_id as compId,
  41. contract_no as contractNo,
  42. car_no as carNo,
  43. warehouse_record_id as warehouseRecordId,
  44. delivery_date as deliveryDate,
  45. process_no as processNo,
  46. tran_car_no as tranCarNo,
  47. case_no as caseNo,
  48. title_no as titleNo,
  49. bin_number as binNumber,
  50. box_no as boxNo,
  51. feedback_person as feedbackPerson,
  52. create_date as createDate,
  53. update_date as updateDate,
  54. net_weight as netWeight,
  55. feedback_weight as feedbackWeight,
  56. gross_weight as grossWeight,
  57. tare as tare,
  58. settlement_weight AS settlementWeight,
  59. settlement_price AS settlementPrice,
  60. ROUND(amount_ing_receivable,2) as amountIngReceivable,
  61. ROUND(amount_ed_receivable,2) as amountEdReceivable,
  62. ROUND(amount_not_receivable,2) as amountNotReceivable,
  63. collection_screenshot as collectionScreenshot,
  64. collection_date as collectionDate,
  65. already_invoice as alreadyInvoice,
  66. warehouse_name as warehouseName,
  67. status,
  68. approve_status as approveStatus,
  69. status_flag as statusFlag,
  70. approve_status as approveStatus,
  71. return_date as returnDate,
  72. return_flag as returnFlag,
  73. workflow_id as workflowId
  74. FROM stock_sale_receipt_report
  75. WHERE
  76. comp_id = #{compId}
  77. and delete_flag = '0'
  78. <if test="contractNo != null and contractNo != ''and contractNo != '全部合同'">
  79. AND contract_no = #{contractNo}
  80. </if>
  81. <if test="processNo != null and processNo != ''">
  82. AND process_no = #{processNo}
  83. </if>
  84. <if test="searchType != null and searchType != ''">
  85. <if test="searchType == 2">
  86. AND amount_ing_receivable-amount_ed_receivable>0
  87. </if>
  88. <if test="searchType == 3">
  89. AND amount_ing_receivable-amount_ed_receivable=0
  90. </if>
  91. </if>
  92. <if test="startDate != null">
  93. AND (DATE_FORMAT(create_date,"%Y%m%d") &gt;=
  94. DATE_FORMAT(#{startDate},"%Y%m%d"))
  95. </if>
  96. <if test="endDate != null">
  97. AND (DATE_FORMAT(create_date,"%Y%m%d") &lt;=
  98. DATE_FORMAT(#{endDate},"%Y%m%d"))
  99. </if>
  100. ORDER BY delivery_date DESC
  101. <if test="currentPage != null and currentPage != ''">
  102. LIMIT ${startRecord}, ${pageSize}
  103. </if>
  104. </select>
  105. <select id="getAmonutIn" parameterType="Map"
  106. resultType="java.lang.String">
  107. SELECT
  108. sum(ei.amount_money) as amount
  109. FROM
  110. expense_info ei
  111. LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = ei.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = ei.warehouse_name
  112. LEFT JOIN contract_management_info cmi ON cmi.comp_id = ei.comp_id and cmi.delete_flag = 0 and cmi.contract_no = ei.contract_no
  113. WHERE
  114. ei.delete_flag = 0
  115. AND ei.comp_id = #{compId}
  116. and ei.expenses_type = '1'
  117. and ei.update_date > #{seachMoth}
  118. <if test="jointVentureParties != null">
  119. AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
  120. </if>
  121. </select>
  122. <select id="getAmonutOut" parameterType="Map"
  123. resultType="java.lang.String">
  124. SELECT
  125. IFNULL( sum( ei.amount_money ), 0 ) + IFNULL((
  126. SELECT
  127. sum( p.amount_ing_payable )
  128. FROM
  129. payment_management p
  130. LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = p.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = p.warehouse_name
  131. LEFT JOIN contract_management_info cmi ON cmi.comp_id = p.comp_id and cmi.delete_flag = 0 and cmi.contract_no = p.contract_no
  132. WHERE
  133. p.delete_flag = 0
  134. AND p.comp_id = #{compId}
  135. AND p.create_date > #{seachMoth}
  136. <if test="jointVentureParties != null">
  137. AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
  138. </if>
  139. ),
  140. 0
  141. ) as aa
  142. FROM
  143. expense_info ei
  144. LEFT JOIN warehouse_base_info wbi ON wbi.comp_id = ei.comp_id and wbi.delete_flag = 0 and wbi.warehouse_name = ei.warehouse_name
  145. LEFT JOIN contract_management_info cmi ON cmi.comp_id = ei.comp_id and cmi.delete_flag = 0 and cmi.contract_no = ei.contract_no
  146. WHERE
  147. ei.delete_flag = 0
  148. AND ei.comp_id = #{compId}
  149. and ei.expenses_type = '2'
  150. and ei.update_date > #{seachMoth}
  151. <if test="jointVentureParties != null">
  152. AND (wbi.joint_venture_parties = #{jointVentureParties} or cmi.joint_venture_parties = #{jointVentureParties})
  153. </if>
  154. </select>
  155. <select id="getAmonutMao" parameterType="Map"
  156. resultType="java.lang.String">
  157. SELECT
  158. sum(
  159. a.amount_ing_receivable - IFNULL( IFNULL( a.cost, w.cost ), 0 )* a.net_weight - IFNULL( a.sale_cost, 0 )) AS
  160. lirun
  161. FROM
  162. stock_sale_receipt_report a
  163. LEFT JOIN warehouse_cost w ON w.comp_id = a.comp_id
  164. AND w.delete_flag = 0
  165. AND w.warehouse_name = a.warehouse_name
  166. AND w.calculate_date = DATE_SUB( a.delivery_date, INTERVAL 1 DAY )
  167. LEFT JOIN warehouse_in_out_info wioi ON wioi.id = a.warehouse_record_id and wioi.delete_flag = 0
  168. LEFT JOIN warehouse_base_info wbi ON wbi.id = wioi.base_id and wbi.delete_flag = 0
  169. WHERE
  170. 1 = 1
  171. AND a.delete_flag = 0
  172. <if test="jointVentureParties != null">
  173. AND wbi.joint_venture_parties = #{jointVentureParties}
  174. </if>
  175. AND a.delivery_date > #{seachMoth}
  176. </select>
  177. </mapper>