|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.ucenter.common.CameraTypeEnum;
|
|
|
import com.fdkankan.ucenter.common.Result;
|
|
|
+import com.fdkankan.ucenter.common.constants.NacosProperty;
|
|
|
import com.fdkankan.ucenter.common.utils.ShellUtil;
|
|
|
import com.fdkankan.ucenter.entity.Camera;
|
|
|
import com.fdkankan.ucenter.entity.CameraDetail;
|
|
@@ -36,8 +37,6 @@ import java.util.Map;
|
|
|
public class LaserService {
|
|
|
|
|
|
@Autowired
|
|
|
- private LaserClient laserClient;
|
|
|
- @Autowired
|
|
|
private IUserService userService;
|
|
|
@Autowired
|
|
|
ICameraService cameraService;
|
|
@@ -47,23 +46,10 @@ public class LaserService {
|
|
|
*/
|
|
|
public SceneNumVo getLaserSceneNumByUser(String token) {
|
|
|
SceneNumVo sceneNumVo = new SceneNumVo();
|
|
|
- try {
|
|
|
- Result sceneNum = laserClient.getSceneNum(token);
|
|
|
- if(sceneNum != null && sceneNum.getCode() == 200){
|
|
|
- sceneNumVo = JSONObject.parseObject(JSONObject.toJSONString(sceneNum.getData()), SceneNumVo.class);
|
|
|
- sceneNumVo.setTotalNum(sceneNumVo.getSceneNum() + sceneNumVo.getCooperationSceneNum());
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return sceneNumVo ;
|
|
|
+ return sceneNumVo;
|
|
|
}
|
|
|
|
|
|
public Integer getLaserSceneNum(Map<String, String> params){
|
|
|
- Result result = laserClient.getSceneNumByCamera(params);
|
|
|
- if(result.getCode() == 200 ){
|
|
|
- return (Integer) result.getData();
|
|
|
- }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -76,65 +62,22 @@ public class LaserService {
|
|
|
}
|
|
|
|
|
|
public void disableCooperation(List<Map<String, String>> params) {
|
|
|
- if(params.size() <=0){
|
|
|
- return;
|
|
|
- }
|
|
|
- laserClient.cooperationDisable(params);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, String>> getCooperationdDisableParam(HashMap<Long,CameraDetail> detailMap,HashMap<Long,Camera> cameraMap ){
|
|
|
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 List<Map<String, String>> getCooperationSaveParam(HashMap<Long,CameraDetail> detailMap,HashMap<Long,Camera> cameraMap ,String username){
|
|
|
List<Map<String, String>> laserParams = new ArrayList<>();
|
|
|
- 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());
|
|
|
- param.put("cooperationUserName", username);
|
|
|
- laserParams.add(param);
|
|
|
- }
|
|
|
- }
|
|
|
return laserParams;
|
|
|
}
|
|
|
|
|
|
public void enableCameraCooperation(List<Map<String, String>> params) {
|
|
|
- if(params.size() <=0){
|
|
|
- return;
|
|
|
- }
|
|
|
- laserClient.cooperationCameraSave(params);
|
|
|
}
|
|
|
|
|
|
public JSONObject getSceneByNum(String num) {
|
|
|
- Result result = laserClient.getSceneByNum(num);
|
|
|
- if(result.getCode() != HttpStatus.OK.value()){
|
|
|
- log.error("获取激光转台场景失败!");
|
|
|
- return null;
|
|
|
- }
|
|
|
- return JSONObject.parseObject(JSONObject.toJSONString(result.getData()));
|
|
|
+ return new JSONObject();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -168,49 +111,10 @@ public class LaserService {
|
|
|
|
|
|
public void copy(Long camaraId, String createTime, String newNum, Integer status,
|
|
|
String path, String sceneKey, String sceneName, Long userId,String version){
|
|
|
- String phone = null;
|
|
|
- String snCode = null;
|
|
|
- if(userId != null){
|
|
|
- User user = userService.getById(userId);
|
|
|
- phone = user == null ? null :user.getUserName();
|
|
|
- }
|
|
|
- if(camaraId != null){
|
|
|
- Camera camera = cameraService.getById(camaraId);
|
|
|
- snCode = camera == null ? null :camera.getSnCode();
|
|
|
- }
|
|
|
- Map<String,Object> params = new HashMap<>();
|
|
|
- params.put("childName",snCode);
|
|
|
- params.put("createTime", createTime);
|
|
|
- params.put("phone", phone);
|
|
|
- params.put("sceneCode", newNum);
|
|
|
- params.put("snCode",snCode);
|
|
|
- params.put("status", status);
|
|
|
- params.put("password", sceneKey);
|
|
|
- params.put("title", sceneName);
|
|
|
- params.put("userId", userId);
|
|
|
- params.put("isCopy", true);
|
|
|
- params.put("path",path);
|
|
|
- params.put("version",version);
|
|
|
- Result result = laserClient.saveOrEdit(newNum, params);
|
|
|
- if( result.getCode() != HttpStatus.OK.value()){
|
|
|
- log.error("激光场景状态同步失败!");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public List<SceneBySnCodeVo> getScenesBySnCode(String snCode, String token) {
|
|
|
List<SceneBySnCodeVo> sceneVo = new ArrayList<>();
|
|
|
- try {
|
|
|
- HashMap<String ,String> param = new HashMap<>();
|
|
|
- param.put("snCode",snCode);
|
|
|
- Result responseEntity = laserClient.getScenesBySnCode(param, token);
|
|
|
- if( responseEntity.getCode() != HttpStatus.OK.value()){
|
|
|
- log.error("根据snCode获取激光转台场景失败!");
|
|
|
- return sceneVo;
|
|
|
- }
|
|
|
- sceneVo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), List.class);
|
|
|
- }catch (Exception e){
|
|
|
- log.error("根据snCode获取激光转台场景失败!",e);
|
|
|
- }
|
|
|
return sceneVo ;
|
|
|
}
|
|
|
|