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 fillSecretLevelName(List list) { list.forEach(item -> item.setName(ArchiveSecretLevelEnum.nameOf(item.getValue()))); return list; } private List fillCarrierTypeName(List list) { list.forEach(item -> item.setName(ArchiveCarrierTypeEnum.nameOf(item.getValue()))); return list; } }