Przeglądaj źródła

工时成本统计修改

yurk 2 lat temu
rodzic
commit
16007274c8

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -73,7 +73,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
 //    List<Map<String, Object>> getOvertimeList(String userId, Integer companyId, String startDate, String endDate, Integer projectId);
 
-    List<Map<String, Object>> getDegreeCost(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId, @Param("companyId") Integer companyId);
+    List<Map<String, Object>> getDegreeCost(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId, @Param("companyId") Integer companyId,List<Integer> departmentIds);
 
     //获取导出的项目数据
     List<HashMap<String, Object>> getExportData(Integer companyId, String userId);

+ 4 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -334,6 +334,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             //判断查看权限
             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());
@@ -341,9 +343,6 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                         collect.addAll(otherCollect);
                         deptIds.addAll(collect);
                     }
-                }else {
-                    //是不是要加
-                    deptIds.add(-1);
                 }
             }
             QueryWrapper<Department> queryWrapper = new QueryWrapper<Department>()
@@ -426,6 +425,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             //判断查看权限
             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().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
@@ -436,8 +436,6 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                             deptIds.addAll(branchDepartment);
                         }
                     }
-                }else {
-                    deptIds.add(-1);
                 }
             }
             //首先校验有无权限
@@ -542,6 +540,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             //判断查看权限
             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());
@@ -549,8 +548,6 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                         collect.addAll(otherCollect);
                         deptIds.addAll(collect);
                     }
-                }else {
-                    deptIds.add(-1);
                 }
             }
             List<String> allUserIds = null;

+ 44 - 40
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -770,8 +770,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
             //判断查看权限
             if(functionAllList.size()==0){
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
                 if(functionDpartList.size()>0){
-                    deptIds=new ArrayList<>();
                     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());
@@ -781,9 +782,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             deptIds.addAll(branchDepartment);
                         }
                     }
-                }else {
-                    deptIds=new ArrayList<>();
-                    deptIds.add(-1);
                 }
             }
             TimeType timeType = timeTypeMapper.selectById(companyId);
@@ -917,6 +915,7 @@ 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());
@@ -924,8 +923,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         collect.addAll(otherCollect);
                         deptIds.addAll(otherCollect);
                     }
-                }else {
-                    deptIds.add(-1);
                 }
             }
             List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds);
@@ -2285,6 +2282,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         if(functionAllList.size()==0){
             if(functionDeptList.size()>0){
                 deptIds=new ArrayList<>();
+                deptIds.add(-1);
                 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);
@@ -2292,9 +2290,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     deptIds.addAll(branchDepartment);
                 }
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,departmentId,deptIds);
@@ -2328,6 +2323,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             if(functionAllList.size()==0){
                 if(functionDeptList.size()>0){
                     deptIds=new ArrayList<>();
+                    deptIds.add(-1);
                     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);
@@ -2335,9 +2331,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                         deptIds.addAll(branchDepartment);
                     }
-                }else {
-                    deptIds=new ArrayList<>();
-                    deptIds.add(-1);
                 }
             }
             List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null,deptIds);
@@ -3016,7 +3009,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        msg.data = projectMapper.getDegreeCost(startDate, endDate, projectId, user.getCompanyId());
+        //当前用户管理部门
+        List<Integer> deptIds=null;
+        List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id", user.getCompanyId()));
+        List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司");
+        List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看负责部门");
+        List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看工时统计");
+        List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看成本统计");
+        //判断查看权限
+        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().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);
+                    }
+                }
+            }
+        }
+        msg.data = projectMapper.getDegreeCost(startDate, endDate, projectId, user.getCompanyId(),deptIds);
         return msg;
     }
 
@@ -3329,8 +3347,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
         //判断查看权限
         if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
             if(functionDeptList.size()>0){
-                deptIds=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);
@@ -3339,9 +3358,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     deptIds.addAll(branchDepartment);
                 }
 
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null,deptIds);
@@ -3730,8 +3746,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
             //判断查看权限
             if(functionAllList.size()==0){
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
                 if(functionDpartList.size()>0){
-                    deptIds=new ArrayList<>();
                     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());
@@ -3741,9 +3758,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             deptIds.addAll(branchDepartment);
                         }
                     }
-                }else {
-                    deptIds=new ArrayList<>();
-                    deptIds.add(-1);
                 }
             }
             TimeType timeType = timeTypeMapper.selectById(companyId);
