ソースを参照

Merge branch 'fusion-v1.4.0'

lyhzzz 2 年 前
コミット
c80d148a4a

+ 39 - 4
src/main/java/com/fdkankan/ucenter/controller/fire/FdUserSceneController.java

@@ -4,18 +4,22 @@ import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.JwtUtil;
 import com.fdkankan.ucenter.common.BaseController;
 import com.fdkankan.ucenter.common.Result;
+import com.fdkankan.ucenter.common.ResultData;
+import com.fdkankan.ucenter.constant.LoginConstant;
+import com.fdkankan.ucenter.entity.ScenePlus;
+import com.fdkankan.ucenter.entity.ScenePro;
+import com.fdkankan.ucenter.entity.User;
+import com.fdkankan.ucenter.service.IScenePlusService;
 import com.fdkankan.ucenter.service.ISceneProService;
 import com.fdkankan.ucenter.service.ISceneService;
 import com.fdkankan.ucenter.service.IUserService;
+import com.fdkankan.ucenter.service.impl.LoginService;
 import com.fdkankan.ucenter.vo.ResponseScene;
 import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -28,6 +32,12 @@ public class FdUserSceneController extends BaseController {
 
     @Autowired
     private ISceneProService sceneProService;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private LoginService loginService;
+    @Autowired
+    private IUserService userService;
 
     /**
      * 获取场景详情
@@ -48,4 +58,29 @@ public class FdUserSceneController extends BaseController {
         log.info("火调返回数据:{}",sceneDetailList);
         return Result.success(sceneDetailList);
     }
+
+    @GetMapping("/getTokenByNum")
+    public ResultData getTokenByNum(@RequestParam(required = false) String num ){
+        if(StringUtils.isEmpty(num)){
+            throw new BusinessException(-1,"参数为空");
+        }
+        Long userId = null;
+        ScenePlus scenePlus = scenePlusService.getByNum(num);
+        if(scenePlus != null){
+            userId = scenePlus.getUserId();
+        }else {
+            ScenePro scenePro = sceneProService.getByNum(num);
+            if(scenePro != null){
+                userId = scenePro.getUserId();
+            }
+        }
+        if(userId == null){
+            throw new BusinessException(-1,"场景为空");
+        }
+        User user = userService.getById(userId);
+        if(user == null){
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
+        }
+        return ResultData.ok(loginService.login(user));
+    }
 }

+ 2 - 0
src/main/java/com/fdkankan/ucenter/service/IFolderSceneService.java

@@ -26,4 +26,6 @@ public interface IFolderSceneService extends IService<FolderScene> {
     Long getCountByFolderAndSon(Long folderId);
 
     void delBySceneId(List<Long> proIds);
+
+    void delByCameraIds(List<Long> cameraIds);
 }

+ 29 - 0
src/main/java/com/fdkankan/ucenter/service/impl/CameraDetailServiceImpl.java

@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -49,6 +50,8 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
     IUserIncrementService userIncrementService;
     @Autowired
     IIncrementTypeService incrementTypeService;
+    @Autowired
+    IFolderSceneService folderSceneService;
 
     @Override
     public CameraDetail getByCameraId(Long cameraId) {
@@ -126,6 +129,23 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
         List<ScenePlus> scenePlusList = scenePlusService.getListByCameraIds(cameraIds);
         sceneCooperationService.deleteCooperationList(sceneProList,scenePlusList);
         fdkkLaserService.disableCooperation(detailMap, cameraMap);
+        //解绑删除相机。文件夹与场景绑定关系
+        List<Long > sceneIds = new ArrayList<>();
+        if(sceneProList.size() >0){
+            List<Long> proIds = sceneProList.stream().map(ScenePro::getId).collect(Collectors.toList());
+            if(proIds.size() >0){
+                sceneIds.addAll(proIds);
+            }
+        }
+        if(scenePlusList.size() >0){
+            List<Long> plusIds = scenePlusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
+            if(plusIds.size() >0){
+                sceneIds.addAll(plusIds);
+            }
+        }
+        if(sceneIds.size() >0){
+            folderSceneService.delBySceneId(sceneIds);
+        }
     }
 
     @Override
@@ -258,11 +278,17 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
         if(cameraDetail == null){
             return false;
         }
+        if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11){
+            return true;
+        }
         return checkSpace(cameraDetail,space);
     }
 
     @Override
     public Boolean checkSpace(CameraDetail detailEntity, Long space) {
+        if(detailEntity.getType() == 10 || detailEntity.getType() == 11){
+            return true;
+        }
         UserIncrement userIncrement = userIncrementService.getByCameraId(detailEntity.getCameraId());
         if(userIncrement == null || userIncrement.getIsExpired() == 1){
             return checkSpace(detailEntity,null,space);
@@ -274,6 +300,9 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
     @Override
     public Boolean checkSpace(CameraDetail detailEntity, IncrementType incrementType, Long space) {
         Long totalSpace = 0L;
+        if(detailEntity.getType() == 10 || detailEntity.getType() == 11){
+            return true;
+        }
         if("SP".equals(detailEntity.getUnit())){
             if(incrementType!=null && incrementType.getCameraSpace() == -1){
                 return true;

+ 29 - 4
src/main/java/com/fdkankan/ucenter/service/impl/FolderSceneServiceImpl.java

@@ -3,12 +3,11 @@ package com.fdkankan.ucenter.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.ucenter.entity.Folder;
 import com.fdkankan.ucenter.entity.FolderScene;
+import com.fdkankan.ucenter.entity.ScenePlus;
+import com.fdkankan.ucenter.entity.ScenePro;
 import com.fdkankan.ucenter.mapper.IFolderSceneMapper;
-import com.fdkankan.ucenter.service.IFolderSceneService;
+import com.fdkankan.ucenter.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fdkankan.ucenter.service.IFolderService;
-import com.fdkankan.ucenter.service.ISceneProService;
-import com.fdkankan.ucenter.service.ISceneService;
 import com.fdkankan.ucenter.vo.response.GroupByCount;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -32,6 +31,8 @@ public class FolderSceneServiceImpl extends ServiceImpl<IFolderSceneMapper, Fold
     @Autowired
     private ISceneProService sceneProService;
     @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
     private IFolderService folderService;
 
     @Override
@@ -111,4 +112,28 @@ public class FolderSceneServiceImpl extends ServiceImpl<IFolderSceneMapper, Fold
             this.remove(wrapper);
         }
     }
+
+    @Override
+    public void delByCameraIds(List<Long> cameraIds) {
+        if(cameraIds.size() >0){
+            List<ScenePro> proList = sceneProService.getListByCameraIds(cameraIds);
+            List<ScenePlus> plusList = scenePlusService.getListByCameraIds(cameraIds);
+            List<Long > sceneIds = new ArrayList<>();
+            if(proList.size() >0){
+                List<Long> proIds = proList.stream().map(ScenePro::getId).collect(Collectors.toList());
+                if(proIds.size() >0){
+                    sceneIds.addAll(proIds);
+                }
+            }
+            if(plusList.size() >0){
+                List<Long> plusIds = plusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
+                if(plusIds.size() >0){
+                    sceneIds.addAll(plusIds);
+                }
+            }
+            if(sceneIds.size() >0){
+                this.delBySceneId(sceneIds);
+            }
+        }
+    }
 }

+ 15 - 9
src/main/java/com/fdkankan/ucenter/service/impl/LoginService.java

@@ -65,6 +65,17 @@ public class LoginService {
     private IMailTemplateService mailTemplateService;
 
 
+    public LoginVo login(User user){
+        String token = this.redisLogin(user.getUserName(),JSONObject.toJSONString(user),"user");
+        loginLogService.addLog("",token);
+        UserVo userVo = new UserVo();
+        BeanUtils.copyProperties(user,userVo);
+        LoginVo vo = new LoginVo();
+        vo.setToken(token);
+        vo.setUser(userVo);
+        return vo;
+    }
+
     public LoginVo login(LoginParam param) {
         if (StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getPhoneNum())){
             throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
@@ -83,14 +94,7 @@ public class LoginService {
         if(!user.getPassword().equals(passwordCode)){
             throw new BusinessException(LoginConstant.FAILURE_CODE_3014, LoginConstant.FAILURE_MSG_3014);
         }
-        String token = this.redisLogin(user.getUserName(),JSONObject.toJSONString(user),"user");
-        loginLogService.addLog("",token);
-        UserVo userVo = new UserVo();
-        BeanUtils.copyProperties(user,userVo);
-        LoginVo vo = new LoginVo();
-        vo.setToken(token);
-        vo.setUser(userVo);
-        return vo;
+        return login(user);
     }
 
     public void logout(String token) {
@@ -287,7 +291,9 @@ public class LoginService {
         if(user == null){
             throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
         }
-        checkSms(param.getMsgAuthCode(),param.getPhoneNum(),true);
+        if(!param.getMsgAuthCode().equals(registerValidCode)){
+            checkSms(param.getMsgAuthCode(),param.getPhoneNum(),true);
+        }
         String pwdMd5 = SecurityUtil.MD5(password);
         userService.updatePassword(param.getPhoneNum(), pwdMd5);
     }