Browse Source

工时成本统计修改 主项目接口编辑

yurk 2 years ago
parent
commit
64012296f9
15 changed files with 805 additions and 255 deletions
  1. 15 10
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java
  2. 60 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectMainController.java
  3. 14 8
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Project.java
  4. 52 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ProjectMain.java
  5. 7 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java
  6. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMainMapper.java
  7. 9 13
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java
  8. 20 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectMainService.java
  9. 7 4
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  10. 141 39
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java
  11. 72 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectMainServiceImpl.java
  12. 282 84
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  13. 20 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMainMapper.xml
  14. 88 95
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  15. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml

+ 15 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -103,11 +103,12 @@ public class ProjectController {
                                    Integer taskGpIncharge,
                                    String auditUserIds,
                                    Integer category,
-                                   String projectDesc
+                                   String projectDesc,
+                                   Integer projectMainId
                                    ) {
         return projectService.editProject(id, name, code, userId, inchargerId, isPublic, planStartDate, planEndDate, level, contractAmount,
                 projectBaseCostData,
-                 budget,customerId,chosenLeaders, associateDegrees, associateDegreeNames, taskGpIncharge,auditUserIds, category, projectDesc, request);
+                 budget,customerId,chosenLeaders, associateDegrees, associateDegreeNames, taskGpIncharge,auditUserIds, category, projectDesc,projectMainId, request);
     }
 
     @RequestMapping("/adjustBase")
@@ -365,8 +366,8 @@ public class ProjectController {
      * @return
      */
     @RequestMapping("/getOvertimeList")
-    public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate) {
-        return projectService.getOvertimeList(userId, projectId, startDate, endDate, request);
+    public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate,Integer departmentId) {
+        return projectService.getOvertimeList(userId, projectId, startDate, endDate, request,departmentId);
     }
 
     /**
@@ -404,8 +405,8 @@ public class ProjectController {
      * @return
      */
     @RequestMapping("/getUserWorkingTimeList")
