BisZhejiangJgRgstrDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.BisZhejiangJgRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr" id="bisZhejiangJgRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="regsNm" column="REGS_NM"/>
  8. <result property="departId" column="DEPART_ID"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="persId" column="PERS_ID"/>
  11. <result property="intm" column="INTM"/>
  12. <result property="uptm" column="UPTM"/>
  13. <result property="note" column="NOTE"/>
  14. <result property="dataStat" column="DATA_STAT"/>
  15. <result property="state" column="STATE"/>
  16. <result property="adFullName" column="AD_FULL_NAME"/>
  17. <result property="telphone" column="TELPHONE"/>
  18. <result property="lgtd" column="LGTD"/>
  19. <result property="lttd" column="LTTD"/>
  20. <result property="lgtdpc" column="LGTDPC"/>
  21. <result property="lttdpc" column="LTTDPC"/>
  22. <result property="jgState" column="JG_STATE"/>
  23. </resultMap>
  24. <sql id="table_columns">
  25. ID,
  26. OBJ_ID,
  27. REGS_NM,
  28. DEPART_ID,
  29. AD_CODE,
  30. PERS_ID,
  31. INTM,
  32. UPTM,
  33. NOTE,
  34. DATA_STAT,
  35. STATE,
  36. AD_FULL_NAME,
  37. TELPHONE,
  38. LGTD,
  39. LTTD,
  40. LGTDPC,
  41. LTTDPC,
  42. JG_STATE
  43. </sql>
  44. <sql id="entity_properties">
  45. #{id},
  46. #{objId},
  47. #{regsNm},
  48. #{departId},
  49. #{adCode},
  50. #{persId},
  51. #{intm},
  52. #{uptm},
  53. #{note},
  54. #{dataStat},
  55. #{state},
  56. #{adFullName},
  57. #{telphone},
  58. #{lgtd},
  59. #{lttd},
  60. #{lgtdpc},
  61. #{lttdpc},
  62. #{jgState}
  63. </sql>
  64. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  65. <sql id="page_where">
  66. <trim prefix="where" prefixOverrides="and | or ">
  67. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  68. <if test="regsNm != null and regsNm != ''">and REGS_NM = #{regsNm}</if>
  69. <if test="departId != null and departId != ''">and DEPART_ID = #{departId}</if>
  70. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  71. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  72. <if test="intm != null">and INTM = #{intm}</if>
  73. <if test="uptm != null">and UPTM = #{uptm}</if>
  74. <if test="note != null and note != ''">and NOTE = #{note}</if>
  75. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  76. <if test="state != null and state != ''">and STATE = #{state}</if>
  77. <if test="adFullName != null and adFullName != ''">and AD_FULL_NAME = #{adFullName}</if>
  78. <if test="telphone != null and telphone != ''">and TELPHONE = #{telphone}</if>
  79. <if test="lgtd != null and lgtd != ''">and LGTD = #{lgtd}</if>
  80. <if test="lttd != null and lttd != ''">and LTTD = #{lttd}</if>
  81. <if test="lgtdpc != null and lgtdpc != ''">and LGTDPC = #{lgtdpc}</if>
  82. <if test="lttdpc != null and lttdpc != ''">and LTTDPC = #{lttdpc}</if>
  83. <if test="jgState != null and jgState != ''">and JG_STATE = #{jgState}</if>
  84. </trim>
  85. </sql>
  86. <select id="get" resultMap="bisZhejiangJgRgstrResultMap" parameterType="String" >
  87. select <include refid="table_columns" /> from BIS_ZHEJIANG_JG_RGSTR where ID = #{id}
  88. </select>
  89. <select id="getBy" resultMap="bisZhejiangJgRgstrResultMap">
  90. select <include refid="table_columns" /> from BIS_ZHEJIANG_JG_RGSTR <include refid="page_where" />
  91. </select>
  92. <select id="findAll" resultMap="bisZhejiangJgRgstrResultMap">
  93. select <include refid="table_columns" /> from BIS_ZHEJIANG_JG_RGSTR
  94. </select>
  95. <select id="findList" resultMap="bisZhejiangJgRgstrResultMap">
  96. select <include refid="table_columns" /> from BIS_ZHEJIANG_JG_RGSTR <include refid="page_where" />
  97. </select>
  98. <select id="selectCount" resultType="int" >
  99. select count(ID) from BIS_ZHEJIANG_JG_RGSTR <include refid="page_where" />
  100. </select>
  101. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr">
  102. insert into BIS_ZHEJIANG_JG_RGSTR( <include refid="table_columns" /> )
  103. values ( <include refid="entity_properties" /> )
  104. </insert>
  105. <delete id="delete" parameterType="java.lang.String">
  106. delete from BIS_ZHEJIANG_JG_RGSTR where ID = #{id}
  107. </delete>
  108. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr">
  109. delete from BIS_ZHEJIANG_JG_RGSTR <include refid="page_where" />
  110. </delete>
  111. <update id="deleteInFlag" parameterType="java.lang.String">
  112. update BIS_ZHEJIANG_JG_RGSTR set flag_valid = 0 where ID = #{id}
  113. </update>
  114. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr">
  115. update BIS_ZHEJIANG_JG_RGSTR
  116. <trim prefix="set" suffixOverrides=",">
  117. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  118. <if test="regsNm != null and regsNm != ''">REGS_NM = #{regsNm},</if>
  119. <if test="departId != null and departId != ''">DEPART_ID = #{departId},</if>
  120. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  121. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  122. <if test="intm != null">INTM = #{intm},</if>
  123. <if test="uptm != null">UPTM = #{uptm},</if>
  124. <if test="note != null and note != ''">NOTE = #{note},</if>
  125. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  126. <if test="state != null and state != ''">STATE = #{state},</if>
  127. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  128. <if test="telphone != null and telphone != ''">TELPHONE = #{telphone},</if>
  129. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  130. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  131. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  132. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  133. <if test="jgState != null and jgState != ''">JG_STATE = #{jgState},</if>
  134. </trim>
  135. <where>ID = #{id}</where>
  136. </update>
  137. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr">
  138. update BIS_ZHEJIANG_JG_RGSTR
  139. <trim prefix="set" suffixOverrides=",">
  140. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  141. <if test="regsNm != null and regsNm != ''">REGS_NM = #{regsNm},</if>
  142. <if test="departId != null and departId != ''">DEPART_ID = #{departId},</if>
  143. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  144. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  145. <if test="intm != null">INTM = #{intm},</if>
  146. <if test="uptm != null">UPTM = #{uptm},</if>
  147. <if test="note != null and note != ''">NOTE = #{note},</if>
  148. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  149. <if test="state != null and state != ''">STATE = #{state},</if>
  150. <if test="adFullName != null and adFullName != ''">AD_FULL_NAME = #{adFullName},</if>
  151. <if test="telphone != null and telphone != ''">TELPHONE = #{telphone},</if>
  152. <if test="lgtd != null and lgtd != ''">LGTD = #{lgtd},</if>
  153. <if test="lttd != null and lttd != ''">LTTD = #{lttd},</if>
  154. <if test="lgtdpc != null and lgtdpc != ''">LGTDPC = #{lgtdpc},</if>
  155. <if test="lttdpc != null and lttdpc != ''">LTTDPC = #{lttdpc},</if>
  156. <if test="jgState != null and jgState != ''">JG_STATE = #{jgState},</if>
  157. </trim>
  158. <include refid="page_where" />
  159. </update>
  160. <select id="getNotSuperviseGroupObj" resultType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr">
  161. select t.*,C.id groupId,C.PNM groupName,B.obj_id
  162. from ATT_ZHEJIANG_JG_BASE t
  163. left join BIS_INSP_ALL_OBJ B
  164. on B.CODE = t.ad_code
  165. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  166. and B.ptype = #{objType}
  167. where 1 = 1
  168. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  169. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  170. <if test="adCode != null and adCode != ''">
  171. and t.AD_CODE like '${adCode}%'
  172. </if>
  173. <choose>
  174. <when test="province != null and province != ''">
  175. and B.AD_CODE LIKE '${province}%'
  176. </when>
  177. <otherwise>
  178. and B.AD_CODE is null
  179. </otherwise>
  180. </choose>
  181. </select>
  182. <select id="getZhejiangJgRegstrInfo" resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  183. select * from
  184. (
  185. SELECT
  186. a.OBJ_ID AS objId,
  187. #{pType} as ptype,
  188. ( CASE WHEN a.STATE IS NULL THEN '0' ELSE a.STATE END ) AS state,
  189. ( CASE WHEN a.AD_FULL_NAME IS NULL THEN to_char( e.AD_FULL_NAME ) ELSE a.AD_FULL_NAME END ) location,
  190. a.INTM AS intm,
  191. a.UPTM AS uptm,
  192. b.id AS nodeId,
  193. a.id AS rgstrId,
  194. a.REGS_NM AS nm,
  195. a.JG_STATE,
  196. insp.pnm AS groupName
  197. FROM
  198. BIS_ZHEJIANG_JG_RGSTR A
  199. LEFT JOIN BIS_INSP_ALL_OBJ b ON a.OBJ_ID = b.OBJ_ID
  200. LEFT JOIN ATT_AD_X_BASE e ON A.AD_CODE = e.ad_code
  201. left join bis_insp_all insp on b.id=insp.id
  202. where 1=1 and
  203. REGEXP_LIKE(
  204. B.Id,'^('||
  205. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{presId} and id like '042%'
  206. <include refid="orgIdSql"/>
  207. )>0 then
  208. (SELECT LISTAGG(id, '|') as
  209. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{presId}
  210. <include refid="orgIdSql"/> and id like '042%' group by persid
  211. )
  212. else (select 'non' from dual) end)
  213. ||')')
  214. )a where 1=1
  215. <if test="sttm !=null and sttm !='' and entm !=null and entm !=''">
  216. and intm&gt;=to_date(#{sttm},'yyyy-mm-dd') and intm &lt;=to_date(#{entm},'yyyy-mm-dd')
  217. </if>
  218. <if test="state !=null and state !=''">
  219. and state = #{state}
  220. </if>
  221. <if test="adName !=null and adName !=''">
  222. and location like '%${adName}%'
  223. </if>
  224. <if test="groupId !=null and groupId !=''">
  225. and nodeId like '${groupId}%'
  226. </if>
  227. <if test="plnaId !=null and plnaId !=''">
  228. and nodeId like '${plnaId}%'
  229. </if>
  230. </select>
  231. <sql id="orgIdSql">
  232. <choose>
  233. <when test="orgId !=null and orgId !=''">
  234. and ORG_ID=#{orgId}
  235. </when>
  236. <otherwise>
  237. and ORG_ID is null
  238. </otherwise>
  239. </choose>
  240. </sql>
  241. <!-- 其他自定义SQL -->
  242. <select id="getListByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.model.BisZhejiangJgRgstr" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam">
  243. select t.*,C.id groupId,C.PNM groupName,B.obj_id,r.ad_full_name as loc
  244. from ATT_ZHEJIANG_JG_BASE t
  245. left join BIS_INSP_ALL_OBJ B
  246. on B.CODE = t.id
  247. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  248. and B.ptype = #{objType}
  249. left join BIS_ZHEJIANG_JG_RGSTR r on b.obj_id=r.obj_id
  250. where 1 = 1
  251. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  252. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  253. <if test="adCode != null and adCode != ''">
  254. and t.AD_CODE like '${adCode}%'
  255. </if>
  256. <choose>
  257. <when test="province != null and province != ''">
  258. and B.AD_CODE LIKE '${province}%'
  259. </when>
  260. <otherwise>
  261. and B.AD_CODE is null
  262. </otherwise>
  263. </choose>
  264. </select>
  265. </mapper>