|
@@ -0,0 +1,79 @@
|
|
|
|
+package com.fdkankan.ucenter.service.impl;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.common.response.PageInfo;
|
|
|
|
+import com.fdkankan.ucenter.constant.LoginConstant;
|
|
|
|
+import com.fdkankan.ucenter.entity.Camera;
|
|
|
|
+import com.fdkankan.ucenter.entity.ScenePlus;
|
|
|
|
+import com.fdkankan.ucenter.entity.ScenePlusExt;
|
|
|
|
+import com.fdkankan.ucenter.entity.User;
|
|
|
|
+import com.fdkankan.ucenter.service.*;
|
|
|
|
+import com.fdkankan.ucenter.vo.request.SceneParam;
|
|
|
|
+import com.fdkankan.ucenter.vo.response.ScenePlusVo;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class FusionService implements IFusionService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ IScenePlusService scenePlusService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IScenePlusExtService scenePlusExtService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IUserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICameraService cameraService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public PageInfo scenePageList(SceneParam param, String token) {
|
|
|
|
+ User user = userService.getByToken(token);
|
|
|
|
+ if(user == null){
|
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3015,LoginConstant.FAILURE_MSG_3015);
|
|
|
|
+ }
|
|
|
|
+ List<Integer> resourceList = new ArrayList<>();
|
|
|
|
+ if(param.getType() == 0){
|
|
|
|
+ resourceList = Arrays.asList(1,2,12,13,14);
|
|
|
|
+ }else if(param.getType() == 1){
|
|
|
|
+ resourceList = Collections.singletonList(3);
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(ScenePlus::getUserId,user.getId());
|
|
|
|
+ wrapper.in(ScenePlus::getSceneSource,resourceList);
|
|
|
|
+ if(StringUtils.isNotBlank(param.getSceneName())){
|
|
|
|
+ wrapper.like(ScenePlus::getTitle,param.getSceneName());
|
|
|
|
+ }
|
|
|
|
+ if(param.getNumList()!= null && param.getNumList().size() >0){
|
|
|
|
+ wrapper.in(ScenePlus::getNum, param.getNumList());
|
|
|
|
+ }
|
|
|
|
+ Page<ScenePlus> page = scenePlusService.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
|
+ if(page.getTotal() <=0){
|
|
|
|
+ return PageInfo.PageInfo(page);
|
|
|
|
+ }
|
|
|
|
+ List<Long> plusIds = page.getRecords().parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
|
+ List<Long> cameraIds = page.getRecords().parallelStream().map(ScenePlus::getCameraId).collect(Collectors.toList());
|
|
|
|
+ List<ScenePlusVo> list = new ArrayList<>();
|
|
|
|
+ HashMap<Long, ScenePlusExt> extMap = scenePlusExtService.getByPlusIds(plusIds);
|
|
|
|
+ HashMap<Long, Camera> cameraMap = cameraService.getByIds(cameraIds);
|
|
|
|
+ for (ScenePlus record : page.getRecords()) {
|
|
|
|
+ ScenePlusVo scenePlusVo = new ScenePlusVo();
|
|
|
|
+ String snCode = cameraMap.get(scenePlusVo.getCameraId()) == null ? "" :cameraMap.get(scenePlusVo.getCameraId()).getSnCode();
|
|
|
|
+ BeanUtils.copyProperties(record,scenePlusVo);
|
|
|
|
+ scenePlusVo.setPlusExt(extMap.get(record.getId()));
|
|
|
|
+ scenePlusVo.setSnCode(snCode);
|
|
|
|
+ scenePlusVo.setSceneType(param.getType());
|
|
|
|
+ list.add(scenePlusVo);
|
|
|
|
+ }
|
|
|
|
+ Page<ScenePlusVo> pageVo = new Page<>(param.getPageNum(),param.getPageSize());
|
|
|
|
+ pageVo.setRecords(list);
|
|
|
|
+ pageVo.setTotal(page.getTotal());
|
|
|
|
+ return PageInfo.PageInfo(pageVo);
|
|
|
|
+ }
|
|
|
|
+}
|