TacInspBatchDao.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.com.goldenwater.dcproj.dao.TacInspBatchDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.TacInspBatch" id="tacInspBatchResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="batch" column="BATCH"/>
  7. <result property="sn" column="SN"/>
  8. <result property="province" column="PROVINCE"/>
  9. </resultMap>
  10. <sql id="table_columns">
  11. ID,
  12. BATCH,
  13. SN,PROVINCE
  14. </sql>
  15. <sql id="entity_properties">
  16. #{id},
  17. #{batch},
  18. #{sn},#{province}
  19. </sql>
  20. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  21. <sql id="page_where">
  22. <trim prefix="where" prefixOverrides="and | or ">
  23. <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
  24. <if test="sn != null and sn != ''">and SN = #{sn}</if>
  25. <include refid="choseSql"/>
  26. </trim>
  27. </sql>
  28. <sql id="choseSql">
  29. <choose>
  30. <when test="province !=null and province !=''">
  31. AND t.PROVINCE=#{province}
  32. </when>
  33. <otherwise>
  34. AND t.PROVINCE is null
  35. </otherwise>
  36. </choose>
  37. </sql>
  38. <select id="get" resultMap="tacInspBatchResultMap" parameterType="String" >
  39. select <include refid="table_columns" /> from TAC_INSP_BATCH where ID = #{id}
  40. </select>
  41. <select id="getBy" resultMap="tacInspBatchResultMap">
  42. select <include refid="table_columns" /> from TAC_INSP_BATCH t <include refid="page_where" />
  43. order by sn
  44. </select>
  45. <select id="findAll" resultMap="tacInspBatchResultMap">
  46. select <include refid="table_columns" /> from TAC_INSP_BATCH
  47. order by sn
  48. </select>
  49. <select id="findList" resultMap="tacInspBatchResultMap">
  50. select <include refid="table_columns" /> from TAC_INSP_BATCH t <include refid="page_where" />
  51. </select>
  52. <select id="selectCount" resultType="int" >
  53. select count(ID) from TAC_INSP_BATCH t <include refid="page_where" />
  54. </select>
  55. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  56. insert into TAC_INSP_BATCH( <include refid="table_columns" /> )
  57. values ( <include refid="entity_properties" /> )
  58. </insert>
  59. <delete id="delete" parameterType="java.lang.String">
  60. delete from TAC_INSP_BATCH where ID = #{id}
  61. </delete>
  62. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  63. delete from TAC_INSP_BATCH t <include refid="page_where" />
  64. </delete>
  65. <update id="deleteInFlag" parameterType="java.lang.String">
  66. update TAC_INSP_BATCH set flag_valid = 0 where ID = #{id}
  67. </update>
  68. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  69. update TAC_INSP_BATCH
  70. <trim prefix="set" suffixOverrides=",">
  71. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  72. <if test="sn != null and sn != ''">SN = #{sn},</if>
  73. <if test="province != null ">PROVINCE = #{province},</if>
  74. </trim>
  75. <where>ID = #{id}</where>
  76. </update>
  77. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  78. update TAC_INSP_BATCH
  79. <trim prefix="set" suffixOverrides=",">
  80. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  81. <if test="sn != null and sn != ''">SN = #{sn},</if>
  82. <if test="province != null ">PROVINCE = #{province},</if>
  83. </trim>
  84. <include refid="page_where" />
  85. </update>
  86. <!-- 其他自定义SQL -->
  87. <select id="getBatchListByYear" resultType="cn.com.goldenwater.dcproj.model.TacInspBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspBatchParam">
  88. select * from TAC_INSP_BATCH t where t.batch not in (select b.batch from TAC_INSP_YEAR_BATCH b where b.year = #{year}
  89. <include refid="choseSqlYear"/>
  90. )
  91. <include refid="choseSql"/>
  92. order by t.sn
  93. </select>
  94. <sql id="choseSqlYear" >
  95. <trim>
  96. <choose>
  97. <when test="province !=null and province !=''">
  98. and b.province=#{province}
  99. </when>
  100. <otherwise>
  101. and b.province is null
  102. </otherwise>
  103. </choose>
  104. </trim>
  105. </sql>
  106. </mapper>