dengsixing 6 月之前
父節點
當前提交
a2a26e35b5

+ 1 - 1
src/main/java/com/fdkankan/Application.java

@@ -35,7 +35,7 @@ public class Application implements CommandLineRunner {
 
     @Override
     public void run(String... args) throws Exception {
-//        convertService.scenePushHistory();
+        convertService.pushOldHistory();
     }
 }
 

+ 11 - 0
src/main/java/com/fdkankan/project/tieta/controller/ConvertController.java

@@ -2,6 +2,7 @@ package com.fdkankan.project.tieta.controller;
 
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.project.tieta.bean.ResultData;
@@ -9,7 +10,9 @@ import com.fdkankan.project.tieta.constant.Constant;
 import com.fdkankan.project.tieta.dto.ScenePushDTO;
 import com.fdkankan.project.tieta.dto.SendConvertDTO;
 import com.fdkankan.project.tieta.entity.FullphotoFileindex;
+import com.fdkankan.project.tieta.entity.FullphotoUprecord;
 import com.fdkankan.project.tieta.service.FullphotoFileindexService;
+import com.fdkankan.project.tieta.service.FullphotoUprecordService;
 import com.fdkankan.project.tieta.service.IConvertService;
 import com.fdkankan.project.tieta.utils.FdfsUtil;
 import com.fdkankan.redis.util.RedisClient;
