xiangpei
2024-08-19 70dfa087a9f61ecc33f3b5bc618202c2023e38f3
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.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;
@@ -133,8 +134,26 @@
        // 获取数据日期时间
        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:
@@ -148,7 +167,6 @@
                checkScore.setExamineTag(checkScore.getExamineTag() == 2 ? 0 : 1);
                break;
        }
        return scoreMapper.selectCheckScoreMap(checkScore).stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
    }
    /**
@@ -272,6 +290,20 @@
        }
    }
    @Override
    public List<Map<String, Object>> home() {
        return baseMapper.home();
    }
    @Override
    public List<Map<String, Object>> calculate(String category) {
        Calendar calendar = Calendar.getInstance();
        Date endDate = calendar.getTime();
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        Date startDate = calendar.getTime();
        return scoreMapper.calculate(startDate, endDate, category);
    }
    //    /**
//     * 新增考核积分