dengsixing 4 maanden geleden
bovenliggende
commit
ef196986fb

+ 19 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildSceneProcessLogListener.java

@@ -3,7 +3,9 @@ package com.fdkankan.contro.mq.listener;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.CommonOperStatus;
 import com.fdkankan.common.constant.ModelingBuildStatus;
+import com.fdkankan.contro.service.IJmgaService;
 import com.fdkankan.contro.service.ISceneBuildProcessLogService;
+import com.fdkankan.contro.service.IScenePlusService;
 import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.rabbitmq.bean.BuildSceneProcessLogMessage;
 import com.rabbitmq.client.Channel;
@@ -16,6 +18,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 @Slf4j
 @Component
@@ -28,6 +33,10 @@ public class BuildSceneProcessLogListener{
 
     @Autowired
     private ISceneBuildProcessLogService sceneBuildProcessLogService;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IJmgaService jmgaService;
 
     /**
      * 场景计算状态日志记录
@@ -46,6 +55,14 @@ public class BuildSceneProcessLogListener{
             String reason = null;
             int status = CommonOperStatus.SUCCESS.code();
             int buildStatus = buildSceneMessage.getBuildStatus();
+
+            Map<String, Object> param = new HashMap<>();
+
+            param.put("scene_num", num);
+            param.put("event_time", new Date());
+            param.put("ryid", scenePlusService.getRyIdByNum(num));
+
+
             //新的计算开始,需要将之前的记录置为失效
             if(buildStatus == ModelingBuildStatus.CALCULATING.code()){
                 sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.CALL.code(),queueModelingCall);
@@ -56,6 +73,8 @@ public class BuildSceneProcessLogListener{
                     reason = ModelingBuildStatus.get(buildStatus).message();
                 }
             }
+
+            jmgaService.sendStatus(param);
             sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.CALL.code(), queueModelingCall, status, reason);
         }catch (Exception e){
             log.error("场景计算流程状态日志记录出错, num="+num, e);

+ 67 - 67
src/main/java/com/fdkankan/contro/mq/listener/BuildSceneProgressListener.java

@@ -1,67 +1,67 @@
-package com.fdkankan.contro.mq.listener;
-
-import cn.hutool.core.thread.ThreadUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.contro.mq.service.IBuildSceneProgressService;
-import com.fdkankan.contro.mq.service.impl.BuildSceneServiceImpl;
-import com.fdkankan.contro.service.ICommonService;
-import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
-import com.google.j2objc.annotations.AutoreleasePool;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.concurrent.*;
-
-@Slf4j
-@Component
-public class BuildSceneProgressListener{
-
-
-    @Autowired
-    private IBuildSceneProgressService buildSceneProgressService;
-
-    @Value("${queue.modeling.modeling-progress-notice}")
-    private String queueName;
-
-    @Autowired
-    private ICommonService commonService;
-
-    /**
-     * 场景计算进度监听
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.modeling.modeling-progress-notice}")
-    )
-    public void buildSceneProgressHandler(Channel channel, Message message) throws Exception {
-        String messageId = message.getMessageProperties().getMessageId();
-        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
-        log.info("开始推送场景计算进度,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
-        BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
-        String num = buildSceneMessage.getSceneNum();
-        try {
-            Map<String, Object> ext = buildSceneMessage.getExt();
-            String uuid = (String)ext.get("uuid");
-            String batchId = (String)ext.get("batchId");
-            commonService.sendSceneStatus(buildSceneMessage.getSceneNum(), uuid, batchId, 3);
-        }catch (Exception e){
-            log.error("开始计算通知失败,num:{}", num, e);
-        }
-
-//        buildSceneProgressService.monitorProgress(buildSceneMessage);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-        log.info("推送场景计算进度完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
-
-    }
-
-}
+//package com.fdkankan.contro.mq.listener;
+//
+//import cn.hutool.core.thread.ThreadUtil;
+//import com.alibaba.fastjson.JSONObject;
+//import com.fdkankan.contro.mq.service.IBuildSceneProgressService;
+//import com.fdkankan.contro.mq.service.impl.BuildSceneServiceImpl;
+//import com.fdkankan.contro.service.ICommonService;
+//import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+//import com.google.j2objc.annotations.AutoreleasePool;
+//import com.rabbitmq.client.Channel;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.amqp.core.Message;
+//import org.springframework.amqp.rabbit.annotation.Queue;
+//import org.springframework.amqp.rabbit.annotation.RabbitListener;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Component;
+//
+//import java.nio.charset.StandardCharsets;
+//import java.util.Map;
+//import java.util.concurrent.*;
+//
+//@Slf4j
+//@Component
+//public class BuildSceneProgressListener{
+//
+//
+//    @Autowired
+//    private IBuildSceneProgressService buildSceneProgressService;
+//
+//    @Value("${queue.modeling.modeling-progress-notice}")
+//    private String queueName;
+//
+//    @Autowired
+//    private ICommonService commonService;
+//
+//    /**
+//     * 场景计算进度监听
+//     * @param channel
+//     * @param message
+//     * @throws Exception
+//     */
+//    @RabbitListener(
+//            queuesToDeclare = @Queue("${queue.modeling.modeling-progress-notice}")
+//    )
+//    public void buildSceneProgressHandler(Channel channel, Message message) throws Exception {
+//        String messageId = message.getMessageProperties().getMessageId();
+//        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+//        log.info("开始推送场景计算进度,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
+//        BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
+//        String num = buildSceneMessage.getSceneNum();
+//        try {
+//            Map<String, Object> ext = buildSceneMessage.getExt();
+//            String uuid = (String)ext.get("uuid");
+//            String batchId = (String)ext.get("batchId");
+//            commonService.sendSceneStatus(buildSceneMessage.getSceneNum(), uuid, batchId, 3);
+//        }catch (Exception e){
+//            log.error("开始计算通知失败,num:{}", num, e);
+//        }
+//
+////        buildSceneProgressService.monitorProgress(buildSceneMessage);
+//        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+//        log.info("推送场景计算进度完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
+//
+//    }
+//
+//}

+ 15 - 13
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -149,6 +149,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private IOrigFileUploadService origFileUploadService;
     @Autowired
     private ILinkPanService linkPanService;
+    @Autowired
+    private IJmgaService jmgaService;
 
 
     @Override
@@ -241,6 +243,19 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 }
                 ext.put("128G", 1);
             }
