Kaynağa Gözat

Merge remote-tracking branch 'origin/hotfix-调整log4j包版本及激光系统转Mq实现' into release

tianboguang 2 yıl önce
ebeveyn
işleme
7fa96a7a1b

+ 12 - 0
pom.xml

@@ -176,6 +176,18 @@
       <version>1.5.0</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-to-slf4j</artifactId>
+      <version>2.17.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <version>2.17.0</version>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>

+ 4 - 3
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -326,7 +326,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){
-            e.printStackTrace();
+            log.error("场景计算结果处理出错!", e);
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
         }
     }
@@ -452,8 +452,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
 
         log.info("数据转换完成:" + projectNum);
-
-        FileUtil.touch("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
+        if(!new File("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum).exists()){
+            FileUtil.mkdir("/mnt/4Dkankan/scene/data" + File.separator + "data" + projectNum);
+        }
         map.put(resultsPath + "floorplan.json", dataViewPath + "floor.json");
         map.put(resultsPath + "floorplan_cad.json", dataViewPath + "floorplan_cad.json");
         map.put(path + File.separator + "capture/stitch_params.txt", dataViewPath + "stitch_params.txt");

+ 1 - 1
src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java

@@ -274,7 +274,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             }
 
         }catch (Exception e){
-            e.printStackTrace();
+            log.error("场景计算结果处理出错!", e);
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
         }
     }

+ 1 - 1
src/main/java/com/fdkankan/contro/schedule/ScheduleJob.java

@@ -36,7 +36,7 @@ public class ScheduleJob {
                 log.info(scalingService.createEcs());
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("弹性升缩开启失败!", e);
             log.error(e.getMessage());
         }
     }

+ 15 - 41
src/main/java/com/fdkankan/contro/service/impl/IFdkkLaserServiceImpl.java

@@ -9,15 +9,12 @@ import com.fdkankan.contro.entity.ScenePro;
 import com.fdkankan.contro.service.IFdkkLaserService;
 import com.fdkankan.contro.service.IScenePlusService;
 import com.fdkankan.contro.service.ISceneProService;
-import com.fdkankan.web.response.Result;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
-import org.springframework.web.client.RestTemplate;
 
 import java.io.File;
 import java.util.Date;
