BisInspGenrlRgstrDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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.BisInspGenrlRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspGenrlRgstr" id="bisInspGenrlRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="nm" column="NM"/>
  8. <result property="objType" column="OBJ_TYPE"/>
  9. <result property="engrType" column="ENGR_TYPE"/>
  10. <result property="adCode" column="AD_CODE"/>
  11. <result property="adName" column="AD_NAME"/>
  12. <result property="loc" column="LOC"/>
  13. <result property="note" column="NOTE"/>
  14. <result property="state" column="STATE"/>
  15. <result property="centerX" column="CENTER_X"/>
  16. <result property="centerY" column="CENTER_Y"/>
  17. <result property="gdX" column="GD_X"/>
  18. <result property="gdY" column="GD_Y"/>
  19. <result property="intm" column="INTM"/>
  20. <result property="uptm" column="UPTM"/>
  21. <result property="dataStat" column="DATA_STAT"/>
  22. </resultMap>
  23. <sql id="table_columns">
  24. ID,
  25. OBJ_ID,
  26. OBJ_TYPE,
  27. ENGR_TYPE,
  28. NM,
  29. AD_CODE,
  30. AD_NAME,
  31. LOC,
  32. NOTE,
  33. STATE,
  34. CENTER_X,
  35. CENTER_Y,
  36. GD_X,
  37. GD_Y,
  38. INTM,
  39. UPTM,
  40. DATA_STAT
  41. </sql>
  42. <sql id="entity_properties">
  43. #{id},
  44. #{objId},
  45. #{objType},
  46. #{engrType},
  47. #{nm},
  48. #{adCode},
  49. #{adName},
  50. #{loc},
  51. #{note},
  52. #{state},
  53. #{centerX},
  54. #{centerY},
  55. #{gdX},
  56. #{gdY},
  57. #{intm},
  58. #{uptm},
  59. #{dataStat}
  60. </sql>
  61. <sql id="page_where">
  62. <trim prefix="where" prefixOverrides="and | or ">
  63. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  64. <if test="nm != null and nm != ''">and NM = #{nm}</if>
  65. <if test="objType != null and objType != ''">and OBJ_TYPE = #{objType}</if>
  66. <if test="engrType != null and engrType != ''">and ENGR_TYPE = #{engrType}</if>
  67. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  68. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  69. <if test="loc != null and loc != ''">and LOC = #{loc}</if>
  70. <if test="note != null and note != ''">and NOTE = #{note}</if>
  71. <if test="state != null and state != ''">and STATE = #{state}</if>
  72. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  73. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  74. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  75. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  76. <if test="intm != null">and INTM = #{intm}</if>
  77. <if test="uptm != null">and UPTM = #{uptm}</if>
  78. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  79. and DATA_STAT='0'
  80. </trim>
  81. </sql>
  82. <select id="get" resultMap="bisInspGenrlRgstrResultMap" parameterType="String" >
  83. select <include refid="table_columns" /> from BIS_INSP_GENRL_RGSTR where ID = #{id}
  84. </select>
  85. <select id="getBy" resultMap="bisInspGenrlRgstrResultMap">
  86. select <include refid="table_columns" /> from BIS_INSP_GENRL_RGSTR <include refid="page_where" />
  87. </select>
  88. <select id="findAll" resultMap="bisInspGenrlRgstrResultMap">
  89. select <include refid="table_columns" /> from BIS_INSP_GENRL_RGSTR
  90. </select>
  91. <select id="findList" resultMap="bisInspGenrlRgstrResultMap">
  92. select <include refid="table_columns" /> from BIS_INSP_GENRL_RGSTR <include refid="page_where" />
  93. </select>
  94. <select id="selectCount" resultType="int" >
  95. select count(ID) from BIS_INSP_GENRL_RGSTR <include refid="page_where" />
  96. </select>
  97. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspGenrlRgstr">
  98. insert into BIS_INSP_GENRL_RGSTR( <include refid="table_columns" /> )
  99. values ( <include refid="entity_properties" /> )
  100. </insert>
  101. <delete id="delete" parameterType="java.lang.String">
  102. update BIS_INSP_GENRL_RGSTR set DATA_STAT='9' where ID = #{id}
  103. </delete>
  104. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspGenrlRgstr">
  105. update BIS_INSP_GENRL_RGSTR set DATA_STAT='9' <include refid="page_where" />
  106. </delete>
  107. <update id="deleteInFlag" parameterType="java.lang.String">
  108. update BIS_INSP_GENRL_RGSTR set DATA_STAT = '9' where ID = #{id}
  109. </update>
  110. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspGenrlRgstr">
  111. update BIS_INSP_GENRL_RGSTR
  112. <trim prefix="set" suffixOverrides=",">
  113. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  114. <if test="nm != null and nm != ''">NM = #{nm},</if>
  115. <if test="objType != null and objType != ''"> OBJ_TYPE = #{objType},</if>
  116. <if test="engrType != null and engrType != ''"> ENGR_TYPE = #{engrType},</if>
  117. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  118. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  119. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  120. <if test="note != null and note != ''">NOTE = #{note},</if>
  121. <if test="state != null and state != ''">STATE = #{state},</if>
  122. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  123. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  124. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  125. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  126. <if test="intm != null">INTM = #{intm},</if>
  127. <if test="uptm != null">UPTM = #{uptm},</if>
  128. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  129. </trim>
  130. <where>ID = #{id}</where>
  131. </update>
  132. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspGenrlRgstr">
  133. update BIS_INSP_GENRL_RGSTR
  134. <trim prefix="set" suffixOverrides=",">
  135. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  136. <if test="nm != null and nm != ''">NM = #{nm},</if>
  137. <if test="objType != null and objType != ''"> OBJ_TYPE = #{objType},</if>
  138. <if test="engrType != null and engrType != ''"> ENGR_TYPE = #{engrType},</if>
  139. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  140. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  141. <if test="loc != null and loc != ''">LOC = #{loc},</if>
  142. <if test="note != null and note != ''">NOTE = #{note},</if>
  143. <if test="state != null and state != ''">STATE = #{state},</if>
  144. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  145. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  146. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  147. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  148. <if test="intm != null">INTM = #{intm},</if>
  149. <if test="uptm != null">UPTM = #{uptm},</if>
  150. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  151. </trim>
  152. <include refid="page_where" />
  153. </update>
  154. <!-- 其他自定义SQL -->
  155. <select id="findPageList" resultType="cn.com.goldenwater.dcproj.dto.BisInspGenrlRgstrDto">
  156. SELECT * FROM (
  157. select A.CODE,
  158. A.ID AS nodeId,
  159. A.NM,
  160. A.PTYPE,
  161. A.OBJ_ID,
  162. IA.PNM AS groupName,
  163. B.ID AS rgstrId,
  164. AW.AD_FULL_NAME,
  165. (CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END) AS STATE,
  166. B.ID,
  167. B.OBJ_TYPE,
  168. B.ENGR_TYPE,
  169. B.AD_CODE,
  170. B.AD_NAME,
  171. B.INTM,
  172. B.UPTM,
  173. B.NOTE,
  174. B.DATA_STAT
  175. FROM BIS_INSP_ALL_OBJ A
  176. JOIN BIS_INSP_GENRL_RGSTR B ON A.OBJ_ID = B.OBJ_ID
  177. LEFT JOIN BIS_INSP_ALL IA ON A.ID = IA.ID
  178. LEFT JOIN ATT_AD_BASE AW ON B.AD_CODE = AW.AD_CODE
  179. <where>
  180. <if test="adCodes ==null or adCodes ==''">
  181. <choose>
  182. <when test='isAll =="1"'>
  183. </when>
  184. <otherwise>
  185. AND A.Id in (
  186. select distinct id from (
  187. SELECT P.id FROM BIS_INSP_ALL P START WITH P.PID IN (SELECT id FROM BIS_INSP_ALL_RLATION A
  188. WHERE A.PERSID = #{presId} and TYPE = #{pType} and length(id) in (3,6,9))
  189. CONNECT BY P.PID = PRIOR P.ID
  190. union all
  191. SELECT P.id FROM BIS_INSP_ALL P where p.id in (SELECT id FROM BIS_INSP_ALL_RLATION A
  192. WHERE A.PERSID =#{presId} and TYPE = #{pType} and length(id)=12 )
  193. )
  194. )
  195. </otherwise>
  196. </choose>
  197. </if>
  198. <if test="adCodes !=null and adCodes !=''">
  199. and
  200. <foreach item="item" index="index" collection="adCodes.split(',')" open="(" separator="or" close=")">
  201. b.ad_code like concat('${item}','%')
  202. </foreach>
  203. </if>
  204. <if test="tabType =='2'.toString()">
  205. AND IA.ENTM &lt; TO_DATE(#{nowTime},'yyyy-MM-dd')+1
  206. </if>
  207. <if test="tabType =='1'.toString()">
  208. AND IA.ENTM &gt;= TO_DATE(#{nowTime},'yyyy-MM-dd')
  209. </if>
  210. </where>
  211. ) A
  212. <where>
  213. <if test="id !=null and id !=''">and a.nodeId like '${id}%'</if>
  214. <if test="plnaId !=null and plnaId !=''">and a.nodeId like '${plnaId}%'</if>
  215. <if test="state !=null and state !=''">and STATE in (${state})</if>
  216. <if test="nm !=null and nm !=''">and a.nm like '%${nm}%'</if>
  217. <if test="rsName !=null and rsName !=''">and a.nm like '%${rsName}%'</if>
  218. <if test="code !=null and code !=''">and a.code = #{code}</if>
  219. <if test="type !=null and type !=''">and a.OBJ_TYPE = #{type}</if>
  220. <if test="engrType !=null and engrType !=''">and a.ENGR_TYPE like '%${engrType}%'</if>
  221. <if test="adName != null and adName != ''">and a.AD_NAME like '%${adName}%'</if>
  222. <if test="sttm != null and sttm != ''">and a.INTM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  223. <if test="entm != null and entm != ''">and a.INTM &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  224. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  225. </where>
  226. order by nodeId asc
  227. <if test="orderBy != null and orderBy != ''">
  228. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  229. </if>
  230. </select>
  231. <!-- 其他自定义SQL -->
  232. <select id="findGenrList" parameterType="cn.com.goldenwater.dcproj.param.TypeParam"
  233. resultType="cn.com.goldenwater.dcproj.dto.BisInspRgstrDto">
  234. SELECT * FROM (
  235. select A.CODE,A.ID nodeId,
  236. A.NM,
  237. #{pType} PTYPE,
  238. A.OBJ_ID,B.ID ID,b.id as rgstrId,
  239. (case when b.State is null then '0' else b.state end) STATE,
  240. B.OBJ_TYPE,B.ENGR_TYPE,B.INTM, b.AD_NAME as ad_name,
  241. ia.pnm groupName
  242. from BIS_INSP_ALL_OBJ A
  243. LEFT JOIN BIS_INSP_GENRL_RGSTR B ON A.OBJ_ID=B.OBJ_ID
  244. LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  245. where A.ptype= #{pType}
  246. <if test="tabType =='2'.toString()">
  247. and ia.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  248. </if>
  249. <if test="tabType =='1'.toString()">
  250. and ia.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  251. </if>
  252. <if test="adCodes ==null or adCodes ==''">
  253. and
  254. REGEXP_LIKE(
  255. A.Id,'^('||
  256. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION WHERE PERSID =#{presId}
  257. <include refid="choseSql"/>
  258. )>0 then
  259. (SELECT LISTAGG(id, '|') WITHIN GROUP(ORDER BY PERSID) as
  260. id FROM BIS_INSP_ALL_RLATION WHERE PERSID =#{presId}
  261. <include refid="choseSql"/>
  262. )
  263. else (select 'non' from dual) end)
  264. ||')')
  265. </if>
  266. ) A WHERE a.PTYPE=#{pType}
  267. <if test="efpType != null and efpType != ''">
  268. and a.type = #{efpType}
  269. </if>
  270. <if test="plnaId !=null and plnaId !=''">
  271. and a.nodeId like '${plnaId}%'
  272. </if>
  273. <if test="state !=null and state !=''">
  274. and STATE in (${state})
  275. </if>
  276. <if test="rsName !=null and rsName !=''">
  277. and a.nm like '%${rsName}%'
  278. </if>
  279. <if test="code !=null and code !=''">
  280. and a.code = #{code}
  281. </if>
  282. <if test="adName != null and adName != ''">and a.adName like '%${adName}%'</if>
  283. <if test="sttm != null and sttm != ''">and a.Intm&gt;= TO_DATE(#{sttm},'YYYY-MM-DD')</if>
  284. <if test="entm != null and entm != ''">and a.Intm &lt; To_DATE(#{entm},'yyyy-MM-dd') + 1</if>
  285. <if test="groupId != null and groupId != ''">and a.nodeId = #{groupId}</if>
  286. order by nodeId asc
  287. <if test="orderBy != null and orderBy != ''">
  288. ,nlssort(nm,'NLS_SORT=SCHINESE_PINYIN_M')
  289. </if>
  290. </select>
  291. <sql id="choseSql">
  292. <choose>
  293. <when test="province != null and province != ''">
  294. and AD_CODE LIKE '${province}%'
  295. </when>
  296. <otherwise>
  297. and AD_CODE is null
  298. </otherwise>
  299. </choose>
  300. </sql>
  301. </mapper>