+
+            Map<String, Object> param = new HashMap<>();
+            try {
+                param.put("event_type", "排队中");
+                param.put("event_content", "排队中");
+                param.put("scene_num", num);
+                param.put("event_time", new Date());
+                param.put("ryid", scenePlusService.getRyIdByNum(num));
+                jmgaService.sendStatus(param);
+            }catch (Exception e){
+                log.info("推送时间失败,param:{}", param);
+            }
+
             mqProducer.sendByWorkQueue(queueModelingCall, message);
 
             log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
@@ -378,13 +393,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 this.sendFailToLaser(sceneCode);
 
                 redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "-1");
-
-                try {
-                    commonService.sendSceneStatus(sceneCode, uuid, batchId, 4);
-                }catch (Exception e){
-                    log.info("通知计算失败状态失败, num:{}", sceneCode, e);
-                }
-
                 return;
             }
 
@@ -543,12 +551,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             redisUtil.set(String.format(RedisKey.SCENE_BUILD_FINISH_NUM, sceneCode), "1");
 
-            try {
-                commonService.sendSceneStatus(sceneCode, uuid, batchId, 4);
-            }catch (Exception e){
-                log.info("通知计算成功状态失败, num:{}", sceneCode, e);
-            }
-
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){

+ 4 - 0
src/main/java/com/fdkankan/contro/service/IJmgaService.java

@@ -2,8 +2,12 @@ package com.fdkankan.contro.service;
 
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.Map;
+
 public interface IJmgaService {
 
     void checkFileWhole(String uuid, String dataSource, JSONObject fdageData);
 
+    void sendStatus(Map<String, Object> param);
+
 }

+ 3 - 1
src/main/java/com/fdkankan/contro/service/IJyUserService.java

@@ -8,7 +8,7 @@ import com.fdkankan.contro.entity.JyUser;
  *  服务类
  * </p>
  *
- * @author 
+ * @author
  * @since 2023-09-11
  */
 public interface IJyUserService extends IService<JyUser> {
@@ -17,4 +17,6 @@ public interface IJyUserService extends IService<JyUser> {
 
     JyUser getByRyId(String userName);
 
+    JyUser getByUserId(Long userId);
+
 }

+ 3 - 1
src/main/java/com/fdkankan/contro/service/IScenePlusService.java

@@ -13,7 +13,7 @@ import java.util.Map;
  * 场景主表 服务类
  * </p>
  *
- * @author 
+ * @author
  * @since 2022-03-16
  */
 public interface IScenePlusService extends IService<ScenePlus> {
@@ -27,4 +27,6 @@ public interface IScenePlusService extends IService<ScenePlus> {
     ScenePlus getByFileId(String fileId);
 
     Long sumUsedSpaceByCameraId(Long cameraId, String spaceTypeStr);
+
+    String getRyIdByNum(String num);
 }

+ 9 - 0
src/main/java/com/fdkankan/contro/service/impl/JmgaServiceImpl.java

@@ -13,6 +13,7 @@ import com.fdkankan.contro.service.IJmgaService;
 import com.fdkankan.contro.service.IOrigFileUploadBatchService;
 import com.fdkankan.contro.service.IOrigFileUploadService;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -34,6 +36,8 @@ public class JmgaServiceImpl implements IJmgaService {
     private IOrigFileUploadService origFileUploadService;
     @Resource
     private FYunFileServiceInterface fileServiceInterface;
+    @Resource
+    private RabbitMqProducer mqProducer;
 
     @Override
     public void checkFileWhole(String uuid, String dataSource, JSONObject fdageData) {
@@ -83,4 +87,9 @@ public class JmgaServiceImpl implements IJmgaService {
             throw new BusinessException(ErrorCode.FAILURE_CODE_4001, JSON.toJSONString(fileList));
         }
     }
+
+    @Override
+    public void sendStatus(Map<String, Object> param) {
+        mqProducer.sendByWorkQueue("jmga-event-notice", param);
+    }
 }

+ 4 - 0
src/main/java/com/fdkankan/contro/service/impl/JyUserServiceImpl.java

@@ -28,4 +28,8 @@ public class JyUserServiceImpl extends ServiceImpl<IJyUserMapper, JyUser> implem
         return this.getOne(new LambdaQueryWrapper<JyUser>().eq(JyUser::getRyId, ryId));
     }
 
+    @Override
+    public JyUser getByUserId(Long userId) {
+        return this.getOne(new LambdaQueryWrapper<JyUser>().eq(JyUser::getUserId, userId));
+    }
 }

+ 16 - 4
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -1678,9 +1678,20 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             mqMessage.getExt().put("noticeTimes", origFileUploadBatch.getNoticeTimes());
             origFileUploadBatchService.updateById(origFileUploadBatch);
             redisUtil.del("single:upload:uuid:" + unicode);
-            //推送通知计算状态
-            commonService.sendSceneStatus(null, unicode, origFileUploadBatch.getBatchId(), 2);
         }
