xiangpei
2024-09-05 0ccc9a0dcadfb32aa8c63b718518ec0d216fae8f
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -2,7 +2,9 @@
import annotation.DataScope;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
@@ -19,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;
@@ -31,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;
@@ -122,6 +126,8 @@
            scoreIndexDTO.setDate(formatter.format(createTime));
        }
        //权限控制
        roleControl(scoreIndexDTO);
        List<Map> map = scoreMapper.selectScoreIndex(scoreIndexDTO);
        scoreMap.put("tableData", checkRules);
@@ -233,6 +239,7 @@
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int publishCheckScore(CheckScoreDTO checkScoreDTO) {
        if (CollectionUtils.isEmpty(checkScoreDTO.getId())) {
            return 0;
@@ -245,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;
    }
    /**
@@ -271,6 +309,8 @@
        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) {
@@ -282,6 +322,8 @@
        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) {
@@ -293,6 +335,8 @@
        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) {
@@ -310,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()) {