BisInspOtherRgstrDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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.BisInspOtherRgstrDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr" id="bisInspOtherRgstrResultMap">
  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="province != null and province != ''">and PROVINCE = #{province}</if>
  84. <if test="inTm != null">and IN_TM = #{inTm}</if>
  85. <if test="upTm != null">and UP_TM = #{upTm}</if>
  86. </trim>
  87. </sql>
  88. <select id="get" resultMap="bisInspOtherRgstrResultMap" parameterType="String">
  89. select
  90. <include refid="table_columns"/>
  91. from BIS_INSP_OTHER_RGSTR where ID = #{id}
  92. </select>
  93. <select id="getBy" resultMap="bisInspOtherRgstrResultMap">
  94. select
  95. <include refid="table_columns"/>
  96. from BIS_INSP_OTHER_RGSTR
  97. <include refid="page_where"/>
  98. </select>
  99. <select id="findAll" resultMap="bisInspOtherRgstrResultMap">
  100. select
  101. <include refid="table_columns"/>
  102. from BIS_INSP_OTHER_RGSTR
  103. </select>
  104. <select id="findList" resultMap="bisInspOtherRgstrResultMap">
  105. select
  106. <include refid="table_columns"/>
  107. from BIS_INSP_OTHER_RGSTR
  108. <include refid="page_where"/>
  109. </select>
  110. <select id="selectCount" resultType="int">
  111. select count(ID) from BIS_INSP_OTHER_RGSTR
  112. <include refid="page_where"/>
  113. </select>
  114. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr">
  115. insert into BIS_INSP_OTHER_RGSTR(
  116. <include refid="table_columns"/>
  117. )
  118. values (
  119. <include refid="entity_properties"/>
  120. )
  121. </insert>
  122. <delete id="delete" parameterType="java.lang.String">
  123. delete from BIS_INSP_OTHER_RGSTR where ID = #{id}
  124. </delete>
  125. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr">
  126. delete from BIS_INSP_OTHER_RGSTR
  127. <include refid="page_where"/>
  128. </delete>
  129. <update id="deleteInFlag" parameterType="java.lang.String">
  130. update BIS_INSP_OTHER_RGSTR set flag_valid = 0 where ID = #{id}
  131. </update>
  132. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr">
  133. update BIS_INSP_OTHER_RGSTR
  134. <trim prefix="set" suffixOverrides=",">
  135. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  136. <if test="name != null and name != ''">NAME = #{name},</if>
  137. <if test="type != null and type != ''">TYPE = #{type},</if>
  138. <if test="admOrg != null and admOrg != ''">ADM_ORG = #{admOrg},</if>
  139. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  140. <if test="location != null and location != ''">LOCATION = #{location},</if>
  141. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  142. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  143. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  144. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  145. <if test="note != null and note != ''">NOTE = #{note},</if>
  146. <if test="state != null and state != ''">STATE = #{state},</if>
  147. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  148. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  149. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  150. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  151. <if test="inTm != null">IN_TM = #{inTm},</if>
  152. <if test="upTm != null">UP_TM = #{upTm},</if>
  153. </trim>
  154. <where>ID = #{id}</where>
  155. </update>
  156. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr">
  157. update BIS_INSP_OTHER_RGSTR
  158. <trim prefix="set" suffixOverrides=",">
  159. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  160. <if test="name != null and name != ''">NAME = #{name},</if>
  161. <if test="type != null and type != ''">TYPE = #{type},</if>
  162. <if test="admOrg != null and admOrg != ''">ADM_ORG = #{admOrg},</if>
  163. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  164. <if test="location != null and location != ''">LOCATION = #{location},</if>
  165. <if test="centerX != null and centerX != ''">CENTER_X = #{centerX},</if>
  166. <if test="centerY != null and centerY != ''">CENTER_Y = #{centerY},</if>
  167. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  168. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  169. <if test="note != null and note != ''">NOTE = #{note},</if>
  170. <if test="state != null and state != ''">STATE = #{state},</if>
  171. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  172. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  173. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  174. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  175. <if test="inTm != null">IN_TM = #{inTm},</if>
  176. <if test="upTm != null">UP_TM = #{upTm},</if>
  177. </trim>
  178. <include refid="page_where"/>
  179. </update>
  180. <sql id="choseSql">
  181. <choose>
  182. <when test="province !=null and province !=''">
  183. and B.province like '${province}%'
  184. </when>
  185. <otherwise>
  186. and B.province is null
  187. </otherwise>
  188. </choose>
  189. </sql>
  190. <select id="getListByInspGroupIdObjType" parameterType="cn.com.goldenwater.dcproj.param.PagePersObjParam" resultType="cn.com.goldenwater.dcproj.dto.BisInspOtherRgstrDto">
  191. select t.*,C.id groupId,C.PNM groupName,B.obj_id
  192. from att_other_base t
  193. left join BIS_INSP_ALL_OBJ B
  194. on B.CODE = t.ID
  195. LEFT JOIN BIS_INSP_ALL C ON B.ID = C.ID
  196. and B.ptype = #{objType}
  197. where 1 = 1
  198. <if test='isAll == "0"'>and B.ID = #{inspGroupId}</if>
  199. <if test='isAll == "1"'>and B.ID LIKE '${inspGroupId}%'</if>
  200. <if test="adCode != null and adCode != ''">
  201. and t.AD_CODE like '${adCode}%'
  202. </if>
  203. <choose>
  204. <when test="province != null and province != ''">
  205. and B.AD_CODE LIKE '${province}%'
  206. </when>
  207. <otherwise>
  208. and B.AD_CODE is null
  209. </otherwise>
  210. </choose>
  211. </select>
  212. <!-- 其他自定义SQL -->
  213. <select id="findPcPage" resultType="cn.com.goldenwater.dcproj.dto.BisInspOtherRgstrDto"
  214. parameterType="cn.com.goldenwater.dcproj.param.BisInspOtherRgstrParam">
  215. select w.* from (
  216. 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
  217. null then cast(c.name as char) else b.name end) as name,b.type,b.IN_TM,b.UP_TM,
  218. c.id as baseId,
  219. (case when b.location is null then c.location else b.location end) as location,ia.pnm groupName,ria.pnm
  220. riverName,ad.ad_full_name,ba.bas_name as basName from BIS_INSP_ALL_OBJ A join BIS_INSP_OTHER_RGSTR B on A.Obj_Id
  221. = B.Obj_Id left join att_other_base c on a.code = c.id
  222. 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
  223. left join BIS_INSP_ALL ria on substr(A.ID,1,6) = ria.id
  224. left join ATT_BAS_BASE ba on b.adm_org = ba.bas_code
  225. where 1 = 1
  226. <if test="tabType =='2'.toString()">
  227. and ia.entm &lt; DATE_ADD(STR_TO_DATE(#{nowTime},'%Y-%m-%d'),INTERVAL 1 DAY)
  228. </if>
  229. <if test="tabType =='1'.toString()">
  230. and ia.entm &gt;=STR_TO_DATE(#{nowTime},'%Y-%m-%d')
  231. </if>
  232. <include refid="choseSql"/>
  233. <if test="adName != null and adName != ''">and ad.AD_FULL_NAME LIKE '%${adName}%'</if>
  234. <if test="groupId != null and groupId != ''">and A.id = #{groupId}</if>
  235. <if test="orgId != null and orgId !=''">and A.id like '${orgId}%'</if>
  236. <if test="sttm != null and sttm != '' and entm != null and entm != ''">
  237. AND B.IN_TM &gt;= STR_TO_DATE(#{sttm},'%Y-%m-%d') AND B.UP_TM &lt; DATE_ADD(STR_TO_DATE(#{entm},'%Y-%m-%d'),INTERVAL 1 DAY)
  238. </if>
  239. and
  240. REGEXP_LIKE(
  241. A.Id,concat('^(',
  242. ( case when(SELECT count(id) from BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId} AND ID LIKE '010%'
  243. <include refid="choseSql"/>
  244. )>0 then
  245. (SELECT group_concat(id separator '|') as
  246. id FROM BIS_INSP_ALL_RLATION B WHERE PERSID =#{presId} AND ID LIKE '010%'
  247. <include refid="choseSql"/>
  248. GROUP BY PERSID
  249. )
  250. else (select 'non' from dual) end)
  251. ,')'))
  252. ) w where 1 = 1
  253. <if test="state != null and state != ''">
  254. and w.fscState in (${state})
  255. </if>
  256. <if test="name != null and name != ''">
  257. and w.name like '%${name}%'
  258. </if>
  259. </select>
  260. <update id="updateOtherRgstr" parameterType="cn.com.goldenwater.dcproj.model.BisInspOtherRgstr">
  261. update BIS_INSP_OTHER_RGSTR
  262. <trim prefix="set" suffixOverrides=",">
  263. <if test="objId != null and objId != ''">OBJ_ID = #{objId},</if>
  264. <if test="name != null and name != ''">NAME = #{name},</if>
  265. <if test="type != null and type != ''">TYPE = #{type},</if>
  266. ADM_ORG = #{admOrg},
  267. AD_CODE = #{adCode},
  268. LOCATION = #{location},
  269. CENTER_X = #{centerX},
  270. CENTER_Y = #{centerY},
  271. <if test="gdX != null and gdX != ''">GD_X = #{gdX},</if>
  272. <if test="gdY != null and gdY != ''">GD_Y = #{gdY},</if>
  273. <if test="note != null and note != ''">NOTE = #{note},</if>
  274. <if test="state != null and state != ''">STATE = #{state},</if>
  275. <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
  276. <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
  277. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  278. <if test="province != null and province != ''">PROVINCE = #{province},</if>
  279. <if test="inTm != null">IN_TM = #{inTm},</if>
  280. <if test="upTm != null">UP_TM = #{upTm},</if>
  281. </trim>
  282. <where>ID = #{id}</where>
  283. </update>
  284. </mapper>