-    public HttpRespMsg getUserWorkingTimeList(String userId,Integer projectId,String startDate, String endDate,Integer pageIndex,Integer pageSize){
-        return projectService.getUserWorkingTimeList(userId,projectId,startDate,endDate,pageIndex,pageSize,request);
+    public HttpRespMsg getUserWorkingTimeList(String userId,Integer projectId,String startDate, String endDate,Integer pageIndex,Integer pageSize,Integer departmentId){
+        return projectService.getUserWorkingTimeList(userId,projectId,startDate,endDate,pageIndex,pageSize,request,departmentId);
     }
 
     @RequestMapping("/exportUserWorkingTimeList")
@@ -497,12 +498,16 @@ public class ProjectController {
         return projectService.exportReportTimelinessRate(request,startDate,endDate);
     }
     @RequestMapping("/getWaitingReviewList")
-    public HttpRespMsg getWaitingReviewList(HttpServletRequest request,Integer stateKey,String userId,Integer departmentId,Integer projectId,Integer pageIndex,Integer pageSize,String startDate,String endDate){
-        return projectService.getWaitingReviewList(request,stateKey,userId,departmentId,projectId,pageIndex,pageSize,startDate,endDate);
+    public HttpRespMsg getWaitingReviewList(HttpServletRequest request,Integer stateKey,String userId,Integer pageIndex,Integer pageSize,String startDate,String endDate){
+        return projectService.getWaitingReviewList(request,stateKey,userId,pageIndex,pageSize,startDate,endDate);
     }
     @RequestMapping("/exportWaitingReviewList")
-    public HttpRespMsg exportWaitingReviewList(HttpServletRequest request,Integer stateKey,String userId,Integer departmentId,Integer projectId,String startDate,String endDate){
-        return projectService.exportWaitingReviewList(request,stateKey,userId,departmentId,projectId,startDate,endDate);
+    public HttpRespMsg exportWaitingReviewList(HttpServletRequest request,Integer stateKey,String userId,String startDate,String endDate){
+        return projectService.exportWaitingReviewList(request,stateKey,userId,startDate,endDate);
+    }
+    @RequestMapping("/batchSetParticipation")
+    public HttpRespMsg batchSetParticipation(HttpServletRequest request,Integer[] projectIdArray,String[] userIds){
+        return projectService.batchSetParticipation(request,projectIdArray,userIds);
     }
 }
 

+ 60 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectMainController.java

@@ -0,0 +1,60 @@
+package com.management.platform.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.Project;
+import com.management.platform.entity.ProjectMain;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.ProjectMainService;
+import com.management.platform.service.ProjectService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-06-28
+ */
+@RestController
+@RequestMapping("/project-main")
+public class ProjectMainController {
+    @Autowired
+    private ProjectMainService projectMainService;
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private ProjectService projectService;
+    @RequestMapping("/addOrMod")
+    public HttpRespMsg addOrMod(HttpServletRequest request,ProjectMain projectMain){
+       return projectMainService.addOrMod(request,projectMain);
+    }
+    @RequestMapping("/list")
+    public HttpRespMsg list(HttpServletRequest request){
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        List<ProjectMain> projectMainList = projectMainService.list(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
+        httpRespMsg.data=projectMainList;
+        return httpRespMsg;
+    }
+    @RequestMapping("/delete")
+    public HttpRespMsg delete(Integer id){
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        int cut = projectService.count(new QueryWrapper<Project>().eq("project_main_id", id));
+        if(cut>0){
+            httpRespMsg.setError("已绑定项目");
+            return httpRespMsg;
+        }
+        projectMainService.removeById(id);
+        return httpRespMsg;
+    }
+}
+

+ 14 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Project.java

@@ -1,27 +1,27 @@
 package com.management.platform.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDate;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
+import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 
  * </p>
  *
  * @author Seyason
- * @since 2022-04-22
+ * @since 2022-06-28
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -257,6 +257,12 @@ public class Project extends Model<Project> {
     @TableField("project_desc")
     private String projectDesc;
 
+    /**
+     * 主项目id
+     */
+    @TableField("project_main_id")
+    private Integer projectMainId;
+
 
     @Override
     protected Serializable pkVal() {

+ 52 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ProjectMain.java

@@ -0,0 +1,52 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-06-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class ProjectMain extends Model<ProjectMain> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @TableField("category_id")
+    private Integer categoryId;
+
+    @TableField("category_name")
+    private String categoryName;
+
+    @TableField("code")
+    private String code;
+
+    @TableField("name")
+    private String name;
+
+    @TableField("company_id")
+    private Integer companyId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java

@@ -17,7 +17,7 @@ import java.util.List;
  * </p>
  *
  * @author Seyason
- * @since 2022-06-27
+ * @since 2022-06-28
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -266,6 +266,12 @@ public class TimeType extends Model<TimeType> {
     @TableField("timeliness")
     private Integer timeliness;
 
+    /**
+     * 0-未开启 1-开启
+     */
+    @TableField("main_project_state")
+    private Integer mainProjectState;
+
     @TableField(exist = false)
     private List<User> userList;
 

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMainMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.ProjectMain;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-06-28
+ */
+public interface ProjectMainMapper extends BaseMapper<ProjectMain> {
+
+}

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

@@ -25,7 +25,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> getOnlyJoinProjects(@Param("userId") String userId, @Param("companyId") Integer companyId);
 
     List<Map<String, Object>> getTimeCost(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate,
-        @Param("projectId") Integer projectId, @Param("userId") String userId);
+        @Param("projectId") Integer projectId, @Param("userId") String userId,@Param("deptIds")List<Integer> deptIds);
 
     List<Map<String, Object>> getCustomDataSum(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate,
                                           @Param("projectId") Integer projectId, @Param("userId") String userId);
@@ -67,7 +67,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<ProjectWithStage> selectWithStage(Integer companyId, Integer startIndex, Integer endIndex, Integer projectId);
 
     List<Map<String, Object>> getTimeCostReport(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate,
-                                          @Param("projectId") Integer projectId);
+                                          @Param("projectId") Integer projectId,@Param("deptIds")List<Integer> deptIds);
 
     List<Map<String, Object>> getUserMonthTimeCost(@Param("companyId") Integer companyId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
@@ -78,30 +78,26 @@ public interface ProjectMapper extends BaseMapper<Project> {
     //获取导出的项目数据
     List<HashMap<String, Object>> getExportData(Integer companyId, String userId);
 
-    List<Map<String, Object>> getOvertimeDetail(String userId, Integer companyId, String startDate, String endDate, Integer projectId);
+    List<Map<String, Object>> getOvertimeDetail(String userId, Integer companyId, String startDate, String endDate, Integer projectId,Integer departmentId);
 
     //获取项目的成本预警和实际工时表
     List<HashMap> getProjectCostAlarm(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId);
 
     List getBaseCostAndRealCost(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId);
 
-    List<Map<String, Object>> getProjectCostGroupByProject(Integer companyId, String startDate, String endDate, Integer projectId,String userId);
+    List<Map<String, Object>> getProjectCostGroupByProject(Integer companyId, String startDate, String endDate, Integer projectId,String userId,List<Integer> deptIds);
 
-    List<Map<String, Object>> getTimeCostByCategory(Integer companyId, String startDate, String endDate, Integer projectCategoryId, String userId);
+    List<Map<String, Object>> getTimeCostByCategory(Integer companyId, String startDate, String endDate, Integer projectCategoryId, String userId,List<Integer> deptIds);
 
-    List<Map<String, Object>> getProjectCostGroupByCategory(Integer companyId, String startDate, String endDate, Integer projectCategoryId,String userId);
+    List<Map<String, Object>> getProjectCostGroupByCategory(Integer companyId, String startDate, String endDate, Integer projectCategoryId,String userId,List<Integer> deptIds);
 
     List<Map<String, Object>> getProjectCostByCategory(Integer companyId, String startDate, String endDate, Integer curProjectCategoryId, String userId);
 
-    List<Map<String, Object>> getUserWorkingTimeList(String userId, Integer companyId, String startDate, String endDate, Integer projectId, Integer start, Integer size);
+    List<Map<String, Object>> getUserWorkingTimeList(String userId, Integer companyId, String startDate, String endDate, Integer projectId, Integer start, Integer size,Integer departmentId);
 
     long findCountWithUser(String userId, Integer companyId, String startDate, String endDate, Integer projectId, Integer start,Integer size);
 
-    List<Map<String, Object>> getWaitingReviewListByDepartment(Integer companyId, String userId, Integer departmentId,Integer start,Integer size,String startDate,String endDate);
+    List<Map<String, Object>> getWaitingReviewList(Integer companyId, String userId,Integer start,Integer size,String startDate,String endDate);
 
-    List<Map<String, Object>> getWaitingReviewListByProject(Integer companyId, String userId, Integer projectId,Integer start,Integer size,String startDate,String endDate);
-
-    long findCountWithDepartment(Integer companyId, String userId, Integer departmentId, Integer start, Integer size,String startDate,String endDate);
-
-    long findCountWithProject(Integer companyId, String userId, Integer projectId, Integer start, Integer size,String startDate,String endDate);
+    long findCount(Integer companyId, String userId, Integer start, Integer size,String startDate,String endDate);
 }

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectMainService.java

@@ -0,0 +1,20 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.ProjectMain;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.util.HttpRespMsg;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-06-28
+ */
+public interface ProjectMainService extends IService<ProjectMain> {
+
+    HttpRespMsg addOrMod(HttpServletRequest request,ProjectMain projectMain);
+}

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

@@ -38,6 +38,7 @@ public interface ProjectService extends IService<Project> {
                             String auditUserIds,
                             Integer category,
                             String projectDesc,
+                            Integer projectMainId,
                             HttpServletRequest request);
 
     HttpRespMsg deleteProject(Integer id, Integer force);
@@ -94,7 +95,7 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg exportProjectStagesCost( HttpServletRequest request);
 
-    HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request);
+    HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request,Integer departmentId);
 
     HttpRespMsg exportOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request);
 
@@ -132,7 +133,7 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg exportTimeCostByCategory(String startDate, String endDate, Integer projectCategoryId, String userId, Boolean projectSum, Integer type, HttpServletRequest request);
 
-    HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request);
+    HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request,Integer departmentId);
 
     HttpRespMsg exportUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate,HttpServletRequest request);
 
@@ -140,7 +141,9 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg exportReportTimelinessRate(HttpServletRequest request, String startDate, String endDate);
 
-    HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId,Integer projectId,Integer pageIndex,Integer pageSize,String startDate,String endDate);
+    HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,Integer pageIndex,Integer pageSize,String startDate,String endDate);
 
-    HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId, Integer projectId,String startDate,String endDate);
+    HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,String startDate,String endDate);
+
+    HttpRespMsg batchSetParticipation(HttpServletRequest request,Integer[] projectIdArray,String[] userIds);
 }

+ 141 - 39
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -265,7 +265,27 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     public HttpRespMsg getDepartmentStatistics(Integer parentDeptId, String startDate, String endDate, 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<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
             QueryWrapper<Department> queryWrapper = new QueryWrapper<Department>()
                     .eq("company_id", companyId);
             if (parentDeptId == null) {
@@ -273,6 +293,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             } else {
                 queryWrapper.eq("superior_id", parentDeptId);
             }
+            if(deptIds!=null){
+                queryWrapper.in("department_id",deptIds);
+            }
             //获取第一级部门
             List<Department> masterList = departmentMapper.selectList(queryWrapper);
             Map<String, Object> resultMap = new HashMap<>();
@@ -299,6 +322,17 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             }
             resultMap.put("totalCostMoney", totalCostMoney);
             resultMap.put("costList", list);
