From 74ae355248c0bccadc80fb37bdb36aee5318fee8 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期三, 04 九月 2024 17:16:30 +0800 Subject: [PATCH] 考核指标导出优化 --- ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java | 56 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 37 insertions(+), 19 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java index 19c36b7..49f85e4 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java @@ -1,12 +1,15 @@ package com.ycl.platform.service.impl; import annotation.DataScope; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.platform.domain.dto.CheckScoreDTO; import com.ycl.platform.domain.dto.CheckScoreIndexDTO; import com.ycl.platform.domain.dto.ScoreIndexDTO; import com.ycl.platform.domain.entity.*; +import com.ycl.platform.domain.vo.CheckIndexCarVO; +import com.ycl.platform.domain.vo.CheckIndexFaceVO; +import com.ycl.platform.domain.vo.CheckIndexVideoVO; import com.ycl.platform.domain.vo.CheckScoreDetailVO; import com.ycl.platform.mapper.CheckRuleMapper; import com.ycl.platform.mapper.CheckScoreMapper; @@ -22,6 +25,7 @@ import com.ycl.utils.DateUtils; import com.ycl.utils.SecurityUtils; import com.ycl.utils.StringUtils; +import constant.CheckConstants; import enumeration.general.PublishType; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; @@ -77,8 +81,18 @@ CheckScoreDetailVO checkScoreDetailVO = new CheckScoreDetailVO(); //鏍规嵁id璇诲彇score CheckScore checkScore = scoreMapper.selectCheckScoreById(checkScoreId); + Integer templateId = 0; + //鏂逛究鍒囨崲鏀逛负锛氭牴鎹畇core鑰冩牳绫诲埆鍜宒to鑰冩牳鏍囩鏌ユā鏉胯鍒欏拰鏉冮噸,娉ㄦ剰鍚岀绫诲悓鏍囩鍙兘鏈変竴涓ā鏉� + QueryWrapper<CheckTemplate> wrapper = new QueryWrapper<>(); + wrapper.eq("examine_tag",checkScoreIndexDTO.getExamineTag()); + wrapper.eq("examine_category",checkScore.getExamineCategory()); + Optional<CheckTemplate> first = templateMapper.selectList(wrapper).stream().findFirst(); + if(first.isPresent()){ + CheckTemplate checkTemplate = first.get(); + templateId = checkTemplate.getId(); + } //璇诲彇瑙勫垯浠ュ強鏉冮噸 - List<CheckTemplateRule> templateRuleList = templateRuleMapper.selectListByTemplateId(checkScore.getTemplateId()); + List<CheckTemplateRule> templateRuleList = templateRuleMapper.selectListByTemplateId(templateId); List<CheckRule> checkRules = new ArrayList<>(); //璇诲彇妯℃澘瀵瑰簲鎵�鏈夎鍒� @@ -99,7 +113,7 @@ .setDate(checkScoreIndexDTO.getDate()) .setQuarter(checkScoreIndexDTO.getQuarter()); scoreIndexDTO.setParams(checkScoreIndexDTO.getParams()); - scoreIndexDTO.setExamineTag(checkScore.getExamineTag()); + scoreIndexDTO.setExamineTag(checkScoreIndexDTO.getExamineTag()); //鑾峰綋鏈堜唤 if (StringUtils.isEmpty(scoreIndexDTO.getDate()) && CollectionUtils.isEmpty(checkScoreIndexDTO.getQuarter())) { //濡傛灉鏌ヨ鏉′欢涓嶅惈鍙傛暟锛屾煡璇㈢Н鍒嗗搴斿垱寤烘椂闂� @@ -144,7 +158,7 @@ // 濡傛灉鏁版嵁涓虹┖锛屽垯鏌ヨ涔嬪墠鐨勬暟鎹� if (checkScores.isEmpty()) { - CheckScore one = new LambdaQueryChainWrapper<>(baseMapper).select(CheckScore::getCreateTime).last("order by create_time desc limit 1").one(); + CheckScore one = scoreMapper.getLast(checkScore); if (Objects.nonNull(one)) { calendar.setTime(one.getCreateTime()); getCheckScore(checkScore, calendar); @@ -244,14 +258,12 @@ @Override public void exportIndex(HttpServletResponse response, CheckScore checkScoreDTO) throws IOException { String date = checkScoreDTO.getDate(); - Integer examineTag = null; //濡傛灉璇锋眰鍙傛暟鏃堕棿涓虹┖锛屾煡杩欐潯璁板綍鐨勬椂闂� if (StringUtils.isEmpty(checkScoreDTO.getDate()) && CollectionUtils.isEmpty(checkScoreDTO.getQuarter())) { CheckScore checkScore = getById(checkScoreDTO.getId()); Date createTime = checkScore.getCreateTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); date = formatter.format(createTime); - examineTag = checkScore.getExamineTag(); } /** 瀵间笁寮爏heet */ @@ -259,29 +271,35 @@ CheckIndexCar checkIndexCar = new CheckIndexCar(); checkIndexCar.setDate(date); checkIndexCar.setQuarter(checkScoreDTO.getQuarter()); - if (examineTag != null) { - checkIndexCar.setExamineTag(Short.parseShort(examineTag + "")); - } List<CheckIndexCar> checkIndexCars = indexCarService.selectCheckIndexCarList(checkIndexCar); - ExcelExp e1 = new ExcelExp("杞﹁締鑰冩牳鎸囨爣鏁版嵁", checkIndexCars, CheckIndexCar.class); + List<CheckIndexCarVO> checkIndexCarVOS = new ArrayList<>(); + for (CheckIndexCar indexCar : checkIndexCars) { + CheckIndexCarVO excelVo = CheckIndexCar.getExcelVo(indexCar); + checkIndexCarVOS.add(excelVo); + } + ExcelExp e1 = new ExcelExp("杞﹁締鑰冩牳鎸囨爣鏁版嵁", checkIndexCarVOS, CheckIndexCarVO.class); //浜鸿劯 CheckIndexFace checkIndexFace = new CheckIndexFace(); checkIndexFace.setDate(date); checkIndexFace.setQuarter(checkScoreDTO.getQuarter()); - if (examineTag != null) { - checkIndexFace.setExamineTag(Short.parseShort(examineTag + "")); - } List<CheckIndexFace> checkIndexFaces = indexFaceService.selectCheckIndexFaceList(checkIndexFace); - ExcelExp e2 = new ExcelExp("浜鸿劯鑰冩牳鎸囨爣鏁版嵁", checkIndexFaces, CheckIndexFace.class); + List<CheckIndexFaceVO> checkIndexFaceVOS = new ArrayList<>(); + for (CheckIndexFace indexFace : checkIndexFaces) { + CheckIndexFaceVO excelVo = CheckIndexFace.getExcelVo(indexFace); + checkIndexFaceVOS.add(excelVo); + } + ExcelExp e2 = new ExcelExp("浜鸿劯鑰冩牳鎸囨爣鏁版嵁", checkIndexFaceVOS, CheckIndexFaceVO.class); //瑙嗛 CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); checkIndexVideo.setDate(date); checkIndexVideo.setQuarter(checkScoreDTO.getQuarter()); - if (examineTag != null) { - checkIndexVideo.setExamineTag(Short.parseShort(examineTag + "")); - } List<CheckIndexVideo> checkIndexVideos = indexVideoService.selectCheckIndexVideoList(checkIndexVideo); - ExcelExp e3 = new ExcelExp("瑙嗛鑰冩牳鎸囨爣鏁版嵁", checkIndexVideos, CheckIndexVideo.class); + List<CheckIndexVideoVO> checkIndexVideoVOS = new ArrayList<>(); + for (CheckIndexVideo indexVideo : checkIndexVideos) { + CheckIndexVideoVO excelVo = CheckIndexVideo.getExcelVo(indexVideo); + checkIndexVideoVOS.add(excelVo); + } + ExcelExp e3 = new ExcelExp("瑙嗛鑰冩牳鎸囨爣鏁版嵁", checkIndexVideoVOS, CheckIndexVideoVO.class); List<ExcelExp> mysheet = new ArrayList<>(); mysheet.add(e1); @@ -297,7 +315,7 @@ SysUser user = SecurityUtils.getLoginUser().getUser(); if (!user.isAdmin()) { for (SysRole role : roles) { - if (role.getPermissions().contains("check:score:publish")) { + if (role.getPermissions().contains("check:score:role:publish")) { Map<String, Object> params = checkScore.getParams(); params.put("publish", PublishType.PUBLISHED.getCode()); } -- Gitblit v1.8.0