Переглянути джерело

完成报表功能-可以给四维看看用

wuweihao 2 роки тому
батько
коміт
8677786fb5

+ 4 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/TestService.java

@@ -25,4 +25,8 @@ public interface TestService  {
     Result sh(TestShDto param);
 
     Result createToken(String userId);
+
+    Result updateSceneCode(String isAll);
+
+    Result updateWorkType(String isAll);
 }

+ 1 - 13
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -113,7 +113,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
             return Result.failure(ErrorEnum.FAILURE_CODE_3021.code(),"上传文件格式有误, 请重新上传");
         }
 
-//        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
         String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSS");
         log.info("time: {}", time);
         String fileName = file.getOriginalFilename();
@@ -126,8 +125,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         String newName = time + "." + suffix;
         String dirType = "fodder/";
         long size = file.getSize();
-//        // 2022-12-20 新增容量
-//        addSize(size);
         size = size / 1024;
         log.info("fileSize: " + size);
 
@@ -240,15 +237,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         return Result.success(entity);
     }
 
-//    /**
-//     * 2022-12-20 当天容量保存到redis
-//     * @param size
-//     */
-//    private void addSize(long size) {
-//        String key = RedisConstant.REPORT_VOLUME + LocalDate.now();
-//        Long aLong = redisUtil.incrBy(key, size, 1, TimeUnit.DAYS);
-//        log.info("当前节点:{} 新增容量:{} KB", key, aLong);
-//    }
 
 
 
@@ -527,7 +515,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     @Override
     public int getTodaySize(LocalDate today, String unit) {
         Integer num = entityMapper.countIntSize(StrUtil.format("select sum(file_size) from tb_fodder " +
-                "where is_delete=0 and DATA_FORMAT(create_time, '%Y-%m-%d') = '{}' ", today));
+                "where is_delete=0 and DATE(create_time) = '{}' ", today));
         num = num == null ? 0 : num;
         int gb = fileUtils.convertUnit("GB", num);
         return gb;

+ 165 - 53
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/TestServiceImpl.java

