|
@@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.dtflys.forest.utils.StringUtils;
|
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.constant.SceneStatus;
|
|
@@ -36,17 +37,34 @@ import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.fileupload.FileItem;
|
|
|
+import org.apache.commons.fileupload.FileItemFactory;
|
|
|
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.entity.mime.HttpMultipartMode;
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.crypto.KeyGenerator;
|
|
|
import javax.crypto.SecretKey;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.nio.charset.Charset;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -320,7 +338,6 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("stationCode", sceneId);
|
|
|
params.put("roomEntityID", roomId);
|
|
|
- params.put("file", FileUtil.file(zipPath));
|
|
|
params.put("manufact", manufact);
|
|
|
params.put("encrypt", encrypt);
|
|
|
params.put("upUserAcct", "xxx");
|
|
@@ -329,8 +346,11 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
log.info("compose:{}", compose);
|
|
|
log.info("encrypt:{}", encrypt);
|
|
|
log.info("开始推送");
|
|
|
+ log.info("params:{}", JSON.toJSONString(params));
|
|
|
try {
|
|
|
- String post = HttpUtil.post(url, params, 60*60*1000);
|
|
|
+ String post = httpClient.upload(url, zipPath, params);
|
|
|
+ log.info("返回结果:{}", post);
|
|
|
+// String post = HttpUtil.post(url, params, 60*60*1000);
|
|
|
jsonObject = JSON.parseObject(post);
|
|
|
if(!jsonObject.containsKey("resultCode")){
|
|
|
throw new RuntimeException("铁塔接口出参错误");
|
|
@@ -355,10 +375,6 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
FileUtil.appendUtf8String(content, parentPath.concat("download").concat("-").concat(logId).concat(".log"));
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
-// System.out.println(AlgorithmUtil.getId("AES"));
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public ResultData sceneBatchMove(MultipartFile file, String origSnCode, String snCode) throws IOException {
|
|
|
if(file.isEmpty()){
|
|
@@ -475,19 +491,19 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
fYunFileService.downloadFile(ossImagesPath.concat("vision.txt"), imagesPath.concat("vision.txt"));
|
|
|
|
|
|
//下载caches/images
|
|
|
- List<String> panoramaImageList = SceneUtil.getPanoramaImageList(imagesPath.concat("vision.txt"));
|
|
|
- log.info(JSON.toJSONString(panoramaImageList));
|
|
|
- List<String> imageList = fYunFileService.listRemoteFiles(String.format(UploadFilePath.scene_result_data_path, num).concat("caches/images/"));
|
|
|
- if(CollUtil.isNotEmpty(imageList)){
|
|
|
- imageList.stream().forEach(key->{
|
|
|
- if(panoramaImageList.contains(key.substring(key.lastIndexOf("/") + 1))){
|
|
|
- if(!FileUtil.exist(imagesPath.concat("8K"))){
|
|
|
- FileUtil.mkdir(imagesPath.concat("8K"));
|
|
|
- }
|
|
|
- fYunFileService.downloadFile(key, imagesPath.concat("8K"));
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+// List<String> panoramaImageList = SceneUtil.getPanoramaImageList(imagesPath.concat("vision.txt"));
|
|
|
+// log.info(JSON.toJSONString(panoramaImageList));
|
|
|
+// List<String> imageList = fYunFileService.listRemoteFiles(String.format(UploadFilePath.scene_result_data_path, num).concat("caches/images/"));
|
|
|
+// if(CollUtil.isNotEmpty(imageList)){
|
|
|
+// imageList.stream().forEach(key->{
|
|
|
+// if(panoramaImageList.contains(key.substring(key.lastIndexOf("/") + 1))){
|
|
|
+// if(!FileUtil.exist(imagesPath.concat("8K"))){
|
|
|
+// FileUtil.mkdir(imagesPath.concat("8K"));
|
|
|
+// }
|
|
|
+// fYunFileService.downloadFile(key, imagesPath.concat("8K"));
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
|
|
|
this.convertVisable(imagesPath.concat("vision.txt"));
|
|
|
|
|
@@ -507,7 +523,143 @@ public class TowerServiceImpl implements ITowerService {
|
|
|
noticeContent.put("result", pushResult);
|
|
|
rabbitMqProducer.sendByWorkQueue(TIE_TA_SCENE_PUSH_CALLBACK_QUEUE, noticeContent);
|
|
|
// rabbitTemplate.convertAndSend(TIE_TA_SCENE_PUSH_CALLBACK_EXCHANGE , TIE_TA_SCENE_PUSH_CALLBACK_ROUTING , noticeContent);
|
|
|
- FileUtil.del(scenePath);
|
|
|
+// FileUtil.del(scenePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String push(String url, String zipPath, Map<String, Object> params){
|
|
|
+
|
|
|
+ org.apache.http.client.HttpClient httpClient = HttpClients.createDefault();
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+
|
|
|
+ // 添加JSON参数
|
|
|
+ String jsonData = JSON.toJSONString(params);
|
|
|
+ StringEntity jsonEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON);
|
|
|
+ httpPost.setEntity(jsonEntity);
|
|
|
+
|
|
|
+ // 添加文件参数
|
|
|
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
|
|
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
|
|
+ String fileName = zipPath.substring(zipPath.lastIndexOf("/") + 1);
|
|
|
+ builder.addBinaryBody("file", new File(zipPath), ContentType.DEFAULT_BINARY, fileName);
|
|
|
+
|
|
|
+ HttpEntity multipart = builder.build();
|
|
|
+ httpPost.setEntity(multipart);
|
|
|
+
|
|
|
+ String responseString = null;
|
|
|
+ try {
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ responseString = EntityUtils.toString(responseEntity);
|
|
|
+ System.out.println("Response: " + responseString);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ return responseString;
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+// String zipPath = "D:\\四维时代\\中国铁塔\\360文件Rsa上传接口说明.zip";
|
|
|
+// String url = "http://120.52.40.44:1808/fileManager/uploadRsaFileZipView";
|
|
|
+// String jsonData = "{\"stationCode\":\"370003010000000001\",\"manufact\":\"3\",\"roomEntityID\":\"500102050000000011399211\",\"encrypt\":\"gCT9mV1evGvXcg16IpVNVGiUurLmQBJjEQxTwBUbxQ7ubWxLXORk0pHfNgFIe+CpI5uOsTEhlKHCjD3glrEGO8NV2QMAGvZ4EmkOHI+PaFQP9jzmDUxemQ6conr3QWfbRYCK/lYCKovqUaQKzaGke3KdtCLTOFyZjo8HH8cNvHo=\",\"upUserAcct\":\"xxx\"}";
|
|
|
+// org.apache.http.client.HttpClient httpClient = HttpClients.createDefault();
|
|
|
+// HttpPost httpPost = new HttpPost(url);
|
|
|
+//
|
|
|
+// // 添加JSON参数
|
|
|
+//// String jsonData = JSON.toJSONString(params);
|
|
|
+// StringEntity jsonEntity = new StringEntity(jsonData, ContentType.MULTIPART_FORM_DATA);
|
|
|
+// httpPost.setEntity(jsonEntity);
|
|
|
+//
|
|
|
+// // 添加文件参数
|
|
|
+// MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
|
|
+// builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
|
|
+// String fileName = zipPath.substring(zipPath.lastIndexOf("/") + 1);
|
|
|
+// builder.addBinaryBody("file", new File(zipPath), ContentType.MULTIPART_FORM_DATA, fileName);
|
|
|
+//
|
|
|
+// HttpEntity multipart = builder.build();
|
|
|
+// httpPost.setEntity(multipart);
|
|
|
+//
|
|
|
+// String responseString = null;
|
|
|
+// try {
|
|
|
+// HttpResponse response = httpClient.execute(httpPost);
|
|
|
+// HttpEntity responseEntity = response.getEntity();
|
|
|
+// if (responseEntity != null) {
|
|
|
+// responseString = EntityUtils.toString(responseEntity);
|
|
|
+// System.out.println("Response: " + responseString);
|
|
|
+// }
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+
|
|
|
+ String paramStr = "{\n" +
|
|
|
+ " \"stationCode\": \"370003010000000001\",\n" +
|
|
|
+ " \"manufact\": \"3\",\n" +
|
|
|
+ " \"roomEntityID\": \"500102050000000011399211\",\n" +
|
|
|
+ " \"encrypt\": \"gCT9mV1evGvXcg16IpVNVGiUurLmQBJjEQxTwBUbxQ7ubWxLXORk0pHfNgFIe+CpI5uOsTEhlKHCjD3glrEGO8NV2QMAGvZ4EmkOHI+PaFQP9jzmDUxemQ6conr3QWfbRYCK/lYCKovqUaQKzaGke3KdtCLTOFyZjo8HH8cNvHo=\",\n" +
|
|
|
+ " \"upUserAcct\": \"xxx\"\n" +
|
|
|
+ "}";
|
|
|
+ Map<String, String> otherParams = JSON.parseObject(paramStr, Map.class);
|
|
|
+ String zipPath = "C:\\Users\\dsx\\Desktop\\370003010000000001_500102050000000011399211.zip";
|
|
|
+ String url = "http://120.52.40.44:1808/fileManager/uploadRsaFileZipView";
|
|
|
+ MultipartFile file = com.fdkankan.extend.util.FileUtil.pathToMultipartFile(zipPath);
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+// //设置请求头
|
|
|
+// if (headerParams != null && headerParams.size() > 0) {
|
|
|
+// for (Map.Entry<String, String> e : headerParams.entrySet()) {
|
|
|
+// String value = e.getValue();
|
|
|
+// String key = e.getKey();
|
|
|
+// if (StringUtils.isNotBlank(value)) {
|
|
|
+// httpPost.setHeader(key, value);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
|
|
+ builder.setCharset(Charset.forName("utf-8"));
|
|
|
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);//加上此行代码解决返回中文乱码问题
|
|
|
+ // 文件传输http请求头(multipart/form-data)
|
|
|
+ if (file != null) {
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ builder.addBinaryBody("file", file.getInputStream(), ContentType.MULTIPART_FORM_DATA, fileName);// 文件流
|
|
|
+ }
|
|
|
+ // 字节传输http请求头(application/json)
|
|
|
+ ContentType contentType = ContentType.create("application/json", Charset.forName("UTF-8"));
|
|
|
+ if (otherParams != null && otherParams.size() > 0) {
|
|
|
+ for (Map.Entry<String, String> e : otherParams.entrySet()) {
|
|
|
+ String value = e.getValue();
|
|
|
+ if (StringUtils.isNotBlank(value)) {
|
|
|
+ builder.addTextBody(e.getKey(), value, contentType);// 类似浏览器表单提交,对应input的name和value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HttpEntity entity = builder.build();
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ System.out.println("开始推送");
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);// 执行提交
|
|
|
+ System.out.println("结束推送");
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ // 将响应内容转换为字符串
|
|
|
+ result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ httpClient.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|