ExpenseAccountMapper.xml 18 KB

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