@@ -43,14 +43,10 @@ import java.util.concurrent.TimeUnit;
 public class TestServiceImpl implements TestService {
 
 
-
-
-
     @Autowired
     ConfigConstant configConstant;
 
-//    @Autowired
-//    FileUtils fileUtils;
+
 
     @Autowired
     AliYunOssUtil aliyunOssUtil;
@@ -68,8 +64,6 @@ public class TestServiceImpl implements TestService {
     RedisUtil redisUtil;
 
 
-
-
     @Override
     public Result batchReplaceSomeData(String isBatch) {
         String basePath = "F:\\work\\四维-全景看看\\data\\";
@@ -103,6 +97,7 @@ public class TestServiceImpl implements TestService {
 
     /**
      * 2022-3-22 根据作品id获取场景码
+     *
      * @param ids
      * @return
      */
@@ -121,10 +116,10 @@ public class TestServiceImpl implements TestService {
 
         // 转json 方便使用
         JSONArray array = JSONArray.parseArray(JSON.toJSONString(sceneCodes));
-        log.info("场景码数量:{}", sceneCodes.size() );
-        log.info("场景码:{}", sceneCodes );
-        log.info("场景码JSON:{}", array );
-        log.info("书略图:{}", iconMap );
+        log.info("场景码数量:{}", sceneCodes.size());
+        log.info("场景码:{}", sceneCodes);
+        log.info("场景码JSON:{}", array);
+        log.info("书略图:{}", iconMap);
 
         downloadThumb(iconMap);
 
@@ -133,10 +128,9 @@ public class TestServiceImpl implements TestService {
     }
 
 
-
-
     /**
      * 2022-10-21
+     *
      * @param isAll
      * @return
      */
@@ -161,14 +155,14 @@ public class TestServiceImpl implements TestService {
         int i = 0;
         for (FodderEntity entity : list) {
             String tour = entity.getTour();
-            if (StrUtil.isNotBlank(tour)){
+            if (StrUtil.isNotBlank(tour)) {
                 continue;
             }
             String sceneCode = entity.getSceneCode();
 //            if (tour.contains("%CURRENTXML%")){
 //                continue;
 //            }
-            i ++ ;
+            i++;
             String basePath = "%CURRENTXML%../" + sceneCode + "/vtour/panos/";
             tour = tour.replaceAll("panos/", basePath);
             entity.setTour(tour);
@@ -198,8 +192,8 @@ public class TestServiceImpl implements TestService {
     @Override
     public Result sh(TestShDto param) {
         String sceneCode = param.getSceneCode();
-        String cmd = StrUtil.format("bash /mnt/720yun_fd_manage_data/baseData/aws_upload.sh test-4dkankan /mnt/720yun_fd_manage_data/{} 720yun_fd_manage/{}", sceneCode, sceneCode );
-        if ("1".equals(param.getType())){
+        String cmd = StrUtil.format("bash /mnt/720yun_fd_manage_data/baseData/aws_upload.sh test-4dkankan /mnt/720yun_fd_manage_data/{} 720yun_fd_manage/{}", sceneCode, sceneCode);
+        if ("1".equals(param.getType())) {
             cmd = "sudo " + cmd;
         }
 
@@ -223,8 +217,126 @@ public class TestServiceImpl implements TestService {
 
 
     /**
+     * 2022-12-26
+     *
+     * @param isAll
+     * @return
+     */
+    @Override
+    public Result updateSceneCode(String isAll) {
+
+        // 1. 获取作品表
+
+        List<WorkEntity> list = workService.findByStatus(1);
+        log.info("作品数量:{}", list.size());
+        int n = 0;
+        for (WorkEntity workEntity : list) {
+            n++;
+
+            // 只处理场景码包含中[] 符合的数据
+            String sceneCodes = workEntity.getSceneCodes();
+            if (StrUtil.isBlank(sceneCodes)) {
+                continue;
+            }
+            if (sceneCodes.startsWith("[")) {
+                String id = workEntity.getId();
+                List<String> codes = downLoadSomeData(id);
+                log.info("更新完成第:{} 个, 作品码为:{}, 处理后的场景码为:{}", n, id, codes);
+                String join = StringUtils.join(codes, ",");
+
+                workEntity.setSceneCodes(join);
+                workService.update(workEntity);
+
+                if (!"1".equals(isAll)) {
+                    break;
+                }
+            }
+
+
+        }
+
+
+        return Result.success();
+    }
+
+    /**
+     * 2022-12-26
+     * @param isAll
+     * @return
+     */
+    @Override
+    public Result updateWorkType(String isAll) {
+        // 1. 获取作品表
+        List<WorkEntity> list = workService.findByStatus(1);
+        log.info("作品数量:{}", list.size());
+        int n = 0;
+        for (WorkEntity workEntity : list) {
+            n++;
+
+            // 只处理没有数据的
+            String type = workEntity.getType();
+            if (StrUtil.isNotBlank(type)) {
+                continue;
+            }
+
+            // 场景码为空的不处理
+            String sceneCodes = workEntity.getSceneCodes();
+            if (StrUtil.isBlank(sceneCodes)){
+                continue;
+            }
+
+            String workType = getTypeBySceneCodes(sceneCodes);
+            workEntity.setType(workType);
+            workService.update(workEntity);
+            log.info("更新完成第:{} 个, 作品码为:{}, 处理后的场景码为:{}", n, workEntity.getId(), workType);
+
+            if (!"1".equals(isAll)) {
+                break;
+            }
+
+
+        }
+
+
+        return Result.success();
+    }
+
+    /**
+     * 2022-12-19
+     * 获取作品类型
+     * @param sceneCodes 场景码集合
+     * @return
+     */
+    private String getTypeBySceneCodes(String sceneCodes){
+        String type = "0"; // 默认值
+        if (StrUtil.isBlank(sceneCodes)){
+            return type;
+        }
+        List<String> list = StrUtil.splitTrim(sceneCodes, ",");
+        boolean isPano = false;
+        boolean is4dkk = false;
+        for (String s : list) {
+            if (s.startsWith("fd720_")){
+                type = "pano";
+                isPano = true;
+            } else {
+                type = "4dkk";
+                is4dkk = true;
+            }
+        }
+        if (isPano && is4dkk){ // 同时满足:mix:混合类型
+            type = "mix";
+        }
+        log.info("当前作品类型为:{}", type);
+        return type;
+
+    }
+
+
+    /**
      * 2022-10-21
      * 作品创建tour.xml
+     *
      * @param isAll
      */
     private void createWorkTour(String isAll) {
@@ -239,9 +351,9 @@ public class TestServiceImpl implements TestService {
             String id = workEntity.getId();
             List<String> sceneCodes = downLoadSomeData(id);
             createTour(sceneCodes, id);
-            n ++;
+            n++;
             log.info("更新完成第:{} 个, 作品码为:{}", n, id);
-            if (!"1".equals(isAll)){
+            if (!"1".equals(isAll)) {
                 break;
             }
 
@@ -250,13 +362,13 @@ public class TestServiceImpl implements TestService {
 
     /**
      * oss 下载ossSomeData
-     * 原因: 作品码里的场景数据有误的
+     *
      * @param id
      * @return
      */
-    private List<String> downLoadSomeData(String id){
-        String someData = configConstant.ossDomain + configConstant.ossBasePath + id +"/someData.json";
-        String locSomeData = configConstant.serverBasePath + id +"/someData.json";
+    private List<String> downLoadSomeData(String id) {
+        String someData = configConstant.ossDomain + configConstant.ossBasePath + id + "/someData.json";
+        String locSomeData = configConstant.serverBasePath + id + "/someData.json";
         try {
             HttpUtil.downloadFile(someData, locSomeData);
         } catch (Exception e) {
@@ -280,7 +392,7 @@ public class TestServiceImpl implements TestService {
 
             String type = sub.getString("type");
             // 过滤场景
-            if ("pano".equals(type)){
+            if ("pano".equals(type)) {
                 String sceneCode = sub.getString("sceneCode");
                 list.add(sceneCode);
             }
@@ -291,6 +403,7 @@ public class TestServiceImpl implements TestService {
 
     /**
      * 创建tour.xml并上传oss
+     *
      * @param scenes
      * @param id
      */
@@ -323,7 +436,7 @@ public class TestServiceImpl implements TestService {
     }
 
 
-    private String getBaseTour(){
+    private String getBaseTour() {
         String baseTourPath = configConstant.serverBasePath + "baseData/tour.xml";
         String s = FileUtil.readString(baseTourPath, "utf-8");
         // 结束标签置空, 方便操作
@@ -334,17 +447,18 @@ public class TestServiceImpl implements TestService {
 
     /**
      * 过滤720场景
+     *
      * @param sceneCodes
      * @return
      */
-    private List<String> filterSceneCodesByPano(String sceneCodes){
-        if (StrUtil.isBlank(sceneCodes)){
+    private List<String> filterSceneCodesByPano(String sceneCodes) {
+        if (StrUtil.isBlank(sceneCodes)) {
             return new ArrayList<>();
         }
         String[] split = sceneCodes.split(",");
         List<String> list = new ArrayList<>();
         for (String s : split) {
-            if (s.startsWith("fd720_")){
+            if (s.startsWith("fd720_")) {
                 list.add(s);
             }
         }
@@ -354,6 +468,7 @@ public class TestServiceImpl implements TestService {
     /**
      * 2022-10-21
      * 更新素材表字段
+     *
      * @param isAll
      */
     private void updateFodderTour(String isAll) {
@@ -366,9 +481,9 @@ public class TestServiceImpl implements TestService {
         int n = 0;
         List<String> errTours = new ArrayList<>();
         for (FodderEntity fodderEntity : list) {
-            n ++;
+            n++;
             String tour = fodderEntity.getTour();
-            if (StrUtil.isNotBlank(tour)){
+            if (StrUtil.isNotBlank(tour)) {
                 continue;
             }
             String ossPath = fodderEntity.getOssPath();
@@ -380,7 +495,7 @@ public class TestServiceImpl implements TestService {
                 HttpUtil.downloadFile(tourPath, locPath);
                 String tourXmlScene = getTourXmlScene(sceneCode);
 
-                if (!tourXmlScene.contains("CURRENTXML")){
+                if (!tourXmlScene.contains("CURRENTXML")) {
                     errTours.add(sceneCode);
                 }
 
@@ -398,18 +513,15 @@ public class TestServiceImpl implements TestService {
             }
 
             // isAll != 1 只更新一个
-            if (!"1".equals(isAll)){
+            if (!"1".equals(isAll)) {
                 break;
             }
 
 
-
-
         }
         log.warn("tour数据异常的数量:{}", errTours.size());
 
 
-
     }
 
 
@@ -435,7 +547,7 @@ public class TestServiceImpl implements TestService {
     }
 
     // 下载初始场景图片
-    private void downloadThumb(Map<String, String> iconMap){
+    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();
@@ -449,14 +561,14 @@ public class TestServiceImpl implements TestService {
         }
     }
 
-    private void getHandleSceneCode(String str, Map iconMap, Set sceneCodes){
+    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)){
+            if ("pano".equals(type)) {
                 String sceneCode = parse.getString("sceneCode");
                 String icon = parse.getString("icon");
                 jsonArray.add(sceneCode);
@@ -473,15 +585,15 @@ public class TestServiceImpl implements TestService {
 
     /**
      * 读取replace.csv
-     *
+     * <p>
      * https://www.4dkankan.com/panorama/show.html?id=606&vr=fd720_7B6nNaWQO
-     *
+     * <p>
      * https://www.4dkankan.com/panorama/show.html?id=566&vr=fd720_1jKqSxWLe
-     *
+     * <p>
      * fd720_1AOhUJZoI -> fd720_A6yCltViq
      */
     @Test
-    public void readReplaceFile(){
+    public void readReplaceFile() {
         String basePath = "F:\\work\\四维-全景看看\\data\\";
         String replacePath = basePath + "replace.csv";
         List<String> str = FileUtil.readLines(replacePath, "utf-8");
@@ -512,8 +624,7 @@ public class TestServiceImpl implements TestService {
     }
 
     /**
-     *
-     * @param workIds 590, 580, 582, 571, 583, 573, 584, 585, 586, 575, 587, 588, 577, 566, 589, 578, 579, 568, 606
+     * @param workIds  590, 580, 582, 571, 583, 573, 584, 585, 586, 575, 587, 588, 577, 566, 589, 578, 579, 568, 606
      * @param basePath
      */
     private void downloadSomeDataJson(Set<String> workIds, String basePath) {
@@ -524,31 +635,31 @@ public class TestServiceImpl implements TestService {
         String url;
         for (String workId : workIds) {
             // oss下载someData.json
-            url = baseUrl + workId + "/someData.json?m="+ System.currentTimeMillis();
+            url = baseUrl + workId + "/someData.json?m=" + System.currentTimeMillis();
             HttpUtil.downloadFile(url, basePath + workId + "/someData.json");
             log.info("下载someData完成: {}", workId);
         }
     }
 
 
-    private void editSomeData(String basePath, String isBatch, List<ReplaceVo> list){
+    private void editSomeData(String basePath, String isBatch, List<ReplaceVo> list) {
         File[] faFiles = new File(basePath).listFiles();
         int i = 0;
         for (File file : faFiles) {
             String dirPath = file.getAbsolutePath();
             String dirName = file.getName();
-            if (FileUtil.isDirectory(dirPath)){
+            if (FileUtil.isDirectory(dirPath)) {
                 log.info("工作目录:{}", dirPath);
                 log.info("工作码: {}", dirName);
                 String outPath = dirPath + "/b/someData.json";
-                this.writeFile(dirPath + "/someData.json",outPath,  list, dirName);
+                this.writeFile(dirPath + "/someData.json", outPath, list, dirName);
 
                 log.info("替换第: {} 个, 场景码: {}", i, dirName);
             }
             i++;
 
-            if (!"0".equals(isBatch)){
-                if (i==1){
+            if (!"0".equals(isBatch)) {
+                if (i == 1) {
                     log.info("单个执行");
                     break;
                 }
@@ -559,9 +670,10 @@ public class TestServiceImpl implements TestService {
 
     /**
      * 写文件
+     *
      * @param inPath 输入文件地址
      */
-    private void writeFile(String inPath, String outPath, List<ReplaceVo> list, String workId){
+    private void writeFile(String inPath, String outPath, List<ReplaceVo> list, String workId) {
         if (!FileUtil.isFile(inPath)) {
             log.error("场景码输入文件不存在,请检查 : {}", inPath);
             return;
@@ -570,7 +682,7 @@ public class TestServiceImpl implements TestService {
         for (ReplaceVo vo : list) {
             String oCode = vo.getOCode();
             String oName = vo.getOName();
-            if (s.contains(oCode) || s.contains(oName)){
+            if (s.contains(oCode) || s.contains(oName)) {
                 log.info("有替换内容, 旧场景码:{}, 新场景码:{}", oCode, vo.getNCode());
                 s = s.replaceAll(oCode, vo.getNCode());
                 s = s.replaceAll(oName, vo.getNName());
@@ -584,7 +696,7 @@ public class TestServiceImpl implements TestService {
         ossUploadSomeData(outPath, workId);
     }
 
-    private void ossUploadSomeData(String srcPath, String workId){
+    private void ossUploadSomeData(String srcPath, String workId) {
         log.info("oss准备上传: {}", srcPath);
         String targetPath = configConstant.ossBasePath + workId + "/someData.json";
         log.info("oss上传地址: {}", targetPath);

+ 1 - 2
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -258,7 +258,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
         StringBuilder builder = new StringBuilder();
         builder.append("SELECT type as groupKey, count(*) as count FROM tb_work WHERE is_delete=0 and status=1");
         if (today != null){
-            builder.append(" and DATA_FORMAT(create_time, '%Y-%m-%d') = '").append(today).append("'");
+            builder.append(" and date(create_time) = '").append(today).append("'");
         }
         builder.append(" and type is not null");
         builder.append(" GROUP BY type");
@@ -389,7 +389,6 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
         BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), ErrorEnum.FAILURE_CODE_3103.code(), "服务器tour.xml文件不存在");
 
         String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
-//        aliyunOssUtil.upload(tourPath, ossKeyPath);
         fileAndOssUtil.upload(tourPath, ossKeyPath);
         log.info("tour.xml上传完成 : {}", ossKeyPath);
         DateUtils.spendTime(startTime, "tour上传oss");

+ 2 - 4
720yun_fd_manage/gis_service/src/main/java/com/gis/task/VisitTask.java

@@ -1,11 +1,9 @@
 package com.gis.task;
 
-import cn.hutool.core.io.FileUtil;
 import com.gis.common.constant.RedisConstant;
 import com.gis.common.util.RedisUtil;
 import com.gis.domain.entity.ReportEntity;
 import com.gis.domain.vo.ReportWorkVo;
-import com.gis.oss.util.FileUtils;
 import com.gis.service.FodderService;
 import com.gis.service.ReportService;
 import com.gis.service.WorkService;
@@ -17,7 +15,6 @@ import org.springframework.stereotype.Component;
 
 import java.time.LocalDate;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Created by owen on 2022/11/9 0009 16:42
@@ -45,7 +42,7 @@ public class VisitTask {
      * 每天24点检查未开始的活动
      * 每天24点执行一次  @Scheduled(cron=" 0 0 0 * * ? ") @Scheduled(cron=" * 1  * * ? ")
      *
-     * Scheduled(cron=" 10 0/5 * * * ? ")   //每五分钟执行一次
+     * Scheduled(cron=" 10 0/5 * * * ? ")   // 每五分钟执行一次, 能被5整除
      * Scheduled(cron = "0 0 3 * * ?") 每天凌晨三点
      */
     @Scheduled(cron = "0 0 2 * * ?")
@@ -104,6 +101,7 @@ public class VisitTask {
         entity.setType("user");
         entity.setTotal(count); // 容量是GB
         entity.setDay(today);
+        entity.setInfoType("all");
         reportService.save(entity);
         log.info("保存用户上线数据完成, 当前数量:{} ", count);
 

+ 13 - 0
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/TestController.java

@@ -273,6 +273,19 @@ public class TestController extends BaseController {
     }
 
 
+    @ApiOperation(value = "v1.3-更新作品场景码", notes = "isAll:不传为更新1个, 传1为更新全部")
+    @GetMapping("/updateSceneCode")
+    public Result updateSceneCode(String isAll)  {
+        return testService.updateSceneCode(isAll);
+    }
+
+    @ApiOperation(value = "v1.3-更新作品类型", notes = "isAll:不传为更新1个, 传1为更新全部")
+    @GetMapping("/updateWorkType")
+    public Result updateWorkType(String isAll)  {
+        return testService.updateWorkType(isAll);
+    }
+
+