ExpenseAccountMapper.xml 41 KB

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