TGeomDbDetailsMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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.spatial.mapper.file.TGeomDbDetailsMapper">
  6. <resultMap type="TGeomDbDetails" id="TGeomDbDetailsResult">
  7. <result property="id" column="id" />
  8. <result property="geom" column="geom" />
  9. <result property="uploadId" column="upload_id" />
  10. <result property="geomJson" column="geom_json" />
  11. <result property="sort" column="sort" />
  12. <result property="geomArea" column="geom_area" />
  13. </resultMap>
  14. <resultMap type="TGeomDb" id="TGeomDbResult">
  15. <result property="id" column="id" />
  16. <result property="name" column="name" />
  17. <result property="createBy" column="create_by" />
  18. <result property="createTime" column="create_time" />
  19. <result property="shppath" column="shppath" />
  20. <result property="filetype" column="filetype" />
  21. <result property="geom" column="geom" />
  22. <result property="geomNumber" column="geom_number" />
  23. <result property="geomArea" column="geom_area" />
  24. <result property="fromroute" column="fromroute" />
  25. </resultMap>
  26. <sql id="selectTGeomDbDetailsVo">
  27. select id, public.st_asewkt(geom) AS geom, upload_id, geom_json, sort, geom_area from t_geom_db_details
  28. </sql>
  29. <select id="selectTGeomDbDetailsList" parameterType="TGeomDbDetails" resultMap="TGeomDbDetailsResult">
  30. <include refid="selectTGeomDbDetailsVo"/>
  31. <where>
  32. <if test="geom != null and geom != ''"> and geom = #{geom}</if>
  33. <if test="uploadId != null and uploadId != ''"> and upload_id = #{uploadId}</if>
  34. <if test="geomJson != null and geomJson != ''"> and geom_json = #{geomJson}</if>
  35. <if test="sort != null and sort != ''"> and sort = #{sort}</if>
  36. <if test="geomArea != null and geomArea != ''"> and geom_area = #{geomArea}</if>
  37. </where>
  38. </select>
  39. <select id="selectTGeomDbDetailsById" parameterType="String" resultMap="TGeomDbDetailsResult">
  40. <include refid="selectTGeomDbDetailsVo"/>
  41. where id = #{id}
  42. </select>
  43. <select id="selectTGeomDbDetailsByNodeId" parameterType="String" resultMap="TGeomDbDetailsResult">
  44. select details.id, public.st_asewkt(details.geom) AS geom, details.upload_id, details.geom_json, details.sort, details.geom_area
  45. from t_geom_db_details details
  46. INNER JOIN t_node_land node on node.geom_db_id=details.upload_id
  47. WHERE node.node_id =#{nodeId}
  48. </select>
  49. <insert id="insertTGeomDbDetails" parameterType="TGeomDbDetails">
  50. insert into t_geom_db_details
  51. <trim prefix="(" suffix=")" suffixOverrides=",">
  52. <if test="id != null and id != ''">id,</if>
  53. <if test="geom != null">geom,</if>
  54. <if test="uploadId != null and uploadId != ''">upload_id,</if>
  55. <if test="geomJson != null">geom_json,</if>
  56. <if test="sort != null">sort,</if>
  57. <if test="geom != null">geom_area,</if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="id != null and id != ''">#{id},</if>
  61. <if test="geom != null">public.st_transform(public.st_geomfromewkt(#{geom}), #{shpDbSRID}),</if>
  62. <if test="uploadId != null and uploadId != ''">#{uploadId},</if>
  63. <if test="geomJson != null">#{geomJson},</if>
  64. <if test="sort != null">#{sort},</if>
  65. <if test="geom != null">
  66. public.st_area(public.st_transform(public.st_geomfromewkt(#{geom}), #{shpAreaSRID})
  67. <if test="shpAreaGeography != null and shpAreaGeography==true ">::PUBLIC.geography</if>
  68. ),
  69. </if>
  70. </trim>
  71. </insert>
  72. <update id="updateTGeomDbDetails" parameterType="TGeomDbDetails">
  73. update t_geom_db_details
  74. <trim prefix="SET" suffixOverrides=",">
  75. <if test="geom != null">geom = #{geom},</if>
  76. <if test="uploadId != null and uploadId != ''">upload_id = #{uploadId},</if>
  77. <if test="geomJson != null">geom_json = #{geomJson},</if>
  78. <if test="sort != null">sort = #{sort},</if>
  79. <if test="geomArea != null">geom_area = #{geomArea},</if>
  80. </trim>
  81. where id = #{id}
  82. </update>
  83. <delete id="deleteTGeomDbDetailsById" parameterType="String">
  84. delete from t_geom_db_details where id = #{id}
  85. </delete>
  86. <delete id="deleteTGeomDbDetailsByIds" parameterType="String">
  87. delete from t_geom_db_details where id in
  88. <foreach item="id" collection="array" open="(" separator="," close=")">
  89. #{id}
  90. </foreach>
  91. </delete>
  92. <select id="sumGeomDetailsByUploadId" parameterType="String" resultMap="TGeomDbResult" >
  93. select public.st_asewkt(public.st_union(geom)) AS geom, count(*) geom_number, sum(geom_area) geom_area
  94. from t_geom_db_details where upload_id = #{id}
  95. </select>
  96. <insert id="batchInsertDjzq">
  97. INSERT INTO vector.djzq (bsm, ysdm, djzqdm, djzqmc, bz, geom, valid_flag)
  98. VALUES
  99. <foreach collection="list" item="item" separator=",">
  100. (
  101. #{item.bsm},
  102. #{item.ysdm},
  103. #{item.djzqdm},
  104. #{item.djzqmc},
  105. #{item.projectid},
  106. <choose>
  107. <when test="item.the_geom != null and item.the_geom != ''">
  108. public.st_transform(public.st_geomfromewkt(#{item.the_geom}), #{shpDbSRID})
  109. </when>
  110. <otherwise>
  111. null
  112. </otherwise>
  113. </choose>,
  114. 0
  115. )
  116. </foreach>
  117. </insert>
  118. <insert id="batchInsertDjq">
  119. INSERT INTO vector.djq (bsm, ysdm, djqdm, djqmc, bz, geom, valid_flag)
  120. VALUES
  121. <foreach collection="list" item="item" separator=",">
  122. (
  123. #{item.bsm},
  124. #{item.ysdm},
  125. #{item.djqdm},
  126. #{item.djqmc},
  127. #{item.projectid},
  128. <choose>
  129. <when test="item.the_geom != null and item.the_geom != ''">
  130. public.st_transform(public.st_geomfromewkt(#{item.the_geom}), #{shpDbSRID})
  131. </when>
  132. <otherwise>
  133. null
  134. </otherwise>
  135. </choose>,
  136. 0
  137. )
  138. </foreach>
  139. </insert>
  140. <insert id="batchInsertJzwShp">
  141. INSERT INTO vector.fw (
  142. objectid,
  143. bsm,
  144. ysdm,
  145. bdcdyh,
  146. zddm,
  147. xzqdm,
  148. zh,
  149. xmmc,
  150. jzwmc,
  151. jgrq,
  152. jzwgd,
  153. zzdmj,
  154. zydmj,
  155. ycjzmj,
  156. scjzmj,
  157. jzwjbyt,
  158. zcs,
  159. dscs,
  160. dxcs,
  161. dxsd,
  162. ghyt,
  163. fwjg,
  164. zts,
  165. bz,
  166. zt,
  167. tstybm,
  168. zrzh,
  169. lplb,
  170. zl,
  171. bgjzxx,
  172. bgtsxx,
  173. rkxh,
  174. rkr,
  175. rksj,
  176. ytmc,
  177. dah,
  178. srctable,
  179. from_id,
  180. to_id,
  181. projectid,
  182. shape_area,
  183. shape_len,
  184. geom
  185. )
  186. VALUES
  187. <foreach collection="list" item="item" separator=",">
  188. (
  189. #{item.objectid},
  190. #{item.bsm},
  191. #{item.ysdm},
  192. #{item.bdcdyh},
  193. #{item.zddm},
  194. #{item.xzqdm},
  195. #{item.zh},
  196. #{item.xmmc},
  197. #{item.jzwmc},
  198. #{item.jgrq},
  199. #{item.jzwgd},
  200. #{item.zzdmj},
  201. #{item.zydmj},
  202. #{item.ycjzmj},
  203. #{item.scjzmj},
  204. #{item.jzwjbyt},
  205. #{item.zcs},
  206. #{item.dscs},
  207. #{item.dxcs},
  208. #{item.dxsd},
  209. #{item.ghyt},
  210. #{item.fwjg},
  211. #{item.zts},
  212. #{item.bz},
  213. #{item.zt},
  214. #{item.tstybm},
  215. #{item.zrzh},
  216. #{item.lplb},
  217. #{item.zl},
  218. #{item.bgjzxx},
  219. #{item.bgtsxx},
  220. #{item.rkxh},
  221. #{item.rkr},
  222. #{item.rksj},
  223. #{item.ytmc},
  224. #{item.dah},
  225. #{item.srctable},
  226. #{item.from_id},
  227. #{item.to_id},
  228. #{item.projectid},
  229. #{item.shape_area},
  230. #{item.shape_len},
  231. <choose>
  232. <when test="item.the_geom != null and item.the_geom != ''">
  233. public.st_transform(
  234. public.st_geomfromewkt(#{item.the_geom}),
  235. #{shpDbSRID}
  236. )
  237. </when>
  238. <otherwise>
  239. null
  240. </otherwise>
  241. </choose>
  242. )
  243. </foreach>
  244. </insert>
  245. <insert id="batchInsertZdShp">
  246. INSERT INTO vector.zd_shp (
  247. objectid,bsm,ysdm,bdcdyh,zddm,zdtzm,zl,midw,
  248. zdmj,yt,dj,jg,qllx,qlxz,qlsdfs,rjl,jzmd,jzxg,
  249. zdszd,zdszn,zdszx,zdszb,tfh,djh,qlrmc,jzmj,jzwzdmj,
  250. zt,bhyy,bhnr,djsj,dbr,fj,tstybm,xzqdm,sjzdtybm,
  251. fzmj,ybzddm,jzlb,syqx,qsrq,zzrq,bgjzxx,bgtsxx,
  252. dah,rkxh,rkr,rksj,ytmc,zdt,bz,srctable,
  253. from_id,to_id,projectid,txzt,jdzt,ywh,bdcqzh,
  254. ydyhfl,shape_area,shape_len,geom
  255. )
  256. VALUES
  257. <foreach collection="list" item="item" separator=",">
  258. (
  259. #{item.objectid},
  260. #{item.bsm},
  261. #{item.ysdm},
  262. #{item.bdcdyh},
  263. #{item.zddm},
  264. #{item.zdtzm},
  265. #{item.zl},
  266. #{item.midw},
  267. #{item.zdmj},
  268. #{item.yt},
  269. #{item.dj},
  270. #{item.jg},
  271. #{item.qllx},
  272. #{item.qlxz},
  273. #{item.qlsdfs},
  274. #{item.rjl},
  275. #{item.jzmd},
  276. #{item.jzxg},
  277. #{item.zdszd},
  278. #{item.zdszn},
  279. #{item.zdszx},
  280. #{item.zdszb},
  281. #{item.tfh},
  282. #{item.djh},
  283. #{item.qlrmc},
  284. #{item.jzmj},
  285. #{item.jzwzdmj},
  286. #{item.zt},
  287. #{item.bhyy},
  288. #{item.bhnr},
  289. #{item.djsj},
  290. #{item.dbr},
  291. #{item.fj},
  292. #{item.tstybm},
  293. #{item.xzqdm},
  294. #{item.sjzdtybm},
  295. #{item.fzmj},
  296. #{item.ybzddm},
  297. #{item.jzlb},
  298. #{item.syqx},
  299. #{item.qsrq},
  300. #{item.zzrq},
  301. #{item.bgjzxx},
  302. #{item.bgtsxx},
  303. #{item.dah},
  304. #{item.rkxh},
  305. #{item.rkr},
  306. #{item.rksj},
  307. #{item.ytmc},
  308. #{item.zdt},
  309. #{item.bz},
  310. #{item.srctable},
  311. #{item.from_id},
  312. #{item.to_id},
  313. #{item.projectid},
  314. #{item.txzt},
  315. #{item.jdzt},
  316. #{item.ywh},
  317. #{item.bdcqzh},
  318. #{item.ydyhfl},
  319. #{item.shape_area},
  320. #{item.shape_len},
  321. <choose>
  322. <when test="item.the_geom != null and item.the_geom != ''">
  323. public.st_transform(
  324. public.st_geomfromewkt(#{item.the_geom}),
  325. #{shpDbSRID}
  326. )
  327. </when>
  328. <otherwise>
  329. null
  330. </otherwise>
  331. </choose>
  332. )
  333. </foreach>
  334. </insert>
  335. <insert id="insertTableData">
  336. INSERT INTO vector.${tableName} (
  337. <foreach collection="data" index="key" item="value" separator=",">
  338. ${key}
  339. </foreach>
  340. )
  341. VALUES (
  342. <foreach collection="data" index="key" item="value" separator=",">
  343. <choose>
  344. <!-- 判断 geom 是否为空,并进行转换 -->
  345. <when test="key == 'geom' and value != null">
  346. public.st_transform(public.st_geomfromewkt(#{value}), #{shpDbSRID})
  347. </when>
  348. <otherwise>
  349. #{value}
  350. </otherwise>
  351. </choose>
  352. </foreach>
  353. )
  354. </insert>
  355. <select id="selectTableDataAndGeom" resultType="Map">
  356. SELECT * ,public.st_asewkt(geom) AS geom2
  357. FROM vector.${tableName}
  358. WHERE 1=1
  359. </select>
  360. <select id="selectTableDjzq" resultType="Map">
  361. SELECT bsm, ysdm, djzqdm, djzqmc, bz, public.st_astext(geom) as wkt_geom, valid_flag FROM vector.djzq
  362. <where>
  363. <if test="ysdm != null and ysdm != ''"> and ysdm = #{ysdm}</if>
  364. <if test="validFlag != null"> and valid_flag = #{validFlag}</if>
  365. </where>
  366. LIMIT 1000
  367. </select>
  368. </mapper>