增加文件统计后端

This commit is contained in:
晴朗 2024-08-31 17:58:10 +08:00
parent 2561546ac2
commit 7820d4907f
5 changed files with 74 additions and 3 deletions

View File

@ -110,4 +110,14 @@ public class DocumentController extends BaseController
{
return toAjax(documentService.pushDoc(ids));
}
/**
* 文档统计涉及文档类别统计文档来源统计
*/
@GetMapping("/statistics")
public AjaxResult statistics()
{
return AjaxResult.success(documentService.statistics());
}
}

View File

@ -3,6 +3,7 @@ package com.rzdata.web.mapper;
import com.rzdata.web.domain.Document;
import java.util.List;
import java.util.Map;
/**
* 请填写功能名称Mapper接口
@ -63,4 +64,8 @@ public interface DocumentMapper
public int updatePushDoc(Document doc);
public int batchDeleteById(List<String> list);
List<Map<String, Object>> countType();
List<Map<String, Object>> countSource();
}

View File

@ -3,6 +3,7 @@ package com.rzdata.web.service;
import com.rzdata.web.domain.Document;
import java.util.List;
import java.util.Map;
/**
* 请填写功能名称Service接口
@ -74,4 +75,6 @@ public interface IDocumentService
int pushDoc(String[] ids);
public int batchDeleteById(List<String> docIds);
Map<String, Object> statistics();
}

View File

@ -5,8 +5,10 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.core.domain.entity.SysDictData;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.system.service.ISysDictTypeService;
import com.rzdata.web.domain.Attachment;
import com.rzdata.web.domain.Document;
import com.rzdata.web.domain.Tool;
@ -16,9 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -37,6 +37,9 @@ public class DocumentServiceImpl implements IDocumentService
@Autowired
private ToolServiceImpl toolService;
@Autowired
private ISysDictTypeService sysDictTypeService;
/**
* 查询请填写功能名称
*
@ -236,5 +239,45 @@ public class DocumentServiceImpl implements IDocumentService
public int batchDeleteById(List<String> docIds){
return documentMapper.batchDeleteById(docIds);
}
@Override
public Map<String, Object> statistics() {
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> countType = this.documentMapper.countType();
List<Map<String, Object>> countSource = this.documentMapper.countSource();
//组织数据
assembleData(countType, countSource);
result.put("countType", countType);
result.put("countSource", countSource);
return result;
}
private void assembleData(List<Map<String, Object>> countType, List<Map<String, Object>> countSource) {
//
List<SysDictData> toolTypeList = sysDictTypeService.selectDictDataByType("doc_class");
List<SysDictData> toolSourceList = sysDictTypeService.selectDictDataByType("doc_source");
if(CollUtil.isNotEmpty(countType)){
for (Map<String, Object> map : countType) {
map.put("value", map.get("statistics"));
for (SysDictData sysDictData : toolTypeList) {
if(sysDictData.getDictValue().equals(map.get("types"))){
map.put("name", sysDictData.getDictLabel());
break;
}
}
}
}
if(CollUtil.isNotEmpty(countSource)){
for (Map<String, Object> map : countSource) {
map.put("value", map.get("statistics"));
for (SysDictData sysDictData : toolSourceList) {
if(sysDictData.getDictValue().equals(map.get("types"))){
map.put("name", sysDictData.getDictLabel());
break;
}
}
}
}
}
}

View File

@ -163,4 +163,14 @@
</foreach>
</delete>
<!-- 文档类型统计-->
<select id="countType" resultType="java.util.Map">
select t.doc_type as types, sum(1) as statistics from t_document t where t.is_deleted = '0' group by t.doc_type;
</select>
<!-- 文档来源统计-->
<select id="countSource" resultType="java.util.Map">
select t.doc_source as types, sum(1) as statistics from t_document t where t.is_deleted = '0' group by t.doc_source;
</select>
</mapper>