1
0
chenendian 4 месяцев назад
Родитель
Сommit
396f05952b

+ 17 - 0
siwei-modules/siwei-apply/pom.xml

@@ -73,6 +73,23 @@
             <scope>provided</scope>
         </dependency>
 
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.10</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5.6</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.6</version>
+        </dependency>
 
     </dependencies>
 

+ 60 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/OfferDataController.java

@@ -0,0 +1,60 @@
+package com.siwei.apply.controller.third;
+
+import com.siwei.apply.domain.LandOneCode;
+import com.siwei.apply.service.third.OfferDataService;
+import com.siwei.common.core.domain.R;
+import com.siwei.common.core.web.controller.BaseController;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ *
+ *
+ */
+@RestController
+@RequestMapping("/public/third2")
+@RequiredArgsConstructor
+public class OfferDataController extends BaseController {
+
+    private final OfferDataService offerDataService;
+
+    /**
+     * 新增
+     */
+    @PostMapping("/bb")
+    public R<Map<String, String>> add(@RequestBody LandOneCode body) {
+        try {
+            Map<String,String>  map = offerDataService.getById("11");
+            map.put("id", map.get("id"));
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 按ID查询
+     */
+    @GetMapping("/{id}")
+    public R<Map> getById(@PathVariable String id) {
+        try {
+            return R.ok(offerDataService.getById(id));
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+    @PostMapping("/addEntity")
+    public R<String> addEntity(@RequestBody LandOneCode body) {
+        try {
+            return R.fail(502,"土地统一编码信息已自动生成,无需手动添加");
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+}

+ 80 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/third/TakeDataController.java

@@ -0,0 +1,80 @@
+package com.siwei.apply.controller.third;
+
+import com.siwei.apply.domain.LandOneCode;
+import com.siwei.apply.service.third.TakeDataService;
+import com.siwei.common.core.domain.R;
+import com.siwei.common.core.utils.StringUtils;
+import com.siwei.common.core.web.controller.BaseController;
+import lombok.RequiredArgsConstructor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ *
+ * 获取不动产数据
+ */
+@RestController
+@RequestMapping("/public/third")
+@RequiredArgsConstructor
+public class TakeDataController extends BaseController {
+    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private final TakeDataService takeDataService;
+
+    /**
+     *
+     * 获取不动产登记号
+     *
+     */
+    @GetMapping("immobileCode/{projectId}")
+    public R<Map<String, String>> getImmobileCode(@PathVariable String projectId) {
+        try {
+            if(StringUtils.isBlank(projectId)){
+                return R.fail(502,"项目id为空,请填充");
+            }
+            Map<String, String> map = takeDataService.getImmobileCode(projectId);
+            return R.ok(map);
+        } catch (Exception e) {
+            return R.fail(502,"服务出错:"+e.getMessage());
+        }
+    }
+
+
+    /**
+     * 按ID查询
+     */
+    @GetMapping("{id}")
+    public R<LandOneCode> getById(@PathVariable String id) {
+        try {
+            return R.ok();
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    /**
+     * 更新(按ID)
+     */
+    @PutMapping("zzz")
+    public R<Void> update(@RequestBody LandOneCode body) {
+        try {
+            return R.ok(null);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+    @PostMapping("addEntity")
+    public R<String> addEntity(@RequestBody LandOneCode body) {
+        try {
+            return R.fail(502,"土地统一编码信息已自动生成,无需手动添加");
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+}

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

@@ -22,6 +22,8 @@ public class ProjectFilterVo {
 
     private Boolean isOnchain;
 
+    private Boolean haveKeyWord;
+
     private List<String> keyWords;
 
     // 分页参数

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

@@ -282,10 +282,13 @@ public class ProjectImpl implements ProjectService {
 
     @Override
     public Map<String, Object> getListSearch(ProjectFilterVo projectFilterVo) {
+        projectFilterVo.setHaveKeyWord(false);
         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);
         Integer count = projectMapper.getSearchCount(projectFilterVo);

+ 32 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/OfferDataService.java

@@ -0,0 +1,32 @@
+package com.siwei.apply.service.third;
+
+import com.siwei.apply.domain.res.GyjsydscdjRes;
+import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
+import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo;
+
+import java.util.Map;
+
+/**
+ * 提供不动产前序资料获取
+ */
+public interface OfferDataService {
+
+    /**
+     *
+     *
+     * @param
+     * @return
+     */
+    Map<String,String> get(String projectId);
+
+
+
+    /**
+     *
+     */
+    Map<String,String> getById(String id);
+
+
+
+
+}

+ 45 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/TakeDataService.java

@@ -0,0 +1,45 @@
+package com.siwei.apply.service.third;
+
+import com.siwei.apply.domain.res.GyjsydscdjRes;
+import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
+import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo;
+import com.siwei.apply.domain.vo.GyjsydscdjVo;
+
+import java.util.Map;
+
+/**
+ * 国有建设用地使用权首次登记 服务接口
+ */
+public interface TakeDataService {
+
+
+    Map<String,String> getImmobileCode(String projectId);
+
+
+    /**
+     * 获取国有建设用地使用权首次登记信息
+     *
+     * @param projectId 项目ID
+     * @return 国有建设用地使用权首次登记结果对象
+     */
+    GyjsydscdjRes get(String projectId);
+
+
+
+
+
+
+    /**
+     * 根据主键id获取国有建设用地使用权首次登记信息,返回结构与 get(projectId) 一致
+     */
+    GyjsydscdjSinglRes getById(String id);
+
+    /**
+     * 更新国有建设用地使用权首次登记信息
+     *
+     * @param gyjsydscdjUpdateVo 国有建设用地使用权首次登记更新视图对象
+     */
+    void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo);
+
+
+}

+ 28 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/OfferDataServiceImpl.java

@@ -0,0 +1,28 @@
+package com.siwei.apply.service.third.impl;
+
+import com.siwei.apply.service.third.OfferDataService;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+
+/**
+ *  获取三方数据服务实现类
+ */
+@Slf4j
+@Service
+public class OfferDataServiceImpl implements OfferDataService {
+
+
+    @Override
+    public Map<String, String> get(String projectId) {
+        return Map.of();
+    }
+
+    @Override
+    public Map<String, String> getById(String id) {
+        return Map.of();
+    }
+}

+ 89 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/third/impl/TakeDataServiceImpl.java

@@ -0,0 +1,89 @@
+package com.siwei.apply.service.third.impl;
+
+import com.siwei.apply.domain.Project;
+import com.siwei.apply.domain.ProjectWorkflow;
+import com.siwei.apply.domain.res.GyjsydscdjRes;
+import com.siwei.apply.domain.res.GyjsydscdjSinglRes;
+import com.siwei.apply.domain.vo.GyjsydscdjUpdateVo;
+import com.siwei.apply.enums.AloneWorkFlowEnum;
+
+import com.siwei.apply.mapper.ProjectWorkflowMapper;
+import com.siwei.apply.service.NodeLandService;
+import com.siwei.apply.service.ProjectService;
+import com.siwei.apply.service.TdgyService;
+import com.siwei.apply.service.third.TakeDataService;
+import com.siwei.apply.utils.HttpClientUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ *  获取三方数据服务实现类
+ */
+@Slf4j
+@Service
+public class TakeDataServiceImpl implements TakeDataService {
+
+    @Autowired
+    private ProjectService projectService;
+
+    @Autowired
+    private ProjectWorkflowMapper projectWorkflowMapper;
+
+    @Autowired
+    private NodeLandService nodeLandService;
+
+    @Override
+    public Map<String, String> getImmobileCode(String projectId) {
+        Map<String, String> retMap = new LinkedHashMap<>();
+
+        Project project = projectService.get(projectId);
+        String firstPlotCode = project.getFirstPlotCode();
+        String secondPlotCode = project.getSecondPlotCode();
+        String tableName = AloneWorkFlowEnum.NODE_2.getTableName(); //土地供应图斑
+
+        List<ProjectWorkflow> projectWorkflows = projectWorkflowMapper.selectByProjectIdAndNodeTableName(projectId,tableName);
+        if (CollectionUtils.isNotEmpty(projectWorkflows)) {
+            String nodeId = projectWorkflows.get(0).getNodeId();
+            Map<String, Object> paramMap = new LinkedHashMap<>();
+            paramMap.put("batchId", projectId);
+            paramMap.put("plotCode", firstPlotCode+secondPlotCode);
+            paramMap.put("geoms", "");
+            Map<String, Object> geomInfo = nodeLandService.getGeomByNodeId(nodeId);
+            if( geomInfo.get("geoms") instanceof  List){
+                List<String> geoms = (List<String>) geomInfo.get("geoms");
+                paramMap.put("geoms", geoms);
+            }
+            //todo 这里调用 httpClient 进行远程调用
+            String result = HttpClientUtil.doGet("https://www.baidu.com",paramMap);
+            //log.error("解析节点附件json失败",e);
+            log.info("获取解析数据为:{}",result);
+            //构造结果进行入库
+        }
+        retMap.put("code","12345678");
+        retMap.put("projectId",projectId);
+        return retMap;
+    }
+
+
+    @Override
+    public GyjsydscdjRes get(String projectId) {
+        return null;
+    }
+
+    @Override
+    public GyjsydscdjSinglRes getById(String id) {
+        return null;
+    }
+
+    @Override
+    public void update(GyjsydscdjUpdateVo gyjsydscdjUpdateVo) {
+
+    }
+}

+ 180 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/utils/HttpClientUtil.java

@@ -0,0 +1,180 @@
+package com.siwei.apply.utils;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpClientUtil {
+    /**
+     * 带参数的get请求
+     *
+     * @param url
+     * @param param
+     * @return String
+     */
+    public static String doGet(String url, Map<String, Object> param) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+
+        String resultString = null;
+        CloseableHttpResponse response = null;
+        try {
+            // 创建uri
+            URIBuilder builder = new URIBuilder(url);
+            if (param != null) {
+                for (String key : param.keySet()) {
+                    builder.addParameter(key, String.valueOf(param.get(key)));
+                }
+            }
+            URI uri = builder.build();
+            // 创建http GET请求
+            HttpGet httpGet = new HttpGet(uri);
+            //设置超时设置
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setConnectionRequestTimeout(10000)
+                    .setConnectTimeout(10000)
+                    .setSocketTimeout(10000).build();
+            httpGet.setConfig(requestConfig);
+            // 执行请求
+            response = httpclient.execute(httpGet);
+            // 判断返回状态是否为200
+            if (response.getStatusLine().getStatusCode() == 200) {
+                resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+                return resultString;
+            }
+            return null;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 不带参数的get请求
+     *
+     * @param url
+     * @return String
+     */
+    public static String doGet(String url) {
+        return doGet(url, null);
+    }
+
+    /**
+     * 带参数的post请求
+     *
+     * @param url
+     * @param param
+     * @return String
+     */
+    public static String doPost(String url, Map<String, String> param) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = null;
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建参数列表
+            if (param != null) {
+                List<NameValuePair> paramList = new ArrayList<>();
+                for (String key : param.keySet()) {
+                    paramList.add(new BasicNameValuePair(key, param.get(key)));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+                httpPost.setEntity(entity);
+            }
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setConnectionRequestTimeout(10000)
+                    .setConnectTimeout(10000)
+                    .setSocketTimeout(10000).build();
+            httpPost.setConfig(requestConfig);
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+            return resultString;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 不带参数的post请求
+     *
+     * @param url
+     * @return String
+     */
+    public static String doPost(String url) {
+        return doPost(url, null);
+    }
+
+    /**
+     * 传送json类型的post请求
+     *
+     * @param url
+     * @param json
+     * @return String
+     */
+    public static String doPostJson(String url, String json) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = null;
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建请求内容
+            StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
+            httpPost.setEntity(entity);
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setConnectionRequestTimeout(10000)
+                    .setConnectTimeout(10000)
+                    .setSocketTimeout(10000).build();
+            httpPost.setConfig(requestConfig);
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return resultString;
+    }
+}

+ 3 - 1
siwei-modules/siwei-apply/src/main/resources/mapper/ProjectMapper.xml

@@ -219,7 +219,9 @@
             COALESCE(
                     jsonb_agg(
                     CASE
-                    WHEN A."id" IS NOT NULL
+                    WHEN
+                    ${haveKeyWord}
+                    AND    A."id" IS NOT NULL
                     AND A."node_id" IS NOT NULL
                     AND A."file_name" IS NOT NULL
                     AND A."file_path" IS NOT NULL THEN