BisInspFscRgstrDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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.BisInspFscRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspFscRgstr" id="bisInspFscRgstrResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="objId" column="OBJ_ID"/>
  7. <result property="name" column="NAME"/>
  8. <result property="type" column="TYPE"/>
  9. <result property="admOrg" column="ADM_ORG"/>
  10. <result property="adCode" column="AD_CODE"/>
  11. <result property="location" column="LOCATION"/>
  12. <result property="centerX" column="CENTER_X"/>
  13. <result property="centerY" column="CENTER_Y"/>
  14. <result property="gdX" column="GD_X"/>
  15. <result property="gdY" column="GD_Y"/>
  16. <result property="note" column="NOTE"/>
  17. <result property="state" column="STATE"/>
  18. <result property="dataStat" column="DATA_STAT"/>
  19. <result property="persId" column="PERS_ID"/>
  20. <result property="groupId" column="GROUP_ID"/>
  21. <result property="inTm" column="IN_TM"/>
  22. <result property="upTm" column="UP_TM"/>
  23. <result property="province" column="PROVINCE"/>
  24. </resultMap>
  25. <sql id="table_columns">
  26. ID,
  27. OBJ_ID,
  28. NAME,
  29. TYPE,
  30. ADM_ORG,
  31. AD_CODE,
  32. LOCATION,
  33. CENTER_X,
  34. CENTER_Y,
  35. GD_X,
  36. GD_Y,
  37. NOTE,
  38. STATE,
  39. DATA_STAT,
  40. PERS_ID,
  41. GROUP_ID,
  42. IN_TM,
  43. UP_TM,PROVINCE
  44. </sql>
  45. <sql id="entity_properties">
  46. #{id},
  47. #{objId},
  48. #{name},
  49. #{type},
  50. #{admOrg},
  51. #{adCode},
  52. #{location},
  53. #{centerX},
  54. #{centerY},
  55. #{gdX},
  56. #{gdY},
  57. #{note},
  58. #{state},
  59. #{dataStat},
  60. #{persId},
  61. #{groupId},
  62. #{inTm},
  63. #{upTm},#{province}
  64. </sql>
  65. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  66. <sql id="page_where">
  67. <trim prefix="where" prefixOverrides="and | or ">
  68. <if test="objId != null and objId != ''">and OBJ_ID = #{objId}</if>
  69. <if test="name != null and name != ''">and NAME = #{name}</if>
  70. <if test="type != null and type != ''">and TYPE = #{type}</if>
  71. <if test="admOrg != null and admOrg != ''">and ADM_ORG = #{admOrg}</if>
  72. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  73. <if test="location != null and location != ''">and LOCATION = #{location}</if>
  74. <if test="centerX != null and centerX != ''">and CENTER_X = #{centerX}</if>
  75. <if test="centerY != null and centerY != ''">and CENTER_Y = #{centerY}</if>
  76. <if test="gdX != null and gdX != ''">and GD_X = #{gdX}</if>
  77. <if test="gdY != null and gdY != ''">and GD_Y = #{gdY}</if>
  78. <if test="note != null and note != ''">and NOTE = #{note}</if>
  79. <if test="state != null and state != ''">and STATE = #{state}</if>
  80. <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
  81. <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
  82. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  83. <if test="inTm != null">and IN_TM = #{inTm}</if>
  84. <if test="upTm != null">and UP_TM = #{upTm}</if>
  85. <choose>
  86. <when test="province !=null and province !=''">
  87. and province =#{province}
  88. </when>
  89. <otherwise>
  90. and province is null
  91. </otherwise>
  92. </choose>
  93. </trim>
  94. </sql>
  95. <select id="get" resultMap="bisInspFscRgstrResultMap" parameterType="String">
  96. select
  97. <include refid="table_columns"/>
  98. from BIS_INSP_FSC_RGSTR where ID = #{id}
  99. </select>
  100. <select id="getBy" resultMap="bisInspFscRgstrResultMap">
  101. select
  102. <include refid="table_columns"/>
  103. from BIS_INSP_FSC_RGSTR
  104. <include refid="page_where"/>
  105. </select>
  106. <select id="findAll" resultMap="bisInspFscRgstrResultMap">
  107. select
  108. <include refid="table_columns"/>
  109. from BIS_INSP_FSC_RGSTR
  110. </select>
  111. <select id="findList" resultMap="bisInspFscRgstrResultMap">
  112. select
  113. <include refid="table_columns"/>
  114. from BIS_INSP_FSC_RGSTR
  115. <include refid="page_where"/>
  116. </select>
  117. <select id="selectCount" resultType="int">
  118. select count(ID) from BIS_INSP_FSC_RGSTR
  119. <include refid="page_where"/>
  120. </select>
  121. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscRgstr">
  122. insert into BIS_INSP_FSC_RGSTR(
  123. <include refid="table_columns"/>
  124. )
  125. values (
  126. <include refid="entity_properties"/>
  127. )
  128. </insert>
  129. <delete id="delete" parameterType="java.lang.String">
  130. delete from BIS_INSP_FSC_RGSTR where ID = #{id}
  131. </delete>
  132. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscRgstr">
  133. delete from BIS_INSP_FSC_RGSTR
  134. <include refid="page_where"/>
  135. </delete>
  136. <update id="deleteInFlag" parameterType="java.lang.String">
  137. update BIS_INSP_FSC_RGSTR set flag_valid = 0 where ID = #{id}
  138. </update>
  139. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscRgstr">
  140. update BIS_INSP_FSC_RGSTR
  141. <trim prefix="set" suffixOverrides=",">
  142. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  143. <if test="name != null and name != ''">NAME = #{name},</if>
  144. <if test="type != null and type != ''">TYPE = #{type},</if>
  145. <if test="admOrg != null and admOrg != ''">ADM_ORG = #{admOrg},</if>
  146. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  147. <if test="location != null and location != ''">LOCATION = #{location},</if>
  148. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  149. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  150. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  151. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  152. <if test="note != null and note != ''">NOTE = #{note},</if>
  153. <if test="state != null and state != ''">STATE = #{state},</if>
  154. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  155. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  156. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  157. <if test="inTm != null">IN_TM = #{inTm},</if>
  158. <if test="upTm != null">UP_TM = #{upTm},</if>
  159. <if test="province != null and province !=''"> PROVINCE = #{province},</if>
  160. </trim>
  161. <where>ID = #{id}</where>
  162. </update>
  163. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscRgstr">
  164. update BIS_INSP_FSC_RGSTR
  165. <trim prefix="set" suffixOverrides=",">
  166. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  167. <if test="name != null and name != ''">NAME = #{name},</if>
  168. <if test="type != null and type != ''">TYPE = #{type},</if>
  169. <if test="admOrg != null and admOrg != ''">ADM_ORG = #{admOrg},</if>
  170. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  171. <if test="location != null and location != ''">LOCATION = #{location},</if>
  172. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  173. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  174. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  175. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  176. <if test="note != null and note != ''">NOTE = #{note},</if>
  177. <if test="state != null and state != ''">STATE = #{state},</if>
  178. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  179. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  180. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  181. <if test="inTm != null">IN_TM = #{inTm},</if>
  182. <if test="upTm != null">UP_TM = #{upTm},</if>
  183. <if test="province != null and province !=''"> PROVINCE = #{province},</if>
  184. </trim>
  185. <include refid="page_where"/>
  186. </update>
  187. <sql id="choseSql">
  188. <choose>
  189. <when test="province !=null and province !=''">
  190. and B.province like '${province}%'
  191. </when>
  192. <otherwise>
  193. and B.province is null
  194. </otherwise>
  195. </choose>
  196. </sql>
  197. <select id="getListByInspGroupIdObjType" resultType="cn.com.goldenwater.dcproj.dto.BisInspFscRgstrDto" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam">
  198. select t.*,C.id groupId,C.PNM groupName,B.obj_id
  199. from att_fsc_base t
  200. left join BIS_INSP_ALL_OBJ B
  201. on B.CODE = t.ID
  202. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  203. and B.ptype = #{objType}
  204. where 1 = 1
  205. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  206. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  207. <if test="adCode != null and adCode != ''">
  208. and t.AD_CODE like '${adCode}%'
  209. </if>
  210. <choose>
  211. <when test="province != null and province != ''">
  212. and B.AD_CODE LIKE '${province}%'
  213. </when>
  214. <otherwise>
  215. and B.AD_CODE is null
  216. </otherwise>
  217. </choose>
  218. </select>
  219. <!-- 其他自定义SQL -->
  220. <select id="findPcPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspFscRgstrDto"
  221. parameterType="cn.com.goldenwater.dcproj.param.BisInspFscRgstrParam">
  222. select * from (
  223. select A.*,b.id as rgstrId,CASE WHEN B.STATE IS NULL THEN '0' ELSE B.STATE END AS fscState,(case when b.name is
  224. null then to_char(c.name) else b.name end) as name,b.type,b.IN_TM,b.UP_TM,
  225. c.id as baseId,
  226. (case when b.location is null then c.location else b.location end) as location,ia.pnm groupName,ria.pnm
  227. riverName,ad.ad_full_name,ba.bas_name as basName from BIS_INSP_ALL_OBJ A join BIS_INSP_FSC_RGSTR B on A.Obj_Id =
  228. B.Obj_Id left join att_fsc_base c on a.code = c.id
  229. left join ATT_AD_X_BASE ad on b.ad_code = ad.ad_code LEFT JOIN BIS_INSP_ALL ia on A.ID = ia.id
  230. left join BIS_INSP_ALL ria on substr(A.ID,0,6) = ria.id
  231. left join ATT_BAS_BASE ba on b.adm_org = ba.bas_code
  232. where 1 = 1
  233. <include refid="choseSql"/>
  234. <if test="tabType =='2'.toString()">
  235. and ia.entm &lt;to_date(#{nowTime},'yyyy-MM-dd')+1
  236. </if>
  237. <if test="tabType =='1'.toString()">
  238. and ia.entm &gt;=to_date(#{nowTime},'yyyy-MM-dd')
  239. </if>
  240. <include refid="choseSql"/>
  241. <if test="adName != null and adName != ''">and ad.AD_FULL_NAME LIKE '%${adName}%'</if>
  242. <if test="groupId != null and groupId != ''">and A.id = #{groupId}</if>
  243. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  244. AND B.IN_TM &gt;= TO_DATE(#{sttm},'YYYY-MM-DD') AND B.UP_TM &lt; TO_DATE(#{entm},'YYYY-MM-DD')+1
  245. </if>
  246. and
  247. REGEXP_LIKE(
  248. A.Id,'^('||
  249. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId} and id like '009%'
  250. <include refid="choseSql"/>
  251. )>0 then
  252. (SELECT LISTAGG(id, '|') as
  253. id FROM BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId} and id like '009%'
  254. <include refid="choseSql"/> GROUP BY PERSID
  255. )
  256. else (select 'non' from dual) end)
  257. ||')')
  258. ) where 1 = 1
  259. <if test="state != null and state != ''">
  260. and fscState in (${state})
  261. </if>
  262. <if test="name != null and name != ''">
  263. and name like '%${name}%'
  264. </if>
  265. </select>
  266. <update id="updateFscRgstr" parameterType="cn.com.goldenwater.dcproj.model.BisInspFscRgstr">
  267. update BIS_INSP_FSC_RGSTR
  268. <trim prefix="set" suffixOverrides=",">
  269. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  270. <if test="name != null and name != ''">NAME = #{name},</if>
  271. <if test="type != null and type != ''">TYPE = #{type},</if>
  272. ADM_ORG = #{admOrg},
  273. AD_CODE = #{adCode},
  274. LOCATION = #{location},
  275. CENTER_X = #{centerX},
  276. CENTER_Y = #{centerY},
  277. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  278. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  279. <if test="note != null and note != ''">NOTE = #{note},</if>
  280. <if test="state != null and state != ''">STATE = #{state},</if>
  281. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  282. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  283. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  284. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  285. <if test="inTm != null">IN_TM = #{inTm},</if>
  286. <if test="upTm != null">UP_TM = #{upTm},</if>
  287. </trim>
  288. <where>ID = #{id}</where>
  289. </update>
  290. </mapper>