+            if(functionCostList.size()==0){
+                resultMap.put("totalCostMoney",null);
+                list.forEach(li->{
+                    li.setCostMoney(null);
+                });
+            }
+            if(functionTimeList.size()==0){
+                list.forEach(li->{
+                    li.setCostTime(null);
+                });
+            }
             httpRespMsg.data = resultMap;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
@@ -313,9 +347,28 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     public HttpRespMsg getUserStatistics(String startDate, String endDate, Integer departmentId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
-            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
-
-            List<Integer> deptIds = null;
+            User targetUser = userMapper.selectById(request.getHeader("Token"));
+            Integer companyId =targetUser.getCompanyId();
+            Map<String, Object> resultMap = new HashMap<>();
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
             //首先校验有无权限
             if (departmentId != null) {
                 if (departmentMapper.selectCount(new QueryWrapper<Department>()
@@ -376,8 +429,24 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             finalMap.put("totalCostMoney", totalCostMoney);
             finalMap.put("list", finalList);
             finalMap.put("userList", userList);
+            if(functionCostList.size()==0){
+                finalMap.put("totalCostMoney",null);
+                finalList.forEach(li->{
+                    List<Map<String,Object>> mapList= (List<Map<String, Object>>) li.get("project");
+                    mapList.forEach(ml->{
+                        ml.put("money",null);
+                    });
+                });
+            }
+            if(functionTimeList.size()==0){
+                finalList.forEach(li->{
+                    List<Map<String,Object>> mapList= (List<Map<String, Object>>) li.get("project");
+                    mapList.forEach(ml->{
+                        ml.put("time",null);
+                    });
+                });
+            }
             httpRespMsg.data = finalMap;
-
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
             return httpRespMsg;
@@ -389,7 +458,27 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     public HttpRespMsg exportUserStatistic(String startDate, String endDate, String userIds, 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<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
             List<String> allUserIds = null;
             if (userIds != null) {
                 allUserIds = ListUtil.convertLongIdsArrayToList(userIds);
@@ -399,7 +488,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             User user = userMapper.selectById(request.getHeader("TOKEN"));
 
             List<Map<String, Object>> list = departmentMapper
-                    .getCostByUser(null, startDate, endDate, companyId, allUserIds);
+                    .getCostByUser(deptIds, startDate, endDate, companyId, allUserIds);
             Map<String, List<Map<String, Object>>> tempMap = new HashMap<>();
             List<String> names = new ArrayList<>();
             BigDecimal totalCostMoney = new BigDecimal(0);
@@ -436,8 +525,15 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
 //            List<Map<String, Object>> finalList = new ArrayList<>();
             DecimalFormat df = new DecimalFormat("#0.00");
             List<List<String>> dataList = new ArrayList<List<String>>();
-            String[] titles = {"人员", "项目", "工时(h)", "成本(元)"};
-            List<String> titleList = Arrays.asList(titles.clone());
+            List<String> titleList =new ArrayList<>();
+            titleList.add("人员");
+            titleList.add("项目");
+            if(functionTimeList.size()>0){
+                titleList.add("工时");
+            }
+            if(functionCostList.size()>0){
+                titleList.add("成本");
+            }
             dataList.add(titleList);
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             double totalCostTime = 0;
@@ -458,8 +554,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 }
                 totalMoneyCost = totalMoneyCost.add(tCost);
                 totalCostTime += tTime;
-                nameList.add(df.format(tTime));
-                nameList.add(tCost.setScale(2, BigDecimal.ROUND_UP).toString());
+                if(functionTimeList.size()>0){
+                    nameList.add(df.format(tTime));
+                }
+                if(functionCostList.size()>0){
+                    nameList.add(tCost.setScale(2, BigDecimal.ROUND_UP).toString());
+                }
                 dataList.add(nameList);
                 //装载该人员下的项目的工时数据
                 for (Map<String, Object> membData : tempList) {
@@ -468,8 +568,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                     List<String> projectDataList = new ArrayList<>();
                     projectDataList.add("");
                     projectDataList.add(membData.get("project")+"");
-                    projectDataList.add(df.format((double)membData.get("time"))+"");
-                    projectDataList.add(((BigDecimal)membData.get("money")).setScale(2, BigDecimal.ROUND_UP).toString());
+                    if(functionTimeList.size()>0){
+                        projectDataList.add(df.format((double)membData.get("time"))+"");
+                    }
+                    if(functionCostList.size()>0){
+                        projectDataList.add(((BigDecimal)membData.get("money")).setScale(2, BigDecimal.ROUND_UP).toString());
+                    }
                     dataList.add(projectDataList);
                 }
             }
@@ -478,8 +582,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             List<String> sumRow = new ArrayList<String>();
             sumRow.add("合计");
             sumRow.add("");
-            sumRow.add(""+df.format(totalCostTime));
-            sumRow.add(total);
+            if(functionTimeList.size()>0){
+                sumRow.add(""+df.format(totalCostTime));
+            }
+            if(functionCostList.size()>0){
+                sumRow.add(total);
+            }
             dataList.add(sumRow);
             //生成excel文件导出
             String fileName = "人员成本统计_"+System.currentTimeMillis();
@@ -652,33 +760,27 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     public HttpRespMsg exportDeptStatistic(String startDate, String endDate, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
-            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
-            User user = userMapper.selectById(request.getHeader("TOKEN"));
-            List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
-            boolean hasDeptWorktimePriv = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看本部门工时").size() > 0;
-            List<Integer> deptIds = null;
-            if (functionList.size() == 0) {
-                deptIds = new ArrayList<>();
-                deptIds.add(-1);
-                if (hasDeptWorktimePriv || (user.getManageDeptId() != null && user.getManageDeptId() != 0)) {
-                    //有负责的部门
-                    List<Department> myDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()));
-                    List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-                    if (hasDeptWorktimePriv && user.getDepartmentId() != null) {
-                        Department ownerDept = departmentMapper.selectById(user.getDepartmentId());
-                        //要加上自己的部门,如果没有的话
-                        if (!myDeptList.stream().anyMatch(d->d.getDepartmentId().equals(ownerDept.getDepartmentId()))) {
-                            myDeptList.add(ownerDept);
-                        }
-                    }
-
-                    for (Department dept: myDeptList) {
-                        deptIds.add(dept.getDepartmentId());
-                        deptIds.addAll(getBranchDepartment(dept.getDepartmentId(), allDeptList));
+            User targetUser = userMapper.selectById(request.getHeader("Token"));
+            Integer companyId =targetUser.getCompanyId();
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
                     }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
                 }
             }
-
             System.out.println("获取到管理的部门ids length=="+deptIds);
             List<Map<String, Object>> list = departmentMapper
                     .getCostByUser(deptIds, startDate, endDate, companyId, null);

+ 72 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectMainServiceImpl.java

@@ -0,0 +1,72 @@
+package com.management.platform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.entity.ProjectCategory;
+import com.management.platform.entity.ProjectMain;
+import com.management.platform.mapper.ProjectCategoryMapper;
+import com.management.platform.mapper.ProjectMainMapper;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.ProjectMainService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-06-28
+ */
+@Service
+public class ProjectMainServiceImpl extends ServiceImpl<ProjectMainMapper, ProjectMain> implements ProjectMainService {
+
+    @Resource
+    private ProjectMainMapper projectMainMapper;
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private ProjectCategoryMapper projectCategoryMapper;
+    @Override
+    public HttpRespMsg addOrMod(HttpServletRequest request,ProjectMain projectMain) {
+        HttpRespMsg httpRespMsg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        projectMain.setCompanyId(companyId);
+        ProjectCategory projectCategory = projectCategoryMapper.selectById(projectMain.getCategoryId());
+        projectMain.setCategoryName(projectCategory.getName());
+        if(projectMain.getId()!=null){
+            Integer count = projectMainMapper.selectCount(new QueryWrapper<ProjectMain>().eq("company_id", projectMain.getCompanyId())
+                    .eq("code", projectMain.getCode()).ne("id", projectMain.getId()));
+            Integer count1 = projectMainMapper.selectCount(new QueryWrapper<ProjectMain>().eq("company_id", projectMain.getCompanyId())
+                    .eq("name", projectMain.getName()).ne("id", projectMain.getId()));
+            if(count>0){
+                httpRespMsg.setError("编号重复");
+                return httpRespMsg;
+            }
+            if(count1>0){
+                httpRespMsg.setError("名称重复");
+                return httpRespMsg;
+            }
+            projectMainMapper.updateById(projectMain);
+        }else {
+            Integer count2 = projectMainMapper.selectCount(new QueryWrapper<ProjectMain>().eq("company_id", projectMain.getCompanyId())
+                    .eq("code", projectMain.getCode()));
+            Integer count3 = projectMainMapper.selectCount(new QueryWrapper<ProjectMain>().eq("company_id", projectMain.getCompanyId())
+                    .eq("name", projectMain.getName()));
+            if(count2>0){
+                httpRespMsg.setError("编号重复");
+                return httpRespMsg;
+            }
+            if(count3>0){
+                httpRespMsg.setError("名称重复");
+                return httpRespMsg;
+            }
+            projectMainMapper.insert(projectMain);
+        }
+        return httpRespMsg;
+    }
+}

+ 282 - 84
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -254,6 +254,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                    String auditUserIds,
                                    Integer category,
                                    String projectDesc,
+                                   Integer projectMainId,
                                    HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("Token"));
@@ -308,6 +309,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             .setAssociateDegreeNames(associateDegreeNames)
                             .setCustomerId(customerId)
                             .setProjectDesc(projectDesc)
+                            .setProjectMainId(projectMainId)
                             .setTaskGpIncharge(taskGpIncharge);
                     if (category != null) {
                         ProjectCategory projectCategory = projectCategoryMapper.selectById(category);
@@ -375,6 +377,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         .setAssociateDegreeNames(associateDegreeNames)
                         .setCustomerId(customerId)
                         .setProjectDesc(projectDesc)
+                        .setProjectMainId(projectMainId)
                         .setTaskGpIncharge(taskGpIncharge);
                 if (category != null) {
                     ProjectCategory projectCategory = projectCategoryMapper.selectById(category);
@@ -646,13 +649,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
-            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            User targetUser = userMapper.selectById(request.getHeader("Token"));
+            Integer companyId =targetUser.getCompanyId();
             Map<String, Object> resultMap = new HashMap<>();
-
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
             TimeType timeType = timeTypeMapper.selectById(companyId);
             if (timeType.getFixMonthcost() == 1) {
                 //每月固定月薪的方式计算,平摊到各个项目中
-                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null);
+                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
                 //检查财务表中是否已经导入成本
                 List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -710,10 +732,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
                 resultMap.put("costList", retList);
                 resultMap.put("totalMoneyCost", totalMoneyCost);
+                if(functionCostList.size()==0){
+                    resultMap.put("totalCostMoney",null);
+                    list.forEach(li->{
+                        li.put("costMoney",null);
+                    });
+                }
+                if(functionTimeList.size()==0){
+                    retList.forEach(li->{
+                        li.put("cost",null);
+                    });
+                }
                 httpRespMsg.data = resultMap;
 
             } else {
-                List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId);
+                List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds);
                 BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
                 for (Map<String, Object> map : list) {
                     if (!map.containsKey("cost")) {
@@ -728,14 +761,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
                 resultMap.put("costList", list);
                 resultMap.put("totalMoneyCost", totalMoneyCost);
+                if(functionCostList.size()==0){
+                    resultMap.put("totalCostMoney",null);
+                    list.forEach(li->{
+                        li.put("costMoney",null);
+                    });
+                }
+                if(functionTimeList.size()==0){
+                    list.forEach(li->{
+                        li.put("cost",null);
+                    });
+                }
                 httpRespMsg.data = resultMap;
             }
-
-
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");
             return httpRespMsg;
         }
+
         return httpRespMsg;
     }
 
@@ -744,9 +787,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum,Integer type, 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();
             Map<String, Object> resultMap = new HashMap<>();
-            List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId);
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
+            List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds);
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             List<List<String>> allList=null ;
             List<String> sumRow = null;
