ExpenseAccountMapper.xml 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.ExpenseAccountMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.ExpenseAccount">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="prid" jdbcType="INTEGER" property="prid" />
  7. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  8. <result column="aid" jdbcType="VARCHAR" property="aid" />
  9. <result column="aname" jdbcType="VARCHAR" property="aname" />
  10. <result column="type" jdbcType="INTEGER" property="type" />
  11. <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
  12. <result column="status" jdbcType="INTEGER" property="status" />
  13. <result column="process_status" jdbcType="INTEGER" property="processStatus" />
  14. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  15. <result column="attachment_url" jdbcType="VARCHAR" property="attachmentUrl" />
  16. <result column="apply_dep" jdbcType="VARCHAR" property="applyDep" />
  17. <result column="pay_dep" jdbcType="VARCHAR" property="payDep" />
  18. <result column="eaaid" jdbcType="INTEGER" property="eaaid" />
  19. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  20. <result column="district_name" jdbcType="VARCHAR" property="districtName" />
  21. <result column="user_names" jdbcType="VARCHAR" property="userNames" />
  22. <result column="release_start" jdbcType="TIMESTAMP" property="releaseStart" />
  23. <result column="release_end" jdbcType="TIMESTAMP" property="releaseEnd" />
  24. <result column="duration" jdbcType="DOUBLE" property="duration" />
  25. <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
  26. <result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount" />
  27. <result column="debit_id" jdbcType="INTEGER" property="debitId" />
  28. <result column="target_type" jdbcType="INTEGER" property="targetType" />
  29. <result column="liquidation_status" jdbcType="INTEGER" property="liquidationStatus" />
  30. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  31. <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
  32. <result column="expense_main" jdbcType="INTEGER" property="expenseMain" />
  33. <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
  34. <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
  35. <result column="secondary_type_other" jdbcType="VARCHAR" property="secondaryTypeOther" />
  36. </resultMap>
  37. <sql id="Base_Column_List">
  38. id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
  39. attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
  40. release_start, release_end, duration, examine_name, settlement_amount, debit_id,
  41. target_type, liquidation_status, remarks, check_no, expense_main, real_amount, secondary_type,
  42. secondary_type_other
  43. </sql>
  44. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  45. select
  46. <include refid="Base_Column_List" />
  47. from expense_account
  48. where id = #{id,jdbcType=INTEGER}
  49. </select>
  50. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  51. delete from expense_account
  52. where id = #{id,jdbcType=INTEGER}
  53. </delete>
  54. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  55. insert into expense_account (prid, order_no, aid,
  56. aname, `type`, type_other,
  57. `status`, process_status, total_amount,
  58. attachment_url, apply_dep, pay_dep,
  59. eaaid, create_time, district_name,
  60. user_names, release_start, release_end,
  61. duration, examine_name, settlement_amount,
  62. debit_id, target_type, liquidation_status,
  63. remarks, check_no, expense_main,
  64. real_amount, secondary_type, secondary_type_other
  65. )
  66. values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
  67. #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
  68. #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
  69. #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
  70. #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
  71. #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
  72. #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
  73. #{debitId,jdbcType=INTEGER}, #{targetType,jdbcType=INTEGER}, #{liquidationStatus,jdbcType=INTEGER},
  74. #{remarks,jdbcType=VARCHAR}, #{checkNo,jdbcType=VARCHAR}, #{expenseMain,jdbcType=INTEGER},
  75. #{realAmount,jdbcType=DECIMAL}, #{secondaryType,jdbcType=INTEGER}, #{secondaryTypeOther,jdbcType=VARCHAR}
  76. )
  77. </insert>
  78. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  79. insert into expense_account
  80. <trim prefix="(" suffix=")" suffixOverrides=",">
  81. <if test="prid != null">
  82. prid,
  83. </if>
  84. <if test="orderNo != null">
  85. order_no,
  86. </if>
  87. <if test="aid != null">
  88. aid,
  89. </if>
  90. <if test="aname != null">
  91. aname,
  92. </if>
  93. <if test="type != null">
  94. `type`,
  95. </if>
  96. <if test="typeOther != null">
  97. type_other,
  98. </if>
  99. <if test="status != null">
  100. `status`,
  101. </if>
  102. <if test="processStatus != null">
  103. process_status,
  104. </if>
  105. <if test="totalAmount != null">
  106. total_amount,
  107. </if>
  108. <if test="attachmentUrl != null">
  109. attachment_url,
  110. </if>
  111. <if test="applyDep != null">
  112. apply_dep,
  113. </if>
  114. <if test="payDep != null">
  115. pay_dep,
  116. </if>
  117. <if test="eaaid != null">
  118. eaaid,
  119. </if>
  120. <if test="createTime != null">
  121. create_time,
  122. </if>
  123. <if test="districtName != null">
  124. district_name,
  125. </if>
  126. <if test="userNames != null">
  127. user_names,
  128. </if>
  129. <if test="releaseStart != null">
  130. release_start,
  131. </if>
  132. <if test="releaseEnd != null">
  133. release_end,
  134. </if>
  135. <if test="duration != null">
  136. duration,
  137. </if>
  138. <if test="examineName != null">
  139. examine_name,
  140. </if>
  141. <if test="settlementAmount != null">
  142. settlement_amount,
  143. </if>
  144. <if test="debitId != null">
  145. debit_id,
  146. </if>
  147. <if test="targetType != null">
  148. target_type,
  149. </if>
  150. <if test="liquidationStatus != null">
  151. liquidation_status,
  152. </if>
  153. <if test="remarks != null">
  154. remarks,
  155. </if>
  156. <if test="checkNo != null">
  157. check_no,
  158. </if>
  159. <if test="expenseMain != null">
  160. expense_main,
  161. </if>
  162. <if test="realAmount != null">
  163. real_amount,
  164. </if>
  165. <if test="secondaryType != null">
  166. secondary_type,
  167. </if>
  168. <if test="secondaryTypeOther != null">
  169. secondary_type_other,
  170. </if>
  171. </trim>
  172. <trim prefix="values (" suffix=")" suffixOverrides=",">
  173. <if test="prid != null">
  174. #{prid,jdbcType=INTEGER},
  175. </if>
  176. <if test="orderNo != null">
  177. #{orderNo,jdbcType=VARCHAR},
  178. </if>
  179. <if test="aid != null">
  180. #{aid,jdbcType=VARCHAR},
  181. </if>
  182. <if test="aname != null">
  183. #{aname,jdbcType=VARCHAR},
  184. </if>
  185. <if test="type != null">
  186. #{type,jdbcType=INTEGER},
  187. </if>
  188. <if test="typeOther != null">
  189. #{typeOther,jdbcType=VARCHAR},
  190. </if>
  191. <if test="status != null">
  192. #{status,jdbcType=INTEGER},
  193. </if>
  194. <if test="processStatus != null">
  195. #{processStatus,jdbcType=INTEGER},
  196. </if>
  197. <if test="totalAmount != null">
  198. #{totalAmount,jdbcType=DECIMAL},
  199. </if>
  200. <if test="attachmentUrl != null">
  201. #{attachmentUrl,jdbcType=VARCHAR},
  202. </if>
  203. <if test="applyDep != null">
  204. #{applyDep,jdbcType=VARCHAR},
  205. </if>
  206. <if test="payDep != null">
  207. #{payDep,jdbcType=VARCHAR},
  208. </if>
  209. <if test="eaaid != null">
  210. #{eaaid,jdbcType=INTEGER},
  211. </if>
  212. <if test="createTime != null">
  213. #{createTime,jdbcType=TIMESTAMP},
  214. </if>
  215. <if test="districtName != null">
  216. #{districtName,jdbcType=VARCHAR},
  217. </if>
  218. <if test="userNames != null">
  219. #{userNames,jdbcType=VARCHAR},
  220. </if>
  221. <if test="releaseStart != null">
  222. #{releaseStart,jdbcType=TIMESTAMP},
  223. </if>
  224. <if test="releaseEnd != null">
  225. #{releaseEnd,jdbcType=TIMESTAMP},
  226. </if>
  227. <if test="duration != null">
  228. #{duration,jdbcType=DOUBLE},
  229. </if>
  230. <if test="examineName != null">
  231. #{examineName,jdbcType=VARCHAR},
  232. </if>
  233. <if test="settlementAmount != null">
  234. #{settlementAmount,jdbcType=DECIMAL},
  235. </if>
  236. <if test="debitId != null">
  237. #{debitId,jdbcType=INTEGER},
  238. </if>
  239. <if test="targetType != null">
  240. #{targetType,jdbcType=INTEGER},
  241. </if>
  242. <if test="liquidationStatus != null">
  243. #{liquidationStatus,jdbcType=INTEGER},
  244. </if>
  245. <if test="remarks != null">
  246. #{remarks,jdbcType=VARCHAR},
  247. </if>
  248. <if test="checkNo != null">
  249. #{checkNo,jdbcType=VARCHAR},
  250. </if>
  251. <if test="expenseMain != null">
  252. #{expenseMain,jdbcType=INTEGER},
  253. </if>
  254. <if test="realAmount != null">
  255. #{realAmount,jdbcType=DECIMAL},
  256. </if>
  257. <if test="secondaryType != null">
  258. #{secondaryType,jdbcType=INTEGER},
  259. </if>
  260. <if test="secondaryTypeOther != null">
  261. #{secondaryTypeOther,jdbcType=VARCHAR},
  262. </if>
  263. </trim>
  264. </insert>
  265. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccount">
  266. update expense_account
  267. <set>
  268. <if test="prid != null">
  269. prid = #{prid,jdbcType=INTEGER},
  270. </if>
  271. <if test="orderNo != null">
  272. order_no = #{orderNo,jdbcType=VARCHAR},
  273. </if>
  274. <if test="aid != null">
  275. aid = #{aid,jdbcType=VARCHAR},
  276. </if>
  277. <if test="aname != null">
  278. aname = #{aname,jdbcType=VARCHAR},
  279. </if>
  280. <if test="type != null">
  281. `type` = #{type,jdbcType=INTEGER},
  282. </if>
  283. <if test="typeOther != null">
  284. type_other = #{typeOther,jdbcType=VARCHAR},
  285. </if>
  286. <if test="status != null">
  287. `status` = #{status,jdbcType=INTEGER},
  288. </if>
  289. <if test="processStatus != null">
  290. process_status = #{processStatus,jdbcType=INTEGER},
  291. </if>
  292. <if test="totalAmount != null">
  293. total_amount = #{totalAmount,jdbcType=DECIMAL},
  294. </if>
  295. <if test="attachmentUrl != null">
  296. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  297. </if>
  298. <if test="applyDep != null">
  299. apply_dep = #{applyDep,jdbcType=VARCHAR},
  300. </if>
  301. <if test="payDep != null">
  302. pay_dep = #{payDep,jdbcType=VARCHAR},
  303. </if>
  304. <if test="eaaid != null">
  305. eaaid = #{eaaid,jdbcType=INTEGER},
  306. </if>
  307. <if test="createTime != null">
  308. create_time = #{createTime,jdbcType=TIMESTAMP},
  309. </if>
  310. <if test="districtName != null">
  311. district_name = #{districtName,jdbcType=VARCHAR},
  312. </if>
  313. <if test="userNames != null">
  314. user_names = #{userNames,jdbcType=VARCHAR},
  315. </if>
  316. <if test="releaseStart != null">
  317. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  318. </if>
  319. <if test="releaseEnd != null">
  320. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  321. </if>
  322. <if test="duration != null">
  323. duration = #{duration,jdbcType=DOUBLE},
  324. </if>
  325. <if test="examineName != null">
  326. examine_name = #{examineName,jdbcType=VARCHAR},
  327. </if>
  328. <if test="settlementAmount != null">
  329. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  330. </if>
  331. <if test="debitId != null">
  332. debit_id = #{debitId,jdbcType=INTEGER},
  333. </if>
  334. <if test="targetType != null">
  335. target_type = #{targetType,jdbcType=INTEGER},
  336. </if>
  337. <if test="liquidationStatus != null">
  338. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  339. </if>
  340. <if test="remarks != null">
  341. remarks = #{remarks,jdbcType=VARCHAR},
  342. </if>
  343. <if test="checkNo != null">
  344. check_no = #{checkNo,jdbcType=VARCHAR},
  345. </if>
  346. <if test="expenseMain != null">
  347. expense_main = #{expenseMain,jdbcType=INTEGER},
  348. </if>
  349. <if test="realAmount != null">
  350. real_amount = #{realAmount,jdbcType=DECIMAL},
  351. </if>
  352. <if test="secondaryType != null">
  353. secondary_type = #{secondaryType,jdbcType=INTEGER},
  354. </if>
  355. <if test="secondaryTypeOther != null">
  356. secondary_type_other = #{secondaryTypeOther,jdbcType=VARCHAR},
  357. </if>
  358. </set>
  359. where id = #{id,jdbcType=INTEGER}
  360. </update>
  361. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccount">
  362. update expense_account
  363. set prid = #{prid,jdbcType=INTEGER},
  364. order_no = #{orderNo,jdbcType=VARCHAR},
  365. aid = #{aid,jdbcType=VARCHAR},
  366. aname = #{aname,jdbcType=VARCHAR},
  367. `type` = #{type,jdbcType=INTEGER},
  368. type_other = #{typeOther,jdbcType=VARCHAR},
  369. `status` = #{status,jdbcType=INTEGER},
  370. process_status = #{processStatus,jdbcType=INTEGER},
  371. total_amount = #{totalAmount,jdbcType=DECIMAL},
  372. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  373. apply_dep = #{applyDep,jdbcType=VARCHAR},
  374. pay_dep = #{payDep,jdbcType=VARCHAR},
  375. eaaid = #{eaaid,jdbcType=INTEGER},
  376. create_time = #{createTime,jdbcType=TIMESTAMP},
  377. district_name = #{districtName,jdbcType=VARCHAR},
  378. user_names = #{userNames,jdbcType=VARCHAR},
  379. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  380. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  381. duration = #{duration,jdbcType=DOUBLE},
  382. examine_name = #{examineName,jdbcType=VARCHAR},
  383. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  384. debit_id = #{debitId,jdbcType=INTEGER},
  385. target_type = #{targetType,jdbcType=INTEGER},
  386. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  387. remarks = #{remarks,jdbcType=VARCHAR},
  388. check_no = #{checkNo,jdbcType=VARCHAR},
  389. expense_main = #{expenseMain,jdbcType=INTEGER},
  390. real_amount = #{realAmount,jdbcType=DECIMAL},
  391. secondary_type = #{secondaryType,jdbcType=INTEGER},
  392. secondary_type_other = #{secondaryTypeOther,jdbcType=VARCHAR}
  393. where id = #{id,jdbcType=INTEGER}
  394. </update>
  395. <sql id="selectDtailsSql">
  396. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  397. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
  398. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  399. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  400. c.name payDepName,d.name ,d.bank ,d.accounts ,a.settlement_amount settlementAmount,a.secondary_type secondaryType,
  401. a.liquidation_status liquidationStatus, a.remarks,a.check_no checkNo,a.secondary_type_other secondaryTypeOther,
  402. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  403. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  404. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  405. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  406. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  407. left join t_order_mid tm on a.order_no =tm.order_no
  408. </sql>
  409. <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  410. SELECT
  411. <include refid="selectDtailsSql"/>
  412. WHERE a.id= #{id}
  413. </select>
  414. <select id="selectByCheckNo" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  415. SELECT
  416. <include refid="selectDtailsSql"/>
  417. WHERE a.check_no= #{checkNo}
  418. </select>
  419. <select id="selectExpenseAccountList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountBo">
  420. select a.id,a.total_amount totalAmount,a.`type`,a.process_status processStatus,a.type_other typeOther,
  421. a.attachment_url attachmentUrl,a.target_type targetType ,a.user_names userNames,
  422. a.secondary_type secondaryType, a.secondary_type_other secondaryTypeOther,a.status,
  423. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  424. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr,
  425. <if test="processStatus ==1">
  426. eae.type eaeType,
  427. </if>
  428. <if test="expenseMain ==0">
  429. mea.examine_name examineName,mea.check_no checkNo,e.contract_no contractNo,
  430. </if>
  431. <if test="expenseMain ==1">
  432. a.examine_name examineName,a.check_no checkNo,
  433. </if>
  434. f.name depName,d2.name financeName, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,a.aname,
  435. b.name appDepName, c.name payDepName
  436. from expense_account a
  437. <if test="type !=null">
  438. right join (select a.id
  439. from expense_account a left join expense_relationship b on a.id =b.id
  440. left join expense_account c on b.ea_id =c.id
  441. where c.`type` = #{type})x on a.id=x.id
  442. </if>
  443. left join admin d on a.aid =d.id left join department f on d.department_id =f.id
  444. left join admin d2 on f.finance_id =d2.id
  445. <if test="expenseMain ==0">
  446. left join expense_relationship er on a.id=er.ea_id
  447. left join expense_account mea on er.id=mea.id
  448. left join t_order_new e on mea.order_no =e.order_no
  449. left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
  450. </if>
  451. <if test="expenseMain ==1">
  452. left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  453. </if>
  454. <if test="processStatus ==1">
  455. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  456. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  457. </if>
  458. where 1=1
  459. <if test="processStatus ==2">
  460. and a.process_status>=0
  461. <if test="examineStatus ==1">
  462. and a.status=1
  463. </if>
  464. <if test="examineStatus ==2">
  465. and a.status=2
  466. </if>
  467. </if>
  468. <if test=" aid !=null">
  469. and a.aid= #{aid}
  470. </if>
  471. <if test="processStatus ==1">
  472. and a.process_status>0
  473. <if test="examineStatus ==0">
  474. and a.process_status =eae.`type`
  475. </if>
  476. <if test="examineStatus ==1">
  477. and a.process_status >eae.`type`
  478. </if>
  479. </if>
  480. <if test="status != null">
  481. and a.status= #{status}
  482. </if>
  483. <if test="checkNo != null " >
  484. <if test="expenseMain ==0">
  485. and mea.check_no like concat('%',#{checkNo},'%')
  486. </if>
  487. <if test="expenseMain ==1">
  488. and a.check_no like concat('%',#{checkNo},'%')
  489. </if>
  490. </if>
  491. <if test="username != null" >
  492. and a.user_names like concat('%',#{username},'%')
  493. </if>
  494. <if test="startTime !=null and endTime !=null">
  495. and a.create_time between #{startTime} and #{endTime}
  496. </if>
  497. <if test="depId != null">
  498. and d.department_id = #{depId}
  499. </if>
  500. <if test="contractNo != null">
  501. and e.contract_no = #{contractNo}
  502. </if>
  503. <if test="applyDep != null">
  504. and a.apply_dep = #{applyDep}
  505. </if>
  506. <if test="payDep != null">
  507. and a.pay_dep = #{payDep}
  508. </if>
  509. <if test="expenseMain != null">
  510. and a.expense_main= #{expenseMain}
  511. </if>
  512. <if test="secondaryType != null">
  513. and a.secondary_type= #{secondaryType}
  514. </if>
  515. order by a.status,a.create_time desc
  516. <if test="page_sql !=null">
  517. ${page_sql}
  518. </if>
  519. </select>
  520. <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
  521. select count(*)
  522. from expense_account a
  523. <if test="type !=null">
  524. right join (select a.id
  525. from expense_account a left join expense_relationship b on a.id =b.id
  526. left join expense_account c on b.ea_id =c.id
  527. where c.`type` = #{type})x on a.id=x.id
  528. </if>
  529. left join admin d on a.aid =d.id left join department f on d.department_id =f.id
  530. left join admin d2 on f.finance_id =d2.id
  531. <if test="expenseMain ==0">
  532. left join expense_relationship er on a.id=er.ea_id
  533. left join expense_account mea on er.id=mea.id
  534. left join t_order_new e on mea.order_no =e.order_no
  535. left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
  536. </if>
  537. <if test="expenseMain ==1">
  538. left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  539. </if>
  540. <if test="processStatus ==1">
  541. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  542. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  543. </if>
  544. where 1=1
  545. <if test="processStatus ==2">
  546. and a.process_status>=0
  547. <if test="examineStatus ==1">
  548. and a.status=1
  549. </if>
  550. <if test="examineStatus ==2">
  551. and a.status=2
  552. </if>
  553. </if>
  554. <if test=" aid !=null">
  555. and a.aid= #{aid}
  556. </if>
  557. <if test="processStatus ==1">
  558. and a.process_status>0
  559. <if test="examineStatus ==0">
  560. and a.process_status =eae.`type`
  561. </if>
  562. <if test="examineStatus ==1">
  563. and a.process_status >eae.`type`
  564. </if>
  565. </if>
  566. <if test="status != null">
  567. and a.status= #{status}
  568. </if>
  569. <if test="checkNo != null " >
  570. <if test="expenseMain ==0">
  571. and mea.check_no like concat('%',#{checkNo},'%')
  572. </if>
  573. <if test="expenseMain ==1">
  574. and a.check_no like concat('%',#{checkNo},'%')
  575. </if>
  576. </if>
  577. <if test="username != null" >
  578. and a.user_names like concat('%',#{username},'%')
  579. </if>
  580. <if test="startTime !=null and endTime !=null">
  581. and a.create_time between #{startTime} and #{endTime}
  582. </if>
  583. <if test="depId != null">
  584. and d.department_id = #{depId}
  585. </if>
  586. <if test="contractNo != null">
  587. and e.contract_no = #{contractNo}
  588. </if>
  589. <if test="applyDep != null">
  590. and a.apply_dep = #{applyDep}
  591. </if>
  592. <if test="payDep != null">
  593. and a.pay_dep = #{payDep}
  594. </if>
  595. <if test="expenseMain != null">
  596. and a.expense_main= #{expenseMain}
  597. </if>
  598. <if test="secondaryType != null">
  599. and a.secondary_type= #{secondaryType}
  600. </if>
  601. </select>
  602. <select id="selectExpenseAccountTotalAmount" resultType="java.lang.Integer">
  603. select sum(a.total_amount) totalAmount
  604. from expense_account a
  605. <if test="type !=null">
  606. right join (select a.id
  607. from expense_account a left join expense_relationship b on a.id =b.id
  608. left join expense_account c on b.ea_id =c.id
  609. where c.`type` = #{type})x on a.id=x.id
  610. </if>
  611. left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  612. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  613. left join t_order_mid tm on a.order_no =tm.order_no
  614. <if test="processStatus ==1">
  615. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  616. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  617. </if>
  618. where 1=1
  619. <if test="processStatus ==2">
  620. and a.process_status>=0
  621. <if test="examineStatus ==1">
  622. and a.status=1
  623. </if>
  624. <if test="examineStatus ==2">
  625. and a.status=2
  626. </if>
  627. </if>
  628. <if test=" aid !=null">
  629. and a.aid= #{aid}
  630. </if>
  631. <if test="processStatus ==1">
  632. and a.process_status>0
  633. <if test="examineStatus ==0">
  634. and a.process_status =eae.`type`
  635. </if>
  636. <if test="examineStatus ==1">
  637. and a.process_status >eae.`type`
  638. </if>
  639. </if>
  640. <if test="status != null">
  641. and a.status= #{status}
  642. </if>
  643. <if test="checkNo != null " >
  644. <if test="expenseMain ==0">
  645. and mea.check_no like concat('%',#{checkNo},'%')
  646. </if>
  647. <if test="expenseMain ==1">
  648. and a.check_no like concat('%',#{checkNo},'%')
  649. </if>
  650. </if>
  651. <if test="username != null" >
  652. and a.user_names like concat('%',#{username},'%')
  653. </if>
  654. <if test="startTime !=null and endTime !=null">
  655. and a.create_time between #{startTime} and #{endTime}
  656. </if>
  657. <if test="depId != null">
  658. and d.department_id = #{depId}
  659. </if>
  660. <if test="contractNo != null">
  661. and e.contract_no = #{contractNo}
  662. </if>
  663. <if test="applyDep != null">
  664. and a.apply_dep = #{applyDep}
  665. </if>
  666. <if test="payDep != null">
  667. and a.pay_dep = #{payDep}
  668. </if>
  669. <if test="expenseMain != null">
  670. and a.expense_main= #{expenseMain}
  671. </if>
  672. <if test="secondaryType != null">
  673. and a.secondary_type= #{secondaryType}
  674. </if>
  675. </select>
  676. <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  677. SELECT
  678. <include refid="selectDtailsSql"/>
  679. WHERE a.status= #{status}
  680. and a.prid= #{prid} and a.aid = #{aid}
  681. </select>
  682. <select id="selectByaidAndType" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  683. SELECT
  684. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  685. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
  686. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  687. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  688. c.name payDepName,d.name ,d.bank ,d.accounts ,t0.amount settlementAmount,a.check_no checkNo,
  689. a.liquidation_status liquidationStatus, a.remarks,
  690. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  691. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  692. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  693. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  694. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  695. left join t_order_mid tm on a.order_no =tm.order_no
  696. left join (select debit_id ,sum(settlement_amount) amount from expense_account where debit_id is not null and
  697. id != #{id} group by debit_id )t0 on a.id =t0.debit_id
  698. WHERE a.status=2 and a.liquidation_status in (0,1,2)
  699. and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
  700. order by a.create_time desc
  701. </select>
  702. <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutMyEAStatistics">
  703. select a.aid,a.aname ,a.type,a.status ,a.total_amount totalAmount ,ifnull(a.debit_id,0) debitId ,a.target_type targetType ,ifnull(a2.total_amount,0) bxdkAmount
  704. from expense_account a
  705. left join expense_account a2 on a.debit_id =a2.id left join admin ad on a.aid=ad.id
  706. where 1=1 and a.expense_main=0
  707. <if test="name != null">
  708. and a.aname like concat('%',#{name},'%')
  709. </if>
  710. <if test="depId != null">
  711. and ad.department_id = #{depId}
  712. </if>
  713. <if test="startTime != null and endTime != null">
  714. and a.create_time between #{startTime} and #{endTime}
  715. </if>
  716. </select>
  717. <select id="selectByDebitId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  718. select
  719. <include refid="Base_Column_List" />
  720. from expense_account
  721. where debit_id = #{debitId}
  722. </select>
  723. <select id="selectByCheckNoNot" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  724. select
  725. <include refid="Base_Column_List" />
  726. from expense_account
  727. where check_no =''
  728. </select>
  729. <select id="selectCountByFinance" resultType="com.goafanti.common.model.FinanceCount">
  730. select x.aid, x.dates dateTime, count(*)expenseCount, sum(if(x.process_status = 1, 1, 0))expenseUnauditedCount
  731. from (select c.finance_id aid , a.process_status, DATE_FORMAT(a.create_time , '%Y-%m-%d') dates
  732. from expense_account a left join admin b on a.aid=b.id left join department c on b.department_id =c.id
  733. where a.status in (1, 2) and a.process_status >0 and c.finance_id = #{aid})x
  734. group by x.aid, x.dates;
  735. </select>
  736. <select id="selectByIds" resultMap="BaseResultMap">
  737. select
  738. <include refid="Base_Column_List" />
  739. from expense_account
  740. where id in
  741. <foreach collection="list" open="(" close=")" separator="," item="id">
  742. #{id}
  743. </foreach>
  744. </select>
  745. <select id="selectByMainId" resultMap="MainMap">
  746. <include refid="mainAllSql"/>
  747. where a.id= #{id}
  748. </select>
  749. <sql id="mainAllSql">
  750. select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,b.real_amount,b.type_other ,
  751. date_format(b.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.examine_name, dep.name applyDepName,dep2.name payDepName,
  752. b.remarks,b.eaaid ,eap.name ,eap.bank ,eap.accounts ,b.status,b.process_status,
  753. c.id sonId,c.total_amount sonAmount,c.`type` sonType,c.type_other sonTypeOther,c.user_names ,c.release_start ,c.release_end ,
  754. c.district_name districtName,c.user_names userNames,c.secondary_type ,c.secondary_type_other,c.attachment_url,
  755. c.duration,pr.plan,pro.contract_no sonContractNo,c.real_amount sonRealAmount,
  756. d.id detId,d.`type` detType,d.amount,d.real_amount detRealAmount ,d.start_district ,d.end_district,d.vehicle,d.vehicle_other,
  757. d.pay_type ,d.invoice_type ,d.invoice_no,d.payer_name ,d.open_bank ,d.bank_accounts ,d.open_bank_address,d.type_other detTypeOther,
  758. date_format(d.start_time,'%Y-%m-%d %H:%i:%S')startTime,date_format(d.end_time,'%Y-%m-%d %H:%i:%S')endTime,
  759. date_format(d.agree_time,'%Y-%m-%d')agreeTime
  760. from expense_relationship a left join expense_account b on a.id =b.id
  761. left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
  762. left join t_order_new o on b.order_no =o.order_no left join expense_account_private eap on b.eaaid =eap.id
  763. left join expense_account c on a.ea_id =c.id left join expense_account_details d on c.id =d.eaid
  764. left join public_release pr on c.prid=pr.id left join t_order_new pro on pr.order_no=pro.order_no
  765. </sql>
  766. <select id="selectListByMainId" resultMap="BaseResultMap">
  767. select b.*
  768. from expense_relationship a left join expense_account b on a.ea_id =b.id
  769. where a.id =#{id}
  770. </select>
  771. <resultMap id="MainMap" type="com.goafanti.expenseAccount.bo.MainExpenseAccount">
  772. <id column="id" jdbcType="INTEGER" property="id" />
  773. <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
  774. <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
  775. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  776. <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
  777. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  778. <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
  779. <result column="aname" jdbcType="VARCHAR" property="aname" />
  780. <result column="apply_dep" jdbcType="VARCHAR" property="applyDep" />
  781. <result column="pay_dep" jdbcType="VARCHAR" property="payDep" />
  782. <result column="applyDepName" jdbcType="VARCHAR" property="applyDepName" />
  783. <result column="payDepName" jdbcType="VARCHAR" property="payDepName" />
  784. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  785. <result column="eaaid" jdbcType="INTEGER" property="eaaid" />
  786. <result column="name" jdbcType="VARCHAR" property="name" />
  787. <result column="bank" jdbcType="VARCHAR" property="bank" />
  788. <result column="accounts" jdbcType="VARCHAR" property="accounts" />
  789. <result column="status" jdbcType="INTEGER" property="status" />
  790. <result column="process_status" jdbcType="INTEGER" property="processStatus" />
  791. <result column="createTimeStr" jdbcType="VARCHAR" property="createTimeStr" />
  792. <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
  793. <association property="sonList" resultMap="SonExpenseAccountMap"></association>
  794. </resultMap>
  795. <resultMap id="SonExpenseAccountMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccount">
  796. <id column="sonId" jdbcType="INTEGER" property="id" />
  797. <result column="sonAmount" jdbcType="DECIMAL" property="totalAmount" />
  798. <result column="sonRealAmount" jdbcType="DECIMAL" property="realAmount" />
  799. <result column="sonType" jdbcType="INTEGER" property="type" />
  800. <result column="sonTypeOther" jdbcType="VARCHAR" property="typeOther" />
  801. <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
  802. <result column="secondary_type_other" jdbcType="INTEGER" property="secondaryTypeOther" />
  803. <result column="attachment_url" jdbcType="INTEGER" property="attachmentUrl" />
  804. <result column="user_names" jdbcType="VARCHAR" property="userNames" />
  805. <result column="release_start" jdbcType="VARCHAR" property="releaseStart" />
  806. <result column="release_end" jdbcType="VARCHAR" property="releaseEnd" />
  807. <result column="districtName" jdbcType="VARCHAR" property="districtName" />
  808. <result column="duration" jdbcType="VARCHAR" property="duration" />
  809. <result column="plan" jdbcType="VARCHAR" property="plan" />
  810. <result column="sonContractNo" jdbcType="VARCHAR" property="contractNo" />
  811. <association property="detList" resultMap="ExpenseAccountDetailsMap"></association>
  812. </resultMap>
  813. <resultMap id="ExpenseAccountDetailsMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccountDetails">
  814. <id column="detId" jdbcType="INTEGER" property="id" />
  815. <result column="detType" jdbcType="INTEGER" property="type" />
  816. <result column="detTypeOther" jdbcType="INTEGER" property="typeOther" />
  817. <result column="amount" jdbcType="DECIMAL" property="amount" />
  818. <result column="detRealAmount" jdbcType="DECIMAL" property="realAmount" />
  819. <result column="start_district" jdbcType="VARCHAR" property="startDistrict" />
  820. <result column="end_district" jdbcType="VARCHAR" property="endDistrict" />
  821. <result column="vehicle" jdbcType="INTEGER" property="vehicle" />
  822. <result column="vehicle_other" jdbcType="VARCHAR" property="vehicleOther" />
  823. <result column="pay_type" jdbcType="INTEGER" property="payType" />
  824. <result column="invoice_type" jdbcType="INTEGER" property="invoiceType" />
  825. <result column="invoice_no" jdbcType="VARCHAR" property="invoiceNo" />
  826. <result column="payer_name" jdbcType="VARCHAR" property="payerName" />
  827. <result column="open_bank" jdbcType="VARCHAR" property="openBank" />
  828. <result column="bank_accounts" jdbcType="VARCHAR" property="bankAccounts" />
  829. <result column="open_bank_address" jdbcType="VARCHAR" property="openBankAddress" />
  830. <result column="startTime" jdbcType="VARCHAR" property="startTime" />
  831. <result column="endTime" jdbcType="VARCHAR" property="endTime" />
  832. <result column="agreeTime" jdbcType="VARCHAR" property="agreeTime" />
  833. </resultMap>
  834. <update id="updateByIds" >
  835. update expense_account
  836. set status= #{status}
  837. where id in
  838. <foreach collection="list" open="(" close=")" separator="," item="item">
  839. #{item.id}
  840. </foreach>
  841. </update>
  842. <update id="updateByMainId">
  843. update expense_relationship a ,expense_account b
  844. set b.status= #{status}
  845. where a.id= #{id} and a.ea_id=b.id
  846. </update>
  847. <update id="updateSonByDetId">
  848. update expense_account x ,(select b.id,sum(c.real_amount) amount
  849. from expense_account_details a left join expense_account b on a.eaid =b.id
  850. left join expense_account_details c on b.id =c.eaid
  851. where a.id= #{id} group by b.id)y
  852. set x.real_amount =y.amount
  853. where x.id=y.id;
  854. </update>
  855. <update id="updateMainByDetId">
  856. update expense_account x ,( select a.id,sum(c.real_amount)amount
  857. from expense_account a left join expense_relationship b on a.id=b.id
  858. left join expense_account c on b.ea_id =c.id
  859. where a.id in(select c.id
  860. from expense_account_details a left join expense_account b on a.eaid =b.id
  861. left join expense_relationship c on b.id =c.ea_id
  862. where a.id= #{id}) group by a.id)y
  863. set x.real_amount =y.amount
  864. where x.id=y.id
  865. </update>
  866. <select id="ExpenseMainList" resultMap="MainMap">
  867. select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,
  868. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.status,b.process_status,b.examine_name,
  869. dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid ,
  870. c.id sonId,c.total_amount sonAmount,c.`type` sonType,c.type_other sonTypeOTher,c.user_names ,c.release_start ,c.release_end,
  871. c.attachment_url attachmentUrl,c.secondary_type,c.secondary_type_other
  872. from expense_relationship a
  873. left join expense_account b on a.id =b.id
  874. left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
  875. left join t_order_new o on b.order_no =o.order_no left join expense_account c on a.ea_id =c.id
  876. left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
  877. where 1=1 and b.expense_main =1
  878. <if test="checkNo !=null">
  879. and b.check_no like concat('%',#{checkNo},'%')
  880. </if>
  881. <if test=" status != null">
  882. and b.status = #{status}
  883. </if>
  884. <if test=" roleType ==0">
  885. and b.aid = #{aid}
  886. </if>
  887. <if test="roleType == 1">
  888. <if test="listStatus ==0">
  889. and b.process_status =1
  890. </if>
  891. <if test="listStatus ==1">
  892. and b.process_status &gt; 1
  893. </if>
  894. and ad.superior_id= #{aid}
  895. </if>
  896. <if test="roleType == 2">
  897. <if test="listStatus ==0">
  898. and b.process_status =2
  899. </if>
  900. <if test="listStatus ==1">
  901. and b.process_status &gt; 2
  902. </if>
  903. and adDep.finance_id = #{aid}
  904. </if>
  905. <if test="roleType == 3">
  906. <if test="listStatus ==0">
  907. and b.process_status =3
  908. </if>
  909. <if test="listStatus ==1">
  910. and b.process_status &gt; 3
  911. </if>
  912. and ad.department_id in
  913. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  914. #{dep}
  915. </foreach>
  916. </if>
  917. <if test="roleType == 4">
  918. <if test="listStatus ==0">
  919. and b.process_status =4 and b.status=1
  920. </if>
  921. <if test="listStatus ==1">
  922. and b.process_status =5 and b.status=2
  923. </if>
  924. </if>
  925. order by b.status ,b.create_time desc
  926. ${page_sql}
  927. </select>
  928. <select id="ExpenseMainCount" resultType="java.lang.Integer">
  929. select count(*)
  930. from expense_account b
  931. left join admin ad on b.aid=ad.id
  932. left join department adDep on ad .department_id=adDep.id
  933. where 1=1 and b.expense_main =1
  934. <if test="checkNo !=null">
  935. and b.check_no like concat('%',#{checkNo},'%')
  936. </if>
  937. <if test=" status != null">
  938. and b.status = #{status}
  939. </if>
  940. <if test=" roleType ==0">
  941. and b.aid = #{aid}
  942. </if>
  943. <if test="roleType == 1">
  944. <if test="listStatus ==0">
  945. and b.process_status =1
  946. </if>
  947. <if test="listStatus ==1">
  948. and b.process_status &gt; 1
  949. </if>
  950. and ad.superior_id= #{aid}
  951. </if>
  952. <if test="roleType == 2">
  953. <if test="listStatus ==0">
  954. and b.process_status =2
  955. </if>
  956. <if test="listStatus ==1">
  957. and b.process_status &gt; 2
  958. </if>
  959. and adDep.finance_id = #{aid}
  960. </if>
  961. <if test="roleType == 3">
  962. <if test="listStatus ==0">
  963. and b.process_status =3
  964. </if>
  965. <if test="listStatus ==1">
  966. and b.process_status &gt; 3
  967. </if>
  968. and ad.department_id in
  969. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  970. #{dep}
  971. </foreach>
  972. </if>
  973. <if test="roleType == 4">
  974. <if test="listStatus ==0">
  975. and b.process_status =4 and b.status=1
  976. </if>
  977. <if test="listStatus ==1">
  978. and b.process_status =5 and b.status=2
  979. </if>
  980. </if>
  981. </select>
  982. <select id="ExpenseDetailsList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountDetailsList">
  983. select mea.check_no ,ead.`type`,ead.amount ,ead.real_amount ,o.contract_no ,dep.name applyDepName,
  984. dep2.name payDepName ,mea.aname ,ad2.name financeName,mea.status ,mea.process_status ,mea.id mainId,
  985. tm.buyer_name buyerName ,date_format(mea.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
  986. from expense_account_details ead left join expense_account a on ead.eaid =a.id
  987. left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
  988. left join t_order_new o on mea.order_no =o.order_no left join t_order_mid tm on o.order_no =tm.order_no
  989. left join department dep on mea.apply_dep =dep.id
  990. left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
  991. left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
  992. where 1=1
  993. <if test=" status != null">
  994. and mea.status = #{status}
  995. </if>
  996. <if test="deps !=null">
  997. and ad.department_id in
  998. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  999. #{dep}
  1000. </foreach>
  1001. </if>
  1002. <if test=" contractNo != null">
  1003. and o.contract_no like concat('%',#{contractNo},'%')
  1004. </if><if test=" buyerName != null">
  1005. and tm.buyer_name like concat('%','buyerName','%')
  1006. </if><if test=" type != null">
  1007. and ead.`type` = #{type}
  1008. </if><if test=" aname != null">
  1009. and mea.aname like concat('%',#{aname},'%')
  1010. </if><if test=" applyDep != null">
  1011. and mea.apply_dep =#{applyDep}
  1012. </if><if test=" payDep != null">
  1013. and mea.pay_dep =#{payDep}
  1014. </if><if test=" startTime != null and endTime !=null">
  1015. and mea.create_time between #{startTime} and #{endTime}
  1016. </if><if test=" checkNo != null">
  1017. and mea.check_no like concat('%',#{checkNo},'%')
  1018. </if>
  1019. ${page_sql}
  1020. </select>
  1021. <select id="ExpenseDetailsCount" resultType="java.lang.Integer">
  1022. select count(*)
  1023. from expense_account_details ead left join expense_account a on ead.eaid =a.id
  1024. left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
  1025. left join t_order_new o on mea.order_no =o.order_no left join t_order_mid tm on o.order_no =tm.order_no
  1026. left join department dep on mea.apply_dep =dep.id
  1027. left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
  1028. left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
  1029. where 1=1
  1030. <if test=" status != null">
  1031. and mea.status = #{status}
  1032. </if>
  1033. <if test="deps !=null">
  1034. and ad.department_id in
  1035. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  1036. #{dep}
  1037. </foreach>
  1038. </if>
  1039. <if test=" contractNo != null">
  1040. and o.contract_no like concat('%',#{contractNo},'%')
  1041. </if><if test=" buyerName != null">
  1042. and tm.buyer_name like concat('%','buyerName','%')
  1043. </if><if test=" type != null">
  1044. and ead.`type` = #{type}
  1045. </if><if test=" aname != null">
  1046. and mea.aname like concat('%',#{aname},'%')
  1047. </if><if test=" applyDep != null">
  1048. and mea.apply_dep =#{applyDep}
  1049. </if><if test=" payDep != null">
  1050. and mea.pay_dep =#{payDep}
  1051. </if><if test=" startTime != null and endTime !=null">
  1052. and mea.create_time between #{startTime} and #{endTime}
  1053. </if><if test=" checkNo != null">
  1054. and mea.check_no like concat('%',#{checkNo},'%')
  1055. </if>
  1056. </select>
  1057. <select id="selectCountByIdsAndType" resultType="java.lang.Integer">
  1058. select count(*) from expense_account
  1059. where type =#{type}
  1060. and id in
  1061. <foreach collection="list" item="id" open="(" close=")" separator=",">
  1062. #{id}
  1063. </foreach>
  1064. </select>
  1065. <select id="selectAllMain" resultMap="BaseResultMap">
  1066. select
  1067. <include refid="Base_Column_List" />
  1068. from expense_account
  1069. where expense_main=1
  1070. </select>
  1071. </mapper>