|
@@ -2,17 +2,23 @@ package com.gis.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gis.common.constant.ConfigConstant;
|
|
|
import com.gis.common.util.AliyunOssUtil;
|
|
|
import com.gis.common.util.FileUtils;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.domain.entity.IconEntity;
|
|
|
+import com.gis.domain.entity.WorkEntity;
|
|
|
import com.gis.mapper.IBaseMapper;
|
|
|
import com.gis.mapper.IconMapper;
|
|
|
import com.gis.service.IconService;
|
|
|
import com.gis.service.TestService;
|
|
|
+import com.gis.service.WorkService;
|
|
|
import com.gis.util.ReplaceVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.junit.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,6 +48,9 @@ public class TestServiceImpl implements TestService {
|
|
|
@Autowired
|
|
|
AliyunOssUtil aliyunOssUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WorkService workService;
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -89,6 +98,73 @@ public class TestServiceImpl implements TestService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 2022-3-22 根据作品id获取场景码
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result getSceneCode(String ids) {
|
|
|
+ List<WorkEntity> list = workService.findByIds(ids);
|
|
|
+ HashMap<String, String> iconMap = new HashMap<>();
|
|
|
+ HashSet<Object> sceneCodes = new HashSet<>();
|
|
|
+ for (WorkEntity entity : list) {
|
|
|
+ Long id = entity.getId();
|
|
|
+ log.info("处理该作品开始: {}", id);
|
|
|
+ getHandleSceneCode(entity.getSceneCodes(), iconMap, sceneCodes);
|
|
|
+ log.info("处理该作品结束: {}", id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 转json 方便使用
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(sceneCodes));
|
|
|
+ log.info("场景码数量:{}", sceneCodes.size() );
|
|
|
+ log.info("场景码:{}", sceneCodes );
|
|
|
+ log.info("场景码JSON:{}", array );
|
|
|
+ log.info("书略图:{}", iconMap );
|
|
|
+
|
|
|
+ downloadThumb(iconMap);
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 下载初始场景图片
|
|
|
+ private void downloadThumb(Map<String, String> iconMap){
|
|
|
+ String basePath = "F:\\work\\项目-科学城(广州)信科集团-3D合作\\thumb";
|
|
|
+ for (Map.Entry<String, String> m : iconMap.entrySet()) {
|
|
|
+ String sceneCode = m.getKey();
|
|
|
+ String ossUrl = m.getValue();
|
|
|
+ String fileName = StringUtils.substringAfterLast(ossUrl, "/");
|
|
|
+ fileName = StringUtils.substringBeforeLast(fileName, "?");
|
|
|
+// String savePath = basePath + "/" + sceneCode;
|
|
|
+ FileUtils.downLoadFromUrl(ossUrl, fileName, basePath);
|
|
|
+ log.info("场景:{} 保存路径: {} 完成", sceneCode, basePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getHandleSceneCode(String str, Map iconMap, Set sceneCodes){
|
|
|
+ JSONArray array = JSONArray.parseArray(str);
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+
|
|
|
+ for (Object o : array) {
|
|
|
+ JSONObject parse = JSON.parseObject(o.toString());
|
|
|
+ String type = parse.getString("type");
|
|
|
+ if ("pano".equals(type)){
|
|
|
+ String sceneCode = parse.getString("sceneCode");
|
|
|
+ String icon = parse.getString("icon");
|
|
|
+ jsonArray.add(sceneCode);
|
|
|
+ iconMap.put(sceneCode, icon);
|
|
|
+ sceneCodes.add(sceneCode);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ log.warn("场景数量:{}", jsonArray.size());
|
|
|
+ log.warn("场景: {}", jsonArray);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 读取replace.csv
|
|
|
*
|
|
|
* https://www.4dkankan.com/panorama/show.html?id=606&vr=fd720_7B6nNaWQO
|