ExpenseAccountMapper.xml 14 KB

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