TWarehousebillsfeesMapper.xml 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284
  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. <result property="fAllotWarehouseid" column="f_allot_warehouseid" />
  65. </resultMap>
  66. <sql id="selectTWarehousebillsfeesVo">
  67. select f_id,
  68. f_pid,
  69. f_lineno,
  70. f_corpid,
  71. f_feeid,
  72. f_feeUnitid,
  73. f_qty,
  74. f_unitprice,
  75. f_amount,
  76. f_currency,
  77. f_exrate,
  78. f_taxrate,
  79. f_dc,
  80. f_billstatus,
  81. f_review_date,
  82. f_statement_no,
  83. f_accamount,
  84. f_stlamount,
  85. f_accamount_date,
  86. f_invnos,
  87. f_invamount,
  88. f_stlamount_no,
  89. f_askamount,
  90. f_status,
  91. f_stlamount_date,
  92. del_flag,
  93. create_by,
  94. create_time,
  95. update_by,
  96. update_time,
  97. remark,
  98. src_id,
  99. src_bill_no,
  100. f_mblno,
  101. f_product_name,
  102. f_marks,
  103. f_chargedate,
  104. f_billing_deadline,
  105. f_inventory_days,
  106. f_amt,
  107. f_billing_days,
  108. f_billing_qty,
  109. f_billtype,
  110. f_billingway,
  111. f_bsdate,
  112. f_originalbilldate,
  113. f_stltypeid,
  114. f_business_type,
  115. f_src_type_id,
  116. f_warehouseid,
  117. f_purchase,
  118. t_productdate,
  119. f_lotno,
  120. f_valid,
  121. f_units,
  122. f_store_env,
  123. f_isfilles,
  124. f_allot_warehouseid
  125. from t_warehousebillsfees
  126. </sql>
  127. <select id="selectTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  128. resultMap="TWarehousebillsfeesResult">
  129. <include refid="selectTWarehousebillsfeesVo"/>
  130. <where>
  131. del_flag = '0'
  132. <if test="fPid != null ">and f_pid = #{fPid}</if>
  133. <if test="fLineno != null ">and f_lineno = #{fLineno}</if>
  134. <if test="fCorpid != null ">and f_corpid = #{fCorpid}</if>
  135. <if test="fFeeid != null ">and f_feeid = #{fFeeid}</if>
  136. <if test="fFeeunitid != null ">and f_feeUnitid = #{fFeeunitid}</if>
  137. <if test="fQty != null ">and f_qty = #{fQty}</if>
  138. <if test="fUnitprice != null ">and f_unitprice = #{fUnitprice}</if>
  139. <if test="fAmount != null ">and f_amount = #{fAmount}</if>
  140. <if test="fCurrency != null and fCurrency != ''">and f_currency = #{fCurrency}</if>
  141. <if test="fExrate != null ">and f_exrate = #{fExrate}</if>
  142. <if test="fTaxrate != null ">and f_taxrate = #{fTaxrate}</if>
  143. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  144. <if test="fBillstatus != null and fBillstatus != ''">and f_billstatus = #{fBillstatus}</if>
  145. <if test="fReviewDate != null ">and f_review_date = #{fReviewDate}</if>
  146. <if test="fStatementNo != null and fStatementNo != ''">and f_statement_no = #{fStatementNo}</if>
  147. <if test="fAccamount != null ">and f_accamount = #{fAccamount}</if>
  148. <if test="fStlamount != null ">and f_stlamount = #{fStlamount}</if>
  149. <if test="fAccamountDate != null ">and f_accamount_date = #{fAccamountDate}</if>
  150. <if test="fInvnos != null and fInvnos != ''">and f_invnos = #{fInvnos}</if>
  151. <if test="fInvamount != null ">and f_invamount = #{fInvamount}</if>
  152. <if test="fStlamountNo != null and fStlamountNo != ''">and f_stlamount_no = #{fStlamountNo}</if>
  153. <if test="fAskamount != null ">and f_askamount = #{fAskamount}</if>
  154. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  155. <if test="fStlamountDate != null ">and f_stlamount_date = #{fStlamountDate}</if>
  156. <if test="srcId != null ">and src_id = #{srcId}</if>
  157. <if test="srcBillNo != null and srcBillNo != ''">and src_bill_no = #{srcBillNo}</if>
  158. <if test="fMblno != null and fMblno != ''">and f_mblno = #{fMblno}</if>
  159. <if test="fProductName != null and fProductName != ''">and f_product_name like concat('%', #{fProductName},
  160. '%')
  161. </if>
  162. <if test="fMarks != null and fMarks != ''">and f_marks = #{fMarks}</if>
  163. <if test="fChargedate != null ">and f_chargedate = #{fChargedate}</if>
  164. <if test="fBillingDeadline != null ">and f_billing_deadline = #{fBillingDeadline}</if>
  165. <if test="fInventoryDays != null ">and f_inventory_days = #{fInventoryDays}</if>
  166. <if test="fAmt != null ">and f_amt = #{fAmt}</if>
  167. <if test="fBillingDays != null ">and f_billing_days = #{fBillingDays}</if>
  168. <if test="fBillingQty != null ">and f_billing_qty = #{fBillingQty}</if>
  169. <if test="fBilltype != null and fBilltype != ''">and f_billtype = #{fBilltype}</if>
  170. <if test="fBillingway != null ">and f_billingway = #{fBillingway}</if>
  171. <if test="fBsdate != null ">and f_bsdate = #{fBsdate}</if>
  172. <if test="fOriginalbilldate != null ">and f_originalbilldate = #{fOriginalbilldate}</if>
  173. <if test="fStltypeid != null">and f_stltypeid = #{fStltypeid},</if>
  174. <if test="fSrcTypeId != null">and f_src_type_id = #{fSrcTypeId},</if>
  175. <if test="fWarehouseid != null ">and f_warehouseid = #{fWarehouseid}</if>
  176. <if test="fPurchase != null ">and f_purchase = #{fPurchase}</if>
  177. </where>
  178. </select>
  179. <select id="selectTWarehousebillsfeesById" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  180. <include refid="selectTWarehousebillsfeesVo"/>
  181. where f_id = #{fId}
  182. </select>
  183. <select id="selectTWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  184. select f_id, f_pid, f_billing_deadline
  185. where f_pid = #{fId}
  186. and f_billtype = 'SJCK'
  187. </select>
  188. <select id="selectWarehousebillsfeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  189. <include refid="selectTWarehousebillsfeesVo"/>
  190. where f_pid = #{fId}
  191. </select>
  192. <select id="selectReconciliation" resultType="java.lang.Integer">
  193. SELECT COUNT(d.f_id)
  194. FROM t_fee_do d
  195. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  196. WHERE d.f_srcpid = #{fId}
  197. AND f.f_billtype = 'DZ'
  198. </select>
  199. <select id="selectCharge" resultType="java.lang.Integer">
  200. SELECT COUNT(d.f_id)
  201. FROM t_fee_do d
  202. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  203. WHERE d.f_srcpid = #{fId}
  204. AND f.f_billtype = 'SF'
  205. </select>
  206. <select id="selectPay" resultType="java.lang.Integer">
  207. SELECT COUNT(d.f_id)
  208. FROM t_fee_do d
  209. LEFT JOIN t_fee f ON d.f_pid = f.f_id
  210. WHERE d.f_srcpid = #{fId}
  211. AND f.f_billtype = 'FF'
  212. </select>
  213. <select id="selectFleetExcelMonthList" parameterType="TWarehousebillsfees"
  214. resultType="com.ruoyi.finance.excel.FleetExcel">
  215. SELECT
  216. CONCAT( MONTH ( s.f_bsdate ), '月份小计:' ) feelMonthName,
  217. CONCAT(
  218. YEAR ( s.f_bsdate ),
  219. '-',
  220. MONTH ( s.f_bsdate )) feelMonth,
  221. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  222. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  223. sum( s.f_amount ) totalAmount,
  224. sum( s.f_invamount ) invamount,
  225. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  226. FROM
  227. t_warehousebillsfees s
  228. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  229. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  230. WHERE
  231. s.f_dc = 'D'
  232. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  233. and s.f_bsdate &gt;= #{fMonth[0]}
  234. </if>
  235. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  236. and s.f_bsdate &lt;= #{fMonth[1]}
  237. </if>
  238. GROUP BY
  239. CONCAT(
  240. YEAR ( f_bsdate ),
  241. '-',
  242. MONTH ( f_bsdate ))
  243. </select>
  244. <select id="selectFleetExcelList" parameterType="TWarehousebillsfees"
  245. resultType="com.ruoyi.finance.excel.FleetExcel">
  246. SELECT
  247. #{createBy} userName,
  248. CONCAT(
  249. YEAR ( s.f_bsdate ),
  250. '-',
  251. MONTH ( s.f_bsdate )) feelMonth,
  252. c.f_name corpName,
  253. sum( CASE WHEN s.f_feeid = 27 THEN s.f_amount ELSE 0 END ) ccf,
  254. sum( CASE WHEN s.f_feeid != 27 THEN s.f_amount ELSE 0 END ) fAmount,
  255. sum( s.f_amount ) totalAmount,
  256. IF
  257. ( f_invamount = 0, 'F', 'T' ) isInvoice,
  258. sum( s.f_invamount ) invamount,
  259. ROUND( sum( t.f_grossweightblc / 1000 ), 2 ) stock
  260. FROM
  261. t_warehousebillsfees s
  262. LEFT JOIN t_corps c ON s.f_corpid = c.f_id
  263. LEFT JOIN t_whgenleg t ON t.f_corpid = s.f_corpid
  264. WHERE
  265. s.f_dc = 'D'
  266. <if test='fMonth != null and fMonth[0] != null and fMonth[0]!= ""'>
  267. and s.f_bsdate &gt;= #{fMonth[0]}
  268. </if>
  269. <if test='fMonth != null and fMonth[1] != null and fMonth[1]!= ""'>
  270. and s.f_bsdate &lt;= #{fMonth[1]}
  271. </if>
  272. GROUP BY CONCAT( YEAR ( f_bsdate ), '-', MONTH ( f_bsdate )), s.f_corpid, c.f_name
  273. </select>
  274. <insert id="insertTWarehousebillsfees" parameterType="TWarehousebillsfees" useGeneratedKeys="true"
  275. keyProperty="fId">
  276. insert into t_warehousebillsfees
  277. <trim prefix="(" suffix=")" suffixOverrides=",">
  278. <if test="fPid != null">f_pid,</if>
  279. <if test="fLineno != null">f_lineno,</if>
  280. <if test="fCorpid != null">f_corpid,</if>
  281. <if test="fFeeid != null">f_feeid,</if>
  282. <if test="fFeeunitid != null">f_feeUnitid,</if>
  283. <if test="fQty != null">f_qty,</if>
  284. <if test="fUnitprice != null">f_unitprice,</if>
  285. <if test="fAmount != null">f_amount,</if>
  286. <if test="fCurrency != null">f_currency,</if>
  287. <if test="fExrate != null">f_exrate,</if>
  288. <if test="fTaxrate != null">f_taxrate,</if>
  289. <if test="fDc != null">f_dc,</if>
  290. <if test="fBillstatus != null">f_billstatus,</if>
  291. <if test="fReviewDate != null">f_review_date,</if>
  292. <if test="fStatementNo != null">f_statement_no,</if>
  293. <if test="fAccamount != null">f_accamount,</if>
  294. <if test="fStlamount != null">f_stlamount,</if>
  295. <if test="fAccamountDate != null">f_accamount_date,</if>
  296. <if test="fInvnos != null">f_invnos,</if>
  297. <if test="fInvamount != null">f_invamount,</if>
  298. <if test="fStlamountNo != null">f_stlamount_no,</if>
  299. <if test="fAskamount != null">f_askamount,</if>
  300. <if test="fStatus != null">f_status,</if>
  301. <if test="fStlamountDate != null">f_stlamount_date,</if>
  302. <if test="delFlag != null">del_flag,</if>
  303. <if test="createBy != null">create_by,</if>
  304. <if test="createTime != null">create_time,</if>
  305. <if test="updateBy != null">update_by,</if>
  306. <if test="updateTime != null">update_time,</if>
  307. <if test="remark != null">remark,</if>
  308. <if test="srcId != null">src_id,</if>
  309. <if test="srcBillNo != null">src_bill_no,</if>
  310. <if test="fMblno != null">f_mblno,</if>
  311. <if test="fProductName != null">f_product_name,</if>
  312. <if test="fMarks != null">f_marks,</if>
  313. <if test="fChargedate != null">f_chargedate,</if>
  314. <if test="fBillingDeadline != null">f_billing_deadline,</if>
  315. <if test="fInventoryDays != null">f_inventory_days,</if>
  316. <if test="fAmt != null">f_amt,</if>
  317. <if test="fBillingDays != null">f_billing_days,</if>
  318. <if test="fBillingQty != null">f_billing_qty,</if>
  319. <if test="fBilltype != null">f_billtype,</if>
  320. <if test="fBillingway != null">f_billingway,</if>
  321. <if test="fBsdate != null">f_bsdate,</if>
  322. <if test="fOriginalbilldate != null">f_originalbilldate,</if>
  323. <if test="fStltypeid != null">f_stltypeid,</if>
  324. <if test="fBusinessType != null">f_business_type,</if>
  325. <if test="fSrcTypeId != null">f_src_type_id,</if>
  326. <if test="fWarehouseid != null">f_warehouseid,</if>
  327. <if test="fPurchase != null">f_purchase,</if>
  328. <if test="tProductdate != null">t_productdate,</if>
  329. <if test="fLotno != null">f_lotno,</if>
  330. <if test="fValid != null">f_valid,</if>
  331. <if test="fUnits != null">f_units,</if>
  332. <if test="fStoreEnv != null">f_store_env,</if>
  333. <if test="fIsfilles != null">f_isfilles,</if>
  334. <if test="fAllotWarehouseid != null">f_allot_warehouseid,</if>
  335. </trim>
  336. <trim prefix="values (" suffix=")" suffixOverrides=",">
  337. <if test="fPid != null">#{fPid},</if>
  338. <if test="fLineno != null">#{fLineno},</if>
  339. <if test="fCorpid != null">#{fCorpid},</if>
  340. <if test="fFeeid != null">#{fFeeid},</if>
  341. <if test="fFeeunitid != null">#{fFeeunitid},</if>
  342. <if test="fQty != null">#{fQty},</if>
  343. <if test="fUnitprice != null">#{fUnitprice},</if>
  344. <if test="fAmount != null">#{fAmount},</if>
  345. <if test="fCurrency != null">#{fCurrency},</if>
  346. <if test="fExrate != null">#{fExrate},</if>
  347. <if test="fTaxrate != null">#{fTaxrate},</if>
  348. <if test="fDc != null">#{fDc},</if>
  349. <if test="fBillstatus != null">#{fBillstatus},</if>
  350. <if test="fReviewDate != null">#{fReviewDate},</if>
  351. <if test="fStatementNo != null">#{fStatementNo},</if>
  352. <if test="fAccamount != null">#{fAccamount},</if>
  353. <if test="fStlamount != null">#{fStlamount},</if>
  354. <if test="fAccamountDate != null">#{fAccamountDate},</if>
  355. <if test="fInvnos != null">#{fInvnos},</if>
  356. <if test="fInvamount != null">#{fInvamount},</if>
  357. <if test="fStlamountNo != null">#{fStlamountNo},</if>
  358. <if test="fAskamount != null">#{fAskamount},</if>
  359. <if test="fStatus != null">#{fStatus},</if>
  360. <if test="fStlamountDate != null">#{fStlamountDate},</if>
  361. <if test="delFlag != null">#{delFlag},</if>
  362. <if test="createBy != null">#{createBy},</if>
  363. <if test="createTime != null">#{createTime},</if>
  364. <if test="updateBy != null">#{updateBy},</if>
  365. <if test="updateTime != null">#{updateTime},</if>
  366. <if test="remark != null">#{remark},</if>
  367. <if test="srcId != null">#{srcId},</if>
  368. <if test="srcBillNo != null">#{srcBillNo},</if>
  369. <if test="fMblno != null">#{fMblno},</if>
  370. <if test="fProductName != null">#{fProductName},</if>
  371. <if test="fMarks != null">#{fMarks},</if>
  372. <if test="fChargedate != null">#{fChargedate},</if>
  373. <if test="fBillingDeadline != null">#{fBillingDeadline},</if>
  374. <if test="fInventoryDays != null">#{fInventoryDays},</if>
  375. <if test="fAmt != null">#{fAmt},</if>
  376. <if test="fBillingDays != null">#{fBillingDays},</if>
  377. <if test="fBillingQty != null">#{fBillingQty},</if>
  378. <if test="fBilltype != null">#{fBilltype},</if>
  379. <if test="fBillingway != null">#{fBillingway},</if>
  380. <if test="fBsdate != null">#{fBsdate},</if>
  381. <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
  382. <if test="fStltypeid != null">#{fStltypeid},</if>
  383. <if test="fBusinessType != null">#{fBusinessType},</if>
  384. <if test="fSrcTypeId != null">#{fSrcTypeId},</if>
  385. <if test="fWarehouseid != null">#{fWarehouseid},</if>
  386. <if test="fPurchase != null">#{fPurchase},</if>
  387. <if test="tProductdate != null">#{tProductdate},</if>
  388. <if test="fLotno != null">#{fLotno},</if>
  389. <if test="fValid != null">#{fValid},</if>
  390. <if test="fUnits != null">#{fUnits},</if>
  391. <if test="fStoreEnv != null">#{fStoreEnv},</if>
  392. <if test="fIsfilles != null">#{fIsfilles},</if>
  393. <if test="fAllotWarehouseid != null">#{fAllotWarehouseid},</if>
  394. </trim>
  395. </insert>
  396. <update id="updateTWarehousebillsfees" parameterType="TWarehousebillsfees">
  397. update t_warehousebillsfees
  398. <trim prefix="SET" suffixOverrides=",">
  399. <if test="fPid != null">f_pid = #{fPid},</if>
  400. <if test="fLineno != null">f_lineno = #{fLineno},</if>
  401. <if test="fCorpid != null">f_corpid = #{fCorpid},</if>
  402. <if test="fFeeid != null">f_feeid = #{fFeeid},</if>
  403. <if test="fFeeunitid != null">f_feeUnitid = #{fFeeunitid},</if>
  404. <if test="fQty != null">f_qty = #{fQty},</if>
  405. <if test="fUnitprice != null">f_unitprice = #{fUnitprice},</if>
  406. <if test="fAmount != null">f_amount = #{fAmount},</if>
  407. <if test="fCurrency != null">f_currency = #{fCurrency},</if>
  408. <if test="fExrate != null">f_exrate = #{fExrate},</if>
  409. <if test="fTaxrate != null">f_taxrate = #{fTaxrate},</if>
  410. <if test="fDc != null">f_dc = #{fDc},</if>
  411. <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
  412. <if test="fReviewDate != null">f_review_date = #{fReviewDate},</if>
  413. <if test="fStatementNo != null">f_statement_no = #{fStatementNo},</if>
  414. <if test="fAccamount != null">f_accamount = #{fAccamount},</if>
  415. <if test="fStlamount != null">f_stlamount = #{fStlamount},</if>
  416. <if test="fAccamountDate != null">f_accamount_date = #{fAccamountDate},</if>
  417. <if test="fInvnos != null">f_invnos = #{fInvnos},</if>
  418. <if test="fInvamount != null">f_invamount = #{fInvamount},</if>
  419. <if test="fStlamountNo != null">f_stlamount_no = #{fStlamountNo},</if>
  420. <if test="fAskamount != null">f_askamount = #{fAskamount},</if>
  421. <if test="fStatus != null">f_status = #{fStatus},</if>
  422. <if test="fStlamountDate != null">f_stlamount_date = #{fStlamountDate},</if>
  423. <if test="delFlag != null">del_flag = #{delFlag},</if>
  424. <if test="createBy != null">create_by = #{createBy},</if>
  425. <if test="createTime != null">create_time = #{createTime},</if>
  426. <if test="updateBy != null">update_by = #{updateBy},</if>
  427. <if test="updateTime != null">update_time = #{updateTime},</if>
  428. <if test="remark != null">remark = #{remark},</if>
  429. <if test="srcId != null">src_id = #{srcId},</if>
  430. <if test="srcBillNo != null">src_bill_no = #{srcBillNo},</if>
  431. <if test="fMblno != null">f_mblno = #{fMblno},</if>
  432. <if test="fProductName != null">f_product_name = #{fProductName},</if>
  433. <if test="fMarks != null">f_marks = #{fMarks},</if>
  434. <if test="fChargedate != null">f_chargedate = #{fChargedate},</if>
  435. <if test="fBillingDeadline != null">f_billing_deadline = #{fBillingDeadline},</if>
  436. <if test="fInventoryDays != null">f_inventory_days = #{fInventoryDays},</if>
  437. <if test="fAmt != null">f_amt = #{fAmt},</if>
  438. <if test="fBillingDays != null">f_billing_days = #{fBillingDays},</if>
  439. <if test="fBillingQty != null">f_billing_qty = #{fBillingQty},</if>
  440. <if test="fBilltype != null">f_billtype = #{fBilltype},</if>
  441. <if test="fBillingway != null">f_billingway = #{fBillingway},</if>
  442. <if test="fBsdate != null">f_bsdate = #{fBsdate},</if>
  443. <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
  444. <if test="fStltypeid != null">f_stltypeid = #{fStltypeid},</if>
  445. <if test="fSrcTypeId != null">f_src_type_id = #{fSrcTypeId},</if>
  446. <if test="fWarehouseid != null">f_warehouseid = #{fWarehouseid},</if>
  447. <if test="fPurchase != null">f_purchase = #{fPurchase},</if>
  448. <if test="tProductdate != null">t_productdate = #{tProductdate},</if>
  449. <if test="fLotno != null">f_lotno = #{fLotno},</if>
  450. <if test="fValid != null">f_valid = #{fValid},</if>
  451. <if test="fUnits != null">f_units = #{fUnits},</if>
  452. <if test="fStoreEnv != null">f_store_env = #{fStoreEnv},</if>
  453. <if test="fIsfilles != null">f_isfilles = #{fIsfilles},</if>
  454. <if test="fAllotWarehouseid != null">f_allot_warehouseid = #{fAllotWarehouseid},</if>
  455. </trim>
  456. where f_id = #{fId}
  457. </update>
  458. <delete id="deleteTWarehousebillsfeesById" parameterType="Long">
  459. delete
  460. from t_warehousebillsfees
  461. where f_id = #{fId}
  462. </delete>
  463. <delete id="deleteByFPid" parameterType="Long">
  464. delete
  465. from t_warehousebillsfees
  466. where f_pid = #{fId}
  467. </delete>
  468. <delete id="deleteTWarehousebillsfeesByIds" parameterType="String">
  469. delete from t_warehousebillsfees where f_id in
  470. <foreach item="fId" collection="array" open="(" separator="," close=")">
  471. #{fId}
  472. </foreach>
  473. </delete>
  474. <update id="warehouseFeesFollowUpdate">
  475. update
  476. t_warehousebillsfees
  477. <trim prefix="SET" suffixOverrides=",">
  478. <if test="fettle != null">f_billstatus = #{fettle},</if>
  479. <if test="auditItem != null and fettle == 6">f_review_date = #{auditItem},</if>
  480. <if test="auditItem != null and fettle != 6">f_review_date = null,</if>
  481. </trim>
  482. where f_pid = #{fPid}
  483. </update>
  484. <update id="updateTWarehousebillsfee" parameterType="Map">
  485. update t_warehousebillsfees
  486. <trim prefix="SET" suffixOverrides=",">
  487. /*判断确认对账*/
  488. <if test="map.billType == 'DZ'">
  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 == 'DZRevoke'">
  495. f_statement_no = #{map.tFee.fBillno},
  496. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  497. f_accamount_date = #{map.tFee.fAccbilldate}
  498. </if>
  499. /*判断收付款*/
  500. <if test="map.billType == 'DC'">
  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 == 'DCRevoke'">
  507. f_stlamount_no = #{map.tFee.fBillno},
  508. f_stlamount = f_stlamount - #{map.tFeeDo.fAmt},
  509. f_stlamount_date =#{map.tFee.fAccbilldate}
  510. </if>
  511. /*判断撤销收付款*/
  512. <if test="map.billType == 'DZSF' or map.billType == 'DZFF'">
  513. f_stlamount_no = #{map.tFee.fBillno},
  514. f_stlamount = f_stlamount - #{map.tFeeDo.fAmt},
  515. f_stlamount_date =#{map.tFee.fAccbilldate}
  516. </if>
  517. /*判断开发票款*/
  518. <if test="map.billType == 'invoiceFP' or map.billType == 'XXFP' or map.billType == 'JXFP'">
  519. f_invamount = f_invamount + #{map.tFeeDo.fAmt},
  520. f_stlamount_date =#{map.tFee.fAccbilldate}
  521. </if>
  522. <if test="map.billType == 'DZinvoiceFP' or map.billType == 'DZXXFP' or map.billType == 'DZJXFP'">
  523. f_invamount = f_invamount - #{map.tFeeDo.fAmt},
  524. f_stlamount_date =#{map.tFee.fAccbilldate}
  525. </if>
  526. /*判断申请发票款*/
  527. <if test="map.billType == 'ApplyFP'">
  528. f_askamount = f_askamount + #{map.tFeeDo.fAmt},
  529. f_stlamount_date =#{map.tFee.fAccbilldate}
  530. </if>
  531. <if test="map.billType == 'DZApplyFP'">
  532. f_askamount = f_askamount - #{map.tFeeDo.fAmt},
  533. f_stlamount_date =#{map.tFee.fAccbilldate}
  534. </if>
  535. /*判断确认对账*/
  536. <if test="map.billType == 'KHDZ'">
  537. f_statement_no = #{map.tFee.fBillno},
  538. f_accamount = f_accamount + #{map.tFeeDo.fAmt},
  539. f_accamount_date = #{map.tFee.fAccbilldate}
  540. </if>
  541. /*判断撤销对账*/
  542. <if test="map.billType == 'KHDZRevoke'">
  543. f_statement_no = #{map.tFee.fBillno},
  544. f_accamount = f_accamount - #{map.tFeeDo.fAmt},
  545. f_accamount_date = #{map.tFee.fAccbilldate}
  546. </if>
  547. </trim>
  548. where f_id = #{map.tFeeDo.fSrcid}
  549. </update>
  550. <select id="selectFeesByPId" parameterType="Long" resultMap="TWarehousebillsfeesResult">
  551. SELECT
  552. tw.f_id,
  553. tw.f_pid,
  554. tw.f_lineno,
  555. tw.f_corpid,
  556. tc.f_name corpName,
  557. tw.f_feeid,
  558. tf.f_name feeName,
  559. tw.f_feeUnitid,
  560. tw.f_qty,
  561. tw.f_unitprice,
  562. tw.f_amount,
  563. tw.f_currency,
  564. tw.f_exrate,
  565. tw.f_taxrate,
  566. tw.f_dc,
  567. tw.f_billstatus,
  568. CASE
  569. WHEN tw.f_billstatus = '1' THEN
  570. '新建'
  571. WHEN tw.f_billstatus = '2' THEN
  572. '暂存'
  573. WHEN tw.f_billstatus = '3' THEN
  574. '驳回'
  575. WHEN tw.f_billstatus = '4' THEN
  576. '提交'
  577. WHEN tw.f_billstatus = '5' THEN
  578. '审批中'
  579. WHEN tw.f_billstatus = '6' THEN
  580. '审批通过'
  581. END AS fBillstatusName,
  582. tw.f_review_date,
  583. tw.f_statement_no,
  584. tw.f_accamount,
  585. tw.f_stlamount,
  586. tw.f_accamount_date,
  587. tw.f_invnos,
  588. tw.f_invamount,
  589. tw.f_stlamount_no,
  590. tw.f_askamount,
  591. tw.f_status,
  592. tw.f_stlamount_date,
  593. tw.del_flag,
  594. tw.create_by,
  595. tw.create_time,
  596. tw.update_by,
  597. tw.update_time,
  598. tw.remark,
  599. tw.src_id,
  600. tw.src_bill_no,
  601. tw.f_mblno,
  602. tw.f_product_name,
  603. tw.f_marks,
  604. tw.f_chargedate,
  605. tw.f_billing_deadline,
  606. tw.f_inventory_days,
  607. tw.f_amt,
  608. tw.f_billing_days,
  609. tw.f_billing_qty,
  610. tw.f_billtype,
  611. tw.f_billingway,
  612. tw.f_bsdate,
  613. tw.f_originalbilldate,
  614. tw.f_stltypeid,
  615. tw.f_business_type,
  616. tw.f_src_type_id
  617. FROM
  618. t_warehousebillsfees tw
  619. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  620. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  621. where tw.f_pid = #{fPid}
  622. and tw.f_billtype = 'KHDD'
  623. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  624. </select>
  625. <delete id="deleteFessByFPid" parameterType="object">
  626. delete
  627. from t_warehousebillsfees
  628. where f_pid = #{fPid}
  629. <if test="fDc != null and fDc != ''">and f_dc = #{fDc}</if>
  630. </delete>
  631. <!--网页版查询对账-->
  632. <select id="webVersionReconciliation" parameterType="TAccount" resultType="map">
  633. SELECT
  634. tb.f_billno AS fBillno,
  635. /**运单号*/
  636. tv.f_name AS vesselName,
  637. /**船名*/
  638. ty.f_no AS voyageName,
  639. /**航次*/
  640. tc.f_name AS invoice,
  641. /**收费单位*/
  642. tc.f_name AS drawee,
  643. /**受票单位*/
  644. tp.f_name AS corpName,
  645. /**货权方*/
  646. pro.dict_label AS fPaymode,
  647. /**付款方式*/
  648. te.f_name AS payment,
  649. /**费用名称*/
  650. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmtdr,
  651. /**原始金额*/
  652. ifnull( tf.f_amount, 0 ) - ifnull( tf.f_accamount, 0 ) AS fAmt,
  653. /**本次金额*/
  654. ta.f_name AS fLoadportidName,
  655. /**始发港*/
  656. tr.f_name AS fDestportidName,
  657. /**目的港*/
  658. pr.dict_label AS fServiceitems,
  659. /**运输条款*/
  660. tg.f_name AS goodName,
  661. /**货名*/
  662. tn.f_name AS transit,
  663. /**箱型*/
  664. items.f_cntrcount AS fCntrcount,
  665. /**箱量*/
  666. tb.f_shippername AS fShippername,
  667. /**发货人*/
  668. tb.f_consigneername AS fConsigneername,
  669. /**收货人*/
  670. tf.f_id AS fSrcid,
  671. tf.f_pid AS fSrcpid,
  672. tf.create_by AS createBy,
  673. tf.create_time AS createTime,
  674. tf.update_by AS updateBy,
  675. tf.update_time AS updateTime,
  676. tf.remark AS remark,
  677. tf.f_mblno AS fMblno,
  678. tf.f_corpid AS fCorpid,
  679. tf.f_feeid AS fFeeid
  680. FROM
  681. t_warehousebillsfees tf
  682. LEFT JOIN t_corps tc ON tc.f_id = tf.f_corpid
  683. LEFT JOIN t_fees te ON te.f_id = tf.f_feeid
  684. LEFT JOIN t_warehousebills tb ON tb.f_id = tf.f_pid
  685. LEFT JOIN t_vessel tv ON tv.f_id = tb.f_vslid
  686. LEFT JOIN t_voyage ty ON ty.f_id = tb.f_voyid
  687. LEFT JOIN t_address ta ON ta.f_id = tb.f_loadportid
  688. LEFT JOIN t_address tr ON tr.f_id = tb.f_destportid
  689. LEFT JOIN sys_dict_data pro ON pro.dict_value = tb.f_paymode
  690. AND pro.dict_type = 'data_settlement_type'
  691. LEFT JOIN sys_dict_data pr ON pr.dict_value = tb.f_serviceitems
  692. AND pr.dict_type = 'f_serviceitems'
  693. LEFT JOIN ( SELECT f_pid, MAX( f_goodsid ) f_goodsid FROM t_warehousebills_cntr GROUP BY f_pid ) w ON w.f_pid =
  694. tb.f_id
  695. LEFT JOIN t_goods tg ON tg.f_id = w.f_goodsid
  696. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  697. ON items.f_pid = tb.f_id
  698. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  699. twc.f_pid = tb.f_id
  700. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  701. LEFT JOIN t_corps tp ON tp.f_id = tb.f_corpid
  702. WHERE
  703. tf.f_billstatus = 6
  704. AND tf.f_dc = 'D'
  705. AND tb.f_typeid = 1
  706. and tb.f_review_date IS NOT NULL
  707. and ifnull(tf.f_amount, 0) - ifnull(tf.f_accamount, 0) > 0
  708. <if test="fLoadportid != null">and tb.f_loadportid = #{fLoadportid}</if>
  709. <if test="fDestportid != null">and tb.f_destportid = #{fDestportid}</if>
  710. <if test="fInvoceobj != null and fInvoceobj != ''">and tb.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  711. <if test="fShippername != null and fShippername != ''">and tb.f_shippername like concat('%', #{fShippername},
  712. '%')
  713. </if>
  714. <if test="fConsigneername != null and fConsigneername != ''">and tb.f_consigneername like concat('%',
  715. #{fConsigneername}, '%')
  716. </if>
  717. <if test="fMblno != null and fMblno != ''">and tb.f_mblno like concat('%', #{fMblno}, '%')</if>
  718. <if test="fBillno != null and fBillno != ''">and tb.f_billno like concat('%', #{fBillno}, '%')</if>
  719. <if test="fVslid != null">and tb.f_vslid = #{fVslid}</if>
  720. <if test="fVoyid != null">and tb.f_voyid = #{fVoyid}</if>
  721. <if test="fCorpid != null">and tf.f_corpid = #{fCorpid}</if>
  722. <if test="fPaymodeid != null">and tb.f_paymode = #{fPaymodeid}</if>
  723. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  724. and tf.create_time &gt;= #{sailTime[0]}
  725. </if>
  726. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  727. and tf.create_time &lt;= #{sailTime[1]}
  728. </if>
  729. <if test="fDocmentdate != null and fDocmentdate != ''">and tb.f_docmentdate = #{fDocmentdate}</if>
  730. <if test="createBy != null and createBy != ''">and tb.create_by = #{createBy}</if>
  731. <if test="goodName != null and goodName != ''">and tg.f_name like concat('%', #{goodName}, '%')</if>
  732. ORDER BY tf.f_id desc
  733. </select>
  734. <!--网页版查询对账明细-->
  735. <select id="webVersionDetail" parameterType="TAccount" resultType="map">
  736. SELECT
  737. tf.f_id AS fId,
  738. te.f_billno AS accountBillno,
  739. /**账单编号*/
  740. tw.f_billno AS fBillno,
  741. /**运单编号*/
  742. tv.f_name AS vesselName,
  743. /**船名*/
  744. ty.f_no AS voyageName,
  745. /**航次*/
  746. te.f_ctrlcorpid AS fCtrlcorpid,
  747. /**获权方*/
  748. tp.f_name AS corpName,
  749. /**结算单位*/
  750. ta.f_name AS fLoadportidName,
  751. /**始发港*/
  752. tr.f_name AS fDestportidName,
  753. /**目的港*/
  754. pr.dict_label AS fServiceitems,
  755. /**运输条款*/
  756. ts.f_name AS payment,
  757. /**费用名称*/
  758. tf.f_amtdr AS fAmtdr,
  759. /**原始金额*/
  760. tf.f_amt AS fAmt,
  761. /**本次金额*/
  762. tn.f_name AS transit,
  763. /**箱型*/
  764. items.f_cntrcount AS fCntrcount,
  765. /**箱量*/
  766. tf.create_by AS createBy,
  767. tf.create_time AS createTime,
  768. CASE
  769. WHEN te.f_billstatus = '1' THEN
  770. '保存'
  771. WHEN te.f_billstatus = '2' THEN
  772. '暂存'
  773. WHEN te.f_billstatus = '3' THEN
  774. '审批驳回'
  775. WHEN te.f_billstatus = '4' THEN
  776. '提交审核'
  777. WHEN te.f_billstatus = '5' THEN
  778. '审核中'
  779. WHEN te.f_billstatus = '6' THEN
  780. '审核完成'
  781. END AS fBillstatus
  782. FROM
  783. t_fee_do tf
  784. LEFT JOIN t_fee te ON te.f_id = tf.f_pid
  785. LEFT JOIN t_warehousebills tw ON tf.f_srcpid = tw.f_id
  786. LEFT JOIN t_warehousebillsfees th ON th.f_id = tf.f_srcid
  787. LEFT JOIN t_vessel tv ON tw.f_vslid = tv.f_id
  788. LEFT JOIN t_voyage ty ON ty.f_id = tw.f_voyid
  789. LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
  790. LEFT JOIN t_address tr ON tr.f_id = tw.f_destportid
  791. LEFT JOIN sys_dict_data pr ON pr.dict_value = tw.f_serviceitems
  792. AND pr.dict_type = 'f_serviceitems'
  793. LEFT JOIN t_fees ts ON ts.f_id = tf.f_feeid
  794. LEFT JOIN ( SELECT f_pid, SUM( f_cntrcount ) f_cntrcount FROM t_warehousebills_cntritems GROUP BY f_pid ) items
  795. ON items.f_pid = tw.f_id
  796. LEFT JOIN ( SELECT f_pid, MAX( f_cntrid ) f_cntrid FROM t_warehousebills_cntritems GROUP BY f_pid ) twc ON
  797. twc.f_pid = tw.f_id
  798. LEFT JOIN t_cntr tn ON tn.f_id = twc.f_cntrid
  799. LEFT JOIN t_corps tp ON tp.f_id = te.f_corpid
  800. WHERE
  801. te.f_billtype = 'KHDZ'
  802. <if test="fLoadportid != null">and tw.f_loadportid = #{fLoadportid}</if>
  803. <if test="fDestportid != null">and tw.f_destportid = #{fDestportid}</if>
  804. <if test="fInvoceobj != null and fInvoceobj != ''">and tw.f_invoceobj like concat('%', #{fInvoceobj}, '%')</if>
  805. <if test="fShippername != null and fShippername != ''">and tw.f_shippername like concat('%', #{fShippername},
  806. '%')
  807. </if>
  808. <if test="fConsigneername != null and fConsigneername != ''">and tw.f_consigneername like concat('%',
  809. #{fConsigneername}, '%')
  810. </if>
  811. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  812. <if test="fVslid != null">and tw.f_vslid = #{fVslid}</if>
  813. <if test="fId != null">and tf.f_id = #{fId}</if>
  814. <if test="fVoyid != null">and tw.f_voyid = #{fVoyid}</if>
  815. <if test="fCorpid != null">and te.f_corpid = #{fCorpid}</if>
  816. <if test="fPaymodeid != null">and tw.f_paymode = #{fPaymodeid}</if>
  817. <if test='sailTime != null and sailTime[0] != null and sailTime[0]!= ""'>
  818. and tf.create_time &gt;= #{sailTime[0]}
  819. </if>
  820. <if test='sailTime != null and sailTime[1] != null and sailTime[1]!= ""'>
  821. and tf.create_time &lt;= #{sailTime[1]}
  822. </if>
  823. <if test="fDocmentdate != null and fDocmentdate != ''">and tw.f_docmentdate = #{fDocmentdate}</if>
  824. <if test="createBy != null and createBy != ''">and te.create_by = #{createBy}</if>
  825. <if test="accountBillno != null and accountBillno != ''">and te.f_billno = #{accountBillno}</if>
  826. ORDER BY tf.f_id desc
  827. </select>
  828. <update id="anPinDeleteFeeUpdate">
  829. update
  830. t_warehousebillsfees
  831. <trim prefix="SET" suffixOverrides=",">
  832. <if test="delFlag != null">del_flag = #{delFlag},</if>
  833. <if test="updateBy != null">update_by = #{updateBy},</if>
  834. <if test="updateTime != null">update_time = #{updateTime},</if>
  835. </trim>
  836. where f_id in
  837. <foreach item="fId" collection="fIds" open="(" separator="," close=")">
  838. #{fId}
  839. </foreach>
  840. </update>
  841. <update id="anPinDeleteFeeUpdateByfPid">
  842. update
  843. t_warehousebillsfees
  844. <trim prefix="SET" suffixOverrides=",">
  845. <if test="delFlag != null">del_flag = #{delFlag},</if>
  846. <if test="updateBy != null">update_by = #{updateBy},</if>
  847. <if test="updateTime != null">update_time = #{updateTime},</if>
  848. </trim>
  849. where f_pid in
  850. <foreach item="fId" collection="fPid" open="(" separator="," close=")">
  851. #{fId}
  852. </foreach>
  853. </update>
  854. <select id="anPinTWarehousebillsfeesList" parameterType="TWarehousebillsfees"
  855. resultMap="TWarehousebillsfeesResult">
  856. select tw.f_id,
  857. tw.f_pid,
  858. tw.f_lineno,
  859. tw.f_corpid,
  860. tw.f_feeid,
  861. tf.f_name AS feeName,
  862. tf.f_currency AS fCurrencyName,
  863. tw.f_feeUnitid,
  864. sc.dict_label AS fFeeunitName,
  865. tw.f_qty,
  866. tw.f_unitprice,
  867. tw.f_amount,
  868. tw.f_currency,
  869. tw.f_exrate,
  870. tw.f_taxrate,
  871. tw.f_dc,
  872. tw.f_billstatus,
  873. CASE
  874. WHEN tw.f_billstatus = '1' THEN
  875. '保存'
  876. WHEN tw.f_billstatus = '2' THEN
  877. '暂存'
  878. WHEN tw.f_billstatus = '3' THEN
  879. '审批驳回'
  880. WHEN tw.f_billstatus = '4' THEN
  881. '提交审核'
  882. WHEN tw.f_billstatus = '5' THEN
  883. '审核中'
  884. WHEN tw.f_billstatus = '6' THEN
  885. '审核完成'
  886. END AS fBillstatusName,
  887. tw.f_review_date,
  888. tw.f_statement_no,
  889. tw.f_accamount,
  890. tw.f_stlamount,
  891. tw.f_accamount_date,
  892. tw.f_invnos,
  893. tw.f_invamount,
  894. tw.f_stlamount_no,
  895. tw.f_askamount,
  896. tw.f_status,
  897. tw.f_stlamount_date,
  898. tw.del_flag,
  899. tw.create_by,
  900. tw.create_time,
  901. tw.update_by,
  902. tw.update_time,
  903. tw.remark,
  904. tw.src_id,
  905. tw.src_bill_no,
  906. tw.f_mblno,
  907. tw.f_product_name,
  908. tw.f_marks,
  909. tw.f_chargedate,
  910. tw.f_billing_deadline,
  911. tw.f_inventory_days,
  912. tw.f_amt,
  913. tw.f_billing_days,
  914. tw.f_billing_qty,
  915. tw.f_billtype,
  916. tw.f_billingway,
  917. tw.f_bsdate,
  918. tw.f_originalbilldate,
  919. tw.f_stltypeid,
  920. sd.dict_label AS fBillingwayName,
  921. tw.f_business_type,
  922. tw.f_src_type_id,
  923. tw.f_warehouseid,
  924. th.f_warehouse_information AS fWarehouseName,
  925. tw.f_purchase,
  926. tw.t_productdate,
  927. tw.f_lotno,
  928. tw.f_valid,
  929. tw.f_units,
  930. tw.f_store_env,
  931. tw.f_isfilles,
  932. si.dict_label AS fUnitsName,
  933. st.dict_label AS fStoreEnvName,
  934. sti.dict_label AS fIsfillesName,
  935. tw.f_allot_warehouseid
  936. from t_warehousebillsfees tw
  937. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  938. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  939. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid AND sc.dict_type = 'data_unitfees'
  940. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid AND sd.dict_type = 'f_paymode'
  941. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units AND si.dict_type = 'f_floatunit'
  942. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env AND st.dict_type = 'f_StorageEnvironment'
  943. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles AND sti.dict_type = 'f_evidence'
  944. <where>
  945. <if test="fPid != null ">and tw.f_pid = #{fPid}</if>
  946. <if test="fLineno != null ">and tw.f_lineno = #{fLineno}</if>
  947. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  948. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  949. <if test="fFeeunitid != null ">and tw.f_feeUnitid = #{fFeeunitid}</if>
  950. <if test="fQty != null ">and tw.f_qty = #{fQty}</if>
  951. <if test="fUnitprice != null ">and tw.f_unitprice = #{fUnitprice}</if>
  952. <if test="fAmount != null ">and tw.f_amount = #{fAmount}</if>
  953. <if test="fCurrency != null and fCurrency != ''">and tw.f_currency = #{fCurrency}</if>
  954. <if test="fExrate != null ">and tw.f_exrate = #{fExrate}</if>
  955. <if test="fTaxrate != null ">and tw.f_taxrate = #{fTaxrate}</if>
  956. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  957. <if test="fBillstatus != null and fBillstatus != ''">and tw.f_billstatus = #{fBillstatus}</if>
  958. <if test="fReviewDate != null ">and tw.f_review_date = #{fReviewDate}</if>
  959. <if test="fStatementNo != null and fStatementNo != ''">and tw.f_statement_no = #{fStatementNo}</if>
  960. <if test="fAccamount != null ">and tw.f_accamount = #{fAccamount}</if>
  961. <if test="fStlamount != null ">and tw.f_stlamount = #{fStlamount}</if>
  962. <if test="fAccamountDate != null ">and tw.f_accamount_date = #{fAccamountDate}</if>
  963. <if test="fInvnos != null and fInvnos != ''">and tw.f_invnos = #{fInvnos}</if>
  964. <if test="fInvamount != null ">and tw.f_invamount = #{fInvamount}</if>
  965. <if test="fStlamountNo != null and fStlamountNo != ''">and tw.f_stlamount_no = #{fStlamountNo}</if>
  966. <if test="fAskamount != null ">and tw.f_askamount = #{fAskamount}</if>
  967. <if test="fStatus != null and fStatus != ''">and tw.f_status = #{fStatus}</if>
  968. <if test="delFlag != null">and tw.del_flag = #{delFlag}</if>
  969. <if test="fStlamountDate != null ">and tw.f_stlamount_date = #{fStlamountDate}</if>
  970. <if test="srcId != null ">and tw.src_id = #{srcId}</if>
  971. <if test="srcBillNo != null and srcBillNo != ''">and tw.src_bill_no = #{srcBillNo}</if>
  972. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  973. <if test="fProductName != null and fProductName != ''">and tw.f_product_name like concat('%',
  974. #{fProductName},
  975. '%')
  976. </if>
  977. <if test="fMarks != null and fMarks != ''">and tw.f_marks = #{fMarks}</if>
  978. <if test="fChargedate != null ">and tw.f_chargedate = #{fChargedate}</if>
  979. <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
  980. <if test="fInventoryDays != null ">and tw.f_inventory_days = #{fInventoryDays}</if>
  981. <if test="fAmt != null ">and tw.f_amt = #{fAmt}</if>
  982. <if test="fBillingDays != null ">and tw.f_billing_days = #{fBillingDays}</if>
  983. <if test="fBillingQty != null ">and tw.f_billing_qty = #{fBillingQty}</if>
  984. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  985. <if test="fBillingway != null ">and tw.f_billingway = #{fBillingway}</if>
  986. <if test="fBsdate != null ">and tw.f_bsdate = #{fBsdate}</if>
  987. <if test="fOriginalbilldate != null ">and tw.f_originalbilldate = #{fOriginalbilldate}</if>
  988. <if test="fStltypeid != null">and tw.f_stltypeid = #{fStltypeid},</if>
  989. <if test="fSrcTypeId != null">and tw.f_src_type_id = #{fSrcTypeId},</if>
  990. <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
  991. <if test="fPurchase != null ">and tw.f_purchase = #{fPurchase}</if>
  992. </where>
  993. </select>
  994. <!--安品出入库统计-->
  995. <select id="selectTWarehouseInorOut" parameterType="TWarehousebillsfees"
  996. resultType="com.ruoyi.anpin.WarhousrExcel">
  997. SELECT
  998. tw.f_id AS fId,
  999. th.f_warehouse_information as wareHouseName,/*仓库*/
  1000. ti.f_bsdate AS fBsdate,/*进货时间*/
  1001. tf.f_name AS feeName,/*物资名称*/
  1002. tf.f_currency AS fCurrencyName,/*物资规格*/
  1003. tw.f_qty AS fQty,/*实际数量*/
  1004. tw.f_amount AS fAmount,/*金额*/
  1005. tw.f_unitprice AS fUnitprice,/*单价*/
  1006. tc.f_name AS corpName,/*供货商*/
  1007. tc.f_manage AS fManage,/*联系人*/
  1008. tc.f_tel AS fTel,/*联系电话*/
  1009. tw.t_productdate AS tProductdate,/*生产日期*/
  1010. tw.f_lotno AS fLotno,/*批次号*/
  1011. CONCAT(tw.f_valid,si.dict_label) AS quality,/*保值期限*/
  1012. st.dict_label AS fStoreEnvName,/*储存环境中文名*/
  1013. sti.dict_label AS fIsfillesName,/*索证索票*/
  1014. std.dict_label AS fFeetype,/*物资类别*/
  1015. sr.user_name AS purchaseName,/*采购人*/
  1016. tp.f_name AS projectName,/*项目名称*/
  1017. CASE
  1018. WHEN tw.f_billtype = 'CK' THEN
  1019. '出库'
  1020. WHEN tw.f_billtype = 'DB' THEN
  1021. '调拨'
  1022. WHEN tw.f_billtype = 'RK' THEN
  1023. '入库'
  1024. END AS fBilltypeName,/*出入库类型*/
  1025. ti.f_sbu AS fSbu,/*开票公司ID*/
  1026. ts.f_name AS fSbuName,/*开票公司名称*/
  1027. sc.dict_label As feeUnitName/*计量单位中文名*/
  1028. FROM t_warehousebillsfees tw
  1029. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1030. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  1031. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid
  1032. AND sc.dict_type = 'data_unitfees'
  1033. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid
  1034. AND sd.dict_type = 'f_paymode'
  1035. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units
  1036. AND si.dict_type = 'f_floatunit'
  1037. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env
  1038. AND st.dict_type = 'f_StorageEnvironment'
  1039. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles
  1040. AND sti.dict_type = 'f_evidence'
  1041. LEFT JOIN t_warehousebills ti ON tw.f_pid = ti.f_id
  1042. LEFT JOIN t_project tp ON ti.f_goodsid = tp.f_id
  1043. LEFT JOIN t_corps tc ON ti.f_corpid = tc.f_id
  1044. LEFT JOIN t_corps ts ON ti.f_sbu = ts.f_id
  1045. LEFT JOIN sys_user sr ON sr.user_id = ti.f_purchase
  1046. LEFT JOIN sys_dict_data std ON std.dict_value = tf.f_feetype
  1047. AND std.dict_type = 'data_cost_attribute'
  1048. <where>
  1049. tw.del_flag = '0'
  1050. and ti.del_flag = '0'
  1051. <if test="fBillstatus != null and fBillstatus == 1">and tw.f_billstatus = 6</if>
  1052. <if test="fBillstatus != null and fBillstatus == 2">and tw.f_billstatus != 6</if>
  1053. <if test="fCorpid != null ">and ti.f_corpid = #{fCorpid}</if>
  1054. <if test="fGoodsid != null ">and ti.f_goodsid = #{fGoodsid}</if>
  1055. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  1056. <if test="fBilltype == null or fBilltype == ''">and tw.f_billtype in ('CK','RK')</if>
  1057. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  1058. <if test="fFeeType != null ">and tf.f_feetype = #{fFeeType}</if>
  1059. <if test="fWarehouseid != null ">and ti.f_warehouseid = #{fWarehouseid}</if>
  1060. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  1061. and ti.f_bsdate &gt;= #{cLoadDate[0]}
  1062. </if>
  1063. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  1064. and ti.f_bsdate &lt;= #{cLoadDate[1]}
  1065. </if>
  1066. </where>
  1067. ORDER BY tw.f_id DESC
  1068. </select>
  1069. <!--安品出销售出库统计-->
  1070. <select id="salesOfOutbound" parameterType="TWarehousebills"
  1071. resultType="com.ruoyi.anpin.SalesOfOutbound">
  1072. SELECT
  1073. td.fgoodsid AS fgoodsid,/*项目id*/
  1074. tp.f_name AS projectName,/*项目中文名*/
  1075. td.ffeetype AS ffeetype,/*物资类别*/
  1076. si.dict_label AS ffeetypeName /*物资类别中文名*/,
  1077. td.fname AS fname,/*物资名*/
  1078. td.fcurrency AS fcurrency,/*规格*/
  1079. td.ffeeunitid AS ffeeunitid,/*计价单位id*/
  1080. sc.dict_label AS ffeeunitidName,/*计价单位中文名*/
  1081. td.fqty AS fqty,/*数量*/
  1082. td.famount AS famount,/*金额*/
  1083. tr.f_name AS fsbuName,/*开票公司*/
  1084. round(td.price,2) AS price/*单价*/
  1085. <if test="groupDate != null and groupDate == 0">
  1086. ,td.fBsdate AS fBsdate/*入库日期*/
  1087. </if>
  1088. FROM
  1089. (
  1090. SELECT
  1091. tc.fgoodsid,
  1092. tc.ffeetype,
  1093. tc.fname,
  1094. tc.fcurrency,
  1095. tc.ffeeunitid,
  1096. tc.fBsdate,
  1097. tc.fSbu,
  1098. IFNULL( SUM( tc.fqty ), 0 ) fqty,
  1099. IFNULL( SUM( tc.famount ), 0 ) famount,
  1100. IFNULL( SUM( tc.famount )/ SUM( tc.fqty ), 0 ) price
  1101. FROM
  1102. (
  1103. SELECT
  1104. tb.f_goodsid fgoodsid,
  1105. /*项目*/
  1106. tf.f_feetype ffeetype,
  1107. /*物资类别*/
  1108. tf.f_name fname,
  1109. /*物资名*/
  1110. tf.f_currency fcurrency,
  1111. /*规格*/
  1112. tw.f_feeunitid ffeeunitid,
  1113. /*计价单位*/
  1114. tw.f_qty fqty,
  1115. /*实际数量*/
  1116. tw.f_amount famount, /*金额*/
  1117. tb.f_sbu fSbu,/*开票公司*/
  1118. tw.f_bsdate fBsdate/*出库日期*/
  1119. FROM
  1120. t_warehousebillsfees tw
  1121. LEFT JOIN t_warehousebills tb ON tw.f_pid = tb.f_id
  1122. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1123. WHERE
  1124. tw.del_flag = '0'
  1125. AND tb.del_flag = '0'
  1126. AND tw.f_billtype = 'XS'
  1127. <if test="fBillstatus != null">and tw.f_billstatus = #{fBillstatus}</if>
  1128. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  1129. <if test="fGoodsid != null and fGoodsid != ''">and tb.f_goodsid = #{fGoodsid}</if>
  1130. <if test="fFeeTypeList != null and fFeeTypeList != '[]'">and tf.f_feetype in
  1131. <foreach item="fId" collection="fFeeTypeList" open="(" separator="," close=")">
  1132. #{fId}
  1133. </foreach>
  1134. </if>
  1135. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  1136. and tb.f_bsdate &gt;= #{cLoadDate[0]}
  1137. </if>
  1138. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  1139. and tb.f_bsdate &lt;= #{cLoadDate[1]}
  1140. </if>
  1141. <if test="fSbu != null ">and tb.f_sbu = #{fSbu}</if>
  1142. ) tc
  1143. GROUP BY
  1144. tc.fgoodsid,
  1145. tc.ffeetype,
  1146. tc.fname,
  1147. tc.fcurrency,
  1148. tc.ffeeunitid,
  1149. tc.fSbu
  1150. <if test="groupDate != null and groupDate == 0">
  1151. ,tc.fBsdate
  1152. </if>
  1153. ) td
  1154. LEFT JOIN t_project tp ON td.fgoodsid = tp.f_id
  1155. LEFT JOIN t_corps tr ON tr.f_id = td.fSbu
  1156. LEFT JOIN sys_dict_data sc ON sc.dict_value = td.ffeeunitid AND sc.dict_type = 'data_unitfees'
  1157. LEFT JOIN sys_dict_data si ON si.dict_value = td.ffeetype AND si.dict_type = 'data_cost_attribute'
  1158. ORDER BY
  1159. <if test="groupDate != null and groupDate == 0">
  1160. td.fBsdate DESC,/*入库日期*/
  1161. </if>
  1162. td.fgoodsid DESC
  1163. </select>
  1164. <!--安品利润统计-->
  1165. <select id="salectAnpinProfit" parameterType="TWarehousebills"
  1166. resultType="com.ruoyi.anpin.ProfitExcel">
  1167. SELECT
  1168. DISTINCT
  1169. temp.years AS annual,
  1170. temp.months AS abbreviated,
  1171. tp.f_name AS projectName,
  1172. temp.market AS market,
  1173. temp.purchase AS purchase,
  1174. temp.profit AS profit,
  1175. ROUND(ifnull((temp.profit/temp.market)* 100,0),2) AS profitMargin
  1176. FROM
  1177. (
  1178. SELECT
  1179. xs.years AS years,
  1180. xs.months AS months,
  1181. xs.fGoodid AS fGoodid,
  1182. IFNULL( xs.pay, 0 ) AS market,
  1183. IFNULL( sq.collect, 0 ) AS purchase,
  1184. CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
  1185. WHEN xs.pay IS NULL AND sq.collect IS NOT NULL THEN 0 -sq.collect
  1186. WHEN xs.pay IS NOT NULL AND sq.collect IS NULL THEN xs.pay- 0
  1187. END AS profit
  1188. FROM
  1189. (
  1190. SELECT
  1191. tw.f_goodsid AS fGoodid,
  1192. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1193. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1194. IFNULL( SUM( tf.f_amount ), 0 ) AS pay
  1195. FROM
  1196. t_warehousebillsfees tf
  1197. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1198. WHERE
  1199. tf.f_billtype = 'XS'
  1200. AND tf.del_flag = '0'
  1201. AND tw.del_flag = '0'
  1202. <if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
  1203. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1204. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1205. <if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
  1206. <if test="monthList != null and monthList[0] != null and monthList[0]!= ''">
  1207. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1208. </if>
  1209. <if test="monthList != null and monthList[1] != null and monthList[1]!= ''">
  1210. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1211. </if>
  1212. GROUP BY
  1213. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1214. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1215. tw.f_goodsid
  1216. ORDER BY
  1217. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1218. DATE_FORMAT( tf.f_bsdate, '%m' )
  1219. ) xs
  1220. LEFT JOIN (
  1221. SELECT
  1222. tw.f_goodsid AS fGoodid,
  1223. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1224. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1225. IFNULL( SUM( tf.f_amount ), 0 ) AS collect
  1226. FROM
  1227. t_warehousebillsfees tf
  1228. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1229. WHERE
  1230. tf.f_billtype = 'CK'
  1231. AND tf.del_flag = '0'
  1232. AND tw.del_flag = '0'
  1233. <if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
  1234. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1235. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1236. <if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
  1237. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1238. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1239. </if>
  1240. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1241. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1242. </if>
  1243. GROUP BY
  1244. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1245. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1246. tw.f_goodsid
  1247. ORDER BY
  1248. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1249. DATE_FORMAT( tf.f_bsdate, '%m' )
  1250. ) sq ON sq.fGoodid = xs.fGoodid
  1251. AND sq.years = xs.years
  1252. AND sq.months = xs.months
  1253. UNION ALL
  1254. SELECT
  1255. sq.years AS years,
  1256. sq.months AS months,
  1257. sq.fGoodid AS fGoodid,
  1258. IFNULL( xs.pay, 0 ) AS market,
  1259. IFNULL( sq.collect, 0 ) AS purchase,
  1260. CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
  1261. WHEN xs.pay IS NULL AND sq.collect IS NOT NULL THEN 0 -sq.collect
  1262. WHEN xs.pay IS NOT NULL AND sq.collect IS NULL THEN xs.pay- 0
  1263. END AS profit
  1264. FROM
  1265. (
  1266. SELECT
  1267. tw.f_goodsid AS fGoodid,
  1268. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1269. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1270. IFNULL( SUM( tf.f_amount ), 0 ) AS collect
  1271. FROM
  1272. t_warehousebillsfees tf
  1273. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1274. WHERE
  1275. tf.f_billtype = 'CK'
  1276. AND tf.del_flag = '0'
  1277. AND tw.del_flag = '0'
  1278. <if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
  1279. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1280. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1281. <if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
  1282. <if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
  1283. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1284. </if>
  1285. <if test='monthList != null and monthList[1] != null and monthList[1]!= ""'>
  1286. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1287. </if>
  1288. GROUP BY
  1289. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1290. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1291. tw.f_goodsid
  1292. ORDER BY
  1293. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1294. DATE_FORMAT( tf.f_bsdate, '%m' )
  1295. ) sq
  1296. LEFT JOIN (
  1297. SELECT
  1298. tw.f_goodsid AS fGoodid,
  1299. DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
  1300. DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
  1301. IFNULL( SUM( tf.f_amount ), 0 ) AS pay
  1302. FROM
  1303. t_warehousebillsfees tf
  1304. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1305. WHERE
  1306. tf.f_billtype = 'XS'
  1307. AND tf.del_flag = '0'
  1308. AND tw.del_flag = '0'
  1309. <if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
  1310. <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
  1311. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1312. <if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
  1313. <if test='monthList != null and monthList[0] != null and monthList[0]!= "" '>
  1314. and DATE_FORMAT(tf.f_bsdate,'%m') &gt;= #{monthList[0]}
  1315. </if>
  1316. <if test='monthList != null and monthList[1] != null and monthList[1]!= "" '>
  1317. and DATE_FORMAT(tf.f_bsdate,'%m') &lt;= #{monthList[1]}
  1318. </if>
  1319. GROUP BY
  1320. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1321. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1322. tw.f_goodsid
  1323. ORDER BY
  1324. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1325. DATE_FORMAT( tf.f_bsdate, '%m' )
  1326. ) xs ON sq.fGoodid = xs.fGoodid
  1327. AND sq.years = xs.years
  1328. AND sq.months = xs.months
  1329. ) AS temp
  1330. LEFT JOIN t_project tp ON tp.f_id = temp.fGoodid
  1331. ORDER BY temp.years,temp.months,CONVERT(tp.f_name USING GBK)
  1332. </select>
  1333. <!--查询入库日期所在年月是否结账-->
  1334. <select id="selectTMonthEndingClosingList" parameterType="object"
  1335. resultType="com.ruoyi.anpin.TMonthEndingClosingExcel">
  1336. select f_id, f_year, f_month, f_start, f_enf, f_status from t_month_ending_closing
  1337. <where>
  1338. <if test="fYear != null and fYear != ''">and f_year = #{fYear}</if>
  1339. <if test="fMonth != null and fMonth != ''">and f_month = #{fMonth}</if>
  1340. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  1341. </where>
  1342. ORDER BY f_year,f_month
  1343. </select>
  1344. <!--安品库存总账-->
  1345. <select id="selectInventoryLedger" parameterType="TWarehousebills"
  1346. resultType="com.ruoyi.anpin.InventoryLedgerExcel">
  1347. SELECT
  1348. DATE_FORMAT( MAX(tf.f_bsdate), '%Y' ) AS fyears,
  1349. /*年*/
  1350. /* DATE_FORMAT( MAX(tf.f_bsdate), '%m' ) AS fmonth,*/
  1351. /*月*/
  1352. tf.f_corpid AS fCorpid,
  1353. /*供应商*/
  1354. tc.f_name AS fCorpName,
  1355. /*供应商名称*/
  1356. tf.f_feeid AS fFeeid,
  1357. /*货物id*/
  1358. te.f_name AS fFName,
  1359. /*货物名称*/
  1360. te.f_currency AS fCurrency,
  1361. /*规格*/
  1362. te.f_feetype AS feetype,
  1363. /*类别*/
  1364. si.dict_label AS feetypeName,
  1365. /*类别名称*/
  1366. tf.f_feeUnitid AS fFeeUnitid,
  1367. /*计价单位*/
  1368. sc.dict_label AS feeUnitName,
  1369. /*计价单位名称*/
  1370. tf.f_warehouseid AS fWarehouseid,
  1371. /*库区*/
  1372. th.f_warehouse_information AS fWarehouseName,
  1373. /*库区中文名*/
  1374. ifnull(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) + IFNULL( de.fQty, 0 ) - IFNULL( df.fQty, 0 ) - sum(
  1375. CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ),0) AS fBeginQty,
  1376. /*期初数量*/
  1377. ROUND(
  1378. IFNULL((
  1379. sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END )+ IFNULL( de.fAmount, 0 )- IFNULL( df.fAmount, 0 ) - sum(
  1380. CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ))/(
  1381. sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END ) + IFNULL( de.fQty, 0 ) - IFNULL( df.fQty, 0 ) - sum( CASE
  1382. WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_qty ELSE 0 END )),
  1383. 0
  1384. ),
  1385. 2
  1386. ) AS fBeginUnitprice,
  1387. /*期初单价*/
  1388. IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END )+ IFNULL( de.fAmount, 0 )- IFNULL( df.fAmount, 0 ) -
  1389. sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;#{timeInterval[0]} THEN tf.f_amount ELSE 0 END ),0) AS
  1390. fBeginAmount,
  1391. /*期初金额*/
  1392. IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1393. THEN tf.f_qty ELSE 0 END ),0) AS rQty,
  1394. /*入库数量*/
  1395. IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1396. THEN tf.f_qty ELSE 0 END ),0) AS cQty,
  1397. /*出库数量*/
  1398. IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1399. THEN tf.f_amount ELSE 0 END ),0) AS rfAmount,
  1400. /*入库金额*/
  1401. IFNULL(sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&gt;=#{timeInterval[0]} AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1402. THEN tf.f_amount ELSE 0 END ),0) AS cfAmount,
  1403. /*出库金额*/
  1404. IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) + IFNULL( dg.fQty, 0 ) - IFNULL( dh.fQty, 0 ) -
  1405. sum( CASE WHEN tf.f_billtype = 'CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END ),0) AS
  1406. fAfterQty,
  1407. /*结余数量*/
  1408. ROUND(
  1409. IFNULL((
  1410. sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) + IFNULL( dg.fAmount, 0 )- IFNULL( dh.fAmount, 0 ) - sum(
  1411. CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_amount ELSE 0 END ))/(
  1412. sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_qty ELSE 0 END ) + IFNULL( dg.fQty, 0 ) - IFNULL( dh.fQty, 0 ) - sum( CASE
  1413. WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;=#{timeInterval[1]} THEN tf.f_qty ELSE 0 END )),
  1414. 0
  1415. ),
  1416. 2
  1417. ) AS fAfterUnitprice,
  1418. /*结余单价*/
  1419. IFNULL(sum( CASE WHEN tf.f_billtype='RK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ) + IFNULL( dg.fAmount, 0 )- IFNULL( dh.fAmount, 0 )-
  1420. sum( CASE WHEN tf.f_billtype='CK' AND tf.f_bsdate&lt;= #{timeInterval[1]} THEN tf.f_amount ELSE 0 END ),0) AS
  1421. fAfterAmount, /*结余金额*/
  1422. IFNULL( dr.fQty, 0 ) AS foldQty,
  1423. /*调入数量*/
  1424. IFNULL( dr.fUnitprice, 0 ) AS foldUnitprice,
  1425. /*调入单价*/
  1426. IFNULL( dr.fAmount, 0 ) AS foldAmount,
  1427. /*调入金额*/
  1428. IFNULL( dc.fQty, 0 ) AS calloutQty,
  1429. /*调出数量*/
  1430. IFNULL( dc.fUnitprice, 0 ) AS calloutUnitprice,
  1431. /*调出单价*/
  1432. IFNULL( dc.fAmount, 0 ) AS calloutAmount /*调出金额*/
  1433. FROM
  1434. t_warehousebillsfees tf
  1435. LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
  1436. LEFT JOIN t_warehouse th ON tf.f_warehouseid = th.f_id
  1437. LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
  1438. LEFT JOIN t_corps tc ON tf.f_corpid = tc.f_id
  1439. LEFT JOIN sys_dict_data sc ON sc.dict_value = tf.f_feeUnitid
  1440. AND sc.dict_type = 'data_unitfees'
  1441. LEFT JOIN sys_dict_data si ON si.dict_value = te.f_feetype
  1442. AND si.dict_type = 'data_cost_attribute'
  1443. LEFT JOIN (
  1444. SELECT
  1445. tf.f_corpid fCorpid,
  1446. tf.f_feeid fFeeid,
  1447. tf.f_feeUnitid fFeeUnitid,
  1448. IFNULL(SUM(tf.f_qty),0) fQty,
  1449. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1450. IFNULL(SUM(tf.f_amount),0) fAmount,
  1451. tf.f_allot_warehouseid fAllotWarehouseid
  1452. FROM
  1453. t_warehousebillsfees tf
  1454. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1455. WHERE
  1456. tf.f_billtype = 'DB'
  1457. AND tf.del_flag = '0'
  1458. AND tw.f_billstatus = 6
  1459. AND tf.f_bsdate&gt;=#{timeInterval[0]}
  1460. AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1461. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_allot_warehouseid
  1462. ) dr ON tf.f_corpid = dr.fCorpid
  1463. AND tf.f_feeid = dr.fFeeid
  1464. AND tf.f_feeUnitid = dr.fFeeUnitid
  1465. AND tf.f_warehouseid = dr.fAllotWarehouseid
  1466. LEFT JOIN (
  1467. SELECT
  1468. tf.f_corpid fCorpid,
  1469. tf.f_feeid fFeeid,
  1470. tf.f_feeUnitid fFeeUnitid,
  1471. IFNULL(SUM(tf.f_qty),0) fQty,
  1472. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1473. IFNULL(SUM(tf.f_amount),0) fAmount,
  1474. tf.f_warehouseid fwarehouseid
  1475. FROM
  1476. t_warehousebillsfees tf
  1477. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1478. WHERE
  1479. tf.f_billtype = 'DB'
  1480. AND tf.del_flag = '0'
  1481. AND tw.f_billstatus = 6
  1482. AND tf.f_bsdate&gt;=#{timeInterval[0]}
  1483. AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1484. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_warehouseid
  1485. ) dc ON tf.f_corpid = dc.fCorpid
  1486. AND tf.f_feeid = dc.fFeeid
  1487. AND tf.f_feeUnitid = dc.fFeeUnitid
  1488. AND tf.f_warehouseid = dc.fwarehouseid
  1489. LEFT JOIN (
  1490. SELECT
  1491. tf.f_corpid fCorpid,
  1492. tf.f_feeid fFeeid,
  1493. tf.f_feeUnitid fFeeUnitid,
  1494. IFNULL(SUM(tf.f_qty),0) fQty,
  1495. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1496. IFNULL(SUM(tf.f_amount),0) fAmount,
  1497. tf.f_allot_warehouseid fAllotWarehouseid
  1498. FROM
  1499. t_warehousebillsfees tf
  1500. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1501. WHERE
  1502. tf.f_billtype = 'DB'
  1503. AND tf.del_flag = '0'
  1504. AND tw.f_billstatus = 6
  1505. AND tf.f_bsdate&lt;=#{timeInterval[0]}
  1506. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_allot_warehouseid
  1507. ) de ON tf.f_corpid = de.fCorpid
  1508. AND tf.f_feeid = de.fFeeid
  1509. AND tf.f_feeUnitid = de.fFeeUnitid
  1510. AND tf.f_warehouseid = de.fAllotWarehouseid
  1511. LEFT JOIN (
  1512. SELECT
  1513. tf.f_corpid fCorpid,
  1514. tf.f_feeid fFeeid,
  1515. tf.f_feeUnitid fFeeUnitid,
  1516. IFNULL(SUM(tf.f_qty),0) fQty,
  1517. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1518. IFNULL(SUM(tf.f_amount),0) fAmount,
  1519. tf.f_warehouseid fwarehouseid
  1520. FROM
  1521. t_warehousebillsfees tf
  1522. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1523. WHERE
  1524. tf.f_billtype = 'DB'
  1525. AND tf.del_flag = '0'
  1526. AND tw.f_billstatus = 6
  1527. AND tf.f_bsdate&lt;=#{timeInterval[0]}
  1528. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_warehouseid
  1529. ) df ON tf.f_corpid = df.fCorpid
  1530. AND tf.f_feeid = df.fFeeid
  1531. AND tf.f_feeUnitid = df.fFeeUnitid
  1532. AND tf.f_warehouseid = df.fwarehouseid
  1533. LEFT JOIN (
  1534. SELECT
  1535. tf.f_corpid fCorpid,
  1536. tf.f_feeid fFeeid,
  1537. tf.f_feeUnitid fFeeUnitid,
  1538. IFNULL(SUM(tf.f_qty),0) fQty,
  1539. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1540. IFNULL(SUM(tf.f_amount),0) fAmount,
  1541. tf.f_allot_warehouseid fAllotWarehouseid
  1542. FROM
  1543. t_warehousebillsfees tf
  1544. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1545. WHERE
  1546. tf.f_billtype = 'DB'
  1547. AND tf.del_flag = '0'
  1548. AND tw.f_billstatus = 6
  1549. AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1550. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_allot_warehouseid
  1551. ) dg ON tf.f_corpid = dg.fCorpid
  1552. AND tf.f_feeid = dg.fFeeid
  1553. AND tf.f_feeUnitid = dg.fFeeUnitid
  1554. AND tf.f_warehouseid = dg.fAllotWarehouseid
  1555. LEFT JOIN (
  1556. SELECT
  1557. tf.f_corpid fCorpid,
  1558. tf.f_feeid fFeeid,
  1559. tf.f_feeUnitid fFeeUnitid,
  1560. IFNULL(SUM(tf.f_qty),0) fQty,
  1561. IFNULL(SUM(tf.f_unitprice),0) fUnitprice,
  1562. IFNULL(SUM(tf.f_amount),0) fAmount,
  1563. tf.f_warehouseid fwarehouseid
  1564. FROM
  1565. t_warehousebillsfees tf
  1566. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1567. WHERE
  1568. tf.f_billtype = 'DB'
  1569. AND tf.del_flag = '0'
  1570. AND tw.f_billstatus = 6
  1571. AND tf.f_bsdate&lt;=#{timeInterval[0]}
  1572. GROUP BY tf.f_corpid,tf.f_feeid,tf.f_feeUnitid,tf.f_warehouseid
  1573. ) dh ON tf.f_corpid = dh.fCorpid
  1574. AND tf.f_feeid = dh.fFeeid
  1575. AND tf.f_feeUnitid = dh.fFeeUnitid
  1576. AND tf.f_warehouseid = dh.fwarehouseid
  1577. WHERE
  1578. tf.f_billtype IN ( 'RK', 'CK' )
  1579. AND tf.del_flag = '0'
  1580. AND tw.del_flag = '0'
  1581. AND tf.f_bsdate&lt;=#{timeInterval[1]}
  1582. <if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
  1583. <if test="fBillstatus != null">and tf.f_billstatus = #{fBillstatus}</if>
  1584. <if test="fBillstatus == null">and tf.f_billstatus = 6</if>
  1585. <if test="fCorpid != null ">and tf.f_corpid = #{fCorpid}</if>
  1586. <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
  1587. <if test="feeName != null and feeName != ''">and tf.f_feeid = #{feeName}</if>
  1588. GROUP BY
  1589. /*DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1590. DATE_FORMAT( tf.f_bsdate, '%m' ),*/
  1591. tf.f_corpid,
  1592. tf.f_feeid,
  1593. te.f_currency,
  1594. tf.f_feeUnitid,
  1595. tf.f_warehouseid,
  1596. te.f_feetype
  1597. ORDER BY
  1598. DATE_FORMAT( tf.f_bsdate, '%Y' ),
  1599. DATE_FORMAT( tf.f_bsdate, '%m' ),
  1600. CONVERT (
  1601. te.f_name USING GBK)
  1602. </select>
  1603. <!--安品查询费用信息-->
  1604. <select id="selectFeeMessage" parameterType="TWarehousebills" resultType="com.ruoyi.anpin.AnPingOrderMessage">
  1605. SELECT
  1606. tc.f_name AS fCorpName,
  1607. ROUND(temp.LastYear,2) AS LastYear,
  1608. ROUND(temp.January,2) AS January,
  1609. ROUND(temp.February,2) AS February,
  1610. ROUND(temp.March,2) AS March,
  1611. ROUND(temp.April,2) AS April,
  1612. ROUND(temp.May,2) AS May,
  1613. ROUND(temp.June,2) AS June,
  1614. ROUND(temp.July,2) AS July,
  1615. ROUND(temp.August,2) AS August,
  1616. ROUND(temp.September,2) AS September,
  1617. ROUND(temp.October,2) AS October,
  1618. ROUND(temp.November,2) AS November,
  1619. ROUND(temp.December,2) AS December,
  1620. ROUND(SUM(temp.LastYear+temp.January+temp.February+temp.March+temp.April+temp.May+temp.June+
  1621. temp.July+temp.August+temp.September+temp.October+temp.November+temp.December),2) AS total
  1622. FROM
  1623. ( SELECT
  1624. tw.f_corpid AS fCorpid,
  1625. CASE
  1626. YEAR ( tw.f_bsdate )
  1627. WHEN #{annum} THEN
  1628. sum( tf.f_amount ) ELSE 0
  1629. END AS LastYear,
  1630. CASE
  1631. MONTH ( tw.f_bsdate )
  1632. WHEN '1' THEN
  1633. sum( tf.f_amount ) ELSE 0
  1634. END AS January,
  1635. CASE
  1636. MONTH ( tw.f_bsdate )
  1637. WHEN '2' THEN
  1638. sum( tf.f_amount ) ELSE 0
  1639. END AS February,
  1640. CASE
  1641. MONTH ( tw.f_bsdate )
  1642. WHEN '3' THEN
  1643. sum( tf.f_amount ) ELSE 0
  1644. END AS March,
  1645. CASE
  1646. MONTH ( tw.f_bsdate )
  1647. WHEN '4' THEN
  1648. sum( tf.f_amount ) ELSE 0
  1649. END AS April,
  1650. CASE
  1651. MONTH ( tw.f_bsdate )
  1652. WHEN '5' THEN
  1653. sum( tf.f_amount ) ELSE 0
  1654. END AS May,
  1655. CASE
  1656. MONTH ( tw.f_bsdate )
  1657. WHEN '6' THEN
  1658. sum( tf.f_amount ) ELSE 0
  1659. END AS June,
  1660. CASE
  1661. MONTH ( tw.f_bsdate )
  1662. WHEN '7' THEN
  1663. sum( tf.f_amount ) ELSE 0
  1664. END AS July,
  1665. CASE
  1666. MONTH ( tw.f_bsdate )
  1667. WHEN '8' THEN
  1668. sum( tf.f_amount ) ELSE 0
  1669. END AS August,
  1670. CASE
  1671. MONTH ( tw.f_bsdate )
  1672. WHEN '9' THEN
  1673. sum( tf.f_amount ) ELSE 0
  1674. END AS September,
  1675. CASE
  1676. MONTH ( tw.f_bsdate )
  1677. WHEN '10' THEN
  1678. sum( tf.f_amount ) ELSE 0
  1679. END AS October,
  1680. CASE
  1681. MONTH ( tw.f_bsdate )
  1682. WHEN '11' THEN
  1683. sum( tf.f_amount ) ELSE 0
  1684. END AS November,
  1685. CASE
  1686. MONTH ( tw.f_bsdate )
  1687. WHEN '12' THEN
  1688. sum( tf.f_amount ) ELSE 0
  1689. END AS December
  1690. FROM
  1691. t_warehousebillsfees tf
  1692. LEFT JOIN t_warehousebills tw ON tw.f_id = tf.f_pid
  1693. where
  1694. DATE_FORMAT( tw.f_bsdate, '%Y' ) = #{tw.annual}
  1695. <if test="tw.fCorpid != null ">and tw.f_corpid = #{tw.fCorpid}</if>
  1696. <if test="tw.fBillstatus != null">and tw.f_billstatus = #{tw.fBillstatus}</if>
  1697. <if test="tw.fBilltype != null and tw.fBilltype != ''">and tw.f_billtype = #{tw.fBilltype}</if>
  1698. GROUP BY
  1699. tw.f_corpid ) AS temp
  1700. LEFT JOIN t_corps tc ON tc.f_id = temp.fCorpid
  1701. GROUP BY temp.fCorpid
  1702. </select>
  1703. <select id="selectAmount" parameterType="long" resultType="java.math.BigDecimal">
  1704. SELECT
  1705. IFNULL(SUM(tw.f_amount),0.00) famount
  1706. FROM
  1707. t_warehousebillsfees tw
  1708. WHERE f_pid = #{fPid}
  1709. AND tw.del_flag = '0'
  1710. </select>
  1711. <!--安品采购申请统计-->
  1712. <select id="purchaseRequest" parameterType="TWarehousebills"
  1713. resultType="com.ruoyi.anpin.PurchaseRequestExcel">
  1714. SELECT
  1715. td.fCorpid AS fCorpid,/*供应商id*/
  1716. tp.f_name AS fCorpidName,/*供应商中文名*/
  1717. td.ffeetype AS ffeetype,/*物资类别*/
  1718. si.dict_label AS ffeetypeName /*物资类别中文名*/,
  1719. td.fname AS fname,/*物资名*/
  1720. td.fcurrency AS fcurrency,/*规格*/
  1721. td.ffeeunitid AS ffeeunitid,/*计价单位id*/
  1722. sc.dict_label AS ffeeunitidName,/*计价单位中文名*/
  1723. td.fqty AS fqty,/*数量*/
  1724. td.famount AS famount,/*金额*/
  1725. tr.f_name AS fsbuName,/*开票公司*/
  1726. round(td.price,2) AS price/*单价*/
  1727. <if test="groupDate != null and groupDate == 0">
  1728. ,td.fBsdate AS fBsdate/*入库日期*/
  1729. </if>
  1730. FROM
  1731. (
  1732. SELECT
  1733. tc.fCorpid,
  1734. tc.ffeetype,
  1735. tc.fname,
  1736. tc.fcurrency,
  1737. tc.ffeeunitid,
  1738. tc.fBsdate,
  1739. tc.fSbu,
  1740. IFNULL( SUM( tc.fqty ), 0 ) fqty,
  1741. IFNULL( SUM( tc.famount ), 0 ) famount,
  1742. IFNULL( SUM( tc.famount )/ SUM( tc.fqty ), 0 ) price
  1743. FROM
  1744. (
  1745. SELECT
  1746. tb.f_corpid fCorpid,
  1747. /*供应商*/
  1748. tf.f_feetype ffeetype,
  1749. /*物资类别*/
  1750. tf.f_name fname,
  1751. /*物资名*/
  1752. tf.f_currency fcurrency,
  1753. /*规格*/
  1754. tw.f_feeunitid ffeeunitid,
  1755. /*计价单位*/
  1756. tw.f_qty fqty,
  1757. /*实际数量*/
  1758. tw.f_amount famount, /*金额*/
  1759. tb.f_sbu fSbu,/*开票公司*/
  1760. tw.f_bsdate fBsdate/*出库日期*/
  1761. FROM
  1762. t_warehousebillsfees tw
  1763. LEFT JOIN t_warehousebills tb ON tw.f_pid = tb.f_id
  1764. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1765. WHERE
  1766. tw.del_flag = '0'
  1767. AND tb.del_flag = '0'
  1768. AND tw.f_billtype = 'SQ'
  1769. <if test="fCorpid != null ">and tb.f_corpid = #{fCorpid}</if>
  1770. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  1771. <if test="fBillstatus != null">and tw.f_billstatus = #{fBillstatus}</if>
  1772. <if test="fGoodsid != null and fGoodsid != ''">and tb.f_goodsid = #{fGoodsid}</if>
  1773. <if test="fFeeTypeList != null and fFeeTypeList != '[]'">and tf.f_feetype in
  1774. <foreach item="fId" collection="fFeeTypeList" open="(" separator="," close=")">
  1775. #{fId}
  1776. </foreach>
  1777. </if>
  1778. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  1779. and tb.f_bsdate &gt;= #{cLoadDate[0]}
  1780. </if>
  1781. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  1782. and tb.f_bsdate &lt;= #{cLoadDate[1]}
  1783. </if>
  1784. <if test="fSbu != null ">and tb.f_sbu = #{fSbu}</if>
  1785. ) tc
  1786. GROUP BY
  1787. tc.fCorpid,
  1788. tc.ffeetype,
  1789. tc.fname,
  1790. tc.fcurrency,
  1791. tc.ffeeunitid,
  1792. tc.fSbu
  1793. <if test="groupDate != null and groupDate == 0">
  1794. ,tc.fBsdate
  1795. </if>
  1796. ) td
  1797. LEFT JOIN t_corps tp ON td.fCorpid = tp.f_id
  1798. LEFT JOIN t_corps tr ON tr.f_id = td.fSbu
  1799. LEFT JOIN sys_dict_data sc ON sc.dict_value = td.ffeeunitid AND sc.dict_type = 'data_unitfees'
  1800. LEFT JOIN sys_dict_data si ON si.dict_value = td.ffeetype AND si.dict_type = 'data_cost_attribute'
  1801. ORDER BY
  1802. <if test="groupDate != null and groupDate == 0">
  1803. td.fBsdate DESC,/*入库日期*/
  1804. </if>
  1805. td.fCorpid DESC
  1806. </select>
  1807. <select id="anPinAllotList" parameterType="TWarehousebillsfees"
  1808. resultMap="TWarehousebillsfeesResult">
  1809. select tw.f_id,
  1810. tw.f_pid,
  1811. tw.f_lineno,
  1812. tw.f_corpid,
  1813. tw.f_feeid,
  1814. tf.f_name AS feeName,
  1815. tf.f_currency AS fCurrencyName,
  1816. tw.f_feeUnitid,
  1817. sc.dict_label AS fFeeunitName,
  1818. tw.f_qty,
  1819. tw.f_unitprice,
  1820. tw.f_amount,
  1821. tw.f_currency,
  1822. tw.f_exrate,
  1823. tw.f_taxrate,
  1824. tw.f_dc,
  1825. tw.f_billstatus,
  1826. CASE
  1827. WHEN tw.f_billstatus = '1' THEN
  1828. '保存'
  1829. WHEN tw.f_billstatus = '2' THEN
  1830. '暂存'
  1831. WHEN tw.f_billstatus = '3' THEN
  1832. '审批驳回'
  1833. WHEN tw.f_billstatus = '4' THEN
  1834. '提交审核'
  1835. WHEN tw.f_billstatus = '5' THEN
  1836. '审核中'
  1837. WHEN tw.f_billstatus = '6' THEN
  1838. '审核完成'
  1839. END AS fBillstatusName,
  1840. tw.f_review_date,
  1841. tw.f_statement_no,
  1842. tw.f_accamount,
  1843. tw.f_stlamount,
  1844. tw.f_accamount_date,
  1845. tw.f_invnos,
  1846. tw.f_invamount,
  1847. tw.f_stlamount_no,
  1848. tw.f_askamount,
  1849. tw.f_status,
  1850. tw.f_stlamount_date,
  1851. tw.del_flag,
  1852. tw.create_by,
  1853. tw.create_time,
  1854. tw.update_by,
  1855. tw.update_time,
  1856. tw.remark,
  1857. tw.src_id,
  1858. tw.src_bill_no,
  1859. tw.f_mblno,
  1860. tw.f_product_name,
  1861. tw.f_marks,
  1862. tw.f_chargedate,
  1863. tw.f_billing_deadline,
  1864. tw.f_inventory_days,
  1865. tw.f_amt,
  1866. tw.f_billing_days,
  1867. tw.f_billing_qty,
  1868. tw.f_billtype,
  1869. tw.f_billingway,
  1870. tw.f_bsdate,
  1871. tw.f_originalbilldate,
  1872. IFNULL(tw.f_stltypeid,0) AS f_stltypeid,
  1873. sd.dict_label AS fBillingwayName,
  1874. tw.f_business_type,
  1875. tw.f_src_type_id,
  1876. tw.f_warehouseid,
  1877. th.f_warehouse_information AS fWarehouseName,
  1878. tw.f_purchase,
  1879. tw.t_productdate,
  1880. tw.f_lotno,
  1881. tw.f_valid,
  1882. tw.f_units,
  1883. tw.f_store_env,
  1884. tw.f_isfilles,
  1885. si.dict_label AS fUnitsName,
  1886. st.dict_label AS fStoreEnvName,
  1887. sti.dict_label AS fIsfillesName,
  1888. tw.f_allot_warehouseid,
  1889. te.f_warehouse_information AS fAllotWarehouseName,
  1890. IFNULL(tl.f_grossweightblc,0) AS fGrossweightblc,
  1891. IFNULL(tl.f_volumnblc,0) AS fVolumnblc,
  1892. IFNULL(tl.f_netweightblc,0) AS fNetweightblc,
  1893. tc.f_name AS corpName
  1894. from t_warehousebillsfees tw
  1895. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1896. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  1897. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  1898. LEFT JOIN t_warehouse te ON tw.f_allot_warehouseid = te.f_id
  1899. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid AND sc.dict_type = 'data_unitfees'
  1900. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid AND sd.dict_type = 'f_paymode'
  1901. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units AND si.dict_type = 'f_floatunit'
  1902. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env AND st.dict_type = 'f_StorageEnvironment'
  1903. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles AND sti.dict_type = 'f_evidence'
  1904. LEFT JOIN t_warehousebills ti ON ti.f_id = tw.f_pid
  1905. LEFT JOIN t_whgenleg tl ON tl.f_corpid = tw.f_corpid AND tl.f_goodsid = tw.f_feeid
  1906. AND tl.f_billingway = tw.f_feeUnitid AND tl.f_warehouse_locationid = tw.f_warehouseid
  1907. <where>
  1908. <if test="fPid != null ">and tw.f_pid = #{fPid}</if>
  1909. <if test="fLineno != null ">and tw.f_lineno = #{fLineno}</if>
  1910. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  1911. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  1912. <if test="fFeeunitid != null ">and tw.f_feeUnitid = #{fFeeunitid}</if>
  1913. <if test="fQty != null ">and tw.f_qty = #{fQty}</if>
  1914. <if test="fUnitprice != null ">and tw.f_unitprice = #{fUnitprice}</if>
  1915. <if test="fAmount != null ">and tw.f_amount = #{fAmount}</if>
  1916. <if test="fCurrency != null and fCurrency != ''">and tw.f_currency = #{fCurrency}</if>
  1917. <if test="fExrate != null ">and tw.f_exrate = #{fExrate}</if>
  1918. <if test="fTaxrate != null ">and tw.f_taxrate = #{fTaxrate}</if>
  1919. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  1920. <if test="fBillstatus != null and fBillstatus != ''">and tw.f_billstatus = #{fBillstatus}</if>
  1921. <if test="fReviewDate != null ">and tw.f_review_date = #{fReviewDate}</if>
  1922. <if test="fStatementNo != null and fStatementNo != ''">and tw.f_statement_no = #{fStatementNo}</if>
  1923. <if test="fAccamount != null ">and tw.f_accamount = #{fAccamount}</if>
  1924. <if test="fStlamount != null ">and tw.f_stlamount = #{fStlamount}</if>
  1925. <if test="fAccamountDate != null ">and tw.f_accamount_date = #{fAccamountDate}</if>
  1926. <if test="fInvnos != null and fInvnos != ''">and tw.f_invnos = #{fInvnos}</if>
  1927. <if test="fInvamount != null ">and tw.f_invamount = #{fInvamount}</if>
  1928. <if test="fStlamountNo != null and fStlamountNo != ''">and tw.f_stlamount_no = #{fStlamountNo}</if>
  1929. <if test="fAskamount != null ">and tw.f_askamount = #{fAskamount}</if>
  1930. <if test="fStatus != null and fStatus != ''">and tw.f_status = #{fStatus}</if>
  1931. <if test="delFlag != null">and tw.del_flag = #{delFlag}</if>
  1932. <if test="fStlamountDate != null ">and tw.f_stlamount_date = #{fStlamountDate}</if>
  1933. <if test="srcId != null ">and tw.src_id = #{srcId}</if>
  1934. <if test="srcBillNo != null and srcBillNo != ''">and tw.src_bill_no = #{srcBillNo}</if>
  1935. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  1936. <if test="fProductName != null and fProductName != ''">and tw.f_product_name like concat('%',
  1937. #{fProductName},
  1938. '%')
  1939. </if>
  1940. <if test="fMarks != null and fMarks != ''">and tw.f_marks = #{fMarks}</if>
  1941. <if test="fChargedate != null ">and tw.f_chargedate = #{fChargedate}</if>
  1942. <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
  1943. <if test="fInventoryDays != null ">and tw.f_inventory_days = #{fInventoryDays}</if>
  1944. <if test="fAmt != null ">and tw.f_amt = #{fAmt}</if>
  1945. <if test="fBillingDays != null ">and tw.f_billing_days = #{fBillingDays}</if>
  1946. <if test="fBillingQty != null ">and tw.f_billing_qty = #{fBillingQty}</if>
  1947. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  1948. <if test="fBillingway != null ">and tw.f_billingway = #{fBillingway}</if>
  1949. <if test="fBsdate != null ">and tw.f_bsdate = #{fBsdate}</if>
  1950. <if test="fOriginalbilldate != null ">and tw.f_originalbilldate = #{fOriginalbilldate}</if>
  1951. <if test="fStltypeid != null">and tw.f_stltypeid = #{fStltypeid},</if>
  1952. <if test="fSrcTypeId != null">and tw.f_src_type_id = #{fSrcTypeId},</if>
  1953. <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
  1954. <if test="fPurchase != null ">and tw.f_purchase = #{fPurchase}</if>
  1955. </where>
  1956. ORDER BY tw.f_id
  1957. </select>
  1958. <!--安品调入统计-->
  1959. <select id="selectTWarehouseFold" parameterType="TWarehousebillsfees"
  1960. resultType="com.ruoyi.anpin.WarhousrExcel">
  1961. SELECT tw.f_id AS fId,
  1962. th.f_warehouse_information as wareHouseName,/*仓库*/
  1963. ti.f_bsdate AS fBsdate,/*进货时间*/
  1964. tf.f_name AS feeName,/*物资名称*/
  1965. tf.f_currency AS fCurrencyName,/*物资规格*/
  1966. tw.f_qty AS fQty,/*实际数量*/
  1967. tw.f_amount AS fAmount,/*金额*/
  1968. tw.f_unitprice AS fUnitprice,/*单价*/
  1969. tc.f_name AS corpName,/*供货商*/
  1970. tc.f_manage AS fManage,/*联系人*/
  1971. tc.f_tel AS fTel,/*联系电话*/
  1972. tw.t_productdate AS tProductdate,/*生产日期*/
  1973. tw.f_lotno AS fLotno,/*批次号*/
  1974. CONCAT(tw.f_valid,si.dict_label) AS quality,/*保值期限*/
  1975. st.dict_label AS fStoreEnvName,/*储存环境中文名*/
  1976. sti.dict_label AS fIsfillesName,/*索证索票*/
  1977. std.dict_label AS fFeetype,/*物资类别*/
  1978. sr.user_name AS purchaseName,/*采购人*/
  1979. tp.f_name AS projectName,/*项目名称*/
  1980. CASE
  1981. WHEN tw.f_billtype = 'CK' THEN
  1982. '出库'
  1983. WHEN tw.f_billtype = 'DB' THEN
  1984. '调拨'
  1985. WHEN tw.f_billtype = 'RK' THEN
  1986. '入库'
  1987. END AS fBilltypeName,/*出入库类型*/
  1988. ti.f_sbu AS fSbu,/*开票公司ID*/
  1989. ts.f_name AS fSbuName,/*开票公司名称*/
  1990. sc.dict_label As feeUnitName/*计量单位中文名*/
  1991. FROM t_warehousebillsfees tw
  1992. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  1993. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  1994. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid
  1995. AND sc.dict_type = 'data_unitfees'
  1996. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid
  1997. AND sd.dict_type = 'f_paymode'
  1998. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units
  1999. AND si.dict_type = 'f_floatunit'
  2000. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env
  2001. AND st.dict_type = 'f_StorageEnvironment'
  2002. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles
  2003. AND sti.dict_type = 'f_evidence'
  2004. LEFT JOIN t_warehousebills ti ON tw.f_pid = ti.f_id
  2005. LEFT JOIN t_project tp ON ti.f_project = tp.f_id
  2006. LEFT JOIN t_corps tc ON ti.f_corpid = tc.f_id
  2007. LEFT JOIN t_corps ts ON ti.f_sbu = ts.f_id
  2008. LEFT JOIN sys_user sr ON sr.user_id = ti.f_purchase
  2009. LEFT JOIN sys_dict_data std ON std.dict_value = tf.f_feetype
  2010. AND std.dict_type = 'data_cost_attribute'
  2011. <where>
  2012. tw.del_flag = '0'
  2013. and ti.del_flag = '0'
  2014. and tw.f_billtype = 'DB'
  2015. <if test="fBillstatus != null and fBillstatus == 1">and tw.f_billstatus = 6</if>
  2016. <if test="fBillstatus != null and fBillstatus == 2">and tw.f_billstatus != 6</if>
  2017. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  2018. <if test="fGoodsid != null ">and ti.f_goodsid = #{fGoodsid}</if>
  2019. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  2020. <if test="fFeeType != null ">and tf.f_feetype = #{fFeeType}</if>
  2021. <if test="fWarehouseid != null ">and ti.f_warehouseid = #{fWarehouseid}</if>
  2022. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  2023. and ti.f_bsdate &gt;= #{cLoadDate[0]}
  2024. </if>
  2025. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  2026. and ti.f_bsdate &lt;= #{cLoadDate[1]}
  2027. </if>
  2028. </where>
  2029. ORDER BY tw.f_id DESC
  2030. </select>
  2031. <!--安品调出统计-->
  2032. <select id="selectTWarehouseCallout" parameterType="TWarehousebillsfees"
  2033. resultType="com.ruoyi.anpin.WarhousrExcel">
  2034. SELECT tw.f_id AS fId,
  2035. th.f_warehouse_information as wareHouseName,/*仓库*/
  2036. ti.f_bsdate AS fBsdate,/*进货时间*/
  2037. tf.f_name AS feeName,/*物资名称*/
  2038. tf.f_currency AS fCurrencyName,/*物资规格*/
  2039. tw.f_qty AS fQty,/*实际数量*/
  2040. tw.f_amount AS fAmount,/*金额*/
  2041. tw.f_unitprice AS fUnitprice,/*单价*/
  2042. tc.f_name AS corpName,/*供货商*/
  2043. tc.f_manage AS fManage,/*联系人*/
  2044. tc.f_tel AS fTel,/*联系电话*/
  2045. tw.t_productdate AS tProductdate,/*生产日期*/
  2046. tw.f_lotno AS fLotno,/*批次号*/
  2047. CONCAT(tw.f_valid,si.dict_label) AS quality,/*保值期限*/
  2048. st.dict_label AS fStoreEnvName,/*储存环境中文名*/
  2049. sti.dict_label AS fIsfillesName,/*索证索票*/
  2050. std.dict_label AS fFeetype,/*物资类别*/
  2051. sr.user_name AS purchaseName,/*采购人*/
  2052. tp.f_name AS projectName,/*项目名称*/
  2053. CASE
  2054. WHEN tw.f_billtype = 'CK' THEN
  2055. '出库'
  2056. WHEN tw.f_billtype = 'DB' THEN
  2057. '调拨'
  2058. WHEN tw.f_billtype = 'RK' THEN
  2059. '入库'
  2060. END AS fBilltypeName,/*出入库类型*/
  2061. ti.f_sbu AS fSbu,/*开票公司ID*/
  2062. ts.f_name AS fSbuName,/*开票公司名称*/
  2063. sc.dict_label As feeUnitName/*计量单位中文名*/
  2064. FROM t_warehousebillsfees tw
  2065. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  2066. LEFT JOIN t_warehouse th ON tw.f_allot_warehouseid = th.f_id
  2067. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid
  2068. AND sc.dict_type = 'data_unitfees'
  2069. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid
  2070. AND sd.dict_type = 'f_paymode'
  2071. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units
  2072. AND si.dict_type = 'f_floatunit'
  2073. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env
  2074. AND st.dict_type = 'f_StorageEnvironment'
  2075. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles
  2076. AND sti.dict_type = 'f_evidence'
  2077. LEFT JOIN t_warehousebills ti ON tw.f_pid = ti.f_id
  2078. LEFT JOIN t_project tp ON ti.f_goodsid = tp.f_id
  2079. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  2080. LEFT JOIN t_corps ts ON ti.f_sbu = ts.f_id
  2081. LEFT JOIN sys_user sr ON sr.user_id = ti.f_purchase
  2082. LEFT JOIN sys_dict_data std ON std.dict_value = tf.f_feetype
  2083. AND std.dict_type = 'data_cost_attribute'
  2084. <where>
  2085. tw.del_flag = '0'
  2086. and ti.del_flag = '0'
  2087. and tw.f_billtype = 'DB'
  2088. <if test="fBillstatus != null and fBillstatus == 1">and tw.f_billstatus = 6</if>
  2089. <if test="fBillstatus != null and fBillstatus == 2">and tw.f_billstatus != 6</if>
  2090. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  2091. <if test="fGoodsid != null ">and ti.f_goodsid = #{fGoodsid}</if>
  2092. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  2093. <if test="fFeeType != null ">and tf.f_feetype = #{fFeeType}</if>
  2094. <if test="fWarehouseid != null ">and ti.f_warehouseid = #{fWarehouseid}</if>
  2095. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  2096. and ti.f_bsdate &gt;= #{cLoadDate[0]}
  2097. </if>
  2098. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  2099. and ti.f_bsdate &lt;= #{cLoadDate[1]}
  2100. </if>
  2101. </where>
  2102. ORDER BY tw.f_id DESC
  2103. </select>
  2104. <select id="anPinExcePort" parameterType="TWarehousebillsfees"
  2105. resultType="com.ruoyi.anpin.AnPinExcePort">
  2106. select tw.f_id,
  2107. tw.f_pid,
  2108. tw.f_lineno,
  2109. tw.f_corpid,
  2110. tw.f_feeid,
  2111. tf.f_name AS feeName,
  2112. tf.f_currency AS fCurrencyName,
  2113. tw.f_feeUnitid,
  2114. sc.dict_label AS fFeeunitName,
  2115. tw.f_qty AS fQty,
  2116. tw.f_unitprice AS fUnitprice,
  2117. tw.f_amount AS fAmount,
  2118. tw.f_currency,
  2119. tw.f_exrate,
  2120. tw.f_taxrate,
  2121. tw.f_dc,
  2122. tw.f_billstatus,
  2123. CASE
  2124. WHEN tw.f_billstatus = '1' THEN
  2125. '保存'
  2126. WHEN tw.f_billstatus = '2' THEN
  2127. '暂存'
  2128. WHEN tw.f_billstatus = '3' THEN
  2129. '审批驳回'
  2130. WHEN tw.f_billstatus = '4' THEN
  2131. '提交审核'
  2132. WHEN tw.f_billstatus = '5' THEN
  2133. '审核中'
  2134. WHEN tw.f_billstatus = '6' THEN
  2135. '审核完成'
  2136. END AS fBillstatusName,
  2137. tw.f_review_date,
  2138. tw.f_statement_no,
  2139. tw.f_accamount,
  2140. tw.f_stlamount,
  2141. tw.f_accamount_date,
  2142. tw.f_invnos,
  2143. tw.f_invamount,
  2144. tw.f_stlamount_no,
  2145. tw.f_askamount,
  2146. tw.f_status,
  2147. tw.f_stlamount_date,
  2148. tw.del_flag,
  2149. tw.create_by,
  2150. tw.create_time,
  2151. tw.update_by,
  2152. tw.update_time,
  2153. tw.remark,
  2154. tw.src_id,
  2155. tw.src_bill_no,
  2156. tw.f_mblno,
  2157. tw.f_product_name,
  2158. tw.f_marks,
  2159. tw.f_chargedate,
  2160. tw.f_billing_deadline,
  2161. tw.f_inventory_days,
  2162. tw.f_amt,
  2163. tw.f_billing_days,
  2164. tw.f_billing_qty,
  2165. tw.f_billtype,
  2166. tw.f_billingway,
  2167. tw.f_bsdate,
  2168. tw.f_originalbilldate,
  2169. tw.f_stltypeid,
  2170. sd.dict_label AS fBillingwayName,
  2171. tw.f_business_type,
  2172. tw.f_src_type_id,
  2173. tw.f_warehouseid,
  2174. th.f_warehouse_information AS fWarehouseName,
  2175. tw.f_purchase,
  2176. tw.t_productdate,
  2177. tw.f_lotno,
  2178. tw.f_valid,
  2179. tw.f_units,
  2180. tw.f_store_env,
  2181. tw.f_isfilles,
  2182. si.dict_label AS fUnitsName,
  2183. st.dict_label AS fStoreEnvName,
  2184. sti.dict_label AS fIsfillesName,
  2185. tw.f_allot_warehouseid,
  2186. te.f_warehouse_information AS fAllotWarehouseName,
  2187. IFNULL(tl.f_grossweightblc,0) AS fGrossweightblc,
  2188. IFNULL(tl.f_volumnblc,0) AS fVolumnblc,
  2189. IFNULL(tl.f_netweightblc,0) AS fNetweightblc,
  2190. tc.f_name AS corpName
  2191. from t_warehousebillsfees tw
  2192. LEFT JOIN t_fees tf ON tw.f_feeid = tf.f_id
  2193. LEFT JOIN t_corps tc ON tw.f_corpid = tc.f_id
  2194. LEFT JOIN t_warehouse th ON tw.f_warehouseid = th.f_id
  2195. LEFT JOIN t_warehouse te ON tw.f_allot_warehouseid = te.f_id
  2196. LEFT JOIN sys_dict_data sc ON sc.dict_value = tw.f_feeUnitid AND sc.dict_type = 'data_unitfees'
  2197. LEFT JOIN sys_dict_data sd ON sd.dict_value = tw.f_stltypeid AND sd.dict_type = 'f_paymode'
  2198. LEFT JOIN sys_dict_data si ON si.dict_value = tw.f_units AND si.dict_type = 'f_floatunit'
  2199. LEFT JOIN sys_dict_data st ON st.dict_value = tw.f_store_env AND st.dict_type = 'f_StorageEnvironment'
  2200. LEFT JOIN sys_dict_data sti ON sti.dict_value = tw.f_isfilles AND sti.dict_type = 'f_evidence'
  2201. LEFT JOIN t_warehousebills ti ON ti.f_id = tw.f_pid
  2202. LEFT JOIN t_whgenleg tl ON tl.f_corpid = tw.f_corpid AND tl.f_goodsid = tw.f_feeid
  2203. AND tl.f_billingway = tw.f_feeUnitid AND tl.f_warehouse_locationid = tw.f_warehouseid
  2204. <where>
  2205. tw.del_flag = '0'
  2206. <if test="fPid != null ">and tw.f_pid = #{fPid}</if>
  2207. <if test="fLineno != null ">and tw.f_lineno = #{fLineno}</if>
  2208. <if test="fCorpid != null ">and tw.f_corpid = #{fCorpid}</if>
  2209. <if test="fFeeid != null ">and tw.f_feeid = #{fFeeid}</if>
  2210. <if test="fFeeunitid != null ">and tw.f_feeUnitid = #{fFeeunitid}</if>
  2211. <if test="fQty != null ">and tw.f_qty = #{fQty}</if>
  2212. <if test="fUnitprice != null ">and tw.f_unitprice = #{fUnitprice}</if>
  2213. <if test="fAmount != null ">and tw.f_amount = #{fAmount}</if>
  2214. <if test="fCurrency != null and fCurrency != ''">and tw.f_currency = #{fCurrency}</if>
  2215. <if test="fExrate != null ">and tw.f_exrate = #{fExrate}</if>
  2216. <if test="fTaxrate != null ">and tw.f_taxrate = #{fTaxrate}</if>
  2217. <if test="fDc != null and fDc != ''">and tw.f_dc = #{fDc}</if>
  2218. <if test="fBillstatus != null and fBillstatus != ''">and tw.f_billstatus = #{fBillstatus}</if>
  2219. <if test="fReviewDate != null ">and tw.f_review_date = #{fReviewDate}</if>
  2220. <if test="fStatementNo != null and fStatementNo != ''">and tw.f_statement_no = #{fStatementNo}</if>
  2221. <if test="fAccamount != null ">and tw.f_accamount = #{fAccamount}</if>
  2222. <if test="fStlamount != null ">and tw.f_stlamount = #{fStlamount}</if>
  2223. <if test="fAccamountDate != null ">and tw.f_accamount_date = #{fAccamountDate}</if>
  2224. <if test="fInvnos != null and fInvnos != ''">and tw.f_invnos = #{fInvnos}</if>
  2225. <if test="fInvamount != null ">and tw.f_invamount = #{fInvamount}</if>
  2226. <if test="fStlamountNo != null and fStlamountNo != ''">and tw.f_stlamount_no = #{fStlamountNo}</if>
  2227. <if test="fAskamount != null ">and tw.f_askamount = #{fAskamount}</if>
  2228. <if test="fStatus != null and fStatus != ''">and tw.f_status = #{fStatus}</if>
  2229. <if test="delFlag != null">and tw.del_flag = #{delFlag}</if>
  2230. <if test="fStlamountDate != null ">and tw.f_stlamount_date = #{fStlamountDate}</if>
  2231. <if test="srcId != null ">and tw.src_id = #{srcId}</if>
  2232. <if test="srcBillNo != null and srcBillNo != ''">and tw.src_bill_no = #{srcBillNo}</if>
  2233. <if test="fMblno != null and fMblno != ''">and tw.f_mblno = #{fMblno}</if>
  2234. <if test="fProductName != null and fProductName != ''">and tw.f_product_name like concat('%',
  2235. #{fProductName},
  2236. '%')
  2237. </if>
  2238. <if test="fMarks != null and fMarks != ''">and tw.f_marks = #{fMarks}</if>
  2239. <if test="fChargedate != null ">and tw.f_chargedate = #{fChargedate}</if>
  2240. <if test="fBillingDeadline != null ">and tw.f_billing_deadline = #{fBillingDeadline}</if>
  2241. <if test="fInventoryDays != null ">and tw.f_inventory_days = #{fInventoryDays}</if>
  2242. <if test="fAmt != null ">and tw.f_amt = #{fAmt}</if>
  2243. <if test="fBillingDays != null ">and tw.f_billing_days = #{fBillingDays}</if>
  2244. <if test="fBillingQty != null ">and tw.f_billing_qty = #{fBillingQty}</if>
  2245. <if test="fBilltype != null and fBilltype != ''">and tw.f_billtype = #{fBilltype}</if>
  2246. <if test="fBillingway != null ">and tw.f_billingway = #{fBillingway}</if>
  2247. <if test="fBsdate != null ">and tw.f_bsdate = #{fBsdate}</if>
  2248. <if test="fOriginalbilldate != null ">and tw.f_originalbilldate = #{fOriginalbilldate}</if>
  2249. <if test="fStltypeid != null">and tw.f_stltypeid = #{fStltypeid},</if>
  2250. <if test="fSrcTypeId != null">and tw.f_src_type_id = #{fSrcTypeId},</if>
  2251. <if test="fWarehouseid != null ">and tw.f_warehouseid = #{fWarehouseid}</if>
  2252. <if test="fPurchase != null ">and tw.f_purchase = #{fPurchase}</if>
  2253. </where>
  2254. </select>
  2255. </mapper>