Browse Source

API:规划成果包查询接口提交

wanger 5 months ago
parent
commit
789cf018d6

+ 2 - 2
onemap-common/onemap-common-core/src/main/java/com/onemap/common/core/constant/CacheConstants.java

@@ -8,9 +8,9 @@ package com.onemap.common.core.constant;
 public class CacheConstants
 {
     /**
-     * 缓存有效期,默认720(分钟)
+     * 缓存有效期,默认120(分钟)
      */
-    public final static long EXPIRATION = 720;
+    public final static long EXPIRATION = 120;
 
     /**
      * 缓存刷新时间,默认120(分钟)

+ 1 - 1
onemap-modules/onemap-analyse/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
     <!-- 日志存放路径 -->
-	<property name="log.path" value="logs/onemap-system" />
+	<property name="log.path" value="logs/onemap-analyse" />
    <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 

+ 12 - 0
onemap-modules/onemap-api/pom.xml

@@ -88,6 +88,18 @@
             <version>1.10.5</version>
         </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>
+
     </dependencies>
 
     <build>

+ 77 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/controller/ResultSearchController.java

@@ -0,0 +1,77 @@
+package com.onemap.api.controller;
+
+
+import com.onemap.api.service.ResultSearchService;
+import com.onemap.common.core.web.controller.BaseController;
+import com.onemap.common.core.web.domain.RequestResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 成果包查询接口
+ *
+ * @author wanger
+ */
+@RequestMapping("/open/results")
+@RestController
+public class ResultSearchController extends BaseController {
+    @Autowired
+    private ResultSearchService resultSearchService;
+
+    /**
+     * 查询已办成果流程接口
+     *
+     * @param ghlx         规划类型(总体规划、专项规划、乡镇规划、村庄规划、详细规划)
+     * @param current      页码,1为第一页
+     * @param size         页数量, 例:10表示单页显示10条数据
+     * @param divisionCode 行政区域代码
+     * @param subject      标题
+     * @return
+     */
+    @GetMapping("/getyb")
+    public RequestResult getyb(String ghlx, Integer current, Integer size, String divisionCode, String subject) {
+        return resultSearchService.getyb(ghlx, current, size, divisionCode, subject);
+    }
+
+    /**
+     * 查询待办成果流程接口
+     *
+     * @param ghlx         规划类型(总体规划、专项规划、乡镇规划、村庄规划、详细规划)
+     * @param current      页码,1为第一页
+     * @param size         页数量, 例:10表示单页显示10条数据
+     * @param divisionCode 行政区域代码
+     * @param subject      标题
+     * @return
+     */
+    @GetMapping("/getdb")
+    public RequestResult getdb(String ghlx, Integer current, Integer size, String divisionCode, String subject) {
+        return resultSearchService.getdb(ghlx, current, size, divisionCode, subject);
+    }
+
+    /**
+     * 查询已办成果审批记录接口
+     *
+     * @param id     记录主键
+     * @param instid 流程主键
+     * @return
+     */
+    @GetMapping("/getybspjl")
+    public RequestResult getybspjl(String id, String instid) {
+        return resultSearchService.getybspjl(id, instid);
+    }
+
+    /**
+     * 下载成果质检审查报告
+     *
+     * @param id    记录主键
+     * @param solid 方案主键
+     * @return
+     */
+    @GetMapping("/downloadReoprt")
+    public RequestResult downloadReoprt(String id, String solid, HttpServletResponse response) {
+        return resultSearchService.downloadReoprt(id, solid, response);
+    }
+
+}

+ 1 - 3
onemap-modules/onemap-api/src/main/java/com/onemap/api/controller/ZhxzController.java

@@ -3,9 +3,7 @@ package com.onemap.api.controller;
 
 import com.onemap.api.domain.AuthorizeDto;
 import com.onemap.api.service.ZhxzService;
-import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
-import com.onemap.common.security.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -18,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
 /**
  * 智慧选址接口
  *
- * @author onemap
+ * @author wanger
  */
 @RequestMapping("/open/zhxz")
 @RestController

+ 17 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/ResultSearchService.java

@@ -0,0 +1,17 @@
+package com.onemap.api.service;
+
+import com.onemap.common.core.web.domain.RequestResult;
+
+import javax.servlet.http.HttpServletResponse;
+
+public interface ResultSearchService {
+
+
+    RequestResult getyb(String ghlx, Integer current, Integer size, String divisionCode, String subject);
+
+    RequestResult getdb(String ghlx, Integer current, Integer size, String divisionCode, String subject);
+
+    RequestResult getybspjl(String id, String instid);
+
+    RequestResult downloadReoprt(String id, String solid, HttpServletResponse response);
+}

+ 0 - 3
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/ZhxzService.java

@@ -2,11 +2,8 @@ package com.onemap.api.service;
 
 import com.onemap.api.domain.AuthorizeDto;
 import com.onemap.common.core.web.domain.RequestResult;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
 
 public interface ZhxzService {
 

+ 278 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/impl/ResultSearchServiceImpl.java

@@ -0,0 +1,278 @@
+package com.onemap.api.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.onemap.api.service.ResultSearchService;
+import com.onemap.api.util.Md5Utils;
+import com.onemap.api.util.RInterfaceUtil;
+import com.onemap.common.core.utils.StringUtils;
+import com.onemap.common.core.web.domain.RequestResult;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+
+@Service
+public class ResultSearchServiceImpl implements ResultSearchService {
+
+    @Value("${Cggl.oauthUrl}")
+    private String oauthUrl;
+    @Value("${Cggl.username}")
+    private String username;
+    @Value("${Cggl.password}")
+    private String password;
+    @Value("${Cggl.landMyAttendsData}")
+    private String landMyAttendsDataURI;
+    @Value("${Cggl.landGetAllTasks}")
+    private String landGetAllTasksURI;
+    @Value("${Cggl.landTaskStatus}")
+    private String landTaskStatusURI;
+    @Value("${Cggl.reportDownload}")
+    private String reportDownloadURI;
+    @Value("${Cggl.landGetRevisePage}")
+    private String landGetRevisePageURI;
+    @Value("${Cggl.reuploadThirdpartyRevise}")
+    private String reuploadThirdpartyReviseURI;
+
+    @Override
+    public RequestResult getyb(String ghlx, Integer current, Integer size, String divisionCode, String subject) {
+        if (StringUtils.isEmpty(ghlx)) {
+            return RequestResult.error("ghlx参数未传递!");
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("planType", getPlanType(ghlx));
+        //TODO wanger 添加默认分页参数
+        if (current == null) {
+            jsonObject.put("current", 1);
+        } else {
+            jsonObject.put("current", current);
+        }
+        if (size == null) {
+            jsonObject.put("size", 999);
+        } else {
+            jsonObject.put("size", size);
+        }
+        if (StringUtils.isNotEmpty(subject)) {
+            jsonObject.put("subject", subject);
+        }
+        if (StringUtils.isNotEmpty(divisionCode)) {
+            jsonObject.put("divisionCode", divisionCode);
+        }
+        JSONObject res = getRequestData(landMyAttendsDataURI, jsonObject);
+        return changeResultObject(res, ghlx, null, null);
+    }
+
+    @Override
+    public RequestResult getdb(String ghlx, Integer current, Integer size, String divisionCode, String subject) {
+        if (StringUtils.isEmpty(ghlx)) {
+            return RequestResult.error("ghlx参数未传递!");
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("planType", getPlanType(ghlx));
+        //TODO wanger 添加默认分页参数
+        if (current == null) {
+            jsonObject.put("current", 1);
+        } else {
+            jsonObject.put("current", current);
+        }
+        if (size == null) {
+            jsonObject.put("size", 999);
+        } else {
+            jsonObject.put("size", size);
+        }
+        if (StringUtils.isNotEmpty(subject)) {
+            jsonObject.put("title", subject);
+        }
+        if (StringUtils.isNotEmpty(divisionCode)) {
+            jsonObject.put("divisionCode", divisionCode);
+        }
+        JSONObject res = getRequestData(landGetAllTasksURI, jsonObject);
+        return changeResultObject(res, ghlx, null, null);
+    }
+
+    @Override
+    public RequestResult getybspjl(String id, String instid) {
+        if (StringUtils.isEmpty(id) || StringUtils.isEmpty(instid)) {
+            return RequestResult.error("参数未传递!");
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("id", id);
+        jsonObject.put("instId", instid);
+        JSONObject res = getRequestData(landTaskStatusURI, jsonObject);
+        return changeResultObject(res, null, id, instid);
+    }
+
+    @Override
+    public RequestResult downloadReoprt(String id, String solid, HttpServletResponse response) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("id", id);
+        jsonObject.put("solId", solid);
+        JSONObject res = getRequestFileData(reportDownloadURI, jsonObject, response);
+        if (res == null) {
+            return RequestResult.success();
+        }
+        Integer status = (Integer) res.get("code");
+        String msg = (String) res.get("msg");
+        Object data = res.get("data");
+        return RequestResult.success(msg, data);
+    }
+
+
+    /**
+     * 将自治区返回的数据结构统一转换为小写字段  并加上ghlx的字段
+     *
+     * @param res  自治区返回结果
+     * @param ghlx 规划类型
+     * @return
+     */
+    public RequestResult changeResultObject(JSONObject res, String ghlx, String id, String instid) {
+        System.out.println(res);
+        Integer status = (Integer) res.get("code");
+        String msg = (String) res.get("msg");
+        if (status == 200) {
+            if (StringUtils.isNotEmpty(ghlx)) {//待办已办查询
+                JSONObject data = (JSONObject) res.get("data");
+                JSONArray records = (JSONArray) data.get("records");
+                List<Object> results = new ArrayList<>();
+                for (int i = 0; i < records.size(); i++) {
+                    JSONObject cur = (JSONObject) records.get(i);
+                    Set<String> keySet = cur.keySet();
+                    Map curMap = new HashMap();
+                    for (String key : keySet) {
+                        curMap.put(key.toLowerCase(), cur.get(key));
+                    }
+                    curMap.put("ghlx", ghlx);
+                    results.add(curMap);
+                }
+                return RequestResult.success(msg, results);
+            } else {//审查记录查询
+                JSONArray records = (JSONArray) res.get("data");
+                List<Object> results = new ArrayList<>();
+                for (int i = 0; i < records.size(); i++) {
+                    JSONObject cur = (JSONObject) records.get(i);
+                    Set<String> keySet = cur.keySet();
+                    Map curMap = new HashMap();
+                    for (String key : keySet) {
+                        curMap.put(key.toLowerCase(), cur.get(key));
+                    }
+                    curMap.put("id", id);
+                    curMap.put("instid", instid);
+                    results.add(curMap);
+                }
+                return RequestResult.success(msg, results);
+            }
+
+        } else {
+            return RequestResult.error(status, msg);
+        }
+    }
+
+    /**
+     * 请求数据
+     *
+     * @param requestURI 请求地址
+     * @param params     请求参数
+     * @return
+     */
+    public JSONObject getRequestFileData(String requestURI, JSONObject params, HttpServletResponse response) {
+        String token = getAccessToken();
+        if (StringUtils.isEmpty(token)) {
+            return null;
+        }
+        JSONObject reStrMd5 = RInterfaceUtil.postRemoteFile(token, requestURI, params, null, response);
+        System.out.println("请求地址:" + requestURI);
+        System.out.println("请求参数:" + params.toJSONString());
+        return reStrMd5;
+    }
+
+    /**
+     * 请求数据
+     *
+     * @param requestURI 请求地址
+     * @param params     请求参数
+     * @return
+     */
+    public JSONObject getRequestData(String requestURI, JSONObject params) {
+        String token = getAccessToken();
+        if (StringUtils.isEmpty(token)) {
+            return null;
+        }
+        JSONObject reStrMd5 = RInterfaceUtil.postRemote(token, requestURI, params, null);
+        System.out.println("请求地址:" + requestURI);
+        System.out.println("请求参数:" + params.toJSONString());
+        System.out.println("请求结果:" + reStrMd5.toJSONString());
+        return reStrMd5;
+    }
+
+    /**
+     * 请求数据
+     *
+     * @param requestURI 请求地址
+     * @param params     请求参数
+     * @return
+     */
+    public JSONObject getRequestFileData(String requestURI, Map<String, Object> params) {
+        String token = getAccessToken();
+        if (StringUtils.isEmpty(token)) {
+            return null;
+        }
+        JSONObject reStrMd5 = RInterfaceUtil.postRemote(token, requestURI, null, params);
+        System.out.println("请求地址:" + requestURI);
+//        System.out.println("请求参数:" + JSON.toJSONString(params));
+        System.out.println("请求结果:" + reStrMd5.toJSONString());
+        return reStrMd5;
+    }
+
+    /**
+     * 通过规划类型转自治区需要的整型数据
+     *
+     * @param ghlx 规划类型
+     * @return
+     */
+    public Integer getPlanType(String ghlx) {
+        switch (ghlx) {
+            case "总体规划":
+                return 1;
+            case "村庄规划":
+                return 2;
+            case "报批项目":
+                return 3;
+            case "总体规划(对部)":
+                return 4;
+            case "详细规划":
+                return 5;
+            case "专项规划":
+                return 6;
+            case "乡镇苏木国土空间规划":
+                return 7;
+            default:
+                return 1;
+        }
+    }
+
+    /**
+     * 调用接口统一获取token
+     *
+     * @return
+     */
+    public String getAccessToken() {
+        //获取token授权
+        JSONObject jsonObject = new JSONObject();
+        //组装请求参数
+        jsonObject.put("grant_type", "password");
+        jsonObject.put("username", username);
+        jsonObject.put("password", Md5Utils.hash(password));
+        //调用post请求方法
+        JSONObject tokenJson = RInterfaceUtil.postRemote(null, oauthUrl, jsonObject, null);
+        System.out.println(tokenJson);
+        String token = "";
+        if (tokenJson.containsKey("success") && tokenJson.getBoolean("success")
+                && tokenJson.containsKey("data") && tokenJson.getJSONObject("data").containsKey("access_token")) {
+            token = tokenJson.getJSONObject("data").getString("access_token");
+            System.out.println(token);
+        }
+        return token;
+    }
+}

+ 0 - 1
onemap-modules/onemap-api/src/main/java/com/onemap/api/service/impl/ZhxzServiceImpl.java

@@ -11,7 +11,6 @@ import com.onemap.common.core.utils.StringUtils;
 import com.onemap.common.core.web.domain.RequestResult;
 import com.onemap.common.security.service.TokenService;
 import com.onemap.system.api.RemoteUserService;
-import com.onemap.system.api.domain.SysUser;
 import com.onemap.system.api.model.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 102 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/util/Md5Utils.java

@@ -0,0 +1,102 @@
+package com.onemap.api.util;
+
+import org.apache.commons.codec.binary.Hex;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+
+/**
+ * Md5加密方法
+ *
+ * @author ruoyi
+ */
+public class Md5Utils
+{
+    private static final Logger log = LoggerFactory.getLogger(Md5Utils.class);
+
+    private static byte[] md5(String s)
+    {
+        MessageDigest algorithm;
+        try
+        {
+            algorithm = MessageDigest.getInstance("MD5");
+            algorithm.reset();
+            algorithm.update(s.getBytes("UTF-8"));
+            byte[] messageDigest = algorithm.digest();
+            return messageDigest;
+        }
+        catch (Exception e)
+        {
+            log.error("MD5 Error...", e);
+        }
+        return null;
+    }
+
+    private static final String toHex(byte hash[])
+    {
+        if (hash == null)
+        {
+            return null;
+        }
+        StringBuffer buf = new StringBuffer(hash.length * 2);
+        int i;
+
+        for (i = 0; i < hash.length; i++)
+        {
+            if ((hash[i] & 0xff) < 0x10)
+            {
+                buf.append("0");
+            }
+            buf.append(Long.toString(hash[i] & 0xff, 16));
+        }
+        return buf.toString();
+    }
+
+    public static String hash(String s)
+    {
+        try
+        {
+            return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
+        }
+        catch (Exception e)
+        {
+            log.error("not supported charset...{}", e);
+            return s;
+        }
+    }
+
+
+    /**
+     * 获取一个文件的md5值(可处理大文件)
+     * @return md5 value
+     */
+    public static String getMD5(File file) {
+        FileInputStream fileInputStream = null;
+        try {
+            MessageDigest MD5 = MessageDigest.getInstance("MD5");
+            fileInputStream = new FileInputStream(file);
+            byte[] buffer = new byte[8192];
+            int length;
+            while ((length = fileInputStream.read(buffer)) != -1) {
+                MD5.update(buffer, 0, length);
+            }
+            return new String(Hex.encodeHex(MD5.digest()));
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            try {
+                if (fileInputStream != null){
+                    fileInputStream.close();
+                }
+            } catch (IOException e) {
+                System.out.println(e.getMessage());
+            }
+        }
+    }
+}

+ 312 - 0
onemap-modules/onemap-api/src/main/java/com/onemap/api/util/RInterfaceUtil.java

@@ -0,0 +1,312 @@
+package com.onemap.api.util;
+
+import com.alibaba.fastjson.JSONObject;
+import com.onemap.common.core.utils.StringUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpStatus;
+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.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.StringBody;
+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 org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 调用厅里接口工具类
+ */
+public class RInterfaceUtil {
+    public static String Authorization = "Basic c2FiZXI6c2FiZXJfc2VjcmV0";
+    public static String TenantId = "000000";
+
+    public static long sliceSize = 10 * 1024 * 1024;
+
+    /**
+     * 调用远程接口
+     *
+     * @param url
+     * @param jsonParam access_token、param都为空时,为获取token请求
+     *                  access_token不为空 param为空时,为gfindByMd5Url请求
+     *                  access_token、param都不为空时,为上传文件请求
+     * @return
+     */
+    public static JSONObject postRemote(String access_token, String url, JSONObject jsonParam, Map<String, Object> param) {
+        //CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
+        RequestConfig config = RequestConfig.custom()
+                .setConnectTimeout(0)
+                .setSocketTimeout(0)
+                .setConnectionRequestTimeout(0)
+                .build();
+        CloseableHttpClient closeableHttpClient = HttpClients.custom()
+                .setDefaultRequestConfig(config)
+                .build();
+        CloseableHttpResponse closeableHttpResponse = null;
+        JSONObject jsonObject = new JSONObject();
+        try {
+            if (param != null) {
+                //文件上传
+                ContentType ctype = ContentType.create("content-disposition", "UTF-8");
+                MultipartEntityBuilder mentity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.RFC6532);
+                Set<String> keyset = param.keySet();
+                for (String key : keyset) {
+                    System.out.println("postRemote 文件上传参数:" + key + ":" + param.get(key));
+                    Object paramObj = param.get(key);
+                    if (paramObj != null) {
+                        if (paramObj instanceof MultipartFile) {
+                            mentity.addBinaryBody(key, ((MultipartFile) paramObj).getInputStream(), ctype, ((MultipartFile) paramObj).getOriginalFilename());
+                        } else if (paramObj instanceof File) {
+                            mentity.addBinaryBody(key, (File) paramObj);//(key, new FileInputStream((File)paramObj),ctype,((File)paramObj).getName());
+                        } else {
+                            mentity.addPart(key, new StringBody(paramObj.toString(), ctype));
+                        }
+                    }
+                }
+                HttpEntity entity = mentity.build();
+                HttpUriRequest post = RequestBuilder.post().setUri(url).setEntity(entity).build();
+                //设置HTTP访问header
+                post.setHeader("Authorization", Authorization);
+                post.addHeader("Tenant-Id", TenantId);
+                if (StringUtils.isNotEmpty(access_token)) {
+                    post.setHeader("Token-Auth", access_token);
+                }
+                closeableHttpResponse = closeableHttpClient.execute(post);
+            } else {
+                //普通请求
+                HttpPost httpPost = new HttpPost(url);
+                //设置HTTP访问header
+                httpPost.setHeader("Authorization", Authorization);
+                httpPost.addHeader("Tenant-Id", TenantId);
+                if (StringUtils.isNotEmpty(access_token)) {
+                    httpPost.setHeader("Token-Auth", access_token);
+                }
+                //设置请求参数
+                //StringEntity entity = new StringEntity(jsonParam.toString(), ContentType.create("text/json", "UTF-8"));
+                List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
+                for (String str : jsonParam.keySet()) {
+                    list.add(new BasicNameValuePair(str, jsonParam.getString(str)));
+                    System.out.println(" key : str : " + str + " value : " + jsonParam.getString(str));
+                }
+                //创建参数集合
+                httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
+                //配置请求时间、超时时间
+                RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
+                httpPost.setConfig(requestConfig);
+
+                //开始发送请求
+                closeableHttpResponse = closeableHttpClient.execute(httpPost);
+            }
+            //获取请求状态码
+            int statusCode = closeableHttpResponse.getStatusLine().getStatusCode();
+            //请求状态码放入到返回json
+            jsonObject.put("code", statusCode);
+            if (statusCode != HttpStatus.SC_OK) {
+                //TODO:状态码非200代表没有正常返回,此处处理你的业务
+                HttpEntity httpEntity = closeableHttpResponse.getEntity();
+                String asset_synchronization = EntityUtils.toString(httpEntity, "UTF-8");
+                try {
+                    //错误是否能解析成json,不能的话直接返回字符串到msg
+                    jsonObject = JSONObject.parseObject(asset_synchronization);
+                } catch (Exception e) {
+                    jsonObject.put("msg", asset_synchronization);
+                }
+            } else {
+                //返回值200
+                HttpEntity httpEntity = closeableHttpResponse.getEntity();
+                String asset_synchronization = EntityUtils.toString(httpEntity, "UTF-8");
+                return JSONObject.parseObject(asset_synchronization);
+            }
+        } catch (IOException e) {
+            //程序异常返回值
+            jsonObject.put("code", -1);
+            jsonObject.put("msg", e.toString());
+            return jsonObject;
+        } finally {
+            if (closeableHttpResponse != null) {
+                try {
+                    //关闭http请求
+                    closeableHttpResponse.close();
+                } catch (IOException e) {
+                    System.out.println(e.toString());
+                }
+            }
+        }
+        System.out.println("postRemote jsonObject: " + jsonObject);
+        return jsonObject;
+    }
+
+    /**
+     * 调用远程文件流接口
+     *
+     * @param url
+     * @param jsonParam access_token、param都为空时,为获取token请求
+     *                  access_token不为空 param为空时,为gfindByMd5Url请求
+     *                  access_token、param都不为空时,为上传文件请求
+     * @return
+     */
+    public static JSONObject postRemoteFile(String access_token, String url, JSONObject jsonParam, Map<String, Object> param, HttpServletResponse response) {
+        CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
+        CloseableHttpResponse closeableHttpResponse = null;
+        JSONObject jsonObject = new JSONObject();
+        try {
+            if (param != null) {
+                //文件上传
+                ContentType ctype = ContentType.create("content-disposition", "UTF-8");
+                MultipartEntityBuilder mentity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.RFC6532);
+                Set<String> keyset = param.keySet();
+                for (String key : keyset) {
+                    System.out.println("postRemote 文件上传参数:" + key + ":" + param.get(key));
+                    Object paramObj = param.get(key);
+                    if (paramObj != null) {
+                        if (paramObj instanceof MultipartFile) {
+                            mentity.addBinaryBody(key, ((MultipartFile) paramObj).getInputStream(), ctype, ((MultipartFile) paramObj).getOriginalFilename());
+                        } else if (paramObj instanceof File) {
+                            mentity.addBinaryBody(key, (File) paramObj);//(key, new FileInputStream((File)paramObj),ctype,((File)paramObj).getName());
+                        } else {
+                            mentity.addPart(key, new StringBody(paramObj.toString(), ctype));
+                        }
+                    }
+                }
+                HttpEntity entity = mentity.build();
+                HttpUriRequest post = RequestBuilder.post().setUri(url).setEntity(entity).build();
+                //设置HTTP访问header
+                post.setHeader("Authorization", Authorization);
+                post.addHeader("Tenant-Id", TenantId);
+                if (StringUtils.isNotEmpty(access_token)) {
+                    post.setHeader("Token-Auth", access_token);
+                }
+                closeableHttpResponse = closeableHttpClient.execute(post);
+            } else {
+                //普通请求
+                HttpPost httpPost = new HttpPost(url);
+                //设置HTTP访问header
+                httpPost.setHeader("Authorization", Authorization);
+                httpPost.addHeader("Tenant-Id", TenantId);
+                if (StringUtils.isNotEmpty(access_token)) {
+                    httpPost.setHeader("Token-Auth", access_token);
+                }
+                //设置请求参数
+                //StringEntity entity = new StringEntity(jsonParam.toString(), ContentType.create("text/json", "UTF-8"));
+                List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
+                for (String str : jsonParam.keySet()) {
+                    list.add(new BasicNameValuePair(str, jsonParam.getString(str)));
+                    System.out.println(" key : str : " + str + " value : " + jsonParam.getString(str));
+                }
+                //创建参数集合
+                httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8"));
+                //配置请求时间、超时时间
+                RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
+                httpPost.setConfig(requestConfig);
+
+                //开始发送请求
+                closeableHttpResponse = closeableHttpClient.execute(httpPost);
+            }
+            //获取请求状态码
+            int statusCode = closeableHttpResponse.getStatusLine().getStatusCode();
+            //请求状态码放入到返回json
+            jsonObject.put("code", statusCode);
+            if (statusCode != HttpStatus.SC_OK) {
+                //TODO:状态码非200代表没有正常返回,此处处理你的业务
+                HttpEntity httpEntity = closeableHttpResponse.getEntity();
+                String asset_synchronization = EntityUtils.toString(httpEntity, "UTF-8");
+                try {
+                    //错误是否能解析成json,不能的话直接返回字符串到msg
+                    jsonObject = JSONObject.parseObject(asset_synchronization);
+                } catch (Exception e) {
+                    jsonObject.put("msg", asset_synchronization);
+                }
+            } else {
+                //返回值200
+                HttpEntity httpEntity = closeableHttpResponse.getEntity();
+                String responseType = httpEntity.getContentType().getValue();
+                if (responseType.contains("zip")) {
+                    byte[] outstream = EntityUtils.toByteArray(httpEntity);
+                    response.getOutputStream().write(outstream);
+                    response.getOutputStream().close();
+                    return null;
+                } else {
+                    String asset_synchronization = EntityUtils.toString(httpEntity, "UTF-8");
+                    return JSONObject.parseObject(asset_synchronization);
+                }
+            }
+        } catch (IOException e) {
+            //程序异常返回值
+            jsonObject.put("code", -1);
+            jsonObject.put("msg", e.toString());
+            return jsonObject;
+        } finally {
+            if (closeableHttpResponse != null) {
+                try {
+                    //关闭http请求
+                    closeableHttpResponse.close();
+                } catch (IOException e) {
+                    System.out.println(e.toString());
+                }
+            }
+        }
+        System.out.println("postRemote jsonObject: " + jsonObject);
+        return jsonObject;
+    }
+
+    /**
+     * 切割文件
+     *
+     * @param fromFileName 源文件的完整路径带文件名
+     * @param toFileName   目标文件的完整路径带文件名
+     * @return
+     * @throws IOException
+     */
+    public static long spilt(String fromFileName, String toFileName, String splice) throws IOException {
+        long curSliceSize = 0;
+        File f = new File(fromFileName);
+        FileInputStream in = new FileInputStream(f);
+        FileOutputStream out = null;
+        FileChannel inChannel = in.getChannel();
+        FileChannel outChannel = null;
+        // 计算最终会分成几个文件
+        int count = (int) (f.length() / sliceSize);
+        for (int i = 0; i <= count; i++) {
+            // 生成文件的路径
+            String t = toFileName + splice + i;
+            try {
+                out = new FileOutputStream(new File(t));
+                outChannel = out.getChannel();
+                // 从inChannel的m*i处,读取固定长度的数据,写入outChannel
+                if (i != count) {
+                    curSliceSize = sliceSize;
+                    inChannel.transferTo(sliceSize * i, curSliceSize, outChannel);
+                } else {// 最后一个文件,大小不固定,所以需要重新计算长度
+                    curSliceSize = f.length() - sliceSize * count;
+                    inChannel.transferTo(sliceSize * i, curSliceSize, outChannel);
+                }
+            } catch (IOException e) {
+                System.out.println(e.toString());
+                return curSliceSize;
+            } finally {
+                out.close();
+                outChannel.close();
+            }
+        }
+        in.close();
+        inChannel.close();
+        return curSliceSize;
+    }
+}

+ 1 - 1
onemap-modules/onemap-api/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
     <!-- 日志存放路径 -->
-	<property name="log.path" value="logs/onemap-gen" />
+	<property name="log.path" value="logs/onemap-api" />
    <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 

+ 17 - 17
onemap-modules/onemap-apply/src/main/java/com/onemap/apply/service/impl/sbjk/SbSearchServiceImpl.java

@@ -238,23 +238,23 @@ public class SbSearchServiceImpl implements SbSearchService {
     @Override
     public WebResult reportDownload(String id, String solId, HttpServletResponse response) {
         //返回测试文件流
-//        try {
-//            response.setHeader("Content-Disposition", "attachment;filename=" + new String("test.zip".getBytes("UTF-8"), "ISO-8859-1"));  // 需要编z码否则中文乱码
-//            response.setContentType("application/zip;charset=utf-8");
-//            response.setCharacterEncoding("UTF-8");
-//            // 直接返回zip输出流不生成临时文件。
-//            File file = new File("E:\\gisdata\\TEMP\\test.zip");
-//            byte[] readAllBytes = Files.readAllBytes(file.toPath());
-//            response.getOutputStream().write(readAllBytes);
-//            response.getOutputStream().close();
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        } finally {
-//            try {
-//                response.getOutputStream().close();
-//            } catch (Exception e) {
-//            }
-//        }
+        try {
+            response.setHeader("Content-Disposition", "attachment;filename=" + new String("test.zip".getBytes("UTF-8"), "ISO-8859-1"));  // 需要编z码否则中文乱码
+            response.setContentType("application/zip;charset=utf-8");
+            response.setCharacterEncoding("UTF-8");
+            // 直接返回zip输出流不生成临时文件。
+            File file = new File("D:\\gisdata\\temp.zip");
+            byte[] readAllBytes = Files.readAllBytes(file.toPath());
+            response.getOutputStream().write(readAllBytes);
+            response.getOutputStream().close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                response.getOutputStream().close();
+            } catch (Exception e) {
+            }
+        }
         Map<String, Object> object = new HashMap<>();
         return WebResult.success("质检审查报告暂没生成。", object);
     }

+ 1 - 1
onemap-modules/onemap-apply/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
     <!-- 日志存放路径 -->
-	<property name="log.path" value="logs/onemap-system" />
+	<property name="log.path" value="logs/onemap-apply" />
    <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
 

+ 1 - 1
onemap-modules/onemap-vector/src/main/resources/logback.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="60 seconds" debug="false">
     <!-- 日志存放路径 -->
-	<property name="log.path" value="logs/onemap-system" />
+	<property name="log.path" value="logs/onemap-vector" />
    <!-- 日志输出格式 -->
 	<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />