TWarehousebillsfeesMapper.xml 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  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="fShipper" column="f_shipper"/>
  12. <result property="fFeeid" column="f_feeid"/>
  13. <result property="fFeeunitid" column="f_feeUnitid"/>
  14. <result property="fWarehouseid" column="f_warehouseid"/>
  15. <result property="fQty" column="f_qty"/>
  16. <result property="fUnitprice" column="f_unitprice"/>
  17. <result property="fAmount" column="f_amount"/>
  18. <result property="fCurrency" column="f_currency"/>
  19. <result property="fExrate" column="f_exrate"/>
  20. <result property="fTaxrate" column="f_taxrate"/>
  21. <result property="fTaxrateStr" column="f_taxratestr"/>
  22. <result property="fDc" column="f_dc"/>
  23. <result property="fBillstatus" column="f_billstatus"/>
  24. <result property="fReviewDate" column="f_review_date"/>
  25. <result property="fAccamount" column="f_accamount"/>
  26. <result property="fStatementNo" column="f_statement_no"/>
  27. <result property="fStlamount" column="f_stlamount"/>
  28. <result property="fInvnos" column="f_invnos"/>
  29. <result property="fAccamountDate" column="f_accamount_date"/>
  30. <result property="fInvamount" column="f_invamount"/>
  31. <result property="fStlamountNo" column="f_stlamount_no"/>
  32. <result property="fAskamount" column="f_askamount"/>
  33. <result property="fStatus" column="f_status"/>
  34. <result property="fStlamountDate" column="f_stlamount_date"/>
  35. <result property="delFlag" column="del_flag"/>
  36. <result property="createBy" column="create_by"/>
  37. <result property="createTime" column="create_time"/>
  38. <result property="updateBy" column="update_by"/>
  39. <result property="updateTime" column="update_time"/>
  40. <result property="remark" column="remark"/>
  41. <result property="srcId" column="src_id"/>
  42. <result property="srcBillNo" column="src_bill_no"/>
  43. <result property="fMblno" column="f_mblno"/>
  44. <result property="fProductName" column="f_product_name"/>
  45. <result property="fMarks" column="f_marks"/>
  46. <result property="fChargedate" column="f_chargedate"/>
  47. <result property="fBillingDeadline" column="f_billing_deadline"/>
  48. <result property="fInventoryDays" column="f_inventory_days"/>
  49. <result property="fAmt" column="f_amt"/>
  50. <result property="fBillingDays" column="f_billing_days"/>
  51. <result property="fBillingQty" column="f_billing_qty"/>
  52. <result property="fBilltype" column="f_billtype"/>
  53. <result property="fBillingway" column="f_billingway"/>
  54. <result property="fBsdate" column="f_bsdate"/>
  55. <result property="priceDateRemarks" column="price_date_remarks"/>
  56. <result property="fOriginalbilldate" column="f_originalbilldate"/>
  57. <result property="fStltypeid" column="f_stltypeid"/>
  58. <result property="fBusinessType" column="f_business_type"/>
  59. <result property="fSrcTypeId" column="f_src_type_id"/>
  60. <result property="fSrcBillno" column="src_bill_no"/>
  61. <result property="fAddress" column="f_address"/>
  62. <result property="fAddressName" column="f_address_name"/>
  63. </resultMap>
  64. <sql id="selectTWarehousebillsfeesVo">
  65. select f_id,
  66. f_pid,
  67. f_lineno,
  68. f_corpid,
  69. f_feeid,
  70. f_warehouseid,
  71. f_feeUnitid,
  72. f_qty,
  73. f_unitprice,
  74. f_amount,
  75. f_currency,
  76. f_exrate,
  77. f_taxrate,
  78. CASE
  79. WHEN f_taxrate = 0 THEN '0.00%'
  80. WHEN f_taxrate != 0 THEN CONCAT(f_taxrate,'%')
  81. END as f_taxratestr,
  82. f_dc,
  83. f_billstatus,
  84. f_review_date,
  85. f_statement_no,
  86. f_accamount,
  87. f_stlamount,
  88. f_accamount_date,
  89. f_invnos,
  90. f_invamount,
  91. f_stlamount_no,
  92. f_askamount,
  93. f_status,
  94. f_stlamount_date,
  95. del_flag,
  96. create_by,
  97. create_time,
  98. update_by,
  99. update_time,
  100. remark,
  101. src_id,
  102. src_bill_no,
  103. f_mblno,
  104. f_product_name,
  105. f_marks,
  106. f_chargedate,
  107. f_billing_deadline,
  108. f_inventory_days,
  109. f_amt,
  110. f_billing_days,
  111. f_billing_qty,
  112. f_billtype,
  113. f_billingway,
  114. f_bsdate,
  115. f_originalbilldate,
  116. f_stltypeid,
  117. f_business_type,
  118. f_src_type_id,
  119. price_date_remarks,
  120. f_address_name,
  121. f_address
  122. from t_warehousebillsfees
  123. </sql>
  124. <select id="selectTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  125. resultMap="TWarehousebillsfeesResult">
  126. <include refid="selectTWarehousebillsfeesVo"/>
  127. <where>
  128. <if test="fPid != null ">and f_pid = #{fPid}</if>
  129. <if test="fLineno != null ">and f_lineno = #{fLineno}</if>
  130. <if test="fCorpid != null ">and f_corpid = #{fCorpid}</if>
  131. <if test="fFeeid != null ">and f_feeid = #{fFeeid}</if>
  132. <if test="fFeeunitid != null ">and f_feeUnitid = #{fFeeunitid}</if>
  133. <if test="fQty != null ">and f_qty = #{fQty}</if>
  134. <if test="fUnitprice != null ">and f_unitprice = #{fUnitprice}</if>
  135. <if test="fAmount != null ">and f_amount = #{fAmount}</if>
  136. <if test="fCurrency != null and fCurrency != ''">and f_currency = #{fCurrency}</if>
  137. <if test="fExrate != null ">and f_exrate = #{fExrate}</if>
  138. <if test="fTaxrate != null ">and f_taxrate = #{fTaxrate}</if>
  139. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  140. <if test="fBillstatus != null and fBillstatus != ''">and f_billstatus = #{fBillstatus}</if>
  141. <if test="fReviewDate != null ">and f_review_date = #{fReviewDate}</if>
  142. <if test="fStatementNo != null and fStatementNo != ''">and f_statement_no = #{fStatementNo}</if>
  143. <if test="fAccamount != null ">and f_accamount = #{fAccamount}</if>
  144. <if test="fStlamount != null ">and f_stlamount = #{fStlamount}</if>
  145. <if test="fAccamountDate != null ">and f_accamount_date = #{fAccamountDate}</if>
  146. <if test="fInvnos != null and fInvnos != ''">and f_invnos = #{fInvnos}</if>
  147. <if test="fInvamount != null ">and f_invamount = #{fInvamount}</if>
  148. <if test="fStlamountNo != null and fStlamountNo != ''">and f_stlamount_no = #{fStlamountNo}</if>
  149. <if test="fAskamount != null ">and f_askamount = #{fAskamount}</if>
  150. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  151. <if test="fStlamountDate != null ">and f_stlamount_date = #{fStlamountDate}</if>
  152. <if test="srcId != null ">and src_id = #{srcId}</if>
  153. <if test="srcBillNo != null and srcBillNo != ''">and src_bill_no = #{srcBillNo}</if>
  154. <if test="fMblno != null and fMblno != ''">and f_mblno = #{fMblno}</if>
  155. <if test="fProductName != null and fProductName != ''">and f_product_name like concat('%', #{fProductName},
  156. '%')
  157. </if>
  158. <if test="fMarks != null and fMarks != ''">and f_marks = #{fMarks}</if>
  159. <if test="fChargedate != null ">and f_chargedate = #{fChargedate}</if>
  160. <if test="fBillingDeadline != null ">and f_billing_deadline = #{fBillingDeadline}</if>
  161. <if test="fInventoryDays != null ">and f_inventory_days = #{fInventoryDays}</if>
  162. <if test="fAmt != null ">and f_amt = #{fAmt}</if>
  163. <if test="fBillingDays != null ">and f_billing_days = #{fBillingDays}</if>
  164. <if test="fBillingQty != null ">and f_billing_qty = #{fBillingQty}</if>
  165. <if test="fBilltype != null and fBilltype != ''">and f_billtype = #{fBilltype}</if>
  166. <if test="fBillingway != null ">and f_billingway = #{fBillingway}</if>
  167. <if test="fBsdate != null ">and f_bsdate = #{fBsdate}</if>
  168. <if test="fOriginalbilldate != null ">and f_originalbilldate = #{fOriginalbilldate}</if>
  169. <if test="fStltypeid != null">and f_stltypeid = #{fStltypeid},</if>
  170. <if test="fSrcTypeId != null">and f_src_type_id = #{fSrcTypeId},</if>
  171. <if test="fAddress != null">and f_address = #{fAddress}</if>
  172. <if test="fAddressName != null and fAddressName != ''">and f_address_name = #{fAddressName}</if>
  173. </where>
  174. </select>
  175. <select id="selectTWarehousebillsfeesById" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  176. <include refid="selectTWarehousebillsfeesVo"/>
  177. where f_id = #{fId}
  178. </select>
  179. <select id="selectTWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  180. select f_id, f_pid, f_billing_deadline, src_bill_no,f_billstatus
  181. from t_warehousebillsfees
  182. where f_pid = #{fId}
  183. and f_billtype = 'SJCK'
  184. </select>
  185. <select id="selectWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  186. <include refid="selectTWarehousebillsfeesVo"/>
  187. where f_pid = #{fId}
  188. </select>
  189. <select id="selectReconciliation" resultType="java.lang.Integer">
  190. SELECT COUNT(d.f_id)
  191. FROM t_fee_do d
  192. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  193. WHERE d.f_srcpid = #{fId}
  194. AND f.f_billtype = 'DZ'
  195. </select>
  196. <select id="selectCharge" resultType="java.lang.Integer">
  197. SELECT COUNT(d.f_id)
  198. FROM t_fee_do d
  199. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  200. WHERE d.f_srcpid = #{fId}
  201. AND f.f_billtype = 'SF'
  202. </select>
  203. <select id="selectPay" resultType="java.lang.Integer">
  204. SELECT COUNT(d.f_id)
  205. FROM t_fee_do d
  206. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  207. WHERE d.f_srcpid = #{fId}
  208. AND f.f_billtype = 'FF'
  209. </select>
  210. <select id="selectFleetExcelMonthList" parameterType="TWarehousebillsfees"
  211. resultType="com.ruoyi.finance.excel.FleetExcel">
  212. SELECT
  213. CONCAT( MONTH ( s.f_bsdate ), '月份小计:' ) feelMonthName,
  214. CONCAT(
  215. YEAR ( s.f_bsdate ),
  216. '-',
  217. MONTH ( s.f_bsdate )) feelMonth,
  218. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  219. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  220. sum( s.f_amount ) totalAmount,
  221. sum( s.f_invamount ) invamount,
  222. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  223. FROM
  224. t_warehousebillsfees s
  225. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  226. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  227. WHERE
  228. s.f_dc = 'D'
  229. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  230. and s.f_bsdate &gt;= #{fMonth[0]}
  231. </if>
  232. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  233. and s.f_bsdate &lt;= #{fMonth[1]}
  234. </if>
  235. GROUP BY
  236. CONCAT(
  237. YEAR ( f_bsdate ),
  238. '-',
  239. MONTH ( f_bsdate ))
  240. </select>
  241. <select id="selectFleetExcelList" parameterType="TWarehousebillsfees"
  242. resultType="com.ruoyi.finance.excel.FleetExcel">
  243. SELECT
  244. #{createBy} userName,
  245. CONCAT(
  246. YEAR ( s.f_bsdate ),
  247. '-',
  248. MONTH ( s.f_bsdate )) feelMonth,
  249. c.f_name corpName,
  250. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  251. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  252. sum( s.f_amount ) totalAmount,
  253. IF
  254. ( f_invamount = 0, 'F', 'T' ) isInvoice,
  255. sum( s.f_invamount ) invamount,
  256. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  257. FROM
  258. t_warehousebillsfees s
  259. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  260. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  261. WHERE
  262. s.f_dc = 'D'
  263. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  264. and s.f_bsdate &gt;= #{fMonth[0]}
  265. </if>
  266. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  267. and s.f_bsdate &lt;= #{fMonth[1]}
  268. </if>
  269. GROUP BY CONCAT( YEAR ( f_bsdate ), '-', MONTH ( f_bsdate )), s.f_corpid, c.f_name
  270. </select>
  271. <insert id="insertTWarehousebillsfees" parameterType="TWarehousebillsfees" useGeneratedKeys="true"
  272. keyProperty="fId">
  273. insert into t_warehousebillsfees
  274. <trim prefix="(" suffix=")" suffixOverrides=",">
  275. <if test="fId != null">f_id,</if>
  276. <if test="fPid != null">f_pid,</if>
  277. <if test="fLineno != null">f_lineno,</if>
  278. <if test="fCorpid != null">f_corpid,</if>
  279. <if test="fFeeid != null">f_feeid,</if>
  280. <if test="fWarehouseid != null">f_warehouseid,</if>
  281. <if test="fFeeunitid != null">f_feeUnitid,</if>
  282. <if test="fQty != null">f_qty,</if>
  283. <if test="fUnitprice != null">f_unitprice,</if>
  284. <if test="fAmount != null">f_amount,</if>
  285. <if test="fCurrency != null">f_currency,</if>
  286. <if test="fExrate != null">f_exrate,</if>
  287. <if test="fTaxrate != null">f_taxrate,</if>
  288. <if test="fDc != null">f_dc,</if>
  289. <if test="fBillstatus != null">f_billstatus,</if>
  290. <if test="fReviewDate != null">f_review_date,</if>
  291. <if test="fStatementNo != null">f_statement_no,</if>
  292. <if test="fAccamount != null">f_accamount,</if>
  293. <if test="fStlamount != null">f_stlamount,</if>
  294. <if test="fAccamountDate != null">f_accamount_date,</if>
  295. <if test="fInvnos != null">f_invnos,</if>
  296. <if test="fInvamount != null">f_invamount,</if>
  297. <if test="fStlamountNo != null">f_stlamount_no,</if>
  298. <if test="fAskamount != null">f_askamount,</if>
  299. <if test="fStatus != null">f_status,</if>
  300. <if test="fStlamountDate != null">f_stlamount_date,</if>
  301. <if test="delFlag != null">del_flag,</if>
  302. <if test="createBy != null">create_by,</if>
  303. <if test="createTime != null">create_time,</if>
  304. <if test="updateBy != null">update_by,</if>
  305. <if test="updateTime != null">update_time,</if>
  306. <if test="remark != null">remark,</if>
  307. <if test="srcId != null">src_id,</if>
  308. <if test="srcBillNo != null">src_bill_no,</if>
  309. <if test="fMblno != null">f_mblno,</if>
  310. <if test="fProductName != null">f_product_name,</if>
  311. <if test="fMarks != null">f_marks,</if>
  312. <if test="fChargedate != null">f_chargedate,</if>
  313. <if test="fBillingDeadline != null">f_billing_deadline,</if>
  314. <if test="fInventoryDays != null">f_inventory_days,</if>
  315. <if test="fAmt != null">f_amt,</if>
  316. <if test="fBillingDays != null">f_billing_days,</if>
  317. <if test="fBillingQty != null">f_billing_qty,</if>
  318. <if test="fBilltype != null">f_billtype,</if>
  319. <if test="fBillingway != null">f_billingway,</if>
  320. <if test="fBsdate != null">f_bsdate,</if>
  321. <if test="fOriginalbilldate != null">f_originalbilldate,</if>
  322. <if test="fStltypeid != null">f_stltypeid,</if>
  323. <if test="fBusinessType != null">f_business_type,</if>
  324. <if test="fSrcTypeId != null">f_src_type_id,</if>
  325. <if test="priceDateRemarks != null">price_date_remarks,</if>
  326. <if test="fAddress != null">f_address,</if>
  327. <if test="fAddressName != null">f_address_name,</if>
  328. </trim>
  329. <trim prefix="values (" suffix=")" suffixOverrides=",">
  330. <if test="fId != null">#{fId},</if>
  331. <if test="fPid != null">#{fPid},</if>
  332. <if test="fLineno != null">#{fLineno},</if>
  333. <if test="fCorpid != null">#{fCorpid},</if>
  334. <if test="fFeeid != null">#{fFeeid},</if>
  335. <if test="fWarehouseid != null">#{fWarehouseid},</if>
  336. <if test="fFeeunitid != null">#{fFeeunitid},</if>
  337. <if test="fQty != null">#{fQty},</if>
  338. <if test="fUnitprice != null">#{fUnitprice},</if>
  339. <if test="fAmount != null">#{fAmount},</if>
  340. <if test="fCurrency != null">#{fCurrency},</if>
  341. <if test="fExrate != null">#{fExrate},</if>
  342. <if test="fTaxrate != null">#{fTaxrate},</if>
  343. <if test="fDc != null">#{fDc},</if>
  344. <if test="fBillstatus != null">#{fBillstatus},</if>
  345. <if test="fReviewDate != null">#{fReviewDate},</if>
  346. <if test="fStatementNo != null">#{fStatementNo},</if>
  347. <if test="fAccamount != null">#{fAccamount},</if>
  348. <if test="fStlamount != null">#{fStlamount},</if>
  349. <if test="fAccamountDate != null">#{fAccamountDate},</if>
  350. <if test="fInvnos != null">#{fInvnos},</if>
  351. <if test="fInvamount != null">#{fInvamount},</if>
  352. <if test="fStlamountNo != null">#{fStlamountNo},</if>
  353. <if test="fAskamount != null">#{fAskamount},</if>
  354. <if test="fStatus != null">#{fStatus},</if>
  355. <if test="fStlamountDate != null">#{fStlamountDate},</if>
  356. <if test="delFlag != null">#{delFlag},</if>
  357. <if test="createBy != null">#{createBy},</if>
  358. <if test="createTime != null">#{createTime},</if>
  359. <if test="updateBy != null">#{updateBy},</if>
  360. <if test="updateTime != null">#{updateTime},</if>
  361. <if test="remark != null">#{remark},</if>
  362. <if test="srcId != null">#{srcId},</if>
  363. <if test="srcBillNo != null">#{srcBillNo},</if>
  364. <if test="fMblno != null">#{fMblno},</if>
  365. <if test="fProductName != null">#{fProductName},</if>
  366. <if test="fMarks != null">#{fMarks},</if>
  367. <if test="fChargedate != null">#{fChargedate},</if>
  368. <if test="fBillingDeadline != null">#{fBillingDeadline},</if>
  369. <if test="fInventoryDays != null">#{fInventoryDays},</if>
  370. <if test="fAmt != null">#{fAmt},</if>
  371. <if test="fBillingDays != null">#{fBillingDays},</if>
  372. <if test="fBillingQty != null">#{fBillingQty},</if>
  373. <if test="fBilltype != null">#{fBilltype},</if>
  374. <if test="fBillingway != null">#{fBillingway},</if>
  375. <if test="fBsdate != null">#{fBsdate},</if>
  376. <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
  377. <if test="fStltypeid != null">#{fStltypeid},</if>
  378. <if test="fBusinessType != null">#{fBusinessType},</if>
  379. <if test="fSrcTypeId != null">#{fSrcTypeId},</if>
  380. <if test="priceDateRemarks != null">#{priceDateRemarks},</if>
  381. <if test="fAddress != null">#{fAddress},</if>
  382. <if test="fAddressName != null">#{fAddressName},</if>
  383. </trim>
  384. </insert>
  385. <update id="updateTWarehousebillsfees" parameterType="TWarehousebillsfees">
  386. update t_warehousebillsfees
  387. <trim prefix="SET" suffixOverrides=",">
  388. <if test="fPid != null">f_pid = #{fPid},</if>
  389. <if test="fLineno != null">f_lineno = #{fLineno},</if>
  390. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  391. <if test="fFeeid != null">f_feeid = #{fFeeid},</if>
  392. <if test="fFeeunitid != null">f_feeUnitid = #{fFeeunitid},</if>
  393. <if test="fQty != null">f_qty = #{fQty},</if>
  394. <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
  395. <if test="fUnitprice != null">f_unitprice = #{fUnitprice},</if>
  396. <if test="fAmount != null">f_amount = #{fAmount},</if>
  397. <if test="fCurrency != null">f_currency = #{fCurrency},</if>
  398. <if test="fExrate != null">f_exrate = #{fExrate},</if>
  399. <if test="fTaxrate != null">f_taxrate = #{fTaxrate},</if>
  400. <if test="fDc != null">f_dc = #{fDc},</if>
  401. <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
  402. <if test="fReviewDate != null || fReviewDate == null">f_review_date = #{fReviewDate},</if>
  403. <if test="fStatementNo != null">f_statement_no = #{fStatementNo},</if>
  404. <if test="fAccamount != null">f_accamount = #{fAccamount},</if>
  405. <if test="fStlamount != null">f_stlamount = #{fStlamount},</if>
  406. <if test="fAccamountDate != null">f_accamount_date = #{fAccamountDate},</if>
  407. <if test="fInvnos != null">f_invnos = #{fInvnos},</if>
  408. <if test="fInvamount != null">f_invamount = #{fInvamount},</if>
  409. <if test="fStlamountNo != null">f_stlamount_no = #{fStlamountNo},</if>
  410. <if test="fAskamount != null">f_askamount = #{fAskamount},</if>
  411. <if test="fStatus != null">f_status = #{fStatus},</if>
  412. <if test="fStlamountDate != null">f_stlamount_date = #{fStlamountDate},</if>
  413. <if test="delFlag != null">del_flag = #{delFlag},</if>
  414. <if test="createBy != null">create_by = #{createBy},</if>
  415. <if test="createTime != null">create_time = #{createTime},</if>
  416. <if test="updateBy != null">update_by = #{updateBy},</if>
  417. <if test="updateTime != null">update_time = #{updateTime},</if>
  418. <if test="remark != null">remark = #{remark},</if>
  419. <if test="srcId != null">src_id = #{srcId},</if>
  420. <if test="srcBillNo != null">src_bill_no = #{srcBillNo},</if>
  421. <if test="fMblno != null">f_mblno = #{fMblno},</if>
  422. <if test="fProductName != null">f_product_name = #{fProductName},</if>
  423. <if test="fMarks != null">f_marks = #{fMarks},</if>
  424. <if test="fChargedate != null">f_chargedate = #{fChargedate},</if>
  425. <if test="fBillingDeadline != null">f_billing_deadline = #{fBillingDeadline},</if>
  426. <if test="fInventoryDays != null">f_inventory_days = #{fInventoryDays},</if>
  427. <if test="fAmt != null">f_amt = #{fAmt},</if>
  428. <if test="fBillingDays != null">f_billing_days = #{fBillingDays},</if>
  429. <if test="fBillingQty != null">f_billing_qty = #{fBillingQty},</if>
  430. <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
  431. <if test="fBillingway != null">f_billingway = #{fBillingway},</if>
  432. <if test="fBsdate != null">f_bsdate = #{fBsdate},</if>
  433. <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
  434. <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
  435. <if test="priceDateRemarks != null">price_date_remarks = #{priceDateRemarks},</if>
  436. <if test="fSrcTypeId != null">f_src_type_id = #{fSrcTypeId},</if>
  437. <if test="fAddress != null">f_address = #{fAddress},</if>
  438. <if test="fAddressName != null">f_address_name = #{fAddressName},</if>
  439. </trim>
  440. where f_id = #{fId}
  441. </update>
  442. <delete id="deleteTWarehousebillsfeesById" parameterType="Long">
  443. delete
  444. from t_warehousebillsfees
  445. where f_id = #{fId}
  446. </delete>
  447. <delete id="deleteByFPid" parameterType="Long">
  448. delete
  449. from t_warehousebillsfees
  450. where f_pid = #{fId}
  451. </delete>
  452. <delete id="deleteTWarehousebillsfeesByIds" parameterType="String">
  453. delete from t_warehousebillsfees where f_id in
  454. <foreach item="fId" collection="array" open="(" separator="," close=")">
  455. #{fId}
  456. </foreach>
  457. </delete>
  458. <update id="warehouseFeesFollowUpdate">
  459. update
  460. t_warehousebillsfees
  461. <trim prefix="SET" suffixOverrides=",">
  462. <if test="fettle != null">f_billstatus = #{fettle},</if>
  463. <if test="auditItem != null and fettle == 6">f_review_date = #{auditItem},</if>
  464. <if test="auditItem != null and fettle != 6">f_review_date = null,</if>
  465. </trim>
  466. where f_pid = #{fPid} and f_accamount &lt;= 0 and f_stlamount &lt;= 0 and f_invamount &lt;= 0
  467. </update>
  468. <update id="warehouseFeesFollowUpdateById">
  469. update
  470. t_warehousebillsfees
  471. <trim prefix="SET" suffixOverrides=",">
  472. <if test="fettle != null">f_billstatus = #{fettle},</if>
  473. <if test="auditItem != null and fettle == 6">f_review_date = #{auditItem},</if>
  474. <if test="auditItem != null and fettle != 6">f_review_date = null,</if>
  475. </trim>
  476. where f_id = #{fPid} and f_accamount &lt;= 0 and f_stlamount &lt;= 0 and f_invamount &lt;= 0
  477. </update>
  478. <update id="updateTWarehousebillsfee" parameterType="Map">
  479. update t_warehousebillsfees
  480. <trim prefix="SET" suffixOverrides=",">
  481. /*判断确认对账*/
  482. <if test="map.billType == 'DZ'">
  483. f_statement_no = #{map.tFee.fBillno},
  484. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  485. f_accamount_date = #{map.tFee.fAccbilldate}
  486. </if>
  487. /*判断撤销对账*/
  488. <if test="map.billType == 'DZRevoke'">
  489. f_statement_no = #{map.tFee.fBillno},
  490. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  491. f_accamount_date = #{map.tFee.fAccbilldate}
  492. </if>
  493. /*判断收付款*/
  494. <if test="map.billType == 'DC'">
  495. f_stlamount_no = #{map.tFee.fBillno},
  496. f_stlamount = f_stlamount + #{map.tFeeDo.fAmt},
  497. f_stlamount_date =#{map.tFee.fAccbilldate}
  498. </if>
  499. /*判断撤销收付款*/
  500. <if test="map.billType == 'DCRevoke'">
  501. f_stlamount_no = #{map.tFee.fBillno},
  502. f_stlamount = f_stlamount - #{map.tFeeDo.fAmt},
  503. f_stlamount_date =#{map.tFee.fAccbilldate}
  504. </if>
  505. /*判断开发票款*/
  506. <if test="map.billType == 'invoiceFP'">
  507. f_invamount = f_invamount + #{map.tFeeDo.fAmt},
  508. f_stlamount_date =#{map.tFee.fAccbilldate}
  509. </if>
  510. <if test="map.billType == 'DZinvoiceFP'">
  511. f_invamount = f_invamount - #{map.tFeeDo.fAmt},
  512. f_stlamount_date =#{map.tFee.fAccbilldate}
  513. </if>
  514. /*判断申请发票款*/
  515. <if test="map.billType == 'ApplyFP'">
  516. f_askamount = f_askamount + #{map.tFeeDo.fAmt},
  517. f_stlamount_date =#{map.tFee.fAccbilldate}
  518. </if>
  519. <if test="map.billType == 'DZApplyFP'">
  520. f_askamount = f_askamount - #{map.tFeeDo.fAmt},
  521. f_stlamount_date =#{map.tFee.fAccbilldate}
  522. </if>
  523. /*判断确认对账*/
  524. <if test="map.billType == 'KHDZ'">
  525. f_statement_no = #{map.tFee.fBillno},
  526. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  527. f_accamount_date = #{map.tFee.fAccbilldate}
  528. </if>
  529. /*判断撤销对账*/
  530. <if test="map.billType == 'KHDZRevoke'">
  531. f_statement_no = #{map.tFee.fBillno},
  532. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  533. f_accamount_date = #{map.tFee.fAccbilldate}
  534. </if>
  535. /*判断确认仓库发票*/
  536. <if test="map.billType == 'FP'">
  537. f_invnos = #{map.tFee.fBillno},
  538. f_invamount = f_invamount + #{map.tFeeDo.fAmt}
  539. </if>
  540. /*判断撤销仓库发票*/
  541. <if test="map.billType == 'FPRevoke'">
  542. f_invnos = #{map.tFee.fBillno},
  543. f_invamount = f_invamount - #{map.tFeeDo.fAmt}
  544. </if>
  545. </trim>
  546. where f_id = #{map.tFeeDo.fSrcid}
  547. </update>
  548. <select id="selectFeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  549. SELECT
  550. tw.f_id,
  551. tw.f_pid,
  552. tw.f_lineno,
  553. tw.f_corpid,
  554. tc.f_name corpName,
  555. tw.f_feeid,
  556. tf.f_name feeName,
  557. tw.f_feeUnitid,
  558. tw.f_qty,
  559. tw.f_unitprice,
  560. tw.f_amount,
  561. tw.f_currency,
  562. tw.f_exrate,
  563. tw.f_taxrate,
  564. tw.f_dc,
  565. tw.f_billstatus,
  566. CASE
  567. WHEN tw.f_billstatus = '1' THEN
  568. '新建'
  569. WHEN tw.f_billstatus = '2' THEN
  570. '暂存'
  571. WHEN tw.f_billstatus = '3' THEN
  572. '驳回'
  573. WHEN tw.f_billstatus = '4' THEN
  574. '提交'
  575. WHEN tw.f_billstatus = '5' THEN
  576. '审批中'
  577. WHEN tw.f_billstatus = '6' THEN
  578. '审批通过'
  579. END AS fBillstatusName,
  580. tw.f_review_date,
  581. tw.f_statement_no,
  582. tw.f_accamount,
  583. tw.f_stlamount,
  584. tw.f_accamount_date,
  585. tw.f_invnos,
  586. tw.f_invamount,
  587. tw.f_stlamount_no,
  588. tw.f_askamount,
  589. tw.f_status,
  590. tw.f_stlamount_date,
  591. tw.del_flag,
  592. tw.create_by,
  593. tw.create_time,
  594. tw.update_by,
  595. tw.update_time,
  596. tw.remark,
  597. tw.src_id,
  598. tw.src_bill_no,
  599. tw.f_mblno,
  600. tw.f_product_name,
  601. tw.f_marks,
  602. tw.price_date_remarks,
  603. tw.f_chargedate,
  604. tw.f_billing_deadline,
  605. tw.f_inventory_days,
  606. tw.f_amt,
  607. tw.f_billing_days,
  608. tw.f_billing_qty,
  609. tw.f_billtype,
  610. tw.f_billingway,
  611. tw.f_bsdate,
  612. tw.f_originalbilldate,
  613. tw.f_stltypeid,
  614. tw.f_business_type,
  615. tw.f_src_type_id,
  616. tw.f_address,
  617. tw.f_address_name
  618. FROM
  619. t_warehousebillsfees tw
  620. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  621. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  622. where tw.f_pid = #{fPid}
  623. and tw.f_billtype = 'KHDD'
  624. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  625. </select>
  626. <select id="voyageFeeDetails" resultType="map">
  627. SELECT
  628. tf.f_name feeName,
  629. SUM(tw.f_unitprice) fUnitprice,
  630. SUM(tw.f_amount) fAmount
  631. FROM
  632. t_warehousebillsfees tw
  633. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  634. WHERE
  635. tw.f_pid = #{fPid}
  636. AND tw.f_billtype = 'KHDD'
  637. <if test="fDc != null and fDc != ''">AND tw.f_dc = #{fDc}</if>
  638. GROUP BY feeName;
  639. </select>
  640. <select id="selectSubItemsFeeDetails" resultType="map">
  641. select tf.f_name feeName,
  642. tw.f_unitprice fUnitprice,
  643. tw.f_amount fAmount
  644. from t_warehousebillsfees tw
  645. LEFT JOIN t_fees tf on tw.f_feeid = tf.f_id
  646. where
  647. <if test="fPid != null and fPid != ''">tw.f_pid = #{fPid}</if>
  648. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  649. </select>
  650. <delete id="deleteFessByFPid" parameterType="object">
  651. delete
  652. from t_warehousebillsfees
  653. where f_pid = #{fPid}
  654. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  655. </delete>
  656. <!--网页版查询对账-->
  657. <select id="webVersionReconciliation" parameterType="TAccount" resultType="map">
  658. SELECT
  659. tb.f_billno AS fBillno,
  660. /**运单号*/
  661. tv.f_name AS vesselName,
  662. /**船名*/
  663. ty.f_no AS voyageName,
  664. /**航次*/
  665. tc.f_name AS invoice,
  666. /**收费单位*/
  667. tc.f_name AS drawee,
  668. /**受票单位*/
  669. tp.f_name AS corpName,
  670. /**货权方*/
  671. pro.dict_label AS fPaymode,
  672. /**付款方式*/
  673. te.f_name AS payment,
  674. /**费用名称*/
  675. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmtdr,
  676. /**原始金额*/
  677. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmt,
  678. /**本次金额*/
  679. ta.f_name AS fLoadportidName,
  680. /**始发港*/
  681. tr.f_name AS fDestportidName,
  682. /**目的港*/
  683. pr.dict_label AS fServiceitems,
  684. /**运输条款*/
  685. tg.f_name AS goodName,
  686. /**货名*/
  687. tn.f_name AS transit,
  688. /**箱型*/
  689. items.f_cntrcount AS fCntrcount,
  690. /**箱量*/
  691. tb.f_shippername AS fShippername,
  692. /**发货人*/
  693. tb.f_consigneername AS fConsigneername,
  694. /**收货人*/
  695. tf.f_id AS fSrcid,
  696. tf.f_pid AS fSrcpid,
  697. tf.create_by AS createBy,
  698. tf.create_time AS createTime,
  699. tf.update_by AS updateBy,
  700. tf.update_time AS updateTime,
  701. tf.remark AS remark,
  702. tf.f_mblno AS fMblno,
  703. tf.f_corpid AS fCorpid,
  704. tf.f_feeid AS fFeeid
  705. FROM
  706. t_warehousebillsfees tf
  707. LEFT JOIN t_corps tc ON tc.f_id = tf.f_corpid
  708. LEFT JOIN t_fees te ON te.f_id = tf.f_feeid
  709. LEFT JOIN t_warehousebills tb ON tb.f_id = tf.f_pid
  710. LEFT JOIN t_vessel tv ON tv.f_id = tb.f_vslid
  711. LEFT JOIN t_voyage ty ON ty.f_id = tb.f_voyid
  712. LEFT JOIN t_address ta ON ta.f_id = tb.f_loadportid
  713. LEFT JOIN t_address tr ON tr.f_id = tb.f_destportid
  714. LEFT JOIN sys_dict_data pro ON pro.dict_value = tb.f_paymode
  715. AND pro.dict_type = 'data_settlement_type'
  716. LEFT JOIN sys_dict_data pr ON pr.dict_value = tb.f_serviceitems
  717. AND pr.dict_type = 'f_serviceitems'
  718. LEFT JOIN ( SELECT f_pid, MAX( f_goodsid ) f_goodsid FROM t_warehousebills_cntr GROUP BY f_pid ) w ON w.f_pid =
  719. tb.f_id
  720. LEFT JOIN t_goods tg ON tg.f_id = w.f_goodsid
  721. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  722. ON items.f_pid = tb.f_id
  723. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  724. twc.f_pid = tb.f_id
  725. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  726. LEFT JOIN t_corps tp ON tp.f_id = tb.f_corpid
  727. WHERE
  728. tf.f_billstatus = 6
  729. AND tf.f_dc = 'D'
  730. AND tb.f_typeid = 1
  731. and tb.f_review_date IS NOT NULL
  732. and ifnull(tf.f_amount, 0) - ifnull(tf.f_accamount, 0) > 0
  733. <if test="fLoadportid != null">and tb.f_loadportid = #{fLoadportid}</if>
  734. <if test="fDestportid != null">and tb.f_destportid = #{fDestportid}</if>
  735. <if test="fInvoceobj != null and fInvoceobj != ''">and tb.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  736. <if test="fShippername != null and fShippername != ''">and tb.f_shippername like concat('%', #{fShippername},
  737. '%')
  738. </if>
  739. <if test="fConsigneername != null and fConsigneername != ''">and tb.f_consigneername like concat('%',
  740. #{fConsigneername}, '%')
  741. </if>
  742. <if test="fMblno != null and fMblno != ''">and tb.f_mblno like concat('%', #{fMblno}, '%')</if>
  743. <if test="fBillno != null and fBillno != ''">and tb.f_billno like concat('%', #{fBillno}, '%')</if>
  744. <if test="fVslid != null">and tb.f_vslid = #{fVslid}</if>
  745. <if test="fVoyid != null">and tb.f_voyid = #{fVoyid}</if>
  746. <if test="fCorpid != null">and tf.f_corpid = #{fCorpid}</if>
  747. <if test="fPaymodeid != null">and tb.f_paymode = #{fPaymodeid}</if>
  748. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  749. and tf.create_time &gt;= #{sailTime[0]}
  750. </if>
  751. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  752. and tf.create_time &lt;= #{sailTime[1]}
  753. </if>
  754. <if test="fDocmentdate != null and fDocmentdate != ''">and tb.f_docmentdate = #{fDocmentdate}</if>
  755. <if test="createBy != null and createBy != ''">and tb.create_by = #{createBy}</if>
  756. <if test="goodName != null and goodName != ''">and tg.f_name like concat('%', #{goodName}, '%')</if>
  757. ORDER BY tf.f_id desc
  758. </select>
  759. <!--网页版查询对账明细-->
  760. <select id="webVersionDetail" parameterType="TAccount" resultType="map">
  761. SELECT
  762. tf.f_id AS fId,
  763. te.f_billno AS accountBillno,
  764. /**账单编号*/
  765. tw.f_billno AS fBillno,
  766. /**运单编号*/
  767. tv.f_name AS vesselName,
  768. /**船名*/
  769. ty.f_no AS voyageName,
  770. /**航次*/
  771. te.f_ctrlcorpid AS fCtrlcorpid,
  772. /**获权方*/
  773. tp.f_name AS corpName,
  774. /**结算单位*/
  775. ta.f_name AS fLoadportidName,
  776. /**始发港*/
  777. tr.f_name AS fDestportidName,
  778. /**目的港*/
  779. pr.dict_label AS fServiceitems,
  780. /**运输条款*/
  781. ts.f_name AS payment,
  782. /**费用名称*/
  783. tf.f_amtdr AS fAmtdr,
  784. /**原始金额*/
  785. tf.f_amt AS fAmt,
  786. /**本次金额*/
  787. tn.f_name AS transit,
  788. /**箱型*/
  789. items.f_cntrcount AS fCntrcount,
  790. /**箱量*/
  791. tf.create_by AS createBy,
  792. tf.create_time AS createTime,
  793. CASE
  794. WHEN te.f_billstatus = '1' THEN
  795. '保存'
  796. WHEN te.f_billstatus = '2' THEN
  797. '暂存'
  798. WHEN te.f_billstatus = '3' THEN
  799. '审批驳回'
  800. WHEN te.f_billstatus = '4' THEN
  801. '提交审核'
  802. WHEN te.f_billstatus = '5' THEN
  803. '审核中'
  804. WHEN te.f_billstatus = '6' THEN
  805. '审核完成'
  806. END AS fBillstatus
  807. FROM
  808. t_fee_do tf
  809. LEFT JOIN t_fee te ON te.f_id = tf.f_pid
  810. LEFT JOIN t_warehousebills tw ON tf.f_srcpid = tw.f_id
  811. LEFT JOIN t_warehousebillsfees th ON th.f_id = tf.f_srcid
  812. LEFT JOIN t_vessel tv ON tw.f_vslid = tv.f_id
  813. LEFT JOIN t_voyage ty ON ty.f_id = tw.f_voyid
  814. LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
  815. LEFT JOIN t_address tr ON tr.f_id = tw.f_destportid
  816. LEFT JOIN sys_dict_data pr ON pr.dict_value = tw.f_serviceitems
  817. AND pr.dict_type = 'f_serviceitems'
  818. LEFT JOIN t_fees ts ON ts.f_id = tf.f_feeid
  819. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  820. ON items.f_pid = tw.f_id
  821. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  822. twc.f_pid = tw.f_id
  823. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  824. LEFT JOIN t_corps tp ON tp.f_id = te.f_corpid
  825. WHERE
  826. te.f_billtype = 'KHDZ'
  827. <if test="fLoadportid != null">and tw.f_loadportid = #{fLoadportid}</if>
  828. <if test="fDestportid != null">and tw.f_destportid = #{fDestportid}</if>
  829. <if test="fInvoceobj != null and fInvoceobj != ''">and tw.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  830. <if test="fShippername != null and fShippername != ''">and tw.f_shippername like concat('%', #{fShippername},
  831. '%')
  832. </if>
  833. <if test="fConsigneername != null and fConsigneername != ''">and tw.f_consigneername like concat('%',
  834. #{fConsigneername}, '%')
  835. </if>
  836. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  837. <if test="fVslid != null">and tw.f_vslid = #{fVslid}</if>
  838. <if test="fId != null">and tf.f_id = #{fId}</if>
  839. <if test="fVoyid != null">and tw.f_voyid = #{fVoyid}</if>
  840. <if test="fCorpid != null">and te.f_corpid = #{fCorpid}</if>
  841. <if test="fPaymodeid != null">and tw.f_paymode = #{fPaymodeid}</if>
  842. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  843. and tf.create_time &gt;= #{sailTime[0]}
  844. </if>
  845. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  846. and tf.create_time &lt;= #{sailTime[1]}
  847. </if>
  848. <if test="fDocmentdate != null and fDocmentdate != ''">and tw.f_docmentdate = #{fDocmentdate}</if>
  849. <if test="createBy != null and createBy != ''">and te.create_by = #{createBy}</if>
  850. <if test="accountBillno != null and accountBillno != ''">and te.f_billno = #{accountBillno}</if>
  851. ORDER BY tf.f_id desc
  852. </select>
  853. <select id="selectTWarehousebillsfeesSrcId" parameterType="Long" resultType="long">
  854. select src_id
  855. FROM t_warehousebillsfees
  856. where f_pid = #{fId}
  857. AND src_id IS NOT NULL
  858. </select>
  859. <select id="accountsDue" resultType="map">
  860. SELECT CASE MONTH (tf.create_time) WHEN '1' THEN SUM(tf.f_amount) ELSE 0 END AS January,
  861. CASE MONTH(tf.create_time) WHEN '2' THEN SUM(tf.f_amount) ELSE 0
  862. END
  863. AS February,
  864. CASE MONTH(tf.create_time) WHEN '3' THEN SUM(tf.f_amount) ELSE 0
  865. END
  866. AS March,
  867. CASE MONTH(tf.create_time) WHEN '4' THEN SUM(tf.f_amount) ELSE 0
  868. END
  869. AS April,
  870. CASE MONTH(tf.create_time) WHEN '5' THEN SUM(tf.f_amount) ELSE 0
  871. END
  872. AS May,
  873. CASE MONTH(tf.create_time) WHEN '6' THEN SUM(tf.f_amount) ELSE 0
  874. END
  875. AS June,
  876. CASE MONTH(tf.create_time) WHEN '7' THEN SUM(tf.f_amount) ELSE 0
  877. END
  878. AS July,
  879. CASE MONTH(tf.create_time) WHEN '8' THEN SUM(tf.f_amount) ELSE 0
  880. END
  881. AS August,
  882. CASE MONTH(tf.create_time) WHEN '9' THEN SUM(tf.f_amount) ELSE 0
  883. END
  884. AS September,
  885. CASE MONTH(tf.create_time) WHEN '10' THEN SUM(tf.f_amount) ELSE 0
  886. END
  887. AS October,
  888. CASE MONTH(tf.create_time) WHEN '11' THEN SUM(tf.f_amount) ELSE 0
  889. END
  890. AS November,
  891. CASE MONTH(tf.create_time) WHEN '12' THEN SUM(tf.f_amount) ELSE 0
  892. END
  893. AS December,
  894. tc.f_name corpName
  895. FROM
  896. t_warehousebillsfees tf
  897. LEFT JOIN t_corps tc ON tf.f_corpid = tc.f_id
  898. WHERE ifnull(tf.f_amount, 0) - ifnull(tf.f_stlamount, 0) >0
  899. AND tf.f_dc = 'D'
  900. AND YEAR(tf.create_time) = YEAR(NOW())
  901. GROUP BY tf.f_corpid
  902. LIMIT 10
  903. </select>
  904. <select id="selectQueryMenuList" parameterType="TWarehousebillsfees"
  905. resultType="com.ruoyi.warehouseBusiness.excel.QueryMenu">
  906. SELECT
  907. tc.f_name AS corpName,
  908. tf.f_mblno AS fMblno,
  909. IF(tf.f_billtype = 'SJRK' || tf.f_billtype = 'SJCK' || tf.f_billtype = 'CKDB' || tf.f_billtype = 'HQZY',tf.f_bsdate, null) AS fBsdate,
  910. tf.f_review_date AS fReviewDate,
  911. te.f_name AS feeName,
  912. tf.f_dc AS fDc,
  913. tf.f_amount AS fAmount,
  914. tf.f_stlamount_no AS fStlamountNo,
  915. tw.f_shipper AS fShipper,
  916. tw.f_emblno AS fEmblno,
  917. tf.f_stlamount AS fStlamount,
  918. tf.f_stlamount_date AS fStlamountDate,
  919. tf.f_invamount AS fInvamount,
  920. tf.f_invnos AS fInvnos,
  921. tf.f_accamount AS fAccamount,
  922. tf.f_accamount_date AS fAccamountDate,
  923. tf.f_statement_no AS fStatementNo,
  924. tf.f_feeUnitid AS fFeeUnitid,
  925. tf.f_qty AS fQty,
  926. tf.f_unitprice AS fUnitprice,
  927. tf.f_billtype AS fBilltype,
  928. tf.f_product_name AS fProductName,
  929. tf.f_stltypeid AS fStltypeid,
  930. tf.remark AS remark,
  931. tf.src_bill_no AS fSrcBillno,
  932. tf.f_chargedate AS fChargedate,
  933. tf.f_billing_deadline AS fBillingDeadline,
  934. tf.f_originalbilldate AS fOriginalbilldate,
  935. CASE
  936. WHEN tf.f_billstatus = '1' THEN '录入'
  937. WHEN tf.f_billstatus = '2' THEN '暂存'
  938. WHEN tf.f_billstatus = '3' THEN '审批驳回'
  939. WHEN tf.f_billstatus = '4' THEN '提交审核'
  940. WHEN tf.f_billstatus = '5' THEN '审核中'
  941. WHEN tf.f_billstatus = '6' THEN '审核通过'
  942. END AS fBillstatusName
  943. FROM t_warehousebillsfees tf
  944. LEFT JOIN t_corps tc ON tc.f_id = tf.f_corpid
  945. LEFT JOIN t_fees te ON te.f_id = tf.f_feeid
  946. LEFT JOIN t_warehousebills tw on tf.f_pid = tw.f_id
  947. <where>
  948. <if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
  949. <if test="fDc != null and fDc != ''">and tf.f_dc = #{fDc}</if>
  950. <if test="fMblno != null and fMblno != ''">and tf.f_mblno like concat('%', #{fMblno}, '%')</if>
  951. <if test="fStalmountStatus == 1">and tf.f_stlamount_no is not null and tf.f_stlamount!=0</if>
  952. <if test="fStalmountStatus == 2">and tf.f_stlamount_no is null</if>
  953. <if test="feesStatus == 1">and tf.f_statement_no is not null and tf.f_accamount &gt;= 0 and tf.f_accamount
  954. != 0
  955. </if>
  956. <if test="feesStatus == 2">and tf.f_statement_no is null</if>
  957. <if test="fInvnosStatus == 1">and tf.f_invnos is not null and tf.f_invamount != 0</if>
  958. <if test="fInvnosStatus == 2">and tf.f_invnos is null</if>
  959. <if test="fCorpid != null and fCorpid != ''">and tf.f_corpid = #{fCorpid}</if>
  960. <if test="fShipper != null and fShipper != ''">and tw.f_shipper like concat('%',#{fShipper},'%')</if>
  961. <if test="fEmblno != null and fEmblno != ''">and tw.f_emblno like concat('%',#{fEmblno},'%')</if>
  962. <if test="fStltypeid != null">and tf.f_stltypeid = #{fStltypeid}</if>
  963. <if test="fSrcBillno != null">and tf.src_bill_no = #{fSrcBillno}</if>
  964. <if test='fFeeids != null'>
  965. and tf.f_feeid in
  966. <foreach item="fFeeid" collection="fFeeids" open="(" separator="," close=")">
  967. #{fFeeid}
  968. </foreach>
  969. </if>
  970. <if test='fReviewDateList != null and fReviewDateList[0] != null and fReviewDateList[0]!= ""'>
  971. and tf.f_review_date &gt;= #{fReviewDateList[0]}
  972. </if>
  973. <if test='fReviewDateList != null and fReviewDateList[1] != null and fReviewDateList[1]!= ""'>
  974. and tf.f_review_date &lt;= #{fReviewDateList[1]}
  975. </if>
  976. <if test='fBsdateList != null and fBsdateList[0] != null and fBsdateList[0]!= ""'>
  977. and tf.f_bsdate &gt;= #{fBsdateList[0]}
  978. </if>
  979. <if test='fBsdateList != null and fBsdateList[1] != null and fBsdateList[1]!= ""'>
  980. and tf.f_bsdate &lt;= #{fBsdateList[1]}
  981. </if>
  982. </where>
  983. ORDER BY tf.f_bsdate desc
  984. </select>
  985. <select id="selectBillDetailsSubItemNew" parameterType="TWarehousebillsfees" resultType="map">
  986. select
  987. twf.f_pid as fId,
  988. twf.f_mblno as fMblno,
  989. dict.dict_label as fBusinesstype,
  990. CASE
  991. WHEN twf.f_billtype = 'SJRK' THEN '入库'
  992. WHEN twf.f_billtype = 'SJCK' THEN '实际出库'
  993. WHEN twf.f_billtype = 'CKDB' THEN '调拨'
  994. WHEN twf.f_billtype = 'HQZY' THEN '货权转移'
  995. WHEN twf.f_billtype = 'CDZZ' THEN '场地直装'
  996. END as fBilltype,
  997. twf.f_corpid as fCorpid,
  998. twf.f_statement_no as fStatementno,
  999. twf.f_product_name as tgfName,
  1000. tc.f_name as tcfName,
  1001. twf.f_qty as fQty,
  1002. tw.f_netweight as fNetweight,
  1003. tw.f_volumn as fVolumn,
  1004. date_format(twf.f_originalbilldate, '%Y-%m-%d') fOriginalbilldate,
  1005. date_format(twf.f_bsdate, '%Y-%m-%d') fBsdate,
  1006. twf.f_billing_days as fBillingdays,
  1007. twf.f_amt as fAmt,
  1008. twf.f_amount as fAmount,
  1009. twf.create_by as createBy,
  1010. date_format(twf.f_chargedate, '%Y-%m-%d') fChargedate,
  1011. date_format(twf.f_stlamount_date, '%Y-%m-%d') fStlamountdate,
  1012. th.f_name as fhName,
  1013. twf.f_dc as fDc,
  1014. twf.remark as remark
  1015. from t_warehousebillsfees twf
  1016. LEFT JOIN t_warehousebills tw on twf.f_pid = tw.f_id
  1017. LEFT JOIN t_goods tg on tw.f_goodsid = tg.f_id
  1018. LEFT JOIN t_corps tc on twf.f_corpid = tc.f_id
  1019. LEFT JOIN t_warehouse th on tw.f_warehouseid = th.f_id
  1020. LEFT JOIN (
  1021. SELECT
  1022. *
  1023. FROM
  1024. sys_dict_data dictIn
  1025. WHERE
  1026. dictIn.dict_label =
  1027. IF((
  1028. (dictIn.dict_type = 'st_in_type' AND dictIn.`status` = '0') OR
  1029. (dictIn.dict_type = 'st_out_type'AND dictIn.status = '0') OR
  1030. (dictIn.dict_type = 'st_trans_type' AND dictIn.status = '0')
  1031. ),dictIn.dict_label,NULL)
  1032. ) dict ON dict.dict_value = twf.f_business_type
  1033. <where>
  1034. <if test="fCorpid != null and fCorpid != ''">and twf.f_corpid = #{fCorpid}</if>
  1035. <if test="fMblno != null and fMblno != ''">and twf.f_mblno like concat('%', #{fMblno}, '%')</if>
  1036. <if test='fBsdateList != null and fBsdateList[0] != null and fBsdateList[0]!= ""'>
  1037. and twf.f_bsdate &gt;= #{fBsdateList[0]}
  1038. </if>
  1039. <if test='fBsdateList != null and fBsdateList[1] != null and fBsdateList[1]!= ""'>
  1040. and twf.f_bsdate &lt;= #{fBsdateList[1]}
  1041. </if>
  1042. <if test='fReviewDateList != null and fReviewDateList[0] != null and fReviewDateList[0]!= ""'>
  1043. and twf.f_review_date &gt;= #{fReviewDateList[0]}
  1044. </if>
  1045. <if test='fReviewDateList != null and fReviewDateList[1] != null and fReviewDateList[1]!= ""'>
  1046. and twf.f_review_date &lt;= #{fReviewDateList[1]}
  1047. </if>
  1048. <if test="fStalmountStatus == 1">and twf.f_stlamount_no is not null and twf.f_stlamount!=0</if>
  1049. <if test="fStalmountStatus == 2">and twf.f_stlamount_no is null</if>
  1050. <if test="feesStatus == 1">and twf.f_statement_no is not null and twf.f_accamount &gt;= 0 and
  1051. twf.f_accamount != 0
  1052. </if>
  1053. <if test="feesStatus == 2">and twf.f_statement_no is null</if>
  1054. <if test="fInvnosStatus == 1">and twf.f_invnos is not null and twf.f_invamount != 0</if>
  1055. <if test="fInvnosStatus == 2">and twf.f_invnos is null</if>
  1056. <if test="fDc != null and fDc != ''">and twf.f_dc = #{fDc}</if>
  1057. <if test='fFeeids != null'>
  1058. and twf.f_feeid in
  1059. <foreach item="fFeeid" collection="fFeeids" open="(" separator="," close=")">
  1060. #{fFeeid}
  1061. </foreach>
  1062. </if>
  1063. <if test="fBillstatus != null and fBillstatus != ''">and twf.f_billstatus = #{fBillstatus}</if>
  1064. <if test="fShipper != null and fShipper != ''">and tw.f_shipper like concat('%',#{fShipper},'%')</if>
  1065. </where>
  1066. GROUP BY
  1067. twf.f_mblno,tc.f_name
  1068. ORDER BY twf.f_bsdate desc
  1069. </select>
  1070. <select id="selectFeesBymblnoAndFname" resultType="map">
  1071. SELECT
  1072. tf.f_name as feeName,
  1073. SUM(twf.f_unitprice) as fUnitprice,
  1074. SUM(twf.f_amount) as fAmount
  1075. FROM
  1076. t_fees tf
  1077. LEFT JOIN t_warehousebillsfees twf on tf.f_id = twf.f_feeid
  1078. <where>
  1079. <if test="fMblno != null and fMblno != ''">and twf.f_mblno = #{fMblno}</if>
  1080. <if test="fCorpid != null and fCorpid != ''">and twf.f_corpid = #{fCorpid}</if>
  1081. <if test="fDc != null and fDc != ''">and twf.f_dc = #{fDc}</if>
  1082. </where>
  1083. GROUP BY
  1084. feeName
  1085. </select>
  1086. </mapper>