| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- //package com.fdkankan.download.service.impl;
- //
- //import cn.hutool.core.collection.CollUtil;
- //import cn.hutool.core.date.DateUtil;
- //import cn.hutool.core.date.TimeInterval;
- //import cn.hutool.core.exceptions.ExceptionUtil;
- //import cn.hutool.core.io.FileUtil;
- //import cn.hutool.core.thread.ExecutorBuilder;
- //import cn.hutool.core.util.ArrayUtil;
- //import cn.hutool.core.util.StrUtil;
- //import cn.hutool.core.util.ZipUtil;
- //import cn.hutool.db.nosql.redis.RedisDS;
- //import cn.hutool.system.HostInfo;
- //import cn.hutool.system.SystemUtil;
- //import com.alibaba.fastjson.JSON;
- //import com.alibaba.fastjson.JSONObject;
- //import com.alibaba.fastjson.serializer.SerializerFeature;
- //import com.aliyun.oss.OSS;
- //import com.aliyun.oss.OSSClientBuilder;
- //import com.aliyun.oss.model.*;
- //import com.fdkankan.common.constant.CommonStatus;
- //import com.fdkankan.common.constant.CommonSuccessStatus;
- //import com.fdkankan.common.constant.SceneSource;
- //import com.fdkankan.download.bean.SceneEditControlsBean;
- //import com.fdkankan.download.bean.SceneViewInfoBean;
- //import com.fdkankan.download.entity.*;
- //import com.fdkankan.download.service.*;
- //import com.fdkankan.model.constants.UploadFilePath;
- //import com.fdkankan.redis.constant.RedisKey;
- //import com.fdkankan.redis.util.RedisLockUtil;
- //import com.fdkankan.redis.util.RedisUtil;
- //import com.fdkankan.rabbitmq.util.RabbitMqProducer;
- //import lombok.extern.slf4j.Slf4j;
- //import org.springframework.beans.factory.annotation.Autowired;
- //import org.springframework.boot.CommandLineRunner;
- //import org.springframework.stereotype.Component;
- //import org.springframework.util.CollectionUtils;
- //import redis.clients.jedis.Jedis;
- //
- //import java.io.BufferedReader;
- //import java.io.IOException;
- //import java.io.InputStream;
- //import java.io.InputStreamReader;
- //import java.math.BigDecimal;
- //import java.util.*;
- //import java.util.concurrent.LinkedBlockingQueue;
- //import java.util.concurrent.ThreadPoolExecutor;
- //import java.util.stream.Collectors;
- //
- //@Slf4j
- //@Component
- //public class GenSceneRunnerImpl implements CommandLineRunner {
- //
- // @Autowired
- // private ISnService snService;
- // @Autowired
- // private IScenePlusService scenePlusService;
- // @Autowired
- // private ICameraService cameraService;
- // @Autowired
- // private IScenePlusExtService scenePlusExtService;
- // @Autowired
- // private IDownloadLogService downloadLogService;
- // @Autowired
- // private RedisUtil redisUtil;
- // @Autowired
- // private RedisLockUtil redisLockUtil;
- // @Autowired
- // private IDownloadService downloadService;
- // @Autowired
- // private RabbitMqProducer mqProducer;
- //
- // private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(5).setMaxPoolSize(5).build();
- //
- // @Autowired
- // ILaserService laserService;
- //
- // @Override
- // public void run(String... args) throws Exception {
- // List<Sn> snList = snService.list();
- // if (CollUtil.isEmpty(snList)) {
- // return;
- // }
- // for (Sn sn : snList) {
- // List<Camera> cameras = cameraService.listBySnCodeList(Arrays.asList(sn.getSn()));
- // if (CollUtil.isEmpty(cameras)) {
- // continue;
- // }
- // Camera camera = cameras.get(0);
- // List<ScenePlus> scenePluses = scenePlusService.listByCameraIdList(Arrays.asList(camera.getId()));
- // if (CollUtil.isEmpty(scenePluses)) {
- // continue;
- // }
- // for (ScenePlus scenePlus : scenePluses) {
- // //上锁
- // HostInfo hostInfo = SystemUtil.getHostInfo();
- // String key = "download:tool:" + scenePlus.getNum();
- // String lockVal = hostInfo.getAddress();
- // try {
- // boolean lock = redisLockUtil.lock(key, lockVal, 24 * 60 * 60);
- // if(!lock){
- // continue;
- // }
- //
- // Thread.sleep(5000L);
- //
- // List<DownloadLog> downloadLogList = downloadLogService.getByNum(scenePlus.getNum());
- // Set<String> types = downloadLogList.stream().map(DownloadLog::getType).collect(Collectors.toSet());
- //
- // int isObj = CommonStatus.NO.code();
- // //下载点云场景
- // if (scenePlus.getSceneSource() == SceneSource.JG.code() || scenePlus.getSceneSource() == SceneSource.SG.code()) {
- // if(!types.contains("laser")){
- // threadPoolExecutor.submit(() -> {
- // try {
- // // TODO: 2024/1/3 文杰实现
- // TimeInterval timer = DateUtil.timer();
- // String zipPath = laserService.downloadHandler(scenePlus.getNum());
- //// if (StrUtil.isNotEmpty(zipPath)){
- //// send(zipPath);
- //// }
- // downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.SUCCESS.code(), null, timer.intervalMinute());
- // } catch (Exception e) {
- // downloadLogService.saveLog(scenePlus.getNum(), "laser", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null);
- // log.error("点云场景打包失败,num:{}", scenePlus.getNum(), e);
- // }
- // });
- // }
- // ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
- // isObj = scenePlusExt.getIsObj();
- // }
- //
- // //下载看看、看见、mesh
- // if (scenePlus.getSceneSource() == SceneSource.BM.code()
- // || scenePlus.getSceneSource() == SceneSource.ZT.code()
- // || isObj == CommonStatus.YES.code()) {
- // if(!types.contains("kankan")) {
- // threadPoolExecutor.submit(() -> {
- // try {
- // TimeInterval timer = DateUtil.timer();
- // String zipPath = downloadService.downloadHandler(scenePlus.getNum());
- //// send(zipPath);
- // downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.SUCCESS.code(), null, timer.intervalMinute());
- // } catch (Exception e) {
- // log.error("看看场景打包失败,num:{}", scenePlus.getNum(), e);
- // downloadLogService.saveLog(scenePlus.getNum(), "kankan", CommonSuccessStatus.FAIL.code(), ExceptionUtil.stacktraceToString(e, 3000), null);
- // }
- // });
- // }
- // }
- // }catch (Exception e){
- // log.error("场景打包失败:{}", scenePlus.getNum(), e);
- // }
- // }
- // }
- //
- //
- //
- // }
- //
- // public static void main(String[] args) throws Throwable {
- // String filePath = "D:\\test\\xuhua.txt";
- //// Set<String> collect = list.stream().filter(v -> !v.contains("_laser")).map(v -> v.substring(v.lastIndexOf("/") + 1, v.lastIndexOf("."))).collect(Collectors.toSet());
- //// FileUtil.writeUtf8Lines(collect, filePath);
- //
- // OSS build = new OSSClientBuilder().build("http://oss-cn-shenzhen.aliyuncs.com","LTAI5tJwboCj3r4vUNkSmbyX", "meDy7VYAWbg8kZCKsoUZcIYQxigWOy");
- //
- // Long all = new Long(0);
- // List<String> strings = FileUtil.readUtf8Lines(filePath);
- //
- // for (String num : strings) {
- // List<String> keyList = new ArrayList<>();
- // Long total = 0L;
- // boolean flag = true;
- // String nextMaker = null;
- // ListObjectsRequest listObjectsRequest = new ListObjectsRequest("4dkankan");
- // //指定下一级文件
- // listObjectsRequest.setPrefix(String.format(UploadFilePath.IMG_VIEW_PATH, num));
- // //设置分页的页容量
- // listObjectsRequest.setMaxKeys(200);
- // do {
- // //获取下一页的起始点,它的下一项
- // listObjectsRequest.setMarker(nextMaker);
- // ObjectListing objectListing = build.listObjects(listObjectsRequest);
- // Long space = objectListing.getObjectSummaries().stream().filter(v->!v.getKey().contains("/images/tiles"))
- // .mapToLong(OSSObjectSummary::getSize).sum();
- // List<String> subKeyList = objectListing.getObjectSummaries().stream().filter(v->!v.getKey().contains("/images/tiles"))
- // .map(OSSObjectSummary::getKey).collect(Collectors.toList());
- // if (!CollectionUtils.isEmpty(subKeyList)) {
- // keyList.addAll(subKeyList);
- // }
- // total += space;
- // nextMaker = objectListing.getNextMarker();
- // //全部执行完后,为false
- // flag = objectListing.isTruncated();
- // } while (flag);
- // all += total;
- //
- //// //下载
- //// if(CollUtil.isNotEmpty(keyList)){
- //// keyList.stream().filter(v->!v.endsWith("/")).forEach(key->{
- //// String localPath = "D:\\test222\\" + num + "\\wwwroot\\" + key;
- //// FileUtil.mkParentDirs(localPath);
- //// DownloadFileRequest request = new DownloadFileRequest("4dkankan", key);
- //// request.setDownloadFile(localPath);
- //// // 默认5个任务并发下载
- //// request.setTaskNum(5);
- //// // 启动断点续传
- //// request.setEnableCheckpoint(true);
- //// try {
- //// build.downloadFile(request);
- //// } catch (Throwable e) {
- //// throw new RuntimeException(e);
- //// }
- //// });
- //// for (String key : keyList) {
- //// if(key.endsWith("/")) continue;
- //// String localPath = "D:\\test222\\" + num + "\\wwwroot\\" + key;
- //// FileUtil.mkParentDirs(localPath);
- //// DownloadFileRequest request = new DownloadFileRequest("4dkankan", key);
- //// request.setDownloadFile(localPath);
- //// // 默认5个任务并发下载
- //// request.setTaskNum(5);
- //// // 启动断点续传
- //// request.setEnableCheckpoint(true);
- //// build.downloadFile(request);
- //// }
- //// }
- //
- //// ZipUtil.zip("D:\\test222\\" + num+ "\\wwwroot\\", "D:\\test222\\zip\\" + num+ ".zip");
- //
- // }
- // System.out.println("总容量:" + all/1024/1024/1024);
- //
- //
- //// String filePath = "D:\\test\\kk.txt";
- ////// OSS build = new OSSClientBuilder().build("http://oss-cn-shenzhen.aliyuncs.com","LTAI5tJwboCj3r4vUNkSmbyX", "meDy7VYAWbg8kZCKsoUZcIYQxigWOy");
- //// List<String> strings = FileUtil.readUtf8Lines(filePath);
- ////
- //// for (String num : strings) {
- //// Jedis jedis = RedisDS.create().getJedis();
- //// String sceneJsonData = jedis.get(String.format(RedisKey.SCENE_JSON, num));
- ////// if(StrUtil.isEmpty(sceneJsonData)){
- ////// try (OSSObject ossObject = build.getObject("4dkankan", String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
- ////// InputStream objectContent = ossObject.getObjectContent();
- ////// ){
- ////// StringBuilder contentJson = new StringBuilder();
- ////// BufferedReader reader = new BufferedReader(new InputStreamReader(objectContent));
- ////// while (true) {
- ////// String line = reader.readLine();
- ////// if (line == null) break;
- ////// contentJson.append(line);
- ////// }
- ////// sceneJsonData = sceneJsonData.toString();
- ////// }
- ////// }
- //// sceneJsonData = sceneJsonData.replace("https://4dkk.4dage.com/", "");
- //// SceneViewInfoBean sceneInfoVO = JSON.parseObject(sceneJsonData, SceneViewInfoBean.class);
- //// sceneInfoVO.setScenePassword(null);
- //// if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
- //// sceneInfoVO.setFloorPlanAngle(0f);
- //// }
- //// if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
- //// sceneInfoVO.setFloorPlanCompass(0f);
- //// }
- //// SceneEditControlsBean controls = sceneInfoVO.getControls();
- //// if(Objects.isNull(controls.getShowShare())){
- //// controls.setShowShare(CommonStatus.YES.code().intValue());
- //// }
- //// if(Objects.isNull(controls.getShowCapture())){
- //// controls.setShowCapture(CommonStatus.YES.code().intValue());
- //// }
- //// if(Objects.isNull(controls.getShowBillboardTitle())){
- //// controls.setShowBillboardTitle(CommonStatus.YES.code().intValue());
- //// }
- ////
- //// FileUtil.writeUtf8String(JSON.toJSONString(sceneInfoVO, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero), "D:\\test5\\" + num + "\\wwwroot\\scene_view_data\\" + num + "\\data\\scene.json");
- ////
- //// jedis.close();
- //// System.out.println("替换完成:" + num);
- //
- //// }
- //
- //
- // }
- //
- // private void send(String zipPath){
- // JSONObject jsonObject = new JSONObject();
- // jsonObject.put("path", zipPath);
- // mqProducer.sendByWorkQueue("rsync-scene", jsonObject);
- // }
- //
- //}
|