|
@@ -1,130 +0,0 @@
|
|
|
-package com.fdkankan.manage.service.impl;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.constant.HttpCode;
|
|
|
-import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.manage.service.IFdkkLaserService;
|
|
|
-import lombok.Data;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-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.web.client.RestTemplate;
|
|
|
-
|
|
|
-import java.io.Serializable;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class IFdkkLaserServiceImpl implements IFdkkLaserService {
|
|
|
-
|
|
|
- private final String UPDATE_SCENE_STATUS_URL_TEMPLATE="/indoor/%s/scene/useStatus/%s";
|
|
|
- private final String DISABLE_COOPERATION_SCENE_URL="/laser/4dage/scene/cooperation/disable";
|
|
|
- private final String ENABLE_COOPERATION_CAMERA_URL="/laser/4dage/scene/cooperation/cameraSave";
|
|
|
- private final String GET_LASER_SCENE_USER_URL="/laser/4dage/getSceneNum";
|
|
|
- private final String GET_LASER_SCENE_CODE_URL="/laser/4dage/scene/getScenesBySnCode";
|
|
|
- private final String GET_LASER_SCENE_CNT_URL="/laser/4dage/scene/getSceneNumByCamera";
|
|
|
-
|
|
|
- @Value("${4dkk.laserService.host:https://uat-laser.4dkankan.com}")
|
|
|
- private String laserHost;
|
|
|
-
|
|
|
- private RestTemplate restTemplate = new RestTemplate();
|
|
|
-
|
|
|
- public void updateSceneStatus(String sceneCode,int status){
|
|
|
- String url = laserHost + String.format(UPDATE_SCENE_STATUS_URL_TEMPLATE,sceneCode,status);
|
|
|
- ResponseEntity<Result> response = restTemplate.getForEntity(url, Result.class);
|
|
|
- if(response.getStatusCode() != HttpStatus.OK){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7001);
|
|
|
- }
|
|
|
- if(response.getBody().getCode() != HttpCode.SC_SUCCESS){
|
|
|
- throw new BusinessException(response.getBody().getCode(), response.getBody().getMsg());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 自研激光转台取消协作
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void disableCooperation(String snCode, String cooperationUserName) {
|
|
|
- List<Map<String,String>> params = new ArrayList<>();
|
|
|
- Map<String,String> param = new HashMap<>();
|
|
|
- param.put("snCode",snCode);
|
|
|
- param.put("cooperationUserName",cooperationUserName);
|
|
|
- params.add(param);
|
|
|
-
|
|
|
- String url = laserHost + DISABLE_COOPERATION_SCENE_URL;
|
|
|
- log.info("自研激光转台取消协作,url:{},params:{}",DISABLE_COOPERATION_SCENE_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("激光场景状态同步失败!");
|
|
|
- }
|
|
|
- }
|
|
|
- /**
|
|
|
- * 自研激光转台添加协作
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void enableCameraCooperation(String snCode, String cooperationUserName) {
|
|
|
- List<Map<String,String>> params = new ArrayList<>();
|
|
|
- Map<String,String> param = new HashMap<>();
|
|
|
- param.put("snCode",snCode);
|
|
|
- param.put("cooperationUserName",cooperationUserName);
|
|
|
- params.add(param);
|
|
|
-
|
|
|
- String url = laserHost + ENABLE_COOPERATION_CAMERA_URL;
|
|
|
- log.info("自研激光转台相机协作,url:{},params:{}",ENABLE_COOPERATION_CAMERA_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("自研激光转台相机协作失败!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据 snCode 获取激光场景场景数量
|
|
|
- */
|
|
|
- public Integer getLaserSceneNum(String snCode){
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- params.put("snCode",snCode);
|
|
|
- try {
|
|
|
- String url = laserHost + GET_LASER_SCENE_CNT_URL;
|
|
|
- log.info("获取激光转台相机场景数,url:{},params:{}",GET_LASER_SCENE_CNT_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("自研激光转台相机协作失败!");
|
|
|
- }
|
|
|
- return (Integer) responseEntity.getBody().getData();
|
|
|
- }catch (Exception e){
|
|
|
- log.error("自研激光转台相机协作失败!",e);
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- @Data
|
|
|
- public static class Result<T> implements Serializable {
|
|
|
- private static final long serialVersionUID = -1491499610244557029L;
|
|
|
- public static final String SUCCESS_MSG = "操作成功";
|
|
|
- public static int CODE_SUCCESS = 0;
|
|
|
- public static int CODE_FAILURE = -1;
|
|
|
- public static String[] NOOP = new String[]{};
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理状态:0: 成功, 1: 失败
|
|
|
- */
|
|
|
- private int code;
|
|
|
- /**
|
|
|
- * 消息
|
|
|
- */
|
|
|
- private String msg;
|
|
|
- /**
|
|
|
- * 返回数据
|
|
|
- */
|
|
|
- private T data;
|
|
|
- }
|
|
|
-}
|