package com.fdkankan.manage.service.impl; import cn.hutool.core.io.FileUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.fastjson.JSONArray; 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.fdkankan.common.util.DateUtil; import com.fdkankan.fyun.face.FYunFileServiceInterface; import com.fdkankan.manage.common.OssPath; import com.fdkankan.manage.common.ResultCode; import com.fdkankan.manage.common.SensitiveWordReplacer; import com.fdkankan.manage.config.ManageConfig; import com.fdkankan.manage.exception.BusinessException; import com.fdkankan.manage.httpClient.service.LaserService; import com.fdkankan.manage.entity.*; import com.fdkankan.manage.mapper.IScenePlusMapper; import com.fdkankan.manage.service.*; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fdkankan.manage.util.ShellUtil; import com.fdkankan.manage.vo.request.AllShareParam; import com.fdkankan.manage.vo.request.SceneParam; import com.fdkankan.manage.vo.request.SceneTotalParam; import com.fdkankan.manage.vo.response.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.File; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; /** *

* 场景主表 服务实现类 *

* * @author * @since 2022-08-02 */ @Service public class ScenePlusServiceImpl extends ServiceImpl implements IScenePlusService { @Autowired ISceneProService sceneProService; @Autowired LaserService laserService; @Autowired ISceneBuildProcessLogService sceneBuildProcessLogService; @Autowired IBuildLogService buildLogService; @Autowired IOrigFileUploadBatchService origFileUploadBatchService; @Autowired IOrigFileUploadService origFileUploadService; @Autowired IExcelService excelService; @Autowired IScenePlusExtService scenePlusExtService; @Autowired FYunFileServiceInterface fYunFileServiceInterface; @Autowired ManageConfig manageConfig; @Override public ScenePlus getByNum(String sceneNum) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScenePlus::getNum,sceneNum); List list = this.list(wrapper); if(list!=null && list.size() >0){ return list.get(0); } return null; } @Override public void unbindCamera(Long cameraId) { LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.set(ScenePlus::getUserId,null) .eq(ScenePlus::getCameraId,cameraId); this.update(wrapper); } @Override public HashMap getCountGroupByUserId(List userIdList,Integer isObj) { HashMap map = new HashMap<>(); if(!userIdList.isEmpty()){ List result = this.getBaseMapper().getCountGroupByUserId(userIdList,isObj); result.forEach(entity ->map.put(entity.getId(),entity.getCount())); } return map; } @Override public HashMap getCountGroupByCameraId(ArrayList cameraIds) { HashMap map = new HashMap<>(); if(!cameraIds.isEmpty()){ List result = this.getBaseMapper().getCountGroupByCameraId(cameraIds); result.forEach(entity ->map.put(entity.getId(),entity.getCount())); } return map; } @Override public Page shareScenePageList(Page objectPage, UserShareParam param) { return this.getBaseMapper().shareScenePageList(objectPage,param); } @Override public Page allScenePageList(Page objectPage, AllShareParam param) { return this.getBaseMapper().allScenePageList(objectPage,param); } @Override public Page sceneAuthPageList(Page objectPage, UserShareParam param) { return this.getBaseMapper().sceneAuthPageList(objectPage,param); } @Override public Page sceneAuthVoPageList(Page objectPage, UserShareParam param) { return this.getBaseMapper().sceneAuthVoPageList(objectPage,param); } @Override public List getByNumList(List numList) { if(numList == null || numList.isEmpty()){ return new ArrayList<>(); } LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ScenePlus::getNum,numList); return this.list(wrapper); } @Override public String getSceneBuildLog(String num) { String sceneBuildLogPath = String.format(OssPath.SCENE_BUILD_LOG_PATH,num,num); if(!fYunFileServiceInterface.fileExist(sceneBuildLogPath)){ throw new BusinessException(ResultCode.LOG_NOT_EXIST); } return manageConfig.getQueryPath() + sceneBuildLogPath ; } @Override public List getNumListBySceneName(String sceneName) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.like(ScenePlus::getTitle,sceneName); return this.list(wrapper).stream().map(ScenePlus::getNum).collect(Collectors.toList()); } @Override public List getVoByNumList(List notAuthList) { if(notAuthList == null || notAuthList.isEmpty()){ return null; } return this.getBaseMapper().getVoByNumList(notAuthList); } @Override public List getByUserIds(List otherUserIds) { if(otherUserIds == null || otherUserIds.isEmpty()){ return new ArrayList<>(); } LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(ScenePlus::getUserId,otherUserIds); return this.list(wrapper).stream().map(ScenePlus::getNum).collect(Collectors.toList()); } @Override public List getByPlatformIds(List otherPlatformIds) { if(otherPlatformIds == null || otherPlatformIds.isEmpty()){ return new ArrayList<>(); } return this.getBaseMapper().getByPlatformIds(otherPlatformIds); } }