package com.fdkankan.manage.service.impl; import cn.dev33.satoken.stp.StpUtil; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fdkankan.common.constant.SceneConstant; import com.fdkankan.fyun.face.FYunFileServiceInterface; import com.fdkankan.manage.common.*; import com.fdkankan.manage.config.LaserConfig; import com.fdkankan.manage.config.ManageConfig; import com.fdkankan.manage.exception.BusinessException; import com.fdkankan.common.util.*; import com.fdkankan.manage.httpClient.client.FdKKClient; import com.fdkankan.manage.httpClient.param.LaserSceneParam; import com.fdkankan.manage.httpClient.service.LaserService; import com.fdkankan.manage.entity.*; import com.fdkankan.manage.httpClient.vo.LaserUpdateUserVo; import com.fdkankan.manage.mapper.ISceneProMapper; import com.fdkankan.manage.service.*; import com.fdkankan.manage.util.SceneStatusUtil; import com.fdkankan.manage.vo.request.SceneParam; import com.fdkankan.manage.vo.response.CameraDataVo; import com.fdkankan.manage.vo.response.GroupByCount; import com.fdkankan.manage.vo.response.SceneVo; import com.fdkankan.rabbitmq.util.RabbitMqProducer; import lombok.extern.slf4j.Slf4j; import net.sf.jsqlparser.parser.JJTCCJSqlParserState; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import javax.annotation.Resource; import java.io.File; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; /** *

* pro场景表 服务实现类 *

* * @author * @since 2022-06-16 */ @Service @Slf4j public class SceneProServiceImpl extends ServiceImpl implements ISceneProService { @Autowired private ICameraService cameraService; @Autowired ICameraDetailService cameraDetailService; @Autowired ISceneService sceneService; @Autowired ISceneCopyLogService copyLogService; @Autowired IUserIncrementService userIncrementService; @Autowired IIncrementTypeService incrementTypeService; @Autowired ISceneProEditService sceneProEditService; @Autowired FYunFileServiceInterface fYunFileServiceInterface; @Autowired IScenePlusService scenePlusService; @Autowired IScene3dNumService scene3dNumService; @Autowired ISceneCopyLogService sceneCopyLogService; @Autowired IScenePlusExtService scenePlusExtService; @Autowired LaserService laserService; @Autowired LaserConfig laserConfig; @Autowired FdKKClient fdKKClient; @Autowired IFolderSceneService folderSceneService; @Autowired IJyUserService jyUserService; @Autowired IJySceneUserAuthService jySceneUserAuthService; @Autowired IJyUserShareService jyUserShareService; @Autowired ISysUserService sysUserService; @Autowired IJySceneAuthService jySceneAuthService; @Autowired IJyUserPlatformService jyUserPlatformService; @Autowired IUserService userService; @Autowired IJyMoveSceneLogService jyMoveSceneLogService; @Autowired IJySceneUploadService jySceneUploadService; @Autowired ICaseNumService caseNumService; @Autowired ICaseService caseService; @Autowired ManageConfig manageConfig; @Autowired RabbitMqProducer rabbitMqProducer; @Override public ScenePro getByNum(String num) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScenePro::getNum,num); wrapper.eq(ScenePro::getIsUpgrade,0); List list = this.list(wrapper); if(list == null || list.size() <=0){ return null; } return list.get(0); } @Override public HashMap getCountGroupByUserId(List userIdList,Integer isObj) { HashMap map = new HashMap<>(); List result = this.getBaseMapper().getCountGroupByUserId(userIdList,isObj); result.forEach(entity ->map.put(entity.getId(),entity.getCount())); return map; } @Override public HashMap getCountGroupByCameraId(List cameraIds) { HashMap map = new HashMap<>(); List result = this.getBaseMapper().getCountGroupByCameraId(cameraIds); result.forEach(entity ->map.put(entity.getId(),entity.getCount())); return map; } @Override public void unbindCamera(Long cameraId) { LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.set(ScenePro::getUserId,null) .eq(ScenePro::getCameraId,cameraId); wrapper.eq(ScenePro::getIsUpgrade,0); this.update(wrapper); } @Override public List getListByCameraId(Long cameraId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScenePro::getCameraId,cameraId); wrapper.eq(ScenePro::getIsUpgrade,0); return this.list(wrapper); } /** * @param payStatus -2 封存,为 1 解封 */ @Override public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId, Integer payStatus) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper plusWr = new LambdaQueryWrapper<>(); Long totalSpace = cameraDetail.getTotalSpace(); UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId); if(userIncrement!=null){ IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId()); if(incrementType!=null){ if(incrementType.getCameraCapacity() == -1){ totalSpace = -1L; }else { totalSpace = incrementType.getCameraCapacity() * 1024 * 1024L; } } } log.info("lockOrUnLockBySpace---cameraId:{},payStatus:{},totalSpace:{},useSpace{}", cameraId,payStatus,totalSpace,cameraDetail.getUsedSpace()); if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量 wrapper.orderByAsc(ScenePro::getCreateTime); plusWr.orderByAsc(ScenePlus::getCreateTime); wrapper.eq(ScenePro::getPayStatus,-2); plusWr.eq(ScenePlus::getPayStatus,-2); }else { if (totalSpace >= cameraDetail.getUsedSpace()) { // 总容量大于已使用容量,不予封存 return; } wrapper.orderByDesc(ScenePro::getCreateTime); plusWr.orderByDesc(ScenePlus::getCreateTime); wrapper.eq(ScenePro::getPayStatus,1); plusWr.eq(ScenePlus::getPayStatus,1); } wrapper.eq(ScenePro::getCameraId,cameraId) .eq(ScenePro::getIsUpgrade,0); plusWr.eq(ScenePlus::getCameraId,cameraId); List list = this.list(wrapper); List plusList = scenePlusService.list(plusWr); Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - totalSpace); Long accumulateSpace = 0L; List lockedIds = new ArrayList<>(); if(payStatus == 1){ Long doSpace = getScenePlusLockedIds(lockedIds, plusList, totalSpace, beyondSpace, accumulateSpace); beyondSpace -= doSpace; getSceneLockedIds(lockedIds,list,totalSpace,beyondSpace,accumulateSpace); }else { Long doSpace = getSceneLockedIds(lockedIds, list, totalSpace, beyondSpace, accumulateSpace); beyondSpace -= doSpace; getScenePlusLockedIds(lockedIds,plusList,totalSpace,beyondSpace,accumulateSpace); } lockOrUnLockScenes(lockedIds,payStatus); } private Long getSceneLockedIds(List lockedIds ,List list,Long count,Long beyondSpace,Long accumulateSpace){ if (list != null && list.size() > 0){ for (ScenePro scenePro : list){ accumulateSpace += scenePro.getSpace(); if (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){ return accumulateSpace - scenePro.getSpace(); } lockedIds.add(scenePro.getId()); } } return accumulateSpace; } private Long getScenePlusLockedIds(List lockedIds , List list, Long count, Long beyondSpace, Long accumulateSpace){ if (list != null && list.size() > 0){ List plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList()); HashMap byPlusIds = scenePlusExtService.getByPlusIds(plusIds); for (ScenePlus scenePlus : list){ ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId()); accumulateSpace += scenePlusExt.getSpace(); if (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){ return accumulateSpace - scenePlusExt.getSpace(); } lockedIds.add(scenePlus.getId()); } } return accumulateSpace; } // payStatus 为 -2 封存,为 1 解封 private void lockOrUnLockScenes(List lockedIds,Integer payStatus) { if (lockedIds == null || lockedIds.size() == 0){ return; } LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.set(ScenePro::getPayStatus,payStatus) .eq(ScenePro::getIsUpgrade,0) .in(ScenePro::getId,lockedIds); this.update(updateWrapper); LambdaUpdateWrapper updatePlusWrapper = new LambdaUpdateWrapper<>(); updatePlusWrapper.set(ScenePlus::getPayStatus,payStatus) .in(ScenePlus::getId,lockedIds); scenePlusService.update(updatePlusWrapper); this.updateOssStatus(lockedIds,payStatus); } /** * 修改oss status.json中 payStatus */ private void updateOssStatus(List lockedIds, Integer payStatus) { LambdaQueryWrapper proWr = new LambdaQueryWrapper<>(); proWr.eq(ScenePro::getIsUpgrade,0); proWr.in(ScenePro::getId,lockedIds); List proList = this.list(proWr); LambdaQueryWrapper pluWr = new LambdaQueryWrapper<>(); pluWr.in(ScenePlus::getId,lockedIds); List plusList = scenePlusService.list(pluWr); for (ScenePro scenePro : proList) { this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),payStatus); } for (ScenePlus scenePlus : plusList) { this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),payStatus); } } /** * 从oss中获取文件,并重写,上传替换 */ private void updateOssStatus(String path,Integer payStatus) { try { if(!fYunFileServiceInterface.fileExist(path)){ return; } String data = fYunFileServiceInterface.getFileContent("4dkankan",path); if(StringUtils.isBlank(data)){ return; } JSONObject jsonObject = JSONObject.parseObject(data); jsonObject.put("payStatus",payStatus); String json = JSONUtil.toJsonStr(jsonObject); FileUtils.writeFile(OssPath.localStatusPath ,json); log.info("updateOssStatus--localPath:{},ossPath:{}",OssPath.localStatusPath,path); fYunFileServiceInterface.uploadFile(OssPath.localStatusPath,path); }catch (Exception e){ e.printStackTrace(); }finally { FileUtil.del(OssPath.localStatusPath); } } @Override public PageInfo pageList(SceneParam param) { SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString())); JyUser jyUser = jyUserService.getBySysId(byId.getId()); if(jyUser == null){ throw new BusinessException(ResultCode.JY_ID_NO_EXIST); } if(byId.getRoleId() !=1 ){ Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId(); if(loginPlatformId == null) { return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize())); } param.setPlatformId(loginPlatformId); if(byId.getRoleId() == 47L ){ param.setUserId(jyUser.getUserId()); } } List openNums = null; List authNumList = null; List openAuthNumList = null; HashMap authHashMap = new HashMap<>(); HashMap openHashMap = new HashMap<>(); if(param.getSceneType() == 1){ param.setNotUserId(jyUser.getUserId()); //List openNums = jySceneAuthService.getOpenNumList(); openNums = jySceneAuthService.getNumListByPlatform(param.getPlatformId(),1); if(!openNums.isEmpty()){ param.getAuthNumList().addAll(openNums); } List jySceneUserAuths = jySceneUserAuthService.getByJyUserId(jyUser.getId()); jySceneUserAuths.stream().filter(e ->e.getNum() != null && e.getAuthType() == 0).forEach( e-> authHashMap.put(e.getNum(),e)); jySceneUserAuths.stream().filter(e ->e.getNum() != null && e.getAuthType() == 1).forEach( e-> openHashMap.put(e.getNum(),e)); List allAuthNum = new ArrayList<>(); allAuthNum.addAll(authHashMap.keySet()); allAuthNum.addAll(openHashMap.keySet()); HashMap authMap = jySceneAuthService.getByNumList(allAuthNum); if(!authHashMap.isEmpty()){ authNumList = authHashMap.keySet().stream().filter(e -> authMap.get(e)!=null && authMap.get(e).getAuthType() == 0).collect(Collectors.toList()); if(!authNumList.isEmpty()){ param.getAuthNumList().addAll(authNumList); } } if(!openHashMap.isEmpty()){ openAuthNumList = openHashMap.keySet().stream().filter(e -> authMap.get(e)!=null && authMap.get(e).getAuthType() == 1).collect(Collectors.toList()); if(!openAuthNumList.isEmpty()){ param.getAuthNumList().addAll(openAuthNumList); } } param.getAuthNumList().addAll(manageConfig.getNumList()); List jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId()); List mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList()); HashMap roleMap = new HashMap<>(); if(!mainUserIds.isEmpty()){ List jyUsers = jyUserService.listByIds(mainUserIds); Set sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet()); HashMap byIds = sysUserService.getByIds(sysIds); jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId())); for (JyUser user : jyUsers) { Long roleId = roleMap.get(user.getId()); if(user.getPlatformId() != null && (roleId == 45L || roleId == 48L)){ param.getOtherPlatformIds().add(user.getPlatformId()); }else { param.getOtherUserIds().add(user.getUserId()); } } } if(param.getAuthNumList().isEmpty() && param.getOtherUserIds().isEmpty() && param.getOtherPlatformIds().isEmpty()){ return PageInfo.PageInfoEmpty(param.getPageNum(),param.getPageSize()); } } Page page ; SceneTypeEnum enumByType ; if(param.getIsObj() != null){ if(param.getIsObj() == 0){ page = this.getBaseMapper().selectLaser(new Page<>(param.getPageNum(),param.getPageSize()),param); }else { page = this.getBaseMapper().selectMesh(new Page<>(param.getPageNum(),param.getPageSize()),param); } }else { if(param.getType() == null){ page = this.getBaseMapper().pageList2(new Page<>(param.getPageNum(),param.getPageSize()),param); }else { enumByType = SceneTypeEnum.getEnumByType(param.getType()); if(enumByType == null){ throw new BusinessException(ResultCode.CAMERA_TYPE_ERROR); } param.setSceneSource(enumByType.getSceneSource()); if(enumByType.getThreeCamera()){ param.setThreeCamType(true); }else { param.setNotThreeCamType(true); } if(enumByType.getLaser()){ page = this.getBaseMapper().selectLaser(new Page<>(param.getPageNum(),param.getPageSize()),param); }else { page = this.getBaseMapper().selectMesh(new Page<>(param.getPageNum(),param.getPageSize()),param); } } } List records = page.getRecords(); List numList = records.parallelStream().map(SceneVo::getNum).collect(Collectors.toList()); HashMap map = copyLogService.getByNewNumList(numList); HashMap mapByNumList = caseNumService.getMapByNumList(numList); for (SceneVo record : page.getRecords()) { if( record.getSceneType().equals("laser") ){ record.setStatus(laserService.toFdStatus(record.getStatus())); record.setWebSite(laserConfig.getLaserWebSite()+record.getNum()); record.setPayStatus(1); } record.setStatusString(SceneStatusUtil.getStatusString(record)); if(map !=null ){ SceneCopyLog sceneCopyLog = map.get(record.getNum()); if(sceneCopyLog != null){ record.setCopyTime(sceneCopyLog.getCreateTime()); record.setIsCopy(true); } } if( byId.getRoleId() == 1L || jyUser.getUserId().equals(record.getUserId())){ record.setIsAuth(true); record.setEditAuth(true); record.setIsAuthOther(true); }else if((byId.getRoleId() == 45L || byId.getRoleId() == 48L) && jyUser.getPlatformId().equals(record.getPlatformId())){ record.setIsAuth(true); record.setEditAuth(true); record.setIsAuthOther(true); } else if(param.getAuthNumList().contains(record.getNum())) { JySceneUserAuth jySceneUserAuth = null; if(openAuthNumList != null && openAuthNumList.contains(record.getNum())){ jySceneUserAuth = openHashMap.get(record.getNum()); } if(authNumList != null && authNumList.contains(record.getNum())){ jySceneUserAuth = authHashMap.get(record.getNum()); } if(jySceneUserAuth != null){ if(jySceneUserAuth.getCanAuthLook() == 1 || jySceneUserAuth.getCanEditLook() == 1){ record.setIsAuth(true); } record.setEditAuth(jySceneUserAuth.getEditAuth() == 1); if(jySceneUserAuth.getEditAuth() == 2){ record.setEditAuth(jySceneUserAuth.getEditEndTime().getTime() > new Date().getTime()); } } }else { record.setIsShare(true); } record.setType( param.getType() == null ?setSceneType(record.getSceneSource(),record.getThreeCamType(),record.getSceneType()) : param.getType()); if(manageConfig.getNumList().contains(record.getNum()) || mapByNumList.get(record.getNum() + toFusionType(record.getType())) != null){ record.setInCase(true); } } return PageInfo.PageInfo(page); } //0 四维看看,1看见场景,2 深时场景,3 三维模型,4深时obj,5深光点云,6深光mesh,7圆周率 private Integer toFusionType(Integer type) { switch (type){ case 5 :return 4; case 6 :return 5; case 7 :return 6; case 8 :return 7; default: return type; } } private Integer setSceneType(Integer sceneSource,String threeCamType,String sceneType) { if(sceneSource == 3 ){ return 1; } if(sceneSource == 4 && sceneType.equals("laser")){ return 2; } if(sceneSource == 4 && sceneType.equals("4dkankan")){ return 5; } if(sceneSource == 5 && sceneType.equals("laser")){ return 6; } if(sceneSource == 5 && sceneType.equals("4dkankan")){ return 7; } return StringUtils.isBlank(threeCamType) ? 0 : 8; } @Override public Object sceneCount() { if( !manageConfig.getNumList().isEmpty()){ return 1; } SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString())); JyUser jyUser = jyUserService.getBySysId(byId.getId()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if(byId.getRoleId() != 1L ){ Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId(); if(jyUser == null){ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS); } List openNums = jySceneAuthService.getNumListByPlatform(loginPlatformId,1); if(!openNums.isEmpty()){ return 1; } if(byId.getRoleId() !=45L && byId.getRoleId() != 48L){ wrapper.eq(ScenePlus::getUserId,jyUser.getUserId()); } List list = jySceneUserAuthService.getByJyUserId(jyUser.getId()); if(list.size() >0){ return 1; } List jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId()); if(jyUserShares.size() >0){ return 1; } } List userIds = new ArrayList<>(); if(byId.getRoleId() == 45L || byId.getRoleId() == 48L){ //获取本平台所有用户 if(byId.getRoleId() == 48L){ Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId(); if(loginPlatformId != null){ userIds = jyUserService.getByUserIdPlatform(loginPlatformId); } } if(byId.getRoleId() == 45L){ //获取江门平台用户 List jyUsers = jyUserService.getListByJm(); userIds = jyUsers.stream().map(JyUser::getUserId).collect(Collectors.toList()); } if(userIds.isEmpty()){ return 0; } wrapper.in(ScenePlus::getUserId,userIds); } return scenePlusService.count(wrapper); } @Override public void move(SceneParam param) { ScenePlus scenePlus = scenePlusService.getByNum(param.getNum()); if(scenePlus== null ){ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005); } if(scenePlus.getSceneStatus() != -2){ throw new BusinessException(SceneConstant.FAILURE_CODE_5037, SceneConstant.FAILURE_MSG_5037); } JyUser jyUser = jyUserService.getByRyNo(param.getRyNo()); if(jyUser == null){ throw new BusinessException(ResultCode.USER_NOT_EXIST); } caseService.checkNumInCase(param.getNum()); JySceneUpload jySceneUpload = jySceneUploadService.getByNum(param.getNum()); if(jySceneUpload == null){ jySceneUpload = new JySceneUpload(); jySceneUpload.setUploadId(scenePlus.getUserId()); jySceneUpload.setNum(scenePlus.getNum()); jySceneUploadService.save(jySceneUpload); } LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(ScenePlus::getId,scenePlus.getId()); wrapper.set(ScenePlus::getUserId,jyUser.getUserId()); scenePlusService.update(wrapper); jySceneAuthService.delByNumList(Arrays.asList(scenePlus.getNum())); jyMoveSceneLogService.saveLog(scenePlus.getNum(),scenePlus.getUserId(),jyUser.getUserId(),Long.valueOf(StpUtil.getLoginId().toString())); laserService.updateSceneUser(new LaserUpdateUserVo(scenePlus.getUserId(),jyUser.getRyNo(),jyUser.getUserId(),scenePlus.getNum())); } @Override public void copy(String sceneNum) throws Exception { ScenePro scenePro = this.getByNum(sceneNum); ScenePlus scenePlus = scenePlusService.getByNum(sceneNum); if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005); } Integer status = scenePro == null ? scenePlus.getSceneStatus() :scenePro.getStatus(); if(status !=-2){ throw new BusinessException(SceneConstant.FAILURE_CODE_5033, SceneConstant.FAILURE_MSG_5033); } // Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId(); // Camera camera = cameraService.getById(cameraId); // if(camera == null){ // throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029); // } // CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId); // if(detailEntity == null){ // throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029); // } // if(detailEntity.getType() == 10 || detailEntity.getType() == 11){ // throw new BusinessException(ResultCode.SS_NO_COPY); // } HashMap param = new HashMap<>(); param.put("num",sceneNum); JSONObject jsonObject = fdKKClient.copyScene(param, "m_a_n_a_g_e"); Integer code = jsonObject.getInteger("code"); if(code != 0){ throw new BusinessException(jsonObject.getInteger("code"),jsonObject.getString("message")); } } @Override public void deleteByNum(String num) { Integer sceneSource = null; ScenePro scenePro = this.getByNum(num); Integer status = -2; if(scenePro!=null){ sceneSource = scenePro.getSceneSource(); status = scenePro.getStatus(); this.removeById(scenePro.getId()); } Scene scene = sceneService.getByNum(num); if(scene!=null){ status = scene.getStatus(); sceneService.removeById(scene.getId()); } ScenePlus scenePlus = scenePlusService.getByNum(num); if(scenePlus!=null){ status = scenePlus.getSceneStatus(); sceneSource = scenePlus.getSceneSource(); ScenePlusExt plusExt = scenePlusExtService.getByPlusId(scenePlus.getId()); if(plusExt != null){ scenePlusExtService.delByPlus(scenePlus.getId()); } scenePlusService.removeById(scenePlus.getId()); scenePlusExtService.delByPlus(scenePlus.getId()); } if(sceneSource != null && (sceneSource == 4 || sceneSource == 5)){ laserService.delete(num); } if(status == 0 ){ HashMap map = new HashMap<>(); map.put("num",num); rabbitMqProducer.sendByWorkQueue("fanout-exchange-iterrupt-calling","",map); } // if(cameraId != null){ // cameraDetailService.addUsedSpace(cameraId,space); // } } @Override public Long getKkCount(List asList, String startTime,List userIds,String treeCamType) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ScenePro::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper.in(ScenePro::getUserId,userIds); } wrapper.eq(ScenePro::getIsUpgrade,0); wrapper.lt(ScenePro::getCreateTime,startTime); long count = this.count(wrapper); LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); wrapper2.in(ScenePlus::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper2.in(ScenePlus::getUserId,userIds); } if(StringUtils.isNotBlank(treeCamType)){ wrapper2.isNotNull(ScenePlus::getThreeCamType); }else { wrapper2.isNull(ScenePlus::getThreeCamType); } wrapper2.lt(ScenePlus::getCreateTime,startTime); long count1 = scenePlusService.count(wrapper2); return count + count1; } @Override public Long getSsCount(List asList, String startTime,List userIds) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ScenePro::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper.in(ScenePro::getUserId,userIds); } wrapper.eq(ScenePro::getIsUpgrade,0); wrapper.lt(ScenePro::getCreateTime,startTime); LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); wrapper2.in(ScenePlus::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper2.in(ScenePlus::getUserId,userIds); } wrapper2.lt(ScenePlus::getCreateTime,startTime); long count = scenePlusService.count(wrapper2); return this.count(wrapper) + count; } @Override public Long getSsObjCount(List asList, String startTime,List userIds) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ScenePro::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper.in(ScenePro::getUserId,userIds); } wrapper.eq(ScenePro::getIsUpgrade,0); if(StringUtils.isNotBlank(startTime)){ wrapper.lt(ScenePro::getCreateTime,startTime); } wrapper.eq(ScenePro::getIsObj,1); LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); wrapper2.in(ScenePlus::getSceneSource,asList); if(!userIds.isEmpty()){ wrapper2.in(ScenePlus::getUserId,userIds); } if(StringUtils.isNotBlank(startTime)){ wrapper2.lt(ScenePlus::getCreateTime,startTime); } List list = scenePlusService.list(wrapper2); List plusIds = list.stream().map(ScenePlus::getId).collect(Collectors.toList()); long count = 0L; if(plusIds.size() >0){ LambdaQueryWrapper wrapper3 = new LambdaQueryWrapper<>(); wrapper3.in(ScenePlusExt::getPlusId,plusIds); wrapper3.eq(ScenePlusExt::getIsObj,1); count = scenePlusExtService.count(wrapper3); } return this.count(wrapper) + count; } @Override public HashMap getSnCodeByNumList(Set numList) { HashMap sceneMap = new HashMap<>(); HashMap cameraMap = new HashMap<>(); HashMap snCodeMap = new HashMap<>(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScenePro::getIsUpgrade,0); wrapper.in(ScenePro::getNum,numList); List list = this.list(wrapper); if(list.size() >0){ list.forEach(entity -> sceneMap.put(entity.getNum(),entity.getCameraId())); } LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); wrapper2.in(ScenePlus::getNum,numList); List list2 = scenePlusService.list(wrapper2); if(list2.size() >0){ list2.forEach(entity -> sceneMap.put(entity.getNum(),entity.getCameraId())); } if(sceneMap.size() <=0){ return snCodeMap; } Set cameraIds = list.stream().map(ScenePro::getCameraId).collect(Collectors.toSet()); Set cameraIds2 = list2.stream().map(ScenePlus::getCameraId).collect(Collectors.toSet()); cameraIds.addAll(cameraIds2); if(cameraIds.size() >0){ List cameraList = cameraService.listByIds(cameraIds); cameraList.forEach(entity -> cameraMap.put(entity.getId(),entity.getSnCode())); for (String num : numList) { Long cameraId = sceneMap.get(num); if(cameraId != null){ snCodeMap.put(num,cameraMap.get(cameraId)); } } } return snCodeMap; } }