@@ -28,23 +25,23 @@ import java.util.Map;
 @Slf4j
 public class IFdkkLaserServiceImpl implements IFdkkLaserService {
 
-    private final String SAVE_SCENE_URL_TEMPLATE = "/laser/init/%s/saveOrEdit";
-    private final String EDIT_LASER_BUILD_STATUS_URL = "/laser/4dage/scene/editBuildStatus";
-    private final String ENABLE_COOPERATION_CAMERA_URL = "/laser/4dage/scene/cooperation/cameraSave";
-
-    @Value("${4dkk.laserService.host}")
-    private String laserHost;
-
-    private RestTemplate restTemplate = new RestTemplate();
-
     @Autowired
     private ISceneProService sceneProService;
 
     @Autowired
     private IScenePlusService scenePlusService;
 
+    @Autowired
+    private RabbitMqProducer rabbitMqProducer;
+
+    @Value("${queue.application.laser.update-scene}")
+    private String updateScene;
+
+    @Value("${queue.application.laser.update-build-status}")
+    private String updateBuildStatus;
+
+
     public void updateSceneStatus(String sceneCode, int sceneStatus, String path, Date createTime) {
-        String url = laserHost + String.format(SAVE_SCENE_URL_TEMPLATE, sceneCode);
         Map<String, Object> params = new HashMap<>();
         params.put("sceneCode", sceneCode);
         params.put("status", sceneStatus);
@@ -53,12 +50,7 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
         if (!ObjectUtils.isEmpty(path)) {
             params.put("path", path);
         }
-        log.info("自研激光转台相机同步,url:{},params:{}", url, JSONObject.toJSONString(params));
-        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
-        log.info("自研激光转台相机同步,url:{},params:{},结果:{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("激光场景状态同步失败!");
-        }
+        rabbitMqProducer.sendByWorkQueue(updateScene, params);
     }
 
     public void syncBuildResult(String sceneNum, String dataSource,Date createTime) {
@@ -97,21 +89,14 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
 
     @Override
     public void pushBuildStatusToLaserSystem(String projectNum, String laserObjFilePath) {
-        String url = laserHost + EDIT_LASER_BUILD_STATUS_URL;
         Map<String, String> params = new HashMap<>();
         params.put("sceneCode", projectNum);
         params.put("objPath", laserObjFilePath);
-        log.info("激光系统同步BuildStatus,url:{},params:{}", ENABLE_COOPERATION_CAMERA_URL, JSONObject.toJSONString(params));
-        ResponseEntity<com.fdkankan.contro.common.Result> responseEntity = restTemplate.postForEntity(url, params, com.fdkankan.contro.common.Result.class);
-        log.info("激光系统同步BuildStatus,url:{},params:{},结果:{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("激光系统同步BuildStatus");
-        }
+        rabbitMqProducer.sendByWorkQueue(updateBuildStatus, params);
     }
 
 
     public void saveScene(ScenePlus scenePlus, String scenePassword, Camera cameraEntity, String phone, boolean rebuild) {
-        String url = laserHost + String.format(SAVE_SCENE_URL_TEMPLATE, scenePlus.getNum());
         Map<String, Object> params = new HashMap<>();
         params.put("childName", cameraEntity.getChildName());
         params.put("createTime", DateUtil.date2String(scenePlus.getCreateTime(), null));
@@ -127,16 +112,10 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
         params.put("version",getSceneVersion(scenePlus.getNum()));
         params.put("title", scenePlus.getTitle());
         params.put("userId", scenePlus.getUserId());
-        log.info("自研激光转台相机同步,url:{},params:{}", url, JSONObject.toJSONString(params));
-        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
-        log.info("自研激光转台相机同步,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("激光场景状态同步失败!");
-        }
+        rabbitMqProducer.sendByWorkQueue(updateScene, params);
     }
 
     public void saveScene(ScenePro scenePro, String scenePassword, Camera cameraEntity, String phone, boolean rebuild) {
-        String url = laserHost + String.format(SAVE_SCENE_URL_TEMPLATE, scenePro.getNum());
         Map<String, Object> params = new HashMap<>();
         params.put("childName", cameraEntity.getChildName());
         if(ObjectUtils.isEmpty(scenePro.getCreateTime())){
@@ -155,12 +134,7 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
         params.put("version",getSceneVersion(scenePro.getNum()));
         params.put("title", scenePro.getSceneName());
         params.put("userId", scenePro.getUserId());
-        log.info("自研激光转台相机同步,url:{},params:{}", url, JSONObject.toJSONString(params));
-        ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url, params, Result.class);
-        log.info("自研激光转台相机同步,url:{},params:{},结果,{}", url, JSONObject.toJSONString(params), JSONObject.toJSONString(responseEntity.getBody()));
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("激光场景状态同步失败!");
-        }
+        rabbitMqProducer.sendByWorkQueue(updateScene, params);
     }
 
     private String getSceneVersion(String num) {

+ 2 - 3
src/main/java/com/fdkankan/contro/service/impl/Scene3dNumServiceImpl.java

@@ -86,7 +86,7 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
             try {
                 Thread.sleep(2000);
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                log.error("场景码加载缓存失败", e);
             }
         }
         sceneNum = redisUtil.lLeftPop(RedisKey.FDKANKAN_SCENE_NUMS);
@@ -129,8 +129,7 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
                 try{
                     this.saveBatch(scene3dNumList);
                 }catch (Exception e){
-                    log.error("场景码插入异常!");
-                    e.printStackTrace();
+                    log.error("场景码插入异常!",e);
                 }
             }
         }finally {