ProjectMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  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.ProjectMapper">
  6. <resultMap id="projectMap" type="com.siwei.apply.domain.Project">
  7. <id column="id" property="id"/>
  8. <result column="name" property="name"/>
  9. <result column="code" property="code"/>
  10. <result column="company" property="company"/>
  11. <result column="created_at" property="createAt"/>
  12. <result column="updated_at" property="updateAt"/>
  13. <result column="project_type" property="projectType"/>
  14. <result column="on_chain_num" property="onChainNum"/>
  15. <result column="creator_id" property="creatorId"/>
  16. <result column="first_plot_code" property="firstPlotCode"/>
  17. <result column="second_plot_code" property="secondPlotCode"/>
  18. </resultMap>
  19. <!-- 扩展映射:继承基础映射并添加特有字段 -->
  20. <resultMap id="SearchProjectMap" type="com.siwei.apply.domain.SearchProject" extends="projectMap">
  21. <result property="attachmentInfoList" column="attachmentInfoList" typeHandler="com.siwei.apply.handler.JsonTypeHandler"/>
  22. </resultMap>
  23. <!-- 扩展映射:继承基础映射并添加特有字段 -->
  24. <resultMap id="SearchProjectUnionMap" type="com.siwei.apply.domain.SearchProjectAndAttachment">
  25. </resultMap>
  26. <insert id="add" parameterType="com.siwei.apply.domain.Project">
  27. INSERT INTO t_project (id, name, code, company,
  28. created_at, updated_at, project_type,first_plot_code,second_plot_code, creator_id)
  29. VALUES (#{id}, #{name}, #{code}, #{company}, now(), now(), #{projectType},
  30. #{firstPlotCode},#{secondPlotCode},
  31. #{creatorId})
  32. </insert>
  33. <select id="get" resultMap="projectMap">
  34. SELECT *
  35. FROM t_project
  36. where t_project.id = #{id}
  37. </select>
  38. <select id="getList" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
  39. SELECT *
  40. FROM t_project
  41. <where>
  42. <if test="name != null and name != ''">
  43. AND name LIKE CONCAT('%', #{name}, '%')
  44. </if>
  45. <if test="code != null and code != ''">
  46. AND code LIKE CONCAT('%', #{code}, '%')
  47. </if>
  48. <if test="keyWord != null and keyWord != ''">
  49. AND (
  50. name LIKE CONCAT('%', #{keyWord}, '%')
  51. OR company LIKE CONCAT('%', #{keyWord}, '%')
  52. )
  53. </if>
  54. <if test="projectType != null and projectType != 0">
  55. AND project_type = #{projectType}
  56. </if>
  57. <if test="isOnchain != null and isOnchain==true">
  58. AND on_chain_num > 0
  59. </if>
  60. <if test="shape != null and shape != ''">
  61. AND EXISTS (
  62. SELECT 1
  63. FROM t_project_workflow pw
  64. JOIN t_node_land nl ON nl.node_id = pw.node_id
  65. JOIN t_geom_db_details gd ON gd.upload_id = nl.geom_db_id
  66. WHERE pw.project_id = t_project.id
  67. AND public.ST_Intersects(gd.geom, public.ST_GeomFromEWKT(#{shape}))
  68. )
  69. </if>
  70. </where>
  71. ORDER BY updated_at DESC
  72. LIMIT #{pageSize} offset #{offset}
  73. </select>
  74. <select id="getListWithoutPage" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
  75. SELECT *
  76. FROM t_project
  77. <where>
  78. <if test="name != null and name != ''">
  79. AND name LIKE CONCAT('%', #{name}, '%')
  80. </if>
  81. <if test="code != null and code != ''">
  82. AND code LIKE CONCAT('%', #{code}, '%')
  83. </if>
  84. <if test="keyWord != null and keyWord != ''">
  85. AND (
  86. name LIKE CONCAT('%', #{keyWord}, '%')
  87. OR company LIKE CONCAT('%', #{keyWord}, '%')
  88. )
  89. </if>
  90. <if test="projectType != null and projectType != 0">
  91. AND project_type = #{projectType}
  92. </if>
  93. <if test="isOnchain != null and isOnchain==true">
  94. AND on_chain_num > 0
  95. </if>
  96. <if test="shape != null and shape != ''">
  97. AND EXISTS (
  98. SELECT 1
  99. FROM t_project_workflow pw
  100. JOIN t_node_land nl ON nl.node_id = pw.node_id
  101. JOIN t_geom_db_details gd ON gd.upload_id = nl.geom_db_id
  102. WHERE pw.project_id = t_project.id
  103. AND public.ST_Intersects(gd.geom, public.ST_GeomFromEWKT(#{shape}))
  104. )
  105. </if>
  106. </where>
  107. ORDER BY updated_at DESC
  108. </select>
  109. <select id="getCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  110. SELECT COUNT(*)
  111. FROM t_project
  112. <where>
  113. <if test="name != null and name != ''">
  114. AND name LIKE CONCAT('%', #{name}, '%')
  115. </if>
  116. <if test="code != null and code != ''">
  117. AND code LIKE CONCAT('%', #{code}, '%')
  118. </if>
  119. <if test="keyWord != null and keyWord != ''">
  120. AND (
  121. name LIKE CONCAT('%', #{keyWord}, '%')
  122. OR company LIKE CONCAT('%', #{keyWord}, '%')
  123. )
  124. </if>
  125. <if test="projectType != null and projectType != 0">
  126. AND project_type = #{projectType}
  127. </if>
  128. <if test="isOnchain != null and isOnchain==true">
  129. AND on_chain_num > 0
  130. </if>
  131. <if test="shape != null and shape != ''">
  132. AND EXISTS (
  133. SELECT 1
  134. FROM t_project_workflow pw
  135. JOIN t_node_land nl ON nl.node_id = pw.node_id
  136. JOIN t_geom_db_details gd ON gd.upload_id = nl.geom_db_id
  137. WHERE pw.project_id = t_project.id
  138. AND public.ST_Intersects(gd.geom, public.ST_GeomFromEWKT(#{shape}))
  139. )
  140. </if>
  141. </where>
  142. </select>
  143. <update id="update" parameterType="com.siwei.apply.domain.vo.ProjectUpdateVo">
  144. UPDATE t_project
  145. <set>
  146. <if test="name != null">name = #{name},</if>
  147. <if test="code != null">code = #{code},</if>
  148. <if test="company != null">company = #{company},</if>
  149. <if test="projectType != null">project_type = #{projectType},</if>
  150. <if test="onChainNum != null">on_chain_num = #{onChainNum},</if>
  151. <if test="firstPlotCode != null">first_plot_code = #{firstPlotCode},</if>
  152. <if test="secondPlotCode != null">second_plot_code = #{secondPlotCode},</if>
  153. updated_at = now()
  154. </set>
  155. WHERE id = #{id}
  156. </update>
  157. <delete id="batchDelete">
  158. DELETE FROM t_project
  159. WHERE id IN
  160. <foreach collection="ids" item="id" open="(" separator="," close=")">
  161. #{id}
  162. </foreach>
  163. </delete>
  164. <select id="getProjectTypeById" parameterType="string" resultType="int">
  165. SELECT project_type
  166. FROM t_project
  167. WHERE id = #{id}
  168. </select>
  169. <!-- 单一方法:一次返回 1/2 和总数的统计结果 -->
  170. <select id="countTypeStats" resultType="com.siwei.apply.domain.res.ProjectNumRes">
  171. SELECT
  172. SUM(CASE WHEN project_type = 1 THEN 1 ELSE 0 END) AS singleCount,
  173. SUM(CASE WHEN project_type = 2 THEN 1 ELSE 0 END) AS batchCount,
  174. COUNT(*) AS total
  175. FROM t_project where on_chain_num>0
  176. </select>
  177. <select id="selectOtherSupply" resultType="com.siwei.apply.domain.res.ProjectSupplyRes">
  178. SELECT
  179. '其他' AS gdType,
  180. '亩' AS gdUnit,
  181. CAST(0 AS double precision) AS gdArea,
  182. CAST(0 AS int) AS count
  183. </select>
  184. <select id="selectOtherSupplyExcludeProject" resultType="com.siwei.apply.domain.res.ProjectSupplyRes">
  185. SELECT
  186. '其他' AS gdType,
  187. '亩' AS gdUnit,
  188. COALESCE(
  189. SUM(
  190. CASE
  191. WHEN gd_unit = '0' THEN COALESCE(gd_area, 0) / 666.6666667
  192. WHEN gd_unit = '1' THEN COALESCE(gd_area, 0) * 15
  193. ELSE COALESCE(gd_area, 0)
  194. END
  195. ), 0
  196. ) AS gdArea,
  197. COUNT(*) AS count
  198. FROM t_tdgy
  199. WHERE project_id IS NULL OR project_id = ''
  200. </select>
  201. <!-- 根据节点获取项目信息-->
  202. <select id="getProjectByNodeId" resultMap="projectMap">
  203. SELECT project.* FROM "public"."t_project" project
  204. LEFT JOIN "public"."t_project_workflow" flow
  205. on flow.project_id=project.id
  206. WHERE flow.node_id = #{nodeId} LIMIT 1
  207. </select>
  208. <select id="getListSearchOld" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="projectMap">
  209. SELECT *
  210. FROM t_project
  211. <where>
  212. <if test="keyWords != null and keyWords.size() > 0">
  213. regexp_like(name,
  214. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  215. , 'i')
  216. OR
  217. regexp_like(code,
  218. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  219. , 'i')
  220. OR
  221. regexp_like(company,
  222. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  223. , 'i')
  224. </if>
  225. <if test="isOnchain != null and isOnchain">
  226. AND on_chain_num > 0
  227. </if>
  228. </where>
  229. ORDER BY updated_at DESC
  230. LIMIT #{pageSize} offset #{offset}
  231. </select>
  232. <select id="getSearchCountOld" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  233. SELECT COUNT(*)
  234. FROM t_project
  235. <where>
  236. <if test="keyWords != null and keyWords.size() > 0">
  237. regexp_like(name,
  238. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  239. , 'i')
  240. OR
  241. regexp_like(code,
  242. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  243. , 'i')
  244. OR
  245. regexp_like(company,
  246. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  247. , 'i')
  248. </if>
  249. <if test="isOnchain != null and isOnchain">
  250. AND on_chain_num > 0
  251. </if>
  252. </where>
  253. </select>
  254. <select id="getListSearchOld2" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="SearchProjectMap">
  255. SELECT
  256. P."id" AS id,
  257. P."name" AS name,
  258. P."code" AS code,
  259. P."company" AS company,
  260. P."created_at" AS createAt,
  261. P."updated_at" AS updateAt,
  262. P."project_type" AS projectType,
  263. P."on_chain_num" AS onChainNum,
  264. P."creator_id" AS creatorId,
  265. COALESCE(
  266. jsonb_agg(
  267. CASE
  268. WHEN
  269. ${haveKeyWord}
  270. AND A."id" IS NOT NULL
  271. AND A."node_id" IS NOT NULL
  272. AND A."file_name" IS NOT NULL
  273. AND A."file_path" IS NOT NULL THEN
  274. jsonb_build_object('id', A.id,
  275. 'nodeId', A.node_id,
  276. 'fileName', A.file_name,
  277. 'filePath', A.file_path)
  278. ELSE NULL
  279. END
  280. ),'[]' -- 确保返回空数组而不是 null
  281. ) AS attachmentInfoList
  282. FROM
  283. public.t_project P
  284. LEFT JOIN
  285. public.t_project_attachment_info A ON P.id = A.project_id
  286. <if test="keyWords != null and keyWords.size() > 0">
  287. AND regexp_like(A.file_name,
  288. REGEXP_REPLACE(
  289. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  290. , '[\r\n\s]+', '', 'g')
  291. , 'i')
  292. </if>
  293. <where>
  294. <if test="keyWords != null and keyWords.size() > 0">
  295. regexp_like(P.name,
  296. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  297. , 'i')
  298. OR
  299. regexp_like(P.code,
  300. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  301. , 'i')
  302. OR
  303. regexp_like(P.company,
  304. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  305. , 'i')
  306. OR
  307. regexp_like(A.file_name,
  308. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  309. , 'i')
  310. </if>
  311. <if test="isOnchain != null and isOnchain">
  312. AND on_chain_num > 0
  313. </if>
  314. </where>
  315. GROUP BY
  316. P.id, P.name, P.code, P.company, P.created_at, P.updated_at, P.project_type, P.on_chain_num, P.creator_id
  317. ORDER BY
  318. updated_at DESC
  319. LIMIT #{pageSize} OFFSET #{offset}
  320. </select>
  321. <select id="getSearchCountOld2" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  322. SELECT COUNT(*)
  323. FROM (
  324. SELECT DISTINCT
  325. P."id" AS id,
  326. P."name" AS name,
  327. P."code" AS code,
  328. P."company" AS company,
  329. P."created_at" AS createAt,
  330. P."updated_at" AS updateAt,
  331. P."project_type" AS projectType,
  332. P."on_chain_num" AS onChainNum,
  333. P."creator_id" AS creatorId
  334. FROM "public"."t_project" P
  335. LEFT JOIN public.t_project_attachment_info A ON P.id = A.project_id
  336. <if test="keyWords != null and keyWords.size() > 0">
  337. AND regexp_like(A.file_name,
  338. REGEXP_REPLACE(
  339. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  340. , '[\r\n\s]+', '', 'g')
  341. , 'i')
  342. </if>
  343. <where>
  344. <if test="keyWords != null and keyWords.size() > 0">
  345. regexp_like(P.name,
  346. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  347. , 'i')
  348. OR
  349. regexp_like(P.code,
  350. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  351. , 'i')
  352. OR
  353. regexp_like(P.company,
  354. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  355. , 'i')
  356. OR
  357. regexp_like(A.file_name,
  358. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  359. , 'i')
  360. </if>
  361. <if test="isOnchain != null and isOnchain">
  362. AND on_chain_num > 0
  363. </if>
  364. </where>
  365. ) AS distinct_projects
  366. </select>
  367. <select id="getListSearch" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultMap="SearchProjectUnionMap">
  368. <if test="filterType==0 or filterType==1">
  369. SELECT
  370. P."id" AS ID,
  371. P."name" AS NAME,
  372. P."code" AS code,
  373. P."company" AS company,
  374. P."created_at" AS createAt,
  375. P."updated_at" AS updateAt,
  376. P."project_type" AS projectType,
  377. P."on_chain_num" AS onChainNum,
  378. P."creator_id" AS creatorId,
  379. P."updated_at" AS updatedAt,
  380. '1' AS selectType,
  381. '' AS attachmentId,
  382. '' AS nodeId,
  383. '' AS fileName,
  384. '' AS filePath,
  385. '' AS resourceCode,
  386. '' AS zl,
  387. '' AS area
  388. FROM PUBLIC.t_project P
  389. <where>
  390. <if test="keyWords != null and keyWords.size() > 0">
  391. regexp_like(P.name,
  392. REGEXP_REPLACE(
  393. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  394. , '[\r\n\s]+', '', 'g')
  395. , 'i')
  396. OR
  397. regexp_like(P.code,
  398. REGEXP_REPLACE(
  399. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  400. , '[\r\n\s]+', '', 'g')
  401. , 'i')
  402. OR
  403. regexp_like(P.company,
  404. REGEXP_REPLACE(
  405. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  406. , '[\r\n\s]+', '', 'g')
  407. , 'i')
  408. </if>
  409. <if test="isOnchain != null and isOnchain">
  410. AND on_chain_num > 0
  411. </if>
  412. </where>
  413. </if>
  414. <if test="filterType==0">
  415. UNION
  416. </if>
  417. <if test="filterType==0 or filterType==2">
  418. SELECT
  419. project."id" AS ID,
  420. project."name" AS NAME,
  421. project."code" AS code,
  422. project."company" AS company,
  423. project."created_at" AS createAt,
  424. project."updated_at" AS updateAt,
  425. project."project_type" AS projectType,
  426. project."on_chain_num" AS onChainNum,
  427. project."creator_id" AS creatorId,
  428. project."updated_at" AS updatedAt,
  429. '2' AS selectType,
  430. info.ID AS attachmentId,
  431. info.node_id AS nodeId,
  432. info.file_name AS fileName,
  433. info.file_path AS filePath,
  434. '' AS resourceCode,
  435. '' AS zl,
  436. '' AS area
  437. FROM PUBLIC.t_project_attachment_info info
  438. LEFT JOIN t_project project on info.project_id=project.id
  439. <where>
  440. <if test="keyWords != null and keyWords.size() > 0">
  441. regexp_like(info.file_name,
  442. REGEXP_REPLACE(
  443. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  444. , '[\r\n\s]+', '', 'g')
  445. , 'i')
  446. </if>
  447. AND project.id is not null
  448. <if test="isOnchain != null and isOnchain">
  449. AND on_chain_num > 0
  450. </if>
  451. </where>
  452. </if>
  453. <if test="filterType==0">
  454. UNION
  455. </if>
  456. <if test="filterType==0 or filterType==3">
  457. SELECT
  458. project."id" AS ID,
  459. project."name" AS NAME,
  460. project."code" AS code,
  461. project."company" AS company,
  462. project."created_at" AS createAt,
  463. project."updated_at" AS updateAt,
  464. project."project_type" AS projectType,
  465. project."on_chain_num" AS onChainNum,
  466. project."creator_id" AS creatorId,
  467. project."updated_at" AS updatedAt,
  468. '3' AS selectType,
  469. '' AS attachmentId,
  470. '' AS nodeId,
  471. '' AS fileName,
  472. '' AS filePath,
  473. (code.resource_immobile_code) AS resourceCode,
  474. details.zl AS zl,
  475. CAST(ROUND(details.geom_area, 2) AS VARCHAR) AS area
  476. FROM
  477. (SELECT DISTINCT ON (project_id)
  478. project_id,
  479. land_code,
  480. code.resource_immobile_code,
  481. code.resource_business_code,
  482. code.resource_project_code
  483. FROM public.t_land_one_code code
  484. ORDER BY project_id) code
  485. LEFT JOIN "public"."t_node_land" node on code.land_code =node.id
  486. LEFT JOIN "public"."t_geom_db_details" details on node.geom_db_id =details.upload_id
  487. LEFT JOIN "public"."t_project" project on code.project_id =project.id
  488. <where>
  489. <if test="keyWords != null and keyWords.size() > 0">
  490. regexp_like((code.resource_immobile_code || code.resource_business_code || code.resource_project_code),
  491. REGEXP_REPLACE(
  492. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  493. , '[\r\n\s]+', '', 'g')
  494. , 'i')
  495. </if>
  496. AND project.id is not null
  497. <if test="isOnchain != null and isOnchain">
  498. AND on_chain_num > 0
  499. </if>
  500. </where>
  501. </if>
  502. ORDER BY
  503. updatedAt DESC
  504. LIMIT #{pageSize} OFFSET #{offset}
  505. </select>
  506. <select id="getSearchCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  507. SELECT COUNT(*)
  508. FROM (
  509. <if test="filterType==0 or filterType==1">
  510. SELECT
  511. P."id" AS ID,
  512. P."name" AS NAME,
  513. P."code" AS code,
  514. P."company" AS company,
  515. P."created_at" AS createAt,
  516. P."updated_at" AS updateAt,
  517. P."project_type" AS projectType,
  518. P."on_chain_num" AS onChainNum,
  519. P."creator_id" AS creatorId,
  520. P."updated_at" AS updatedAt,
  521. '1' AS selectType,
  522. '' AS attachmentId,
  523. '' AS nodeId ,
  524. '' AS fileName,
  525. '' AS filePath,
  526. '' AS resourceCode,
  527. '' AS zl,
  528. '' AS area
  529. FROM PUBLIC.t_project P
  530. <where>
  531. <if test="keyWords != null and keyWords.size() > 0">
  532. regexp_like(P.name,
  533. REGEXP_REPLACE(
  534. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  535. , '[\r\n\s]+', '', 'g')
  536. , 'i')
  537. OR
  538. regexp_like(P.code,
  539. REGEXP_REPLACE(
  540. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  541. , '[\r\n\s]+', '', 'g')
  542. , 'i')
  543. OR
  544. regexp_like(P.company,
  545. REGEXP_REPLACE(
  546. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  547. , '[\r\n\s]+', '', 'g')
  548. , 'i')
  549. </if>
  550. <if test="isOnchain != null and isOnchain">
  551. AND on_chain_num > 0
  552. </if>
  553. </where>
  554. </if>
  555. <if test="filterType==0">
  556. UNION
  557. </if>
  558. <if test="filterType==0 or filterType==2">
  559. SELECT
  560. project."id" AS ID,
  561. project."name" AS NAME,
  562. project."code" AS code,
  563. project."company" AS company,
  564. project."created_at" AS createAt,
  565. project."updated_at" AS updateAt,
  566. project."project_type" AS projectType,
  567. project."on_chain_num" AS onChainNum,
  568. project."creator_id" AS creatorId,
  569. project."updated_at" AS updatedAt,
  570. '2' AS selectType,
  571. info.ID AS attachmentId,
  572. info.node_id AS nodeId,
  573. info.file_name AS fileName,
  574. info.file_path AS filePath,
  575. '' AS resourceCode,
  576. '' AS zl,
  577. '' AS area
  578. FROM PUBLIC.t_project_attachment_info info
  579. LEFT JOIN t_project project on info.project_id=project.id
  580. <where>
  581. <if test="keyWords != null and keyWords.size() > 0">
  582. regexp_like(info.file_name,
  583. REGEXP_REPLACE(
  584. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  585. , '[\r\n\s]+', '', 'g')
  586. , 'i')
  587. </if>
  588. AND project.id is not null
  589. <if test="isOnchain != null and isOnchain">
  590. AND on_chain_num > 0
  591. </if>
  592. </where>
  593. </if>
  594. <if test="filterType==0">
  595. UNION
  596. </if>
  597. <if test="filterType==0 or filterType==3">
  598. SELECT
  599. project."id" AS ID,
  600. project."name" AS NAME,
  601. project."code" AS code,
  602. project."company" AS company,
  603. project."created_at" AS createAt,
  604. project."updated_at" AS updateAt,
  605. project."project_type" AS projectType,
  606. project."on_chain_num" AS onChainNum,
  607. project."creator_id" AS creatorId,
  608. project."updated_at" AS updatedAt,
  609. '3' AS selectType,
  610. '' AS attachmentId,
  611. '' AS nodeId ,
  612. '' AS fileName,
  613. '' AS filePath,
  614. (code.resource_immobile_code) AS resourceCode,
  615. details.zl AS zl,
  616. CAST(ROUND(details.geom_area, 2) AS VARCHAR) AS area
  617. FROM
  618. (SELECT DISTINCT ON (project_id)
  619. project_id,
  620. land_code,
  621. code.resource_immobile_code,
  622. code.resource_business_code,
  623. code.resource_project_code
  624. FROM public.t_land_one_code code
  625. ORDER BY project_id) code
  626. LEFT JOIN "public"."t_node_land" node on code.land_code =node.id
  627. LEFT JOIN "public"."t_geom_db_details" details on node.geom_db_id =details.upload_id
  628. LEFT JOIN "public"."t_project" project on code.project_id =project.id
  629. <where>
  630. <if test="keyWords != null and keyWords.size() > 0">
  631. regexp_like((code.resource_immobile_code || code.resource_business_code || code.resource_project_code),
  632. REGEXP_REPLACE(
  633. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  634. , '[\r\n\s]+', '', 'g')
  635. , 'i')
  636. </if>
  637. AND project.id is not null
  638. <if test="isOnchain != null and isOnchain">
  639. AND on_chain_num > 0
  640. </if>
  641. </where>
  642. </if>
  643. ) AS distinct_projects
  644. </select>
  645. <select id="getSearchProjectCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  646. SELECT COUNT(*)
  647. FROM (
  648. SELECT
  649. P."id" AS ID,
  650. P."name" AS NAME,
  651. P."code" AS code,
  652. P."company" AS company,
  653. P."created_at" AS createAt,
  654. P."updated_at" AS updateAt,
  655. P."project_type" AS projectType,
  656. P."on_chain_num" AS onChainNum,
  657. P."creator_id" AS creatorId,
  658. P."updated_at" AS updatedAt,
  659. '1' AS selectType,
  660. '' AS attachmentId,
  661. '' AS nodeId ,
  662. '' AS fileName,
  663. '' AS filePath
  664. FROM PUBLIC.t_project P
  665. <where>
  666. <if test="keyWords != null and keyWords.size() > 0">
  667. regexp_like(P.name,
  668. REGEXP_REPLACE(
  669. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  670. , '[\r\n\s]+', '', 'g')
  671. , 'i')
  672. OR
  673. regexp_like(P.code,
  674. REGEXP_REPLACE(
  675. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  676. , '[\r\n\s]+', '', 'g')
  677. , 'i')
  678. OR
  679. regexp_like(P.company,
  680. REGEXP_REPLACE(
  681. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  682. , '[\r\n\s]+', '', 'g')
  683. , 'i')
  684. </if>
  685. <if test="isOnchain != null and isOnchain">
  686. AND on_chain_num > 0
  687. </if>
  688. </where>
  689. ) AS distinct_projects
  690. </select>
  691. <select id="getSearchAttachmentCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  692. SELECT COUNT(*)
  693. FROM (
  694. SELECT
  695. project."id" AS ID,
  696. project."name" AS NAME,
  697. project."code" AS code,
  698. project."company" AS company,
  699. project."created_at" AS createAt,
  700. project."updated_at" AS updateAt,
  701. project."project_type" AS projectType,
  702. project."on_chain_num" AS onChainNum,
  703. project."creator_id" AS creatorId,
  704. project."updated_at" AS updatedAt,
  705. '2' AS selectType,
  706. info.ID AS attachmentId,
  707. info.node_id AS nodeId,
  708. info.file_name AS fileName,
  709. info.file_path AS filePath
  710. FROM PUBLIC.t_project_attachment_info info
  711. LEFT JOIN t_project project on info.project_id=project.id
  712. <where>
  713. <if test="keyWords != null and keyWords.size() > 0">
  714. regexp_like(info.file_name,
  715. REGEXP_REPLACE(
  716. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  717. , '[\r\n\s]+', '', 'g')
  718. , 'i')
  719. </if>
  720. AND project.id is not null
  721. <if test="isOnchain != null and isOnchain">
  722. AND on_chain_num > 0
  723. </if>
  724. </where>
  725. ) AS distinct_projects
  726. </select>
  727. <select id="getSearchGraphicLayerCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
  728. SELECT COUNT(*)
  729. FROM (
  730. SELECT
  731. project."id" AS ID,
  732. project."name" AS NAME,
  733. project."code" AS code,
  734. project."company" AS company,
  735. project."created_at" AS createAt,
  736. project."updated_at" AS updateAt,
  737. project."project_type" AS projectType,
  738. project."on_chain_num" AS onChainNum,
  739. project."creator_id" AS creatorId,
  740. project."updated_at" AS updatedAt,
  741. '3' AS selectType,
  742. '' AS attachmentId,
  743. '' AS nodeId,
  744. '' AS fileName,
  745. '' AS filePath,
  746. (code.resource_immobile_code) AS resourceCode,
  747. details.zl AS zl,
  748. CAST(ROUND(details.geom_area, 2) AS VARCHAR) AS area
  749. FROM
  750. (SELECT DISTINCT ON (project_id)
  751. project_id,
  752. land_code,
  753. code.resource_immobile_code,
  754. code.resource_business_code,
  755. code.resource_project_code
  756. FROM public.t_land_one_code code
  757. ORDER BY project_id) code
  758. LEFT JOIN "public"."t_node_land" node on code.land_code =node.id
  759. LEFT JOIN "public"."t_geom_db_details" details on node.geom_db_id =details.upload_id
  760. LEFT JOIN "public"."t_project" project on code.project_id =project.id
  761. <where>
  762. <if test="keyWords != null and keyWords.size() > 0">
  763. regexp_like((code.resource_immobile_code || code.resource_business_code || code.resource_project_code),
  764. REGEXP_REPLACE(
  765. <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
  766. , '[\r\n\s]+', '', 'g')
  767. , 'i')
  768. </if>
  769. AND project.id is not null
  770. <if test="isOnchain != null and isOnchain">
  771. AND on_chain_num > 0
  772. </if>
  773. </where>
  774. ) AS distinct_projects
  775. </select>
  776. <delete id="deleteNodeByTable">
  777. DELETE FROM ${tableName}
  778. WHERE id = #{nodeId}
  779. </delete>
  780. </mapper>