Browse Source

Merge remote-tracking branch 'origin/master'

dengsixing 2 years ago
parent
commit
18032be4f0

+ 6 - 0
src/main/java/com/fdkankan/ucenter/httpClient/client/LaserClient.java

@@ -39,4 +39,10 @@ public interface LaserClient {
 
     @Get("/laser/init/${0}")
     Result getSceneByNum(String num);
+
+    /**
+     * 新增场景
+     */
+    @Post("/laser/init/{sceneNum}/saveOrEdit")
+    Result saveOrEdit(@Var("sceneNum") String sceneNum, @JSONBody  Map<String,Object> params);
 }

+ 32 - 0
src/main/java/com/fdkankan/ucenter/httpClient/service/LaserService.java

@@ -7,6 +7,7 @@ import com.fdkankan.ucenter.entity.Camera;
 import com.fdkankan.ucenter.entity.CameraDetail;
 import com.fdkankan.ucenter.entity.User;
 import com.fdkankan.ucenter.httpClient.client.LaserClient;
+import com.fdkankan.ucenter.service.ICameraService;
 import com.fdkankan.ucenter.service.IUserService;
 import com.fdkankan.ucenter.vo.response.SceneNumVo;
 import lombok.extern.slf4j.Slf4j;
@@ -31,6 +32,8 @@ public class LaserService {
     private LaserClient laserClient;
     @Autowired
     private IUserService userService;
+    @Autowired
+    ICameraService cameraService;
     /**
      * 根据用户获取激光相机数量
      * @param token
@@ -112,4 +115,33 @@ public class LaserService {
         }
         return JSONObject.parseObject(JSONObject.toJSONString(result.getData()));
     }
+
+    public void copy(Long camaraId, String createTime, String newNum, Integer status, String sceneKey, String sceneName, Long userId){
+        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("copy", true);
+        Result result = laserClient.saveOrEdit(newNum, params);
+        if( result.getCode() != HttpStatus.OK.value()){
+            log.error("激光场景状态同步失败!");
+        }
+    }
+
 }

+ 7 - 0
src/main/java/com/fdkankan/ucenter/service/impl/ScenePlusServiceImpl.java

@@ -15,6 +15,7 @@ import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.ucenter.bean.SceneJsonBean;
 import com.fdkankan.ucenter.entity.*;
+import com.fdkankan.ucenter.httpClient.service.LaserService;
 import com.fdkankan.ucenter.mapper.IScenePlusMapper;
 import com.fdkankan.ucenter.service.*;
 
@@ -63,6 +64,8 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     FYunFileServiceInterface fYunFileServiceInterface;
     @Autowired
     RedisUtil redisUtil;
+    @Autowired
+    LaserService laserService;
 
     @Value("${main.url}")
     private String mainUrl;
@@ -268,6 +271,10 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                 scenePlus.setSceneStatus(-2);
                 this.updateById(scenePlus);
                 log.info("复制场景结束-{}", new Date());
+                if(scenePlus.getSceneSource() == 4){  //深时复制
+                    laserService.copy(scenePlus.getCameraId(),scenePlus.getCreateTime(),newNum,scenePlus.getSceneStatus(),
+                            sceneEditInfo.getScenePassword(),scenePlus.getTitle(),scenePlus.getUserId());
+                }
             }catch (Exception e){
                 this.removeById(scenePlus.getId());
                 log.error("复制场景异常", e);

+ 6 - 2
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -97,12 +97,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     private ISceneEditInfoService sceneEditInfoService;
     @Autowired
     private RedisUtil redisUtil;
-
     @Resource
     private ISceneUpgradeMapper sceneUpgradeMapper;
-
     @Autowired
     private IInnerService innerService;
+    @Autowired
+    LaserService laserService;
 
     @Value("${main.url}")
     private String mainUrl;
@@ -647,6 +647,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 oldScene.setStatus(-2);
                 this.updateById(oldScene);
                 log.info("复制场景结束-{}", new Date());
+                if(oldScene.getSceneSource() == 4){  //深时复制
+                    laserService.copy(oldScene.getCameraId(),oldScene.getCreateTime(),newNum,oldScene.getStatus(),
+                            oldEditScene.getSceneKey(),oldScene.getSceneName(),oldScene.getUserId());
+                }
             } catch (Exception e) {
                 this.removeById(oldScene.getId());
                 log.error("复制场景异常", e);