ExpenseAccountMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. </resultMap>
  30. <sql id="Base_Column_List">
  31. id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
  32. attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
  33. release_start, release_end, duration, examine_name, settlement_amount, debit_id,
  34. target_type
  35. </sql>
  36. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  37. select
  38. <include refid="Base_Column_List" />
  39. from expense_account
  40. where id = #{id,jdbcType=INTEGER}
  41. </select>
  42. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  43. delete from expense_account
  44. where id = #{id,jdbcType=INTEGER}
  45. </delete>
  46. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  47. insert into expense_account (prid, order_no, aid,
  48. aname, `type`, type_other,
  49. `status`, process_status, total_amount,
  50. attachment_url, apply_dep, pay_dep,
  51. eaaid, create_time, district_name,
  52. user_names, release_start, release_end,
  53. duration, examine_name, settlement_amount,
  54. debit_id, target_type)
  55. values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
  56. #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
  57. #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
  58. #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
  59. #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
  60. #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
  61. #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
  62. #{debitId,jdbcType=INTEGER}, #{targetType,jdbcType=INTEGER})
  63. </insert>
  64. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
  65. insert into expense_account
  66. <trim prefix="(" suffix=")" suffixOverrides=",">
  67. <if test="prid != null">
  68. prid,
  69. </if>
  70. <if test="orderNo != null">
  71. order_no,
  72. </if>
  73. <if test="aid != null">
  74. aid,
  75. </if>
  76. <if test="aname != null">
  77. aname,
  78. </if>
  79. <if test="type != null">
  80. `type`,
  81. </if>
  82. <if test="typeOther != null">
  83. type_other,
  84. </if>
  85. <if test="status != null">
  86. `status`,
  87. </if>
  88. <if test="processStatus != null">
  89. process_status,
  90. </if>
  91. <if test="totalAmount != null">
  92. total_amount,
  93. </if>
  94. <if test="attachmentUrl != null">
  95. attachment_url,
  96. </if>
  97. <if test="applyDep != null">
  98. apply_dep,
  99. </if>
  100. <if test="payDep != null">
  101. pay_dep,
  102. </if>
  103. <if test="eaaid != null">
  104. eaaid,
  105. </if>
  106. <if test="createTime != null">
  107. create_time,
  108. </if>
  109. <if test="districtName != null">
  110. district_name,
  111. </if>
  112. <if test="userNames != null">
  113. user_names,
  114. </if>
  115. <if test="releaseStart != null">
  116. release_start,
  117. </if>
  118. <if test="releaseEnd != null">
  119. release_end,
  120. </if>
  121. <if test="duration != null">
  122. duration,
  123. </if>
  124. <if test="examineName != null">
  125. examine_name,
  126. </if>
  127. <if test="settlementAmount != null">
  128. settlement_amount,
  129. </if>
  130. <if test="debitId != null">
  131. debit_id,
  132. </if>
  133. <if test="targetType != null">
  134. target_type,
  135. </if>
  136. </trim>
  137. <trim prefix="values (" suffix=")" suffixOverrides=",">
  138. <if test="prid != null">
  139. #{prid,jdbcType=INTEGER},
  140. </if>
  141. <if test="orderNo != null">
  142. #{orderNo,jdbcType=VARCHAR},
  143. </if>
  144. <if test="aid != null">
  145. #{aid,jdbcType=VARCHAR},
  146. </if>
  147. <if test="aname != null">
  148. #{aname,jdbcType=VARCHAR},
  149. </if>
  150. <if test="type != null">
  151. #{type,jdbcType=INTEGER},
  152. </if>
  153. <if test="typeOther != null">
  154. #{typeOther,jdbcType=VARCHAR},
  155. </if>
  156. <if test="status != null">
  157. #{status,jdbcType=INTEGER},
  158. </if>
  159. <if test="processStatus != null">
  160. #{processStatus,jdbcType=INTEGER},
  161. </if>
  162. <if test="totalAmount != null">
  163. #{totalAmount,jdbcType=DECIMAL},
  164. </if>
  165. <if test="attachmentUrl != null">
  166. #{attachmentUrl,jdbcType=VARCHAR},
  167. </if>
  168. <if test="applyDep != null">
  169. #{applyDep,jdbcType=VARCHAR},
  170. </if>
  171. <if test="payDep != null">
  172. #{payDep,jdbcType=VARCHAR},
  173. </if>
  174. <if test="eaaid != null">
  175. #{eaaid,jdbcType=INTEGER},
  176. </if>
  177. <if test="createTime != null">
  178. #{createTime,jdbcType=TIMESTAMP},
  179. </if>
  180. <if test="districtName != null">
  181. #{districtName,jdbcType=VARCHAR},
  182. </if>
  183. <if test="userNames != null">
  184. #{userNames,jdbcType=VARCHAR},
  185. </if>
  186. <if test="releaseStart != null">
  187. #{releaseStart,jdbcType=TIMESTAMP},
  188. </if>
  189. <if test="releaseEnd != null">
  190. #{releaseEnd,jdbcType=TIMESTAMP},
  191. </if>
  192. <if test="duration != null">
  193. #{duration,jdbcType=DOUBLE},
  194. </if>
  195. <if test="examineName != null">
  196. #{examineName,jdbcType=VARCHAR},
  197. </if>
  198. <if test="settlementAmount != null">
  199. #{settlementAmount,jdbcType=DECIMAL},
  200. </if>
  201. <if test="debitId != null">
  202. #{debitId,jdbcType=INTEGER},
  203. </if>
  204. <if test="targetType != null">
  205. #{targetType,jdbcType=INTEGER},
  206. </if>
  207. </trim>
  208. </insert>
  209. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccount">
  210. update expense_account
  211. <set>
  212. <if test="prid != null">
  213. prid = #{prid,jdbcType=INTEGER},
  214. </if>
  215. <if test="orderNo != null">
  216. order_no = #{orderNo,jdbcType=VARCHAR},
  217. </if>
  218. <if test="aid != null">
  219. aid = #{aid,jdbcType=VARCHAR},
  220. </if>
  221. <if test="aname != null">
  222. aname = #{aname,jdbcType=VARCHAR},
  223. </if>
  224. <if test="type != null">
  225. `type` = #{type,jdbcType=INTEGER},
  226. </if>
  227. <if test="typeOther != null">
  228. type_other = #{typeOther,jdbcType=VARCHAR},
  229. </if>
  230. <if test="status != null">
  231. `status` = #{status,jdbcType=INTEGER},
  232. </if>
  233. <if test="processStatus != null">
  234. process_status = #{processStatus,jdbcType=INTEGER},
  235. </if>
  236. <if test="totalAmount != null">
  237. total_amount = #{totalAmount,jdbcType=DECIMAL},
  238. </if>
  239. <if test="attachmentUrl != null">
  240. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  241. </if>
  242. <if test="applyDep != null">
  243. apply_dep = #{applyDep,jdbcType=VARCHAR},
  244. </if>
  245. <if test="payDep != null">
  246. pay_dep = #{payDep,jdbcType=VARCHAR},
  247. </if>
  248. <if test="eaaid != null">
  249. eaaid = #{eaaid,jdbcType=INTEGER},
  250. </if>
  251. <if test="createTime != null">
  252. create_time = #{createTime,jdbcType=TIMESTAMP},
  253. </if>
  254. <if test="districtName != null">
  255. district_name = #{districtName,jdbcType=VARCHAR},
  256. </if>
  257. <if test="userNames != null">
  258. user_names = #{userNames,jdbcType=VARCHAR},
  259. </if>
  260. <if test="releaseStart != null">
  261. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  262. </if>
  263. <if test="releaseEnd != null">
  264. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  265. </if>
  266. <if test="duration != null">
  267. duration = #{duration,jdbcType=DOUBLE},
  268. </if>
  269. <if test="examineName != null">
  270. examine_name = #{examineName,jdbcType=VARCHAR},
  271. </if>
  272. <if test="settlementAmount != null">
  273. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  274. </if>
  275. <if test="debitId != null">
  276. debit_id = #{debitId,jdbcType=INTEGER},
  277. </if>
  278. <if test="targetType != null">
  279. target_type = #{targetType,jdbcType=INTEGER},
  280. </if>
  281. </set>
  282. where id = #{id,jdbcType=INTEGER}
  283. </update>
  284. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.ExpenseAccount">
  285. update expense_account
  286. set prid = #{prid,jdbcType=INTEGER},
  287. order_no = #{orderNo,jdbcType=VARCHAR},
  288. aid = #{aid,jdbcType=VARCHAR},
  289. aname = #{aname,jdbcType=VARCHAR},
  290. `type` = #{type,jdbcType=INTEGER},
  291. type_other = #{typeOther,jdbcType=VARCHAR},
  292. `status` = #{status,jdbcType=INTEGER},
  293. process_status = #{processStatus,jdbcType=INTEGER},
  294. total_amount = #{totalAmount,jdbcType=DECIMAL},
  295. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  296. apply_dep = #{applyDep,jdbcType=VARCHAR},
  297. pay_dep = #{payDep,jdbcType=VARCHAR},
  298. eaaid = #{eaaid,jdbcType=INTEGER},
  299. create_time = #{createTime,jdbcType=TIMESTAMP},
  300. district_name = #{districtName,jdbcType=VARCHAR},
  301. user_names = #{userNames,jdbcType=VARCHAR},
  302. release_start = #{releaseStart,jdbcType=TIMESTAMP},
  303. release_end = #{releaseEnd,jdbcType=TIMESTAMP},
  304. duration = #{duration,jdbcType=DOUBLE},
  305. examine_name = #{examineName,jdbcType=VARCHAR},
  306. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  307. debit_id = #{debitId,jdbcType=INTEGER},
  308. target_type = #{targetType,jdbcType=INTEGER}
  309. where id = #{id,jdbcType=INTEGER}
  310. </update>
  311. <sql id="selectDtailsSql">
  312. a.id, a.prid, a.order_no orderNo, o.contract_no contractNo ,tm.buyer_name buyerName, a.aid, a.aname, a.`type`,
  313. a.type_other typeOther , a.status,a.process_status processStatus,a.total_amount totalAmount,
  314. a.attachment_url attachmentUrl,a.apply_dep applyDep, a.pay_dep payDep, a.eaaid,a.district_name districtName,
  315. a.user_names userNames,a.create_time, a.release_start,a.release_end, a.duration,b.name appDepName,
  316. c.name payDepName,d.name ,d.bank ,d.accounts ,a.settlement_amount settlementAmount,
  317. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,
  318. date_format(a.release_start,'%Y-%m-%d %H:%i:%S')releaseStartStr,
  319. date_format(a.release_end,'%Y-%m-%d %H:%i:%S')releaseEndStr
  320. </sql>
  321. <select id="selectByid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  322. SELECT
  323. <include refid="selectDtailsSql"/>
  324. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  325. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  326. left join t_order_mid tm on a.order_no =tm.order_no
  327. WHERE a.id= #{id}
  328. </select>
  329. <select id="selectExpenseAccountList" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccountBo">
  330. select a.id,a.total_amount totalAmount,a.`type`,a.process_status processStatus,a.status,a.examine_name examineName,
  331. a.target_type targetType , e.contract_no contractNo,tm.buyer_name buyerName ,f.name depName,d2.name financeName,
  332. date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimeStr,a.aname, b.name appDepName, c.name payDepName
  333. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  334. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  335. left join t_order_mid tm on a.order_no =tm.order_no left join department f on d.department_id =f.id
  336. left join admin d2 on f.finance_id =d2.id
  337. where 1=1
  338. <if test="processStatus ==0">
  339. and a.aid= #{aid}
  340. </if>
  341. <if test="processStatus ==1">
  342. and a.process_status>0
  343. and a.status =1
  344. and d.superior_id =#{aid}
  345. </if>
  346. <if test="status != null">
  347. and a.status= #{status}
  348. </if>
  349. <if test="startTime !=null and endTime !=null">
  350. and a.create_time between #{startTime} and #{endTime}
  351. </if>
  352. <if test="depId != null">
  353. and d.department_id = #{depId}
  354. </if>
  355. <if test="orderNo != null">
  356. and a.order_no = #{orderNo}
  357. </if>
  358. <if test="username != null">
  359. and tm.buyer_name = #{username}
  360. </if>
  361. <if test="applyDep != null">
  362. and a.apply_dep = #{applyDep}
  363. </if>
  364. <if test="payDep != null">
  365. and a.pay_dep = #{payDep}
  366. </if>
  367. order by a.create_time desc
  368. <if test="page_sql !=null">
  369. ${page_sql}
  370. </if>
  371. </select>
  372. <select id="selectExpenseAccountCount" resultType="java.lang.Integer">
  373. select count(*)
  374. from expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  375. left join admin d on a.aid =d.id left join t_order_new e on a.order_no =e.order_no
  376. left join t_order_mid tm on a.order_no =tm.order_no
  377. where 1=1
  378. <if test="processStatus ==0">
  379. and a.aid= #{aid}
  380. </if>
  381. <if test="processStatus ==1">
  382. and a.process_status>0
  383. and a.status =1
  384. and d.superior_id =#{aid}
  385. </if>
  386. <if test="status != null">
  387. and a.status= #{status}
  388. </if>
  389. <if test="startTime !=null and endTime !=null">
  390. and a.create_time between #{startTime} and #{endTime}
  391. </if>
  392. <if test="depId != null">
  393. and d.department_id = #{depId}
  394. </if>
  395. <if test="orderNo != null">
  396. and a.order_no = #{orderNo}
  397. </if>
  398. <if test="username != null">
  399. and tm.buyer_name = #{username}
  400. </if>
  401. <if test="applyDep != null">
  402. and a.apply_dep = #{applyDep}
  403. </if>
  404. <if test="payDep != null">
  405. and a.pay_dep = #{payDep}
  406. </if>
  407. </select>
  408. <select id="selectByaidAndPrid" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  409. SELECT
  410. <include refid="selectDtailsSql"/>
  411. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  412. left join expense_account_private d on a.eaaid=d.id
  413. WHERE a.status= #{status}
  414. and a.prid= #{prid} and a.aid = #{aid}
  415. </select>
  416. <select id="selectByaidAndType" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  417. SELECT
  418. <include refid="selectDtailsSql"/>
  419. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  420. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  421. left join t_order_mid tm on a.order_no =tm.order_no
  422. WHERE a.status=2
  423. and a.aid= #{aid} and a.type= #{type} and a.pay_dep= #{depId}
  424. </select>
  425. <select id="selectStatistics" resultType="com.goafanti.expenseAccount.bo.OutExpenseAccount">
  426. SELECT
  427. <include refid="selectDtailsSql"/>
  428. FROM expense_account a left join department b on a.apply_dep =b.id left join department c on a.pay_dep =c.id
  429. left join expense_account_private d on a.eaaid=d.id left join t_order_new o on a.order_no =o.order_no
  430. left join t_order_mid tm on a.order_no =tm.order_no left join admin ad on a.aid=ad.id
  431. where a.status=2
  432. <if test="name != null">
  433. and ad.name like concat('%','y','%')
  434. </if>
  435. <if test="depId != null">
  436. and ad.department_id = #{depId}
  437. </if>
  438. <if test="startTime != null and endTime != null">
  439. and a.create_time between #{startTime} and #{endTime}
  440. </if>
  441. </select>
  442. </mapper>