AttUserBaseDao.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.AttUserBaseDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.AttUserBase" id="attUserBaseResultMap">
  5. <result property="guid" column="GUID"/>
  6. <result property="userGuid" column="USER_GUID"/>
  7. <result property="userCode" column="USER_CODE"/>
  8. <result property="userName" column="USER_NAME"/>
  9. <result property="password" column="PASSWORD"/>
  10. <result property="userType" column="USER_TYPE"/>
  11. <result property="persId" column="PERS_ID"/>
  12. <result property="adminOrg" column="ADMIN_ORG"/>
  13. <result property="status" column="STATUS"/>
  14. <result property="modifier" column="MODIFIER"/>
  15. <result property="fromDate" column="FROM_DATE"/>
  16. <result property="toDate" column="TO_DATE"/>
  17. <result property="note" column="NOTE"/>
  18. <result property="nodeCode" column="NODE_CODE"/>
  19. <result property="isTempUser" column="IS_TEMP_USER"/>
  20. <result property="userEndDate" column="USER_END_DATE"/>
  21. </resultMap>
  22. <sql id="table_columns">
  23. GUID,
  24. USER_GUID,
  25. USER_CODE,
  26. USER_NAME,
  27. PASSWORD,
  28. USER_TYPE,
  29. PERS_ID,
  30. ADMIN_ORG,
  31. STATUS,
  32. MODIFIER,
  33. FROM_DATE,
  34. TO_DATE,
  35. NOTE,
  36. NODE_CODE,
  37. IS_TEMP_USER,
  38. USER_END_DATE
  39. </sql>
  40. <sql id="entity_properties">
  41. #{guid},
  42. #{userGuid},
  43. #{userCode},
  44. #{userName},
  45. #{password},
  46. #{userType},
  47. #{persId},
  48. #{adminOrg},
  49. #{status},
  50. #{modifier},
  51. #{fromDate},
  52. #{toDate},
  53. #{note},
  54. #{nodeCode},
  55. #{isTempUser},
  56. #{userEndDate}
  57. </sql>
  58. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  59. <sql id="page_where">
  60. <trim prefix="where" prefixOverrides="and | or ">
  61. <if test="userGuid != null and userGuid != ''">and USER_GUID = #{userGuid}</if>
  62. <if test="userCode != null and userCode != ''">and USER_CODE = #{userCode}</if>
  63. <if test="userName != null and userName != ''">and USER_NAME LIKE concat(concat('%',#{userName}),'%')</if>
  64. <if test="password != null and password != ''">and PASSWORD = #{password}</if>
  65. <if test="userType != null and userType != ''">and USER_TYPE = #{userType}</if>
  66. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  67. <if test="adminOrg != null and adminOrg != ''">and ADMIN_ORG = #{adminOrg}</if>
  68. <if test="status != null and status != ''">and STATUS = #{status}</if>
  69. <if test="modifier != null and modifier != ''">and MODIFIER = #{modifier}</if>
  70. <if test="fromDate != null">and FROM_DATE = #{fromDate}</if>
  71. <if test="toDate != null">and TO_DATE = #{toDate}</if>
  72. <if test="note != null and note != ''">and NOTE = #{note}</if>
  73. <if test="nodeCode != null and nodeCode != ''">and NODE_CODE = #{nodeCode}</if>
  74. <if test="isTempUser != null and isTempUser != ''">and IS_TEMP_USER = #{isTempUser}</if>
  75. <if test="userEndDate != null">and USER_END_DATE = #{userEndDate}</if>
  76. </trim>
  77. </sql>
  78. <select id="get" resultMap="attUserBaseResultMap" parameterType="String" >
  79. select <include refid="table_columns" /> from att_user_base where GUID = #{id}
  80. </select>
  81. <select id="getBy" resultMap="attUserBaseResultMap">
  82. select <include refid="table_columns" /> from att_user_base <include refid="page_where" />
  83. </select>
  84. <select id="findAll" resultMap="attUserBaseResultMap">
  85. select <include refid="table_columns" /> from att_user_base
  86. </select>
  87. <select id="findList" resultMap="attUserBaseResultMap">
  88. select <include refid="table_columns" /> from att_user_base <include refid="page_where" />
  89. </select>
  90. <select id="selectCount" resultType="int" >
  91. select count(GUID) from att_user_base <include refid="page_where" />
  92. </select>
  93. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.AttUserBase">
  94. insert into att_user_base( <include refid="table_columns" /> )
  95. values ( <include refid="entity_properties" /> )
  96. </insert>
  97. <delete id="delete" parameterType="java.lang.String">
  98. delete from att_user_base where GUID = #{id}
  99. </delete>
  100. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.AttUserBase">
  101. delete from att_user_base <include refid="page_where" />
  102. </delete>
  103. <update id="deleteInFlag" parameterType="java.lang.String">
  104. update att_user_base set flag_valid = 0 where GUID = #{id}
  105. </update>
  106. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.AttUserBase">
  107. update att_user_base
  108. <trim prefix="set" suffixOverrides=",">
  109. <if test="userGuid != null and userGuid != ''">USER_GUID = #{userGuid},</if>
  110. <if test="userCode != null and userCode != ''">USER_CODE = #{userCode},</if>
  111. <if test="userName != null and userName != ''">USER_NAME = #{userName},</if>
  112. <if test="password != null and password != ''">PASSWORD = #{password},</if>
  113. <if test="userType != null and userType != ''">USER_TYPE = #{userType},</if>
  114. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  115. <if test="adminOrg != null and adminOrg != ''">ADMIN_ORG = #{adminOrg},</if>
  116. <if test="status != null and status != ''">STATUS = #{status},</if>
  117. <if test="modifier != null and modifier != ''">MODIFIER = #{modifier},</if>
  118. <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
  119. <if test="toDate != null">TO_DATE = #{toDate},</if>
  120. <if test="note != null and note != ''">NOTE = #{note},</if>
  121. <if test="nodeCode != null and nodeCode != ''">NODE_CODE = #{nodeCode},</if>
  122. <if test="isTempUser != null and isTempUser != ''">IS_TEMP_USER = #{isTempUser},</if>
  123. <if test="userEndDate != null">USER_END_DATE = #{userEndDate},</if>
  124. </trim>
  125. <where>GUID = #{guid}</where>
  126. </update>
  127. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.AttUserBase">
  128. update att_user_base
  129. <trim prefix="set" suffixOverrides=",">
  130. <if test="userGuid != null and userGuid != ''">USER_GUID = #{userGuid},</if>
  131. <if test="userCode != null and userCode != ''">USER_CODE = #{userCode},</if>
  132. <if test="userName != null and userName != ''">USER_NAME = #{userName},</if>
  133. <if test="password != null and password != ''">PASSWORD = #{password},</if>
  134. <if test="userType != null and userType != ''">USER_TYPE = #{userType},</if>
  135. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  136. <if test="adminOrg != null and adminOrg != ''">ADMIN_ORG = #{adminOrg},</if>
  137. <if test="status != null and status != ''">STATUS = #{status},</if>
  138. <if test="modifier != null and modifier != ''">MODIFIER = #{modifier},</if>
  139. <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
  140. <if test="toDate != null">TO_DATE = #{toDate},</if>
  141. <if test="note != null and note != ''">NOTE = #{note},</if>
  142. <if test="nodeCode != null and nodeCode != ''">NODE_CODE = #{nodeCode},</if>
  143. <if test="isTempUser != null and isTempUser != ''">IS_TEMP_USER = #{isTempUser},</if>
  144. <if test="userEndDate != null">USER_END_DATE = #{userEndDate},</if>
  145. </trim>
  146. <include refid="page_where" />
  147. </update>
  148. <!-- 其他自定义SQL -->
  149. <sql id="orgIdSql">
  150. <choose>
  151. <when test="orgId !=null and orgId !=''">
  152. and ORG_ID=#{orgId}
  153. </when>
  154. <otherwise>
  155. and ORG_ID is null
  156. </otherwise>
  157. </choose>
  158. </sql>
  159. <!--根据用户id获取该用户是否为管理员-->
  160. <select id="getPersById" parameterType="String" resultType="cn.com.goldenwater.dcproj.dto.PersBaseDto">
  161. SELECT A.GUID persid,A.PERMISSION permission FROM BIS_INSP_ALL_RLATION_PERS A WHERE A.GUID = #{persid}
  162. </select>
  163. <!--获取管理员所在组-->
  164. <select id="getLastLeafPoint" resultType="cn.com.goldenwater.dcproj.dto.PersGroupDto">
  165. select j.* from BIS_INSP_ALL j where j.id like '${ptype}${orgId}______'
  166. <if test="groupName !=null and groupName !=''">
  167. and j.pnm like '%${groupName}%'
  168. </if>
  169. order by j.id asc
  170. </select>
  171. <select id="getpersGroup" resultType="cn.com.goldenwater.dcproj.dto.PersGroupDto">
  172. SELECT DISTINCT T1.ID,T1.NM,T1.PNM,T1.PPNM,CONCAT(CONCAT(CONCAT(CONCAT(T1.PPNM,'-'),T1.PNM),'-'),T1.NM) AS resultName from
  173. (SELECT A.ID,A.PNM NM,C.ID PID,C.PNM,D.ID PPID,D.PNM PPNM FROM BIS_INSP_ALL A LEFT JOIN BIS_INSP_ALL_RLATION B ON A.ID = B.ID
  174. LEFT JOIN BIS_INSP_ALL C ON A.PID = C.ID
  175. LEFT JOIN BIS_INSP_ALL D ON C.PID = D.ID
  176. WHERE 1 = 1 AND
  177. REGEXP_LIKE(
  178. A.Id,'^('||
  179. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{persid} <include refid="orgIdSql"/>
  180. and id like '${ptype}%')>0 then
  181. (SELECT LISTAGG(id, '|') WITHIN GROUP(ORDER BY PERSID) as
  182. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{persid} <include refid="orgIdSql"/> and id like '${ptype}%')
  183. else (select 'non' from dual) end)
  184. ||')')
  185. AND A.ID LIKE '${ptype}${orgId}%' AND LENGTH(A.ID) = 12
  186. <if test="tabType =='2'.toString()">
  187. and A.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  188. </if>
  189. <if test="tabType =='1'.toString()">
  190. and A.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  191. </if>
  192. <include refid="choseSql"/>
  193. <if test="groupName != null and groupName != ''">and A.PNM LIKE '%${groupName}%'</if>
  194. <!-- 根据批次Id查询批次下面的组 -->
  195. <if test="plnaId != null and plnaId != ''">and A.ID LIKE '%${plnaId}%'</if>
  196. ) T1
  197. </select>
  198. <sql id="choseSql">
  199. <choose>
  200. <when test="province !=null and province !=''">
  201. and B.ad_code=#{province}
  202. </when>
  203. <otherwise>
  204. and B.ad_code is null
  205. </otherwise>
  206. </choose>
  207. </sql>
  208. </mapper>