|
|
@@ -9,6 +9,7 @@ import com.tuoheng.admin.entity.InspectionFile; |
|
|
|
import com.tuoheng.admin.entity.InspectionFileHandle; |
|
|
|
import com.tuoheng.admin.entity.Report; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.DataPermissionEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.request.report.QueryReportPageListRequest; |
|
|
@@ -73,21 +74,30 @@ public class QueryReportPageListService { |
|
|
|
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); |
|
|
|
// 用户只能查看自己生成的报告 或者是当前租户下自动生成的报告 |
|
|
|
//request.setCreateUser(userId); |
|
|
|
|
|
|
|
// 查询结果 |
|
|
|
IPage<Report> pageData = reportMapper.selectPageList(page, request); |
|
|
|
|
|
|
|
if (null == pageData || pageData.getTotal() == 0) { |
|
|
|
log.info("获取任务分页列表为空"); |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
List<Report> reportList = pageData.getRecords(); |
|
|
|
|
|
|
|
List<Report> reportsData = new ArrayList<>(); |
|
|
|
for (Report report : reportList) { |
|
|
|
if(report.getCreateUser().equals(userId) || report.getAutoGenerate() == 2){ |
|
|
|
reportsData.add(report); |
|
|
|
} |
|
|
|
|
|
|
|
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { |
|
|
|
reportsData = this.getAllList(reportList); |
|
|
|
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { |
|
|
|
reportsData = this.getListByDepts(reportList, user); |
|
|
|
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { |
|
|
|
reportsData = this.getListByDept(reportList, user); |
|
|
|
} |
|
|
|
if(CollectionUtil.isEmpty(reportsData) || reportsData.size() == 0){ |
|
|
|
return JsonResult.success(pageData); |
|
|
|
} |
|
|
|
|
|
|
|
// 构造返回结果对象 |
|
|
|
List<ReportPageListVo> reportPageListVoList = this.buildReportPageListVoList(reportsData); |
|
|
|
|
|
|
|
// 重写返回结果对象 |
|
|
|
IPage<ReportPageListVo> reportVoPageData = new Page<>(); |
|
|
|
reportVoPageData.setPages(pageData.getPages()); |
|
|
@@ -99,6 +109,26 @@ public class QueryReportPageListService { |
|
|
|
return JsonResult.success(reportVoPageData); |
|
|
|
} |
|
|
|
|
|
|
|
//本租户下报告数据 |
|
|
|
private List<Report> getAllList(List<Report> reportList) { |
|
|
|
return reportList; |
|
|
|
} |
|
|
|
|
|
|
|
//当前部门及子孙部门报告数据 |
|
|
|
private List<Report> getListByDepts(List<Report> reportList, User user) { |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
List<String> deptIdList = deptMapper.selectAllChildListById(deptId); |
|
|
|
List<Report> collect = reportList.stream().filter((Report r) -> deptIdList.contains(r.getDeptId())).collect(Collectors.toList()); |
|
|
|
return collect; |
|
|
|
} |
|
|
|
|
|
|
|
//当前部门报告数据 |
|
|
|
private List<Report> getListByDept(List<Report> reportList, User user) { |
|
|
|
String deptId = user.getDeptId(); |
|
|
|
List<Report> collect = reportList.stream().filter(x -> x.getDeptId().equals(deptId)).collect(Collectors.toList()); |
|
|
|
return collect; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查参数 |
|
|
|
* |