TaskAnnualReportMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.TaskAnnualReportMapper">
  4. <resultMap type="com.goafanti.common.model.TaskAnnualReport" id="TaskAnnualReportMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="uid" column="uid" jdbcType="VARCHAR"/>
  7. <result property="tid" column="tid" jdbcType="INTEGER"/>
  8. <result property="year" column="year" jdbcType="INTEGER"/>
  9. <result property="salesAmount" column="sales_amount" jdbcType="VARCHAR"/>
  10. <result property="researchAmount" column="research_amount" jdbcType="VARCHAR"/>
  11. <result property="aid" column="aid" jdbcType="VARCHAR"/>
  12. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  13. </resultMap>
  14. <sql id="TaskAnnualReportAllSql">
  15. id, uid, tid, year, sales_amount, research_amount, aid, create_time
  16. </sql>
  17. <!--查询单个-->
  18. <select id="queryById" resultMap="TaskAnnualReportMap">
  19. select
  20. <include refid="TaskAnnualReportAllSql"/>
  21. from task_annual_report
  22. where id = #{id}
  23. </select>
  24. <!--查询指定行数据-->
  25. <select id="findTaskAnnualReportList" resultMap="TaskAnnualReportMap">
  26. select
  27. <include refid="TaskAnnualReportAllSql"/>
  28. from task_annual_report
  29. <where>
  30. <if test="id != null">
  31. and id = #{id}
  32. </if>
  33. <if test="uid != null and uid != ''">
  34. and uid = #{uid}
  35. </if>
  36. <if test="tid != null">
  37. and tid = #{tid}
  38. </if>
  39. <if test="year != null">
  40. and year = #{year}
  41. </if>
  42. <if test="salesAmount != null">
  43. and sales_amount = #{salesAmount}
  44. </if>
  45. <if test="researchAmount != null">
  46. and research_amount = #{researchAmount}
  47. </if>
  48. <if test="aid != null and aid != ''">
  49. and aid = #{aid}
  50. </if>
  51. <if test="createTime != null">
  52. and create_time = #{createTime}
  53. </if>
  54. </where>
  55. <if test="page_sql != null">
  56. ${page_sql}
  57. </if>
  58. </select>
  59. <!--统计总行数-->
  60. <select id="findTaskAnnualReportCount" resultType="java.lang.Integer">
  61. select count(1)
  62. from task_annual_report
  63. <where>
  64. <if test="id != null">
  65. and id = #{id}
  66. </if>
  67. <if test="uid != null and uid != ''">
  68. and uid = #{uid}
  69. </if>
  70. <if test="tid != null">
  71. and tid = #{tid}
  72. </if>
  73. <if test="year != null">
  74. and year = #{year}
  75. </if>
  76. <if test="salesAmount != null">
  77. and sales_amount = #{salesAmount}
  78. </if>
  79. <if test="researchAmount != null">
  80. and research_amount = #{researchAmount}
  81. </if>
  82. <if test="aid != null and aid != ''">
  83. and aid = #{aid}
  84. </if>
  85. <if test="createTime != null">
  86. and create_time = #{createTime}
  87. </if>
  88. </where>
  89. </select>
  90. <!--新增所有列-->
  91. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  92. insert into task_annual_report(uid, tid, year, sales_amount, research_amount, aid, create_time)
  93. values (#{uid}, #{tid}, #{year}, #{salesAmount}, #{researchAmount}, #{aid}, #{createTime})
  94. </insert>
  95. <insert id="insertBatch">
  96. insert into task_annual_report(uid, tid, year, sales_amount, research_amount, aid, create_time)
  97. values
  98. <foreach collection="entities" item="entity" separator=",">
  99. (#{entity.uid}, #{entity.tid}, #{entity.year}, #{entity.salesAmount}, #{entity.researchAmount},
  100. #{entity.aid}, #{entity.createTime})
  101. </foreach>
  102. </insert>
  103. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  104. insert into task_annual_report(uid, tid, year, sales_amount, research_amount, aid, create_time)
  105. values
  106. <foreach collection="entities" item="entity" separator=",">
  107. (#{entity.uid}, #{entity.tid}, #{entity.year}, #{entity.salesAmount}, #{entity.researchAmount},
  108. #{entity.aid}, #{entity.createTime})
  109. </foreach>
  110. on duplicate key update
  111. uid = values(uid),
  112. tid = values(tid),
  113. year = values(year),
  114. sales_amount = values(sales_amount),
  115. research_amount = values(research_amount),
  116. aid = values(aid),
  117. create_time = values(create_time)
  118. </insert>
  119. <!--通过主键修改数据-->
  120. <update id="update">
  121. update task_annual_report
  122. <set>
  123. <if test="uid != null and uid != ''">
  124. uid = #{uid},
  125. </if>
  126. <if test="tid != null">
  127. tid = #{tid},
  128. </if>
  129. <if test="year != null">
  130. year = #{year},
  131. </if>
  132. <if test="salesAmount != null">
  133. sales_amount = #{salesAmount},
  134. </if>
  135. <if test="researchAmount != null">
  136. research_amount = #{researchAmount},
  137. </if>
  138. <if test="aid != null and aid != ''">
  139. aid = #{aid},
  140. </if>
  141. <if test="createTime != null">
  142. create_time = #{createTime},
  143. </if>
  144. </set>
  145. where id = #{id}
  146. </update>
  147. <!--通过主键删除-->
  148. <delete id="deleteById">
  149. delete
  150. from task_annual_report
  151. where id = #{id}
  152. </delete>
  153. <select id="selectByTidAndYear" resultMap="TaskAnnualReportMap">
  154. select
  155. <include refid="TaskAnnualReportAllSql"/>
  156. from task_annual_report
  157. where tid = #{tid} and year = #{year}
  158. </select>
  159. <select id="selectThreeYear" resultMap="TaskAnnualReportMap">
  160. select
  161. <include refid="TaskAnnualReportAllSql"/>
  162. from task_annual_report
  163. where tid = #{tid} and year in (#{year}-1,#{year}-2)
  164. </select>
  165. </mapper>