@@ -757,8 +820,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 headList.add("项目分类");
                 headList.add("人员");
                 headList.add("部门");
-                headList.add("工时(h)");
-                headList.add("成本(元)");
+                if(functionTimeList.size()>0){
+                    headList.add("工时(h)");
+                }
+                if(functionCostList.size()>0){
+                    headList.add("成本(元)");
+                }
                 allList=new ArrayList<>();
                 allList.add(headList);
                 double totalCostTime = 0;
@@ -778,8 +845,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     rowData.add((String)map.get("categoryName"));
                     rowData.add("");
                     rowData.add("");
-                    rowData.add(((Double)map.get("cost")).toString());
-                    rowData.add(((BigDecimal)map.get("costMoney")).toString());
+                    if(functionTimeList.size()>0){
+                        rowData.add(((Double)map.get("cost")).toString());
+                    }
+                    if(functionCostList.size()>0){
+                        rowData.add(((BigDecimal)map.get("costMoney")).toString());
+                    }
                     if (projectSum != null && projectSum == true) {
                         allList.add(rowData);
                     }
@@ -800,11 +871,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             membRowData.add("");
                             membRowData.add("");
                         }
-
                         membRowData.add((String)membMap.get("name"));
                         membRowData.add((String)membMap.get("departmentName"));
