BisInspOprdCstrProjRgstrDao.xml 14 KB

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