云
2026-09-29 f87ce86307056f63f79312178037cc8714eb2b13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package cn.iocoder.yudao.module.archive.service.stat;
 
import cn.iocoder.yudao.module.archive.controller.admin.stat.vo.ArchiveStatRespVO;
import cn.iocoder.yudao.module.archive.controller.admin.stat.vo.ArchiveStatValueVO;
import cn.iocoder.yudao.module.archive.dal.mysql.borrow.ArchiveBorrowMapper;
import cn.iocoder.yudao.module.archive.dal.mysql.document.ArchiveDocumentMapper;
import cn.iocoder.yudao.module.archive.enums.ArchiveCarrierTypeEnum;
import cn.iocoder.yudao.module.archive.enums.ArchiveSecretLevelEnum;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
 
import java.util.List;
 
/**
 * 档案统计 Service 实现类
 *
 * @author 超级管理员
 */
@Service
@Validated
public class ArchiveStatServiceImpl implements ArchiveStatService {
 
    @Resource
    private ArchiveDocumentMapper documentMapper;
 
    @Resource
    private ArchiveBorrowMapper borrowMapper;
 
    @Override
    public ArchiveStatRespVO getOverview() {
        ArchiveStatRespVO respVO = new ArchiveStatRespVO();
 
        // 1. 档案存量
        respVO.setTotalCount(documentMapper.selectTotalCount());
        respVO.setInStockCount(documentMapper.selectInStockCount());
        respVO.setBorrowedCount(documentMapper.selectBorrowedCount());
 
        // 2. 借阅流转(借出中 / 逾期未还,逾期实时计算)
        respVO.setBorrowingCount(borrowMapper.selectBorrowingCount());
        respVO.setOverdueCount(borrowMapper.selectOverdueCount());
 
        // 3. 分布统计(密级 / 载体补枚举名称,便于前端直接渲染)
        respVO.setByCategory(documentMapper.selectCountGroupByCategory());
        respVO.setBySecretLevel(fillSecretLevelName(documentMapper.selectCountGroupBySecretLevel()));
        respVO.setByCarrierType(fillCarrierTypeName(documentMapper.selectCountGroupByCarrierType()));
        return respVO;
    }
 
    private List<ArchiveStatValueVO> fillSecretLevelName(List<ArchiveStatValueVO> list) {
        list.forEach(item -> item.setName(ArchiveSecretLevelEnum.nameOf(item.getValue())));
        return list;
    }
 
    private List<ArchiveStatValueVO> fillCarrierTypeName(List<ArchiveStatValueVO> list) {
        list.forEach(item -> item.setName(ArchiveCarrierTypeEnum.nameOf(item.getValue())));
        return list;
    }
 
}