ExpenseAccountMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. </resultMap>
  33. <sql id="Base_Column_List">
  34. id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
  35. attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
  36. release_start, release_end, duration, examine_name, settlement_amount, debit_id,
  37. target_type, liquidation_status, remarks, check_no
  38. </sql>
  39. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  40. select
  41. <include refid="Base_Column_List" />
  42. from expense_account
  43. where id = #{id,jdbcType=INTEGER}
  44. </select>
  45. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  46. delete from expense_account
  47. where id = #{id,jdbcType=INTEGER}
  48. </delete>
  49. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  50. insert into expense_account (prid, order_no, aid,
  51. aname, `type`, type_other,
  52. `status`, process_status, total_amount,
  53. attachment_url, apply_dep, pay_dep,
  54. eaaid, create_time, district_name,
  55. user_names, release_start, release_end,
  56. duration, examine_name, settlement_amount,
  57. debit_id, target_type, liquidation_status,
  58. remarks, check_no)
  59. values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
  60. #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
  61. #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
  62. #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
  63. #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
  64. #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
  65. #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
  66. #{debitId,jdbcType=INTEGER}, #{targetType,jdbcType=INTEGER}, #{liquidationStatus,jdbcType=INTEGER},
  67. #{remarks,jdbcType=VARCHAR}, #{checkNo,jdbcType=VARCHAR})
  68. </insert>
  69. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  70. insert into expense_account
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="prid != null">
  73. prid,
  74. </if>
  75. <if test="orderNo != null">
  76. order_no,
  77. </if>
  78. <if test="aid != null">
  79. aid,
  80. </if>
  81. <if test="aname != null">
  82. aname,
  83. </if>
  84. <if test="type != null">
  85. `type`,
  86. </if>
  87. <if test="typeOther != null">
  88. type_other,
  89. </if>
  90. <if test="status != null">
  91. `status`,
  92. </if>
  93. <if test="processStatus != null">
  94. process_status,
  95. </if>
  96. <if test="totalAmount != null">
  97. total_amount,
  98. </if>
  99. <if test="attachmentUrl != null">
  100. attachment_url,
  101. </if>
  102. <if test="applyDep != null">
  103. apply_dep,
  104. </if>
  105. <if test="payDep != null">
  106. pay_dep,
  107. </if>
  108. <if test="eaaid != null">
  109. eaaid,
  110. </if>
  111. <if test="createTime != null">
  112. create_time,
  113. </if>
  114. <if test="districtName != null">
  115. district_name,
  116. </if>
  117. <if test="userNames != null">
  118. user_names,
  119. </if>
  120. <if test="releaseStart != null">
  121. release_start,
  122. </if>
  123. <if test="releaseEnd != null">
  124. release_end,
  125. </if>
  126. <if test="duration != null">
  127. duration,
  128. </if>
  129. <if test="examineName != null">
  130. examine_name,
  131. </if>
  132. <if test="settlementAmount != null">
  133. settlement_amount,
  134. </if>
  135. <if test="debitId != null">
  136. debit_id,
  137. </if>
  138. <if test="targetType != null">
  139. target_type,
  140. </if>
  141. <if test="liquidationStatus != null">
  142. liquidation_status,
  143. </if>
  144. <if test="remarks != null">
  145. remarks,
  146. </if>
  147. <if test="checkNo != null">
  148. check_no,
  149. </if>
  150. </trim>
  151. <trim prefix="values (" suffix=")" suffixOverrides=",">
  152. <if test="prid != null">
  153. #{prid,jdbcType=INTEGER},
  154. </if>
  155. <if test="orderNo != null">
  156. #{orderNo,jdbcType=VARCHAR},
  157. </if>
  158. <if test="aid != null">
  159. #{aid,jdbcType=VARCHAR},
  160. </if>
  161. <if test="aname != null">
  162. #{aname,jdbcType=VARCHAR},
  163. </if>
  164. <if test="type != null">
  165. #{type,jdbcType=INTEGER},
  166. </if>
  167. <if test="typeOther != null">
  168. #{typeOther,jdbcType=VARCHAR},
  169. </if>
  170. <if test="status != null">
  171. #{status,jdbcType=INTEGER},
  172. </if>
  173. <if test="processStatus != null">
  174. #{processStatus,jdbcType=INTEGER},
  175. </if>
  176. <if test="totalAmount != null">
  177. #{totalAmount,jdbcType=DECIMAL},
  178. </if>
  179. <if test="attachmentUrl != null">
  180. #{attachmentUrl,jdbcType=VARCHAR},
  181. </if>
  182. <if test="applyDep != null">
  183. #{applyDep,jdbcType=VARCHAR},
  184. </if>
  185. <if test="payDep != null">
  186. #{payDep,jdbcType=VARCHAR},
  187. </if>
  188. <if test="eaaid != null">
  189. #{eaaid,jdbcType=INTEGER},
  190. </if>
  191. <if test="createTime != null">
  192. #{createTime,jdbcType=TIMESTAMP},
  193. </if>
  194. <if test="districtName != null">
  195. #{districtName,jdbcType=VARCHAR},
  196. </if>
  197. <if test="userNames != null">
  198. #{userNames,jdbcType=VARCHAR},
  199. </if>
  200. <if test="releaseStart != null">
  201. #{releaseStart,jdbcType=TIMESTAMP},
  202. </if>
  203. <if test="releaseEnd != null">
  204. #{releaseEnd,jdbcType=TIMESTAMP},
  205. </if>
  206. <if test="duration != null">
  207. #{duration,jdbcType=DOUBLE},
  208. </if>
  209. <if test="examineName != null">
  210. #{examineName,jdbcType=VARCHAR},
  211. </if>
  212. <if test="settlementAmount != null">
  213. #{settlementAmount,jdbcType=DECIMAL},
  214. </if>
  215. <if test="debitId != null">
  216. #{debitId,jdbcType=INTEGER},
  217. </if>
  218. <if test="targetType != null">
  219. #{targetType,jdbcType=INTEGER},
  220. </if>
  221. <if test="liquidationStatus != null">
  222. #{liquidationStatus,jdbcType=INTEGER},
  223. </if>
  224. <if test="remarks != null">
  225. #{remarks,jdbcType=VARCHAR},
  226. </if>
  227. <if test="checkNo != null">
  228. #{checkNo,jdbcType=VARCHAR},
  229. </if>
  230. </trim>
  231. </insert>
  232. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccount">
  233. update expense_account
  234. <set>
  235. <if test="prid != null">
  236. prid = #{prid,jdbcType=INTEGER},
  237. </if>
  238. <if test="orderNo != null">
  239. order_no = #{orderNo,jdbcType=VARCHAR},
  240. </if>
  241. <if test="aid != null">
  242. aid = #{aid,jdbcType=VARCHAR},
  243. </if>
  244. <if test="aname != null">
  245. aname = #{aname,jdbcType=VARCHAR},
  246. </if>
  247. <if test="type != null">
  248. `type` = #{type,jdbcType=INTEGER},
  249. </if>
  250. <if test="typeOther != null">
  251. type_other = #{typeOther,jdbcType=VARCHAR},
  252. </if>
  253. <if test="status != null">
  254. `status` = #{status,jdbcType=INTEGER},
  255. </if>
  256. <if test="processStatus != null">
  257. process_status = #{processStatus,jdbcType=INTEGER},
  258. </if>
  259. <if test="totalAmount != null">
  260. total_amount = #{totalAmount,jdbcType=DECIMAL},
  261. </if>
  262. <if test="attachmentUrl != null">
  263. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  264. </if>
  265. <if test="applyDep != null">
  266. apply_dep = #{applyDep,jdbcType=VARCHAR},
  267. </if>
  268. <if test="payDep != null">
  269. pay_dep = #{payDep,jdbcType=VARCHAR},
  270. </if>
  271. <if test="eaaid != null">
  272. eaaid = #{eaaid,jdbcType=INTEGER},
  273. </if>
  274. <if test="createTime != null">
  275. create_time = #{createTime,jdbcType=TIMESTAMP},
  276. </if>
  277. <if test="districtName != null">
  278. district_name = #{districtName,jdbcType=VARCHAR},
  279. </if>
  280. <if test="userNames != null">
  281. user_names = #{userNames,jdbcType=VARCHAR},
  282. </if>
  283. <if test="releaseStart != null">
  284. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  285. </if>
  286. <if test="releaseEnd != null">
  287. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  288. </if>
  289. <if test="duration != null">
  290. duration = #{duration,jdbcType=DOUBLE},
  291. </if>
  292. <if test="examineName != null">
  293. examine_name = #{examineName,jdbcType=VARCHAR},
  294. </if>
  295. <if test="settlementAmount != null">
  296. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  297. </if>
  298. <if test="debitId != null">
  299. debit_id = #{debitId,jdbcType=INTEGER},
  300. </if>
  301. <if test="targetType != null">
  302. target_type = #{targetType,jdbcType=INTEGER},
  303. </if>
  304. <if test="liquidationStatus != null">
  305. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  306. </if>
  307. <if test="remarks != null">
  308. remarks = #{remarks,jdbcType=VARCHAR},
  309. </if>
  310. <if test="checkNo != null">
  311. check_no = #{checkNo,jdbcType=VARCHAR},
  312. </if>
  313. </set>
  314. where id = #{id,jdbcType=INTEGER}
  315. </update>
  316. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccount">
  317. update expense_account
  318. set prid = #{prid,jdbcType=INTEGER},
  319. order_no = #{orderNo,jdbcType=VARCHAR},
  320. aid = #{aid,jdbcType=VARCHAR},
  321. aname = #{aname,jdbcType=VARCHAR},
  322. `type` = #{type,jdbcType=INTEGER},
  323. type_other = #{typeOther,jdbcType=VARCHAR},
  324. `status` = #{status,jdbcType=INTEGER},
  325. process_status = #{processStatus,jdbcType=INTEGER},
  326. total_amount = #{totalAmount,jdbcType=DECIMAL},
  327. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  328. apply_dep = #{applyDep,jdbcType=VARCHAR},
  329. pay_dep = #{payDep,jdbcType=VARCHAR},
  330. eaaid = #{eaaid,jdbcType=INTEGER},
  331. create_time = #{createTime,jdbcType=TIMESTAMP},
  332. district_name = #{districtName,jdbcType=VARCHAR},
  333. user_names = #{userNames,jdbcType=VARCHAR},
  334. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  335. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  336. duration = #{duration,jdbcType=DOUBLE},
  337. examine_name = #{examineName,jdbcType=VARCHAR},
  338. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  339. debit_id = #{debitId,jdbcType=INTEGER},
  340. target_type = #{targetType,jdbcType=INTEGER},
  341. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  342. remarks = #{remarks,jdbcType=VARCHAR},
  343. check_no = #{checkNo,jdbcType=VARCHAR}
  344. where id = #{id,jdbcType=INTEGER}
  345. </update>
  346. <sql id="selectDtailsSql">
  347. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  348. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
  349. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  350. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  351. c.name payDepName,d.name ,d.bank ,d.accounts ,a.settlement_amount settlementAmount,
  352. a.liquidation_status liquidationStatus, a.remarks,a.check_no checkNo,
  353. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  354. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  355. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  356. </sql>
  357. <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  358. SELECT
  359. <include refid="selectDtailsSql"/>
  360. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  361. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  362. left join t_order_mid tm on a.order_no =tm.order_no
  363. WHERE a.id= #{id}
  364. </select>
  365. <select id="selectByCheckNo" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  366. SELECT
  367. <include refid="selectDtailsSql"/>
  368. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  369. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  370. left join t_order_mid tm on a.order_no =tm.order_no
  371. WHERE a.check_no= #{checkNo}
  372. </select>
  373. <select id="selectExpenseAccountList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountBo">
  374. select a.id,a.total_amount totalAmount,a.`type`,a.process_status processStatus,a.status,a.examine_name examineName,a.type_other typeOther,
  375. a.attachment_url attachmentUrl,a.target_type targetType , e.contract_no contractNo,tm.buyer_name buyerName ,a.check_no checkNo,
  376. <if test="processStatus ==1">
  377. eae.type eaeType,
  378. </if>
  379. f.name depName,d2.name financeName, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,a.aname,
  380. b.name appDepName, c.name payDepName
  381. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  382. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  383. left join t_order_mid tm on a.order_no =tm.order_no left join department f on d.department_id =f.id
  384. left join admin d2 on f.finance_id =d2.id
  385. <if test="processStatus ==1">
  386. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  387. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  388. </if>
  389. where 1=1
  390. <if test="processStatus ==2">
  391. and a.process_status>0
  392. <if test="examineStatus ==0">
  393. and a.status=1
  394. </if>
  395. <if test="examineStatus ==1">
  396. and a.status=2
  397. </if>
  398. </if>
  399. <if test=" aid !=null">
  400. and a.aid= #{aid}
  401. </if>
  402. <if test="processStatus ==1">
  403. and a.process_status>0
  404. <if test="examineStatus ==0">
  405. and a.process_status =eae.`type`
  406. </if>
  407. <if test="examineStatus ==1">
  408. and a.process_status >eae.`type`
  409. </if>
  410. </if>
  411. <if test="status != null">
  412. and a.status= #{status}
  413. </if>
  414. <if test="type != null">
  415. and a.type= #{type}
  416. </if>
  417. <if test="startTime !=null and endTime !=null">
  418. and a.create_time between #{startTime} and #{endTime}
  419. </if>
  420. <if test="depId != null">
  421. and d.department_id = #{depId}
  422. </if>
  423. <if test="contractNo != null">
  424. and e.contract_no = #{contractNo}
  425. </if>
  426. <if test="username != null">
  427. and tm.buyer_name like concat('%',#{username},'%')
  428. </if>
  429. <if test="applyDep != null">
  430. and a.apply_dep = #{applyDep}
  431. </if>
  432. <if test="payDep != null">
  433. and a.pay_dep = #{payDep}
  434. </if>
  435. order by a.status,a.create_time desc
  436. <if test="page_sql !=null">
  437. ${page_sql}
  438. </if>
  439. </select>
  440. <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
  441. select count(*)
  442. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  443. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  444. left join t_order_mid tm on a.order_no =tm.order_no
  445. <if test="processStatus ==1">
  446. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  447. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  448. </if>
  449. where 1=1
  450. <if test="processStatus ==2">
  451. and a.process_status>0
  452. <if test="examineStatus ==0">
  453. and a.status=1
  454. </if>
  455. <if test="examineStatus ==1">
  456. and a.status=2
  457. </if>
  458. </if>
  459. <if test=" aid !=null">
  460. and a.aid= #{aid}
  461. </if>
  462. <if test="processStatus ==1">
  463. and a.process_status>0
  464. <if test="examineStatus ==0">
  465. and a.process_status =eae.`type`
  466. </if>
  467. <if test="examineStatus ==1">
  468. and a.process_status >eae.`type`
  469. </if>
  470. </if>
  471. <if test="status != null">
  472. and a.status= #{status}
  473. </if>
  474. <if test="type != null">
  475. and a.type= #{type}
  476. </if>
  477. <if test="startTime !=null and endTime !=null">
  478. and a.create_time between #{startTime} and #{endTime}
  479. </if>
  480. <if test="depId != null">
  481. and d.department_id = #{depId}
  482. </if>
  483. <if test="contractNo != null">
  484. and e.contract_no = #{contractNo}
  485. </if>
  486. <if test="username != null">
  487. and tm.buyer_name like concat('%',#{username},'%')
  488. </if>
  489. <if test="applyDep != null">
  490. and a.apply_dep = #{applyDep}
  491. </if>
  492. <if test="payDep != null">
  493. and a.pay_dep = #{payDep}
  494. </if>
  495. </select>
  496. <select id="selectExpenseAccountTotalAmount" resultType="java.lang.Integer">
  497. select sum(a.total_amount) totalAmount
  498. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  499. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  500. left join t_order_mid tm on a.order_no =tm.order_no
  501. <if test="processStatus ==1">
  502. inner join (select eaid ,auditor,min(process_status)`type` from expense_account_examine
  503. where auditor= #{auditor} group by eaid) eae on a.id=eae.eaid
  504. </if>
  505. where 1=1
  506. <if test="processStatus ==2">
  507. and a.process_status>0
  508. <if test="examineStatus ==0">
  509. and a.status=1
  510. </if>
  511. <if test="examineStatus ==1">
  512. and a.status=2
  513. </if>
  514. </if>
  515. <if test=" aid !=null">
  516. and a.aid= #{aid}
  517. </if>
  518. <if test="processStatus ==1">
  519. and a.process_status>0
  520. <if test="examineStatus ==0">
  521. and a.process_status =eae.`type`
  522. </if>
  523. <if test="examineStatus ==1">
  524. and a.process_status >eae.`type`
  525. </if>
  526. </if>
  527. <if test="status != null">
  528. and a.status= #{status}
  529. </if>
  530. <if test="type != null">
  531. and a.type= #{type}
  532. </if>
  533. <if test="startTime !=null and endTime !=null">
  534. and a.create_time between #{startTime} and #{endTime}
  535. </if>
  536. <if test="depId != null">
  537. and d.department_id = #{depId}
  538. </if>
  539. <if test="contractNo != null">
  540. and e.contract_no = #{contractNo}
  541. </if>
  542. <if test="username != null">
  543. and tm.buyer_name like concat('%',#{username},'%')
  544. </if>
  545. <if test="applyDep != null">
  546. and a.apply_dep = #{applyDep}
  547. </if>
  548. <if test="payDep != null">
  549. and a.pay_dep = #{payDep}
  550. </if>
  551. </select>
  552. <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  553. SELECT
  554. <include refid="selectDtailsSql"/>
  555. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  556. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  557. left join t_order_mid tm on a.order_no =tm.order_no
  558. WHERE a.status= #{status}
  559. and a.prid= #{prid} and a.aid = #{aid}
  560. </select>
  561. <select id="selectByaidAndType" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  562. SELECT
  563. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  564. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,a.debit_id debitId,
  565. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  566. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  567. c.name payDepName,d.name ,d.bank ,d.accounts ,t0.amount settlementAmount,a.check_no checkNo,
  568. a.liquidation_status liquidationStatus, a.remarks,
  569. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  570. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  571. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  572. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  573. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  574. left join t_order_mid tm on a.order_no =tm.order_no
  575. left join (select debit_id ,sum(settlement_amount) amount from expense_account where debit_id is not null and
  576. id != #{id} group by debit_id )t0 on a.id =t0.debit_id
  577. WHERE a.status=2 and a.liquidation_status in (0,1,2)
  578. and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
  579. order by a.create_time desc
  580. </select>
  581. <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutMyEAStatistics">
  582. 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
  583. from expense_account a
  584. left join expense_account a2 on a.debit_id =a2.id left join admin ad on a.aid=ad.id
  585. where 1=1
  586. <if test="name != null">
  587. and a.aname like concat('%',#{name},'%')
  588. </if>
  589. <if test="depId != null">
  590. and ad.department_id = #{depId}
  591. </if>
  592. <if test="startTime != null and endTime != null">
  593. and a.create_time between #{startTime} and #{endTime}
  594. </if>
  595. </select>
  596. <select id="selectByDebitId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  597. select
  598. <include refid="Base_Column_List" />
  599. from expense_account
  600. where debit_id = #{debitId}
  601. </select>
  602. <select id="selectByCheckNoNot" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  603. select
  604. <include refid="Base_Column_List" />
  605. from expense_account
  606. where check_no =''
  607. </select>
  608. </mapper>