ExpenseAccountMapper.xml 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  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 , e.contract_no contractNo,tm.buyer_name buyerName ,
  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,
  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. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  438. left join t_order_mid tm on a.order_no =tm.order_no left join department f on d.department_id =f.id
  439. left join admin d2 on f.finance_id =d2.id
  440. <if test="expenseMain ==0">
  441. left join expense_relationship er on a.id=er.id
  442. left join expense_account mea on er.ea_id=mea.id
  443. left join department b on mea.apply_dep =b.id left join department c on mea.pay_dep =c.id
  444. </if>
  445. <if test="expenseMain ==1">
  446. left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  447. </if>
  448. <if test="processStatus ==1">
  449. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  450. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  451. </if>
  452. where 1=1
  453. <if test="processStatus ==2">
  454. and a.process_status>=0
  455. <if test="examineStatus ==1">
  456. and a.status=1
  457. </if>
  458. <if test="examineStatus ==2">
  459. and a.status=2
  460. </if>
  461. </if>
  462. <if test=" aid !=null">
  463. and a.aid= #{aid}
  464. </if>
  465. <if test="processStatus ==1">
  466. and a.process_status>0
  467. <if test="examineStatus ==0">
  468. and a.process_status =eae.`type`
  469. </if>
  470. <if test="examineStatus ==1">
  471. and a.process_status >eae.`type`
  472. </if>
  473. </if>
  474. <if test="status != null">
  475. and a.status= #{status}
  476. </if>
  477. <if test="type != null">
  478. and a.type= #{type}
  479. </if>
  480. <if test="checkNo != null " >
  481. <if test="expenseMain ==0">
  482. and mea.check_no like concat('%',#{checkNo},'%')
  483. </if>
  484. <if test="expenseMain ==1">
  485. and a.check_no like concat('%',#{checkNo},'%')
  486. </if>
  487. </if>
  488. <if test="username != null" >
  489. and tm.buyer_name like concat('%',#{username},'%')
  490. </if>
  491. <if test="startTime !=null and endTime !=null">
  492. and a.create_time between #{startTime} and #{endTime}
  493. </if>
  494. <if test="depId != null">
  495. and d.department_id = #{depId}
  496. </if>
  497. <if test="contractNo != null">
  498. and e.contract_no = #{contractNo}
  499. </if>
  500. <if test="applyDep != null">
  501. and a.apply_dep = #{applyDep}
  502. </if>
  503. <if test="payDep != null">
  504. and a.pay_dep = #{payDep}
  505. </if>
  506. <if test="expenseMain != null">
  507. and a.expense_main= #{expenseMain}
  508. </if>
  509. <if test="secondaryType != null">
  510. and a.secondary_type= #{secondaryType}
  511. </if>
  512. order by a.status,a.create_time desc
  513. <if test="page_sql !=null">
  514. ${page_sql}
  515. </if>
  516. </select>
  517. <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
  518. select count(*)
  519. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  520. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  521. left join t_order_mid tm on a.order_no =tm.order_no
  522. <if test="processStatus ==1">
  523. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  524. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  525. </if>
  526. where 1=1
  527. <if test="processStatus ==2">
  528. and a.process_status>=0
  529. <if test="examineStatus ==1">
  530. and a.status=1
  531. </if>
  532. <if test="examineStatus ==2">
  533. and a.status=2
  534. </if>
  535. </if>
  536. <if test=" aid !=null">
  537. and a.aid= #{aid}
  538. </if>
  539. <if test="processStatus ==1">
  540. and a.process_status>0
  541. <if test="examineStatus ==0">
  542. and a.process_status =eae.`type`
  543. </if>
  544. <if test="examineStatus ==1">
  545. and a.process_status >eae.`type`
  546. </if>
  547. </if>
  548. <if test="status != null">
  549. and a.status= #{status}
  550. </if>
  551. <if test="type != null">
  552. and a.type= #{type}
  553. </if>
  554. <if test="checkNo != null " >
  555. <if test="expenseMain ==0">
  556. and mea.check_no like concat('%',#{checkNo},'%')
  557. </if>
  558. <if test="expenseMain ==1">
  559. and a.check_no like concat('%',#{checkNo},'%')
  560. </if>
  561. </if>
  562. <if test="username != null" >
  563. and tm.buyer_name like concat('%',#{username},'%')
  564. </if>
  565. <if test="startTime !=null and endTime !=null">
  566. and a.create_time between #{startTime} and #{endTime}
  567. </if>
  568. <if test="depId != null">
  569. and d.department_id = #{depId}
  570. </if>
  571. <if test="contractNo != null">
  572. and e.contract_no = #{contractNo}
  573. </if>
  574. <if test="applyDep != null">
  575. and a.apply_dep = #{applyDep}
  576. </if>
  577. <if test="payDep != null">
  578. and a.pay_dep = #{payDep}
  579. </if>
  580. <if test="expenseMain != null">
  581. and a.expense_main= #{expenseMain}
  582. </if>
  583. <if test="secondaryType != null">
  584. and a.secondary_type= #{secondaryType}
  585. </if>
  586. </select>
  587. <select id="selectExpenseAccountTotalAmount" resultType="java.lang.Integer">
  588. select sum(a.total_amount) totalAmount
  589. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  590. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  591. left join t_order_mid tm on a.order_no =tm.order_no
  592. <if test="processStatus ==1">
  593. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  594. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  595. </if>
  596. where 1=1
  597. <if test="processStatus ==2">
  598. and a.process_status>=0
  599. <if test="examineStatus ==1">
  600. and a.status=1
  601. </if>
  602. <if test="examineStatus ==2">
  603. and a.status=2
  604. </if>
  605. </if>
  606. <if test=" aid !=null">
  607. and a.aid= #{aid}
  608. </if>
  609. <if test="processStatus ==1">
  610. and a.process_status>0
  611. <if test="examineStatus ==0">
  612. and a.process_status =eae.`type`
  613. </if>
  614. <if test="examineStatus ==1">
  615. and a.process_status >eae.`type`
  616. </if>
  617. </if>
  618. <if test="status != null">
  619. and a.status= #{status}
  620. </if>
  621. <if test="type != null">
  622. and a.type= #{type}
  623. </if>
  624. <if test="checkNo != null " >
  625. <if test="expenseMain ==0">
  626. and mea.check_no like concat('%',#{checkNo},'%')
  627. </if>
  628. <if test="expenseMain ==1">
  629. and a.check_no like concat('%',#{checkNo},'%')
  630. </if>
  631. </if>
  632. <if test="username != null" >
  633. and tm.buyer_name like concat('%',#{username},'%')
  634. </if>
  635. <if test="startTime !=null and endTime !=null">
  636. and a.create_time between #{startTime} and #{endTime}
  637. </if>
  638. <if test="depId != null">
  639. and d.department_id = #{depId}
  640. </if>
  641. <if test="contractNo != null">
  642. and e.contract_no = #{contractNo}
  643. </if>
  644. <if test="applyDep != null">
  645. and a.apply_dep = #{applyDep}
  646. </if>
  647. <if test="payDep != null">
  648. and a.pay_dep = #{payDep}
  649. </if>
  650. <if test="expenseMain != null">
  651. and a.expense_main= #{expenseMain}
  652. </if>
  653. <if test="secondaryType != null">
  654. and a.secondary_type= #{secondaryType}
  655. </if>
  656. </select>
  657. <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  658. SELECT
  659. <include refid="selectDtailsSql"/>
  660. WHERE a.status= #{status}
  661. and a.prid= #{prid} and a.aid = #{aid}
  662. </select>
  663. <select id="selectByaidAndType" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  664. SELECT
  665. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  666. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
  667. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  668. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  669. c.name payDepName,d.name ,d.bank ,d.accounts ,t0.amount settlementAmount,a.check_no checkNo,
  670. a.liquidation_status liquidationStatus, a.remarks,
  671. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  672. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  673. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  674. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  675. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  676. left join t_order_mid tm on a.order_no =tm.order_no
  677. left join (select debit_id ,sum(settlement_amount) amount from expense_account where debit_id is not null and
  678. id != #{id} group by debit_id )t0 on a.id =t0.debit_id
  679. WHERE a.status=2 and a.liquidation_status in (0,1,2)
  680. and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
  681. order by a.create_time desc
  682. </select>
  683. <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutMyEAStatistics">
  684. 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
  685. from expense_account a
  686. left join expense_account a2 on a.debit_id =a2.id left join admin ad on a.aid=ad.id
  687. where 1=1 and a.expense_main=0
  688. <if test="name != null">
  689. and a.aname like concat('%',#{name},'%')
  690. </if>
  691. <if test="depId != null">
  692. and ad.department_id = #{depId}
  693. </if>
  694. <if test="startTime != null and endTime != null">
  695. and a.create_time between #{startTime} and #{endTime}
  696. </if>
  697. </select>
  698. <select id="selectByDebitId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  699. select
  700. <include refid="Base_Column_List" />
  701. from expense_account
  702. where debit_id = #{debitId}
  703. </select>
  704. <select id="selectByCheckNoNot" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  705. select
  706. <include refid="Base_Column_List" />
  707. from expense_account
  708. where check_no =''
  709. </select>
  710. <select id="selectCountByFinance" resultType="com.goafanti.common.model.FinanceCount">
  711. select x.aid, x.dates dateTime, count(*)expenseCount, sum(if(x.process_status = 1, 1, 0))expenseUnauditedCount
  712. from (select c.finance_id aid , a.process_status, DATE_FORMAT(a.create_time , '%Y-%m-%d') dates
  713. from expense_account a left join admin b on a.aid=b.id left join department c on b.department_id =c.id
  714. where a.status in (1, 2) and a.process_status >0 and c.finance_id = #{aid})x
  715. group by x.aid, x.dates;
  716. </select>
  717. <select id="selectByIds" resultMap="BaseResultMap">
  718. select
  719. <include refid="Base_Column_List" />
  720. from expense_account
  721. where id in
  722. <foreach collection="list" open="(" close=")" separator="," item="id">
  723. #{id}
  724. </foreach>
  725. </select>
  726. <select id="selectByMainId" resultMap="MainMap">
  727. <include refid="mainAllSql"/>
  728. where a.id= #{id}
  729. </select>
  730. <sql id="mainAllSql">
  731. 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,
  732. date_format(b.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.examine_name,
  733. dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid ,eap.name ,eap.bank ,eap.accounts ,b.status,b.process_status,
  734. c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,c.user_names ,c.release_start ,c.release_end ,
  735. c.district_name districtName,c.user_names userNames,c.secondary_type ,c.secondary_type_other,c.attachment_url,
  736. d.id detId,d.`type` detType,d.amount,d.real_amount realAmount ,d.start_district ,d.end_district,d.vehicle,d.vehicle_other,
  737. d.pay_type ,d.invoice_type ,d.invoice_no,d.payer_name ,d.open_bank ,d.bank_accounts ,d.open_bank_address
  738. from expense_relationship a left join expense_account b on a.id =b.id
  739. left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
  740. left join t_order_new o on b.order_no =o.order_no left join expense_account_private eap on b.eaaid =eap.id
  741. left join expense_account c on a.ea_id =c.id left join expense_account_details d on c.id =d.eaid
  742. </sql>
  743. <select id="selectListByMainId" resultMap="BaseResultMap">
  744. select b.*
  745. from expense_relationship a left join expense_account b on a.ea_id =b.id
  746. where a.id =#{id}
  747. </select>
  748. <resultMap id="MainMap" type="com.goafanti.expenseAccount.bo.MainExpenseAccount">
  749. <id column="id" jdbcType="INTEGER" property="id" />
  750. <result column="check_no" jdbcType="VARCHAR" property="checkNo" />
  751. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  752. <result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
  753. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  754. <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
  755. <result column="aname" jdbcType="VARCHAR" property="aname" />
  756. <result column="apply_dep" jdbcType="VARCHAR" property="applyDep" />
  757. <result column="pay_dep" jdbcType="VARCHAR" property="payDep" />
  758. <result column="applyDepName" jdbcType="VARCHAR" property="applyDepName" />
  759. <result column="payDepName" jdbcType="VARCHAR" property="payDepName" />
  760. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  761. <result column="eaaid" jdbcType="INTEGER" property="eaaid" />
  762. <result column="name" jdbcType="VARCHAR" property="name" />
  763. <result column="bank" jdbcType="VARCHAR" property="bank" />
  764. <result column="accounts" jdbcType="VARCHAR" property="accounts" />
  765. <result column="status" jdbcType="INTEGER" property="status" />
  766. <result column="process_status" jdbcType="INTEGER" property="processStatus" />
  767. <result column="createTimeStr" jdbcType="VARCHAR" property="createTimeStr" />
  768. <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
  769. <association property="sonList" resultMap="SonExpenseAccountMap"></association>
  770. </resultMap>
  771. <resultMap id="SonExpenseAccountMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccount">
  772. <id column="sonId" jdbcType="INTEGER" property="id" />
  773. <result column="sonAmount" jdbcType="DECIMAL" property="totalAmount" />
  774. <result column="type" jdbcType="INTEGER" property="type" />
  775. <result column="type_other" jdbcType="VARCHAR" property="typeOther" />
  776. <result column="secondary_type" jdbcType="INTEGER" property="secondaryType" />
  777. <result column="secondary_type_other" jdbcType="INTEGER" property="secondaryTypeOther" />
  778. <result column="attachment_url" jdbcType="INTEGER" property="attachmentUrl" />
  779. <result column="user_names" jdbcType="VARCHAR" property="userNames" />
  780. <result column="release_start" jdbcType="VARCHAR" property="releaseStart" />
  781. <result column="release_end" jdbcType="VARCHAR" property="releaseEnd" />
  782. <result column="districtName" jdbcType="VARCHAR" property="districtName" />
  783. <association property="detList" resultMap="ExpenseAccountDetailsMap"></association>
  784. </resultMap>
  785. <resultMap id="ExpenseAccountDetailsMap" type="com.goafanti.expenseAccount.bo.SonExpenseAccountDetails">
  786. <id column="detId" jdbcType="INTEGER" property="id" />
  787. <result column="detType" jdbcType="INTEGER" property="type" />
  788. <result column="amount" jdbcType="DECIMAL" property="amount" />
  789. <result column="start_district" jdbcType="VARCHAR" property="startDistrict" />
  790. <result column="end_district" jdbcType="VARCHAR" property="endDistrict" />
  791. <result column="vehicle" jdbcType="INTEGER" property="vehicle" />
  792. <result column="vehicle_other" jdbcType="VARCHAR" property="vehicleOther" />
  793. <result column="pay_type" jdbcType="INTEGER" property="payType" />
  794. <result column="invoice_type" jdbcType="INTEGER" property="invoiceType" />
  795. <result column="invoice_no" jdbcType="VARCHAR" property="invoiceNo" />
  796. <result column="payer_name" jdbcType="VARCHAR" property="payerName" />
  797. <result column="open_bank" jdbcType="VARCHAR" property="openBank" />
  798. <result column="bank_accounts" jdbcType="VARCHAR" property="bankAccounts" />
  799. <result column="open_bank_address" jdbcType="VARCHAR" property="openBankAddress" />
  800. </resultMap>
  801. <update id="updateByIds" >
  802. update expense_account
  803. set status= #{status}
  804. where id in
  805. <foreach collection="list" open="(" close=")" separator="," item="item">
  806. #{item.id}
  807. </foreach>
  808. </update>
  809. <update id="updateByMainId">
  810. update expense_relationship a ,expense_account b
  811. set b.status= #{status}
  812. where a.id= #{id} and a.ea_id=b.id
  813. </update>
  814. <select id="ExpenseMainList" resultMap="MainMap">
  815. select b.id,b.check_no,b.total_amount,b.order_no,o.contract_no,b.aname,b.apply_dep,b.pay_dep,
  816. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,b.status,b.process_status,b.examine_name,
  817. dep.name applyDepName,dep2.name payDepName, b.remarks,b.eaaid ,
  818. c.id sonId,c.total_amount sonAmount,c.`type` ,c.type_other ,c.user_names ,c.release_start ,c.release_end,
  819. c.attachment_url attachmentUrl,c.secondary_type,c.secondary_type_other
  820. from expense_relationship a
  821. left join expense_account b on a.id =b.id
  822. left join department dep on b.apply_dep =dep.id left join department dep2 on b.pay_dep =dep2.id
  823. left join t_order_new o on b.order_no =o.order_no left join expense_account c on a.ea_id =c.id
  824. left join admin ad on b.aid=ad.id left join department adDep on ad.department_id=adDep.id
  825. where 1=1 and b.expense_main =1
  826. <if test="checkNo !=null">
  827. and b.check_no like concat('%',#{checkNo},'%')
  828. </if>
  829. <if test=" status != null">
  830. and b.status = #{status}
  831. </if>
  832. <if test=" roleType ==0">
  833. and b.aid = #{aid}
  834. </if>
  835. <if test="roleType == 1">
  836. <if test="listStatus ==0">
  837. and b.process_status =1
  838. </if>
  839. <if test="listStatus ==1">
  840. and b.process_status &gt; 1
  841. </if>
  842. and ad.superior_id= #{aid}
  843. </if>
  844. <if test="roleType == 2">
  845. <if test="listStatus ==0">
  846. and b.process_status =2
  847. </if>
  848. <if test="listStatus ==1">
  849. and b.process_status &gt; 2
  850. </if>
  851. and adDep.finance_id = #{aid}
  852. </if>
  853. <if test="roleType == 3">
  854. <if test="listStatus ==0">
  855. and b.process_status =3
  856. </if>
  857. <if test="listStatus ==1">
  858. and b.process_status &gt; 3
  859. </if>
  860. and ad.department_id in
  861. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  862. #{dep}
  863. </foreach>
  864. </if>
  865. ${page_sql}
  866. </select>
  867. <select id="ExpenseMainCount" resultType="java.lang.Integer">
  868. select count(*)
  869. from expense_account b
  870. left join admin ad on b.aid=ad.id
  871. left join department adDep on ad .department_id=adDep.id
  872. where 1=1 and b.expense_main =1
  873. <if test="checkNo !=null">
  874. and b.check_no like concat('%',#{checkNo},'%')
  875. </if>
  876. <if test=" status != null">
  877. and b.status = #{status}
  878. </if>
  879. <if test=" roleType ==0">
  880. and b.aid = #{aid}
  881. </if>
  882. <if test="roleType == 1">
  883. <if test="listStatus ==0">
  884. and b.process_status =1
  885. </if>
  886. <if test="listStatus ==1">
  887. and b.process_status &gt; 1
  888. </if>
  889. and ad.superior_id= #{aid}
  890. </if>
  891. <if test="roleType == 2">
  892. <if test="listStatus ==0">
  893. and b.process_status =2
  894. </if>
  895. <if test="listStatus ==1">
  896. and b.process_status &gt; 2
  897. </if>
  898. and adDep.finance_id = #{aid}
  899. </if>
  900. <if test="roleType == 3">
  901. <if test="listStatus ==0">
  902. and b.process_status =3
  903. </if>
  904. <if test="listStatus ==1">
  905. and b.process_status &gt; 3
  906. </if>
  907. and ad.department_id in
  908. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  909. #{dep}
  910. </foreach>
  911. </if>
  912. </select>
  913. <select id="ExpenseDetailsList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountDetailsList">
  914. select mea.check_no ,ead.`type`,ead.amount ,ead.real_amount ,o.contract_no ,dep.name applyDepName,
  915. dep2.name payDepName ,mea.aname ,ad2.name financeName,mea.status ,mea.process_status ,mea.id mainId,
  916. tm.buyer_name buyerName ,date_format(mea.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr
  917. from expense_account_details ead left join expense_account a on ead.eaid =a.id
  918. left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
  919. 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
  920. left join department dep on mea.apply_dep =dep.id
  921. left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
  922. left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
  923. where 1=1
  924. <if test=" status != null">
  925. and mea.status = #{status}
  926. </if>
  927. <if test="deps !=null">
  928. and ad.department_id in
  929. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  930. #{dep}
  931. </foreach>
  932. </if>
  933. <if test=" contractNo != null">
  934. and o.contract_no like concat('%',#{contractNo},'%')
  935. </if><if test=" buyerName != null">
  936. and tm.buyer_name like concat('%','buyerName','%')
  937. </if><if test=" type != null">
  938. and ead.`type` = #{type}
  939. </if><if test=" aname != null">
  940. and mea.aname like concat('%',#{aname},'%')
  941. </if><if test=" applyDep != null">
  942. and mea.apply_dep =#{applyDep}
  943. </if><if test=" payDep != null">
  944. and mea.pay_dep =#{payDep}
  945. </if><if test=" startTime != null and endTime !=null">
  946. and mea.create_time between #{startTime} and #{endTime}
  947. </if><if test=" checkNo != null">
  948. and mea.check_no like concat('%',#{checkNo},'%')
  949. </if>
  950. ${page_sql}
  951. </select>
  952. <select id="ExpenseDetailsCount" resultType="java.lang.Integer">
  953. select count(*)
  954. from expense_account_details ead left join expense_account a on ead.eaid =a.id
  955. left join expense_relationship er on a.id=er.ea_id left join expense_account mea on er.id=mea.id
  956. 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
  957. left join department dep on mea.apply_dep =dep.id
  958. left join department dep2 on mea.pay_dep =dep2.id left join admin ad on mea.aid=ad.id
  959. left join department dep3 on ad.department_id =dep3.id left join admin ad2 on dep3.finance_id =ad2.id
  960. where 1=1
  961. <if test=" status != null">
  962. and mea.status = #{status}
  963. </if>
  964. <if test="deps !=null">
  965. and ad.department_id in
  966. <foreach collection="deps" item="dep" open="(" close=")" separator=",">
  967. #{dep}
  968. </foreach>
  969. </if>
  970. <if test=" contractNo != null">
  971. and o.contract_no like concat('%',#{contractNo},'%')
  972. </if><if test=" buyerName != null">
  973. and tm.buyer_name like concat('%','buyerName','%')
  974. </if><if test=" type != null">
  975. and ead.`type` = #{type}
  976. </if><if test=" aname != null">
  977. and mea.aname like concat('%',#{aname},'%')
  978. </if><if test=" applyDep != null">
  979. and mea.apply_dep =#{applyDep}
  980. </if><if test=" payDep != null">
  981. and mea.pay_dep =#{payDep}
  982. </if><if test=" startTime != null and endTime !=null">
  983. and mea.create_time between #{startTime} and #{endTime}
  984. </if><if test=" checkNo != null">
  985. and mea.check_no like concat('%',#{checkNo},'%')
  986. </if>
  987. </select>
  988. <select id="selectCountByIdsAndType" resultType="java.lang.Integer">
  989. select count(*) from expense_account
  990. where type =#{type}
  991. and id in
  992. <foreach collection="list" item="id" open="(" close=")" separator=",">
  993. #{id}
  994. </foreach>
  995. </select>
  996. </mapper>