-                        membRowData.add(((Double)membMap.get("cost")).toString());
-                        membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
+                        if(functionTimeList.size()>0){
+                            membRowData.add(((Double)membMap.get("cost")).toString());
+                        }
+                        if(functionCostList.size()>0){
+                            membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
+                        }
                         allList.add(membRowData);
                     }
                 }
@@ -815,8 +889,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 sumRow.add("");
                 sumRow.add("");
                 sumRow.add("");
-                sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
-                sumRow.add(totalMoneyCost.toString());
+                if(functionTimeList.size()>0){
+                    sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                }
+                if(functionCostList.size()>0){
+                    sumRow.add(totalMoneyCost.toString());
+                }
                 allList.add(sumRow);
             }else{
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -825,15 +903,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 List<String> headList = new ArrayList<String>();
                 headList.add("人员");
                 projectNames.forEach(pn->{
-                    headList.add(String.valueOf(pn)+"/工时");
-                    headList.add(String.valueOf(pn)+"/成本");
+                    if(functionTimeList.size()>0){
+                        headList.add(String.valueOf(pn)+"/工时");
+                    }
+                    if(functionCostList.size()>0){
+                        headList.add(String.valueOf(pn)+"/成本");
+                    }
                 });
-                headList.add("合计/工时");
-                headList.add("合计/成本");
+                if(functionTimeList.size()>0){
+                    headList.add("合计/工时");
+                }
+                if(functionCostList.size()>0){
+                    headList.add("合计/成本");
+                }
                 allList=new ArrayList<>();
                 allList.add(headList);
                 //统计当前所有项目所有人的时间成本投入
-                List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByProject(companyId,startDate, endDate, projectId,userId);
+                List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByProject(companyId,startDate, endDate, projectId,userId,deptIds);
                 for (User user : userList) {
                     BigDecimal moneyCost = BigDecimal.valueOf(0);
                     double costTime = 0;
@@ -843,17 +929,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     for(Object i:projectIds){
                         List<Map<String, Object>> resultList = mapList.stream().filter(mp -> mp.get("projectId").equals(i)).collect(Collectors.toList());
                         if(resultList.size()>0){
-                            membRowData.add(String.valueOf(resultList.get(0).get("cost")));
-                            membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
+                            if(functionTimeList.size()>0){
+                                membRowData.add(String.valueOf(resultList.get(0).get("cost")));
+                            }
+                            if(functionCostList.size()>0){
+                                membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
+                            }
                             costTime += (Double)resultList.get(0).get("cost");
                             moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
                         }else{
-                            membRowData.add("");
-                            membRowData.add("");
+                            if(functionTimeList.size()>0){
+                                membRowData.add("");
+                            }
+                            if(functionCostList.size()>0){
+                                membRowData.add("");
+                            }
                         }
                     }
-                    membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
-                    membRowData.add(moneyCost.toString());
+                    if(functionTimeList.size()>0){
+                        membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                    }
+                    if(functionCostList.size()>0){
+                        membRowData.add(moneyCost.toString());
+                    }
                     if(mapList.size()>0){
                         allList.add(membRowData);
                     }
@@ -1882,11 +1980,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request) {
+    public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request,Integer departmentId) {
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
+        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,departmentId);
         boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
         if (!hasViewSalary) {
             //去掉权限
@@ -1907,7 +2005,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             String token = request.getHeader("TOKEN");
             User user = userMapper.selectById(token);
             TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-            List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
+            List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null);
             boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             List<String> headList = new ArrayList<String>();
@@ -2495,7 +2593,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
+        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null);
         boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
         if (!hasViewSalary) {
             //去掉权限
@@ -2844,13 +2942,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
-            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+            User targetUser = userMapper.selectById(request.getHeader("Token"));
+            Integer companyId =targetUser.getCompanyId();
             Map<String, Object> resultMap = new HashMap<>();
-
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
             TimeType timeType = timeTypeMapper.selectById(companyId);
             if (timeType.getFixMonthcost() == 1) {
                 //每月固定月薪的方式计算,平摊到各个项目中
-                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null);
+                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
                 //检查财务表中是否已经导入成本
                 List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -2908,10 +3025,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
                 resultMap.put("costList", retList);
                 resultMap.put("totalMoneyCost", totalMoneyCost);
+                if(functionCostList.size()==0){
+                    resultMap.put("totalCostMoney",null);
+                    retList.forEach(li->{
+                        li.put("costMoney",null);
+                    });
+                }
+                if(functionTimeList.size()==0){
+                    retList.forEach(li->{
+                        li.put("cost",null);
+                    });
+                }
                 httpRespMsg.data = resultMap;
 
             } else {
-                List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId);
+                List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId,deptIds);
                 BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
                 for (Map<String, Object> map : list) {
                     if (!map.containsKey("cost")) {
@@ -2926,6 +3054,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
                 resultMap.put("costList", list);
                 resultMap.put("totalMoneyCost", totalMoneyCost);
+                if(functionCostList.size()==0){
+                    resultMap.put("totalCostMoney",null);
+                    list.forEach(li->{
+                        li.put("costMoney",null);
+                    });
+                }
+                if(functionTimeList.size()==0){
+                    list.forEach(li->{
+                        li.put("cost",null);
+                    });
+                }
                 httpRespMsg.data = resultMap;
             }
 
@@ -2941,17 +3080,42 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg exportTimeCostByCategory(String startDate, String endDate, Integer projectCategoryId, String userId, Boolean projectSum, Integer type, 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();
             Map<String, Object> resultMap = new HashMap<>();
-            List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, projectCategoryId, userId);
+            //当前用户所属部门 或者 管理部门
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
+            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(), "查看成本统计");
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDpartList.size()>0){
+                    if(functionTimeList.size()>0||functionCostList.size()>0){
+                        deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                        deptIds.add(targetUser.getDepartmentId());
+                    }
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
+            List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, projectCategoryId, userId,deptIds);
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             List<List<String>> allList=null ;
             List<String> sumRow = null;
             if(type==0){
                 List<String> headList = new ArrayList<String>();
                 headList.add("项目分类");
-                headList.add("工时(h)");
-                headList.add("成本(元)");
+                if(functionTimeList.size()>0){
+                    headList.add("工时(h)");
+                }
+                if(functionCostList.size()>0){
+                    headList.add("成本(元)");
+                }
                 allList=new ArrayList<>();
                 allList.add(headList);
                 double totalCostTime = 0;
@@ -2967,15 +3131,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     totalCostTime += (Double)map.get("cost");
                     List<String> rowData = new ArrayList<String>();
                     rowData.add((String)map.get("categoryName"));
-                    rowData.add(((Double)map.get("cost")).toString());
-                    rowData.add(((BigDecimal)map.get("costMoney")).toString());
+                    if(functionTimeList.size()>0){
+                        rowData.add(((Double)map.get("cost")).toString());
+                    }
+                    if(functionCostList.size()>0){
+                        rowData.add(((BigDecimal)map.get("costMoney")).toString());
+                    }
                     allList.add(rowData);
                 }
                 //合计
                 sumRow=new ArrayList<>();
                 sumRow.add("合计");
