|
@@ -305,6 +305,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(optional.isPresent()){
|
|
|
projectVO.setDepartmentName(optional.get().getDepartmentName());
|
|
|
}
|
|
|
+ /**/
|
|
|
projectVO.setParticipator(participationMapper.getParticipator(projectVO.getId()));
|
|
|
Optional<User> first = userList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
|
|
|
if (first.isPresent()) {
|
|
@@ -978,7 +979,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
httpRespMsg.data = resultMap;
|
|
|
|
|
|
} else {
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds,null);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("cost")) {
|
|
@@ -1017,7 +1018,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//导出查询者所在公司每个项目的工时成本,包括项目人员明细统计
|
|
|
@Override
|
|
|
- public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum,Integer type, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum,Integer type,Integer deptId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
@@ -1026,12 +1027,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//当前用户管理部门
|
|
|
List<Integer> deptIds=null;
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", targetUser.getCompanyId()));
|
|
|
List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全公司");
|
|
|
List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
|
List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
//判断查看权限
|
|
|
+ List<Integer> filterDeptIds=null;
|
|
|
+ if(deptId!=null){
|
|
|
+ filterDeptIds= getBranchDepartment(deptId, allDepartmentList);
|
|
|
+ }
|
|
|
if(functionAllList.size()==0){
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -1040,11 +1046,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
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);
|
|
|
- deptIds.addAll(otherCollect);
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //没有查看全公司的权限 只能先判断当前部门/父级别是否在负责部门才能获取数据
|
|
|
+ if(deptId!=null){
|
|
|
+ Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(deptId)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ if(deptIds.contains(first.get().getSuperiorId())||deptIds.contains(deptId)){
|
|
|
+ filterDeptIds= getBranchDepartment(deptId,allDepartmentList);
|
|
|
+ }else {
|
|
|
+ filterDeptIds=new ArrayList<>();
|
|
|
+ filterDeptIds.add(-1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds);
|
|
|
+ System.out.println(filterDeptIds);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds,filterDeptIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<List<String>> allList=null ;
|
|
|
List<String> sumRow = null;
|
|
@@ -1091,7 +1113,7 @@ 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, userId);
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId, userId,deptIds,filterDeptIds);
|
|
|
map.put("membList", membList);
|
|
|
for (Map<String, Object> membMap : membList) {
|
|
|
double pTotalTime = 0;
|
|
@@ -1360,7 +1382,36 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
public HttpRespMsg getProjectCost(String startDate, String endDate, Integer projectId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId = targetUser.getCompanyId();
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
|
|
|
+ List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全公司");
|
|
|
+ List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
|
+ List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
+ List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ //判断查看权限
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ if(functionDpartList.size()>0){
|
|
|
+ if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
+ for (Department department : departmentList) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(department.getDepartmentId(), allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//首先查看有无浏览权限
|
|
|
if (!projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
|
|
|
httpRespMsg.setError("无权查看其他公司的项目详情");
|
|
@@ -1368,7 +1419,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
if (timeType.getFixMonthcost() == 0) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null);
|
|
|
+ //数据下 非负责部门人员数据不展示
|
|
|
+ List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null,deptIds,null);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("costMoney")) {
|
|
@@ -1385,7 +1437,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
endDate = endDate + "-31";
|
|
|
List<Map<String, Object>> userMonthTimeCostList = projectMapper.getUserMonthTimeCost(companyId, startDate+"-01", endDate+"-31");
|
|
|
|
|
|
- List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId, null,deptIds,null);
|
|
|
|
|
|
//检查财务表中是否已经导入成本
|
|
|
List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
|
|
@@ -4212,6 +4264,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
//当前用户管理部门
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
|
|
|
List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全公司");
|
|
@@ -4227,7 +4280,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
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);
|
|
|
- deptIds.addAll(collect);
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|