TWarehousebillsfeesMapper.xml 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  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="fQty" column="f_qty"/>
  14. <result property="fUnitprice" column="f_unitprice"/>
  15. <result property="fAmount" column="f_amount"/>
  16. <result property="fCurrency" column="f_currency"/>
  17. <result property="fExrate" column="f_exrate"/>
  18. <result property="fTaxrate" column="f_taxrate"/>
  19. <result property="fDc" column="f_dc"/>
  20. <result property="fBillstatus" column="f_billstatus"/>
  21. <result property="fReviewDate" column="f_review_date"/>
  22. <result property="fAccamount" column="f_accamount"/>
  23. <result property="fStatementNo" column="f_statement_no"/>
  24. <result property="fStlamount" column="f_stlamount"/>
  25. <result property="fInvnos" column="f_invnos"/>
  26. <result property="fAccamountDate" column="f_accamount_date"/>
  27. <result property="fInvamount" column="f_invamount"/>
  28. <result property="fStlamountNo" column="f_stlamount_no"/>
  29. <result property="fAskamount" column="f_askamount"/>
  30. <result property="fStatus" column="f_status"/>
  31. <result property="fStlamountDate" column="f_stlamount_date"/>
  32. <result property="delFlag" column="del_flag"/>
  33. <result property="createBy" column="create_by"/>
  34. <result property="createTime" column="create_time"/>
  35. <result property="updateBy" column="update_by"/>
  36. <result property="updateTime" column="update_time"/>
  37. <result property="remark" column="remark"/>
  38. <result property="srcId" column="src_id"/>
  39. <result property="srcBillNo" column="src_bill_no"/>
  40. <result property="fMblno" column="f_mblno"/>
  41. <result property="fProductName" column="f_product_name"/>
  42. <result property="fMarks" column="f_marks"/>
  43. <result property="fChargedate" column="f_chargedate"/>
  44. <result property="fBillingDeadline" column="f_billing_deadline"/>
  45. <result property="fInventoryDays" column="f_inventory_days"/>
  46. <result property="fAmt" column="f_amt"/>
  47. <result property="fBillingDays" column="f_billing_days"/>
  48. <result property="fBillingQty" column="f_billing_qty"/>
  49. <result property="fBilltype" column="f_billtype"/>
  50. <result property="fBillingway" column="f_billingway"/>
  51. <result property="fBsdate" column="f_bsdate"/>
  52. <result property="fOriginalbilldate" column="f_originalbilldate"/>
  53. <result property="fStltypeid" column="f_stltypeid"/>
  54. <result property="fBusinessType" column="f_business_type"/>
  55. <result property="fSrcTypeId" column="f_src_type_id"/>
  56. <result property="fWarehouseid" column="f_warehouseid"/>
  57. <result property="fPurchase" column="f_purchase"/>
  58. <result property="tProductdate" column="t_productdate"/>
  59. <result property="fLotno" column="f_lotno"/>
  60. <result property="fValid" column="f_valid"/>
  61. <result property="fUnits" column="f_units"/>
  62. <result property="fStoreEnv" column="f_store_env"/>
  63. <result property="fIsfilles" column="f_isfilles"/>
  64. </resultMap>
  65. <sql id="selectTWarehousebillsfeesVo">
  66. select f_id,
  67. f_pid,
  68. f_lineno,
  69. f_corpid,
  70. f_feeid,
  71. f_feeUnitid,
  72. f_qty,
  73. f_unitprice,
  74. f_amount,
  75. f_currency,
  76. f_exrate,
  77. f_taxrate,
  78. f_dc,
  79. f_billstatus,
  80. f_review_date,
  81. f_statement_no,
  82. f_accamount,
  83. f_stlamount,
  84. f_accamount_date,
  85. f_invnos,
  86. f_invamount,
  87. f_stlamount_no,
  88. f_askamount,
  89. f_status,
  90. f_stlamount_date,
  91. del_flag,
  92. create_by,
  93. create_time,
  94. update_by,
  95. update_time,
  96. remark,
  97. src_id,
  98. src_bill_no,
  99. f_mblno,
  100. f_product_name,
  101. f_marks,
  102. f_chargedate,
  103. f_billing_deadline,
  104. f_inventory_days,
  105. f_amt,
  106. f_billing_days,
  107. f_billing_qty,
  108. f_billtype,
  109. f_billingway,
  110. f_bsdate,
  111. f_originalbilldate,
  112. f_stltypeid,
  113. f_business_type,
  114. f_src_type_id,
  115. f_warehouseid,
  116. f_purchase,
  117. t_productdate,
  118. f_lotno,
  119. f_valid,
  120. f_units,
  121. f_store_env,
  122. f_isfilles
  123. from t_warehousebillsfees
  124. </sql>
  125. <select id="selectTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  126. resultMap="TWarehousebillsfeesResult">
  127. <include refid="selectTWarehousebillsfeesVo"/>
  128. <where>
  129. <if test="fPid != null ">and f_pid = #{fPid}</if>
  130. <if test="fLineno != null ">and f_lineno = #{fLineno}</if>
  131. <if test="fCorpid != null ">and f_corpid = #{fCorpid}</if>
  132. <if test="fFeeid != null ">and f_feeid = #{fFeeid}</if>
  133. <if test="fFeeunitid != null ">and f_feeUnitid = #{fFeeunitid}</if>
  134. <if test="fQty != null ">and f_qty = #{fQty}</if>
  135. <if test="fUnitprice != null ">and f_unitprice = #{fUnitprice}</if>
  136. <if test="fAmount != null ">and f_amount = #{fAmount}</if>
  137. <if test="fCurrency != null and fCurrency != ''">and f_currency = #{fCurrency}</if>
  138. <if test="fExrate != null ">and f_exrate = #{fExrate}</if>
  139. <if test="fTaxrate != null ">and f_taxrate = #{fTaxrate}</if>
  140. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  141. <if test="fBillstatus != null and fBillstatus != ''">and f_billstatus = #{fBillstatus}</if>
  142. <if test="fReviewDate != null ">and f_review_date = #{fReviewDate}</if>
  143. <if test="fStatementNo != null and fStatementNo != ''">and f_statement_no = #{fStatementNo}</if>
  144. <if test="fAccamount != null ">and f_accamount = #{fAccamount}</if>
  145. <if test="fStlamount != null ">and f_stlamount = #{fStlamount}</if>
  146. <if test="fAccamountDate != null ">and f_accamount_date = #{fAccamountDate}</if>
  147. <if test="fInvnos != null and fInvnos != ''">and f_invnos = #{fInvnos}</if>
  148. <if test="fInvamount != null ">and f_invamount = #{fInvamount}</if>
  149. <if test="fStlamountNo != null and fStlamountNo != ''">and f_stlamount_no = #{fStlamountNo}</if>
  150. <if test="fAskamount != null ">and f_askamount = #{fAskamount}</if>
  151. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  152. <if test="delFlag != null">and del_flag = #{delFlag}</if>
  153. <if test="fStlamountDate != null ">and f_stlamount_date = #{fStlamountDate}</if>
  154. <if test="srcId != null ">and src_id = #{srcId}</if>
  155. <if test="srcBillNo != null and srcBillNo != ''">and src_bill_no = #{srcBillNo}</if>
  156. <if test="fMblno != null and fMblno != ''">and f_mblno = #{fMblno}</if>
  157. <if test="fProductName != null and fProductName != ''">and f_product_name like concat('%', #{fProductName},
  158. '%')
  159. </if>
  160. <if test="fMarks != null and fMarks != ''">and f_marks = #{fMarks}</if>
  161. <if test="fChargedate != null ">and f_chargedate = #{fChargedate}</if>
  162. <if test="fBillingDeadline != null ">and f_billing_deadline = #{fBillingDeadline}</if>
  163. <if test="fInventoryDays != null ">and f_inventory_days = #{fInventoryDays}</if>
  164. <if test="fAmt != null ">and f_amt = #{fAmt}</if>
  165. <if test="fBillingDays != null ">and f_billing_days = #{fBillingDays}</if>
  166. <if test="fBillingQty != null ">and f_billing_qty = #{fBillingQty}</if>
  167. <if test="fBilltype != null and fBilltype != ''">and f_billtype = #{fBilltype}</if>
  168. <if test="fBillingway != null ">and f_billingway = #{fBillingway}</if>
  169. <if test="fBsdate != null ">and f_bsdate = #{fBsdate}</if>
  170. <if test="fOriginalbilldate != null ">and f_originalbilldate = #{fOriginalbilldate}</if>
  171. <if test="fStltypeid != null">and f_stltypeid = #{fStltypeid},</if>
  172. <if test="fSrcTypeId != null">and f_src_type_id = #{fSrcTypeId},</if>
  173. <if test="fWarehouseid != null ">and f_warehouseid = #{fWarehouseid}</if>
  174. <if test="fPurchase != null ">and f_purchase = #{fPurchase}</if>
  175. </where>
  176. </select>
  177. <select id="selectTWarehousebillsfeesById" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  178. <include refid="selectTWarehousebillsfeesVo"/>
  179. where f_id = #{fId}
  180. </select>
  181. <select id="selectTWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  182. select f_id, f_pid, f_billing_deadline
  183. where f_pid = #{fId}
  184. and f_billtype = 'SJCK'
  185. </select>
  186. <select id="selectWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  187. <include refid="selectTWarehousebillsfeesVo"/>
  188. where f_pid = #{fId}
  189. </select>
  190. <select id="selectReconciliation" resultType="java.lang.Integer">
  191. SELECT COUNT(d.f_id)
  192. FROM t_fee_do d
  193. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  194. WHERE d.f_srcpid = #{fId}
  195. AND f.f_billtype = 'DZ'
  196. </select>
  197. <select id="selectCharge" resultType="java.lang.Integer">
  198. SELECT COUNT(d.f_id)
  199. FROM t_fee_do d
  200. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  201. WHERE d.f_srcpid = #{fId}
  202. AND f.f_billtype = 'SF'
  203. </select>
  204. <select id="selectPay" resultType="java.lang.Integer">
  205. SELECT COUNT(d.f_id)
  206. FROM t_fee_do d
  207. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  208. WHERE d.f_srcpid = #{fId}
  209. AND f.f_billtype = 'FF'
  210. </select>
  211. <select id="selectFleetExcelMonthList" parameterType="TWarehousebillsfees"
  212. resultType="com.ruoyi.finance.excel.FleetExcel">
  213. SELECT
  214. CONCAT( MONTH ( s.f_bsdate ), '月份小计:' ) feelMonthName,
  215. CONCAT(
  216. YEAR ( s.f_bsdate ),
  217. '-',
  218. MONTH ( s.f_bsdate )) feelMonth,
  219. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  220. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  221. sum( s.f_amount ) totalAmount,
  222. sum( s.f_invamount ) invamount,
  223. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  224. FROM
  225. t_warehousebillsfees s
  226. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  227. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  228. WHERE
  229. s.f_dc = 'D'
  230. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  231. and s.f_bsdate &gt;= #{fMonth[0]}
  232. </if>
  233. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  234. and s.f_bsdate &lt;= #{fMonth[1]}
  235. </if>
  236. GROUP BY
  237. CONCAT(
  238. YEAR ( f_bsdate ),
  239. '-',
  240. MONTH ( f_bsdate ))
  241. </select>
  242. <select id="selectFleetExcelList" parameterType="TWarehousebillsfees"
  243. resultType="com.ruoyi.finance.excel.FleetExcel">
  244. SELECT
  245. #{createBy} userName,
  246. CONCAT(
  247. YEAR ( s.f_bsdate ),
  248. '-',
  249. MONTH ( s.f_bsdate )) feelMonth,
  250. c.f_name corpName,
  251. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  252. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  253. sum( s.f_amount ) totalAmount,
  254. IF
  255. ( f_invamount = 0, 'F', 'T' ) isInvoice,
  256. sum( s.f_invamount ) invamount,
  257. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  258. FROM
  259. t_warehousebillsfees s
  260. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  261. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  262. WHERE
  263. s.f_dc = 'D'
  264. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  265. and s.f_bsdate &gt;= #{fMonth[0]}
  266. </if>
  267. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  268. and s.f_bsdate &lt;= #{fMonth[1]}
  269. </if>
  270. GROUP BY CONCAT( YEAR ( f_bsdate ), '-', MONTH ( f_bsdate )), s.f_corpid, c.f_name
  271. </select>
  272. <insert id="insertTWarehousebillsfees" parameterType="TWarehousebillsfees" useGeneratedKeys="true"
  273. keyProperty="fId">
  274. insert into t_warehousebillsfees
  275. <trim prefix="(" suffix=")" suffixOverrides=",">
  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="fFeeunitid != null">f_feeUnitid,</if>
  281. <if test="fQty != null">f_qty,</if>
  282. <if test="fUnitprice != null">f_unitprice,</if>
  283. <if test="fAmount != null">f_amount,</if>
  284. <if test="fCurrency != null">f_currency,</if>
  285. <if test="fExrate != null">f_exrate,</if>
  286. <if test="fTaxrate != null">f_taxrate,</if>
  287. <if test="fDc != null">f_dc,</if>
  288. <if test="fBillstatus != null">f_billstatus,</if>
  289. <if test="fReviewDate != null">f_review_date,</if>
  290. <if test="fStatementNo != null">f_statement_no,</if>
  291. <if test="fAccamount != null">f_accamount,</if>
  292. <if test="fStlamount != null">f_stlamount,</if>
  293. <if test="fAccamountDate != null">f_accamount_date,</if>
  294. <if test="fInvnos != null">f_invnos,</if>
  295. <if test="fInvamount != null">f_invamount,</if>
  296. <if test="fStlamountNo != null">f_stlamount_no,</if>
  297. <if test="fAskamount != null">f_askamount,</if>
  298. <if test="fStatus != null">f_status,</if>
  299. <if test="fStlamountDate != null">f_stlamount_date,</if>
  300. <if test="delFlag != null">del_flag,</if>
  301. <if test="createBy != null">create_by,</if>
  302. <if test="createTime != null">create_time,</if>
  303. <if test="updateBy != null">update_by,</if>
  304. <if test="updateTime != null">update_time,</if>
  305. <if test="remark != null">remark,</if>
  306. <if test="srcId != null">src_id,</if>
  307. <if test="srcBillNo != null">src_bill_no,</if>
  308. <if test="fMblno != null">f_mblno,</if>
  309. <if test="fProductName != null">f_product_name,</if>
  310. <if test="fMarks != null">f_marks,</if>
  311. <if test="fChargedate != null">f_chargedate,</if>
  312. <if test="fBillingDeadline != null">f_billing_deadline,</if>
  313. <if test="fInventoryDays != null">f_inventory_days,</if>
  314. <if test="fAmt != null">f_amt,</if>
  315. <if test="fBillingDays != null">f_billing_days,</if>
  316. <if test="fBillingQty != null">f_billing_qty,</if>
  317. <if test="fBilltype != null">f_billtype,</if>
  318. <if test="fBillingway != null">f_billingway,</if>
  319. <if test="fBsdate != null">f_bsdate,</if>
  320. <if test="fOriginalbilldate != null">f_originalbilldate,</if>
  321. <if test="fStltypeid != null">f_stltypeid,</if>
  322. <if test="fBusinessType != null">f_business_type,</if>
  323. <if test="fSrcTypeId != null">f_src_type_id,</if>
  324. <if test="fWarehouseid != null">f_warehouseid,</if>
  325. <if test="fPurchase != null">f_purchase,</if>
  326. <if test="tProductdate != null">t_productdate,</if>
  327. <if test="fLotno != null">f_lotno,</if>
  328. <if test="fValid != null">f_valid,</if>
  329. <if test="fUnits != null">f_units,</if>
  330. <if test="fStoreEnv != null">f_store_env,</if>
  331. <if test="fIsfilles != null">f_isfilles,</if>
  332. </trim>
  333. <trim prefix="values (" suffix=")" suffixOverrides=",">
  334. <if test="fPid != null">#{fPid},</if>
  335. <if test="fLineno != null">#{fLineno},</if>
  336. <if test="fCorpid != null">#{fCorpid},</if>
  337. <if test="fFeeid != null">#{fFeeid},</if>
  338. <if test="fFeeunitid != null">#{fFeeunitid},</if>
  339. <if test="fQty != null">#{fQty},</if>
  340. <if test="fUnitprice != null">#{fUnitprice},</if>
  341. <if test="fAmount != null">#{fAmount},</if>
  342. <if test="fCurrency != null">#{fCurrency},</if>
  343. <if test="fExrate != null">#{fExrate},</if>
  344. <if test="fTaxrate != null">#{fTaxrate},</if>
  345. <if test="fDc != null">#{fDc},</if>
  346. <if test="fBillstatus != null">#{fBillstatus},</if>
  347. <if test="fReviewDate != null">#{fReviewDate},</if>
  348. <if test="fStatementNo != null">#{fStatementNo},</if>
  349. <if test="fAccamount != null">#{fAccamount},</if>
  350. <if test="fStlamount != null">#{fStlamount},</if>
  351. <if test="fAccamountDate != null">#{fAccamountDate},</if>
  352. <if test="fInvnos != null">#{fInvnos},</if>
  353. <if test="fInvamount != null">#{fInvamount},</if>
  354. <if test="fStlamountNo != null">#{fStlamountNo},</if>
  355. <if test="fAskamount != null">#{fAskamount},</if>
  356. <if test="fStatus != null">#{fStatus},</if>
  357. <if test="fStlamountDate != null">#{fStlamountDate},</if>
  358. <if test="delFlag != null">#{delFlag},</if>
  359. <if test="createBy != null">#{createBy},</if>
  360. <if test="createTime != null">#{createTime},</if>
  361. <if test="updateBy != null">#{updateBy},</if>
  362. <if test="updateTime != null">#{updateTime},</if>
  363. <if test="remark != null">#{remark},</if>
  364. <if test="srcId != null">#{srcId},</if>
  365. <if test="srcBillNo != null">#{srcBillNo},</if>
  366. <if test="fMblno != null">#{fMblno},</if>
  367. <if test="fProductName != null">#{fProductName},</if>
  368. <if test="fMarks != null">#{fMarks},</if>
  369. <if test="fChargedate != null">#{fChargedate},</if>
  370. <if test="fBillingDeadline != null">#{fBillingDeadline},</if>
  371. <if test="fInventoryDays != null">#{fInventoryDays},</if>
  372. <if test="fAmt != null">#{fAmt},</if>
  373. <if test="fBillingDays != null">#{fBillingDays},</if>
  374. <if test="fBillingQty != null">#{fBillingQty},</if>
  375. <if test="fBilltype != null">#{fBilltype},</if>
  376. <if test="fBillingway != null">#{fBillingway},</if>
  377. <if test="fBsdate != null">#{fBsdate},</if>
  378. <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
  379. <if test="fStltypeid != null">#{fStltypeid},</if>
  380. <if test="fBusinessType != null">#{fBusinessType},</if>
  381. <if test="fSrcTypeId != null">#{fSrcTypeId},</if>
  382. <if test="fWarehouseid != null">#{fWarehouseid},</if>
  383. <if test="fPurchase != null">#{fPurchase},</if>
  384. <if test="tProductdate != null">#{tProductdate},</if>
  385. <if test="fLotno != null">#{fLotno},</if>
  386. <if test="fValid != null">#{fValid},</if>
  387. <if test="fUnits != null">#{fUnits},</if>
  388. <if test="fStoreEnv != null">#{fStoreEnv},</if>
  389. <if test="fIsfilles != null">#{fIsfilles},</if>
  390. </trim>
  391. </insert>
  392. <update id="updateTWarehousebillsfees" parameterType="TWarehousebillsfees">
  393. update t_warehousebillsfees
  394. <trim prefix="SET" suffixOverrides=",">
  395. <if test="fPid != null">f_pid = #{fPid},</if>
  396. <if test="fLineno != null">f_lineno = #{fLineno},</if>
  397. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  398. <if test="fFeeid != null">f_feeid = #{fFeeid},</if>
  399. <if test="fFeeunitid != null">f_feeUnitid = #{fFeeunitid},</if>
  400. <if test="fQty != null">f_qty = #{fQty},</if>
  401. <if test="fUnitprice != null">f_unitprice = #{fUnitprice},</if>
  402. <if test="fAmount != null">f_amount = #{fAmount},</if>
  403. <if test="fCurrency != null">f_currency = #{fCurrency},</if>
  404. <if test="fExrate != null">f_exrate = #{fExrate},</if>
  405. <if test="fTaxrate != null">f_taxrate = #{fTaxrate},</if>
  406. <if test="fDc != null">f_dc = #{fDc},</if>
  407. <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
  408. <if test="fReviewDate != null">f_review_date = #{fReviewDate},</if>
  409. <if test="fStatementNo != null">f_statement_no = #{fStatementNo},</if>
  410. <if test="fAccamount != null">f_accamount = #{fAccamount},</if>
  411. <if test="fStlamount != null">f_stlamount = #{fStlamount},</if>
  412. <if test="fAccamountDate != null">f_accamount_date = #{fAccamountDate},</if>
  413. <if test="fInvnos != null">f_invnos = #{fInvnos},</if>
  414. <if test="fInvamount != null">f_invamount = #{fInvamount},</if>
  415. <if test="fStlamountNo != null">f_stlamount_no = #{fStlamountNo},</if>
  416. <if test="fAskamount != null">f_askamount = #{fAskamount},</if>
  417. <if test="fStatus != null">f_status = #{fStatus},</if>
  418. <if test="fStlamountDate != null">f_stlamount_date = #{fStlamountDate},</if>
  419. <if test="delFlag != null">del_flag = #{delFlag},</if>
  420. <if test="createBy != null">create_by = #{createBy},</if>
  421. <if test="createTime != null">create_time = #{createTime},</if>
  422. <if test="updateBy != null">update_by = #{updateBy},</if>
  423. <if test="updateTime != null">update_time = #{updateTime},</if>
  424. <if test="remark != null">remark = #{remark},</if>
  425. <if test="srcId != null">src_id = #{srcId},</if>
  426. <if test="srcBillNo != null">src_bill_no = #{srcBillNo},</if>
  427. <if test="fMblno != null">f_mblno = #{fMblno},</if>
  428. <if test="fProductName != null">f_product_name = #{fProductName},</if>
  429. <if test="fMarks != null">f_marks = #{fMarks},</if>
  430. <if test="fChargedate != null">f_chargedate = #{fChargedate},</if>
  431. <if test="fBillingDeadline != null">f_billing_deadline = #{fBillingDeadline},</if>
  432. <if test="fInventoryDays != null">f_inventory_days = #{fInventoryDays},</if>
  433. <if test="fAmt != null">f_amt = #{fAmt},</if>
  434. <if test="fBillingDays != null">f_billing_days = #{fBillingDays},</if>
  435. <if test="fBillingQty != null">f_billing_qty = #{fBillingQty},</if>
  436. <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
  437. <if test="fBillingway != null">f_billingway = #{fBillingway},</if>
  438. <if test="fBsdate != null">f_bsdate = #{fBsdate},</if>
  439. <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
  440. <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
  441. <if test="fSrcTypeId != null">f_src_type_id = #{fSrcTypeId},</if>
  442. <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
  443. <if test="fPurchase != null">f_purchase = #{fPurchase},</if>
  444. <if test="tProductdate != null">t_productdate = #{tProductdate},</if>
  445. <if test="fLotno != null">f_lotno = #{fLotno},</if>
  446. <if test="fValid != null">f_valid = #{fValid},</if>
  447. <if test="fUnits != null">f_units = #{fUnits},</if>
  448. <if test="fStoreEnv != null">f_store_env = #{fStoreEnv},</if>
  449. <if test="fIsfilles != null">f_isfilles = #{fIsfilles},</if>
  450. </trim>
  451. where f_id = #{fId}
  452. </update>
  453. <delete id="deleteTWarehousebillsfeesById" parameterType="Long">
  454. delete
  455. from t_warehousebillsfees
  456. where f_id = #{fId}
  457. </delete>
  458. <delete id="deleteByFPid" parameterType="Long">
  459. delete
  460. from t_warehousebillsfees
  461. where f_pid = #{fId}
  462. </delete>
  463. <delete id="deleteTWarehousebillsfeesByIds" parameterType="String">
  464. delete from t_warehousebillsfees where f_id in
  465. <foreach item="fId" collection="array" open="(" separator="," close=")">
  466. #{fId}
  467. </foreach>
  468. </delete>
  469. <update id="warehouseFeesFollowUpdate">
  470. update
  471. t_warehousebillsfees
  472. <trim prefix="SET" suffixOverrides=",">
  473. <if test="fettle != null">f_billstatus = #{fettle},</if>
  474. <if test="auditItem != null and fettle == 6">f_review_date = #{auditItem},</if>
  475. <if test="auditItem != null and fettle != 6">f_review_date = null,</if>
  476. </trim>
  477. where f_pid = #{fPid}
  478. </update>
  479. <update id="updateTWarehousebillsfee" parameterType="Map">
  480. update t_warehousebillsfees
  481. <trim prefix="SET" suffixOverrides=",">
  482. /*判断确认对账*/
  483. <if test="map.billType == 'DZ'">
  484. f_statement_no = #{map.tFee.fBillno},
  485. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  486. f_accamount_date = #{map.tFee.fAccbilldate}
  487. </if>
  488. /*判断撤销对账*/
  489. <if test="map.billType == 'DZRevoke'">
  490. f_statement_no = #{map.tFee.fBillno},
  491. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  492. f_accamount_date = #{map.tFee.fAccbilldate}
  493. </if>
  494. /*判断收付款*/
  495. <if test="map.billType == 'DC'">
  496. f_stlamount_no = #{map.tFee.fBillno},
  497. f_stlamount = f_stlamount + #{map.tFeeDo.fAmt},
  498. f_stlamount_date =#{map.tFee.fAccbilldate}
  499. </if>
  500. /*判断撤销收付款*/
  501. <if test="map.billType == 'DCRevoke'">
  502. f_stlamount_no = #{map.tFee.fBillno},
  503. f_stlamount = f_stlamount - #{map.tFeeDo.fAmt},
  504. f_stlamount_date =#{map.tFee.fAccbilldate}
  505. </if>
  506. /*判断开发票款*/
  507. <if test="map.billType == 'invoiceFP'">
  508. f_invamount = f_invamount + #{map.tFeeDo.fAmt},
  509. f_stlamount_date =#{map.tFee.fAccbilldate}
  510. </if>
  511. <if test="map.billType == 'DZinvoiceFP'">
  512. f_invamount = f_invamount - #{map.tFeeDo.fAmt},
  513. f_stlamount_date =#{map.tFee.fAccbilldate}
  514. </if>
  515. /*判断申请发票款*/
  516. <if test="map.billType == 'ApplyFP'">
  517. f_askamount = f_askamount + #{map.tFeeDo.fAmt},
  518. f_stlamount_date =#{map.tFee.fAccbilldate}
  519. </if>
  520. <if test="map.billType == 'DZApplyFP'">
  521. f_askamount = f_askamount - #{map.tFeeDo.fAmt},
  522. f_stlamount_date =#{map.tFee.fAccbilldate}
  523. </if>
  524. /*判断确认对账*/
  525. <if test="map.billType == 'KHDZ'">
  526. f_statement_no = #{map.tFee.fBillno},
  527. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  528. f_accamount_date = #{map.tFee.fAccbilldate}
  529. </if>
  530. /*判断撤销对账*/
  531. <if test="map.billType == 'KHDZRevoke'">
  532. f_statement_no = #{map.tFee.fBillno},
  533. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  534. f_accamount_date = #{map.tFee.fAccbilldate}
  535. </if>
  536. </trim>
  537. where f_id = #{map.tFeeDo.fSrcid}
  538. </update>
  539. <select id="selectFeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  540. SELECT
  541. tw.f_id,
  542. tw.f_pid,
  543. tw.f_lineno,
  544. tw.f_corpid,
  545. tc.f_name corpName,
  546. tw.f_feeid,
  547. tf.f_name feeName,
  548. tw.f_feeUnitid,
  549. tw.f_qty,
  550. tw.f_unitprice,
  551. tw.f_amount,
  552. tw.f_currency,
  553. tw.f_exrate,
  554. tw.f_taxrate,
  555. tw.f_dc,
  556. tw.f_billstatus,
  557. CASE
  558. WHEN tw.f_billstatus = '1' THEN
  559. '新建'
  560. WHEN tw.f_billstatus = '2' THEN
  561. '暂存'
  562. WHEN tw.f_billstatus = '3' THEN
  563. '驳回'
  564. WHEN tw.f_billstatus = '4' THEN
  565. '提交'
  566. WHEN tw.f_billstatus = '5' THEN
  567. '审批中'
  568. WHEN tw.f_billstatus = '6' THEN
  569. '审批通过'
  570. END AS fBillstatusName,
  571. tw.f_review_date,
  572. tw.f_statement_no,
  573. tw.f_accamount,
  574. tw.f_stlamount,
  575. tw.f_accamount_date,
  576. tw.f_invnos,
  577. tw.f_invamount,
  578. tw.f_stlamount_no,
  579. tw.f_askamount,
  580. tw.f_status,
  581. tw.f_stlamount_date,
  582. tw.del_flag,
  583. tw.create_by,
  584. tw.create_time,
  585. tw.update_by,
  586. tw.update_time,
  587. tw.remark,
  588. tw.src_id,
  589. tw.src_bill_no,
  590. tw.f_mblno,
  591. tw.f_product_name,
  592. tw.f_marks,
  593. tw.f_chargedate,
  594. tw.f_billing_deadline,
  595. tw.f_inventory_days,
  596. tw.f_amt,
  597. tw.f_billing_days,
  598. tw.f_billing_qty,
  599. tw.f_billtype,
  600. tw.f_billingway,
  601. tw.f_bsdate,
  602. tw.f_originalbilldate,
  603. tw.f_stltypeid,
  604. tw.f_business_type,
  605. tw.f_src_type_id
  606. FROM
  607. t_warehousebillsfees tw
  608. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  609. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  610. where tw.f_pid = #{fPid}
  611. and tw.f_billtype = 'KHDD'
  612. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  613. </select>
  614. <delete id="deleteFessByFPid" parameterType="object">
  615. delete
  616. from t_warehousebillsfees
  617. where f_pid = #{fPid}
  618. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  619. </delete>
  620. <!--网页版查询对账-->
  621. <select id="webVersionReconciliation" parameterType="TAccount" resultType="map">
  622. SELECT
  623. tb.f_billno AS fBillno,
  624. /**运单号*/
  625. tv.f_name AS vesselName,
  626. /**船名*/
  627. ty.f_no AS voyageName,
  628. /**航次*/
  629. tc.f_name AS invoice,
  630. /**收费单位*/
  631. tc.f_name AS drawee,
  632. /**受票单位*/
  633. tp.f_name AS corpName,
  634. /**货权方*/
  635. pro.dict_label AS fPaymode,
  636. /**付款方式*/
  637. te.f_name AS payment,
  638. /**费用名称*/
  639. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmtdr,
  640. /**原始金额*/
  641. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmt,
  642. /**本次金额*/
  643. ta.f_name AS fLoadportidName,
  644. /**始发港*/
  645. tr.f_name AS fDestportidName,
  646. /**目的港*/
  647. pr.dict_label AS fServiceitems,
  648. /**运输条款*/
  649. tg.f_name AS goodName,
  650. /**货名*/
  651. tn.f_name AS transit,
  652. /**箱型*/
  653. items.f_cntrcount AS fCntrcount,
  654. /**箱量*/
  655. tb.f_shippername AS fShippername,
  656. /**发货人*/
  657. tb.f_consigneername AS fConsigneername,
  658. /**收货人*/
  659. tf.f_id AS fSrcid,
  660. tf.f_pid AS fSrcpid,
  661. tf.create_by AS createBy,
  662. tf.create_time AS createTime,
  663. tf.update_by AS updateBy,
  664. tf.update_time AS updateTime,
  665. tf.remark AS remark,
  666. tf.f_mblno AS fMblno,
  667. tf.f_corpid AS fCorpid,
  668. tf.f_feeid AS fFeeid
  669. FROM
  670. t_warehousebillsfees tf
  671. LEFT JOIN t_corps tc ON tc.f_id = tf.f_corpid
  672. LEFT JOIN t_fees te ON te.f_id = tf.f_feeid
  673. LEFT JOIN t_warehousebills tb ON tb.f_id = tf.f_pid
  674. LEFT JOIN t_vessel tv ON tv.f_id = tb.f_vslid
  675. LEFT JOIN t_voyage ty ON ty.f_id = tb.f_voyid
  676. LEFT JOIN t_address ta ON ta.f_id = tb.f_loadportid
  677. LEFT JOIN t_address tr ON tr.f_id = tb.f_destportid
  678. LEFT JOIN sys_dict_data pro ON pro.dict_value = tb.f_paymode
  679. AND pro.dict_type = 'data_settlement_type'
  680. LEFT JOIN sys_dict_data pr ON pr.dict_value = tb.f_serviceitems
  681. AND pr.dict_type = 'f_serviceitems'
  682. LEFT JOIN ( SELECT f_pid, MAX( f_goodsid ) f_goodsid FROM t_warehousebills_cntr GROUP BY f_pid ) w ON w.f_pid =
  683. tb.f_id
  684. LEFT JOIN t_goods tg ON tg.f_id = w.f_goodsid
  685. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  686. ON items.f_pid = tb.f_id
  687. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  688. twc.f_pid = tb.f_id
  689. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  690. LEFT JOIN t_corps tp ON tp.f_id = tb.f_corpid
  691. WHERE
  692. tf.f_billstatus = 6
  693. AND tf.f_dc = 'D'
  694. AND tb.f_typeid = 1
  695. and tb.f_review_date IS NOT NULL
  696. and ifnull(tf.f_amount, 0) - ifnull(tf.f_accamount, 0) > 0
  697. <if test="fLoadportid != null">and tb.f_loadportid = #{fLoadportid}</if>
  698. <if test="fDestportid != null">and tb.f_destportid = #{fDestportid}</if>
  699. <if test="fInvoceobj != null and fInvoceobj != ''">and tb.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  700. <if test="fShippername != null and fShippername != ''">and tb.f_shippername like concat('%', #{fShippername},
  701. '%')
  702. </if>
  703. <if test="fConsigneername != null and fConsigneername != ''">and tb.f_consigneername like concat('%',
  704. #{fConsigneername}, '%')
  705. </if>
  706. <if test="fMblno != null and fMblno != ''">and tb.f_mblno like concat('%', #{fMblno}, '%')</if>
  707. <if test="fBillno != null and fBillno != ''">and tb.f_billno like concat('%', #{fBillno}, '%')</if>
  708. <if test="fVslid != null">and tb.f_vslid = #{fVslid}</if>
  709. <if test="fVoyid != null">and tb.f_voyid = #{fVoyid}</if>
  710. <if test="fCorpid != null">and tf.f_corpid = #{fCorpid}</if>
  711. <if test="fPaymodeid != null">and tb.f_paymode = #{fPaymodeid}</if>
  712. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  713. and tf.create_time &gt;= #{sailTime[0]}
  714. </if>
  715. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  716. and tf.create_time &lt;= #{sailTime[1]}
  717. </if>
  718. <if test="fDocmentdate != null and fDocmentdate != ''">and tb.f_docmentdate = #{fDocmentdate}</if>
  719. <if test="createBy != null and createBy != ''">and tb.create_by = #{createBy}</if>
  720. <if test="goodName != null and goodName != ''">and tg.f_name like concat('%', #{goodName}, '%')</if>
  721. ORDER BY tf.f_id desc
  722. </select>
  723. <!--网页版查询对账明细-->
  724. <select id="webVersionDetail" parameterType="TAccount" resultType="map">
  725. SELECT
  726. tf.f_id AS fId,
  727. te.f_billno AS accountBillno,
  728. /**账单编号*/
  729. tw.f_billno AS fBillno,
  730. /**运单编号*/
  731. tv.f_name AS vesselName,
  732. /**船名*/
  733. ty.f_no AS voyageName,
  734. /**航次*/
  735. te.f_ctrlcorpid AS fCtrlcorpid,
  736. /**获权方*/
  737. tp.f_name AS corpName,
  738. /**结算单位*/
  739. ta.f_name AS fLoadportidName,
  740. /**始发港*/
  741. tr.f_name AS fDestportidName,
  742. /**目的港*/
  743. pr.dict_label AS fServiceitems,
  744. /**运输条款*/
  745. ts.f_name AS payment,
  746. /**费用名称*/
  747. tf.f_amtdr AS fAmtdr,
  748. /**原始金额*/
  749. tf.f_amt AS fAmt,
  750. /**本次金额*/
  751. tn.f_name AS transit,
  752. /**箱型*/
  753. items.f_cntrcount AS fCntrcount,
  754. /**箱量*/
  755. tf.create_by AS createBy,
  756. tf.create_time AS createTime,
  757. CASE
  758. WHEN te.f_billstatus = '1' THEN
  759. '保存'
  760. WHEN te.f_billstatus = '2' THEN
  761. '暂存'
  762. WHEN te.f_billstatus = '3' THEN
  763. '审批驳回'
  764. WHEN te.f_billstatus = '4' THEN
  765. '提交审核'
  766. WHEN te.f_billstatus = '5' THEN
  767. '审核中'
  768. WHEN te.f_billstatus = '6' THEN
  769. '审核完成'
  770. END AS fBillstatus
  771. FROM
  772. t_fee_do tf
  773. LEFT JOIN t_fee te ON te.f_id = tf.f_pid
  774. LEFT JOIN t_warehousebills tw ON tf.f_srcpid = tw.f_id
  775. LEFT JOIN t_warehousebillsfees th ON th.f_id = tf.f_srcid
  776. LEFT JOIN t_vessel tv ON tw.f_vslid = tv.f_id
  777. LEFT JOIN t_voyage ty ON ty.f_id = tw.f_voyid
  778. LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
  779. LEFT JOIN t_address tr ON tr.f_id = tw.f_destportid
  780. LEFT JOIN sys_dict_data pr ON pr.dict_value = tw.f_serviceitems
  781. AND pr.dict_type = 'f_serviceitems'
  782. LEFT JOIN t_fees ts ON ts.f_id = tf.f_feeid
  783. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  784. ON items.f_pid = tw.f_id
  785. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  786. twc.f_pid = tw.f_id
  787. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  788. LEFT JOIN t_corps tp ON tp.f_id = te.f_corpid
  789. WHERE
  790. te.f_billtype = 'KHDZ'
  791. <if test="fLoadportid != null">and tw.f_loadportid = #{fLoadportid}</if>
  792. <if test="fDestportid != null">and tw.f_destportid = #{fDestportid}</if>
  793. <if test="fInvoceobj != null and fInvoceobj != ''">and tw.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  794. <if test="fShippername != null and fShippername != ''">and tw.f_shippername like concat('%', #{fShippername},
  795. '%')
  796. </if>
  797. <if test="fConsigneername != null and fConsigneername != ''">and tw.f_consigneername like concat('%',
  798. #{fConsigneername}, '%')
  799. </if>
  800. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  801. <if test="fVslid != null">and tw.f_vslid = #{fVslid}</if>
  802. <if test="fId != null">and tf.f_id = #{fId}</if>
  803. <if test="fVoyid != null">and tw.f_voyid = #{fVoyid}</if>
  804. <if test="fCorpid != null">and te.f_corpid = #{fCorpid}</if>
  805. <if test="fPaymodeid != null">and tw.f_paymode = #{fPaymodeid}</if>
  806. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  807. and tf.create_time &gt;= #{sailTime[0]}
  808. </if>
  809. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  810. and tf.create_time &lt;= #{sailTime[1]}
  811. </if>
  812. <if test="fDocmentdate != null and fDocmentdate != ''">and tw.f_docmentdate = #{fDocmentdate}</if>
  813. <if test="createBy != null and createBy != ''">and te.create_by = #{createBy}</if>
  814. <if test="accountBillno != null and accountBillno != ''">and te.f_billno = #{accountBillno}</if>
  815. ORDER BY tf.f_id desc
  816. </select>
  817. <update id="anPinDeleteFeeUpdate">
  818. update
  819. t_warehousebillsfees
  820. <trim prefix="SET" suffixOverrides=",">
  821. <if test="delFlag != null">del_flag = #{delFlag},</if>
  822. <if test="updateBy != null">update_by = #{updateBy},</if>
  823. <if test="updateTime != null">update_time = #{updateTime},</if>
  824. </trim>
  825. where f_id in
  826. <foreach item="fId" collection="fIds" open="(" separator="," close=")">
  827. #{fId}
  828. </foreach>
  829. </update>
  830. <select id="anPinTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  831. resultMap="TWarehousebillsfeesResult">
  832. select tw.f_id,
  833. tw.f_pid,
  834. tw.f_lineno,
  835. tw.f_corpid,
  836. tw.f_feeid,
  837. tf.f_name AS feeName,
  838. tf.f_currency AS fCurrencyName,
  839. tw.f_feeUnitid,
  840. sc.dict_label AS fFeeunitName,
  841. tw.f_qty,
  842. tw.f_unitprice,
  843. tw.f_amount,
  844. tw.f_currency,
  845. tw.f_exrate,
  846. tw.f_taxrate,
  847. tw.f_dc,
  848. tw.f_billstatus,
  849. CASE
  850. WHEN tw.f_billstatus = '1' THEN
  851. '保存'
  852. WHEN tw.f_billstatus = '2' THEN
  853. '暂存'
  854. WHEN tw.f_billstatus = '3' THEN
  855. '审批驳回'
  856. WHEN tw.f_billstatus = '4' THEN
  857. '提交审核'
  858. WHEN tw.f_billstatus = '5' THEN
  859. '审核中'
  860. WHEN tw.f_billstatus = '6' THEN
  861. '审核完成'
  862. END AS fBillstatusName,
  863. tw.f_review_date,
  864. tw.f_statement_no,
  865. tw.f_accamount,
  866. tw.f_stlamount,
  867. tw.f_accamount_date,
  868. tw.f_invnos,
  869. tw.f_invamount,
  870. tw.f_stlamount_no,
  871. tw.f_askamount,
  872. tw.f_status,
  873. tw.f_stlamount_date,
  874. tw.del_flag,
  875. tw.create_by,
  876. tw.create_time,
  877. tw.update_by,
  878. tw.update_time,
  879. tw.remark,
  880. tw.src_id,
  881. tw.src_bill_no,
  882. tw.f_mblno,
  883. tw.f_product_name,
  884. tw.f_marks,
  885. tw.f_chargedate,
  886. tw.f_billing_deadline,
  887. tw.f_inventory_days,
  888. tw.f_amt,
  889. tw.f_billing_days,
  890. tw.f_billing_qty,
  891. tw.f_billtype,
  892. tw.f_billingway,
  893. tw.f_bsdate,
  894. tw.f_originalbilldate,
  895. tw.f_stltypeid,
  896. sd.dict_label AS fBillingwayName,
  897. tw.f_business_type,
  898. tw.f_src_type_id,
  899. tw.f_warehouseid,
  900. th.f_warehouse_information AS fWarehouseName,
  901. tw.f_purchase,
  902. tw.t_productdate,
  903. tw.f_lotno,
  904. tw.f_valid,
  905. tw.f_units,
  906. tw.f_store_env,
  907. tw.f_isfilles,
  908. si.dict_label AS fUnitsName,
  909. st.dict_label AS fStoreEnvName,
  910. sti.dict_label AS fIsfillesName
  911. from t_warehousebillsfees tw
  912. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  913. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  914. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid AND sc.dict_type = 'data_unitfees'
  915. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid AND sd.dict_type = 'f_paymode'
  916. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units AND si.dict_type = 'f_floatunit'
  917. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env AND st.dict_type = 'f_StorageEnvironment'
  918. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles AND sti.dict_type = 'f_evidence'
  919. <where>
  920. <if test="fPid != null ">and tw.f_pid = #{fPid}</if>
  921. <if test="fLineno != null ">and tw.f_lineno = #{fLineno}</if>
  922. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  923. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  924. <if test="fFeeunitid != null ">and tw.f_feeUnitid = #{fFeeunitid}</if>
  925. <if test="fQty != null ">and tw.f_qty = #{fQty}</if>
  926. <if test="fUnitprice != null ">and tw.f_unitprice = #{fUnitprice}</if>
  927. <if test="fAmount != null ">and tw.f_amount = #{fAmount}</if>
  928. <if test="fCurrency != null and fCurrency != ''">and tw.f_currency = #{fCurrency}</if>
  929. <if test="fExrate != null ">and tw.f_exrate = #{fExrate}</if>
  930. <if test="fTaxrate != null ">and tw.f_taxrate = #{fTaxrate}</if>
  931. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  932. <if test="fBillstatus != null and fBillstatus != ''">and tw.f_billstatus = #{fBillstatus}</if>
  933. <if test="fReviewDate != null ">and tw.f_review_date = #{fReviewDate}</if>
  934. <if test="fStatementNo != null and fStatementNo != ''">and tw.f_statement_no = #{fStatementNo}</if>
  935. <if test="fAccamount != null ">and tw.f_accamount = #{fAccamount}</if>
  936. <if test="fStlamount != null ">and tw.f_stlamount = #{fStlamount}</if>
  937. <if test="fAccamountDate != null ">and tw.f_accamount_date = #{fAccamountDate}</if>
  938. <if test="fInvnos != null and fInvnos != ''">and tw.f_invnos = #{fInvnos}</if>
  939. <if test="fInvamount != null ">and tw.f_invamount = #{fInvamount}</if>
  940. <if test="fStlamountNo != null and fStlamountNo != ''">and tw.f_stlamount_no = #{fStlamountNo}</if>
  941. <if test="fAskamount != null ">and tw.f_askamount = #{fAskamount}</if>
  942. <if test="fStatus != null and fStatus != ''">and tw.f_status = #{fStatus}</if>
  943. <if test="delFlag != null">and tw.del_flag = #{delFlag}</if>
  944. <if test="fStlamountDate != null ">and tw.f_stlamount_date = #{fStlamountDate}</if>
  945. <if test="srcId != null ">and tw.src_id = #{srcId}</if>
  946. <if test="srcBillNo != null and srcBillNo != ''">and tw.src_bill_no = #{srcBillNo}</if>
  947. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  948. <if test="fProductName != null and fProductName != ''">and tw.f_product_name like concat('%',
  949. #{fProductName},
  950. '%')
  951. </if>
  952. <if test="fMarks != null and fMarks != ''">and tw.f_marks = #{fMarks}</if>
  953. <if test="fChargedate != null ">and tw.f_chargedate = #{fChargedate}</if>
  954. <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
  955. <if test="fInventoryDays != null ">and tw.f_inventory_days = #{fInventoryDays}</if>
  956. <if test="fAmt != null ">and tw.f_amt = #{fAmt}</if>
  957. <if test="fBillingDays != null ">and tw.f_billing_days = #{fBillingDays}</if>
  958. <if test="fBillingQty != null ">and tw.f_billing_qty = #{fBillingQty}</if>
  959. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  960. <if test="fBillingway != null ">and tw.f_billingway = #{fBillingway}</if>
  961. <if test="fBsdate != null ">and tw.f_bsdate = #{fBsdate}</if>
  962. <if test="fOriginalbilldate != null ">and tw.f_originalbilldate = #{fOriginalbilldate}</if>
  963. <if test="fStltypeid != null">and tw.f_stltypeid = #{fStltypeid},</if>
  964. <if test="fSrcTypeId != null">and tw.f_src_type_id = #{fSrcTypeId},</if>
  965. <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
  966. <if test="fPurchase != null ">and tw.f_purchase = #{fPurchase}</if>
  967. </where>
  968. </select>
  969. <!--安品出入库统计-->
  970. <select id="selectTWarehouseInorOut" parameterType="TWarehousebills"
  971. resultType="com.ruoyi.anpin.WarhousrExcel">
  972. SELECT ti.f_bsdate AS fBsdate,/*进货时间*/
  973. tf.f_name AS feeName,/*物资名称*/
  974. tf.f_currency AS fCurrencyName,/*物资规格*/
  975. tw.f_qty AS fQty,/*实际数量*/
  976. tc.f_name AS corpName,/*供货商*/
  977. tc.f_manage AS fManage,/*联系人*/
  978. tc.f_tel AS fTel,/*联系电话*/
  979. tw.t_productdate AS tProductdate,/*生产日期*/
  980. tw.f_lotno AS fLotno,/*批次号*/
  981. CONCAT(tw.f_units,si.dict_label) AS quality,/*保值期限*/
  982. st.dict_label AS fStoreEnvName,/*储存环境中文名*/
  983. sti.dict_label AS fIsfillesName,/*索证索票*/
  984. std.dict_label AS fFeetype,/*物资类别*/
  985. sr.user_name AS purchaseName,/*采购人*/
  986. CASE
  987. WHEN tw.f_billtype = 'CK' THEN
  988. '出库'
  989. WHEN tw.f_billtype = 'RK' THEN
  990. '入库'
  991. END AS fBilltypeName/*出入库类型*/
  992. FROM t_warehousebillsfees tw
  993. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  994. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  995. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid
  996. AND sc.dict_type = 'data_unitfees'
  997. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid
  998. AND sd.dict_type = 'f_paymode'
  999. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units
  1000. AND si.dict_type = 'f_floatunit'
  1001. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env
  1002. AND st.dict_type = 'f_StorageEnvironment'
  1003. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles
  1004. AND sti.dict_type = 'f_evidence'
  1005. LEFT JOIN t_warehousebills ti ON tw.f_pid = ti.f_id
  1006. LEFT JOIN t_corps tc ON ti.f_corpid = tc.f_id
  1007. LEFT JOIN sys_user sr ON sr.user_id = ti.f_purchase
  1008. LEFT JOIN sys_dict_data std ON std.dict_value = tf.f_feetype
  1009. AND std.dict_type = 'data_cost_attribute'
  1010. <where>
  1011. tw.del_flag = '0'
  1012. <if test="fBillstatus != null and fBillstatus == 1">and tw.f_billstatus = 6</if>
  1013. <if test="fBillstatus != null and fBillstatus == 2">and tw.f_billstatus != 6</if>
  1014. <if test="fCorpid != null ">and ti.f_corpid = #{fCorpid}</if>
  1015. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  1016. <if test="fBilltype == null or fBilltype == ''">and tw.f_billtype in ('CK','RK')</if>
  1017. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  1018. <if test="fFeeType != null ">and tf.f_feetype = #{fFeeType}</if>
  1019. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  1020. and ti.f_bsdate &gt;= #{cLoadDate[0]}
  1021. </if>
  1022. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  1023. and ti.f_bsdate &lt;= #{cLoadDate[1]}
  1024. </if>
  1025. </where>
  1026. ORDER BY tw.f_id DESC
  1027. </select>
  1028. <!--安品出销售出库统计-->
  1029. <select id="salesOfOutbound" parameterType="TWarehousebills"
  1030. resultType="com.ruoyi.anpin.SalesOfOutbound">
  1031. SELECT
  1032. td.fgoodsid AS fgoodsid,/*项目id*/
  1033. tp.f_name AS projectName,/*项目中文名*/
  1034. td.ffeetype AS ffeetype,/*物资类别*/
  1035. si.dict_label AS ffeetypeName /*物资类别中文名*/,
  1036. td.fname AS fname,/*物资名*/
  1037. td.fcurrency AS fcurrency,/*规格*/
  1038. td.ffeeunitid AS ffeeunitid,/*计价单位id*/
  1039. sc.dict_label AS ffeeunitidName,/*计价单位中文名*/
  1040. td.fqty AS fqty,/*数量*/
  1041. td.famount AS famount,/*金额*/
  1042. round(td.price,2) AS price/*单价*/
  1043. FROM
  1044. (
  1045. SELECT
  1046. tc.fgoodsid,
  1047. tc.ffeetype,
  1048. tc.fname,
  1049. tc.fcurrency,
  1050. tc.ffeeunitid,
  1051. IFNULL( SUM( tc.fqty ), 0 ) fqty,
  1052. IFNULL( SUM( tc.famount ), 0 ) famount,
  1053. IFNULL( SUM( tc.famount )/ SUM( tc.fqty ), 0 ) price
  1054. FROM
  1055. (
  1056. SELECT
  1057. tb.f_goodsid fgoodsid,
  1058. /*项目*/
  1059. tf.f_feetype ffeetype,
  1060. /*物资类别*/
  1061. tf.f_name fname,
  1062. /*物资名*/
  1063. tf.f_currency fcurrency,
  1064. /*规格*/
  1065. tw.f_feeunitid ffeeunitid,
  1066. /*计价单位*/
  1067. tw.f_qty fqty,
  1068. /*实际数量*/
  1069. tw.f_amount famount /*金额*/
  1070. FROM
  1071. t_warehousebillsfees tw
  1072. LEFT JOIN t_warehousebills tb ON tw.f_pid = tb.f_id
  1073. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1074. WHERE
  1075. tw.del_flag = '0'
  1076. AND tw.f_billtype = 'XS'
  1077. <if test="fBillstatus != null">and tw.f_billstatus = #{fBillstatus}</if>
  1078. <if test="fGoodsid != null and fGoodsid != ''">and tb.f_goodsid = #{fGoodsid}</if>
  1079. <if test="fFeeid != null">and tw.f_feeid = #{fFeeid}</if>
  1080. <if test="fFeeType != null ">and tf.f_feetype = #{fFeeType}</if>
  1081. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  1082. and tb.f_bsdate &gt;= #{cLoadDate[0]}
  1083. </if>
  1084. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  1085. and tb.f_bsdate &lt;= #{cLoadDate[1]}
  1086. </if>
  1087. ) tc
  1088. GROUP BY
  1089. tc.fgoodsid,
  1090. tc.ffeetype,
  1091. tc.fname,
  1092. tc.fcurrency,
  1093. tc.ffeeunitid
  1094. ) td
  1095. LEFT JOIN t_project tp ON td.fgoodsid = tp.f_id
  1096. LEFT JOIN sys_dict_data sc ON sc.dict_value = td.ffeeunitid AND sc.dict_type = 'data_unitfees'
  1097. LEFT JOIN sys_dict_data si ON si.dict_value = td.ffeetype AND si.dict_type = 'data_cost_attribute'
  1098. ORDER BY td.fgoodsid DESC
  1099. </select>
  1100. <!--安品利润统计-->
  1101. <select id="salectAnpinProfit" parameterType="TWarehousebills"
  1102. resultType="com.ruoyi.anpin.ProfitExcel">
  1103. SELECT
  1104. temp.years AS annual,
  1105. temp.months AS abbreviated,
  1106. temp.fCorpName AS fCorpName,
  1107. temp.market AS market,
  1108. temp.purchase AS purchase,
  1109. temp.profit AS profit
  1110. FROM
  1111. (
  1112. SELECT
  1113. xs.years AS years,
  1114. xs.months AS months,
  1115. xs.f_corpid AS fCorpid,
  1116. CASE
  1117. WHEN tc.f_name IS NOT NULL THEN
  1118. tc.f_name
  1119. WHEN ts.f_name IS NOT NULL THEN
  1120. ts.f_name
  1121. END AS fCorpName,
  1122. IFNULL( xs.pay, 0 ) AS market,
  1123. IFNULL( sq.collect, 0 ) AS purchase,
  1124. CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
  1125. WHEN xs.pay IS NULL AND sq.collect IS NOT NULL THEN 0 -sq.collect
  1126. WHEN xs.pay IS NOT NULL AND sq.collect IS NULL THEN xs.pay- 0
  1127. END AS profit
  1128. FROM
  1129. (
  1130. SELECT
  1131. tf.f_corpid,
  1132. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1133. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1134. IFNULL( SUM( tf.f_amount ), 0 ) AS pay
  1135. FROM
  1136. t_warehousebillsfees tf
  1137. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1138. LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
  1139. WHERE
  1140. tf.f_billtype = 'XS'
  1141. AND tf.del_flag = '0'
  1142. AND tf.f_billstatus = 6
  1143. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1144. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1145. <if test="years != null and years != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{years}</if>
  1146. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1147. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1148. </if>
  1149. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1150. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1151. </if>
  1152. GROUP BY
  1153. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1154. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1155. tf.f_corpid
  1156. ORDER BY
  1157. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1158. DATE_FORMAT( tf.f_bsdate, '%m' )
  1159. ) xs
  1160. LEFT JOIN (
  1161. SELECT
  1162. tf.f_corpid,
  1163. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1164. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1165. IFNULL( SUM( tf.f_amount ), 0 ) AS collect
  1166. FROM
  1167. t_warehousebillsfees tf
  1168. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1169. LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
  1170. WHERE
  1171. tf.f_billtype = 'SQ'
  1172. AND tf.del_flag = '0'
  1173. AND tf.f_billstatus = 6
  1174. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1175. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1176. <if test="years != null and years != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{years}</if>
  1177. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1178. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1179. </if>
  1180. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1181. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1182. </if>
  1183. GROUP BY
  1184. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1185. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1186. tf.f_corpid
  1187. ORDER BY
  1188. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1189. DATE_FORMAT( tf.f_bsdate, '%m' )
  1190. ) sq ON sq.f_corpid = xs.f_corpid
  1191. AND sq.years = xs.years
  1192. AND sq.months = xs.months
  1193. LEFT JOIN t_corps tc ON xs.f_corpid = tc.f_id
  1194. LEFT JOIN t_corps ts ON sq.f_corpid = ts.f_id
  1195. UNION ALL
  1196. SELECT
  1197. sq.years AS years,
  1198. sq.months AS months,
  1199. sq.f_corpid AS fCorpid,
  1200. CASE
  1201. WHEN tc.f_name IS NOT NULL THEN
  1202. tc.f_name
  1203. WHEN ts.f_name IS NOT NULL THEN
  1204. ts.f_name
  1205. END AS fCorpName,
  1206. IFNULL( xs.pay, 0 ) AS market,
  1207. IFNULL( sq.collect, 0 ) AS purchase,
  1208. CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
  1209. WHEN xs.pay IS NULL AND sq.collect IS NOT NULL THEN 0 -sq.collect
  1210. WHEN xs.pay IS NOT NULL AND sq.collect IS NULL THEN xs.pay- 0
  1211. END AS profit
  1212. FROM
  1213. (
  1214. SELECT
  1215. tf.f_corpid,
  1216. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1217. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1218. IFNULL( SUM( tf.f_amount ), 0 ) AS collect
  1219. FROM
  1220. t_warehousebillsfees tf
  1221. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1222. LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
  1223. WHERE
  1224. tf.f_billtype = 'SQ'
  1225. AND tf.del_flag = '0'
  1226. AND tf.f_billstatus = 6
  1227. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1228. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1229. <if test="years != null and years != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{years}</if>
  1230. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1231. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1232. </if>
  1233. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1234. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1235. </if>
  1236. GROUP BY
  1237. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1238. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1239. tf.f_corpid
  1240. ORDER BY
  1241. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1242. DATE_FORMAT( tf.f_bsdate, '%m' )
  1243. ) sq
  1244. LEFT JOIN (
  1245. SELECT
  1246. tf.f_corpid,
  1247. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1248. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1249. IFNULL( SUM( tf.f_amount ), 0 ) AS pay
  1250. FROM
  1251. t_warehousebillsfees tf
  1252. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1253. LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
  1254. WHERE
  1255. tf.f_billtype = 'XS'
  1256. AND tf.del_flag = '0'
  1257. AND tf.f_billstatus = 6
  1258. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1259. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1260. <if test="years != null and years != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{years}</if>
  1261. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1262. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1263. </if>
  1264. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1265. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1266. </if>
  1267. GROUP BY
  1268. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1269. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1270. tf.f_corpid
  1271. ORDER BY
  1272. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1273. DATE_FORMAT( tf.f_bsdate, '%m' )
  1274. ) xs ON sq.f_corpid = xs.f_corpid
  1275. AND sq.years = xs.years
  1276. AND sq.months = xs.months
  1277. LEFT JOIN t_corps tc ON xs.f_corpid = tc.f_id
  1278. LEFT JOIN t_corps ts ON sq.f_corpid = ts.f_id
  1279. ) AS temp
  1280. ORDER BY temp.years,temp.months,CONVERT(temp.fCorpName USING GBK)
  1281. </select>
  1282. </mapper>