+
+        Map<String, Object> param = new HashMap<>();
+        try {
+            param.put("event_type", "上传完毕");
+            param.put("event_content", "上传完毕");
+            param.put("scene_num", sceneNum);
+            param.put("event_time", new Date());
+            param.put("ryid", scenePlusService.getRyIdByNum(sceneNum));
+            jmgaService.sendStatus(param);
+        }catch (Exception e){
+            log.info("推送时间失败,param:{}", param);
+        }
+
         rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
 
         return scenePlusVO;
@@ -2331,8 +2342,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                     origFileUploadBatchService.save(origFileUploadBatch);
                 }
             }
-            //推送开始上传状态
-            commonService.sendSceneStatus(null, uuid, batchId, 1);
         }
 
 
@@ -2415,6 +2424,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //校验文件是否完整
         jmgaService.checkFileWhole(uuid, dataSource, fdageData);
 
+        //推送开始上传状态
+
         //调注册用户接口
         Map<String, Object> params = new HashMap<>();
         params.put("ryId", customUserId);
@@ -2449,6 +2460,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 //            icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
 //            log.info("上传icon成功....");
 //        }
+
         buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, camera, cameraDetail, rebuild, "", user, customUserId, "single");
 
         scenePlus = scenePlusService.getScenePlusByNum(sceneNum);

+ 13 - 1
src/main/java/com/fdkankan/contro/service/impl/ScenePlusServiceImpl.java

@@ -6,10 +6,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.constant.*;
 import com.fdkankan.contro.entity.CameraDetail;
+import com.fdkankan.contro.entity.JyUser;
 import com.fdkankan.contro.entity.ScenePlus;
 import com.fdkankan.contro.entity.ScenePlusExt;
 import com.fdkankan.contro.mapper.IScenePlusMapper;
 import com.fdkankan.contro.service.ICameraDetailService;
+import com.fdkankan.contro.service.IJyUserService;
 import com.fdkankan.contro.service.IScenePlusExtService;
 import com.fdkankan.contro.service.IScenePlusService;
 import com.fdkankan.web.response.ResultData;
@@ -29,7 +31,7 @@ import java.util.stream.Collectors;
  * 场景主表 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2022-03-16
  */
 @Slf4j
@@ -40,6 +42,8 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     private IScenePlusExtService scenePlusExtService;
     @Autowired
     private ICameraDetailService cameraDetailService;
+    @Autowired
+    private IJyUserService jyUserService;
 
     @Override
     public ScenePlus getScenePlusByNum(String num) {
@@ -140,4 +144,12 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         }
         return null;
     }
+
+    @Override
+    public String getRyIdByNum(String num) {
+        ScenePlus scenePlus = this.getScenePlusByNum(num);
+        Long userId = scenePlus.getUserId();
+        JyUser jyUser = jyUserService.getByUserId(userId);
+        return jyUser.getRyId();
+    }
 }