| | |
| | | package com.ruoyi.warehouse.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.warehouse.dto.DocumentationDto; |
| | | import com.ruoyi.warehouse.pojo.Documentation; |
| | | import com.ruoyi.warehouse.pojo.DocumentationBorrowManagement; |
| | | import com.ruoyi.warehouse.service.DocumentationService; |
| | | import com.ruoyi.warehouse.mapper.DocumentationMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author 86151 |
| | |
| | | @Autowired |
| | | private DocumentationMapper documentationMapper; |
| | | @Override |
| | | public IPage<Documentation> listPage(Page page, Documentation documentation) { |
| | | public IPage<DocumentationDto> listPage(Page page, Documentation documentation) { |
| | | return documentationMapper.listPage(page, documentation); |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response) { |
| | | List<Documentation> list =documentationMapper.list(); |
| | | ExcelUtil<Documentation> util = new ExcelUtil<>(Documentation.class); |
| | | util.exportExcel(response, list, "文档信息表"); |
| | | public void export(HttpServletResponse response,Documentation documentation) { |
| | | IPage<DocumentationDto> list = documentationMapper.listPage(null, documentation); |
| | | ExcelUtil<DocumentationDto> util = new ExcelUtil<>(DocumentationDto.class); |
| | | util.exportExcel(response, list.getRecords(), "文档信息表"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteByIds(List<Long> ids) { |
| | | List<Documentation> documentationList = documentationMapper.selectList(new LambdaQueryWrapper<Documentation>().in(Documentation::getId, ids)); |
| | | for (Documentation documentation : documentationList) { |
| | | //如果文档状态是已借出,不能删除 |
| | | if ("借出".equals(documentation.getDocStatus()) || "作废".equals(documentation.getDocStatus())) { |
| | | throw new RuntimeException("当前文档状态为 " + documentation.getDocStatus() + ",不支持删除"); |
| | | } |
| | | documentationMapper.deleteById(documentation.getId()); |
| | | } |
| | | return true; |
| | | } |
| | | /** |
| | | * 列表所有文档 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DocumentationDto> listAll() { |
| | | List<DocumentationDto> list = documentationMapper.list().stream().filter(documentationDto -> "正常".equals(documentationDto.getDocStatus())).collect(Collectors.toList()); |
| | | return list; |
| | | } |
| | | /** |
| | | * 获取文档总数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getTotalDocsCount() { |
| | | return documentationMapper.countTotalDocs(); |
| | | } |
| | | /** |
| | | * 获取文档分类总数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getCategoryNumCount() { |
| | | return documentationMapper.countCategoryNum(); |
| | | } |
| | | /** |
| | | * 获取已借出文档总数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getBorrowedDocsCount() { |
| | | return documentationMapper.countBorrowedDocs(); |
| | | } |
| | | /** |
| | | * 获取每月新增文档总数 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer getMonthlyAddedDocsCount() { |
| | | return documentationMapper.countMonthlyAddedDocs(); |
| | | } |
| | | /** |
| | | * 获取文档分类分布 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getCategoryDistribution() { |
| | | return documentationMapper.countCategoryDistribution(); |
| | | } |
| | | /** |
| | | * 获取文档状态分布 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getStatusDistribution() { |
| | | return documentationMapper.countStatusDistribution(); |
| | | } |
| | | } |
| | | |