|
@@ -1,160 +0,0 @@
|
|
|
-package com.fdkankan.ucenter.service.impl;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.ucenter.common.CameraTypeEnum;
|
|
|
-import com.fdkankan.ucenter.common.Result;
|
|
|
-import com.fdkankan.ucenter.entity.Camera;
|
|
|
-import com.fdkankan.ucenter.entity.CameraDetail;
|
|
|
-import com.fdkankan.ucenter.entity.User;
|
|
|
-import com.fdkankan.ucenter.service.IUserService;
|
|
|
-import com.fdkankan.ucenter.vo.response.SceneNumVo;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class FdkkLaserService {
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- IUserService userService;
|
|
|
-
|
|
|
- @Value("${4dkk.laserService.basePath}")
|
|
|
- private String laserHost;
|
|
|
- private final String GET_LASER_SCENE_USER_URL="/laser/4dage/getSceneNum";
|
|
|
- private final String GET_LASER_SCENE_CNT_URL="/laser/4dage/scene/getSceneNumByCamera";
|
|
|
- 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 RestTemplate restTemplate = new RestTemplate();
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据用户获取激光相机数量
|
|
|
- * @param token
|
|
|
- */
|
|
|
- public SceneNumVo getLaserSceneNumByUser(String token) {
|
|
|
- SceneNumVo sceneNumVo = new SceneNumVo();
|
|
|
- try {
|
|
|
- String url = laserHost + GET_LASER_SCENE_USER_URL;
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.add("fdToken", token);
|
|
|
- HttpEntity<Object> formEntity = new HttpEntity<>( headers);
|
|
|
- log.info("获取激光转台相机场景数,url:{},fdToken:{}",GET_LASER_SCENE_USER_URL,token);
|
|
|
- ResponseEntity<Result> responseEntity = restTemplate.postForEntity(url,formEntity, Result.class);
|
|
|
- log.info("获取激光转台相机场景数,url:{},fdToken:{},结果:{}",url,token, JSONObject.toJSONString(responseEntity.getBody()));
|
|
|
- if(responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()){
|
|
|
- log.error("自研激光转台相机协作失败!");
|
|
|
- return sceneNumVo;
|
|
|
- }
|
|
|
- sceneNumVo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), SceneNumVo.class);
|
|
|
- sceneNumVo.setTotalNum(sceneNumVo.getSceneNum() + sceneNumVo.getCooperationSceneNum());
|
|
|
- }catch (Exception e){
|
|
|
- log.error("自研激光转台相机协作失败!",e);
|
|
|
- }
|
|
|
- return sceneNumVo ;
|
|
|
- }
|
|
|
-
|
|
|
- public Integer getLaserSceneNum(Map<String, String> params){
|
|
|
- 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 0;
|
|
|
- }
|
|
|
- return (Integer) responseEntity.getBody().getData();
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
- public Integer test(Map<String, String> params){
|
|
|
- try {
|
|
|
- String url ="http://192.168.0.38:8088/test";
|
|
|
- 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 0;
|
|
|
- }
|
|
|
- return (Integer) responseEntity.getBody().getData();
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- public void disableCooperation(HashMap<Long,CameraDetail> detailMap,HashMap<Long,Camera> cameraMap ){
|
|
|
- this.disableCooperation(getCooperationParam(detailMap,cameraMap,null));
|
|
|
- }
|
|
|
- public void enableCameraCooperation(HashMap<Long,CameraDetail> detailMap,HashMap<Long,Camera> cameraMap ,String username){
|
|
|
- this.enableCameraCooperation(getCooperationParam(detailMap,cameraMap,username));
|
|
|
- }
|
|
|
-
|
|
|
- public void disableCooperation(List<Map<String, String>> params) {
|
|
|
- if(params.size() <=0){
|
|
|
- return;
|
|
|
- }
|
|
|
- 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("激光场景状态同步失败!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public List<Map<String, String>> getCooperationParam(HashMap<Long,CameraDetail> detailMap,HashMap<Long,Camera> cameraMap ,String username){
|
|
|
- List<Map<String, String>> laserParams = new ArrayList<>();
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
- for (Long aLong : detailMap.keySet()) {
|
|
|
- if(detailMap.get(aLong).getCooperationUser()!=null){
|
|
|
- userIds.add(detailMap.get(aLong).getCooperationUser());
|
|
|
- }
|
|
|
- }
|
|
|
- if(userIds.size() >0){
|
|
|
- HashMap<Long, User> userMap = userService.getByIds(userIds);
|
|
|
- for (Long cameraId : detailMap.keySet()) {
|
|
|
- CameraDetail cameraDetail = detailMap.get(cameraId);
|
|
|
- if (cameraDetail.getType() == CameraTypeEnum.LASER_TURN.getType()) {
|
|
|
- Camera cameraEntity = cameraMap.get(cameraId);
|
|
|
- Map<String, String> param = new HashMap<>();
|
|
|
- param.put("snCode", cameraEntity.getSnCode());
|
|
|
- String name = userMap.get(cameraDetail.getCooperationUser()) == null ?null : userMap.get(cameraDetail.getCooperationUser()).getUserName();
|
|
|
- param.put("cooperationUserName", name);
|
|
|
- laserParams.add(param);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return laserParams;
|
|
|
- }
|
|
|
-
|
|
|
- public void enableCameraCooperation(List<Map<String, String>> params) {
|
|
|
- if(params.size() <=0){
|
|
|
- return;
|
|
|
- }
|
|
|
- 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("自研激光转台相机协作失败!");
|
|
|
- }
|
|
|
- }
|
|
|
-}
|