| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import annotation.DataScope; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.platform.domain.dto.CheckScoreDTO; |
| | | import com.ycl.platform.domain.dto.CheckScoreIndexDTO; |
| | |
| | | Short examineCategory = checkScore.getExamineCategory(); |
| | | String[] indexTableArr ={"","t_check_index_video","t_check_index_car","t_check_index_face"}; |
| | | String tableName = indexTableArr[examineCategory]; |
| | | //获当月份 |
| | | String date = checkScoreIndexDTO.getDate(); |
| | | if(StringUtils.isEmpty(date)){ |
| | | //如果查询条件不含参数,查询积分对应创建时间 |
| | | Date createTime = checkScore.getCreateTime(); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); |
| | | date = formatter.format(createTime); |
| | | } |
| | | |
| | | ScoreIndexDTO scoreIndexDTO = new ScoreIndexDTO() |
| | | .setTableName(tableName) |
| | | .setDeptId(checkScore.getDeptId()) |
| | | .setDate(date); |
| | | .setDate(checkScoreIndexDTO.getDate()) |
| | | .setQuarter(checkScoreIndexDTO.getQuarter()); |
| | | scoreIndexDTO.setParams(checkScoreIndexDTO.getParams()); |
| | | |
| | | //获当月份 |
| | | if(StringUtils.isEmpty(scoreIndexDTO.getDate()) && CollectionUtils.isEmpty(checkScoreIndexDTO.getQuarter())){ |
| | | //如果查询条件不含参数,查询积分对应创建时间 |
| | | Date createTime = checkScore.getCreateTime(); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); |
| | | scoreIndexDTO.setDate(formatter.format(createTime)); |
| | | } |
| | | |
| | | List<Map> map = scoreMapper.selectScoreIndex(scoreIndexDTO); |
| | | |
| | | scoreMap.put("tableData",checkRules); |
| | |
| | | |
| | | // 获取数据日期时间 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | getCheckScore(checkScore, calendar); |
| | | |
| | | // 一号查询之前的数据 |
| | | if (LocalDateTime.now().getDayOfMonth() == 1) { calendar.add(Calendar.DAY_OF_MONTH, -1); } |
| | | |
| | | List<CheckScore> checkScores = scoreMapper.selectCheckScoreMap(checkScore); |
| | | // 如果数据为空,则查询之前的数据 |
| | | if (checkScores.isEmpty()) { |
| | | CheckScore one = new LambdaQueryChainWrapper<>(baseMapper).select(CheckScore::getCreateTime).last("order by create_time desc limit 1").one(); |
| | | if (Objects.nonNull(one)) { |
| | | calendar.setTime(one.getCreateTime()); |
| | | getCheckScore(checkScore, calendar); |
| | | checkScores = scoreMapper.selectCheckScoreMap(checkScore); |
| | | } |
| | | } |
| | | return checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); |
| | | } |
| | | |
| | | private void getCheckScore(CheckScore checkScore, Calendar calendar) |
| | | { |
| | | // 0 省厅月度 1 市局月度 2 省厅季度 3 市局季度 |
| | | switch (checkScore.getExamineTag()) { |
| | | case 0, 1: |
| | |
| | | checkScore.setExamineTag(checkScore.getExamineTag() == 2 ? 0 : 1); |
| | | break; |
| | | } |
| | | return scoreMapper.selectCheckScoreMap(checkScore).stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询考核积分卡片列表 |
| | | * |
| | | * @param checkScore 考核积分 |
| | | * @return 考核积分 |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d",userAlias = "u") |
| | | public Map<Long, List<CheckScore>> selectCheckScoreChart(CheckScore checkScore) |
| | | { |
| | | //区县只能看已发布 |
| | | roleControl(checkScore); |
| | | |
| | | //查询成绩 |
| | | String date = checkScore.getDate(); |
| | | if(StringUtils.isEmpty(date)){ |
| | | //如果为空查本月的数据 |
| | | Calendar now = Calendar.getInstance(); |
| | | //取昨天 |
| | | // now.add(Calendar.DATE, -1); |
| | | Date yesterday = now.getTime(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); |
| | | date = simpleDateFormat.format(yesterday); |
| | | checkScore.setDate(date); |
| | | } |
| | | List<CheckScore> checkScores = scoreMapper.selectCheckScoreList(checkScore); |
| | | return checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); |
| | | } |
| | | |
| | | /** |
| | | * 区县详情 |
| | |
| | | public void exportIndex(HttpServletResponse response,CheckScore checkScoreDTO) throws IOException { |
| | | String date = checkScoreDTO.getDate(); |
| | | //如果请求参数时间为空,查这条记录的时间 |
| | | if(StringUtils.isEmpty(date)) { |
| | | if(StringUtils.isEmpty(checkScoreDTO.getDate()) && CollectionUtils.isEmpty(checkScoreDTO.getQuarter())){ |
| | | CheckScore checkScore = getById(checkScoreDTO.getId()); |
| | | Date createTime = checkScore.getCreateTime(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); |
| | | date = simpleDateFormat.format(createTime); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); |
| | | date = formatter.format(createTime); |
| | | } |
| | | |
| | | /** 导三张sheet */ |
| | | //车辆 |
| | | CheckIndexCar checkIndexCar = new CheckIndexCar(); |
| | | checkIndexCar.setDate(date); |
| | | checkIndexCar.setQuarter(checkScoreDTO.getQuarter()); |
| | | List<CheckIndexCar> checkIndexCars = indexCarService.selectCheckIndexCarList(checkIndexCar); |
| | | ExcelExp e1 = new ExcelExp("车辆考核指标数据",checkIndexCars,CheckIndexCar.class); |
| | | //人脸 |
| | | CheckIndexFace checkIndexFace = new CheckIndexFace(); |
| | | checkIndexFace.setDate(date); |
| | | checkIndexFace.setQuarter(checkScoreDTO.getQuarter()); |
| | | List<CheckIndexFace> checkIndexFaces = indexFaceService.selectCheckIndexFaceList(checkIndexFace); |
| | | ExcelExp e2 = new ExcelExp("人脸考核指标数据",checkIndexFaces,CheckIndexFace.class); |
| | | //视频 |
| | | CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); |
| | | checkIndexVideo.setDate(date); |
| | | checkIndexVideo.setQuarter(checkScoreDTO.getQuarter()); |
| | | List<CheckIndexVideo> checkIndexVideos = indexVideoService.selectCheckIndexVideoList(checkIndexVideo); |
| | | ExcelExp e3 = new ExcelExp("视频考核指标数据",checkIndexVideos,CheckIndexVideo.class); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> home() { |
| | | return baseMapper.home(); |
| | | } |
| | | |
| | | // /** |
| | | // * 新增考核积分 |