ExpenseAccountMapper.xml 45 KB

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