Ver código fonte

http://192.168.0.21/index.php?m=task&f=view&taskID=21619
请求激光系统改为请求Mq

tianboguang 2 anos atrás
pai
commit
c80ca91ead

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

@@ -9,12 +9,10 @@ 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;
@@ -28,13 +26,6 @@ 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
@@ -43,8 +34,17 @@ public class IFdkkLaserServiceImpl implements IFdkkLaserService {
     @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 +53,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 +92,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 +115,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 +137,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) {