BisInspAllRlationDao.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.BisInspAllRlationDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspAllRlation" id="bisInspAllRlationResultMap">
  5. <result property="persid" column="PERSID"/>
  6. <result property="id" column="ID"/>
  7. <result property="pertype" column="PERTYPE"/>
  8. <result property="impData" column="IMP_DATA"/>
  9. <result property="orgId" column="ORG_ID"/>
  10. <result property="adCode" column="AD_CODE"/>
  11. <result property="type" column="TYPE"/>
  12. </resultMap>
  13. <sql id="table_columns">
  14. PERSID,
  15. ID,
  16. PERTYPE,
  17. IMP_DATA,ORG_ID,AD_CODE,TYPE
  18. </sql>
  19. <sql id="entity_properties">
  20. #{persid},
  21. #{id},
  22. #{pertype},
  23. #{impData},#{orgId},#{adCode},#{type}
  24. </sql>
  25. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  26. <sql id="page_where">
  27. <trim prefix="where" prefixOverrides="and | or ">
  28. <if test="id != null and id != ''">and ID = #{id}</if>
  29. <if test="persid != null and persid != ''">and PERSID = #{persid}</if>
  30. <if test="pertype != null and pertype != ''">and PERTYPE = #{pertype}</if>
  31. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  32. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  33. <choose>
  34. <when test="province != null and province != ''">
  35. and AD_CODE = #{province}
  36. </when>
  37. <otherwise>
  38. and AD_CODE is null
  39. </otherwise>
  40. </choose>
  41. </trim>
  42. </sql>
  43. <select id="get" resultMap="bisInspAllRlationResultMap" parameterType="String">
  44. select
  45. <include refid="table_columns"/>
  46. from BIS_INSP_ALL_RLATION where ID = #{id}
  47. </select>
  48. <select id="getBy" resultMap="bisInspAllRlationResultMap">
  49. select
  50. <include refid="table_columns"/>
  51. from BIS_INSP_ALL_RLATION n where n.id like '${id}%'
  52. <if test="pertype != null and pertype != ''">
  53. and n.pertype=#{pertype}
  54. </if>
  55. <if test="adCode !=null and adCode !=''">
  56. and n.AD_CODE=#{adCode}
  57. </if>
  58. <if test="orgId !=null and orgId !=''">
  59. and n.org_id=#{orgId}
  60. </if>
  61. and n.persid=#{persid}
  62. </select>
  63. <select id="findAll" resultMap="bisInspAllRlationResultMap">
  64. select
  65. <include refid="table_columns"/>
  66. from BIS_INSP_ALL_RLATION
  67. </select>
  68. <select id="findList" resultMap="bisInspAllRlationResultMap">
  69. select
  70. <include refid="table_columns"/>
  71. from BIS_INSP_ALL_RLATION
  72. <include refid="page_where"/>
  73. </select>
  74. <select id="selectCount" resultType="int">
  75. select count(ID) from BIS_INSP_ALL_RLATION
  76. <include refid="page_where"/>
  77. </select>
  78. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  79. insert into BIS_INSP_ALL_RLATION(
  80. <include refid="table_columns"/>
  81. )
  82. values (
  83. <include refid="entity_properties"/>
  84. )
  85. </insert>
  86. <delete id="delete" parameterType="java.lang.String">
  87. delete from BIS_INSP_ALL_RLATION where ID = #{id}
  88. </delete>
  89. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  90. delete from BIS_INSP_ALL_RLATION
  91. <where>
  92. <if test="id != null and id != ''">and ID = #{id}</if>
  93. <if test="persid != null and persid != ''">and PERSID = #{persid}</if>
  94. <if test="pertype != null and pertype != ''">and PERTYPE = #{pertype}</if>
  95. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  96. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  97. </where>
  98. </delete>
  99. <update id="deleteInFlag" parameterType="java.lang.String">
  100. update BIS_INSP_ALL_RLATION set flag_valid = 0 where ID = #{id}
  101. </update>
  102. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  103. update BIS_INSP_ALL_RLATION
  104. <trim prefix="set" suffixOverrides=",">
  105. <if test="pertype != null and pertype != ''">PERTYPE = #{pertype},</if>
  106. <if test="impData != null and impData != ''">IMP_DATA = #{impData},</if>
  107. <if test="adCode !=null and adCode !=''">
  108. AD_CODE=#{adCode},
  109. </if>
  110. <if test="orgId !=null and orgId !=''">
  111. org_id=#{orgId},
  112. </if>
  113. </trim>
  114. <where>ID = #{id} and PERSID = #{persid}</where>
  115. </update>
  116. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspAllRlation">
  117. update BIS_INSP_ALL_RLATION
  118. <trim prefix="set" suffixOverrides=",">
  119. <if test="id != null and id != ''">ID = #{id},</if>
  120. <if test="persid != null and persid != ''">PERSID = #{persid},</if>
  121. <if test="pertype != null and pertype != ''">PERTYPE = #{pertype},</if>
  122. <if test="impData != null and impData != ''">IMP_DATA = #{impData},</if>
  123. <if test="adCode !=null and adCode !=''">
  124. AD_CODE=#{adCode},
  125. </if>
  126. <if test="orgId !=null and orgId !=''">
  127. org_id=#{orgId},
  128. </if>
  129. </trim>
  130. <include refid="page_where"/>
  131. </update>
  132. <!-- 其他自定义SQL -->
  133. <delete id="deleteMemberBy" parameterType="cn.com.goldenwater.dcproj.param.BisInspAllRlationParam">
  134. delete from BIS_INSP_ALL_RLATION where ID = #{id} AND PERSID = #{persid}
  135. </delete>
  136. <select id="getIdByPersid" resultType="java.lang.String">
  137. SELECT ID
  138. FROM BIS_INSP_ALL_RLATION
  139. WHERE PERSID = #{persid}
  140. <if test="id != null and id != ''">
  141. and ID like '%${id}%'
  142. </if>
  143. <if test="pType != null and pType != ''">
  144. and TYPE = #{pType}
  145. </if>
  146. </select>
  147. <select id="getPnmByPersid" resultType="java.lang.String">
  148. SELECT C.PNM
  149. FROM BIS_INSP_ALL_RLATION B
  150. JOIN BIS_INSP_ALL C ON B.ID = C.ID
  151. WHERE PERSID = #{persid}
  152. <if test="id != null and id != ''">
  153. and C.ID like '%${id}%'
  154. </if>
  155. <if test="orgId != null and orgId != '' ">
  156. AND B.ID LIKE '___${orgId}%'
  157. </if>
  158. <if test="pType != null and pType != ''">and B.ID like '${pType}%'</if>
  159. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  160. AND TO_DATE(TO_CHAR(C.STTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  161. AND TO_DATE(TO_CHAR(C.ENTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  162. </if>
  163. </select>
  164. <select id="getObjByPersid" resultType="java.lang.String">
  165. SELECT T.NAME
  166. FROM BIS_INSP_ALL_RLATION B
  167. JOIN BIS_INSP_ALL C ON B.ID = C.ID
  168. JOIN ATT_INSP_TYPE T ON SUBSTR(B.ID, 0, 3) = T.CODE
  169. WHERE PERSID = #{persid}
  170. <if test="id != null and id != ''">
  171. and C.ID like '%${id}%'
  172. </if>
  173. <if test="orgId != null and orgId != '' ">
  174. AND B.ID LIKE '___${orgId}%'
  175. </if>
  176. <if test="pType != null and pType != ''">and B.ID like '${pType}%'</if>
  177. <if test="sttm != null and sttm != '' and entm != null and entm != '' ">
  178. AND TO_DATE(TO_CHAR(C.STTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &gt;= TO_DATE(#{sttm}, 'YYYY-MM-DD')
  179. AND TO_DATE(TO_CHAR(C.ENTM, 'YYYY-MM-DD'), 'YYYY-MM-DD') &lt; TO_DATE(#{entm}, 'YYYY-MM-DD') + 1
  180. </if>
  181. </select>
  182. <select id="getPersNameById" resultType="java.util.Map">
  183. SELECT B.PERTYPE, C.PERS_NAME
  184. FROM BIS_INSP_ALL_RLATION B
  185. JOIN BIS_INSP_ALL_RLATION_PERS C ON B.PERSID = C.GUID
  186. WHERE B.ID like '%${id}%'
  187. <if test="pertype != null and pertype != ''">AND B.PERTYPE = #{pertype}</if>
  188. </select>
  189. <select id="getPersPhoneById" resultType="java.util.Map">
  190. SELECT B.PERTYPE, C.MOBILENUMB
  191. FROM BIS_INSP_ALL_RLATION B
  192. JOIN BIS_INSP_ALL_RLATION_PERS C ON B.PERSID = C.GUID
  193. WHERE B.ID like '%${id}%'
  194. <if test="pertype != null and pertype != ''">AND B.PERTYPE = #{pertype}</if>
  195. </select>
  196. <!-- 福建省 标准化示范工地 获取当前用户在所在督查组的身份 -->
  197. <select id="getPerTypeByUserIdandObjId" resultMap="bisInspAllRlationResultMap">
  198. select ar.* from bis_insp_all_rlation ar
  199. where type = #{pType} and org_id = #{orgId} and PERSID = #{persid}
  200. </select>
  201. </mapper>