|
@@ -99,7 +99,7 @@ public class TowerServiceImpl implements ITowerService {
|
|
@Value("${tower.url}")
|
|
@Value("${tower.url}")
|
|
private String url;
|
|
private String url;
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private FYunFileServiceInterface fYunFileService;
|
|
private FYunFileServiceInterface fYunFileService;
|
|
@Autowired
|
|
@Autowired
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
@@ -335,7 +335,7 @@ public class TowerServiceImpl implements ITowerService {
|
|
String compose = sceneId.concat("+").concat(roomId).concat("+").concat(fileMd5);
|
|
String compose = sceneId.concat("+").concat(roomId).concat("+").concat(fileMd5);
|
|
String encrypt = RsaCryptTools.encryptData(compose, privateKey);
|
|
String encrypt = RsaCryptTools.encryptData(compose, privateKey);
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
params.put("stationCode", sceneId);
|
|
params.put("stationCode", sceneId);
|
|
params.put("roomEntityID", roomId);
|
|
params.put("roomEntityID", roomId);
|
|
params.put("manufact", manufact);
|
|
params.put("manufact", manufact);
|
|
@@ -349,6 +349,7 @@ public class TowerServiceImpl implements ITowerService {
|
|
log.info("params:{}", JSON.toJSONString(params));
|
|
log.info("params:{}", JSON.toJSONString(params));
|
|
try {
|
|
try {
|
|
String post = httpClient.upload(url, zipPath, params);
|
|
String post = httpClient.upload(url, zipPath, params);
|
|
|
|
+// String post = this.push(url, zipPath, params);
|
|
log.info("返回结果:{}", post);
|
|
log.info("返回结果:{}", post);
|
|
// String post = HttpUtil.post(url, params, 60*60*1000);
|
|
// String post = HttpUtil.post(url, params, 60*60*1000);
|
|
jsonObject = JSON.parseObject(post);
|
|
jsonObject = JSON.parseObject(post);
|
|
@@ -441,6 +442,7 @@ public class TowerServiceImpl implements ITowerService {
|
|
Map<String, Object> noticeContent = new HashMap<>();
|
|
Map<String, Object> noticeContent = new HashMap<>();
|
|
noticeContent.put("num", num);
|
|
noticeContent.put("num", num);
|
|
String scenePath = parentPath.concat(num).concat("/");
|
|
String scenePath = parentPath.concat(num).concat("/");
|
|
|
|
+ FileUtil.del(scenePath);
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
@@ -474,7 +476,12 @@ public class TowerServiceImpl implements ITowerService {
|
|
//下载mesh
|
|
//下载mesh
|
|
FileUtil.mkdir(dataPath.concat("mesh/"));
|
|
FileUtil.mkdir(dataPath.concat("mesh/"));
|
|
List<String> meshList = fYunFileService.listRemoteFiles(ossDataPath.concat("mesh"));
|
|
List<String> meshList = fYunFileService.listRemoteFiles(ossDataPath.concat("mesh"));
|
|
- meshList.parallelStream().forEach(key -> fYunFileService.downloadFile(key, dataPath.concat("mesh/")));
|
|
|
|
|
|
+ meshList.parallelStream().forEach(key -> {
|
|
|
|
+ if(key.endsWith("mtl") || key.endsWith("obj") || key.endsWith("jpg")){
|
|
|
|
+ String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
|
+ fYunFileService.downloadFile(key, dataPath.concat("mesh/").concat(fileName));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
//images数据下载
|
|
//images数据下载
|
|
String imagesPath = sceneSourcePath + "/images/";
|
|
String imagesPath = sceneSourcePath + "/images/";
|
|
@@ -527,39 +534,53 @@ public class TowerServiceImpl implements ITowerService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
+ private String push(String url, String zipPath, Map<String, String> params) throws Exception {
|
|
|
|
|
|
- // 添加文件参数
|
|
|
|
- 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;
|
|
|
|
|
|
+ MultipartFile file = com.fdkankan.extend.util.FileUtil.pathToMultipartFile(zipPath);
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ String result = "";
|
|
try {
|
|
try {
|
|
- HttpResponse response = httpClient.execute(httpPost);
|
|
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ 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 (params != null && params.size() > 0) {
|
|
|
|
+ for (Map.Entry<String, String> e : params.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);
|
|
|
|
+ log.info("开始推送:{}", zipPath);
|
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);// 执行提交
|
|
|
|
+ log.info("结束推送:{}", zipPath);
|
|
HttpEntity responseEntity = response.getEntity();
|
|
HttpEntity responseEntity = response.getEntity();
|
|
if (responseEntity != null) {
|
|
if (responseEntity != null) {
|
|
- responseString = EntityUtils.toString(responseEntity);
|
|
|
|
- System.out.println("Response: " + responseString);
|
|
|
|
|
|
+ // 将响应内容转换为字符串
|
|
|
|
+ result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
|
|
|
|
+ log.info("推送压缩包:{},铁塔接口返回结果:{}", zipPath, result);
|
|
|
|
+ }
|
|
|
|
+ } finally {
|
|
|
|
+ try {
|
|
|
|
+ httpClient.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
}
|
|
}
|
|
- return responseString;
|
|
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
// String zipPath = "D:\\四维时代\\中国铁塔\\360文件Rsa上传接口说明.zip";
|
|
// String zipPath = "D:\\四维时代\\中国铁塔\\360文件Rsa上传接口说明.zip";
|
|
// String url = "http://120.52.40.44:1808/fileManager/uploadRsaFileZipView";
|
|
// String url = "http://120.52.40.44:1808/fileManager/uploadRsaFileZipView";
|