-                sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
-                sumRow.add(totalMoneyCost.toString());
+                if(functionTimeList.size()>0){
+                    sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                }
+                if(functionCostList.size()>0){
+                    sumRow.add(totalMoneyCost.toString());
+                }
                 allList.add(sumRow);
             }else{
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -2984,15 +3156,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 List<String> headList = new ArrayList<String>();
                 headList.add("人员");
                 projectCategoryNameS.forEach(pc->{
-                    headList.add(String.valueOf(pc)+"/工时");
-                    headList.add(String.valueOf(pc)+"/成本");
+                    if(functionTimeList.size()>0){
+                        headList.add(String.valueOf(pc)+"/工时");
+                    }
+                    if(functionCostList.size()>0){
+                        headList.add(String.valueOf(pc)+"/成本");
+                    }
                 });
-                headList.add("工时/合计");
-                headList.add("成本/合计");
+                if(functionTimeList.size()>0){
+                    headList.add("工时/合计");
+                }
+                if(functionCostList.size()>0){
+                    headList.add("成本/合计");
+                }
                 allList=new ArrayList<>();
                 allList.add(headList);
                 //统计当前所有项目所有人的时间成本投入
-                List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByCategory(companyId,startDate,endDate, projectCategoryId,userId);
+                List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByCategory(companyId,startDate,endDate, projectCategoryId,userId,deptIds);
                 for (User user : userList) {
                     BigDecimal moneyCost = BigDecimal.valueOf(0);
                     double costTime = 0;
@@ -3002,17 +3182,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     for(Object i:projectCategorys){
                         List<Map<String, Object>> resultList = mapList.stream().filter(mp -> mp.get("category").equals(i)).collect(Collectors.toList());
                         if(resultList.size()>0){
-                            membRowData.add(String.valueOf(resultList.get(0).get("cost")));
-                            membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
+                            if(functionTimeList.size()>0){
+                                membRowData.add(String.valueOf(resultList.get(0).get("cost")));
+                            }
+                            if(functionCostList.size()>0){
+                                membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
+                            }
                             costTime += (Double)resultList.get(0).get("cost");
                             moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
                         }else{
-                            membRowData.add("");
-                            membRowData.add("");
+                            if(functionTimeList.size()>0){
+                                membRowData.add("");
+                            }
+                            if(functionCostList.size()>0){
+                                membRowData.add("");
+                            }
                         }
                     }
-                    membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
-                    membRowData.add(moneyCost.toString());
+                    if(functionTimeList.size()>0){
+                        membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
+                    }
+                    if(functionCostList.size()>0){
+                        membRowData.add(moneyCost.toString());
+                    }
                     if(mapList.size()>0){
                         allList.add(membRowData);
                     }
@@ -3031,14 +3223,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request) {
+    public HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request,Integer departmentId) {
         //1.获取分页结果
         Integer size=pageSize;//查询条数
         Integer start =(pageIndex-1)*size;//limit开始
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size);
+        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,departmentId);
         long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
         list.forEach(li->{
             double isPublic = (double) li.get("isPublic");
@@ -3060,7 +3252,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
-        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
+        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,null);
         String[] string={"人员","普通项目工时","公共项目工时","总工时","公共项目工时占比"};
         List<List<String>> dataList=new ArrayList<>();
         dataList.add(Arrays.asList(string));
@@ -3199,10 +3391,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId,Integer projectId,Integer pageIndex,Integer pageSize,String startDate,String endDate) {
+    public HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,Integer pageIndex,Integer pageSize,String startDate,String endDate) {
         HttpRespMsg msg=new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
-        List<Map<String,Object>> list;
         Integer size;
         Integer start;
         if(pageIndex!=null&&pageSize!=null){
@@ -3212,14 +3403,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             size=null;
             start=null;
         }
-        long total;
-        if(stateKey==0){
-            list=projectMapper.getWaitingReviewListByDepartment(user.getCompanyId(),userId,departmentId,start,size,startDate,endDate);
-            total=projectMapper.findCountWithDepartment(user.getCompanyId(),userId,departmentId,null,null,startDate,endDate);
-        }else {
-            list=projectMapper.getWaitingReviewListByProject(user.getCompanyId(),userId,projectId,start,size,startDate,endDate);
-            total=projectMapper.findCountWithProject(user.getCompanyId(),userId,projectId,null,null,startDate,endDate);
-        }
+        List<Map<String,Object>>  list=projectMapper.getWaitingReviewList(user.getCompanyId(),userId,start,size,startDate,endDate);
+        long total=projectMapper.findCount(user.getCompanyId(),userId,null,null,startDate,endDate);
         HashMap map=new HashMap();
         map.put("total",total);
         map.put("result",list);
@@ -3228,38 +3413,51 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId, Integer projectId,String startDate,String endDate) {
-        HttpRespMsg msg = getWaitingReviewList(request, stateKey, userId, departmentId, projectId, null, null,startDate,endDate);
+    public HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,String startDate,String endDate) {
+        HttpRespMsg msg = getWaitingReviewList(request, stateKey, userId, null, null,startDate,endDate);
         HashMap resultmap= (HashMap) msg.data;
         List<Map<String,Object>> list= (List<Map<String, Object>>) resultmap.get("result");
         List<List<String>> dataList=new ArrayList<>();
-        String[] s;
-        String fileName;
-        if(stateKey==0){
-            s= new String[]{"人员", "部门", "待审核数量"};
-            fileName = "人员部门待审核统计_"+System.currentTimeMillis();
-        }else {
-            s= new String[]{"人员", "项目", "待审核数量"};
-            fileName = "人员项目待审核统计_"+System.currentTimeMillis();
-        }
+        String[] s={"人员", "待审核数量"};
         dataList.add(Arrays.asList(s));
         for (Map<String, Object> map : list) {
             List<String> item=new ArrayList<>();
             item.add(String.valueOf(map.get("userName")));
-            if(stateKey==0){
-                item.add(String.valueOf(map.get("departmentName")));
-            }else {
-                item.add(String.valueOf(map.get("projectName")));
-            }
             item.add(String.valueOf(map.get("num")));
             dataList.add(item);
         }
         //生成excel文件导出
+        String fileName = "人员待审核统计_"+System.currentTimeMillis();
         String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
         msg.data = resp;
         return msg;
     }
 
