ScenePlusServiceImpl.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.fdkankan.manage.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4. import com.fdkankan.common.util.DateUtil;
  5. import com.fdkankan.manage.httpClient.service.LaserService;
  6. import com.fdkankan.manage.entity.*;
  7. import com.fdkankan.manage.mapper.IScenePlusMapper;
  8. import com.fdkankan.manage.service.*;
  9. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  10. import com.fdkankan.manage.vo.response.GroupByCount;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import java.util.ArrayList;
  14. import java.util.Date;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. /**
  18. * <p>
  19. * 场景主表 服务实现类
  20. * </p>
  21. *
  22. * @author
  23. * @since 2022-08-02
  24. */
  25. @Service
  26. public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlus> implements IScenePlusService {
  27. @Autowired
  28. ISceneProService sceneProService;
  29. @Autowired
  30. LaserService laserService;
  31. @Autowired
  32. IScenePlusExtService scenePlusExtService;
  33. @Override
  34. public ScenePlus getByNum(String sceneNum) {
  35. LambdaQueryWrapper<ScenePlus> wrapper = new LambdaQueryWrapper<>();
  36. wrapper.eq(ScenePlus::getNum,sceneNum);
  37. List<ScenePlus> list = this.list(wrapper);
  38. if(list!=null && list.size() >0){
  39. return list.get(0);
  40. }
  41. return null;
  42. }
  43. @Override
  44. public void unbindCamera(Long cameraId) {
  45. LambdaUpdateWrapper<ScenePlus> wrapper = new LambdaUpdateWrapper<>();
  46. wrapper.set(ScenePlus::getUserId,null)
  47. .eq(ScenePlus::getCameraId,cameraId);
  48. this.update(wrapper);
  49. }
  50. @Override
  51. public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer isObj) {
  52. HashMap<Long,Long> map = new HashMap<>();
  53. List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList,isObj);
  54. result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
  55. return map;
  56. }
  57. @Override
  58. public HashMap<Long, Long> getCountGroupByCameraId(ArrayList<Long> cameraIds) {
  59. HashMap<Long,Long> map = new HashMap<>();
  60. List<GroupByCount> result = this.getBaseMapper().getCountGroupByCameraId(cameraIds);
  61. result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
  62. return map;
  63. }
  64. @Override
  65. public String getDataSourceByNum(String num) {
  66. ScenePro scenePro = sceneProService.getByNum(num);
  67. if(scenePro != null ){
  68. return scenePro.getDataSource();
  69. }
  70. ScenePlus plus = this.getByNum(num);
  71. if(plus != null){
  72. ScenePlusExt plusExt = scenePlusExtService.getByPlusId(plus.getId());
  73. if(plusExt.getDataSource() != null){
  74. return plusExt.getDataSource();
  75. }
  76. }
  77. return null;
  78. }
  79. }