ExpenseAccountMapper.xml 45 KB

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