DailyRecordPaymentDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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="cn.ourwill.module.house.dao.daily.DailyRecordPaymentDao">
  4. <resultMap type="cn.ourwill.module.house.entity.daily.DailyRecordPayment" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="house_id" property="houseId"/>
  7. <result column="htype" property="htype"/>
  8. <result column="uuid" property="uuid"/>
  9. <result column="recorder" property="recorder"/>
  10. <result column="count" property="count"/>
  11. <result column="type" property="type"/>
  12. <result column="sub_type" property="subType"/>
  13. <result column="pay_time" property="payTime"/>
  14. <result column="price" property="price"/>
  15. <result column="unit" property="unit"/>
  16. <result column="number" property="number"/>
  17. <result column="pay_content" property="payContent"/>
  18. <result column="c_id" property="cId"/>
  19. <result column="c_time" property="cTime"/>
  20. <result column="u_id" property="uId"/>
  21. <result column="u_time" property="uTime"/>
  22. <result column="version" property="version"/>
  23. </resultMap>
  24. <resultMap type="cn.ourwill.module.house.entity.daily.DailyRecordPayment" id="mapForStatistics">
  25. <result column="grain_id" property="grainId"/>
  26. <result column="grain_name" property="grainName"/>
  27. <result column="feeType" property="feeType"/>
  28. <result column="fee" property="fee"/>
  29. <result column="feeDate" property="feeDate"/>
  30. </resultMap>
  31. <sql id="columns">
  32. id ,
  33. house_id ,
  34. htype ,
  35. uuid ,
  36. recorder ,
  37. `count` ,
  38. `type` ,
  39. sub_type ,
  40. pay_time ,
  41. price ,
  42. unit ,
  43. `number` ,
  44. pay_content ,
  45. c_id ,
  46. c_time ,
  47. u_id ,
  48. u_time ,
  49. version
  50. </sql>
  51. <sql id="joinCols">
  52. </sql>
  53. <select id="get" resultMap="baseMap">
  54. SELECT
  55. <include refid="columns"/>
  56. FROM daily_record_payment a
  57. <include refid="joinCols"/>
  58. WHERE a.id = #{id}
  59. </select>
  60. <select id="getByUuid" resultMap="baseMap">
  61. SELECT
  62. <include refid="columns"/>
  63. FROM daily_record_payment a
  64. <include refid="joinCols"/>
  65. WHERE a.uuid = #{uuid}
  66. </select>
  67. <select id="findNoUuidList" resultMap="baseMap">
  68. SELECT
  69. <include refid="columns"/>
  70. FROM daily_record_payment a
  71. <include refid="joinCols"/>
  72. WHERE a.uuid is null or trim(a.uuid) = '';
  73. </select>
  74. <select id="findStatisticscInfo" resultMap="mapForStatistics">
  75. SELECT
  76. sg.id AS grain_id,
  77. sg.name AS grain_name,
  78. sdd.name AS feeType,
  79. sum(drp.count) AS fee,
  80. date_format(drp.pay_time, '%Y-%m') AS feeDate
  81. FROM daily_record_payment drp
  82. LEFT JOIN sys_dic_data sdd ON sdd.id = drp.type
  83. LEFT JOIN house_info sh ON sh.id = drp.house_id
  84. LEFT JOIN sys_grain sg ON sg.id = sh.grain_id
  85. <where>
  86. sg.id IS NOT NULL
  87. AND date_format(drp.pay_time, '%Y-%m') IS NOT NULL
  88. AND drp.count IS NOT NULL
  89. <if test="grainId != null and grainId != ''">
  90. and sg.id = #{grainId}
  91. </if>
  92. <if test="cityId != null and cityId != ''">
  93. and sg.parentId = #{cityId}
  94. </if>
  95. <if test="dateStart != null and dateStart != ''">
  96. and date_format(drp.pay_time, '%Y-%m-%d') &gt; date_format(#{dateStart}, '%Y-%m-%d')
  97. </if>
  98. <if test="dateEnd != null and dateEnd != ''">
  99. and date_format(drp.pay_time, '%Y-%m-%d') &lt; date_format(#{dateEnd}, '%Y-%m-%d')
  100. </if>
  101. </where>
  102. GROUP BY
  103. sg.name,
  104. date_format(drp.pay_time, '%Y-%m'),
  105. sdd.name
  106. <choose>
  107. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  108. ORDER BY ${page.orderBy}
  109. </when>
  110. <otherwise>
  111. </otherwise>
  112. </choose>
  113. </select>
  114. <select id="findList" resultMap="baseMap">
  115. SELECT
  116. <include refid="columns"/>
  117. FROM daily_record_payment a
  118. <include refid="joinCols"/>
  119. <where>
  120. <if test="id !=null">
  121. and id = #{id}
  122. </if>
  123. <if test="houseId !=null">
  124. and house_id = #{houseId}
  125. </if>
  126. <if test="htype !=null">
  127. and htype = #{htype}
  128. </if>
  129. <if test="uuid !=null">
  130. and uuid = #{uuid}
  131. </if>
  132. <if test="recorder !=null">
  133. and recorder = #{recorder}
  134. </if>
  135. <if test="count !=null">
  136. and `count` = #{count}
  137. </if>
  138. <if test="type !=null">
  139. and `type` = #{type}
  140. </if>
  141. <if test="subType !=null">
  142. and sub_type = #{subType}
  143. </if>
  144. <if test="payTime !=null">
  145. and pay_time = #{payTime}
  146. </if>
  147. <if test="searchStartDate !=null">
  148. and STR_TO_DATE(pay_time, '%Y-%m-%d') <![CDATA[ >= ]]> #{searchStartDate}
  149. </if>
  150. <if test="searchEndDate !=null">
  151. and STR_TO_DATE(pay_time, '%Y-%m-%d') &lt;= #{searchEndDate}
  152. </if>
  153. <if test="price !=null">
  154. and price = #{price}
  155. </if>
  156. <if test="unit !=null">
  157. and unit = #{unit}
  158. </if>
  159. <if test="number !=null">
  160. and `number` = #{number}
  161. </if>
  162. <if test="payContent !=null">
  163. and pay_content = #{payContent}
  164. </if>
  165. <if test="cId !=null">
  166. and c_id = #{cId}
  167. </if>
  168. <if test="cTime !=null">
  169. and c_time = #{cTime}
  170. </if>
  171. <if test="uId !=null">
  172. and u_id = #{uId}
  173. </if>
  174. <if test="uTime !=null">
  175. and u_time = #{uTime}
  176. </if>
  177. <if test="version !=null">
  178. and version = #{version}
  179. </if>
  180. </where>
  181. <choose>
  182. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  183. ORDER BY ${page.orderBy}
  184. </when>
  185. <otherwise>
  186. </otherwise>
  187. </choose>
  188. </select>
  189. <select id="findAllList" resultMap="baseMap">
  190. SELECT
  191. <include refid="columns"/>
  192. FROM daily_record_payment a
  193. <include refid="joinCols"/>
  194. <where>
  195. <if test="id !=null">
  196. and id = #{id}
  197. </if>
  198. <if test="houseId !=null">
  199. and house_id = #{houseId}
  200. </if>
  201. <if test="htype !=null">
  202. and htype = #{htype}
  203. </if>
  204. <if test="uuid !=null">
  205. and uuid = #{uuid}
  206. </if>
  207. <if test="recorder !=null">
  208. and recorder = #{recorder}
  209. </if>
  210. <if test="count !=null">
  211. and `count` = #{count}
  212. </if>
  213. <if test="type !=null">
  214. and `type` = #{type}
  215. </if>
  216. <if test="subType !=null">
  217. and sub_type = #{subType}
  218. </if>
  219. <if test="payTime !=null">
  220. and pay_time = #{payTime}
  221. </if>
  222. <if test="price !=null">
  223. and price = #{price}
  224. </if>
  225. <if test="unit !=null">
  226. and unit = #{unit}
  227. </if>
  228. <if test="number !=null">
  229. and `number` = #{number}
  230. </if>
  231. <if test="payContent !=null">
  232. and pay_content = #{payContent}
  233. </if>
  234. <if test="cId !=null">
  235. and c_id = #{cId}
  236. </if>
  237. <if test="cTime !=null">
  238. and c_time = #{cTime}
  239. </if>
  240. <if test="uId !=null">
  241. and u_id = #{uId}
  242. </if>
  243. <if test="uTime !=null">
  244. and u_time = #{uTime}
  245. </if>
  246. <if test="version !=null">
  247. and version = #{version}
  248. </if>
  249. </where>
  250. <choose>
  251. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  252. ORDER BY ${page.orderBy}
  253. </when>
  254. <otherwise>
  255. </otherwise>
  256. </choose>
  257. </select>
  258. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  259. parameterType="cn.ourwill.module.house.entity.daily.DailyRecordPayment">
  260. INSERT INTO daily_record_payment
  261. <trim prefix="(" suffix=")" suffixOverrides=",">
  262. <!-- <if test=" id != null">
  263. id,
  264. </if>-->
  265. <if test=" houseId != null">
  266. house_id,
  267. </if>
  268. <if test=" htype != null">
  269. htype,
  270. </if>
  271. <if test=" uuid != null">
  272. uuid,
  273. </if>
  274. <if test=" recorder != null">
  275. recorder,
  276. </if>
  277. <if test=" count != null">
  278. `count`,
  279. </if>
  280. <if test=" type != null">
  281. `type`,
  282. </if>
  283. <if test=" subType != null">
  284. sub_type,
  285. </if>
  286. <if test=" payTime != null">
  287. pay_time,
  288. </if>
  289. <if test=" price != null">
  290. price,
  291. </if>
  292. <if test=" unit != null">
  293. unit,
  294. </if>
  295. <if test=" number != null">
  296. `number`,
  297. </if>
  298. <if test=" payContent != null">
  299. pay_content,
  300. </if>
  301. <if test=" cId != null">
  302. c_id,
  303. </if>
  304. <if test=" cTime != null">
  305. c_time,
  306. </if>
  307. <if test=" uId != null">
  308. u_id,
  309. </if>
  310. <if test=" uTime != null">
  311. u_time,
  312. </if>
  313. <if test=" version != null">
  314. version
  315. </if>
  316. </trim>
  317. <trim prefix="values (" suffix=")" suffixOverrides=",">
  318. <!--<if test=" id != null">
  319. #{id}, </if>-->
  320. <if test=" houseId != null">
  321. #{houseId}, </if>
  322. <if test=" htype != null">
  323. #{htype}, </if>
  324. <if test=" uuid != null">
  325. #{uuid}, </if>
  326. <if test=" recorder != null">
  327. #{recorder}, </if>
  328. <if test=" count != null">
  329. #{count}, </if>
  330. <if test=" type != null">
  331. #{type}, </if>
  332. <if test=" subType != null">
  333. #{subType}, </if>
  334. <if test=" payTime != null">
  335. #{payTime}, </if>
  336. <if test=" price != null">
  337. #{price}, </if>
  338. <if test=" unit != null">
  339. #{unit}, </if>
  340. <if test=" number != null">
  341. #{number}, </if>
  342. <if test=" payContent != null">
  343. #{payContent}, </if>
  344. <if test=" cId != null">
  345. #{cId}, </if>
  346. <if test=" cTime != null">
  347. #{cTime}, </if>
  348. <if test=" uId != null">
  349. #{uId}, </if>
  350. <if test=" uTime != null">
  351. #{uTime}, </if>
  352. <if test=" version != null">
  353. #{version} </if>
  354. </trim>
  355. </insert>
  356. <update id="update" parameterType="cn.ourwill.module.house.entity.daily.DailyRecordPayment">
  357. UPDATE daily_record_payment <set>
  358. <if test="id != null">
  359. id= #{id} ,
  360. </if>
  361. <if test="houseId != null">
  362. house_id= #{houseId} ,
  363. </if>
  364. <if test="htype != null">
  365. htype= #{htype} ,
  366. </if>
  367. <if test="uuid != null">
  368. uuid= #{uuid} ,
  369. </if>
  370. <if test="recorder != null">
  371. recorder= #{recorder} ,
  372. </if>
  373. <if test="count != null">
  374. `count`= #{count} ,
  375. </if>
  376. <if test="type != null">
  377. `type`= #{type} ,
  378. </if>
  379. <if test="subType != null">
  380. sub_type= #{subType} ,
  381. </if>
  382. <if test="payTime != null">
  383. pay_time= #{payTime} ,
  384. </if>
  385. <if test="price != null">
  386. price= #{price} ,
  387. </if>
  388. <if test="unit != null">
  389. unit= #{unit} ,
  390. </if>
  391. <if test="number != null">
  392. `number`= #{number} ,
  393. </if>
  394. <if test="payContent != null">
  395. pay_content= #{payContent} ,
  396. </if>
  397. <if test="cId != null">
  398. c_id= #{cId} ,
  399. </if>
  400. <if test="cTime != null">
  401. c_time= #{cTime} ,
  402. </if>
  403. <if test="uId != null">
  404. u_id= #{uId} ,
  405. </if>
  406. <if test="uTime != null">
  407. u_time= #{uTime} ,
  408. </if>
  409. <if test="version != null">
  410. version= #{version}
  411. </if>
  412. </set>
  413. WHERE id = #{id}
  414. </update>
  415. <update id="updateByUuid" parameterType="cn.ourwill.module.house.entity.daily.DailyRecordPayment">
  416. UPDATE daily_record_payment <set>
  417. <if test="houseId != null">
  418. house_id= #{houseId} ,
  419. </if>
  420. <if test="htype != null">
  421. htype= #{htype} ,
  422. </if>
  423. <if test="recorder != null">
  424. recorder= #{recorder} ,
  425. </if>
  426. <if test="count != null">
  427. `count`= #{count} ,
  428. </if>
  429. <if test="type != null">
  430. `type`= #{type} ,
  431. </if>
  432. <if test="subType != null">
  433. sub_type= #{subType} ,
  434. </if>
  435. <if test="payTime != null">
  436. pay_time= #{payTime} ,
  437. </if>
  438. <if test="price != null">
  439. price= #{price} ,
  440. </if>
  441. <if test="unit != null">
  442. unit= #{unit} ,
  443. </if>
  444. <if test="number != null">
  445. `number`= #{number} ,
  446. </if>
  447. <if test="payContent != null">
  448. pay_content= #{payContent} ,
  449. </if>
  450. <if test="cId != null">
  451. c_id= #{cId} ,
  452. </if>
  453. <if test="cTime != null">
  454. c_time= #{cTime} ,
  455. </if>
  456. <if test="uId != null">
  457. u_id= #{uId} ,
  458. </if>
  459. <if test="uTime != null">
  460. u_time= #{uTime} ,
  461. </if>
  462. <if test="version != null">
  463. version= #{version}
  464. </if>
  465. </set>
  466. WHERE uuid = #{uuid}
  467. </update>
  468. <delete id="deleteById" parameterType="java.lang.Long">
  469. DELETE FROM daily_record_payment WHERE id = #{id}
  470. </delete>
  471. <delete id="deleteByIds" parameterType="java.util.List">
  472. DELETE FROM daily_record_payment WHERE id IN
  473. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  474. #{item}
  475. </foreach>
  476. </delete>
  477. <select id="findByHouseIdNoPage" resultMap="baseMap">
  478. SELECT *
  479. FROM daily_record_payment a
  480. where house_id=#{houseId}
  481. <if test="cTime != null">
  482. AND pay_time <![CDATA[ <= ]]> #{cTime}
  483. </if>
  484. </select>
  485. <select id="findByHouseId" resultMap="baseMap">
  486. SELECT SUM(number)
  487. FROM daily_record_payment
  488. where house_id=#{houseId}
  489. <if test="payContent != null">
  490. AND pay_content= #{payContent}
  491. </if>
  492. </select>
  493. <delete id="deletePaymentByHouseId">
  494. DELETE FROM daily_record_payment
  495. WHERE house_id = #{houseId}
  496. <if test="cTime != null">
  497. AND pay_time <![CDATA[ <= ]]> #{cTime}
  498. </if>
  499. </delete>
  500. </mapper>