TacInspBatchDao.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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
  40. <include refid="table_columns"/>
  41. from TAC_INSP_BATCH where ID = #{id}
  42. </select>
  43. <select id="getBy" resultMap="tacInspBatchResultMap">
  44. select
  45. <include refid="table_columns"/>
  46. from TAC_INSP_BATCH t
  47. <include refid="page_where"/>
  48. order by sn
  49. </select>
  50. <select id="findAll" resultMap="tacInspBatchResultMap">
  51. select
  52. <include refid="table_columns"/>
  53. from TAC_INSP_BATCH
  54. order by sn
  55. </select>
  56. <select id="findList" resultMap="tacInspBatchResultMap">
  57. select
  58. <include refid="table_columns"/>
  59. from TAC_INSP_BATCH t
  60. <include refid="page_where"/>
  61. </select>
  62. <select id="selectCount" resultType="int">
  63. select count(ID) from TAC_INSP_BATCH t
  64. <include refid="page_where"/>
  65. </select>
  66. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  67. insert into TAC_INSP_BATCH(
  68. <include refid="table_columns"/>
  69. )
  70. values (
  71. <include refid="entity_properties"/>
  72. )
  73. </insert>
  74. <delete id="delete" parameterType="java.lang.String">
  75. delete from TAC_INSP_BATCH where ID = #{id}
  76. </delete>
  77. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  78. delete from TAC_INSP_BATCH t
  79. <include refid="page_where"/>
  80. </delete>
  81. <update id="deleteInFlag" parameterType="java.lang.String">
  82. update TAC_INSP_BATCH set flag_valid = 0 where ID = #{id}
  83. </update>
  84. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  85. update TAC_INSP_BATCH
  86. <trim prefix="set" suffixOverrides=",">
  87. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  88. <if test="sn != null and sn != ''">SN = #{sn},</if>
  89. <if test="province != null ">PROVINCE = #{province},</if>
  90. </trim>
  91. <where>ID = #{id}</where>
  92. </update>
  93. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspBatch">
  94. update TAC_INSP_BATCH
  95. <trim prefix="set" suffixOverrides=",">
  96. <if test="batch != null and batch != ''">BATCH = #{batch},</if>
  97. <if test="sn != null and sn != ''">SN = #{sn},</if>
  98. <if test="province != null ">PROVINCE = #{province},</if>
  99. </trim>
  100. <include refid="page_where"/>
  101. </update>
  102. <!-- 其他自定义SQL -->
  103. <select id="getBatchListByYear" resultType="cn.com.goldenwater.dcproj.model.TacInspBatch"
  104. parameterType="cn.com.goldenwater.dcproj.param.TacInspBatchParam">
  105. SELECT * FROM TAC_INSP_BATCH T
  106. WHERE T.BATCH NOT IN (SELECT B.BATCH FROM TAC_INSP_YEAR_BATCH B WHERE B.YEAR = #{year}
  107. <include refid="choseSqlYear"/>
  108. )
  109. <include refid="choseSql"/>
  110. ORDER BY T.SN
  111. </select>
  112. <sql id="choseSqlYear">
  113. <trim>
  114. <choose>
  115. <when test="province !=null and province !=''">
  116. and b.province=#{province}
  117. </when>
  118. <otherwise>
  119. and b.province is null
  120. </otherwise>
  121. </choose>
  122. </trim>
  123. </sql>
  124. </mapper>