Browse Source

groupBy 报错

lyhzzz 3 năm trước cách đây
mục cha
commit
2d947c0de8

+ 5 - 4
src/main/java/com/fdkankan/manage/service/impl/CameraDetailServiceImpl.java

@@ -15,8 +15,10 @@ import com.fdkankan.manage.vo.response.GroupByCount;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -118,12 +120,11 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
     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());
+        Set<Long> cameraIds = list.parallelStream().map(CameraDetail::getCameraId).collect(Collectors.toSet());
         HashMap<Long, Long> resultMap = new HashMap<>();
-        HashMap<Long, Long> sceneProMap = sceneProService.getCountGroupByCameraId(cameraIds);
-        HashMap<Long, Long> sceneMap = sceneService.getCountGroupByCameraId(cameraIds);
+        HashMap<Long, Long> sceneProMap = sceneProService.getCountGroupByCameraId(new ArrayList<>(cameraIds));
+        HashMap<Long, Long> sceneMap = sceneService.getCountGroupByCameraId(new ArrayList<>(cameraIds));
 
         for (CameraDetail cameraDetail : list) {
             Long sceneProCount = sceneProMap.get(cameraDetail.getCameraId()) == null ? 0L : sceneProMap.get(cameraDetail.getCameraId());