PrjContractDao.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.liang.dao.PrjContractDao">
  4. <resultMap type="com.liang.entity.PrjContract" id="PrjContractMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="htmc" column="HTMC" jdbcType="VARCHAR"/>
  7. <result property="wj" column="WJ" jdbcType="VARCHAR"/>
  8. <result property="htje" column="HTJE" jdbcType="NUMERIC"/>
  9. <result property="cjr" column="CJR" jdbcType="INTEGER"/>
  10. <result property="cjsj" column="CJSJ" jdbcType="TIMESTAMP"/>
  11. <result property="rws" column="RWS" jdbcType="INTEGER"/>
  12. </resultMap>
  13. <!--查询单个-->
  14. <select id="queryById" resultMap="PrjContractMap">
  15. select c.*, x.ZWMC as RWSMC, u.name as CJRXM
  16. from prj_Contract c
  17. left join prj_Project x on x.ID = c.RWS
  18. left join sys_user_info u on u.user_id = c.CJR
  19. where c.ID = #{id}
  20. </select>
  21. <!--查询指定行数据-->
  22. <select id="queryAllByLimit" resultMap="PrjContractMap">
  23. select
  24. ID, HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL
  25. from prj_Contract
  26. <where>
  27. <if test="id != null">
  28. and ID = #{id}
  29. </if>
  30. <if test="htmc != null and htmc != ''">
  31. and HTMC = #{htmc}
  32. </if>
  33. <if test="wj != null and wj != ''">
  34. and WJ = #{wj}
  35. </if>
  36. <if test="htje != null">
  37. and HTJE = #{htje}
  38. </if>
  39. <if test="cjr != null">
  40. and CJR = #{cjr}
  41. </if>
  42. <if test="cjsj != null">
  43. and CJSJ = #{cjsj}
  44. </if>
  45. <if test="rws != null">
  46. and RWS = #{rws}
  47. </if>
  48. <if test="zbpc != null">
  49. and ZBPC = #{zbpc}
  50. </if>
  51. <if test="zxdw != null">
  52. and ZXDW = #{zxdw}
  53. </if>
  54. <if test="yszl != null and yszl != ''">
  55. and YSZL = #{yszl}
  56. </if>
  57. </where>
  58. limit #{pageable.offset}, #{pageable.pageSize}
  59. </select>
  60. <!--统计总行数-->
  61. <select id="count" resultType="java.lang.Long">
  62. select count(1)
  63. from prj_Contract
  64. <where>
  65. <if test="id != null">
  66. and ID = #{id}
  67. </if>
  68. <if test="htmc != null and htmc != ''">
  69. and HTMC = #{htmc}
  70. </if>
  71. <if test="wj != null and wj != ''">
  72. and WJ = #{wj}
  73. </if>
  74. <if test="htje != null">
  75. and HTJE = #{htje}
  76. </if>
  77. <if test="cjr != null">
  78. and CJR = #{cjr}
  79. </if>
  80. <if test="cjsj != null">
  81. and CJSJ = #{cjsj}
  82. </if>
  83. <if test="rws != null">
  84. and RWS = #{rws}
  85. </if>
  86. <if test="zbpc != null">
  87. and ZBPC = #{zbpc}
  88. </if>
  89. <if test="zxdw != null">
  90. and ZXDW = #{zxdw}
  91. </if>
  92. <if test="yszl != null and yszl != ''">
  93. and YSZL = #{yszl}
  94. </if>
  95. </where>
  96. </select>
  97. <!--新增所有列-->
  98. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  99. insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
  100. values (#{htmc}, #{wj}, #{htje}, #{cjr}, GETDATE(), #{rws},#{zbpc},#{zxdw},#{yszl})
  101. </insert>
  102. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  103. insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
  104. values
  105. <foreach collection="entities" item="entity" separator=",">
  106. (#{entity.htmc}, #{entity.wj}, #{entity.htje}, #{entity.cjr}, #{entity.cjsj}, #{entity.rws},#{entity.zbpc},#{entity.zxdw},#{entity.yszl})
  107. </foreach>
  108. </insert>
  109. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  110. insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
  111. values
  112. <foreach collection="entities" item="entity" separator=",">
  113. (#{entity.htmc}, #{entity.wj}, #{entity.htje}, #{entity.cjr}, #{entity.cjsj}, #{entity.rws},#{entity.zbpc},#{entity.zxdw},#{entity.yszl})
  114. </foreach>
  115. on duplicate key update
  116. HTMC = values(HTMC),
  117. WJ = values(WJ),
  118. HTJE = values(HTJE),
  119. CJR = values(CJR),
  120. CJSJ = values(CJSJ),
  121. RWS = values(RWS),
  122. ZBPC = values(ZBPC),
  123. ZXDW = values(ZXDW),
  124. YSZL = values(YSZL)
  125. </insert>
  126. <!--通过主键修改数据-->
  127. <update id="update">
  128. update prj_Contract
  129. set HTMC = #{htmc},
  130. WJ = #{wj},
  131. HTJE = #{htje},
  132. RWS = #{rws},
  133. YSZL = #{yszl},
  134. ZBPC = #{zbpc},
  135. ZXDW = #{zxdw}
  136. where ID = #{id}
  137. </update>
  138. <!--通过主键删除-->
  139. <delete id="deleteById">
  140. delete from prj_Contract where ID = #{id}
  141. </delete>
  142. <!--批量删除合同-->
  143. <delete id="batchDelete" parameterType="java.util.ArrayList">
  144. delete from prj_Contract
  145. where ID in
  146. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  147. #{item}
  148. </foreach>
  149. </delete>
  150. <!--合同列表-->
  151. <select id="getContractList" resultMap="PrjContractMap" parameterType="map">
  152. select c.*, x.ZWMC as RWSMC, u.name as CJRXM
  153. from prj_Contract c
  154. left join prj_Project x on x.ID = c.RWS
  155. left join sys_user_info u on u.user_id = c.CJR
  156. where 1 = 1
  157. <if test="htmc != null and htmc != ''">
  158. and c.HTMC like '%'+#{htmc}+'%'
  159. </if>
  160. <if test="rws != null and rws != ''">
  161. and c.RWS = #{rws}
  162. </if>
  163. <if test="rwsmc != null and rwsmc != ''">
  164. and x.ZWMC like '%'+#{rwsmc}+'%'
  165. </if>
  166. <choose>
  167. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  168. order by ${sortName} ${sortOrder}
  169. </when>
  170. <otherwise>
  171. order by c.ID asc
  172. </otherwise>
  173. </choose>
  174. </select>
  175. </mapper>