ScenePlusServiceImpl.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package com.fdkankan.manage.service.impl;
  2. import cn.hutool.core.io.FileUtil;
  3. import com.alibaba.excel.EasyExcel;
  4. import com.alibaba.excel.ExcelWriter;
  5. import com.alibaba.fastjson.JSONArray;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  9. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  10. import com.fdkankan.common.util.DateUtil;
  11. import com.fdkankan.fyun.face.FYunFileServiceInterface;
  12. import com.fdkankan.manage.common.OssPath;
  13. import com.fdkankan.manage.common.ResultCode;
  14. import com.fdkankan.manage.common.SensitiveWordReplacer;
  15. import com.fdkankan.manage.config.ManageConfig;
  16. import com.fdkankan.manage.exception.BusinessException;
  17. import com.fdkankan.manage.httpClient.service.LaserService;
  18. import com.fdkankan.manage.entity.*;
  19. import com.fdkankan.manage.mapper.IScenePlusMapper;
  20. import com.fdkankan.manage.service.*;
  21. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  22. import com.fdkankan.manage.util.ShellUtil;
  23. import com.fdkankan.manage.vo.request.AllShareParam;
  24. import com.fdkankan.manage.vo.request.SceneParam;
  25. import com.fdkankan.manage.vo.request.SceneTotalParam;
  26. import com.fdkankan.manage.vo.response.*;
  27. import org.apache.commons.lang3.StringUtils;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.stereotype.Service;
  30. import java.io.File;
  31. import java.nio.charset.StandardCharsets;
  32. import java.util.*;
  33. import java.util.stream.Collectors;
  34. /**
  35. * <p>
  36. * 场景主表 服务实现类
  37. * </p>
  38. *
  39. * @author
  40. * @since 2022-08-02
  41. */
  42. @Service
  43. public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlus> implements IScenePlusService {
  44. @Autowired
  45. ISceneProService sceneProService;
  46. @Autowired
  47. LaserService laserService;
  48. @Autowired
  49. ISceneBuildProcessLogService sceneBuildProcessLogService;
  50. @Autowired
  51. IBuildLogService buildLogService;
  52. @Autowired
  53. IOrigFileUploadBatchService origFileUploadBatchService;
  54. @Autowired
  55. IOrigFileUploadService origFileUploadService;
  56. @Autowired
  57. IExcelService excelService;
  58. @Autowired
  59. IScenePlusExtService scenePlusExtService;
  60. @Autowired
  61. FYunFileServiceInterface fYunFileServiceInterface;
  62. @Autowired
  63. ManageConfig manageConfig;
  64. @Override
  65. public ScenePlus getByNum(String sceneNum) {
  66. LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
  67. wrapper.eq(ScenePlus::getNum,sceneNum);
  68. List<ScenePlus> list = this.list(wrapper);
  69. if(list!=null && list.size() >0){
  70. return list.get(0);
  71. }
  72. return null;
  73. }
  74. @Override
  75. public void unbindCamera(Long cameraId) {
  76. LambdaUpdateWrapper<ScenePlus> wrapper = new LambdaUpdateWrapper<>();
  77. wrapper.set(ScenePlus::getUserId,null)
  78. .eq(ScenePlus::getCameraId,cameraId);
  79. this.update(wrapper);
  80. }
  81. @Override
  82. public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer isObj) {
  83. HashMap<Long,Long> map = new HashMap<>();
  84. if(!userIdList.isEmpty()){
  85. List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList,isObj);
  86. result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
  87. }
  88. return map;
  89. }
  90. @Override
  91. public HashMap<Long, Long> getCountGroupByCameraId(ArrayList<Long> cameraIds) {
  92. HashMap<Long,Long> map = new HashMap<>();
  93. if(!cameraIds.isEmpty()){
  94. List<GroupByCount> result = this.getBaseMapper().getCountGroupByCameraId(cameraIds);
  95. result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
  96. }
  97. return map;
  98. }
  99. @Override
  100. public Page<UserShareSceneVo> shareScenePageList(Page<UserShareSceneVo> objectPage, UserShareParam param) {
  101. return this.getBaseMapper().shareScenePageList(objectPage,param);
  102. }
  103. @Override
  104. public Page<UserShareSceneVo> allScenePageList(Page<UserShareSceneVo> objectPage, AllShareParam param) {
  105. return this.getBaseMapper().allScenePageList(objectPage,param);
  106. }
  107. @Override
  108. public Page<UserShareSceneVo> sceneAuthPageList(Page<UserShareSceneVo> objectPage, UserShareParam param) {
  109. return this.getBaseMapper().sceneAuthPageList(objectPage,param);
  110. }
  111. @Override
  112. public Page<UserAuthSceneVo> sceneAuthVoPageList(Page<UserShareSceneVo> objectPage, UserShareParam param) {
  113. return this.getBaseMapper().sceneAuthVoPageList(objectPage,param);
  114. }
  115. @Override
  116. public List<ScenePlus> getByNumList(List<String> numList) {
  117. if(numList == null || numList.isEmpty()){
  118. return new ArrayList<>();
  119. }
  120. LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
  121. wrapper.in(ScenePlus::getNum,numList);
  122. return this.list(wrapper);
  123. }
  124. @Override
  125. public String getSceneBuildLog(String num) {
  126. String sceneBuildLogPath = String.format(OssPath.SCENE_BUILD_LOG_PATH,num,num);
  127. if(!fYunFileServiceInterface.fileExist(sceneBuildLogPath)){
  128. throw new BusinessException(ResultCode.LOG_NOT_EXIST);
  129. }
  130. return manageConfig.getQueryPath() + sceneBuildLogPath ;
  131. }
  132. @Override
  133. public List<String> getNumListBySceneName(String sceneName) {
  134. LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
  135. wrapper.like(ScenePlus::getTitle,sceneName);
  136. return this.list(wrapper).stream().map(ScenePlus::getNum).collect(Collectors.toList());
  137. }
  138. @Override
  139. public List<SceneVoSimp> getVoByNumList(List<String> notAuthList) {
  140. if(notAuthList == null || notAuthList.isEmpty()){
  141. return null;
  142. }
  143. return this.getBaseMapper().getVoByNumList(notAuthList);
  144. }
  145. @Override
  146. public List<String> getByUserIds(List<Long> otherUserIds) {
  147. if(otherUserIds == null || otherUserIds.isEmpty()){
  148. return new ArrayList<>();
  149. }
  150. LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
  151. wrapper.in(ScenePlus::getUserId,otherUserIds);
  152. return this.list(wrapper).stream().map(ScenePlus::getNum).collect(Collectors.toList());
  153. }
  154. @Override
  155. public List<String> getByPlatformIds(List<Integer> otherPlatformIds) {
  156. if(otherPlatformIds == null || otherPlatformIds.isEmpty()){
  157. return new ArrayList<>();
  158. }
  159. return this.getBaseMapper().getByPlatformIds(otherPlatformIds);
  160. }
  161. }