Преглед изворни кода

Merge remote-tracking branch 'origin/dev' into dev

chenendian пре 2 недеља
родитељ
комит
3a7af70d87

+ 103 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/ChenController.java

@@ -0,0 +1,103 @@
+package com.siwei.apply.controller;
+
+import com.siwei.apply.domain.res.YdysyxzRes;
+import com.siwei.apply.domain.vo.YdysyxzVo;
+import com.siwei.apply.service.YdysyxzService;
+import com.siwei.common.core.domain.R;
+import com.siwei.common.core.web.controller.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 用地预审与选址 控制器
+ * 单独选址第一步
+ */
+@RestController
+@RequestMapping("/chen")
+public class ChenController extends BaseController {
+    @Autowired
+    private YdysyxzService ydysyxzService;
+
+    /**
+     * 添加用地预审与选址信息
+     */
+    @PostMapping()
+    public R<Map> Add(@RequestBody YdysyxzVo ydysyxzVo) {
+        try {
+            // 判断是否存在
+            Boolean b = ydysyxzService.isExit(ydysyxzVo.getProjectId());
+            if (b) {
+                return R.fail("此项目已添加用地预审与选址");
+            }
+            // 添加
+            String id = ydysyxzService.add(ydysyxzVo);
+            Map<String, String> map = new HashMap<>();
+            map.put("id", id);
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 获取用地预审与选址信息
+     *
+     * @param projectId 项目ID
+     * @return 用地预审与选址信息
+     */
+    @GetMapping("/{projectId}")
+    public R<YdysyxzRes> Get(@PathVariable String projectId) {
+        try {
+            return R.ok(ydysyxzService.get(projectId));
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 通过主键id获取用地预审与选址信息,返回结果与按projectId查询一致
+     */
+    @GetMapping("/id/{id}")
+    public R<YdysyxzRes> GetById(@PathVariable String id) {
+        try {
+            return R.ok(ydysyxzService.getById(id));
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 通过主键id获取用地预审与选址信息(POST方式,参数为RequestBody)
+     */
+    @PostMapping("/id")
+    public R<YdysyxzRes> GetByIdPost(@RequestBody String id) {
+        try {
+            return R.ok(ydysyxzService.getById(id));
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+
+    }
+
+    @GetMapping("/test")
+    public R<String> getDataTest(String str) {
+        try {
+            String retString = "测试";
+            return R.ok(str+retString);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    // 测试用main方法
+    public static void main(String[] args) {
+        System.out.println("陈先生");
+    }
+
+
+
+
+}

+ 1 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/vo/ProjectFilterVo.java

@@ -22,7 +22,7 @@ public class ProjectFilterVo {
 
     private Boolean isOnchain;
 
-    private Boolean haveKeyWord;
+    private Integer filterType;
 
     private List<String> keyWords;
 

+ 2 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/ProjectMapper.java

@@ -2,6 +2,7 @@ package com.siwei.apply.mapper;
 
 import com.siwei.apply.domain.Project;
 import com.siwei.apply.domain.SearchProject;
+import com.siwei.apply.domain.SearchProjectAndAttachment;
 import com.siwei.apply.domain.res.ProjectNumRes;
 import com.siwei.apply.domain.vo.ProjectFilterVo;
 import com.siwei.apply.domain.vo.ProjectUpdateVo;
@@ -66,7 +67,7 @@ public interface ProjectMapper {
     /**
      * 获取检索的项目列表
      */
-    List<SearchProject> getListSearch(ProjectFilterVo projectFilterVo);
+    List<SearchProjectAndAttachment> getListSearch(ProjectFilterVo projectFilterVo);
 
     Integer getSearchCount(ProjectFilterVo projectFilterVo);
 

+ 4 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/impl/ProjectImpl.java

@@ -284,15 +284,15 @@ public class ProjectImpl implements ProjectService {
 
     @Override
     public Map<String, Object> getListSearch(ProjectFilterVo projectFilterVo) {
-        projectFilterVo.setHaveKeyWord(false);
+        if(Objects.isNull(projectFilterVo.getFilterType())){
+            projectFilterVo.setFilterType(0);
+        }
         if(StringUtils.isNotBlank(projectFilterVo.getKeyWord())){
             List<String> keyWords = List.of(projectFilterVo.getKeyWord().trim().split("\\s+"));
             projectFilterVo.setKeyWords(keyWords);
-            projectFilterVo.setHaveKeyWord(true);
         }
-
         //todo 这里后期可以进行优化,把查询出的项目id写入redis中,分页时候可以取缓存
-        List<SearchProject> projects = projectMapper.getListSearch(projectFilterVo);
+        List<SearchProjectAndAttachment> projects = projectMapper.getListSearch(projectFilterVo);
         Integer count = projectMapper.getSearchCount(projectFilterVo);
         //根据项目id查询所有流程id
         List<String> projectIdList = projects.stream().map(BaseId::getId).collect(Collectors.toList());

+ 184 - 2
siwei-modules/siwei-apply/src/main/resources/mapper/ProjectMapper.xml

@@ -23,6 +23,12 @@
     </resultMap>
 
 
+    <!-- 扩展映射:继承基础映射并添加特有字段 -->
+    <resultMap id="SearchProjectUnionMap" type="com.siwei.apply.domain.SearchProjectAndAttachment">
+    </resultMap>
+
+
+
     <insert id="add" parameterType="com.siwei.apply.domain.Project">
         INSERT INTO t_project (id, name, code, company,
                                created_at, updated_at, project_type,first_plot_code,second_plot_code, creator_id)
@@ -205,7 +211,7 @@
         </where>
     </select>
 
-    <select id="getListSearch" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo"  resultMap="SearchProjectMap">
+    <select id="getListSearchOld2" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo"  resultMap="SearchProjectMap">
         SELECT
             P."id" AS id,
             P."name" AS  name,
@@ -273,7 +279,7 @@
             LIMIT #{pageSize} OFFSET #{offset}
     </select>
 
-    <select id="getSearchCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
+    <select id="getSearchCountOld2" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
         SELECT COUNT(*)
         FROM (
         SELECT DISTINCT
@@ -320,6 +326,182 @@
         ) AS distinct_projects
     </select>
 
+    <select id="getListSearch" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo"  resultMap="SearchProjectUnionMap">
+            <if test="filterType==0 or filterType==1">
+                SELECT
+                P."id" AS ID,
+                P."name" AS NAME,
+                P."code" AS code,
+                P."company" AS company,
+                P."created_at" AS createAt,
+                P."updated_at" AS updateAt,
+                P."project_type" AS projectType,
+                P."on_chain_num" AS onChainNum,
+                P."creator_id" AS creatorId,
+                P."updated_at" AS updatedAt,
+                '1'  AS selectType,
+                '' AS attachmentId,
+                '' AS nodeId  ,
+                '' AS fileName,
+                '' AS  filePath
+                FROM  PUBLIC.t_project P
+
+                <where>
+                    <if test="keyWords != null and keyWords.size() > 0">
+                        regexp_like(P.name,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                        OR
+                        regexp_like(P.code,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                        OR
+                        regexp_like(P.company,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                    </if>
+                    <if test="isOnchain != null and isOnchain">
+                        AND on_chain_num > 0
+                    </if>
+                </where>
+            </if>
+
+                <if test="filterType==0">
+                    UNION
+                </if>
+
+            <if test="filterType==0 or filterType==2">
+                SELECT
+                project."id" AS ID,
+                project."name" AS NAME,
+                project."code" AS code,
+                project."company" AS company,
+                project."created_at" AS createAt,
+                project."updated_at" AS updateAt,
+                project."project_type" AS projectType,
+                project."on_chain_num" AS onChainNum,
+                project."creator_id" AS creatorId,
+                project."updated_at" AS updatedAt,
+                '2'  AS selectType,
+                info.ID AS attachmentId,
+                info.node_id AS nodeId,
+                info.file_name AS  fileName,
+                info.file_path AS filePath
+                FROM  PUBLIC.t_project_attachment_info info
+                LEFT JOIN t_project project   on  info.project_id=project.id
+                <where>
+                    <if test="keyWords != null and keyWords.size() > 0">
+                        regexp_like(info.file_name,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                    </if>
+                    AND  project.id is not null
+                    <if test="isOnchain != null and isOnchain">
+                        AND on_chain_num > 0
+                    </if>
+                </where>
+            </if>
+         ORDER BY
+            updatedAt DESC
+            LIMIT #{pageSize} OFFSET #{offset}
+    </select>
+
+    <select id="getSearchCount" parameterType="com.siwei.apply.domain.vo.ProjectFilterVo" resultType="int">
+        SELECT COUNT(*)
+        FROM (
+            <if test="filterType==0 or filterType==1">
+                SELECT
+                P."id" AS ID,
+                P."name" AS NAME,
+                P."code" AS code,
+                P."company" AS company,
+                P."created_at" AS createAt,
+                P."updated_at" AS updateAt,
+                P."project_type" AS projectType,
+                P."on_chain_num" AS onChainNum,
+                P."creator_id" AS creatorId,
+                P."updated_at" AS updatedAt,
+                '1'  AS selectType,
+                '' AS attachmentId,
+                '' AS nodeId  ,
+                '' AS fileName,
+                '' AS  filePath
+                FROM  PUBLIC.t_project P
+
+                <where>
+                    <if test="keyWords != null and keyWords.size() > 0">
+                        regexp_like(P.name,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                        OR
+                        regexp_like(P.code,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                        OR
+                        regexp_like(P.company,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                    </if>
+                    <if test="isOnchain != null and isOnchain">
+                        AND on_chain_num > 0
+                    </if>
+                </where>
+            </if>
+
+            <if test="filterType==0">
+                UNION
+            </if>
+
+            <if test="filterType==0 or filterType==2">
+                SELECT
+                project."id" AS ID,
+                project."name" AS NAME,
+                project."code" AS code,
+                project."company" AS company,
+                project."created_at" AS createAt,
+                project."updated_at" AS updateAt,
+                project."project_type" AS projectType,
+                project."on_chain_num" AS onChainNum,
+                project."creator_id" AS creatorId,
+                project."updated_at" AS updatedAt,
+                '2'  AS selectType,
+                info.ID AS attachmentId,
+                info.node_id AS nodeId,
+                info.file_name AS  fileName,
+                info.file_path AS filePath
+                FROM  PUBLIC.t_project_attachment_info info
+                LEFT JOIN t_project project   on  info.project_id=project.id
+                <where>
+                    <if test="keyWords != null and keyWords.size() > 0">
+                        regexp_like(info.file_name,
+                        REGEXP_REPLACE(
+                        <foreach collection="keyWords" item="word" open="'(" separator="|" close=")'" >${word}</foreach>
+                        , '[\r\n\s]+', '', 'g')
+                        , 'i')
+                    </if>
+                    AND  project.id is not null
+                    <if test="isOnchain != null and isOnchain">
+                        AND on_chain_num > 0
+                    </if>
+                </where>
+            </if>
+        ) AS distinct_projects
+    </select>
+
 
     <delete id="deleteNodeByTable">
         DELETE FROM ${tableName}