From ab744742edfd1b402dbbe326acba110db8d0b8ac Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期二, 03 九月 2024 19:49:31 +0800
Subject: [PATCH] 考核bug修复、详情页加切换

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java |   41 ++++++++++++++++++++++++++---------------
 1 files changed, 26 insertions(+), 15 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..1c70ede 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,6 +1,7 @@
 package com.ycl.platform.service.impl;
 
 import annotation.DataScope;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ycl.platform.domain.dto.CheckScoreDTO;
@@ -22,6 +23,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 +79,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 +111,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 +156,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 +256,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,28 +269,28 @@
         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);
+        for (CheckIndexCar indexCar : checkIndexCars) {
+            indexCar.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexCar.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+        }
         ExcelExp e1 = new ExcelExp("杞﹁締鑰冩牳鎸囨爣鏁版嵁", checkIndexCars, CheckIndexCar.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);
+        for (CheckIndexFace indexFace : checkIndexFaces) {
+            indexFace.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexFace.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+        }
         ExcelExp e2 = new ExcelExp("浜鸿劯鑰冩牳鎸囨爣鏁版嵁", checkIndexFaces, CheckIndexFace.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);
+        for (CheckIndexVideo indexVideo : checkIndexVideos) {
+            indexVideo.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexVideo.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+        }
         ExcelExp e3 = new ExcelExp("瑙嗛鑰冩牳鎸囨爣鏁版嵁", checkIndexVideos, CheckIndexVideo.class);
 
         List<ExcelExp> mysheet = new ArrayList<>();
@@ -297,7 +307,8 @@
         SysUser user = SecurityUtils.getLoginUser().getUser();
         if (!user.isAdmin()) {
             for (SysRole role : roles) {
-                if (role.getPermissions().contains("check:score:publish")) {
+                //TODO锛氭湰鍦板簱淇敼
+                if (role.getPermissions().contains("check:score:role:publish")) {
                     Map<String, Object> params = checkScore.getParams();
                     params.put("publish", PublishType.PUBLISHED.getCode());
                 }

--
Gitblit v1.8.0