ExpenseAccountMapper.xml 47 KB

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