CadastreFileMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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. </resultMap>
  23. <sql id="Base_Column_List">
  24. 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
  25. </sql>
  26. <insert id="add" parameterType="com.siwei.apply.domain.CadastreFile">
  27. INSERT INTO t_cadastre_file (
  28. 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
  29. ) VALUES (
  30. #{id}, #{name}, #{uploadUser}, #{uploadTime}, #{filePath}, #{proxyPath}, #{unzipPath}, #{fileType}, #{storage}, #{status}, #{readStatus}, #{readMessage}, #{fileStorageTime}, #{updateTime}, #{fileSize}
  31. )
  32. </insert>
  33. <select id="get" resultMap="cadastreFileMap">
  34. SELECT <include refid="Base_Column_List"/>
  35. FROM t_cadastre_file
  36. WHERE id = #{id}
  37. </select>
  38. <update id="update" parameterType="com.siwei.apply.domain.CadastreFile">
  39. UPDATE t_cadastre_file
  40. <set>
  41. <if test="name != null">name = #{name},</if>
  42. <if test="uploadUser != null">upload_user = #{uploadUser},</if>
  43. <if test="uploadTime != null">upload_time = #{uploadTime},</if>
  44. <if test="filePath != null">file_path = #{filePath},</if>
  45. <if test="proxyPath != null">proxy_path = #{proxyPath},</if>
  46. <if test="unzipPath != null">unzip_path = #{unzipPath},</if>
  47. <if test="fileType != null">file_type = #{fileType},</if>
  48. <if test="storage != null">storage = #{storage},</if>
  49. <if test="status != null">status = #{status},</if>
  50. <if test="readStatus != null">read_status = #{readStatus},</if>
  51. <if test="readMessage != null">read_message = #{readMessage},</if>
  52. <if test="fileStorageTime != null">file_storage_time = #{fileStorageTime},</if>
  53. <if test="updateTime != null">update_time = #{updateTime},</if>
  54. <if test="fileSize != null">file_size = #{fileSize},</if>
  55. </set>
  56. WHERE id = #{id}
  57. </update>
  58. <delete id="delete">
  59. DELETE FROM t_cadastre_file WHERE id = #{id}
  60. </delete>
  61. <delete id="batchDelete">
  62. DELETE FROM t_cadastre_file
  63. WHERE id IN
  64. <foreach collection="ids" item="id" open="(" separator="," close=")">
  65. #{id}
  66. </foreach>
  67. </delete>
  68. <select id="getList" resultMap="cadastreFileMap">
  69. SELECT <include refid="Base_Column_List"/>
  70. FROM t_cadastre_file
  71. <where>
  72. <if test="name != null and name != ''">
  73. AND name LIKE CONCAT('%', #{name}, '%')
  74. </if>
  75. <if test="status != null and status != ''">
  76. AND status = #{status}
  77. </if>
  78. </where>
  79. </select>
  80. <select id="selectTableRowExcel" resultType="map">
  81. SELECT *
  82. FROM vector.${tableName}
  83. <where>
  84. <if test="bsmList != null and bsmList.size() > 0">
  85. AND bsm IN
  86. <foreach collection="bsmList" item="item" open="(" separator="," close=")">
  87. #{item}
  88. </foreach>
  89. </if>
  90. <if test="ywhList != null and ywhList.size() > 0">
  91. AND ywh IN
  92. <foreach collection="ywhList" item="item" open="(" separator="," close=")">
  93. #{item}
  94. </foreach>
  95. </if>
  96. </where>
  97. </select>
  98. <select id="selectTableCollum" parameterType="String" resultType="String">
  99. select COLUMN_NAME FROM information_schema.COLUMNS
  100. WHERE
  101. table_schema = 'vector'
  102. AND TABLE_NAME = #{tableName}
  103. </select>
  104. <select id="selectTableCollumAndType" parameterType="String" resultType="map">
  105. select COLUMN_NAME, DATA_TYPE FROM information_schema.COLUMNS
  106. WHERE
  107. table_schema = 'vector'
  108. AND TABLE_NAME = #{tableName}
  109. </select>
  110. <select id="selectDistinctValueByField" parameterType="String" resultType="String">
  111. select distinct ${fieldName} FROM vector.${tableName}
  112. WHERE valid_flag = 0
  113. </select>
  114. <select id="selectAllTable" resultType="string">
  115. select table_name from information_schema.tables
  116. where table_schema = 'vector'
  117. </select>
  118. <select id="selectAllTableNoView" resultType="string">
  119. select table_name from information_schema.tables
  120. where table_schema = 'vector'
  121. </select>
  122. <insert id="insertTableData222">
  123. INSERT INTO ${tableName} (
  124. <foreach collection="tableDataMap" item="map" separator=",">
  125. <foreach collection="map.keySet()" item="key" separator=",">
  126. ${key}
  127. </foreach>
  128. </foreach>
  129. )
  130. VALUES (
  131. <foreach collection="tableDataMap" item="map" separator=",">
  132. <foreach collection="map.values()" item="value" separator=",">
  133. #{value}
  134. </foreach>
  135. </foreach>
  136. )
  137. </insert>
  138. <insert id="insertTableData">
  139. INSERT INTO vector.${tableName} (
  140. <foreach collection="data" index="key" item="value" separator=",">
  141. ${key}
  142. </foreach>
  143. )
  144. VALUES (
  145. <foreach collection="data" index="key" item="value" separator=",">
  146. <choose>
  147. <!-- 判断 geom 是否为空,并进行转换 -->
  148. <when test="key == 'geom' and value != null">
  149. public.st_transform(public.st_geomfromewkt(#{value}), #{shpDbSRID})
  150. </when>
  151. <otherwise>
  152. #{value}
  153. </otherwise>
  154. </choose>
  155. </foreach>
  156. )
  157. </insert>
  158. <insert id="batchInsertTableData">
  159. INSERT INTO vector.${tableName} (
  160. <foreach collection="keys" item="key" separator=",">
  161. ${key}
  162. </foreach>
  163. )
  164. VALUES
  165. <foreach collection="dataList" item="data" separator=",">
  166. (
  167. <foreach collection="keys" item="key" separator=",">
  168. <choose>
  169. <!-- 判断 geom 是否为空,并进行转换 -->
  170. <when test="key == 'geom' and data[key] != null">
  171. public.st_transform(public.st_geomfromewkt(#{data[${key}]}), #{shpDbSRID})
  172. </when>
  173. <otherwise>
  174. #{data[${key}]}
  175. </otherwise>
  176. </choose>
  177. </foreach>
  178. )
  179. </foreach>
  180. </insert>
  181. <select id="selectGeoms" resultType="string">
  182. SELECT array_to_string(array_agg(ST_AsEWKT(gd.geom)), '|') as "geoms"
  183. from vector.${tableName} gd
  184. </select>
  185. <select id="countByValidFlag" resultType="int">
  186. SELECT COUNT(*)
  187. FROM vector.${tableName}
  188. WHERE valid_flag = #{validFlag}
  189. </select>
  190. <update id="addValidFlagColumn">
  191. COMMENT ON COLUMN vector.${tableName}."valid_flag" IS '有效标识:0-当前版本,1-历史版本';
  192. </update>
  193. <update id="addValidFlagColumn2">
  194. ALTER TABLE vector.${tableName} ADD COLUMN IF NOT EXISTS valid_flag int2
  195. </update>
  196. <select id="getListByFilter" parameterType="com.siwei.apply.domain.vo.CadastreFileFilterVo" resultMap="cadastreFileMap">
  197. SELECT <include refid="Base_Column_List"/>
  198. FROM t_cadastre_file
  199. <where>
  200. <if test="name != null and name != ''">
  201. AND name LIKE CONCAT('%', #{name}, '%')
  202. </if>
  203. <if test="fileType != null and fileType != ''">
  204. AND file_type = #{fileType}
  205. </if>
  206. <if test="storageBeginTime != null and storageBeginTime != ''"><!-- 结束时间检索 -->
  207. AND "upload_time" &gt;= TO_TIMESTAMP(#{storageBeginTime}, 'YYYY-MM-DD HH24:MI:SS')
  208. </if>
  209. <if test="storageEndTime != null and storageEndTime != ''"><!-- 结束时间检索 -->
  210. AND "upload_time" &lt;= TO_TIMESTAMP(#{storageEndTime}, 'YYYY-MM-DD HH24:MI:SS')+ INTERVAL '1 day'
  211. </if>
  212. <if test="readStatus != null and readStatus != ''">
  213. AND read_status = #{readStatus}
  214. </if>
  215. </where>
  216. ORDER BY upload_time DESC
  217. LIMIT #{pageSize} OFFSET #{offset}
  218. </select>
  219. <select id="getCountByFilter" parameterType="com.siwei.apply.domain.vo.CadastreFileFilterVo" resultType="int">
  220. SELECT COUNT(*)
  221. FROM t_cadastre_file
  222. <where>
  223. <if test="name != null and name != ''">
  224. AND name LIKE CONCAT('%', #{name}, '%')
  225. </if>
  226. <if test="fileType != null and fileType != ''">
  227. AND file_type = #{fileType}
  228. </if>
  229. <if test="storageBeginTime != null and storageBeginTime != ''"><!-- 结束时间检索 -->
  230. AND "upload_time" &gt;= TO_TIMESTAMP(#{storageBeginTime}, 'YYYY-MM-DD HH24:MI:SS')
  231. </if>
  232. <if test="storageEndTime != null and storageEndTime != ''"><!-- 结束时间检索 -->
  233. AND "upload_time" &lt;= TO_TIMESTAMP(#{storageEndTime}, 'YYYY-MM-DD HH24:MI:SS')+ INTERVAL '1 day'
  234. </if>
  235. <!-- <if test="uploadTime != null and uploadTime != ''">-->
  236. <!-- AND to_char(upload_time, 'YYYY-MM-DD') = #{uploadTime}-->
  237. <!-- </if>-->
  238. <if test="readStatus != null and readStatus != ''">
  239. AND read_status = #{readStatus}
  240. </if>
  241. </where>
  242. </select>
  243. <update id="updateValidFlag">
  244. UPDATE vector.${tableName} SET valid_flag = #{validFlag} WHERE 1=1
  245. <if test="oldValidFlag != null and oldValidFlag != ''">
  246. and valid_flag= #{oldValidFlag}
  247. </if>
  248. </update>
  249. <delete id="deleteByValidFlag">
  250. DELETE FROM vector.${tableName} WHERE valid_flag = #{validFlag}
  251. </delete>
  252. <select id="selectTableData" resultType="Map">
  253. SELECT *
  254. FROM vector.${tableName} WHERE 1=1
  255. <if test="validFlag != null and validFlag != ''">
  256. and valid_flag= #{validFlag}
  257. </if>
  258. </select>
  259. <select id="selectTableDataByCondition" resultType="Map">
  260. SELECT *
  261. FROM vector.${tableName}
  262. WHERE 1=1
  263. <if test="validFlag != null and validFlag != ''">
  264. and valid_flag = #{validFlag}::int2
  265. </if>
  266. <if test="bsm != null and bsm != ''">
  267. and bsm= #{bsm}::int4
  268. </if>
  269. <if test="ywh != null and ywh != ''">
  270. and ${ywh}
  271. </if>
  272. LIMIT 100
  273. </select>
  274. <select id="selectTableDataByZDDMorBDCDYH" resultType="Map">
  275. SELECT *
  276. FROM vector.${tableName}
  277. WHERE 1=1
  278. <if test="validFlag != null and validFlag != ''">
  279. and valid_flag = #{validFlag}::int2
  280. </if>
  281. <if test="zdIdList != null and zdIdList.size() > 0">
  282. AND ${zddmKey} IN
  283. <foreach collection="zdIdList" item="id" open="(" separator="," close=")">
  284. #{id}
  285. </foreach>
  286. </if>
  287. <if test="bdcIdList != null and bdcIdList.size() > 0">
  288. AND bdcdyh IN
  289. <foreach collection="bdcIdList" item="id" open="(" separator="," close=")">
  290. #{id}
  291. </foreach>
  292. </if>
  293. </select>
  294. <select id="selectExistsSameData" resultType="Map">
  295. SELECT * FROM vector.${tableName}
  296. WHERE valid_flag = #{validFlag}
  297. <if test="data.rwbsm != null and data.rwbsm!='' ">
  298. AND rwbsm = #{data.rwbsm}
  299. </if>
  300. <if test="data.geom != null and data.geom!='' ">
  301. AND public.ST_Equals(geom,public.st_geomfromewkt(#{data.geom}))
  302. </if>
  303. LIMIT 1
  304. </select>
  305. <update id="batchUpdateByBsm">
  306. <foreach collection="list" item="data" separator=";">
  307. UPDATE vector.${tableName}
  308. <trim prefix="SET" suffixOverrides=",">
  309. <foreach collection="data" index="key" item="value">
  310. <if test="key != 'bsm' and key != 'ywh' and value != null and value != ''">
  311. <choose>
  312. <when test="key == 'geom'">
  313. ${key} = #{value},
  314. </when>
  315. <otherwise>
  316. ${key} = #{value},
  317. </otherwise>
  318. </choose>
  319. </if>
  320. </foreach>
  321. </trim>
  322. <where>
  323. <if test="data.bsm != null and data.bsm != ''">
  324. AND bsm = #{data.bsm}
  325. </if>
  326. <if test="data.ywh != null and data.ywh != ''">
  327. AND ywh = #{data.ywh}
  328. </if>
  329. </where>
  330. </foreach>
  331. </update>
  332. <delete id="batchDeleteByBsm">
  333. <foreach collection="list" item="data" separator=";">
  334. DELETE FROM vector.${tableName}
  335. <where>
  336. <if test="data.bsm != null and data.bsm != ''">
  337. AND bsm = #{data.bsm}
  338. </if>
  339. <if test="data.ywh != null and data.ywh != ''">
  340. AND ywh = #{data.ywh}
  341. </if>
  342. </where>
  343. </foreach>
  344. </delete>
  345. <select id="intersectsTableWkt" resultType="Map">
  346. SELECT *
  347. FROM vector.${tableName} inTbale
  348. where public.st_intersects(inTbale.geom,public.st_geomfromewkt(#{ewkt}))
  349. <if test="validFlag != null and validFlag != ''">
  350. and valid_flag = #{validFlag}
  351. </if>
  352. </select>
  353. <select id="selectTableDataByBsm" resultType="Map">
  354. SELECT * ,public.st_asewkt(geom) geom2 FROM vector.${tableName}
  355. WHERE valid_flag = 0
  356. <if test="bsm != null and bsm != ''">
  357. and bsm= ${bsm}
  358. </if>
  359. LIMIT 1
  360. </select>
  361. <select id="checkQueryWhere" resultType="String">
  362. EXPLAIN (FORMAT JSON)
  363. SELECT 1 FROM vector.${tableName} WHERE ${queryWhere} LIMIT 1
  364. </select>
  365. </mapper>