|
@@ -5,17 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
|
import com.fdkankan.manage.entity.AuthPage;
|
|
import com.fdkankan.manage.entity.AuthPage;
|
|
|
|
|
+import com.fdkankan.manage.entity.CameraType;
|
|
|
import com.fdkankan.manage.entity.JyPlatform;
|
|
import com.fdkankan.manage.entity.JyPlatform;
|
|
|
import com.fdkankan.manage.entity.JyUser;
|
|
import com.fdkankan.manage.entity.JyUser;
|
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
|
import com.fdkankan.manage.mapper.IAuthPageMapper;
|
|
import com.fdkankan.manage.mapper.IAuthPageMapper;
|
|
|
-import com.fdkankan.manage.service.IAuthPageService;
|
|
|
|
|
|
|
+import com.fdkankan.manage.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.manage.service.IJyPlatformService;
|
|
|
|
|
-import com.fdkankan.manage.service.IJyUserService;
|
|
|
|
|
-import com.fdkankan.manage.service.ISysRoleService;
|
|
|
|
|
import com.fdkankan.manage.vo.AuthPageVo;
|
|
import com.fdkankan.manage.vo.AuthPageVo;
|
|
|
import com.fdkankan.manage.vo.request.PageDataAuth;
|
|
import com.fdkankan.manage.vo.request.PageDataAuth;
|
|
|
|
|
+import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
|
|
+import com.fdkankan.manage.vo.response.GroupByCountVo;
|
|
|
|
|
+import com.fdkankan.manage.vo.response.GroupByList;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -40,6 +41,10 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
|
|
|
IJyPlatformService platformService;
|
|
IJyPlatformService platformService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ISysRoleService sysRoleService;
|
|
ISysRoleService sysRoleService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IDataService dataService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICameraTypeService cameraTypeService;
|
|
|
@Override
|
|
@Override
|
|
|
public void setAuth(PageDataAuth param) {
|
|
public void setAuth(PageDataAuth param) {
|
|
|
if(param.getJyId() == null ){
|
|
if(param.getJyId() == null ){
|
|
@@ -50,6 +55,13 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
|
|
|
throw new BusinessException(ResultCode.USERNAME_ERROR);
|
|
throw new BusinessException(ResultCode.USERNAME_ERROR);
|
|
|
}
|
|
}
|
|
|
JyUser loginUser = jyUserService.getLoginUser();
|
|
JyUser loginUser = jyUserService.getLoginUser();
|
|
|
|
|
+ if(jyUser.getId().equals(loginUser.getId())){
|
|
|
|
|
+ throw new BusinessException(ResultCode.PAGE_AUTH_ERROR);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<AuthPage> byJyUserId = this.getByJyUserIdAndPlatformId(jyUser.getId(),loginUser.getPlatformId());
|
|
|
|
|
+ if(byJyUserId != null && !byJyUserId.isEmpty()){
|
|
|
|
|
+ throw new BusinessException(ResultCode.PAGE_AUTH_ERROR2);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
AuthPage authPage = new AuthPage();
|
|
AuthPage authPage = new AuthPage();
|
|
|
authPage.setJyId(param.getJyId() );
|
|
authPage.setJyId(param.getJyId() );
|
|
@@ -59,6 +71,13 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
|
|
|
this.save(authPage);
|
|
this.save(authPage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<AuthPage> getByJyUserIdAndPlatformId(Integer jyId,Integer platformId) {
|
|
|
|
|
+ LambdaQueryWrapper<AuthPage> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(AuthPage::getJyId,jyId);
|
|
|
|
|
+ wrapper.eq(AuthPage::getCreaterPlatformId,platformId);
|
|
|
|
|
+ return this.list(wrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void delAuth(AuthPageVo param) {
|
|
public void delAuth(AuthPageVo param) {
|
|
|
if(param.getId() == null){
|
|
if(param.getId() == null){
|
|
@@ -76,8 +95,25 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
|
|
|
return this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
|
|
return this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ISceneProService sceneProService;
|
|
|
@Override
|
|
@Override
|
|
|
- public List<JyPlatform> platformList() {
|
|
|
|
|
|
|
+ public List<JyPlatform> platformList(Integer sceneType) {
|
|
|
|
|
+ if(sceneType != null && sceneType == 0){
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sceneType != null && sceneType == 1){
|
|
|
|
|
+ List<GroupByList> platform = sceneProService.selectMeshGroup("platform",1);
|
|
|
|
|
+ List<Integer> collect = platform.stream().map(GroupByList::getId).collect(Collectors.toList());
|
|
|
|
|
+ if(collect.isEmpty()){
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ return platformService.listByIds(collect);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sceneType != null && sceneType == 2){
|
|
|
|
|
+ return platformService.list();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
JyUser loginUser = jyUserService.getLoginUser();
|
|
JyUser loginUser = jyUserService.getLoginUser();
|
|
|
if(sysRoleService.isSuperAdmin()){
|
|
if(sysRoleService.isSuperAdmin()){
|
|
|
List<JyPlatform> list = platformService.list();
|
|
List<JyPlatform> list = platformService.list();
|
|
@@ -88,23 +124,58 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
|
|
|
}
|
|
}
|
|
|
List<AuthPage> authPages = this.getByJyUserId(loginUser.getId());
|
|
List<AuthPage> authPages = this.getByJyUserId(loginUser.getId());
|
|
|
List<Integer> platformIds = authPages.stream().map(AuthPage::getCreaterPlatformId).collect(Collectors.toList());
|
|
List<Integer> platformIds = authPages.stream().map(AuthPage::getCreaterPlatformId).collect(Collectors.toList());
|
|
|
- if(loginUser.getPlatformId() != null){
|
|
|
|
|
- platformIds.add(loginUser.getPlatformId());
|
|
|
|
|
- }
|
|
|
|
|
- if(platformIds!= null && !platformIds.isEmpty()){
|
|
|
|
|
|
|
+ if(!platformIds.isEmpty()){
|
|
|
|
|
+ List<JyPlatform> reList = new ArrayList<>();
|
|
|
List<JyPlatform> jyPlatforms = platformService.listByIds(platformIds);
|
|
List<JyPlatform> jyPlatforms = platformService.listByIds(platformIds);
|
|
|
for (JyPlatform jyPlatform : jyPlatforms) {
|
|
for (JyPlatform jyPlatform : jyPlatforms) {
|
|
|
- if(platformIds.contains(jyPlatform.getId())){
|
|
|
|
|
- jyPlatform.setPageAuth("admin");
|
|
|
|
|
-
|
|
|
|
|
|
|
+ jyPlatform.setPageAuth("admin");
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean flag = sysRoleService.isAdmin();
|
|
|
|
|
+ if(loginUser.getPlatformId() != null){
|
|
|
|
|
+ JyPlatform loginPlatfrom = platformService.getById(loginUser.getPlatformId());
|
|
|
|
|
+ if(!platformIds.contains(loginUser.getPlatformId())){
|
|
|
|
|
+ if (flag){
|
|
|
|
|
+ loginPlatfrom.setPageAuth("admin");
|
|
|
|
|
+ }
|
|
|
|
|
+ reList.add(loginPlatfrom);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return jyPlatforms;
|
|
|
|
|
|
|
+ reList.addAll(jyPlatforms);
|
|
|
|
|
+ return reList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<GroupByList> cameraList(Integer sceneType) {
|
|
|
|
|
+ if(sceneType != null && (sceneType == 0 || sceneType == 1)){
|
|
|
|
|
+ return sceneProService.selectMeshGroup("camera",sceneType);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sceneType != null && sceneType == 2 ){
|
|
|
|
|
+ List<GroupByCount> list = dataService.cameraGroupByPlatformId(new ArrayList<>());
|
|
|
|
|
+ return getCameraGroupList(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<JyPlatform> jyPlatforms = this.platformList(sceneType);
|
|
|
|
|
+ if(jyPlatforms == null || jyPlatforms.isEmpty()){
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Integer> platformIds = jyPlatforms.stream().map(JyPlatform::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<GroupByCount> list = dataService.cameraGroupByPlatformId(platformIds);
|
|
|
|
|
+ return getCameraGroupList(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<GroupByList> getCameraGroupList(List<GroupByCount> list){
|
|
|
|
|
+ List<Long> ids = list.stream().filter(e -> e.getId() != null && e.getCount() != null && e.getCount() >0).map(GroupByCount::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<GroupByList> groupByLists = new ArrayList<>();
|
|
|
|
|
+ List<CameraType> cameraTypes = cameraTypeService.listByTypes(ids);
|
|
|
|
|
+ for (CameraType cameraType : cameraTypes) {
|
|
|
|
|
+ groupByLists.add(new GroupByList(cameraType.getCameraType(),cameraType.getRemark()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return groupByLists;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private List<AuthPage> getByJyUserId(Integer jyId) {
|
|
private List<AuthPage> getByJyUserId(Integer jyId) {
|
|
|
LambdaQueryWrapper<AuthPage> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<AuthPage> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(AuthPage::getJyId,jyId);
|
|
wrapper.eq(AuthPage::getJyId,jyId);
|