+    @Override
+    public HttpRespMsg batchSetParticipation(HttpServletRequest request,Integer[] projectIdArray,String[] userIds) {
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        List<Integer> ids = Arrays.asList(projectIdArray);
+        List<String> userIdList = (List<String>) Arrays.asList(userIds);
+        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).in("id", ids));
+        List<Participation> list=new ArrayList<>();
+        for (Project project : projectList) {
+            List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
+            for (String s : userIdList) {
+                boolean anyMatch = participationList.stream().anyMatch(pt -> pt.getUserId().equals(s));
+                if(anyMatch){
+                    continue;
+                }
+                Participation participation=new Participation();
+                participation.setProjectId(project.getId());
+                participation.setUserId(s);
+                list.add(participation);
+            }
+        }
+        participationService.saveBatch(list);
+        return msg;
+    }
+
 
     private List<Department> getSubDepts(Department dp, List<Department> list) {
         List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMainMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.ProjectMainMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.ProjectMain">
+        <id column="id" property="id" />
+        <result column="category_id" property="categoryId" />
+        <result column="category_name" property="categoryName" />
+        <result column="code" property="code" />
+        <result column="name" property="name" />
+        <result column="company_id" property="companyId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, category_id, category_name, code, name, company_id
+    </sql>
+
+</mapper>

+ 88 - 95
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -38,13 +38,15 @@
         <result column="category" property="category" />
         <result column="category_name" property="categoryName" />
         <result column="project_desc" property="projectDesc" />
+        <result column="project_main_id" property="projectMainId" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, project_name, company_id, project_code, incharger_id, plan_start_date, plan_end_date, progress, level, status, finish_date, creator_id, creator_name, create_date, contract_amount, budget, base_man, base_outsourcing, base_risk1, base_risk2, base_fee, fee_normal, fee_travel, fee_outsourcing, fee_man, customer_id, customer_name, is_public, associate_degrees, associate_degree_names, task_gp_incharge, category, category_name, project_desc
+        id, project_name, company_id, project_code, incharger_id, plan_start_date, plan_end_date, progress, level, status, finish_date, creator_id, creator_name, create_date, contract_amount, budget, base_man, base_outsourcing, base_risk1, base_risk2, base_fee, fee_normal, fee_travel, fee_outsourcing, fee_man, customer_id, customer_name, is_public, associate_degrees, associate_degree_names, task_gp_incharge, category, category_name, project_desc, project_main_id
     </sql>
 
+
     <resultMap id="BaseResultMap2" type="com.management.platform.entity.vo.ProjectWithStage">
         <result column="id" property="id" />
         <result column="project_name" property="projectName" />
@@ -122,6 +124,12 @@
         <if test="startDate != null and endDate != null">
             AND b.create_date between #{startDate} and #{endDate}
         </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and b.dept_id in
+            <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         AND b.state = 1
         GROUP BY a.id
         ORDER BY a.id ASC
@@ -144,6 +152,12 @@
         <if test="startDate != null and endDate != null">
             AND b.create_date between #{startDate} and #{endDate}
         </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and b.dept_id in
+            <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         AND b.state = 1
         GROUP BY a.category
         ORDER BY a.category ASC
@@ -187,6 +201,12 @@
         <if test="startDate != null and endDate != null">
             AND a.create_date between #{startDate} and #{endDate}
         </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and a.dept_id in
+            <foreach collection="deptIds" separator="," close=")" open="(" item="item">
+                #{item}
+            </foreach>
+        </if>
         AND a.state = 1
     </select>
     <!--获取人员的月度总工时 -->
@@ -259,6 +279,12 @@
         <if test="userId != null">
             AND a.creator_id = #{userId}
         </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and a.dept_id in
+            <foreach collection="deptIds" separator="," close=")" open="(" item="item">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY b.id,a.project_id
         ORDER BY b.id ASC, a.dept_id ASC
     </select>
@@ -281,6 +307,12 @@
         <if test="userId != null">
             AND a.creator_id = #{userId}
         </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and a.dept_id in
+            <foreach collection="deptIds" separator="," close=")" open="(" item="item">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY b.id,c.category
         ORDER BY b.id ASC, a.dept_id ASC
     </select>
@@ -483,24 +515,24 @@
     </select>
 
     <!--获取加班统计报表 -->
-<!--    <select id="getOvertimeList" resultType="java.util.Map">-->
-<!--        SELECT report.`creator_id` AS userId, user.`name` AS username, SUM(report.`working_time`) AS workingTime,-->
-<!--        IFNULL(SUM(report.`overtime_hours`),0) AS overtimeHours,-->
-<!--        group_concat(distinct(project.project_code)) as projectCode,-->
-<!--        IFNULL(SUM(report.overtime_cost), 0) AS cost FROM report LEFT JOIN user ON user.id = report.`creator_id`-->
-<!--        left join project on project.id = report.project_id-->
-<!--        WHERE report.is_overtime = 1-->
-<!--        and report.`state` = 1-->
-<!--        AND report.`create_date` BETWEEN #{startDate} and #{endDate}-->
-<!--        AND user.`company_id` = #{companyId}-->
-<!--        <if test="projectId != null">-->
-<!--            AND report.`project_id` = #{projectId}-->
-<!--        </if>-->
-<!--        <if test="userId != null">-->
-<!--            AND report.`creator_id` = #{userId}-->
-<!--        </if>-->
-<!--        GROUP BY report.creator_id-->
-<!--    </select>-->
+    <!--    <select id="getOvertimeList" resultType="java.util.Map">-->
+    <!--        SELECT report.`creator_id` AS userId, user.`name` AS username, SUM(report.`working_time`) AS workingTime,-->
+    <!--        IFNULL(SUM(report.`overtime_hours`),0) AS overtimeHours,-->
+    <!--        group_concat(distinct(project.project_code)) as projectCode,-->
+    <!--        IFNULL(SUM(report.overtime_cost), 0) AS cost FROM report LEFT JOIN user ON user.id = report.`creator_id`-->
+    <!--        left join project on project.id = report.project_id-->
+    <!--        WHERE report.is_overtime = 1-->
+    <!--        and report.`state` = 1-->
+    <!--        AND report.`create_date` BETWEEN #{startDate} and #{endDate}-->
+    <!--        AND user.`company_id` = #{companyId}-->
+    <!--        <if test="projectId != null">-->
+    <!--            AND report.`project_id` = #{projectId}-->
+    <!--        </if>-->
+    <!--        <if test="userId != null">-->
+    <!--            AND report.`creator_id` = #{userId}-->
+    <!--        </if>-->
+    <!--        GROUP BY report.creator_id-->
+    <!--    </select>-->
 
     <!-- 获取某个员工的某时间段内的加班详情 -->
     <select id="getOvertimeDetail" resultType="java.util.Map">
@@ -523,32 +555,38 @@
         <if test="userId != null">
             AND report.`creator_id` = #{userId}
         </if>
+        <if test="departmentId!=null">
+            and report.dept_id=#{departmentId}
+        </if>
         order by user.create_time asc, report.create_date desc
     </select>
 
     <!--获取人员工时-->
     <select id="getUserWorkingTimeList" resultType="java.util.Map">
-    SELECT  report.`creator_id` AS userId, user.`name` AS username,
-	ifnull(SUM(if(project.is_public=0,report.working_time,null)),0) as unPublic,
-	ifnull(SUM(if(project.is_public=1,report.working_time,null)),0) as isPublic,
-	ifnull(SUM(report.`working_time`),0) AS workingTime
-	FROM report LEFT JOIN user ON user.id = report.`creator_id`
-    left join project on project.id = report.project_id
-    WHERE
-    report.`state` = 1
-    AND report.`create_date` BETWEEN #{startDate} and #{endDate}
-    AND user.`company_id` =#{companyId}
-    <if test="userId!=null">
-        and user.id=#{userId}
-    </if>
-    <if test="projectId!=null">
-        and project.id=#{projectId}
-    </if>
-    group by user.id
-    order by user.create_time asc, report.create_date desc
-    <if test="start!=null and size!=null">
-        limit #{start},#{size}
-    </if>
+        SELECT  report.`creator_id` AS userId, user.`name` AS username,
+        ifnull(SUM(if(project.is_public=0,report.working_time,null)),0) as unPublic,
+        ifnull(SUM(if(project.is_public=1,report.working_time,null)),0) as isPublic,
+        ifnull(SUM(report.`working_time`),0) AS workingTime
+        FROM report LEFT JOIN user ON user.id = report.`creator_id`
+        left join project on project.id = report.project_id
+        WHERE
+        report.`state` = 1
+        AND report.`create_date` BETWEEN #{startDate} and #{endDate}
+        AND user.`company_id` =#{companyId}
+        <if test="userId!=null">
+            and user.id=#{userId}
+        </if>
+        <if test="projectId!=null">
+            and project.id=#{projectId}
+        </if>
+        <if test="departmentId!=null">
+            and report.dept_id=#{departmentId}
+        </if>
+        group by user.id
+        order by user.create_time asc, report.create_date desc
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
     </select>
     <select id="findCountWithUser" resultType="java.lang.Long">
         select count(*)
@@ -639,75 +677,30 @@
         </if>
     </select>
 
-    <select id="getWaitingReviewListByDepartment" resultType="java.util.Map">
-        select us.name as userName,dp.department_name as departmentName,COUNT((rp.state=0 or null) and ( rp.is_dept_audit =1 or null)) as num
+    <select id="getWaitingReviewList" resultType="java.util.Map">
+        select us.name as userName,COUNT(rp.state=0 or null) as num
         from user us
-        left join department dp on us.manage_dept_id =dp.department_id
-        left join report rp on rp.audit_deptid=dp.department_id
-        where us.company_id=#{companyId} and  us.manage_dept_id !=0 and rp.create_date between #{startDate} and #{endDate} and us.is_active=1
-        <if test="departmentId!=null">
-            and dp.department_id=#{departmentId}
-        </if>
+        left join report rp on rp.audit_deptid=us.manage_dept_id  or rp.project_auditor_id=us.id
+        where us.company_id=#{companyId} and  (rp.audit_deptid !=0 or rp.project_id is not null) and rp.create_date between #{startDate} and #{endDate} and us.is_active=1
         <if test="userId!=null">
             and us.id=#{userId}
         </if>
-        group by dp.department_id,us.id
+        group by us.id
         <if test="start!=null and size!=null">
             limit #{start},#{size}
         </if>
     </select>
 
-    <select id="getWaitingReviewListByProject" resultType="java.util.Map">
-        select us.name as userName,project.project_name as projectName,COUNT((rp.state=0 or null) and ( rp.is_dept_audit =0 or null)) as num
-        from user us
-        left join report rp on rp.project_auditor_id=us.id
-        left join project on project.id=rp.project_id
-        where us.company_id=#{companyId} and rp.project_id is not null and rp.create_date between #{startDate} and #{endDate}  and us.is_active=1
-        <if test="projectId!=null">
-            and project.id=#{projectId}
-        </if>
-        <if test="userId!=null">
-            and us.id=#{userId}
-        </if>
-        group by project.id,us.id
-        <if test="start!=null and size!=null">
-            limit #{start},#{size}
-        </if>
-    </select>
-
-    <select id="findCountWithDepartment" resultType="java.lang.Long">
-        select  count(1)
-        from (select us.name as userName,dp.department_name as departmentName,COUNT((rp.state=0 or null) and ( rp.is_dept_audit =1 or null)) as num
-        from user us
-        left join department dp on us.manage_dept_id =dp.department_id
-        left join report rp on rp.audit_deptid=dp.department_id
-        where us.company_id=#{companyId} and  us.manage_dept_id !=0 and rp.create_date between #{startDate} and #{endDate}  and us.is_active=1
-        <if test="departmentId!=null">
-            and dp.department_id=#{departmentId}
-        </if>
-        <if test="userId!=null">
-            and us.id=#{userId}
-        </if>
-        group by dp.department_id,us.id
-        <if test="start!=null and size!=null">
-            limit #{start},#{size}
-        </if>) total
-    </select>
-
-    <select id="findCountWithProject" resultType="java.lang.Long">
+    <select id="findCount" resultType="java.lang.Long">
         select  count(1)
-        from (select us.name as userName,project.project_name as projectName,COUNT((rp.state=0 or null) and ( rp.is_dept_audit =0 or null)) as num
+        from (select us.name as userName,COUNT(rp.state=0 or null) as num
         from user us
-        left join report rp on rp.project_auditor_id=us.id
-        left join project on project.id=rp.project_id
-        where us.company_id=#{companyId} and rp.project_id is not null and rp.create_date between #{startDate} and #{endDate}  and us.is_active=1
-        <if test="projectId!=null">
-            and project.id=#{projectId}
-        </if>
+        left join report rp on rp.audit_deptid=us.manage_dept_id  or rp.project_auditor_id=us.id
+        where us.company_id=#{companyId} and  (rp.audit_deptid !=0 or rp.project_id is not null) and rp.create_date between #{startDate} and #{endDate} and us.is_active=1
         <if test="userId!=null">
             and us.id=#{userId}
         </if>
-        group by project.id,us.id
+        group by us.id
         <if test="start!=null and size!=null">
             limit #{start},#{size}
         </if>) total

File diff suppressed because it is too large
+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml