ExpenseAccountMapper.xml 46 KB

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