@@ -3877,6 +3891,7 @@ 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());
@@ -3884,8 +3899,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         collect.addAll(otherCollect);
                         deptIds.addAll(collect);
                     }
-                }else {
-                    deptIds.add(-1);
                 }
             }
             List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, projectCategoryId, userId,deptIds);
@@ -4023,8 +4036,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
         //判断查看权限
         if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
             if(functionDeptList.size()>0){
-                deptIds=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);
@@ -4032,9 +4046,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     deptIds.addAll(branchDepartment);
                 }
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,departmentId,deptIds);
@@ -4067,8 +4078,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
         //判断查看权限
         if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
             if(functionDeptList.size()>0){
-                deptIds=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);
@@ -4076,9 +4088,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     deptIds.addAll(branchDepartment);
                 }
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,null,deptIds);
@@ -4124,8 +4133,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
         //判断查看权限
         if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
             if(functionDeptList.size()>0){
-                deptIds=new ArrayList<>();
                 List<Integer> collect = userDepartmentList.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);
@@ -4133,10 +4143,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     deptIds.addAll(branchDepartment);
                 }
-
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         List<Map<String,Object>> reportList=reportMapper.getUserReportTimelinessRate(targetUser.getCompanyId(),startDate,endDate);
@@ -4364,8 +4370,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
         //判断查看权限
         if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
             if(functionDeptList.size()>0){
-                deptIds=new ArrayList<>();
                 List<Integer> collect = userDepartmentList.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);
@@ -4373,9 +4380,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     deptIds.addAll(branchDepartment);
                 }
-            }else {
-                deptIds=new ArrayList<>();
-                deptIds.add(-1);
             }
         }
         long total;

+ 12 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -157,6 +157,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private ReportLogMapper reportLogMapper;
     @Resource
     private ThirdPartyInterfaceMapper thirdPartyInterfaceMapper;
+    @Resource
+    private DepartmentOtherManagerMapper departmentOtherManagerMapper;
 
     @Value(value = "${upload.path}")
     private String path;
@@ -217,13 +219,22 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 if (hasDeptWorktimePriv || (user.getManageDeptId() != null &&  user.getManageDeptId() > 0)) {
                     //找到该部门的所有子部门
                     List<Department> allDepts = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-                    //查找当前部门经理负责的部门
+                    //查找当前部门经理负责的部门 或者作为其他负责人的部分
                     List<Department> queryDeptList = null;
                     if (deptId != null) {
                         queryDeptList = allDepts.stream().filter(dp->dp.getDepartmentId().equals(deptId)).collect(Collectors.toList());
                     } else {
                         queryDeptList = allDepts.stream().filter(
                                 dp -> user.getId().equals(dp.getManagerId()) || (hasDeptWorktimePriv && dp.getDepartmentId().equals(user.getDepartmentId()))).collect(Collectors.toList());
+                        List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        for (Integer integer : otherCollect) {
+                            Optional<Department> first = allDepts.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
+                            if(first.isPresent()){
+                                queryDeptList.add(first.get());
+                            }
+                        }
+
                     }
 
                     if (queryDeptList.size() > 0) {

+ 7 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/DepartmentMapper.xml

@@ -24,10 +24,12 @@
         SELECT SUM(b.working_time) AS time, SUM(b.cost) AS money
         FROM report AS b
         WHERE b.state = 1
-        AND b.dept_id IN
-        <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
-            #{departmentId}
-        </foreach>
+        <if test="departmentIds != null and departmentIds.size()>0">
+            AND b.dept_id IN
+            <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
+                #{departmentId}
+            </foreach>
+        </if>
         <if test="startDate != null and endDate != null">
             AND b.create_date between #{startDate} and #{endDate}
         </if>
@@ -41,7 +43,7 @@
         LEFT JOIN report AS b ON a.id = b.creator_id
         LEFT JOIN project AS c ON b.project_id = c.id
         WHERE b.state = 1
-        <if test="departmentIds != null">
+        <if test="departmentIds != null and departmentIds.size()>0">
             AND b.dept_id IN
             <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
                 #{departmentId}

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -662,6 +662,12 @@
         WHERE
         a.state = 1
         and a.company_id = #{companyId}
+        <if test="departmentIds!=null and departmentIds.size()>0">
+            and a.dept_id in
+            <foreach collection="departmentIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         <if test="projectId != null">
             and a.project_id = #{projectId}
         </if>