From 0ccc9a0dcadfb32aa8c63b718518ec0d216fae8f Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 05 九月 2024 17:06:16 +0800
Subject: [PATCH] 保存到mongo时设置标签信息

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java |   84 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 74 insertions(+), 10 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 0137fda..eb9098a 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
@@ -2,12 +2,16 @@
 
 import annotation.DataScope;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.platform.base.CheckIndex;
 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;
@@ -17,6 +21,7 @@
 import com.ycl.platform.service.ICheckIndexFaceService;
 import com.ycl.platform.service.ICheckIndexVideoService;
 import com.ycl.platform.service.ICheckScoreService;
+import com.ycl.system.entity.BaseEntity;
 import com.ycl.system.entity.SysRole;
 import com.ycl.system.entity.SysUser;
 import com.ycl.system.service.ISysDeptService;
@@ -29,6 +34,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import pojo.ExcelExp;
 import utils.poi.ExcelUtilManySheet;
@@ -120,6 +126,8 @@
             scoreIndexDTO.setDate(formatter.format(createTime));
         }
 
+        //鏉冮檺鎺у埗
+        roleControl(scoreIndexDTO);
         List<Map> map = scoreMapper.selectScoreIndex(scoreIndexDTO);
 
         scoreMap.put("tableData", checkRules);
