fuliqi
2024-11-14 5533880a277aa5dd75c1794f7f5fa4426ea41d6e
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -304,35 +304,25 @@
     */
    @Override
    public void exportIndex(HttpServletResponse response, CheckResultExportDTO exportDTO) throws IOException {
//        String date = exportDTO.getDate();
        //如果请求参数时间为空,查这条记录的时间
//        if (StringUtils.isEmpty(exportDTO.getDate()) && CollectionUtils.isEmpty(exportDTO.getQuarter())) {
//            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
//            if (exportDTO.getId() != null) {
//                CheckScore checkScore = getById(exportDTO.getId());
//                Date createTime = checkScore.getCreateTime();
//                date = formatter.format(createTime);
//            } else {
//                //防止卡片页面导出不传scoreId,导致报错
//                date = formatter.format(new Date());
//            }
//        }
        //没有标签默认全导
        if(CollectionUtils.isEmpty(exportDTO.getExamineTags())){
            exportDTO.setExamineTags(Arrays.asList(0,1,2));
        }
        /** 导三张sheet */
        //车辆
        CheckIndexCar checkIndexCar = new CheckIndexCar();
//        checkIndexCar.setDate(date);
        checkIndexCar.setQuarter(exportDTO.getQuarter());
        checkIndexCar.setDeptId(exportDTO.getDeptId());
        checkIndexCar.setDeptIds(exportDTO.getDeptIds());
        //权限控制 只能查看已发布
        roleControl(checkIndexCar);
        List<CheckIndexCar> checkIndexCars = new ArrayList<>();
        //车辆和人脸没有公安部
        for (Integer examineTag : exportDTO.getExamineTags()) {
            if(examineTag ==2) continue;
            CheckIndexCar checkIndexCar = new CheckIndexCar();
//        checkIndexCar.setDate(date);
            checkIndexCar.setQuarter(exportDTO.getQuarter());
            checkIndexCar.setDeptId(exportDTO.getDeptId());
            checkIndexCar.setDeptIds(exportDTO.getDeptIds());
            //权限控制 只能查看已发布
            roleControl(checkIndexCar);
            checkIndexCar.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexCar.setExamineTagQuery(1);
            }
            checkIndexCars.addAll(indexCarService.selectCheckIndexCarList(checkIndexCar));
        }
        //计算平均值放在excel最后
@@ -367,20 +357,19 @@
            checkIndexCarVOS.add(excelVo);
        }
        ExcelExp e1 = new ExcelExp("车辆考核指标数据", checkIndexCarVOS, CheckIndexCarVO.class);
        //人脸
        CheckIndexFace checkIndexFace = new CheckIndexFace();
//        checkIndexFace.setDate(date);
        checkIndexFace.setQuarter(exportDTO.getQuarter());
        checkIndexFace.setDeptId(exportDTO.getDeptId());
        checkIndexFace.setDeptIds(exportDTO.getDeptIds());
        //权限控制 只能查看已发布
        roleControl(checkIndexFace);
        List<CheckIndexFace> checkIndexFaces = new ArrayList<>();
        for (Integer examineTag : exportDTO.getExamineTags()) {
            if(examineTag ==2) continue;
            CheckIndexFace checkIndexFace = new CheckIndexFace();
//        checkIndexFace.setDate(date);
            checkIndexFace.setQuarter(exportDTO.getQuarter());
            checkIndexFace.setDeptId(exportDTO.getDeptId());
            checkIndexFace.setDeptIds(exportDTO.getDeptIds());
            //权限控制 只能查看已发布
            roleControl(checkIndexFace);
            checkIndexFace.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexFace.setExamineTagQuery(1);
            }
            checkIndexFaces.addAll(indexFaceService.selectCheckIndexFaceList(checkIndexFace));
        }
        //计算平均值放在excel最后
@@ -415,20 +404,18 @@
            checkIndexFaceVOS.add(excelVo);
        }
        ExcelExp e2 = new ExcelExp("人脸考核指标数据", checkIndexFaceVOS, CheckIndexFaceVO.class);
        //视频
        CheckIndexVideo checkIndexVideo = new CheckIndexVideo();
//        checkIndexVideo.setDate(date);
        checkIndexVideo.setQuarter(exportDTO.getQuarter());
        checkIndexVideo.setDeptId(exportDTO.getDeptId());
        checkIndexVideo.setDeptIds(exportDTO.getDeptIds());
        //权限控制 只能查看已发布
        roleControl(checkIndexVideo);
        List<CheckIndexVideo> checkIndexVideos = new ArrayList<>();
        for (Integer examineTag : exportDTO.getExamineTags()) {
            CheckIndexVideo checkIndexVideo = new CheckIndexVideo();
//        checkIndexVideo.setDate(date);
            checkIndexVideo.setQuarter(exportDTO.getQuarter());
            checkIndexVideo.setDeptId(exportDTO.getDeptId());
            checkIndexVideo.setDeptIds(exportDTO.getDeptIds());
            //权限控制 只能查看已发布
            roleControl(checkIndexVideo);
            checkIndexVideo.setExamineTag(Short.valueOf(examineTag + ""));
            if (examineTag == 0) {
                checkIndexVideo.setExamineTagQuery(1);
            }
            checkIndexVideos.addAll(indexVideoService.selectCheckIndexVideoList(checkIndexVideo));
        }
        //计算平均值放在excel最后
@@ -448,6 +435,17 @@
            List<CheckIndexVideo> provinceList = checkIndexVideos.stream().filter(video -> CheckConstants.Examine_Tag_Province.equals(video.getExamineTag())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(provinceList)) {
                Map<Long, List<CheckIndexVideo>> videoMap = provinceList.stream().collect(Collectors.groupingBy(CheckIndexVideo::getDeptId));
                List<CheckIndexVideo> videos = new ArrayList<>();
                videoMap.forEach((deptId, list) -> {
                    CheckIndexVideo video = CheckIndexVideo.calculateAverage(list);
                    videos.add(video);
                });
                //根据积分降序
                checkIndexVideos.addAll(videos.stream().sorted(Comparator.comparing(CheckIndexVideo::getScore).reversed()).collect(Collectors.toList()));
            }
            List<CheckIndexVideo> deptList = checkIndexVideos.stream().filter(video -> CheckConstants.Examine_Tag_Dept.equals(video.getExamineTag())).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(deptList)) {
                Map<Long, List<CheckIndexVideo>> videoMap = deptList.stream().collect(Collectors.groupingBy(CheckIndexVideo::getDeptId));
                List<CheckIndexVideo> videos = new ArrayList<>();
                videoMap.forEach((deptId, list) -> {
                    CheckIndexVideo video = CheckIndexVideo.calculateAverage(list);
@@ -548,7 +546,7 @@
        //填充各个区县数据
        for (CheckScore checkScore : dashboard) {
            Map<String, Object> map = new HashMap<>();
            map.put("score", checkScore.getScore().setScale(2,RoundingMode.HALF_UP));
            map.put("score", checkScore.getScore().setScale(1,RoundingMode.HALF_UP));
            resultMap.put(checkScore.getDeptName(), map);
        }
        return resultMap;