ProjectMapper.xml 32 KB

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