@@ -231,6 +239,7 @@
      * @return 缁撴灉
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int publishCheckScore(CheckScoreDTO checkScoreDTO) {
         if (CollectionUtils.isEmpty(checkScoreDTO.getId())) {
             return 0;
@@ -243,8 +252,39 @@
         }
         String code = publishType.getCode();
         checkScoreDTO.setPublish(code);
-
-        return scoreMapper.publishCheckScore(checkScoreDTO);
+        int i = scoreMapper.publishCheckScore(checkScoreDTO);
+        //鎺у埗index琛ㄧ殑鍙戝竷鐘舵��
+        List<Integer> ids = checkScoreDTO.getId();
+        QueryWrapper<CheckScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("id",ids);
+        List<CheckScore> scoreList = scoreMapper.selectList(queryWrapper);
+        //鏈�澶氫负3娆″惊鐜�
+        for (CheckScore checkScore : scoreList) {
+            Short examineCategory = checkScore.getExamineCategory();
+            if(CheckConstants.Rule_Category_Video.equals(examineCategory)){
+                UpdateWrapper<CheckIndexVideo> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.set("publish",code);
+                updateWrapper.eq("dept_id",checkScore.getDeptId());
+                updateWrapper.eq("examine_tag",checkScore.getExamineTag());
+                updateWrapper.between("create_time",DateUtils.getDayStart(checkScore.getCreateTime()),DateUtils.getDayEnd(checkScore.getCreateTime()));
+                indexVideoService.update(updateWrapper);
+            }else if(CheckConstants.Rule_Category_Car.equals(examineCategory)){
+                UpdateWrapper<CheckIndexCar> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.set("publish",code);
+                updateWrapper.eq("dept_id",checkScore.getDeptId());
+                updateWrapper.eq("examine_tag",checkScore.getExamineTag());
+                updateWrapper.between("create_time",DateUtils.getDayStart(checkScore.getCreateTime()),DateUtils.getDayEnd(checkScore.getCreateTime()));
+                indexCarService.update(updateWrapper);
+            }else if(CheckConstants.Rule_Category_Face.equals(examineCategory)){
+                UpdateWrapper<CheckIndexFace> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.set("publish",code);
+                updateWrapper.eq("dept_id",checkScore.getDeptId());
+                updateWrapper.eq("examine_tag",checkScore.getExamineTag());
+                updateWrapper.between("create_time",DateUtils.getDayStart(checkScore.getCreateTime()),DateUtils.getDayEnd(checkScore.getCreateTime()));
+                indexFaceService.update(updateWrapper);
+            }
+        }
+        return i;
     }
 
     /**
@@ -269,29 +309,41 @@
         CheckIndexCar checkIndexCar = new CheckIndexCar();
         checkIndexCar.setDate(date);
         checkIndexCar.setQuarter(checkScoreDTO.getQuarter());
+        //鏉冮檺鎺у埗 鍙兘鏌ョ湅宸插彂甯�
+        roleControl(checkIndexCar);
         List<CheckIndexCar> checkIndexCars = indexCarService.selectCheckIndexCarList(checkIndexCar);
+        List<CheckIndexCarVO> checkIndexCarVOS = new ArrayList<>();
         for (CheckIndexCar indexCar : checkIndexCars) {
-            indexCar.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexCar.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+            CheckIndexCarVO excelVo = CheckIndexCar.getExcelVo(indexCar);
+            checkIndexCarVOS.add(excelVo);
         }
-        ExcelExp e1 = new ExcelExp("杞﹁締鑰冩牳鎸囨爣鏁版嵁", checkIndexCars, CheckIndexCar.class);
+        ExcelExp e1 = new ExcelExp("杞﹁締鑰冩牳鎸囨爣鏁版嵁", checkIndexCarVOS, CheckIndexCarVO.class);
         //浜鸿劯
         CheckIndexFace checkIndexFace = new CheckIndexFace();
         checkIndexFace.setDate(date);
         checkIndexFace.setQuarter(checkScoreDTO.getQuarter());
+        //鏉冮檺鎺у埗 鍙兘鏌ョ湅宸插彂甯�
+        roleControl(checkIndexFace);
         List<CheckIndexFace> checkIndexFaces = indexFaceService.selectCheckIndexFaceList(checkIndexFace);
+        List<CheckIndexFaceVO> checkIndexFaceVOS = new ArrayList<>();
         for (CheckIndexFace indexFace : checkIndexFaces) {
-            indexFace.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexFace.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+            CheckIndexFaceVO excelVo = CheckIndexFace.getExcelVo(indexFace);
+            checkIndexFaceVOS.add(excelVo);
         }
-        ExcelExp e2 = new ExcelExp("浜鸿劯鑰冩牳鎸囨爣鏁版嵁", checkIndexFaces, CheckIndexFace.class);
+        ExcelExp e2 = new ExcelExp("浜鸿劯鑰冩牳鎸囨爣鏁版嵁", checkIndexFaceVOS, CheckIndexFaceVO.class);
         //瑙嗛
         CheckIndexVideo checkIndexVideo = new CheckIndexVideo();
         checkIndexVideo.setDate(date);
         checkIndexVideo.setQuarter(checkScoreDTO.getQuarter());
+        //鏉冮檺鎺у埗 鍙兘鏌ョ湅宸插彂甯�
+        roleControl(checkIndexVideo);
         List<CheckIndexVideo> checkIndexVideos = indexVideoService.selectCheckIndexVideoList(checkIndexVideo);
+        List<CheckIndexVideoVO> checkIndexVideoVOS = new ArrayList<>();
         for (CheckIndexVideo indexVideo : checkIndexVideos) {
-            indexVideo.setExamineTagStr(CheckConstants.Examine_Tag_Province.equals(indexVideo.getExamineTag()) ? "鐪佸巺鑰冩牳" : "鍖哄幙鑰冩牳");
+            CheckIndexVideoVO excelVo = CheckIndexVideo.getExcelVo(indexVideo);
+            checkIndexVideoVOS.add(excelVo);
         }
-        ExcelExp e3 = new ExcelExp("瑙嗛鑰冩牳鎸囨爣鏁版嵁", checkIndexVideos, CheckIndexVideo.class);
+        ExcelExp e3 = new ExcelExp("瑙嗛鑰冩牳鎸囨爣鏁版嵁", checkIndexVideoVOS, CheckIndexVideoVO.class);
 
         List<ExcelExp> mysheet = new ArrayList<>();
         mysheet.add(e1);
@@ -302,7 +354,19 @@
 
     }
 
-    private void roleControl(CheckScore checkScore) {
+    private void roleControl(CheckIndex checkIndex) {
+        List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if (!user.isAdmin()) {
+            for (SysRole role : roles) {
+                if (role.getPermissions().contains("check:score:role:publish")) {
+                    Map<String, Object> params = checkIndex.getParams();
+                    params.put("publish", PublishType.PUBLISHED.getCode());
+                }
+            }
+        }
+    }
+    private void roleControl(BaseEntity checkScore) {
         List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
         SysUser user = SecurityUtils.getLoginUser().getUser();
         if (!user.isAdmin()) {

--
Gitblit v1.8.0