|
@@ -1029,24 +1029,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
|
List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ List<Integer> deptRelatedProjectIds = new ArrayList<>();
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
|
+
|
|
|
+ //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
|
|
|
+ List<Integer> allMyManagedDeptIds = new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ collect.addAll(otherCollect);
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ allMyManagedDeptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ if (allMyManagedDeptIds.size() > 0) {
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().select("id").in("dept_id", allMyManagedDeptIds));
|
|
|
+ deptRelatedProjectIds = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
if(functionDpartList.size()>0){
|
|
|
if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
- List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
- List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
|
|
|
- collect.addAll(otherCollect);
|
|
|
- for (Integer integer : collect) {
|
|
|
- List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
- deptIds.addAll(branchDepartment);
|
|
|
- }
|
|
|
+ deptIds.addAll(allMyManagedDeptIds);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds,null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds,null, deptRelatedProjectIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("cost")) {
|
|
@@ -1100,6 +1111,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
|
List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ List<Integer> deptRelatedProjectIds = new ArrayList<>();
|
|
|
+
|
|
|
//判断查看权限
|
|
|
List<Integer> filterDeptIds=null;
|
|
|
if(deptId!=null){
|
|
@@ -1108,16 +1121,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(functionAllList.size()==0){
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
|
- if(functionDpartList.size()>0){
|
|
|
- if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
- List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
- List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
|
|
|
- collect.addAll(otherCollect);
|
|
|
- for (Integer integer : collect) {
|
|
|
- List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
- deptIds.addAll(branchDepartment);
|
|
|
- }
|
|
|
- }
|
|
|
+ //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
|
|
|
+ List<Integer> allMyManagedDeptIds = new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ collect.addAll(otherCollect);
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ allMyManagedDeptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ if (allMyManagedDeptIds.size() > 0) {
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().select("id").in("dept_id", allMyManagedDeptIds));
|
|
|
+ deptRelatedProjectIds = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
}
|
|
|
//没有查看全公司的权限 只能先判断当前部门/父级别是否在负责部门才能获取数据
|
|
|
if(deptId!=null){
|
|
@@ -1133,7 +1148,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
System.out.println(filterDeptIds);
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds,filterDeptIds);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds,filterDeptIds,deptRelatedProjectIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<List<String>> allList=null ;
|
|
|
List<String> sumRow = null;
|
|
@@ -1180,7 +1195,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
//统计每个项目中的人员时间成本投入
|
|
|
int curProjectId = (Integer)map.get("id");
|
|
|
- List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId,stateKey, userId,deptIds,filterDeptIds);
|
|
|
+ //判断是否是当前项目的所属部门的主要或者其他负责人
|
|
|
+ List<Integer> finalDeptIds = null;
|
|
|
+ if (deptRelatedProjectIds.contains(curProjectId)) {
|
|
|
+ //有权限看该项目的全部参与人员,不需要按照部门过滤了
|
|
|
+ } else {
|
|
|
+ finalDeptIds = deptIds;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId,stateKey, userId,finalDeptIds,filterDeptIds);
|
|
|
map.put("membList", membList);
|
|
|
for (Map<String, Object> membMap : membList) {
|
|
|
double pTotalTime = 0;
|