TFeeMapper.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.finance.mapper.TFeeMapper">
  6. <resultMap type="TFee" id="TFeeResult">
  7. <result property="fId" column="f_id"/>
  8. <result property="fBillno" column="f_billno"/>
  9. <result property="fCtrlcorpid" column="f_ctrlcorpid"/>
  10. <result property="fActId" column="f_act_id"/>
  11. <result property="fCorpid" column="f_corpid"/>
  12. <result property="fTransActId" column="f_trans_act_id"/>
  13. <result property="tMblno" column="t_mblno"/>
  14. <result property="fAmtdr" column="f_amtdr"/>
  15. <result property="fAmtcr" column="f_amtcr"/>
  16. <result property="fBilltype" column="f_billtype"/>
  17. <result property="fBillstatus" column="f_billstatus"/>
  18. <result property="fRemarks" column="f_remarks"/>
  19. <result property="fFromDate" column="f_from_date"/>
  20. <result property="fAccbilldate" column="f_accbilldate"/>
  21. <result property="fToDate" column="f_to_date"/>
  22. <result property="fRefNo" column="f_ref_no"/>
  23. <result property="delFlag" column="del_flag"/>
  24. <result property="createBy" column="create_by"/>
  25. <result property="fDeptid" column="f_deptid"/>
  26. <result property="createTime" column="create_time"/>
  27. <result property="updateBy" column="update_by"/>
  28. <result property="updateTime" column="update_time"/>
  29. <result property="chargingMethod" column="charging_method"/>
  30. <result property="invoiceNo" column="invoice_no"/>
  31. <result property="bank" column="bank"/>
  32. <result property="waterBillNo" column="water_bill_no"/>
  33. </resultMap>
  34. <sql id="selectTFeeVo">
  35. select f_id, f_billno, f_ctrlcorpid, f_act_id, f_corpid, f_trans_act_id, t_mblno, f_amtdr, f_amtcr, f_billtype, f_billstatus, f_remarks, f_from_date, f_accbilldate, f_to_date, f_ref_no, del_flag, create_by, f_deptid, create_time, update_by,
  36. update_time,charging_method ,invoice_no , bank , water_bill_no from t_fee
  37. </sql>
  38. <select id="selectTFeeList" parameterType="TFee" resultMap="TFeeResult">
  39. select
  40. ware.*
  41. from
  42. t_fee ware
  43. left join sys_user u on ware.create_by = u.user_name
  44. left join sys_dept d on ware.f_deptid = d.dept_id
  45. <where>
  46. <if test="fBillno != null and fBillno != ''">and ware.f_billno = #{fBillno}</if>
  47. <if test="fCtrlcorpid != null ">and ware.f_ctrlcorpid = #{fCtrlcorpid}</if>
  48. <if test="fActId != null ">and ware.f_act_id = #{fActId}</if>
  49. <if test="fCorpid != null ">and ware.f_corpid = #{fCorpid}</if>
  50. <if test="fTransActId != null ">and ware.f_trans_act_id = #{fTransActId}</if>
  51. <if test="tMblno != null and tMblno != ''">and t_mblno = #{tMblno}</if>
  52. <if test="fAmtdr != null ">and ware.f_amtdr = #{fAmtdr}</if>
  53. <if test="fAmtcr != null ">and ware.f_amtcr = #{fAmtcr}</if>
  54. <if test="fBilltype != null and fBilltype != ''">and ware.f_billtype = #{fBilltype}</if>
  55. <if test="fBillstatus != null and fBillstatus != ''">and ware.f_billstatus = #{fBillstatus}</if>
  56. <if test="fRemarks != null and fRemarks != ''">and ware.f_remarks = #{fRemarks}</if>
  57. <if test="fFromDate != null ">and ware.f_from_date = #{fFromDate}</if>
  58. <if test="fAccbilldate != null ">and ware.f_accbilldate = #{fAccbilldate}</if>
  59. <if test="fToDate != null ">and ware.f_to_date = #{fToDate}</if>
  60. <if test="fRefNo != null and fRefNo != ''">and ware.f_ref_no = #{fRefNo}</if>
  61. <if test="fDeptid != null ">and ware.f_deptid = #{fDeptid}</if>
  62. <if test='timeInterval != null and timeInterval[0] != null and timeInterval[0]!= ""'>
  63. and ware.f_accbilldate &gt;= #{timeInterval[0]}
  64. </if>
  65. <if test='timeInterval != null and timeInterval[1] != null and timeInterval[1]!= ""'>
  66. and ware.f_accbilldate &lt;= #{timeInterval[1]}
  67. </if>
  68. <if test="chargingMethod != null ">and ware.charging_method = #{chargingMethod}</if>
  69. <if test="invoiceNo != null ">and ware.invoice_no = #{invoiceNo}</if>
  70. <if test="bank != null ">and ware.bank = #{bank}</if>
  71. <if test="waterBillNo != null ">and ware.water_bill_no = #{waterBillNo}</if>
  72. </where>
  73. ${params.dataScope}
  74. </select>
  75. <select id="selectTFeeList1" parameterType="TFee" resultType="Map">
  76. SELECT
  77. f.f_id AS fId,
  78. f.f_billno AS fBillno,
  79. f.f_ctrlcorpid AS fCtrlcorpid,
  80. f.f_corpid AS fCorpid,
  81. c.f_name AS fCorpidName,
  82. f.f_accbilldate AS fAccbilldate,
  83. f.t_mblno AS tMblno,
  84. f.f_amtdr AS fAmtdr,
  85. f.f_amtcr AS fAmtcr,
  86. f.f_billtype AS fBilltype,
  87. CASE
  88. WHEN f.f_billstatus = '1' THEN '保存'
  89. WHEN f.f_billstatus = '2' THEN '暂存'
  90. WHEN f.f_billstatus = '3' THEN '审批驳回'
  91. WHEN f.f_billstatus = '4' THEN '提交审核'
  92. WHEN f.f_billstatus = '5' THEN '审核中'
  93. WHEN f.f_billstatus = '6' THEN '审核完成'
  94. END
  95. AS fBillstatus,
  96. f.f_remarks AS fRemarks,
  97. f.create_by AS createBy
  98. FROM
  99. t_fee AS f
  100. LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
  101. left join sys_user u on f.create_by = u.user_name
  102. left join sys_dept d on f.f_deptid = d.dept_id
  103. <where>
  104. <if test="fBillno != null and fBillno != ''">and f.f_billno = #{fBillno}</if>
  105. <if test="fCtrlcorpid != null ">and f.f_ctrlcorpid = #{fCtrlcorpid}</if>
  106. <if test="fCorpid != null ">and f.f_corpid = #{fCorpid}</if>
  107. <if test="tMblno != null and tMblno != ''">and f.t_mblno = #{tMblno}</if>
  108. <if test="fAmtdr != null ">and f.f_amtdr = #{fAmtdr}</if>
  109. <if test="fAmtcr != null ">and f.f_amtcr = #{fAmtcr}</if>
  110. <if test="fBilltype != null and fBilltype != ''">and f.f_billtype = #{fBilltype}</if>
  111. <if test="fBillstatus != null and fBillstatus != ''">and f.f_billstatus = #{fBillstatus}</if>
  112. <if test="fRemarks != null and fRemarks != ''">and f.f_remarks = #{fRemarks}</if>
  113. <if test="fAccbilldate != null ">and f.f_accbilldate = #{fAccbilldate}</if>
  114. <if test="fDeptid != null ">and f.f_deptid = #{fDeptid}</if>
  115. <if test='timeInterval != null and timeInterval[0] != null and timeInterval[0]!= ""'>
  116. and f.f_accbilldate &gt;= #{timeInterval[0]}
  117. </if>
  118. <if test='timeInterval != null and timeInterval[1] != null and timeInterval[1]!= ""'>
  119. and f.f_accbilldate &lt;= #{timeInterval[1]}
  120. </if>
  121. <if test="chargingMethod != null ">and f.charging_method = #{chargingMethod}</if>
  122. <if test="invoiceNo != null ">and f.invoice_no = #{invoiceNo}</if>
  123. <if test="bank != null ">and f.bank = #{bank}</if>
  124. <if test="waterBillNo != null ">and f.water_bill_no = #{waterBillNo}</if>
  125. </where>
  126. ${params.dataScope}
  127. </select>
  128. <select id="selectTFeeById" parameterType="Long" resultMap="TFeeResult">
  129. <include refid="selectTFeeVo"/>
  130. where f_id = #{fId}
  131. </select>
  132. <insert id="insertTFee" parameterType="TFee" useGeneratedKeys="true" keyProperty="fId">
  133. insert into t_fee
  134. <trim prefix="(" suffix=")" suffixOverrides=",">
  135. <if test="fId != null">f_id,</if>
  136. <if test="fBillno != null">f_billno,</if>
  137. <if test="fCtrlcorpid != null">f_ctrlcorpid,</if>
  138. <if test="fActId != null">f_act_id,</if>
  139. <if test="fCorpid != null">f_corpid,</if>
  140. <if test="fTransActId != null">f_trans_act_id,</if>
  141. <if test="tMblno != null">t_mblno,</if>
  142. <if test="fAmtdr != null">f_amtdr,</if>
  143. <if test="fAmtcr != null">f_amtcr,</if>
  144. <if test="fBilltype != null and fBilltype != ''">f_billtype,</if>
  145. <if test="fBillstatus != null and fBillstatus != ''">f_billstatus,</if>
  146. <if test="fRemarks != null">f_remarks,</if>
  147. <if test="fFromDate != null">f_from_date,</if>
  148. <if test="fAccbilldate != null">f_accbilldate,</if>
  149. <if test="fToDate != null">f_to_date,</if>
  150. <if test="fRefNo != null">f_ref_no,</if>
  151. <if test="delFlag != null">del_flag,</if>
  152. <if test="createBy != null">create_by,</if>
  153. <if test="fDeptid != null">f_deptid,</if>
  154. <if test="createTime != null">create_time,</if>
  155. <if test="updateBy != null">update_by,</if>
  156. <if test="updateTime != null">update_time,</if>
  157. <if test="chargingMethod != null">charging_method,</if>
  158. <if test="invoiceNo != null">invoice_no,</if>
  159. <if test="bank != null">bank,</if>
  160. <if test="waterBillNo != null">water_bill_no,</if>
  161. </trim>
  162. <trim prefix="values (" suffix=")" suffixOverrides=",">
  163. <if test="fId != null">#{fId},</if>
  164. <if test="fBillno != null">#{fBillno},</if>
  165. <if test="fCtrlcorpid != null">#{fCtrlcorpid},</if>
  166. <if test="fActId != null">#{fActId},</if>
  167. <if test="fCorpid != null">#{fCorpid},</if>
  168. <if test="fTransActId != null">#{fTransActId},</if>
  169. <if test="tMblno != null">#{tMblno},</if>
  170. <if test="fAmtdr != null">#{fAmtdr},</if>
  171. <if test="fAmtcr != null">#{fAmtcr},</if>
  172. <if test="fBilltype != null and fBilltype != ''">#{fBilltype},</if>
  173. <if test="fBillstatus != null and fBillstatus != ''">#{fBillstatus},</if>
  174. <if test="fRemarks != null">#{fRemarks},</if>
  175. <if test="fFromDate != null">#{fFromDate},</if>
  176. <if test="fAccbilldate != null">#{fAccbilldate},</if>
  177. <if test="fToDate != null">#{fToDate},</if>
  178. <if test="fRefNo != null">#{fRefNo},</if>
  179. <if test="delFlag != null">#{delFlag},</if>
  180. <if test="createBy != null">#{createBy},</if>
  181. <if test="fDeptid != null">#{fDeptid},</if>
  182. <if test="createTime != null">#{createTime},</if>
  183. <if test="updateBy != null">#{updateBy},</if>
  184. <if test="updateTime != null">#{updateTime},</if>
  185. <if test="chargingMethod != null">#{chargingMethod},</if>
  186. <if test="invoiceNo != null">#{invoiceNo},</if>
  187. <if test="bank != null">#{bank},</if>
  188. <if test="waterBillNo != null">#{waterBillNo},</if>
  189. </trim>
  190. </insert>
  191. <update id="updateTFee" parameterType="TFee">
  192. update t_fee
  193. <trim prefix="SET" suffixOverrides=",">
  194. <if test="fBillno != null">f_billno = #{fBillno},</if>
  195. <if test="fCtrlcorpid != null">f_ctrlcorpid = #{fCtrlcorpid},</if>
  196. <if test="fActId != null">f_act_id = #{fActId},</if>
  197. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  198. <if test="fTransActId != null">f_trans_act_id = #{fTransActId},</if>
  199. <if test="tMblno != null">t_mblno = #{tMblno},</if>
  200. <if test="fAmtdr != null">f_amtdr = #{fAmtdr},</if>
  201. <if test="fAmtcr != null">f_amtcr = #{fAmtcr},</if>
  202. <if test="fBilltype != null and fBilltype != ''">f_billtype = #{fBilltype},</if>
  203. <if test="fBillstatus != null and fBillstatus != ''">f_billstatus = #{fBillstatus},</if>
  204. <if test="fRemarks != null">f_remarks = #{fRemarks},</if>
  205. <if test="fFromDate != null">f_from_date = #{fFromDate},</if>
  206. <if test="fAccbilldate != null">f_accbilldate = #{fAccbilldate},</if>
  207. <if test="fToDate != null">f_to_date = #{fToDate},</if>
  208. <if test="fRefNo != null">f_ref_no = #{fRefNo},</if>
  209. <if test="delFlag != null">del_flag = #{delFlag},</if>
  210. <if test="createBy != null">create_by = #{createBy},</if>
  211. <if test="fDeptid != null">f_deptid = #{fDeptid},</if>
  212. <if test="createTime != null">create_time = #{createTime},</if>
  213. <if test="updateBy != null">update_by = #{updateBy},</if>
  214. <if test="updateTime != null">update_time = #{updateTime},</if>
  215. <if test="chargingMethod != null">charging_method = #{chargingMethod},</if>
  216. <if test="invoiceNo != null">invoice_no = #{invoiceNo},</if>
  217. <if test="bank != null">bank = #{bank},</if>
  218. <if test="waterBillNo != null">water_bill_no = #{waterBillNo},</if>
  219. </trim>
  220. where f_id = #{fId}
  221. </update>
  222. <delete id="deleteTFeeById" parameterType="Long">
  223. delete from t_fee where f_id = #{fId}
  224. </delete>
  225. <delete id="deleteTFeeByIds" parameterType="String">
  226. delete
  227. f.*,
  228. fd.*
  229. from
  230. t_fee f
  231. LEFT JOIN t_fee_do fd ON fd.f_pid = f.f_id
  232. where f.f_id in
  233. <foreach item="fId" collection="array" open="(" separator="," close=")">
  234. #{fId}
  235. </foreach>
  236. </delete>
  237. <select id="warehouseBillsFeesList" resultType="java.util.Map">
  238. SELECT
  239. w.f_id AS fSrcid,
  240. t.f_id AS fSrcpid,
  241. t.f_corpid AS fCorpid,
  242. c.f_name AS fName,
  243. w.fId AS fId,
  244. w.fName AS fFeesName,
  245. t.f_bscorpno AS fBscorpno,
  246. w.f_mblno AS fMblno,
  247. w.f_product_name AS fProductName,
  248. w.f_bsdate AS fBsdate,
  249. t.f_billtype AS fBilltype,
  250. t.f_review_date AS fReviewDate,
  251. w.f_feeid AS fFeeid,
  252. w.src_bill_no AS srcBillNo,
  253. w.f_mblno AS fMblno,
  254. w.f_product_name AS fProductName,
  255. w.f_marks AS fMarks,
  256. w.f_chargedate AS fChargedate,
  257. w.f_billing_days AS fBillingDays,
  258. w.f_billing_deadline AS fBillingDeadline,
  259. w.f_inventory_days AS fInventoryDays,
  260. w.f_originalbilldate AS fOriginalbilldate,
  261. f.f_name AS fFeeName,
  262. w.f_dc AS fSrcdc,
  263. ifnull( w.f_amount, 0 ) - ifnull( w.f_stlamount, 0 ) AS fAmtdr,
  264. ifnull( w.f_amount, 0 ) - ifnull( w.f_stlamount, 0 ) AS fAmt,
  265. dictIn.dict_label AS fBusinessType
  266. FROM
  267. t_warehousebills t
  268. LEFT JOIN t_corps c ON c.f_id = t.f_corpid
  269. LEFT JOIN (
  270. SELECT
  271. f.f_id AS f_id,
  272. f.f_pid AS f_pid,
  273. f.f_lineno AS f_lineno,
  274. f.f_corpid,
  275. f.f_feeid,
  276. f.f_feeUnitid,
  277. f.f_qty,
  278. f.f_unitprice,
  279. f.f_amount,
  280. f.f_currency,
  281. f.f_exrate,
  282. f.f_taxrate,
  283. f.f_dc,
  284. f.f_billstatus,
  285. f.f_statement_no,
  286. f.f_accamount,
  287. f.f_accamount_date,
  288. f.f_stlamount_no,
  289. f.f_stlamount,
  290. f.f_stlamount_date,
  291. f.f_invnos,
  292. f.f_invamount,
  293. f.f_askamount,
  294. f.f_chargedate,
  295. f.f_status,
  296. f.remark,
  297. f.f_mblno,
  298. f.f_product_name,
  299. f.src_bill_no,
  300. f.f_billing_days,
  301. f.f_inventory_days,
  302. f.f_marks,
  303. f.f_billing_deadline,
  304. f.f_originalbilldate,
  305. f.f_billtype,
  306. f.f_business_type,
  307. f.f_bsdate,
  308. c.f_id AS fId,
  309. c.f_name AS fName
  310. FROM
  311. t_warehousebillsfees AS f
  312. LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
  313. ) w ON w.f_pid = t.f_id
  314. LEFT JOIN t_fees f ON w.f_feeid = f.f_id
  315. LEFT JOIN sys_dict_data dictIn ON dictIn.dict_value = w.f_business_type
  316. <where>
  317. <if test="map.tWareHouseFees.fCorpid != null and map.tWareHouseFees.fCorpid != ''">and t.f_corpid = #{map.tWareHouseFees.fCorpid} </if>
  318. <if test="map.tWareHouseFees.fToCorpid != null and map.tWareHouseFees.fToCorpid != ''">and w.f_corpid = #{map.tWareHouseFees.fToCorpid} </if>
  319. <if test="map.tWareHouseFees.fMblno != null and map.tWareHouseFees.fMblno != ''">and w.f_mblno like concat('%', #{map.tWareHouseFees.fMblno}, '%') </if>
  320. <if test="map.tWareHouseFees.fStatementNo != null and map.tWareHouseFees.fStatementNo != ''">and w.f_statement_no like concat('%', #{map.tWareHouseFees.fStatementNo}, '%') </if>
  321. <if test='map.tWareHouseFees.fReconciliation != null and map.tWareHouseFees.fReconciliation != "" and map.tWareHouseFees.fReconciliation == "1" '>
  322. and w.f_accamount_date IS NOT NULL
  323. </if>
  324. <if test='map.tWareHouseFees.fReconciliation != null and map.tWareHouseFees.fReconciliation != "" and map.tWareHouseFees.fReconciliation == "0" '>
  325. and w.f_accamount_date IS NULL
  326. </if>
  327. <if test='map.tWareHouseFees.fDc != null and map.tWareHouseFees.fDc != "" and map.tWareHouseFees.fDc == "D" '>
  328. and w.f_dc = #{map.tWareHouseFees.fDc}
  329. </if>
  330. <if test='map.tWareHouseFees.fDc != null and map.tWareHouseFees.fDc != "" and map.tWareHouseFees.fDc == "C" '>
  331. and w.f_dc = #{map.tWareHouseFees.fDc}
  332. </if>
  333. <if test="map.tWareHouseFees.fFeeid != null and map.tWareHouseFees.fFeeid != '' ">
  334. and w.f_feeid in
  335. <foreach collection="map.tWareHouseFees.fFeeid" item="id" index="index" open="(" close=")" separator=",">
  336. #{id}
  337. </foreach>
  338. </if>
  339. <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[0] != null and map.tWareHouseFees.timeExamine[0]!= ""'>
  340. and t.f_review_date &gt;= #{map.tWareHouseFees.timeExamine[0]}
  341. </if>
  342. <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[1] != null and map.tWareHouseFees.timeExamine[1]!= ""'>
  343. and t.f_review_date &lt;= #{map.tWareHouseFees.timeExamine[1]}
  344. </if>
  345. <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[0] != null and map.tWareHouseFees.timeInterval[0]!= ""'>
  346. and t.f_bsdate &gt;= #{map.tWareHouseFees.timeInterval[0]}
  347. </if>
  348. <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[1] != null and map.tWareHouseFees.timeInterval[1]!= ""'>
  349. and t.f_bsdate &lt;= #{map.tWareHouseFees.timeInterval[1]}
  350. </if>
  351. <if test='map.tWareHouseFees.timeReconci != null and map.tWareHouseFees.timeReconci[0] != null and map.tWareHouseFees.timeReconci[0]!= ""'>
  352. and w.f_accamount_date &gt;= #{map.tWareHouseFees.timeReconci[0]}
  353. </if>
  354. <if test='map.tWareHouseFees.timeReconci != null and map.tWareHouseFees.timeReconci[1] != null and map.tWareHouseFees.timeReconci[1]!= ""'>
  355. and w.f_accamount_date &lt;= #{map.tWareHouseFees.timeReconci[1]}
  356. </if>
  357. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'SJRK'">
  358. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  359. AND dictIn.dict_type = 'st_in_type'
  360. AND dictIn.status = '0'
  361. </if>
  362. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'SJCK'">
  363. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  364. AND dictIn.dict_type = 'st_out_type'
  365. AND dictIn.status = '0'
  366. </if>
  367. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'HQZY'">
  368. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  369. AND dictIn.dict_type = 'st_trans_type'
  370. AND dictIn.status = '0'
  371. </if>
  372. <if test="map.tWareHouseFees.fBilltype == null ">
  373. AND dictIn.dict_type in ('st_in_type','st_out_type','st_trans_type')
  374. AND dictIn.status = '0'
  375. </if>
  376. <if test="map.tWareHouseFees.fBusinessType != null and map.tWareHouseFees.fBusinessType != '' ">
  377. and w.f_business_type in
  378. <foreach collection="map.tWareHouseFees.fBusinessType" item="id" open="(" close=")" separator=",">
  379. #{id}
  380. </foreach>
  381. </if>
  382. and t.f_review_date IS NOT NULL
  383. and ifnull(w.f_amount, 0) - ifnull(w.f_stlamount, 0) > 0
  384. GROUP BY w.f_id
  385. </where>
  386. </select>
  387. <select id="warehouseBillsFeesListAccamount" resultType="java.util.Map">
  388. SELECT
  389. w.f_id AS fSrcid,
  390. t.f_id AS fSrcpid,
  391. t.f_corpid AS fCorpid,
  392. c.f_name AS fName,
  393. w.fName AS fFeesName,
  394. t.f_bscorpno AS fBscorpno,
  395. w.f_mblno AS fMblno,
  396. w.f_product_name AS fProductName,
  397. w.f_bsdate AS fBsdate,
  398. t.f_billtype AS fBilltype,
  399. t.f_review_date AS fReviewDate,
  400. w.f_marks AS fMarks,
  401. w.f_feeid AS fFeeid,
  402. w.f_billtype AS fBilltype,
  403. w.f_chargedate AS fChargedate,
  404. w.f_originalbilldate AS fOriginalbilldate,
  405. w.f_billing_deadline AS fBillingDeadline,
  406. w.f_billing_days AS fBillingDays,
  407. w.f_inventory_days AS fInventoryDays,
  408. f.f_name AS fFeeName,
  409. w.f_dc AS fSrcdc,
  410. ifnull( w.f_amount, 0 ) - ifnull( w.f_accamount, 0 ) AS fAmtdr,
  411. ifnull( w.f_amount, 0 ) - ifnull( w.f_accamount, 0 ) AS fAmt,
  412. dict.dict_label AS fFeeunitid,
  413. w.f_qty AS fQty ,
  414. w.f_unitprice AS fUnitprice ,
  415. dictIn.dict_label AS fBusinessType
  416. FROM
  417. t_warehousebills t
  418. LEFT JOIN t_corps c ON c.f_id = t.f_corpid
  419. LEFT JOIN (
  420. SELECT
  421. f.f_id AS f_id,
  422. f.f_pid AS f_pid,
  423. f.f_lineno AS f_lineno,
  424. f.f_corpid,
  425. f.f_feeid,
  426. f.f_feeUnitid,
  427. f.f_qty,
  428. f.f_unitprice,
  429. f.f_amount,
  430. f.f_currency,
  431. f.f_exrate,
  432. f.f_taxrate,
  433. f.f_dc,
  434. f.f_billstatus,
  435. f.f_statement_no,
  436. f.f_accamount,
  437. f.f_accamount_date,
  438. f.f_stlamount_no,
  439. f.f_stlamount,
  440. f.f_stlamount_date,
  441. f.f_invnos,
  442. f.f_invamount,
  443. f.f_askamount,
  444. f.f_status,
  445. f.remark,
  446. f.f_inventory_days,
  447. f.f_billing_days,
  448. f.f_billing_deadline,
  449. f.f_originalbilldate,
  450. f.f_mblno,
  451. f.f_product_name,
  452. f.f_chargedate,
  453. f.src_bill_no,
  454. f.f_billtype,
  455. f.f_marks,
  456. f.f_business_type,
  457. f.f_bsdate,
  458. c.f_id AS fId,
  459. c.f_name AS fName
  460. FROM
  461. t_warehousebillsfees AS f
  462. LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
  463. ) w ON w.f_pid = t.f_id
  464. LEFT JOIN t_fees f ON w.f_feeid = f.f_id
  465. LEFT JOIN sys_dict_data dict ON dict.dict_value = w.f_feeUnitid
  466. LEFT JOIN sys_dict_data dictIn ON dictIn.dict_value = w.f_business_type
  467. <where>
  468. dict.status = '0'
  469. AND dict.dict_type = 'data_unitfees'
  470. <if test="map.tWareHouseFees.fCorpid != null and map.tWareHouseFees.fCorpid != ''">and t.f_corpid = #{map.tWareHouseFees.fCorpid} </if>
  471. <if test="map.tWareHouseFees.fToCorpid != null and map.tWareHouseFees.fToCorpid != ''">and w.f_corpid = #{map.tWareHouseFees.fToCorpid} </if>
  472. <if test="map.tWareHouseFees.fMblno != null and map.tWareHouseFees.fMblno != ''">and w.f_mblno like concat('%', #{map.tWareHouseFees.fMblno}, '%') </if>
  473. <if test="map.tWareHouseFees.fStatementNo != null and map.tWareHouseFees.fStatementNo != ''">and w.f_statement_no like concat('%', #{map.tWareHouseFees.fStatementNo}, '%') </if>
  474. <if test='map.tWareHouseFees.fReconciliation != null and map.tWareHouseFees.fReconciliation != "" and map.tWareHouseFees.fReconciliation == "1" '>
  475. and w.f_accamount_date IS NOT NULL
  476. </if>
  477. <if test='map.tWareHouseFees.fReconciliation != null and map.tWareHouseFees.fReconciliation != "" and map.tWareHouseFees.fReconciliation == "0" '>
  478. and w.f_accamount_date IS NULL
  479. </if>
  480. <if test='map.tWareHouseFees.fDc != null and map.tWareHouseFees.fDc != "" and map.tWareHouseFees.fDc == "D" '>
  481. and w.f_dc = #{map.tWareHouseFees.fDc}
  482. </if>
  483. <if test='map.tWareHouseFees.fDc != null and map.tWareHouseFees.fDc != "" and map.tWareHouseFees.fDc == "C" '>
  484. and w.f_dc = #{map.tWareHouseFees.fDc}
  485. </if>
  486. <if test="map.tWareHouseFees.fFeeid != null and map.tWareHouseFees.fFeeid != '' ">
  487. and w.f_feeid in
  488. <foreach collection="map.tWareHouseFees.fFeeid" item="id" index="index" open="(" close=")" separator=",">
  489. #{id}
  490. </foreach>
  491. </if>
  492. <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[0] != null and map.tWareHouseFees.timeExamine[0]!= ""'>
  493. and t.f_review_date &gt;= #{map.tWareHouseFees.timeExamine[0]}
  494. </if>
  495. <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[1] != null and map.tWareHouseFees.timeExamine[1]!= ""'>
  496. and t.f_review_date &lt;= #{map.tWareHouseFees.timeExamine[1]}
  497. </if>
  498. <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[0] != null and map.tWareHouseFees.timeInterval[0]!= ""'>
  499. and t.f_bsdate &gt;= #{map.tWareHouseFees.timeInterval[0]}
  500. </if>
  501. <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[1] != null and map.tWareHouseFees.timeInterval[1]!= ""'>
  502. and t.f_bsdate &lt;= #{map.tWareHouseFees.timeInterval[1]}
  503. </if>
  504. <if test='map.tWareHouseFees.timeReconci != null and map.tWareHouseFees.timeReconci[0] != null and map.tWareHouseFees.timeReconci[0]!= ""'>
  505. and w.f_accamount_date &gt;= #{map.tWareHouseFees.timeReconci[0]}
  506. </if>
  507. <if test='map.tWareHouseFees.timeReconci != null and map.tWareHouseFees.timeReconci[1] != null and map.tWareHouseFees.timeReconci[1]!= ""'>
  508. and w.f_accamount_date &lt;= #{map.tWareHouseFees.timeReconci[1]}
  509. </if>
  510. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'SJRK'">
  511. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  512. AND dictIn.dict_type = 'st_in_type'
  513. AND dictIn.status = '0'
  514. </if>
  515. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'SJCK'">
  516. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  517. AND dictIn.dict_type = 'st_out_type'
  518. AND dictIn.status = '0'
  519. </if>
  520. <if test="map.tWareHouseFees.fBilltype != null and map.tWareHouseFees.fBilltype == 'HQZY'">
  521. and w.f_billtype = #{map.tWareHouseFees.fBilltype}
  522. AND dictIn.dict_type = 'st_trans_type'
  523. AND dictIn.status = '0'
  524. </if>
  525. <if test="map.tWareHouseFees.fBilltype == null ">
  526. AND dictIn.dict_type in ('st_in_type','st_out_type','st_trans_type')
  527. AND dictIn.status = '0'
  528. </if>
  529. <if test="map.tWareHouseFees.fBusinessType != null and map.tWareHouseFees.fBusinessType != '' ">
  530. and w.f_business_type in
  531. <foreach collection="map.tWareHouseFees.fBusinessType" item="id" open="(" close=")" separator=",">
  532. #{id}
  533. </foreach>
  534. </if>
  535. and t.f_review_date IS NOT NULL
  536. and ifnull(w.f_amount, 0) - ifnull(w.f_accamount, 0) > 0
  537. GROUP BY w.f_id
  538. </where>
  539. </select>
  540. <select id="warehouseBillsFeesList1" resultType="java.util.Map">
  541. SELECT
  542. a.*,
  543. ifnull( a.fAmount, 0 ) - ifnull( a.fStlamount, 0 ) AS nnfinished
  544. FROM
  545. (
  546. SELECT
  547. w.f_id AS fSrcid,
  548. t.f_id AS fSrcpid,
  549. t.f_corpid AS fCorpid,
  550. c.f_name AS fName,
  551. w.fId AS fId,
  552. w.fName AS fFeesName,
  553. w.f_mblno AS fMblno,
  554. w.f_product_name AS fProductName,
  555. w.f_marks AS fMarks,
  556. t.f_billtype AS fBilltype,
  557. t.f_review_date AS fReviewDate,
  558. w.f_dc AS fSrcdc,
  559. SUM(w.f_amount) AS fAmount,
  560. SUM(w.f_stlamount) AS fStlamount
  561. FROM
  562. t_warehousebills t
  563. left join sys_user u on t.create_by = u.user_name
  564. left join sys_dept d on t.f_bsdeptid = d.dept_id
  565. LEFT JOIN t_corps c ON c.f_id = t.f_corpid
  566. LEFT JOIN (
  567. SELECT
  568. f.f_id AS f_id,
  569. f.f_pid AS f_pid,
  570. f.f_lineno AS f_lineno,
  571. f.f_corpid,
  572. f.f_feeid,
  573. f.f_feeUnitid,
  574. f.f_qty,
  575. f.f_unitprice,
  576. f.f_amount,
  577. f.f_currency,
  578. f.f_exrate,
  579. f.f_taxrate,
  580. f.f_dc,
  581. f.f_billstatus,
  582. f.f_statement_no,
  583. f.f_accamount,
  584. f.f_accamount_date,
  585. f.f_stlamount_no,
  586. f.f_stlamount,
  587. f.f_stlamount_date,
  588. f.f_invnos,
  589. f.f_invamount,
  590. f.f_askamount,
  591. f.f_status,
  592. f.remark,
  593. f.f_mblno,
  594. f.f_product_name,
  595. f.f_marks,
  596. c.f_id AS fId,
  597. c.f_name AS fName
  598. FROM
  599. t_warehousebillsfees AS f
  600. LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
  601. ) w ON w.f_pid = t.f_id
  602. LEFT JOIN t_fees f ON w.f_feeid = f.f_id
  603. <where>
  604. <if test="fCorpid != null and fCorpid != ''">and t.f_corpid = #{fCorpid} </if>
  605. <if test="fToCorpid != null and fToCorpid != ''">and w.f_corpid = #{fToCorpid} </if>
  606. <if test="fMblno != null and fMblno != ''">and w.f_mblno like concat('%', #{fMblno}, '%') </if>
  607. <if test="fMarks != null and fMarks != ''">and w.f_marks like concat('%', #{fMarks}, '%') </if>
  608. <if test="fProductName != null and fProductName != ''">and w.f_product_name like concat('%', #{fProductName}, '%') </if>
  609. <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "0" '>
  610. and w.f_billstatus != 6
  611. </if>
  612. <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "1" '>
  613. and w.f_billstatus = 6
  614. </if>
  615. <if test='fDc != null and fDc != "" and fDc == "D" '>
  616. and w.f_dc = #{fDc}
  617. </if>
  618. <if test='fDc != null and fDc != "" and fDc == "C" '>
  619. and w.f_dc = #{fDc}
  620. </if>
  621. <if test='timeExamine != null and timeExamine[0] != null and timeExamine[0]!= ""'>
  622. and t.f_review_date &gt;= #{timeExamine[0]}
  623. </if>
  624. <if test='timeExamine != null and timeExamine[1] != null and timeExamine[1]!= ""'>
  625. and t.f_review_date &lt;= #{timeExamine[1]}
  626. </if>
  627. <if test='fReconciliation!= null and fReconciliation != "" and fReconciliation == "0" '>
  628. and ifnull(w.f_amount, 0) - ifnull(w.f_stlamount, 0) != 0
  629. </if>
  630. and t.f_review_date IS NOT NULL
  631. ${params.dataScope}
  632. GROUP BY
  633. w.f_pid,
  634. w.f_dc,
  635. w.f_corpid
  636. </where>
  637. ) a
  638. </select>
  639. <select id="selectTWarehousebillsItemsList"
  640. resultType="com.ruoyi.warehouseBusiness.domain.TWareHouseExcelItem">
  641. SELECT
  642. ( @ii := @ii + 1 ) AS fId,
  643. wi.src_bill_no AS fMblno,
  644. CASE
  645. wi.f_billtype
  646. WHEN 'SJRK' THEN
  647. '入库'
  648. WHEN 'SJCK' THEN
  649. '出库'
  650. WHEN 'HQZY' THEN
  651. '货转'
  652. WHEN 'CKDB' THEN
  653. '调拨'
  654. WHEN 'KCZZ' THEN
  655. '库存总账'
  656. END AS fBilltype,
  657. wi.f_product_name AS fGoodsid,
  658. wi.f_marks AS fMarks,
  659. dict.dict_label AS fFeeunitid,
  660. wi.f_qty AS fBillingQty,
  661. wi.f_unitprice AS fUnitprice,
  662. wi.f_bsdate AS fBsdate,
  663. wi.f_inventory_days AS fInventoryDays,
  664. wi.f_billing_days AS fBillingDays,
  665. f.f_name AS fFeeid,
  666. w.f_amt AS fAmt2
  667. FROM
  668. t_fee_do w
  669. LEFT JOIN t_warehousebillsfees wi ON w.f_srcid = wi.f_id
  670. LEFT JOIN t_fees f ON wi.f_feeid = f.f_id
  671. LEFT JOIN sys_dict_data dict ON dict.dict_value = wi.f_feeUnitid
  672. ,(
  673. SELECT
  674. @ii := 0
  675. ) AS ii
  676. WHERE
  677. dict.status = '0'
  678. AND dict.dict_type = 'data_unitfees'
  679. AND w.f_pid = #{fId}
  680. </select>
  681. <select id="warehouseBillsFeesProfitList" resultType="java.util.Map">
  682. SELECT
  683. t.f_id AS fSrcpid,
  684. c.f_name AS fName,
  685. c1.f_name AS fFeesName,
  686. w.f_mblno AS fMblno,
  687. w.f_product_name AS fProductName,
  688. w.f_marks AS fMarks,
  689. t.f_billtype AS fBilltype,
  690. w.f_review_date AS fReviewDate,
  691. sum( CASE f_dc WHEN 'D' THEN f_amount ELSE 0 END ) fAmount,
  692. sum( CASE f_dc WHEN 'C' THEN f_amount ELSE 0 END ) fStlamount,
  693. sum( CASE f_dc WHEN 'D' THEN f_amount ELSE 0 END ) - sum( CASE f_dc WHEN 'C' THEN f_amount ELSE 0 END ) nnfinished
  694. FROM
  695. t_warehousebillsfees w
  696. LEFT JOIN t_warehousebills t ON t.f_id = w.f_pid
  697. left join sys_user u on t.create_by = u.user_name
  698. left join sys_dept d on t.f_bsdeptid = d.dept_id
  699. LEFT JOIN t_corps c ON c.f_id = t.f_corpid
  700. LEFT JOIN t_corps c1 ON c1.f_id = w.f_corpid
  701. <where>
  702. <if test="fCorpid != null and fCorpid != ''">and t.f_corpid = #{fCorpid} </if>
  703. <if test="fToCorpid != null and fToCorpid != ''">and w.f_corpid = #{fToCorpid} </if>
  704. <if test="fMblno != null and fMblno != ''">and w.f_mblno like concat('%', #{fMblno}, '%') </if>
  705. <if test="fMarks != null and fMarks != ''">and w.f_marks like concat('%', #{fMarks}, '%') </if>
  706. <if test="fProductName != null and fProductName != ''">and w.f_product_name like concat('%', #{fProductName}, '%') </if>
  707. <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "0" '>
  708. and w.f_billstatus != 6
  709. </if>
  710. <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "1" '>
  711. and w.f_billstatus = 6
  712. </if>
  713. <if test='timeExamine != null and timeExamine[0] != null and timeExamine[0]!= ""'>
  714. and w.f_review_date &gt;= #{timeExamine[0]}
  715. </if>
  716. <if test='timeExamine != null and timeExamine[1] != null and timeExamine[1]!= ""'>
  717. and w.f_review_date &lt;= #{timeExamine[1]}
  718. </if>
  719. <if test='fReconciliation!= null and fReconciliation != "" and fReconciliation == "0" '>
  720. and ifnull(w.f_amount, 0) - ifnull(w.f_stlamount, 0) != 0
  721. </if>
  722. <if test="fBusinessType != null and fBusinessType != '' ">
  723. and w.f_business_type in
  724. <foreach collection="fBusinessType" item="id" open="(" close=")" separator=",">
  725. #{id}
  726. </foreach>
  727. </if>
  728. <if test="fFeeid != null and fFeeid != '' ">
  729. and w.f_feeid in
  730. <foreach collection="fFeeid" item="id" open="(" close=")" separator=",">
  731. #{id}
  732. </foreach>
  733. </if>
  734. and w.f_review_date IS NOT NULL
  735. ${params.dataScope}
  736. GROUP BY
  737. w.f_mblno
  738. </where>
  739. </select>
  740. <select id="selectFeeList" resultType="java.util.Map">
  741. select
  742. ware.create_by AS createBy,
  743. ware.f_billno AS fBillno,
  744. ware.f_ctrlcorpid AS fCtrlcorpid,
  745. ware.create_time AS createTime,
  746. ware.f_accbilldate AS fAccbilldate,
  747. ware.t_mblno AS tMblno,
  748. dict.dict_label AS chargingMethod,
  749. ware.invoice_no AS invoiceNo,
  750. ware.bank AS bank,
  751. ware.water_bill_no AS waterBillNo,
  752. ware.f_amtdr AS fAmtdr,
  753. ware.f_amtcr AS fAmtcr,
  754. ware.f_remarks AS fRemarks,
  755. CASE
  756. WHEN ware.f_billstatus = '1' THEN '保存'
  757. WHEN ware.f_billstatus = '2' THEN '暂存'
  758. WHEN ware.f_billstatus = '3' THEN '审批驳回'
  759. WHEN ware.f_billstatus = '4' THEN '提交审核'
  760. WHEN ware.f_billstatus = '5' THEN '审核中'
  761. WHEN ware.f_billstatus = '6' THEN '审核完成'
  762. END
  763. AS fBillstatus
  764. from
  765. t_fee ware
  766. left join sys_user u on ware.create_by = u.user_name
  767. left join sys_dept d on ware.f_deptid = d.dept_id
  768. LEFT JOIN sys_dict_data dict ON dict.dict_value = ware.charging_method
  769. <where>
  770. dict.status = '0'
  771. AND dict.dict_type = 'data_settlement_type'
  772. <if test="fBillno != null and fBillno != ''">and ware.f_billno = #{fBillno}</if>
  773. <if test="fCtrlcorpid != null ">and ware.f_ctrlcorpid = #{fCtrlcorpid}</if>
  774. <if test="fActId != null ">and ware.f_act_id = #{fActId}</if>
  775. <if test="fCorpid != null ">and ware.f_corpid = #{fCorpid}</if>
  776. <if test="fTransActId != null ">and ware.f_trans_act_id = #{fTransActId}</if>
  777. <if test="tMblno != null and tMblno != ''">and ware.t_mblno = #{tMblno}</if>
  778. <if test="fAmtdr != null ">and ware.f_amtdr = #{fAmtdr}</if>
  779. <if test="fAmtcr != null ">and ware.f_amtcr = #{fAmtcr}</if>
  780. <if test="fBilltype != null and fBilltype != ''">and ware.f_billtype = #{fBilltype}</if>
  781. <if test="fBillstatus != null and fBillstatus != ''">and ware.f_billstatus = #{fBillstatus}</if>
  782. <if test="fRemarks != null and fRemarks != ''">and ware.f_remarks = #{fRemarks}</if>
  783. <if test="fFromDate != null ">and ware.f_from_date = #{fFromDate}</if>
  784. <if test="fAccbilldate != null ">and ware.f_accbilldate = #{fAccbilldate}</if>
  785. <if test="fToDate != null ">and ware.f_to_date = #{fToDate}</if>
  786. <if test="fRefNo != null and fRefNo != ''">and ware.f_ref_no = #{fRefNo}</if>
  787. <if test="fDeptid != null ">and ware.f_deptid = #{fDeptid}</if>
  788. <if test='timeInterval != null and timeInterval[0] != null and timeInterval[0]!= ""'>
  789. and ware.f_accbilldate &gt;= #{timeInterval[0]}
  790. </if>
  791. <if test='timeInterval != null and timeInterval[1] != null and timeInterval[1]!= ""'>
  792. and ware.f_accbilldate &lt;= #{timeInterval[1]}
  793. </if>
  794. <if test="chargingMethod != null ">and ware.charging_method = #{chargingMethod}</if>
  795. <if test="invoiceNo != null ">and ware.invoice_no = #{invoiceNo}</if>
  796. <if test="bank != null ">and ware.bank = #{bank}</if>
  797. <if test="waterBillNo != null ">and ware.water_bill_no = #{waterBillNo}</if>
  798. </where>
  799. ${params.dataScope}
  800. </select>
  801. </mapper>