CadastreFileMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.siwei.apply.mapper.CadastreFileMapper">
  6. <resultMap id="cadastreFileMap" type="com.siwei.apply.domain.CadastreFile">
  7. <id column="id" property="id"/>
  8. <result column="name" property="name"/>
  9. <result column="upload_user" property="uploadUser"/>
  10. <result column="upload_time" property="uploadTime"/>
  11. <result column="file_path" property="filePath"/>
  12. <result column="proxy_path" property="proxyPath"/>
  13. <result column="unzip_path" property="unzipPath"/>
  14. <result column="file_type" property="fileType"/>
  15. <result column="storage" property="storage"/>
  16. <result column="status" property="status"/>
  17. <result column="read_status" property="readStatus"/>
  18. <result column="read_message" property="readMessage"/>
  19. <result column="file_storage_time" property="fileStorageTime"/>
  20. <result column="update_time" property="updateTime"/>
  21. <result column="file_size" property="fileSize"/>
  22. <result column="land_right_type" property="landRightType"/>
  23. </resultMap>
  24. <sql id="Base_Column_List">
  25. id, name, upload_user, upload_time, file_path, proxy_path, unzip_path, file_type, storage, status, read_status, read_message, file_storage_time, update_time, file_size,land_right_type,cadastre_type
  26. </sql>
  27. <insert id="add" parameterType="com.siwei.apply.domain.CadastreFile">
  28. INSERT INTO t_cadastre_file (
  29. id, name, upload_user, upload_time, file_path, proxy_path, unzip_path, file_type, storage, status, read_status, read_message, file_storage_time, update_time, file_size, land_right_type, cadastre_type
  30. ) VALUES (
  31. #{id}, #{name}, #{uploadUser}, #{uploadTime}, #{filePath}, #{proxyPath}, #{unzipPath}, #{fileType}, #{storage}, #{status}, #{readStatus}, #{readMessage}, #{fileStorageTime},#{updateTime}, #{fileSize},#{landRightType}, #{cadastreType}
  32. )
  33. </insert>
  34. <select id="get" resultMap="cadastreFileMap">
  35. SELECT <include refid="Base_Column_List"/>
  36. FROM t_cadastre_file
  37. WHERE id = #{id}
  38. </select>
  39. <update id="update" parameterType="com.siwei.apply.domain.CadastreFile">
  40. UPDATE t_cadastre_file
  41. <set>
  42. <if test="name != null">name = #{name},</if>
  43. <if test="uploadUser != null">upload_user = #{uploadUser},</if>
  44. <if test="uploadTime != null">upload_time = #{uploadTime},</if>
  45. <if test="filePath != null">file_path = #{filePath},</if>
  46. <if test="proxyPath != null">proxy_path = #{proxyPath},</if>
  47. <if test="unzipPath != null">unzip_path = #{unzipPath},</if>
  48. <if test="fileType != null">file_type = #{fileType},</if>
  49. <if test="storage != null">storage = #{storage},</if>
  50. <if test="status != null">status = #{status},</if>
  51. <if test="readStatus != null">read_status = #{readStatus},</if>
  52. <if test="readMessage != null">read_message = #{readMessage},</if>
  53. <if test="fileStorageTime != null">file_storage_time = #{fileStorageTime},</if>
  54. <if test="updateTime != null">update_time = #{updateTime},</if>
  55. <if test="fileSize != null">file_size = #{fileSize},</if>
  56. <if test="landRightType != null">land_right_type = #{landRightType},</if>
  57. <if test="cadastreType != null">cadastre_type = #{cadastreType},</if>
  58. </set>
  59. WHERE id = #{id}
  60. </update>
  61. <delete id="delete">
  62. DELETE FROM t_cadastre_file WHERE id = #{id}
  63. </delete>
  64. <delete id="batchDelete">
  65. DELETE FROM t_cadastre_file
  66. WHERE id IN
  67. <foreach collection="ids" item="id" open="(" separator="," close=")">
  68. #{id}
  69. </foreach>
  70. </delete>
  71. <select id="getList" resultMap="cadastreFileMap">
  72. SELECT <include refid="Base_Column_List"/>
  73. FROM t_cadastre_file
  74. <where>
  75. <if test="name != null and name != ''">
  76. AND name LIKE CONCAT('%', #{name}, '%')
  77. </if>
  78. <if test="status != null and status != ''">
  79. AND status = #{status}
  80. </if>
  81. </where>
  82. </select>
  83. <select id="selectTableRowExcel" resultType="map">
  84. SELECT *
  85. FROM vector.${tableName}
  86. <where>
  87. <if test="bsmList != null and bsmList.size() > 0">
  88. AND bsm IN
  89. <foreach collection="bsmList" item="item" open="(" separator="," close=")">
  90. #{item}
  91. </foreach>
  92. </if>
  93. <if test="ywhList != null and ywhList.size() > 0">
  94. AND ywh IN
  95. <foreach collection="ywhList" item="item" open="(" separator="," close=")">
  96. #{item}
  97. </foreach>
  98. </if>
  99. </where>
  100. </select>
  101. <select id="selectTableCollum" parameterType="String" resultType="String">
  102. select COLUMN_NAME FROM information_schema.COLUMNS
  103. WHERE
  104. table_schema = #{schemaName}
  105. AND TABLE_NAME = #{tableName}
  106. </select>
  107. <select id="selectTableCollumAndType" parameterType="String" resultType="map">
  108. select COLUMN_NAME, DATA_TYPE FROM information_schema.COLUMNS
  109. WHERE
  110. table_schema = #{schemaName}
  111. AND TABLE_NAME = #{tableName}
  112. </select>
  113. <select id="selectDistinctValueByField" parameterType="String" resultType="String">
  114. select distinct ${fieldName} FROM vector.${tableName}
  115. WHERE 1=1
  116. <if test="validFlag != null">
  117. AND valid_flag = #{validFlag}::int2
  118. </if>
  119. </select>
  120. <select id="selectAllTable" resultType="string">
  121. select table_name from information_schema.tables
  122. where table_schema = #{schemaName}
  123. </select>
  124. <select id="selectAllTableNoView" resultType="string">
  125. select table_name from information_schema.tables
  126. where table_schema = 'natural'
  127. </select>
  128. <insert id="insertTableData222">
  129. INSERT INTO ${tableName} (
  130. <foreach collection="tableDataMap" item="map" separator=",">
  131. <foreach collection="map.keySet()" item="key" separator=",">
  132. ${key}
  133. </foreach>
  134. </foreach>
  135. )
  136. VALUES (
  137. <foreach collection="tableDataMap" item="map" separator=",">
  138. <foreach collection="map.values()" item="value" separator=",">
  139. #{value}
  140. </foreach>
  141. </foreach>
  142. )
  143. </insert>
  144. <insert id="insertTableData" parameterType="map">
  145. INSERT INTO vector.${tableName} (
  146. <foreach collection="data" index="key" item="value" separator=",">
  147. ${key}
  148. </foreach>
  149. )
  150. VALUES (
  151. <foreach collection="data" index="key" item="value" separator=",">
  152. <choose>
  153. <when test="key == 'geom' and value != null">
  154. public.st_transform(public.st_geomfromewkt(#{value}), #{shpDbSRID})
  155. </when>
  156. <when test="key == 'valid_flag' and value != null">
  157. #{value}::int2
  158. </when>
  159. <otherwise>
  160. #{value}
  161. </otherwise>
  162. </choose>
  163. </foreach>
  164. )
  165. </insert>
  166. <insert id="batchInsertTableData">
  167. INSERT INTO vector.${tableName} (
  168. <foreach collection="keys" item="key" separator=",">
  169. ${key}
  170. </foreach>
  171. )
  172. VALUES
  173. <foreach collection="dataList" item="data" separator=",">
  174. (
  175. <foreach collection="keys" item="key" separator=",">
  176. <choose>
  177. <!-- 判断 geom 是否为空,并进行转换 -->
  178. <when test="key == 'geom' and data[key] != null">
  179. public.st_transform(public.st_geomfromewkt(#{data[${key}]}), #{shpDbSRID})
  180. </when>
  181. <otherwise>
  182. #{data[${key}]}
  183. </otherwise>
  184. </choose>
  185. </foreach>
  186. )
  187. </foreach>
  188. </insert>
  189. <select id="selectGeoms" resultType="string">
  190. SELECT array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|') as "geoms"
  191. from ${schemaName}.${tableName} gd
  192. <where>
  193. <if test="tableName=='zdjbxx'">
  194. AND gd.valid_flag = 0 AND gd.zt IN ('1', '2')
  195. <if test="landRightType != null and landRightType != ''">
  196. and gd.sm= #{landRightType}
  197. </if>
  198. </if>
  199. </where>
  200. </select>
  201. <select id="countByValidFlag" resultType="int">
  202. SELECT COUNT(*)
  203. FROM vector.${tableName}
  204. WHERE valid_flag = #{validFlag}::int2
  205. </select>
  206. <update id="addValidFlagColumn">
  207. COMMENT ON COLUMN natural.${tableName}."valid_flag" IS '有效标识:0-当前版本,1-历史版本';
  208. </update>
  209. <update id="addValidFlagColumn2">
  210. ALTER TABLE vector.${tableName} ADD COLUMN IF NOT EXISTS valid_flag int2
  211. </update>
  212. <select id="getListByFilter" parameterType="com.siwei.apply.domain.vo.CadastreFileFilterVo" resultMap="cadastreFileMap">
  213. SELECT <include refid="Base_Column_List"/>
  214. FROM t_cadastre_file
  215. <where>
  216. <if test="name != null and name != ''">
  217. AND name LIKE CONCAT('%', #{name}, '%')
  218. </if>
  219. <if test="fileType != null and fileType != '' and fileType != 0">
  220. AND file_type = #{fileType}
  221. </if>
  222. <if test="storageBeginTime != null and storageBeginTime != ''"><!-- 结束时间检索 -->
  223. AND "upload_time" &gt;= TO_TIMESTAMP(#{storageBeginTime}, 'YYYY-MM-DD HH24:MI:SS')
  224. </if>
  225. <if test="storageEndTime != null and storageEndTime != ''"><!-- 结束时间检索 -->
  226. AND "upload_time" &lt;= TO_TIMESTAMP(#{storageEndTime}, 'YYYY-MM-DD HH24:MI:SS')+ INTERVAL '1 day'
  227. </if>
  228. <if test="readStatus != null and readStatus != ''">
  229. AND read_status = #{readStatus}
  230. </if>
  231. <if test="status != null and status != ''">
  232. AND status = #{status}
  233. </if>
  234. </where>
  235. ORDER BY upload_time DESC
  236. LIMIT #{pageSize} OFFSET #{offset}
  237. </select>
  238. <select id="getCountByFilter" parameterType="com.siwei.apply.domain.vo.CadastreFileFilterVo" resultType="int">
  239. SELECT COUNT(*)
  240. FROM t_cadastre_file
  241. <where>
  242. <if test="name != null and name != ''">
  243. AND name LIKE CONCAT('%', #{name}, '%')
  244. </if>
  245. <if test="fileType != null and fileType != ''">
  246. AND file_type = #{fileType}
  247. </if>
  248. <if test="storageBeginTime != null and storageBeginTime != ''"><!-- 结束时间检索 -->
  249. AND "upload_time" &gt;= TO_TIMESTAMP(#{storageBeginTime}, 'YYYY-MM-DD HH24:MI:SS')
  250. </if>
  251. <if test="storageEndTime != null and storageEndTime != ''"><!-- 结束时间检索 -->
  252. AND "upload_time" &lt;= TO_TIMESTAMP(#{storageEndTime}, 'YYYY-MM-DD HH24:MI:SS')+ INTERVAL '1 day'
  253. </if>
  254. <!-- <if test="uploadTime != null and uploadTime != ''">-->
  255. <!-- AND to_char(upload_time, 'YYYY-MM-DD') = #{uploadTime}-->
  256. <!-- </if>-->
  257. <if test="readStatus != null and readStatus != ''">
  258. AND read_status = #{readStatus}
  259. </if>
  260. <if test="status != null and status != ''">
  261. AND status = #{status}
  262. </if>
  263. </where>
  264. </select>
  265. <update id="updateValidFlag">
  266. UPDATE vector.${tableName} SET valid_flag = #{validFlag}::int2 WHERE 1=1
  267. <if test="oldValidFlag != null and oldValidFlag != ''">
  268. and valid_flag= #{oldValidFlag}::int2
  269. </if>
  270. <!-- 兼容宗地相关的权力类型 -->
  271. <if test="landRightType != null and landRightType != ''">
  272. and sm= #{landRightType}
  273. </if>
  274. </update>
  275. <delete id="deleteByValidFlag">
  276. DELETE FROM vector.${tableName}
  277. WHERE valid_flag = #{validFlag}::int2
  278. <if test="landRightType != null and landRightType != ''">
  279. and sm= #{landRightType}
  280. </if>
  281. </delete>
  282. <select id="selectTableData" resultType="Map">
  283. SELECT *
  284. FROM vector.${tableName} WHERE 1=1
  285. <if test="validFlag != null and validFlag != ''">
  286. and valid_flag= #{validFlag}::int2
  287. </if>
  288. <if test="landRightType != null and landRightType != ''">
  289. and sm= #{landRightType}
  290. </if>
  291. </select>
  292. <select id="selectTableDataByCondition" resultType="Map">
  293. SELECT *
  294. FROM vector.${tableName}
  295. WHERE 1=1
  296. <if test="validFlag != null and validFlag != ''">
  297. and valid_flag = #{validFlag}::int2
  298. </if>
  299. <if test="bsm != null and bsm != ''">
  300. and bsm= #{bsm}::int4
  301. </if>
  302. <if test="ywh != null and ywh != ''">
  303. and ${ywh}
  304. </if>
  305. <if test="needLimit != null and needLimit">
  306. LIMIT 100
  307. </if>
  308. </select>
  309. <select id="selectTableDataByZDDMorBDCDYH" resultType="Map">
  310. SELECT *
  311. FROM vector.${tableName}
  312. WHERE 1=1
  313. <if test="validFlag != null and validFlag != ''">
  314. and valid_flag = #{validFlag}::int2
  315. </if>
  316. <if test="zdIdList != null and zdIdList.size() > 0">
  317. AND ${zddmKey} IN
  318. <foreach collection="zdIdList" item="id" open="(" separator="," close=")">
  319. #{id}
  320. </foreach>
  321. </if>
  322. <if test="bdcIdList != null and bdcIdList.size() > 0">
  323. AND bdcdyh IN
  324. <foreach collection="bdcIdList" item="id" open="(" separator="," close=")">
  325. #{id}
  326. </foreach>
  327. </if>
  328. </select>
  329. <select id="selectExistsSameData" resultType="Map">
  330. SELECT * FROM vector.${tableName}
  331. WHERE valid_flag = #{validFlag}::int2
  332. <if test="data.rwbsm != null and data.rwbsm!='' ">
  333. AND rwbsm = #{data.rwbsm}
  334. </if>
  335. <if test="data.geom != null and data.geom!='' ">
  336. AND public.ST_Equals(geom,public.st_geomfromewkt(#{data.geom}))
  337. </if>
  338. LIMIT 1
  339. </select>
  340. <update id="batchUpdateByBsm">
  341. <foreach collection="list" item="data" separator=";">
  342. UPDATE vector.${tableName}
  343. <trim prefix="SET" suffixOverrides=",">
  344. <foreach collection="data" index="key" item="value">
  345. <if test="key != 'bsm' and key != 'ywh' and value != null and value != ''">
  346. <choose>
  347. <when test="key == 'geom'">
  348. ${key} = #{value},
  349. </when>
  350. <otherwise>
  351. ${key} = #{value},
  352. </otherwise>
  353. </choose>
  354. </if>
  355. </foreach>
  356. </trim>
  357. <where>
  358. <if test="data.bsm != null and data.bsm != ''">
  359. AND bsm = #{data.bsm}
  360. </if>
  361. <if test="data.ywh != null and data.ywh != ''">
  362. AND ywh = #{data.ywh}
  363. </if>
  364. </where>
  365. </foreach>
  366. </update>
  367. <delete id="batchDeleteByBsm">
  368. <foreach collection="list" item="data" separator=";">
  369. DELETE FROM vector.${tableName}
  370. <where>
  371. <if test="data.bsm != null and data.bsm != ''">
  372. AND bsm = #{data.bsm}
  373. </if>
  374. <if test="data.ywh != null and data.ywh != ''">
  375. AND ywh = #{data.ywh}
  376. </if>
  377. </where>
  378. </foreach>
  379. </delete>
  380. <select id="intersectsTableWkt" resultType="Map">
  381. SELECT *
  382. FROM vector.${tableName} inTbale
  383. where public.st_intersects(inTbale.geom,public.st_geomfromewkt(#{ewkt}))
  384. <if test="validFlag != null and validFlag != ''">
  385. and valid_flag = #{validFlag}::int2
  386. </if>
  387. </select>
  388. <select id="selectTableDataByBsm" resultType="Map">
  389. SELECT * ,public.st_asewkt(geom) geom2 FROM vector.${tableName}
  390. WHERE valid_flag = 0
  391. <if test="bsm != null and bsm != ''">
  392. and bsm= ${bsm}
  393. </if>
  394. LIMIT 1
  395. </select>
  396. <select id="selectTableUnionEwkt" resultType="String">
  397. SELECT public.st_asewkt(public.st_multi(public.st_union(geom))) geom2
  398. FROM vector.${tableName}
  399. WHERE 1=1
  400. <if test="validFlag != null and validFlag != ''">
  401. and valid_flag = #{validFlag}::int2
  402. </if>
  403. </select>
  404. <select id="checkQueryWhere" resultType="String">
  405. EXPLAIN (FORMAT JSON)
  406. SELECT 1 FROM vector.${tableName} WHERE ${queryWhere} LIMIT 1
  407. </select>
  408. <select id="transformTo4326" resultType="String">
  409. SELECT public.st_asewkt(wktField) from
  410. (SELECT public.st_transform(public.st_geomfromewkt(#{ewkt}), 4326) as wktField)
  411. </select>
  412. <select id="selectQlrList" resultType="Map">
  413. SELECT *
  414. FROM vector.qlr
  415. where 1=1
  416. <if test="validFlag != null and validFlag != ''">
  417. and valid_flag = #{validFlag}::int2
  418. </if>
  419. <if test="name != null and name != ''">
  420. and qlrmc LIKE CONCAT('%', #{name}, '%')
  421. </if>
  422. </select>
  423. <!-- ========================================这里数据治理的相关sql:modify 20260914====================================================== -->
  424. <!--<select id="getIntersectsGeomZdList" resultType="map">-->
  425. <!-- ELSE ST_Area(ST_Intersection(public.ST_GeomFromEWKT(#{ewkt}), zd.geom)) / ST_Area(zd.geom) > 0.9-->
  426. <select id="getIntersectsGeomZdList" resultType="Map">
  427. SELECT *
  428. FROM vector.zd_shp zd
  429. where 1=1
  430. AND CASE
  431. WHEN NULLIF(ST_Area(zd.geom,true),0) IS NULL THEN false
  432. ELSE ST_Area(ST_Intersection((SELECT geom from t_geom_db_details WHERE id=#{detailsId}), zd.geom),true) / ST_Area(zd.geom,true) > 0.9
  433. END
  434. </select>
  435. </mapper>