“zhifk” 2 anni fa
parent
commit
2b2081e802

+ 43 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -27,7 +27,9 @@ import javax.validation.Valid;
 
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.apache.http.message.BasicNameValuePair;
 import org.springblade.archive.service.IArchiveAutoPdfService;
+import org.springblade.archive.utils.CallBgrsjk;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.mp.support.Condition;
@@ -50,6 +52,7 @@ import org.springblade.archive.wrapper.ArchivesAutoWrapper;
 import org.springblade.archive.service.IArchivesAutoService;
 import org.springblade.core.boot.ctrl.BladeController;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -529,5 +532,44 @@ public class ArchivesAutoController extends BladeController {
 
 		return R.fail("未找到对应的Id");
 	}
-
+	/**
+	 * 获取档案销毁人列表
+	 */
+	@GetMapping("/getModelview")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "获取BIM模型", notes = "获取BIM模型")
+	public R getModelview(@RequestParam String compareId,@RequestParam String fileId,@RequestParam String integrateId){
+		List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
+
+		if(StringUtils.isNotEmpty(compareId)){
+			list.add(new BasicNameValuePair("compareId", compareId));
+		}
+		if(StringUtils.isNotEmpty(fileId)){
+			list.add(new BasicNameValuePair("fileId", fileId));
+		}
+		if(StringUtils.isNotEmpty(compareId)){
+			list.add(new BasicNameValuePair("integrateId", integrateId));
+		}
+		if(!(list.size()>0)){
+			return R.data(null);
+		}
+		String value= "Basic T0VKb0FDeGdiU1RSb0pKZ2htZ0VYdVJlYzYwVVJrQXM6RHREUGZldU5qUE43VVY0Q01sdmhyRFYydXRZVzJFdlA=";
+		String value2= CallBgrsjk.callpostdata(value);
+		if(StringUtils.isEmpty(value2)){
+			return R.data(null);
+		}
+		JSONObject jsonObject = JSONObject.parseObject(value2);
+		Map<String,Object> map = (Map<String,Object>)jsonObject;
+		if(map.get("data") == null) {
+			return R.data(null);
+		}
+		JSONObject  jsonObject1 = JSONObject.parseObject(map.get("data").toString());
+		Map<String,Object> map1 = (Map<String,Object>)jsonObject1;
+		if(map1.get("token") != null) {
+			String value3 = CallBgrsjk.callgetdata("Bearer " + map1.get("token"),list);
+			JSONObject jsonObject3 = JSONObject.parseObject(value3);
+			return R.data(jsonObject3);
+		}
+		return R.data(null);
+	}
 }

+ 78 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/CallBgrsjk.java

@@ -0,0 +1,78 @@
+package org.springblade.archive.utils;
+
+import cn.hutool.json.JSONObject;
+import org.apache.http.Consts;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+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.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.util.List;
+
+public class CallBgrsjk {
+    //模型预览,post请求获取BIMFACE服务器端API接口 获取Access Token
+    public static String callpostdata(String requestParams) {
+        String url = null;
+        JSONObject jb=new JSONObject();
+        jb.put("code",0);
+        try {
+            CloseableHttpClient httpClient = HttpClients.createDefault();
+            RequestConfig requestConfig = RequestConfig.custom()
+                    .setSocketTimeout(300 * 1000)
+                    .setConnectTimeout(300 * 1000)
+                    .build();
+//            url = "http://URL:Port/地址";
+            url = "https://api.bimface.com/oauth2/token";
+            HttpPost post = new HttpPost(url);
+            post.setConfig(requestConfig);
+            post.setHeader("Authorization",requestParams);
+//            StringEntity postingString = new StringEntity(requestParams,
+//                    "utf-8");
+//            post.setEntity(postingString);
+            HttpResponse response = httpClient.execute(post);
+            String content = EntityUtils.toString(response.getEntity());
+            System.out.println(content);
+            return content;
+        } catch (Exception e) {
+
+            return jb.toString();
+        }
+    }
+    //模型预览,get请求获取BIMFACE服务器端API接口 获取模型的View Token
+    public static String callgetdata(String requestParams, List<BasicNameValuePair> list) {
+        String url = null;
+        JSONObject jb=new JSONObject();
+        jb.put("code",0);
+        try {
+
+//		1、创建httpClient
+            CloseableHttpClient client = HttpClients.createDefault();
+//		2、封装请求参数
+//            List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
+//            list.add(new BasicNameValuePair("fileId", "2016629174421504"));
+
+            //3、转化参数
+            String params = EntityUtils.toString(new UrlEncodedFormEntity(list, Consts.UTF_8));
+            //4、创建HttpGet请求
+            HttpGet httpGet = new HttpGet("https://api.bimface.com/view/token"+"?"+params);
+            httpGet.setHeader("Authorization",requestParams);
+            CloseableHttpResponse response = client.execute(httpGet);
+
+            //5、获取实体
+            HttpEntity entity = response.getEntity();
+            //将实体装成字符串
+            String string = EntityUtils.toString(entity);
+            return string;
+        } catch (Exception e) {
+
+            return jb.toString();
+        }
+    }
+}