|
|
@@ -11,12 +11,13 @@ import com.fdkankan.manage.entity.CameraDetail;
|
|
|
import com.fdkankan.manage.entity.User;
|
|
|
import com.fdkankan.manage.mapper.ICameraDetailMapper;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
-import com.fdkankan.manage.vo.response.GroupByUserIdCount;
|
|
|
+import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -36,15 +37,11 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
|
|
|
@Autowired
|
|
|
ISceneProService sceneProService;
|
|
|
@Autowired
|
|
|
+ ISceneService sceneService;
|
|
|
+ @Autowired
|
|
|
IFdkkLaserService fdkkLaserService;
|
|
|
|
|
|
- @Override
|
|
|
- public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList) {
|
|
|
- HashMap<Long,Long> map = new HashMap<>();
|
|
|
- List<GroupByUserIdCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList);
|
|
|
- result.forEach(entity ->map.put(entity.getUserId(),entity.getCount()));
|
|
|
- return map;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void unbindCamera(Long cameraId, User user) {
|
|
|
@@ -94,4 +91,41 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
|
|
|
wrapper.eq(CameraDetail::getCameraId,cameraId);
|
|
|
this.remove(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList) {
|
|
|
+ HashMap<Long,Long> map = new HashMap<>();
|
|
|
+ List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList);
|
|
|
+ result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Long, Long> getCountGroupByCompanyId() {
|
|
|
+ List<GroupByCount> result = this.getBaseMapper().getCountGroupByCompanyId();
|
|
|
+ HashMap<Long,Long> map = new HashMap<>();
|
|
|
+ result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Long, Long> getSceneCountGroupByCameraId() {
|
|
|
+ LambdaQueryWrapper<CameraDetail> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.isNotNull(CameraDetail::getCompanyId);
|
|
|
+ wrapper.groupBy(CameraDetail::getCameraId);
|
|
|
+ List<CameraDetail> list = this.list(wrapper);
|
|
|
+ List<Long> cameraIds = list.parallelStream().map(CameraDetail::getCameraId).collect(Collectors.toList());
|
|
|
+ HashMap<Long, Long> resultMap = new HashMap<>();
|
|
|
+ HashMap<Long, Long> sceneProMap = sceneProService.getCountGroupByCameraId(cameraIds);
|
|
|
+ HashMap<Long, Long> sceneMap = sceneService.getCountGroupByCameraId(cameraIds);
|
|
|
+
|
|
|
+ for (CameraDetail cameraDetail : list) {
|
|
|
+ Long sceneProCount = sceneProMap.get(cameraDetail.getCameraId()) == null ? 0L : sceneProMap.get(cameraDetail.getCameraId());
|
|
|
+ Long sceneCount = sceneMap.get(cameraDetail.getCameraId()) == null ? 0L : sceneMap.get(cameraDetail.getCameraId());
|
|
|
+ Long count = sceneProCount + sceneCount;
|
|
|
+ resultMap.merge(cameraDetail.getCompanyId(), count, Long::sum);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|