@@ -32,6 +35,8 @@ public class ConvertController {
     private IConvertService convertService;
     @Resource
     private RedisClient redisClient;
+    @Autowired
+    FullphotoUprecordService fullphotoUprecordService;
 
     @PostMapping("/sendConvert")
     public ResultData sendConvert(@RequestBody @Validated SendConvertDTO dto){
@@ -41,6 +46,12 @@ public class ConvertController {
 
     @PostMapping("/push")
     public ResultData push(@RequestBody @Validated ScenePushDTO dto){
+        List<FullphotoUprecord> list1 = fullphotoUprecordService.list(
+                new LambdaQueryWrapper<FullphotoUprecord>()
+                        .eq(FullphotoUprecord::getStationCode, dto.getStationCode())
+                        .eq(FullphotoUprecord::getEntityId, dto.getEntityId())
+                        .orderByDesc(FullphotoUprecord::getUpTime));
+        dto.setUploadId(list1.get(0).getUploadId());
         return convertService.scenePush(dto, "api");
     }
 

+ 2 - 0
src/main/java/com/fdkankan/project/tieta/dto/ScenePushDTO.java

@@ -23,4 +23,6 @@ public class ScenePushDTO {
 
     @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date upTime;
+
+    private String uploadId;
 }

+ 2 - 0
src/main/java/com/fdkankan/project/tieta/entity/FullphotoUprecord.java

@@ -104,5 +104,7 @@ public class FullphotoUprecord implements Serializable {
     @TableField("UP_VERSION")
     private String upVersion;
 
+    private Integer count;
+
 
 }

+ 2 - 15
src/main/java/com/fdkankan/project/tieta/schedule/Job.java

@@ -39,16 +39,9 @@ public class Job {
 
     @Scheduled(initialDelay = 2*10*1000, fixedDelay = 10*60*1000)
     public void push(){
-//        Map<String, Object> lockMap = redisClient.lockLeaseTime(Constant.REDIS_LOCK_SCENE_CONVERT, 30 * 60 * 1000);
-//        boolean lock = (Boolean) lockMap.get("lock");
-//        if(!lock){
-//            return;
-//        }
-//        String uniqueFlag = (String) lockMap.get("uniqueFlag");
-//        try {
             String startTimeStr = redisClient.get(Constant.REDIS_SCENE_CONVERT_STARTTIME);
             if(StrUtil.isEmpty(startTimeStr)){
-                startTimeStr = "2024-09-01 00:00:00";
+                startTimeStr = DateUtil.formatDateTime(new Date());
                 redisClient.add(Constant.REDIS_SCENE_CONVERT_STARTTIME, startTimeStr);
             }
             DateTime start = DateUtil.parse(startTimeStr, "yyyy-MM-dd HH:mm:ss");
@@ -65,18 +58,12 @@ public class Job {
                     continue;
                 }
 
-                convertService.scenePush(ScenePushDTO.builder().upTime(item.getUpTime()).stationCode(item.getStationCode()).entityId(item.getEntityId()).build(), null);
+                convertService.scenePush(ScenePushDTO.builder().upTime(item.getUpTime()).stationCode(item.getStationCode()).entityId(item.getEntityId()).uploadId(item.getUploadId()).build(), null);
                 if(maxTime.before(item.getUpTime())){
                     maxTime = item.getUpTime();
                     redisClient.add(Constant.REDIS_SCENE_CONVERT_STARTTIME, DateUtil.format(maxTime, "yyyy-MM-dd HH:mm:ss"));
                 }
             }
-
-//        }finally {
-//            if(lock){
-//                redisClient.unLock(Constant.REDIS_LOCK_SCENE_CONVERT, uniqueFlag);
-//            }
-//        }
     }
 
 }

+ 2 - 0
src/main/java/com/fdkankan/project/tieta/service/FullphotoFileindexService.java

@@ -21,6 +21,8 @@ public interface FullphotoFileindexService extends IService<FullphotoFileindex>
 
     Page<FullphotoFileindex> pageStationCodeAndEntityId(long current, int size);
 
+    List<FullphotoFileindex> listByUploadId(String uploadId);
+
 
 
 }

+ 2 - 0
src/main/java/com/fdkankan/project/tieta/service/IConvertService.java

@@ -12,5 +12,7 @@ public interface IConvertService {
 
     void scenePushHistory();
 
+    void pushOldHistory();
+
 
 }

+ 44 - 4
src/main/java/com/fdkankan/project/tieta/service/impl/ConvertServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.project.tieta.bean.ResultData;
 import com.fdkankan.project.tieta.constant.Constant;
@@ -12,7 +13,9 @@ import com.fdkankan.project.tieta.constant.ServerCode;
 import com.fdkankan.project.tieta.dto.ScenePushDTO;
 import com.fdkankan.project.tieta.dto.SendConvertDTO;
 import com.fdkankan.project.tieta.entity.FullphotoFileindex;
+import com.fdkankan.project.tieta.entity.FullphotoUprecord;
 import com.fdkankan.project.tieta.service.FullphotoFileindexService;
+import com.fdkankan.project.tieta.service.FullphotoUprecordService;
 import com.fdkankan.project.tieta.service.IConvertService;
 import com.fdkankan.redis.util.RedisClient;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
@@ -36,6 +39,8 @@ public class ConvertServiceImpl implements IConvertService {
     private FullphotoFileindexService fullphotoFileindexService;
     @Resource
     private RedisClient redisClient;
+    @Autowired
+    FullphotoUprecordService fullphotoUprecordService;
 
     @Override
     public void sendConvert(SendConvertDTO dto) {
@@ -51,7 +56,14 @@ public class ConvertServiceImpl implements IConvertService {
         playload.put("stationCode", dto.getStationCode());
         playload.put("entityId", dto.getEntityId());
         playload.put("upTime", DateUtil.format(dto.getUpTime(), DatePattern.NORM_DATETIME_PATTERN));
-        List<FullphotoFileindex> fullphotoFileindices = fullphotoFileindexService.listByStationCodeAndEntityId(dto.getStationCode(), dto.getEntityId());
+        if(StrUtil.isNotEmpty(convertType)){
+            playload.put("convertType", convertType);
+        }
+        if(StrUtil.isNotEmpty(convertType) && convertType.equals("upTime")){//只更新上传时间,直接发送,不需要查文件列表数据
+            mqProducer.sendByWorkQueue(Constant.QUEUE_SCENE_CONVERT, playload);
+            return ResultData.ok();
+        }
+        List<FullphotoFileindex> fullphotoFileindices = fullphotoFileindexService.listByUploadId(dto.getUploadId());
         if(CollUtil.isEmpty(fullphotoFileindices)){
             return ResultData.error(ServerCode.RESOURCE_NOT_EXIST);
         }
@@ -63,9 +75,6 @@ public class ConvertServiceImpl implements IConvertService {
             return item;
         }).collect(Collectors.toList());
         playload.put("fileList", fileList);
-        if(StrUtil.isNotEmpty(convertType)){
-            playload.put("convertType", convertType);
-        }
         mqProducer.sendByWorkQueue(Constant.QUEUE_SCENE_CONVERT, playload);
         return ResultData.ok();
     }
@@ -101,4 +110,35 @@ public class ConvertServiceImpl implements IConvertService {
             current++;
         }while (fullphotoFileindexPage.hasNext());
     }
+
+    @Override
+    public void pushOldHistory() {
+        List<FullphotoUprecord> list = fullphotoUprecordService.list(new LambdaQueryWrapper<FullphotoUprecord>().select(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId).groupBy(FullphotoUprecord::getStationCode, FullphotoUprecord::getEntityId));
+        for (FullphotoUprecord fullphotoUprecord : list) {
+
+            List<FullphotoUprecord> list1 = fullphotoUprecordService.list(
+                    new LambdaQueryWrapper<FullphotoUprecord>()
+                            .eq(FullphotoUprecord::getStationCode, fullphotoUprecord.getStationCode())
+                            .eq(FullphotoUprecord::getEntityId, fullphotoUprecord.getEntityId())
+                            .orderByDesc(FullphotoUprecord::getUpTime));
+
+            for(int i = 0; i < list1.size(); i++){
+                FullphotoUprecord fullphotoUprecord1 = list1.get(i);
+                ScenePushDTO scenePushDTO = new ScenePushDTO();
+                scenePushDTO.setStationCode(fullphotoUprecord1.getStationCode());
+                scenePushDTO.setEntityId(fullphotoUprecord1.getEntityId());
+                scenePushDTO.setUpTime(fullphotoUprecord1.getUpTime());
+                scenePushDTO.setUploadId(fullphotoUprecord1.getUploadId());
+                String convertType = null;
+                if(i == 0){
+                    convertType = "upTime";//默认vr系统已经是
+                }else{
+                    convertType = "old";
+                }
+                this.scenePush(scenePushDTO, convertType);
+            }
+        }
+
+
+    }
 }

+ 6 - 0
src/main/java/com/fdkankan/project/tieta/service/impl/FullphotoFileindexServiceImpl.java

@@ -36,4 +36,10 @@ public class FullphotoFileindexServiceImpl extends ServiceImpl<FullphotoFileinde
         Page<FullphotoFileindex> fullphotoFileindexPage1 = this.baseMapper.pageStationCodeAndEntityId(fullphotoFileindexPage);
         return fullphotoFileindexPage1;
     }
+
+    @Override
+    public List<FullphotoFileindex> listByUploadId(String uploadId) {
+        return this.list(new LambdaQueryWrapper<FullphotoFileindex>()
+                .eq(FullphotoFileindex::getUploadId, uploadId));
+    }
 }