TWarehousebillsfeesMapper.xml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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.warehouseBusiness.mapper.TWarehousebillsfeesMapper">
  6. <resultMap type="TWarehousebillsfees" id="TWarehousebillsfeesResult">
  7. <result property="fId" column="f_id"/>
  8. <result property="fPid" column="f_pid"/>
  9. <result property="fLineno" column="f_lineno"/>
  10. <result property="fCorpid" column="f_corpid"/>
  11. <result property="fFeeid" column="f_feeid"/>
  12. <result property="fFeeunitid" column="f_feeUnitid"/>
  13. <result property="fWarehouseid" column="f_warehouseid"/>
  14. <result property="fQty" column="f_qty"/>
  15. <result property="fUnitprice" column="f_unitprice"/>
  16. <result property="fAmount" column="f_amount"/>
  17. <result property="fCurrency" column="f_currency"/>
  18. <result property="fExrate" column="f_exrate"/>
  19. <result property="fTaxrate" column="f_taxrate"/>
  20. <result property="fDc" column="f_dc"/>
  21. <result property="fBillstatus" column="f_billstatus"/>
  22. <result property="fReviewDate" column="f_review_date"/>
  23. <result property="fAccamount" column="f_accamount"/>
  24. <result property="fStatementNo" column="f_statement_no"/>
  25. <result property="fStlamount" column="f_stlamount"/>
  26. <result property="fInvnos" column="f_invnos"/>
  27. <result property="fAccamountDate" column="f_accamount_date"/>
  28. <result property="fInvamount" column="f_invamount"/>
  29. <result property="fStlamountNo" column="f_stlamount_no"/>
  30. <result property="fAskamount" column="f_askamount"/>
  31. <result property="fStatus" column="f_status"/>
  32. <result property="fStlamountDate" column="f_stlamount_date"/>
  33. <result property="delFlag" column="del_flag"/>
  34. <result property="createBy" column="create_by"/>
  35. <result property="createTime" column="create_time"/>
  36. <result property="updateBy" column="update_by"/>
  37. <result property="updateTime" column="update_time"/>
  38. <result property="remark" column="remark"/>
  39. <result property="srcId" column="src_id"/>
  40. <result property="srcBillNo" column="src_bill_no"/>
  41. <result property="fMblno" column="f_mblno"/>
  42. <result property="fProductName" column="f_product_name"/>
  43. <result property="fMarks" column="f_marks"/>
  44. <result property="fChargedate" column="f_chargedate"/>
  45. <result property="fBillingDeadline" column="f_billing_deadline"/>
  46. <result property="fInventoryDays" column="f_inventory_days"/>
  47. <result property="fAmt" column="f_amt"/>
  48. <result property="fBillingDays" column="f_billing_days"/>
  49. <result property="fBillingQty" column="f_billing_qty"/>
  50. <result property="fBilltype" column="f_billtype"/>
  51. <result property="fBillingway" column="f_billingway"/>
  52. <result property="fBsdate" column="f_bsdate"/>
  53. <result property="fOriginalbilldate" column="f_originalbilldate"/>
  54. <result property="fStltypeid" column="f_stltypeid"/>
  55. <result property="fBusinessType" column="f_business_type"/>
  56. <result property="fSrcTypeId" column="f_src_type_id"/>
  57. </resultMap>
  58. <sql id="selectTWarehousebillsfeesVo">
  59. select f_id,
  60. f_pid,
  61. f_lineno,
  62. f_corpid,
  63. f_feeid,
  64. f_warehouseid,
  65. f_feeUnitid,
  66. f_qty,
  67. f_unitprice,
  68. f_amount,
  69. f_currency,
  70. f_exrate,
  71. f_taxrate,
  72. f_dc,
  73. f_billstatus,
  74. f_review_date,
  75. f_statement_no,
  76. f_accamount,
  77. f_stlamount,
  78. f_accamount_date,
  79. f_invnos,
  80. f_invamount,
  81. f_stlamount_no,
  82. f_askamount,
  83. f_status,
  84. f_stlamount_date,
  85. del_flag,
  86. create_by,
  87. create_time,
  88. update_by,
  89. update_time,
  90. remark,
  91. src_id,
  92. src_bill_no,
  93. f_mblno,
  94. f_product_name,
  95. f_marks,
  96. f_chargedate,
  97. f_billing_deadline,
  98. f_inventory_days,
  99. f_amt,
  100. f_billing_days,
  101. f_billing_qty,
  102. f_billtype,
  103. f_billingway,
  104. f_bsdate,
  105. f_originalbilldate,
  106. f_stltypeid,
  107. f_business_type,
  108. f_src_type_id
  109. from t_warehousebillsfees
  110. </sql>
  111. <select id="selectTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  112. resultMap="TWarehousebillsfeesResult">
  113. <include refid="selectTWarehousebillsfeesVo"/>
  114. <where>
  115. <if test="fPid != null ">and f_pid = #{fPid}</if>
  116. <if test="fLineno != null ">and f_lineno = #{fLineno}</if>
  117. <if test="fCorpid != null ">and f_corpid = #{fCorpid}</if>
  118. <if test="fFeeid != null ">and f_feeid = #{fFeeid}</if>
  119. <if test="fFeeunitid != null ">and f_feeUnitid = #{fFeeunitid}</if>
  120. <if test="fQty != null ">and f_qty = #{fQty}</if>
  121. <if test="fUnitprice != null ">and f_unitprice = #{fUnitprice}</if>
  122. <if test="fAmount != null ">and f_amount = #{fAmount}</if>
  123. <if test="fCurrency != null and fCurrency != ''">and f_currency = #{fCurrency}</if>
  124. <if test="fExrate != null ">and f_exrate = #{fExrate}</if>
  125. <if test="fTaxrate != null ">and f_taxrate = #{fTaxrate}</if>
  126. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  127. <if test="fBillstatus != null and fBillstatus != ''">and f_billstatus = #{fBillstatus}</if>
  128. <if test="fReviewDate != null ">and f_review_date = #{fReviewDate}</if>
  129. <if test="fStatementNo != null and fStatementNo != ''">and f_statement_no = #{fStatementNo}</if>
  130. <if test="fAccamount != null ">and f_accamount = #{fAccamount}</if>
  131. <if test="fStlamount != null ">and f_stlamount = #{fStlamount}</if>
  132. <if test="fAccamountDate != null ">and f_accamount_date = #{fAccamountDate}</if>
  133. <if test="fInvnos != null and fInvnos != ''">and f_invnos = #{fInvnos}</if>
  134. <if test="fInvamount != null ">and f_invamount = #{fInvamount}</if>
  135. <if test="fStlamountNo != null and fStlamountNo != ''">and f_stlamount_no = #{fStlamountNo}</if>
  136. <if test="fAskamount != null ">and f_askamount = #{fAskamount}</if>
  137. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  138. <if test="fStlamountDate != null ">and f_stlamount_date = #{fStlamountDate}</if>
  139. <if test="srcId != null ">and src_id = #{srcId}</if>
  140. <if test="srcBillNo != null and srcBillNo != ''">and src_bill_no = #{srcBillNo}</if>
  141. <if test="fMblno != null and fMblno != ''">and f_mblno = #{fMblno}</if>
  142. <if test="fProductName != null and fProductName != ''">and f_product_name like concat('%', #{fProductName},
  143. '%')
  144. </if>
  145. <if test="fMarks != null and fMarks != ''">and f_marks = #{fMarks}</if>
  146. <if test="fChargedate != null ">and f_chargedate = #{fChargedate}</if>
  147. <if test="fBillingDeadline != null ">and f_billing_deadline = #{fBillingDeadline}</if>
  148. <if test="fInventoryDays != null ">and f_inventory_days = #{fInventoryDays}</if>
  149. <if test="fAmt != null ">and f_amt = #{fAmt}</if>
  150. <if test="fBillingDays != null ">and f_billing_days = #{fBillingDays}</if>
  151. <if test="fBillingQty != null ">and f_billing_qty = #{fBillingQty}</if>
  152. <if test="fBilltype != null and fBilltype != ''">and f_billtype = #{fBilltype}</if>
  153. <if test="fBillingway != null ">and f_billingway = #{fBillingway}</if>
  154. <if test="fBsdate != null ">and f_bsdate = #{fBsdate}</if>
  155. <if test="fOriginalbilldate != null ">and f_originalbilldate = #{fOriginalbilldate}</if>
  156. <if test="fStltypeid != null">and f_stltypeid = #{fStltypeid},</if>
  157. <if test="fSrcTypeId != null">and f_src_type_id = #{fSrcTypeId},</if>
  158. </where>
  159. </select>
  160. <select id="selectTWarehousebillsfeesById" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  161. <include refid="selectTWarehousebillsfeesVo"/>
  162. where f_id = #{fId}
  163. </select>
  164. <select id="selectTWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  165. select f_id, f_pid, f_billing_deadline
  166. where f_pid = #{fId}
  167. and f_billtype = 'SJCK'
  168. </select>
  169. <select id="selectWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  170. <include refid="selectTWarehousebillsfeesVo"/>
  171. where f_pid = #{fId}
  172. </select>
  173. <select id="selectReconciliation" resultType="java.lang.Integer">
  174. SELECT COUNT(d.f_id)
  175. FROM t_fee_do d
  176. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  177. WHERE d.f_srcpid = #{fId}
  178. AND f.f_billtype = 'DZ'
  179. </select>
  180. <select id="selectCharge" resultType="java.lang.Integer">
  181. SELECT COUNT(d.f_id)
  182. FROM t_fee_do d
  183. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  184. WHERE d.f_srcpid = #{fId}
  185. AND f.f_billtype = 'SF'
  186. </select>
  187. <select id="selectPay" resultType="java.lang.Integer">
  188. SELECT COUNT(d.f_id)
  189. FROM t_fee_do d
  190. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  191. WHERE d.f_srcpid = #{fId}
  192. AND f.f_billtype = 'FF'
  193. </select>
  194. <select id="selectFleetExcelMonthList" parameterType="TWarehousebillsfees" resultType="com.ruoyi.finance.excel.FleetExcel">
  195. SELECT
  196. CONCAT( MONTH ( s.f_bsdate ), '月份小计:' ) feelMonthName,
  197. CONCAT(
  198. YEAR ( s.f_bsdate ),
  199. '-',
  200. MONTH ( s.f_bsdate )) feelMonth,
  201. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  202. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  203. sum( s.f_amount ) totalAmount,
  204. sum( s.f_invamount ) invamount,
  205. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  206. FROM
  207. t_warehousebillsfees s
  208. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  209. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  210. WHERE
  211. s.f_dc = 'D'
  212. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  213. and s.f_bsdate &gt;= #{fMonth[0]}
  214. </if>
  215. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  216. and s.f_bsdate &lt;= #{fMonth[1]}
  217. </if>
  218. GROUP BY
  219. CONCAT(
  220. YEAR ( f_bsdate ),
  221. '-',
  222. MONTH ( f_bsdate ))
  223. </select>
  224. <select id="selectFleetExcelList" parameterType="TWarehousebillsfees" resultType="com.ruoyi.finance.excel.FleetExcel">
  225. SELECT
  226. #{createBy} userName,
  227. CONCAT(
  228. YEAR ( s.f_bsdate ),
  229. '-',
  230. MONTH ( s.f_bsdate )) feelMonth,
  231. c.f_name corpName,
  232. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  233. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  234. sum( s.f_amount ) totalAmount,
  235. IF
  236. ( f_invamount = 0, 'F', 'T' ) isInvoice,
  237. sum( s.f_invamount ) invamount,
  238. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  239. FROM
  240. t_warehousebillsfees s
  241. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  242. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  243. WHERE
  244. s.f_dc = 'D'
  245. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  246. and s.f_bsdate &gt;= #{fMonth[0]}
  247. </if>
  248. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  249. and s.f_bsdate &lt;= #{fMonth[1]}
  250. </if>
  251. GROUP BY CONCAT( YEAR ( f_bsdate ), '-', MONTH ( f_bsdate )), s.f_corpid, c.f_name
  252. </select>
  253. <insert id="insertTWarehousebillsfees" parameterType="TWarehousebillsfees" useGeneratedKeys="true"
  254. keyProperty="fId">
  255. insert into t_warehousebillsfees
  256. <trim prefix="(" suffix=")" suffixOverrides=",">
  257. <if test="fPid != null">f_pid,</if>
  258. <if test="fLineno != null">f_lineno,</if>
  259. <if test="fCorpid != null">f_corpid,</if>
  260. <if test="fFeeid != null">f_feeid,</if>
  261. <if test="fWarehouseid != null">f_warehouseid,</if>
  262. <if test="fFeeunitid != null">f_feeUnitid,</if>
  263. <if test="fQty != null">f_qty,</if>
  264. <if test="fUnitprice != null">f_unitprice,</if>
  265. <if test="fAmount != null">f_amount,</if>
  266. <if test="fCurrency != null">f_currency,</if>
  267. <if test="fExrate != null">f_exrate,</if>
  268. <if test="fTaxrate != null">f_taxrate,</if>
  269. <if test="fDc != null">f_dc,</if>
  270. <if test="fBillstatus != null">f_billstatus,</if>
  271. <if test="fReviewDate != null">f_review_date,</if>
  272. <if test="fStatementNo != null">f_statement_no,</if>
  273. <if test="fAccamount != null">f_accamount,</if>
  274. <if test="fStlamount != null">f_stlamount,</if>
  275. <if test="fAccamountDate != null">f_accamount_date,</if>
  276. <if test="fInvnos != null">f_invnos,</if>
  277. <if test="fInvamount != null">f_invamount,</if>
  278. <if test="fStlamountNo != null">f_stlamount_no,</if>
  279. <if test="fAskamount != null">f_askamount,</if>
  280. <if test="fStatus != null">f_status,</if>
  281. <if test="fStlamountDate != null">f_stlamount_date,</if>
  282. <if test="delFlag != null">del_flag,</if>
  283. <if test="createBy != null">create_by,</if>
  284. <if test="createTime != null">create_time,</if>
  285. <if test="updateBy != null">update_by,</if>
  286. <if test="updateTime != null">update_time,</if>
  287. <if test="remark != null">remark,</if>
  288. <if test="srcId != null">src_id,</if>
  289. <if test="srcBillNo != null">src_bill_no,</if>
  290. <if test="fMblno != null">f_mblno,</if>
  291. <if test="fProductName != null">f_product_name,</if>
  292. <if test="fMarks != null">f_marks,</if>
  293. <if test="fChargedate != null">f_chargedate,</if>
  294. <if test="fBillingDeadline != null">f_billing_deadline,</if>
  295. <if test="fInventoryDays != null">f_inventory_days,</if>
  296. <if test="fAmt != null">f_amt,</if>
  297. <if test="fBillingDays != null">f_billing_days,</if>
  298. <if test="fBillingQty != null">f_billing_qty,</if>
  299. <if test="fBilltype != null">f_billtype,</if>
  300. <if test="fBillingway != null">f_billingway,</if>
  301. <if test="fBsdate != null">f_bsdate,</if>
  302. <if test="fOriginalbilldate != null">f_originalbilldate,</if>
  303. <if test="fStltypeid != null">f_stltypeid,</if>
  304. <if test="fBusinessType != null">f_business_type,</if>
  305. <if test="fSrcTypeId != null">f_src_type_id,</if>
  306. </trim>
  307. <trim prefix="values (" suffix=")" suffixOverrides=",">
  308. <if test="fPid != null">#{fPid},</if>
  309. <if test="fLineno != null">#{fLineno},</if>
  310. <if test="fCorpid != null">#{fCorpid},</if>
  311. <if test="fFeeid != null">#{fFeeid},</if>
  312. <if test="fWarehouseid != null">#{fWarehouseid},</if>
  313. <if test="fFeeunitid != null">#{fFeeunitid},</if>
  314. <if test="fQty != null">#{fQty},</if>
  315. <if test="fUnitprice != null">#{fUnitprice},</if>
  316. <if test="fAmount != null">#{fAmount},</if>
  317. <if test="fCurrency != null">#{fCurrency},</if>
  318. <if test="fExrate != null">#{fExrate},</if>
  319. <if test="fTaxrate != null">#{fTaxrate},</if>
  320. <if test="fDc != null">#{fDc},</if>
  321. <if test="fBillstatus != null">#{fBillstatus},</if>
  322. <if test="fReviewDate != null">#{fReviewDate},</if>
  323. <if test="fStatementNo != null">#{fStatementNo},</if>
  324. <if test="fAccamount != null">#{fAccamount},</if>
  325. <if test="fStlamount != null">#{fStlamount},</if>
  326. <if test="fAccamountDate != null">#{fAccamountDate},</if>
  327. <if test="fInvnos != null">#{fInvnos},</if>
  328. <if test="fInvamount != null">#{fInvamount},</if>
  329. <if test="fStlamountNo != null">#{fStlamountNo},</if>
  330. <if test="fAskamount != null">#{fAskamount},</if>
  331. <if test="fStatus != null">#{fStatus},</if>
  332. <if test="fStlamountDate != null">#{fStlamountDate},</if>
  333. <if test="delFlag != null">#{delFlag},</if>
  334. <if test="createBy != null">#{createBy},</if>
  335. <if test="createTime != null">#{createTime},</if>
  336. <if test="updateBy != null">#{updateBy},</if>
  337. <if test="updateTime != null">#{updateTime},</if>
  338. <if test="remark != null">#{remark},</if>
  339. <if test="srcId != null">#{srcId},</if>
  340. <if test="srcBillNo != null">#{srcBillNo},</if>
  341. <if test="fMblno != null">#{fMblno},</if>
  342. <if test="fProductName != null">#{fProductName},</if>
  343. <if test="fMarks != null">#{fMarks},</if>
  344. <if test="fChargedate != null">#{fChargedate},</if>
  345. <if test="fBillingDeadline != null">#{fBillingDeadline},</if>
  346. <if test="fInventoryDays != null">#{fInventoryDays},</if>
  347. <if test="fAmt != null">#{fAmt},</if>
  348. <if test="fBillingDays != null">#{fBillingDays},</if>
  349. <if test="fBillingQty != null">#{fBillingQty},</if>
  350. <if test="fBilltype != null">#{fBilltype},</if>
  351. <if test="fBillingway != null">#{fBillingway},</if>
  352. <if test="fBsdate != null">#{fBsdate},</if>
  353. <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
  354. <if test="fStltypeid != null">#{fStltypeid},</if>
  355. <if test="fBusinessType != null">#{fBusinessType},</if>
  356. <if test="fSrcTypeId != null">#{fSrcTypeId},</if>
  357. </trim>
  358. </insert>
  359. <update id="updateTWarehousebillsfees" parameterType="TWarehousebillsfees">
  360. update t_warehousebillsfees
  361. <trim prefix="SET" suffixOverrides=",">
  362. <if test="fPid != null">f_pid = #{fPid},</if>
  363. <if test="fLineno != null">f_lineno = #{fLineno},</if>
  364. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  365. <if test="fFeeid != null">f_feeid = #{fFeeid},</if>
  366. <if test="fFeeunitid != null">f_feeUnitid = #{fFeeunitid},</if>
  367. <if test="fQty != null">f_qty = #{fQty},</if>
  368. <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
  369. <if test="fUnitprice != null">f_unitprice = #{fUnitprice},</if>
  370. <if test="fAmount != null">f_amount = #{fAmount},</if>
  371. <if test="fCurrency != null">f_currency = #{fCurrency},</if>
  372. <if test="fExrate != null">f_exrate = #{fExrate},</if>
  373. <if test="fTaxrate != null">f_taxrate = #{fTaxrate},</if>
  374. <if test="fDc != null">f_dc = #{fDc},</if>
  375. <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
  376. <if test="fReviewDate != null">f_review_date = #{fReviewDate},</if>
  377. <if test="fStatementNo != null">f_statement_no = #{fStatementNo},</if>
  378. <if test="fAccamount != null">f_accamount = #{fAccamount},</if>
  379. <if test="fStlamount != null">f_stlamount = #{fStlamount},</if>
  380. <if test="fAccamountDate != null">f_accamount_date = #{fAccamountDate},</if>
  381. <if test="fInvnos != null">f_invnos = #{fInvnos},</if>
  382. <if test="fInvamount != null">f_invamount = #{fInvamount},</if>
  383. <if test="fStlamountNo != null">f_stlamount_no = #{fStlamountNo},</if>
  384. <if test="fAskamount != null">f_askamount = #{fAskamount},</if>
  385. <if test="fStatus != null">f_status = #{fStatus},</if>
  386. <if test="fStlamountDate != null">f_stlamount_date = #{fStlamountDate},</if>
  387. <if test="delFlag != null">del_flag = #{delFlag},</if>
  388. <if test="createBy != null">create_by = #{createBy},</if>
  389. <if test="createTime != null">create_time = #{createTime},</if>
  390. <if test="updateBy != null">update_by = #{updateBy},</if>
  391. <if test="updateTime != null">update_time = #{updateTime},</if>
  392. <if test="remark != null">remark = #{remark},</if>
  393. <if test="srcId != null">src_id = #{srcId},</if>
  394. <if test="srcBillNo != null">src_bill_no = #{srcBillNo},</if>
  395. <if test="fMblno != null">f_mblno = #{fMblno},</if>
  396. <if test="fProductName != null">f_product_name = #{fProductName},</if>
  397. <if test="fMarks != null">f_marks = #{fMarks},</if>
  398. <if test="fChargedate != null">f_chargedate = #{fChargedate},</if>
  399. <if test="fBillingDeadline != null">f_billing_deadline = #{fBillingDeadline},</if>
  400. <if test="fInventoryDays != null">f_inventory_days = #{fInventoryDays},</if>
  401. <if test="fAmt != null">f_amt = #{fAmt},</if>
  402. <if test="fBillingDays != null">f_billing_days = #{fBillingDays},</if>
  403. <if test="fBillingQty != null">f_billing_qty = #{fBillingQty},</if>
  404. <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
  405. <if test="fBillingway != null">f_billingway = #{fBillingway},</if>
  406. <if test="fBsdate != null">f_bsdate = #{fBsdate},</if>
  407. <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
  408. <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
  409. <if test="fSrcTypeId != null">f_src_type_id = #{fSrcTypeId},</if>
  410. </trim>
  411. where f_id = #{fId}
  412. </update>
  413. <delete id="deleteTWarehousebillsfeesById" parameterType="Long">
  414. delete
  415. from t_warehousebillsfees
  416. where f_id = #{fId}
  417. </delete>
  418. <delete id="deleteByFPid" parameterType="Long">
  419. delete
  420. from t_warehousebillsfees
  421. where f_pid = #{fId}
  422. </delete>
  423. <delete id="deleteTWarehousebillsfeesByIds" parameterType="String">
  424. delete from t_warehousebillsfees where f_id in
  425. <foreach item="fId" collection="array" open="(" separator="," close=")">
  426. #{fId}
  427. </foreach>
  428. </delete>
  429. <update id="warehouseFeesFollowUpdate">
  430. update
  431. t_warehousebillsfees
  432. <trim prefix="SET" suffixOverrides=",">
  433. <if test="fettle != null">f_billstatus = #{fettle},</if>
  434. <if test="auditItem != null and fettle == 6">f_review_date = #{auditItem},</if>
  435. <if test="auditItem != null and fettle != 6">f_review_date = null,</if>
  436. </trim>
  437. where f_pid = #{fPid}
  438. </update>
  439. <update id="updateTWarehousebillsfee" parameterType="Map">
  440. update t_warehousebillsfees
  441. <trim prefix="SET" suffixOverrides=",">
  442. /*判断确认对账*/
  443. <if test="map.billType == 'DZ'">
  444. f_statement_no = #{map.tFee.fBillno},
  445. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  446. f_accamount_date = #{map.tFee.fAccbilldate}
  447. </if>
  448. /*判断撤销对账*/
  449. <if test="map.billType == 'DZRevoke'">
  450. f_statement_no = #{map.tFee.fBillno},
  451. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  452. f_accamount_date = #{map.tFee.fAccbilldate}
  453. </if>
  454. /*判断收付款*/
  455. <if test="map.billType == 'DC'">
  456. f_stlamount_no = #{map.tFee.fBillno},
  457. f_stlamount = f_stlamount + #{map.tFeeDo.fAmt},
  458. f_stlamount_date =#{map.tFee.fAccbilldate}
  459. </if>
  460. /*判断撤销收付款*/
  461. <if test="map.billType == 'DCRevoke'">
  462. f_stlamount_no = #{map.tFee.fBillno},
  463. f_stlamount = f_stlamount - #{map.tFeeDo.fAmt},
  464. f_stlamount_date =#{map.tFee.fAccbilldate}
  465. </if>
  466. /*判断开发票款*/
  467. <if test="map.billType == 'invoiceFP'">
  468. f_invamount = f_invamount + #{map.tFeeDo.fAmt},
  469. f_stlamount_date =#{map.tFee.fAccbilldate}
  470. </if>
  471. <if test="map.billType == 'DZinvoiceFP'">
  472. f_invamount = f_invamount - #{map.tFeeDo.fAmt},
  473. f_stlamount_date =#{map.tFee.fAccbilldate}
  474. </if>
  475. /*判断申请发票款*/
  476. <if test="map.billType == 'ApplyFP'">
  477. f_askamount = f_askamount + #{map.tFeeDo.fAmt},
  478. f_stlamount_date =#{map.tFee.fAccbilldate}
  479. </if>
  480. <if test="map.billType == 'DZApplyFP'">
  481. f_askamount = f_askamount - #{map.tFeeDo.fAmt},
  482. f_stlamount_date =#{map.tFee.fAccbilldate}
  483. </if>
  484. /*判断确认对账*/
  485. <if test="map.billType == 'KHDZ'">
  486. f_statement_no = #{map.tFee.fBillno},
  487. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  488. f_accamount_date = #{map.tFee.fAccbilldate}
  489. </if>
  490. /*判断撤销对账*/
  491. <if test="map.billType == 'KHDZRevoke'">
  492. f_statement_no = #{map.tFee.fBillno},
  493. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  494. f_accamount_date = #{map.tFee.fAccbilldate}
  495. </if>
  496. </trim>
  497. where f_id = #{map.tFeeDo.fSrcid}
  498. </update>
  499. <select id="selectFeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  500. SELECT
  501. tw.f_id,
  502. tw.f_pid,
  503. tw.f_lineno,
  504. tw.f_corpid,
  505. tc.f_name corpName,
  506. tw.f_feeid,
  507. tf.f_name feeName,
  508. tw.f_feeUnitid,
  509. tw.f_qty,
  510. tw.f_unitprice,
  511. tw.f_amount,
  512. tw.f_currency,
  513. tw.f_exrate,
  514. tw.f_taxrate,
  515. tw.f_dc,
  516. tw.f_billstatus,
  517. CASE
  518. WHEN tw.f_billstatus = '1' THEN
  519. '新建'
  520. WHEN tw.f_billstatus = '2' THEN
  521. '暂存'
  522. WHEN tw.f_billstatus = '3' THEN
  523. '驳回'
  524. WHEN tw.f_billstatus = '4' THEN
  525. '提交'
  526. WHEN tw.f_billstatus = '5' THEN
  527. '审批中'
  528. WHEN tw.f_billstatus = '6' THEN
  529. '审批通过'
  530. END AS fBillstatusName,
  531. tw.f_review_date,
  532. tw.f_statement_no,
  533. tw.f_accamount,
  534. tw.f_stlamount,
  535. tw.f_accamount_date,
  536. tw.f_invnos,
  537. tw.f_invamount,
  538. tw.f_stlamount_no,
  539. tw.f_askamount,
  540. tw.f_status,
  541. tw.f_stlamount_date,
  542. tw.del_flag,
  543. tw.create_by,
  544. tw.create_time,
  545. tw.update_by,
  546. tw.update_time,
  547. tw.remark,
  548. tw.src_id,
  549. tw.src_bill_no,
  550. tw.f_mblno,
  551. tw.f_product_name,
  552. tw.f_marks,
  553. tw.f_chargedate,
  554. tw.f_billing_deadline,
  555. tw.f_inventory_days,
  556. tw.f_amt,
  557. tw.f_billing_days,
  558. tw.f_billing_qty,
  559. tw.f_billtype,
  560. tw.f_billingway,
  561. tw.f_bsdate,
  562. tw.f_originalbilldate,
  563. tw.f_stltypeid,
  564. tw.f_business_type,
  565. tw.f_src_type_id
  566. FROM
  567. t_warehousebillsfees tw
  568. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  569. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  570. where tw.f_pid = #{fPid}
  571. and tw.f_billtype = 'KHDD'
  572. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  573. </select>
  574. <delete id="deleteFessByFPid" parameterType="object">
  575. delete
  576. from t_warehousebillsfees
  577. where f_pid = #{fPid}
  578. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  579. </delete>
  580. <!--网页版查询对账-->
  581. <select id="webVersionReconciliation" parameterType="TAccount" resultType="map">
  582. SELECT
  583. tb.f_billno AS fBillno,
  584. /**运单号*/
  585. tv.f_name AS vesselName,
  586. /**船名*/
  587. ty.f_no AS voyageName,
  588. /**航次*/
  589. tc.f_name AS invoice,
  590. /**收费单位*/
  591. tc.f_name AS drawee,
  592. /**受票单位*/
  593. tp.f_name AS corpName,
  594. /**货权方*/
  595. pro.dict_label AS fPaymode,
  596. /**付款方式*/
  597. te.f_name AS payment,
  598. /**费用名称*/
  599. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmtdr,
  600. /**原始金额*/
  601. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmt,
  602. /**本次金额*/
  603. ta.f_name AS fLoadportidName,
  604. /**始发港*/
  605. tr.f_name AS fDestportidName,
  606. /**目的港*/
  607. pr.dict_label AS fServiceitems,
  608. /**运输条款*/
  609. tg.f_name AS goodName,
  610. /**货名*/
  611. tn.f_name AS transit,
  612. /**箱型*/
  613. items.f_cntrcount AS fCntrcount,
  614. /**箱量*/
  615. tb.f_shippername AS fShippername,
  616. /**发货人*/
  617. tb.f_consigneername AS fConsigneername,
  618. /**收货人*/
  619. tf.f_id AS fSrcid,
  620. tf.f_pid AS fSrcpid,
  621. tf.create_by AS createBy,
  622. tf.create_time AS createTime,
  623. tf.update_by AS updateBy,
  624. tf.update_time AS updateTime,
  625. tf.remark AS remark,
  626. tf.f_mblno AS fMblno,
  627. tf.f_corpid AS fCorpid,
  628. tf.f_feeid AS fFeeid
  629. FROM
  630. t_warehousebillsfees tf
  631. LEFT JOIN t_corps tc ON tc.f_id = tf.f_corpid
  632. LEFT JOIN t_fees te ON te.f_id = tf.f_feeid
  633. LEFT JOIN t_warehousebills tb ON tb.f_id = tf.f_pid
  634. LEFT JOIN t_vessel tv ON tv.f_id = tb.f_vslid
  635. LEFT JOIN t_voyage ty ON ty.f_id = tb.f_voyid
  636. LEFT JOIN t_address ta ON ta.f_id = tb.f_loadportid
  637. LEFT JOIN t_address tr ON tr.f_id = tb.f_destportid
  638. LEFT JOIN sys_dict_data pro ON pro.dict_value = tb.f_paymode
  639. AND pro.dict_type = 'data_settlement_type'
  640. LEFT JOIN sys_dict_data pr ON pr.dict_value = tb.f_serviceitems
  641. AND pr.dict_type = 'f_serviceitems'
  642. LEFT JOIN ( SELECT f_pid, MAX( f_goodsid ) f_goodsid FROM t_warehousebills_cntr GROUP BY f_pid ) w ON w.f_pid = tb.f_id
  643. LEFT JOIN t_goods tg ON tg.f_id = w.f_goodsid
  644. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items ON items.f_pid = tb.f_id
  645. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON twc.f_pid = tb.f_id
  646. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  647. LEFT JOIN t_corps tp ON tp.f_id = tb.f_corpid
  648. WHERE
  649. tf.f_billstatus = 6
  650. AND tf.f_dc = 'D'
  651. AND tb.f_typeid = 1
  652. and tb.f_review_date IS NOT NULL
  653. and ifnull(tf.f_amount, 0) - ifnull(tf.f_accamount, 0) > 0
  654. <if test="fLoadportid != null">and tb.f_loadportid = #{fLoadportid}</if>
  655. <if test="fDestportid != null">and tb.f_destportid = #{fDestportid}</if>
  656. <if test="fInvoceobj != null and fInvoceobj != ''">and tb.f_invoceobj like concat('%', #{fInvoceobj}, '%') </if>
  657. <if test="fShippername != null and fShippername != ''">and tb.f_shippername like concat('%', #{fShippername}, '%') </if>
  658. <if test="fConsigneername != null and fConsigneername != ''">and tb.f_consigneername like concat('%', #{fConsigneername}, '%') </if>
  659. <if test="fMblno != null and fMblno != ''">and tb.f_mblno like concat('%', #{fMblno}, '%') </if>
  660. <if test="fBillno != null and fBillno != ''">and tb.f_billno like concat('%', #{fBillno}, '%') </if>
  661. <if test="fVslid != null">and tb.f_vslid = #{fVslid}</if>
  662. <if test="fVoyid != null">and tb.f_voyid = #{fVoyid}</if>
  663. <if test="fCorpid != null">and tf.f_corpid = #{fCorpid}</if>
  664. <if test="fPaymodeid != null">and tb.f_paymode = #{fPaymodeid}</if>
  665. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  666. and tf.create_time &gt;= #{sailTime[0]}
  667. </if>
  668. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  669. and tf.create_time &lt;= #{sailTime[1]}
  670. </if>
  671. <if test="fDocmentdate != null and fDocmentdate != ''">and tb.f_docmentdate = #{fDocmentdate}</if>
  672. <if test="createBy != null and createBy != ''">and tb.create_by = #{createBy}</if>
  673. <if test="goodName != null and goodName != ''">and tg.f_name like concat('%', #{goodName}, '%')</if>
  674. ORDER BY tf.f_id desc
  675. </select>
  676. <!--网页版查询对账明细-->
  677. <select id="webVersionDetail" parameterType="TAccount" resultType="map">
  678. SELECT
  679. tf.f_id AS fId,
  680. te.f_billno AS accountBillno,
  681. /**账单编号*/
  682. tw.f_billno AS fBillno,
  683. /**运单编号*/
  684. tv.f_name AS vesselName,
  685. /**船名*/
  686. ty.f_no AS voyageName,
  687. /**航次*/
  688. te.f_ctrlcorpid AS fCtrlcorpid,
  689. /**获权方*/
  690. tp.f_name AS corpName,
  691. /**结算单位*/
  692. ta.f_name AS fLoadportidName,
  693. /**始发港*/
  694. tr.f_name AS fDestportidName,
  695. /**目的港*/
  696. pr.dict_label AS fServiceitems,
  697. /**运输条款*/
  698. ts.f_name AS payment,
  699. /**费用名称*/
  700. tf.f_amtdr AS fAmtdr,
  701. /**原始金额*/
  702. tf.f_amt AS fAmt,
  703. /**本次金额*/
  704. tn.f_name AS transit,
  705. /**箱型*/
  706. items.f_cntrcount AS fCntrcount,
  707. /**箱量*/
  708. tf.create_by AS createBy,
  709. tf.create_time AS createTime,
  710. CASE
  711. WHEN te.f_billstatus = '1' THEN
  712. '保存'
  713. WHEN te.f_billstatus = '2' THEN
  714. '暂存'
  715. WHEN te.f_billstatus = '3' THEN
  716. '审批驳回'
  717. WHEN te.f_billstatus = '4' THEN
  718. '提交审核'
  719. WHEN te.f_billstatus = '5' THEN
  720. '审核中'
  721. WHEN te.f_billstatus = '6' THEN
  722. '审核完成'
  723. END AS fBillstatus
  724. FROM
  725. t_fee_do tf
  726. LEFT JOIN t_fee te ON te.f_id = tf.f_pid
  727. LEFT JOIN t_warehousebills tw ON tf.f_srcpid = tw.f_id
  728. LEFT JOIN t_warehousebillsfees th ON th.f_id = tf.f_srcid
  729. LEFT JOIN t_vessel tv ON tw.f_vslid = tv.f_id
  730. LEFT JOIN t_voyage ty ON ty.f_id = tw.f_voyid
  731. LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
  732. LEFT JOIN t_address tr ON tr.f_id = tw.f_destportid
  733. LEFT JOIN sys_dict_data pr ON pr.dict_value = tw.f_serviceitems
  734. AND pr.dict_type = 'f_serviceitems'
  735. LEFT JOIN t_fees ts ON ts.f_id = tf.f_feeid
  736. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items ON items.f_pid = tw.f_id
  737. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON twc.f_pid = tw.f_id
  738. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  739. LEFT JOIN t_corps tp ON tp.f_id = te.f_corpid
  740. WHERE
  741. te.f_billtype = 'KHDZ'
  742. <if test="fLoadportid != null">and tw.f_loadportid = #{fLoadportid}</if>
  743. <if test="fDestportid != null">and tw.f_destportid = #{fDestportid}</if>
  744. <if test="fInvoceobj != null and fInvoceobj != ''">and tw.f_invoceobj like concat('%', #{fInvoceobj}, '%') </if>
  745. <if test="fShippername != null and fShippername != ''">and tw.f_shippername like concat('%', #{fShippername}, '%') </if>
  746. <if test="fConsigneername != null and fConsigneername != ''">and tw.f_consigneername like concat('%', #{fConsigneername}, '%') </if>
  747. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  748. <if test="fVslid != null">and tw.f_vslid = #{fVslid}</if>
  749. <if test="fId != null">and tf.f_id = #{fId}</if>
  750. <if test="fVoyid != null">and tw.f_voyid = #{fVoyid}</if>
  751. <if test="fCorpid != null">and te.f_corpid = #{fCorpid}</if>
  752. <if test="fPaymodeid != null">and tw.f_paymode = #{fPaymodeid}</if>
  753. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  754. and tf.create_time &gt;= #{sailTime[0]}
  755. </if>
  756. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  757. and tf.create_time &lt;= #{sailTime[1]}
  758. </if>
  759. <if test="fDocmentdate != null and fDocmentdate != ''">and tw.f_docmentdate = #{fDocmentdate}</if>
  760. <if test="createBy != null and createBy != ''">and te.create_by = #{createBy}</if>
  761. <if test="accountBillno != null and accountBillno != ''">and te.f_billno = #{accountBillno}</if>
  762. ORDER BY tf.f_id desc
  763. </select>
  764. <select id="selectTWarehousebillsfeesSrcId" parameterType="Long" resultType="long">
  765. select src_id
  766. FROM
  767. t_warehousebillsfees
  768. where f_pid = #{fId}
  769. AND src_id IS NOT NULL
  770. </select>
  771. <select id="accountsDue" resultType="map">
  772. SELECT
  773. CASE MONTH(tf.create_time) WHEN '1' THEN SUM(tf.f_amount) ELSE 0 END AS January,
  774. CASE MONTH(tf.create_time) WHEN '2' THEN SUM(tf.f_amount) ELSE 0 END AS February,
  775. CASE MONTH(tf.create_time) WHEN '3' THEN SUM(tf.f_amount) ELSE 0 END AS March,
  776. CASE MONTH(tf.create_time) WHEN '4' THEN SUM(tf.f_amount) ELSE 0 END AS April,
  777. CASE MONTH(tf.create_time) WHEN '5' THEN SUM(tf.f_amount) ELSE 0 END AS May,
  778. CASE MONTH(tf.create_time) WHEN '6' THEN SUM(tf.f_amount) ELSE 0 END AS June,
  779. CASE MONTH(tf.create_time) WHEN '7' THEN SUM(tf.f_amount) ELSE 0 END AS July,
  780. CASE MONTH(tf.create_time) WHEN '8' THEN SUM(tf.f_amount) ELSE 0 END AS August,
  781. CASE MONTH(tf.create_time) WHEN '9' THEN SUM(tf.f_amount) ELSE 0 END AS September,
  782. CASE MONTH(tf.create_time) WHEN '10' THEN SUM(tf.f_amount) ELSE 0 END AS October,
  783. CASE MONTH(tf.create_time) WHEN '11' THEN SUM(tf.f_amount) ELSE 0 END AS November,
  784. CASE MONTH(tf.create_time) WHEN '12' THEN SUM(tf.f_amount) ELSE 0 END AS December,
  785. tc.f_name corpName
  786. FROM
  787. t_warehousebillsfees tf
  788. LEFT JOIN t_corps tc ON tf.f_corpid = tc.f_id
  789. WHERE ifnull(tf.f_amount, 0) - ifnull(tf.f_stlamount, 0) >0
  790. AND tf.f_dc = 'D'
  791. AND YEAR(tf.create_time) = YEAR(NOW())
  792. GROUP BY tf.f_corpid
  793. LIMIT 10
  794. </select>
  795. </mapper>