ExpenseAccountMapper.xml 45 KB

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