Browse Source

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

ggooalice 2 năm trước cách đây
mục cha
commit
6922e9abf5
25 tập tin đã thay đổi với 1212 bổ sung367 xóa
  1. 17 12
      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. 10 14
      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. 8 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  10. 154 102
      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. 379 92
      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. 118 96
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  15. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml
  16. 4 3
      fhKeeper/formulahousekeeper/timesheet/build/webpack.prod.conf.js
  17. 10 10
      fhKeeper/formulahousekeeper/timesheet/config/index.js
  18. 5 0
      fhKeeper/formulahousekeeper/timesheet/index.html
  19. 2 0
      fhKeeper/formulahousekeeper/timesheet/src/permissions.js
  20. 2 2
      fhKeeper/formulahousekeeper/timesheet/src/views/Login.vue
  21. 37 8
      fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue
  22. 13 2
      fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue
  23. 186 9
      fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue
  24. 1 1
      fhKeeper/formulahousekeeper/timesheet/src/views/quanx/quanx.vue
  25. 3 1
      fhKeeper/formulahousekeeper/timesheet/src/views/settings/timetype.vue

+ 17 - 12
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -63,8 +63,8 @@ public class ProjectController {
     public HttpRespMsg getProjectPage(@RequestParam Integer pageIndex, @RequestParam Integer pageSize, String keyword,
                                       @RequestParam(required = false, defaultValue = "1") Integer searchField,
                                       Integer projectId, //可以直接传projectId来进行匹配
-                                      Integer status, Integer category) {
-        return projectService.getProjectPage(pageIndex, pageSize, keyword,searchField, status, category, projectId, request);
+                                      Integer status, Integer category,Integer projectMainId) {
+        return projectService.getProjectPage(pageIndex, pageSize, keyword,searchField, status, category, projectId,projectMainId, request);
     }
 
     @RequestMapping("/saveBatchAccoDegrees")
@@ -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,Integer departmentId){
+        return projectService.getWaitingReviewList(request,stateKey,userId,pageIndex,pageSize,startDate,endDate,departmentId);
     }
     @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> {
+
+}

+ 10 - 14
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<Integer> deptIds);
 
     //获取项目的成本预警和实际工时表
     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,List<Integer> deptIds);
 
-    long findCountWithUser(String userId, Integer companyId, String startDate, String endDate, Integer projectId, Integer start,Integer size);
+    long findCountWithUser(String userId, Integer companyId, String startDate, String endDate, Integer projectId, Integer start,Integer size,Integer departmentId,List<Integer> deptIds);
 
-    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,Integer departmentId);
 
-    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,Integer departmentId);
 }

+ 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);
+}

+ 8 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -20,7 +20,7 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getProjectList(Integer forReport, HttpServletRequest request);
 
     HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
-                               Integer status, Integer category, Integer projectId, HttpServletRequest request);
+                               Integer status, Integer category, Integer projectId,Integer projectMainId, HttpServletRequest request);
 
     HttpRespMsg editProject(Integer id, String name, String code, String[] userIds, String inchargerId,
                             Integer isPublic,
@@ -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,Integer departmentId);
 
-    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);
 }

+ 154 - 102
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,101 +760,45 @@ 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));
-                    }
-                }
+            HttpRespMsg msg = getDepartmentStatistics(null, startDate, endDate, request);
+            Map<String,Object> mapData = (Map<String, Object>) msg.data;
+            List<DepartmentMasterVO> costList = (List<DepartmentMasterVO>) mapData.get("costList");
+            BigDecimal totalCostMoney= (BigDecimal) mapData.get("totalCostMoney");
+            List<String> titleList=new ArrayList<>();
+            titleList.add("部门");
+            if(!costList.stream().anyMatch(ct->ct.getCostTime()==null)){
+                titleList.add("工时");
             }
-
-            System.out.println("获取到管理的部门ids length=="+deptIds);
-            List<Map<String, Object>> list = departmentMapper
-                    .getCostByUser(deptIds, startDate, endDate, companyId, null);
-            Map<String, List<Map<String, Object>>> tempMap = new HashMap<>();
-            for (Map<String, Object> map : list) {
-                if (tempMap.containsKey(map.get("user"))) {
-                    //这个名字已经装进数组中了
-                    List<Map<String, Object>> tempList = tempMap.get(map.get("user"));
-                    Map<String, Object> dataMap = new HashMap<>();
-                    dataMap.put("project", map.get("project"));
-                    Double time = (Double) map.getOrDefault("time", 0);
-                    dataMap.put("time", time);
-                    tempList.add(dataMap);
-                } else {
-                    //这个名字尚未装进数组中
-                    List<Map<String, Object>> tempList = new ArrayList<>();
-                    if (map.containsKey("project")) {
-                        Map<String, Object> dataMap = new HashMap<>();
-                        dataMap.put("project", map.get("project"));
-                        Double time = (Double) map.getOrDefault("time", 0);
-                        dataMap.put("time", time);
-                        tempList.add(dataMap);
-                    }
-                    tempMap.put((String) map.get("user"), tempList);
-                }
+            if(!costList.stream().anyMatch(ct->ct.getCostMoney()==null)){
+                titleList.add("成本");
             }
-            DecimalFormat df = new DecimalFormat("#.00");
-            List<List<String>> dataList = new ArrayList<List<String>>();
-            String[] titles = {"人员", "项目", "工时(h)"};
-            List<String> titleList = Arrays.asList(titles.clone());
+            List<List<String>> dataList=new ArrayList<>();
             dataList.add(titleList);
-            double totalCostTime = 0;
-            for (String key : tempMap.keySet()) {
-                Map<String, Object> map = new HashMap<>();
-                map.put("name", key);
-                map.put("project", tempMap.get(key));
-                List<String> nameList = new ArrayList<String>();
-                nameList.add(key);//姓名
-                nameList.add("");//空着
-                List<Map<String, Object>> tempList = tempMap.get(key);
-                //统计个人的时间和成本
-                double tTime = 0;
-                for (Map<String, Object> membData : tempList) {
-                    tTime += (double)membData.get("time");
+            BigDecimal bigDecimal=new BigDecimal(0);
+            for (DepartmentMasterVO departmentMasterVO : costList) {
+                List<String> item=new ArrayList<>();
+                item.add(departmentMasterVO.getDepartmentName());
+                if(!costList.stream().anyMatch(ct->ct.getCostTime()==null)){
+                    item.add(String.valueOf(departmentMasterVO.getCostTime()));
+                    bigDecimal=bigDecimal.add(BigDecimal.valueOf(departmentMasterVO.getCostTime()));
                 }
-                totalCostTime += tTime;
-                nameList.add(df.format(tTime));
-                dataList.add(nameList);
-                //装载该人员下的项目的工时数据
-                for (Map<String, Object> membData : tempList) {
-                    tTime += (double)membData.get("time");
-                    List<String> projectDataList = new ArrayList<>();
-                    projectDataList.add("");
-                    projectDataList.add(membData.get("project")+"");
-                    projectDataList.add(df.format((double)membData.get("time"))+"");
-                    dataList.add(projectDataList);
+                if(!costList.stream().anyMatch(ct->ct.getCostMoney()==null)){
+                    item.add(String.valueOf(departmentMasterVO.getCostMoney()));
                 }
+                dataList.add(item);
             }
-            //合计
-            List<String> sumRow = new ArrayList<String>();
-            sumRow.add("合计");
-            sumRow.add("");
-            sumRow.add(""+df.format(totalCostTime));
-            dataList.add(sumRow);
+            List<String> rowData=new ArrayList<>();
+            rowData.add("合计");
+            if(!costList.stream().anyMatch(ct->ct.getCostTime()==null)){
+                rowData.add(String.valueOf(bigDecimal.doubleValue()));
+            }
+            if(!costList.stream().anyMatch(ct->ct.getCostMoney()==null)){
+                rowData.add(totalCostMoney.toString());
+            }
+            dataList.add(rowData);
             //生成excel文件导出
-            String fileName = "人员工时统计_"+System.currentTimeMillis();
+            String fileName = "部门工时统计_"+System.currentTimeMillis();
             String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
-
             httpRespMsg.data = resp;
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");

+ 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;
+    }
+}

+ 379 - 92
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -165,7 +165,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     //分页获取项目列表
     @Override
     public HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
-                                      Integer status, Integer category, Integer projectId, HttpServletRequest request) {
+                                      Integer status, Integer category, Integer projectId,Integer projectMainId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             //通过公司id获取该公司所有的项目列表
@@ -203,6 +203,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             if (category != null) {
                 queryWrapper.eq("category", category);
             }
+            if (projectMainId != null) {
+                queryWrapper.eq("project_main_id", projectMainId);
+            }
             if (projectId != null) {
                 queryWrapper.eq("id", projectId);
             }
@@ -254,6 +257,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 +312,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 +380,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 +652,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 +735,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 +764,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 +790,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 +823,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 +848,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 +874,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 +892,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 +906,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 +932,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 +1983,25 @@ 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<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
+        List<Integer> deptIds=null;
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            if(functionDeptList.size()>0){
+                deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                deptIds.add(user.getDepartmentId());
+            }else {
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
+            }
+        }
+        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,departmentId,deptIds);
         boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
         if (!hasViewSalary) {
             //去掉权限
@@ -1907,7 +2022,21 @@ 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<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
+            List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
+            List<Integer> deptIds=null;
+            List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+            //判断查看权限
+            if(functionAllList.size()==0){
+                if(functionDeptList.size()>0){
+                    deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                    deptIds.add(user.getDepartmentId());
+                }else {
+                    deptIds=new ArrayList<>();
+                    deptIds.add(-1);
+                }
+            }
+            List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null,deptIds);
             boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             List<String> headList = new ArrayList<String>();
@@ -2495,7 +2624,21 @@ 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<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
+        List<Integer> deptIds=null;
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            if(functionDeptList.size()>0){
+                deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                deptIds.add(user.getDepartmentId());
+            }else {
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
+            }
+        }
+        List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null,deptIds);
         boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
         if (!hasViewSalary) {
             //去掉权限
@@ -2844,13 +2987,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 +3070,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 +3099,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 +3125,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 +3176,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 +3201,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 +3227,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,15 +3268,29 @@ 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);
-        long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
+        List<Integer> deptIds=null;
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            if(functionDeptList.size()>0){
+                    deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                    deptIds.add(user.getDepartmentId());
+            }else {
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
+            }
+        }
+        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,departmentId,deptIds);
+        long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,departmentId,deptIds);
         list.forEach(li->{
             double isPublic = (double) li.get("isPublic");
             double workingTime = (double) li.get("workingTime");
@@ -3060,7 +3311,21 @@ 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<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
+        List<Integer> deptIds=null;
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            if(functionDeptList.size()>0){
+                deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                deptIds.add(user.getDepartmentId());
+            }else {
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
+            }
+        }
+        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,null,deptIds);
         String[] string={"人员","普通项目工时","公共项目工时","总工时","公共项目工时占比"};
         List<List<String>> dataList=new ArrayList<>();
         dataList.add(Arrays.asList(string));
@@ -3099,21 +3364,37 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 days-=1;
             }
         }
-        Integer companyId= userMapper.selectById(request.getHeader("token")).getCompanyId();
-        TimeType timeType = timeTypeMapper.selectById(companyId);
+        User targetUser= userMapper.selectById(request.getHeader("token"));
+        TimeType timeType = timeTypeMapper.selectById(targetUser.getCompanyId());
         Integer timeliness = timeType.getTimeliness();
-        List<Map<String,Object>> reportList=reportMapper.getUserReportTimelinessRate(companyId,startDate,endDate);
-        System.out.println(reportList);
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "全公司工时分配");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "负责部门工时分配");
+        List<Integer> deptIds=null;
+        List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id",targetUser.getCompanyId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            if(functionDeptList.size()>0){
+                deptIds = userDepartmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
+                deptIds.add(targetUser.getDepartmentId());
+            }else {
+                deptIds=new ArrayList<>();
+                deptIds.add(-1);
+            }
+        }
+        List<Map<String,Object>> reportList=reportMapper.getUserReportTimelinessRate(targetUser.getCompanyId(),startDate,endDate);
         QueryWrapper<User> queryWrapper=new QueryWrapper();
-        queryWrapper.eq("company_id",companyId);
+        queryWrapper.eq("company_id",targetUser.getCompanyId());
         if(departmentId!=null){
             queryWrapper.eq("department_id",departmentId);
         }
         if(userId!=null){
             queryWrapper.eq("id",userId);
         }
+        if(deptIds!=null){
+            queryWrapper.in("department_id",deptIds);
+        }
         queryWrapper.eq("is_active",1).orderByAsc("department_id");
-        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", targetUser.getCompanyId()));
         List<User> userList;
         long total=0;
         if(pageIndex!=null&&pageSize!=null){
@@ -3199,10 +3480,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,Integer departmentId) {
         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 +3492,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,departmentId);
+        long total=projectMapper.findCount(user.getCompanyId(),userId,null,null,startDate,endDate,departmentId);
         HashMap map=new HashMap();
         map.put("total",total);
         map.put("result",list);
@@ -3228,38 +3502,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,null);
         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>

+ 118 - 96
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,39 +555,57 @@
         <if test="userId != null">
             AND report.`creator_id` = #{userId}
         </if>
+        <if test="departmentId!=null">
+            and report.dept_id=#{departmentId}
+        </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and report.dept_id in
+            <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </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>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and report.dept_id in
+            <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </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(*)
         from (SELECT  report.`creator_id` AS userId, user.`name` AS username,
-        SUM(if(project.is_public=0,report.working_time,null)) as unPublic,
-        SUM(if(project.is_public=1,report.working_time,null)) as isPublic,
-        SUM(report.`working_time`) AS workingTime
+        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
@@ -568,6 +618,15 @@
         <if test="projectId!=null">
             and project.id=#{projectId}
         </if>
+        <if test="departmentId!=null">
+            and report.dept_id=#{departmentId}
+        </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and report.dept_id in
+            <foreach collection="deptIds" open="(" item="item" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
         group by user.id
         order by user.create_time asc, report.create_date desc
         <if test="start!=null and size!=null">
@@ -639,75 +698,38 @@
         </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,dp.department_name as departmentName,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
+        left join department dp on dp.department_id=rp.dept_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
-        <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 test="departmentId!=null">
+            and rp.dept_id=#{departmentId}
         </if>
-        group by project.id,us.id
+        group by us.id
         <if test="start!=null and size!=null">
             limit #{start},#{size}
         </if>
     </select>
 
-    <select id="findCountWithDepartment" resultType="java.lang.Long">
+    <select id="findCount" 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 (select us.name as userName,dp.department_name as departmentName,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
+        left join department dp on dp.department_id=rp.dept_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
-        <if test="start!=null and size!=null">
-            limit #{start},#{size}
-        </if>) total
-    </select>
-
-    <select id="findCountWithProject" 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 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 test="departmentId!=null">
+            and rp.dept_id=#{departmentId}
         </if>
-        group by project.id,us.id
+        group by us.id
         <if test="start!=null and size!=null">
             limit #{start},#{size}
         </if>) total

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml


+ 4 - 3
fhKeeper/formulahousekeeper/timesheet/build/webpack.prod.conf.js

@@ -8,6 +8,7 @@ var CopyWebpackPlugin = require('copy-webpack-plugin')
 var HtmlWebpackPlugin = require('html-webpack-plugin')
 var ExtractTextPlugin = require('extract-text-webpack-plugin')
 var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
+var version = new Date().getTime()
 
 var env = config.build.env
 
@@ -22,8 +23,8 @@ var webpackConfig = merge(baseWebpackConfig, {
     output: {
         publicPath: './',
         path: config.build.assetsRoot,
-        filename: utils.assetsPath('js/[name].[chunkhash].js'),
-        chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
+        filename: utils.assetsPath(`js/[name].[chunkhash].${version}.js`),
+        chunkFilename: utils.assetsPath(`js/[id].[chunkhash].${version}.js`)
     },
     plugins: [
         // http://vuejs.github.io/vue-loader/en/workflow/production.html
@@ -40,7 +41,7 @@ var webpackConfig = merge(baseWebpackConfig, {
         }),
         // extract css into its own file
         new ExtractTextPlugin({
-        filename: utils.assetsPath('css/[name].[contenthash].css')
+        filename: utils.assetsPath(`css/[name].[contenthash].${version}.css`)
         }),
         // Compress extracted CSS. We are using this plugin so that possible
         // duplicated CSS from different components can be deduped.

+ 10 - 10
fhKeeper/formulahousekeeper/timesheet/config/index.js

@@ -2,17 +2,17 @@ var path = require('path')
 
 //  var ip = '127.0.0.1'
 // var ip = '47.100.37.243'
-// var ip = '192.168.2.7'
+var ip = '192.168.2.7'
 
-var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
-for (var i in ifaces) {
-    for (var j in ifaces[i]) {
-        var val = ifaces[i][j]
-        if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
-            ip = val.address
-        }
-    }
-}
+// var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
+// for (var i in ifaces) {
+//     for (var j in ifaces[i]) {
+//         var val = ifaces[i][j]
+//         if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
+//             ip = val.address
+//         }
+//     }
+// }
 
 module.exports = {
   build: {

+ 5 - 0
fhKeeper/formulahousekeeper/timesheet/index.html

@@ -2,6 +2,11 @@
 <html>
     <head>
         <meta charset="utf-8">
+        <!-- 尝试清除打包缓存 -->
+        <!-- <meta http-equiv="pragram" content="no-cache">
+        <meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
+        <meta http-equiv="expires" content="0"> -->
+        <!-- 尝试清除打包缓存 -->
         <title>工时管家</title>
         <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico"/>
         <link href="./static/css/public.css" rel="stylesheet" type="text/css"/>

+ 2 - 0
fhKeeper/formulahousekeeper/timesheet/src/permissions.js

@@ -40,6 +40,7 @@ const StringUtil = {
         setFinanceAuditor: false, //设置财务审核人
 
         // 项目报表服务 // 
+        reportProject: false, // 项目报表 //
         reportTask : false, // 项目任务报表 //
         reportCostOf : false, // 项目成本报表 // 
         reportBalance : false, // 项目收支平衡表 // 
@@ -152,6 +153,7 @@ const StringUtil = {
         arr[i] == '日报待审核统计' ? obj.reportAuditRate = true : ''
         arr[i] == '查看工时统计' ? obj.countHours = true : ''
         arr[i] == '查看成本统计' ? obj.countCost = true : ''
+        arr[i] == '项目报表' ? obj.reportProject = true : ''
     }
 
     return obj

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/Login.vue

@@ -7,7 +7,7 @@
                 </div>
                 <h3 class="title">工时管家</h3>
                 <el-form-item class="login-input" prop="username">
-                    <el-input type="text" v-model="ruleForm.username" autocomplete="off" placeholder="账号" clearable prefix-icon="el-icon-user-solid"></el-input>
+                    <el-input type="text" v-model="ruleForm.username" autocomplete="off" placeholder="账号/手机号" clearable prefix-icon="el-icon-user-solid"></el-input>
                 </el-form-item>
                 <el-form-item class="login-input" prop="password">
                     <el-input type="password" v-model="ruleForm.password" @keyup.enter.native="handleSubmit" autocomplete="off" placeholder="密码" show-password prefix-icon="el-icon-lock"></el-input>
@@ -61,7 +61,7 @@
                     password: ''
                 },
                 rules: {
-                    username: [{ required: true, message: '请输入账号', trigger: 'blur' },],
+                    username: [{ required: true, message: '请输入账号/手机号', trigger: 'blur' },],
                     password: [{ required: true, message: '请输入密码', trigger: 'blur' },]
                 }
             };

+ 37 - 8
fhKeeper/formulahousekeeper/timesheet/src/views/corpreport/list.vue

@@ -1,11 +1,11 @@
 <template>
   <section>
     <div>
-    <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff;overflow-y:auto;overflow-x:hidden;">
+    <div class="sidebars" ref="sidebars" style="width: 200px;display: block;background: #fff;">
       <div ref="abbisd" style="width: 100%;overflow: hidden;">
         <el-col :span="12">
           <el-menu
-            default-active="1-1"
+            :default-active="defaultActive"
             class="el-menu-vertical-demo"
             @select="staffs"
             background-color="#ffffff"
@@ -17,7 +17,7 @@
                 <i class="iconfont firerock-iconbaobiao"></i>
                 <span>项目报表服务</span>
               </template>
-                <el-menu-item index="1-1" ><p @click="ssl(0)">项目报表</p></el-menu-item>
+                <el-menu-item index="1-1" v-if="permissions.reportProject"><p @click="ssl(0)">项目报表</p></el-menu-item>
                 <el-menu-item index="1-2" v-if="permissions.reportTask"><p @click="ssl(1)">项目任务报表</p></el-menu-item>
                 <el-menu-item index="1-3" v-if="permissions.reportCostOf"><p @click="ssl(2)">项目成本报表</p></el-menu-item>
                 <el-menu-item index="1-9" v-if="permissions.reportAllTimeDivide || permissions.reportTimeDivide"><p @click="ssl(8)">人员工时分配表</p></el-menu-item>
@@ -42,7 +42,7 @@
         <div class="spans" ref="side" style="left: -19px;"><i  ref="sideI" class="el-icon-arrow-left"></i></div>
       </div> -->
     <!-- 内容主体区域 -->
-  <div class="contents">
+  <div class="contents" v-if="allWrong">
     <div class="headine" ref="headine">
       <h3 ref="headHe" style="padding-left: 210px">{{shuz[ins]}}</h3>
       <div class="headScreen">
@@ -402,6 +402,8 @@
                     <span>¥{{scope.row.baseCurcost | numberToCurrency}}</span>
                   </template>
                 </el-table-column>
+                <el-table-column  prop="currentRemainingBudget" label="当前剩余预算" min-width="200"></el-table-column>
+                <el-table-column  prop="remainingBudget" label="总剩余预算" min-width="200"></el-table-column>
                 <el-table-column prop="feeMan" label="已发生工时成本" min-width="160" align="right">
                   <template slot-scope="scope">
                     <span :class="scope.row.baseCurcost * 0.9 < scope.row.feeMan ? 'warntext' : ''">¥{{scope.row.feeMan | numberToCurrency}}</span>
@@ -624,7 +626,7 @@ export default {
       "项目收支平衡表(利润表)","客户项目利润报表","项目阶段工时表",
       "加班情况统计表","工时成本预警表","人员工时分配表",
       "员工填报及时率统计","日报待审核统计"],
-      ins: 0,
+      ins: 10000,
       user: JSON.parse(sessionStorage.user),
       overTimeList: [], // 项目加班情况统计列表
       proList: [],
@@ -650,8 +652,10 @@ export default {
       departmentList: [],
       departmentIdArray: [],
       selUserList: [],
-      departmentOrProject: 1
+      departmentOrProject: 1,
 
+      allWrong: true,
+      defaultActive: '1-1'
     };
   },
   computed: {},
@@ -672,6 +676,7 @@ export default {
     this.getDepartmentList()
     this.getcustomerList()
     this.getcusProjectList()
+    this.authorityToJudge()
   },
   filters: {
       
@@ -690,6 +695,30 @@ export default {
       }
   },
   methods: {
+    authorityToJudge() {
+      // if(this.permissions.reportProject) {this.ins = 0;return} else
+      // if(this.permissions.reportTask) {this.ins = 1;return} else
+      // if(this.permissions.reportCostOf) {this.ins = 2;return} else
+      // if(this.permissions.reportTimeDivide) {this.ins = 8;return} else
+      // if(this.permissions.reportCostWarning) {this.ins = 7;return} else
+      // if(this.permissions.reportBalance) {this.ins = 3;return} else
+      // if(this.permissions.reportProfits) {this.ins = 4;return} else
+      // if(this.permissions.reportPhase) {this.ins = 5;return} else
+      // if(this.permissions.reportOvertime) {this.ins = 6;return} else
+      // if(this.permissions.reportTimely) {this.ins = 9;return} else
+      // if(this.permissions.reportAuditRate) {this.ins = 10;return} else {this.allWrong = false}
+      if(this.permissions.reportProject) {this.ssl(0);this.defaultActive = '1-1';return} else
+      if(this.permissions.reportTask) {this.ssl(1);this.defaultActive = '1-2';return} else
+      if(this.permissions.reportCostOf) {this.ssl(2);this.defaultActive = '1-3';return} else
+      if(this.permissions.reportTimeDivide) {this.ssl(8);this.defaultActive = '1-9';return} else
+      if(this.permissions.reportCostWarning) {this.ssl(7);this.defaultActive = '1-4';return} else
+      if(this.permissions.reportBalance) {this.ssl(3);this.defaultActive = '1-5';return} else
+      if(this.permissions.reportProfits) {this.ssl(4);this.defaultActive = '1-6';return} else
+      if(this.permissions.reportPhase) {this.ssl(5);this.defaultActive = '1-7';return} else
+      if(this.permissions.reportOvertime) {this.ssl(6);this.defaultActive = '1-8';return} else
+      if(this.permissions.reportTimely) {this.ssl(9);this.defaultActive = '1-10';return} else
+      if(this.permissions.reportAuditRate) {this.ssl(10);this.defaultActive = '1-11';return} else {this.allWrong = false}
+    },
     rowspan(spanArr,position,spanName){
       this.list1.forEach((item,index) => {
         if(index == 0){
@@ -1441,9 +1470,9 @@ export default {
     },
     // 点击侧边栏事件
     side() {
-      if(this.$refs.side.style.left < '0px') {
+      if(this.$refs.side.style.left < '1px') {
         this.$refs.sidebars.style.width = '1px'
-        this.$refs.sid.style.left = '0px'
+        this.$refs.sid.style.left = '1px'
         this.$refs.side.style.left = '1px'
         this.$refs.sideI.className = 'el-icon-arrow-right'
         this.$refs.staff.style.margin = '5px 0px 0px 5px'

+ 13 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -339,9 +339,20 @@
             getUserCostList() {
                 this.listLoading = true;
                 console.log(this.port.project.userCost, '获取人员成本统计列表')
+                console.log(this.user.timeType.fixMonthcost)
+                console.log(Boolean(this.dateRange))
+                let startDateNum = ''
+                let endDateNum = ''
+                if(this.dateRange) {
+                    startDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange
+                    endDateNum = this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
+                } 
+                // return 
                 this.http.post(this.port.project.userCost, {
-                    startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange, 
-                    endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
+                    // startDate:this.user.timeType.fixMonthcost==0?this.dateRange[0]:this.dateRange, 
+                    // endDate: this.user.timeType.fixMonthcost==0?this.dateRange[1]:this.dateRange
+                    startDate: startDateNum,
+                    endDate: endDateNum
                 },
                 res => {
                     this.listLoading = false;

+ 186 - 9
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -28,6 +28,13 @@
                         <el-option label="已撤销" value=3 ></el-option>
                     </el-select>
                 </el-form-item>
+                <!-- 主项目筛选 -->
+                <el-form-item v-if="user.timeType.mainProjectState == '1'">
+                    <span style="margin-left:5px;margin-right:5px;color:#606266;">主项目</span>
+                    <el-select v-model="projectMainId" style="width:110px;"  placeholder="请选择" clearable @change="searchClfList" size="small">
+                        <el-option v-for="item in mainProjectList" :key="item.id" :label="item.name" :value="item.id" ></el-option>
+                    </el-select>
+                </el-form-item>
                 <!-- 分类筛选 -->
                 <el-form-item >
                     <span style="margin-left:5px;margin-right:5px;color:#606266;">分类</span>
@@ -35,6 +42,7 @@
                         <el-option v-for="item in baseClfList" :key="item.id" :label="item.name" :value="item.id" ></el-option>
                     </el-select>
                 </el-form-item>
+                
                 <!-- 分类条目 -->
                 <!-- <el-form-item style="float:right;"  v-if="permissions.projectClassification">
                     <el-link type="primary" :underline="false" @click="showClfDialog = true">分类管理</el-link>
@@ -76,6 +84,9 @@
                             <el-dropdown-item v-if="permissions.projectClassification">
                                 <el-link type="primary" :underline="false" @click="showClfDialog = true">分类管理</el-link>
                             </el-dropdown-item>
+                            <el-dropdown-item v-if="user.timeType.mainProjectState == 1">
+                                <el-link type="primary" :underline="false" @click="mainProjectDialog = true">主项目管理</el-link>
+                            </el-dropdown-item>
                         </el-dropdown-menu>
                         </el-dropdown>
                 </el-form-item>
@@ -190,7 +201,7 @@
             </el-table-column>
             <el-table-column label="操作" :width="showColumnWidth" align="left" fixed="right" v-if="showColumnWidth != '0' || permissions.projectManagement">
                 <template slot-scope="scope">
-                    <el-button v-if="permissions.projectManagement || user.id==scope.row.creatorId" size="mini"  @click="subProject(scope.row)">子项目</el-button>
+                    <el-button v-if="(permissions.projectManagement || user.id==scope.row.creatorId) && user.timeType.mainProjectState != '1'" size="mini"  @click="subProject(scope.row)">子项目</el-button>
                     <el-button size="mini" v-if="permissions.projectManagement || user.id==scope.row.inchargerId || user.id==scope.row.creatorId" type="primary" @click="handleAdd(scope.$index, scope.row)">编辑</el-button>
                     <!-- <el-button v-if="permissions.projectManagement || user.id==scope.row.creatorId" size="mini"  @click="deletePro(scope.$index, scope.row)">删除</el-button> -->
                     <el-dropdown class="customdropdown" split-button size="mini" @click="finishPro(scope.row)" v-if="(permissions.projectManagement || user.id==scope.row.creatorId || user.id==scope.row.inchargerId) && scope.row.status == 1" placement="bottom-start">
@@ -231,6 +242,14 @@
             <el-form ref="form1" :model="addForm" :rules="rules" label-width="120px">
                 <el-form-item label="项目编号" >
                     <el-input v-model="addForm.code" :disabled="!permissions.projectManagement && addForm.creatorId != user.id" placeholder="请输入项目编号" clearable></el-input>
+                </el-form-item>
+                 <el-form-item label="主项目" v-if="user.timeType.mainProjectState == '1'">
+                    <el-select v-model="addForm.projectMainId" clearable :disabled="!permissions.projectManagement && addForm.creatorId != user.id">
+                        <el-option v-for="(item) in mainProjectList" :key="item.id" :value="item.id" :label="item.name + '\u3000' + item.code">
+                            <span style="float: left; color: #8492a6; font-size: 13px;">{{ item.code }}</span>
+                            <span style="float: right;margin-left: 20px">{{ item.name }}</span>
+                        </el-option>
+                    </el-select>
                 </el-form-item>
                 <el-form-item label="项目分类">
                     <el-select v-model="addForm.category"  style="width:32%;" clearable :disabled="!permissions.projectManagement && addForm.creatorId != user.id">
@@ -504,11 +523,35 @@
                 <el-button type="primary" @click="addNewClf()" >新增分类项</el-button>
             </div>
         </el-dialog>
+        <!-- 主项目配置 -->
+        <el-dialog title="主项目管理" show-header="false" v-if="mainProjectDialog" :visible.sync="mainProjectDialog" :close-on-click-modal="false" customClass="customWidth" width="800px">
+            <el-table :data="mainProjectList" highlight-current-row  height="400" style="width: 100%;">
+                <el-table-column type="index" width="60" label="序号">
+                    <template slot-scope="scope" >
+                            {{scope.$index+1+(page-1)*size}}
+                        </template>
+                </el-table-column>
+                <el-table-column prop="code" label="编号" ></el-table-column>
+                <el-table-column prop="name" label="名称" ></el-table-column>
+                <el-table-column prop="categoryName" label="分类名称" ></el-table-column>
+                <el-table-column label="操作" width="150">
+                    <template slot-scope="scope" >
+                        <el-button size="small" type="primary" @click="addManPro(scope.row)">编辑</el-button>
+                        <el-button size="small" type="danger" @click="deleteManPro(scope.row)">删除</el-button>
+                    </template>
+                </el-table-column>
+
+            </el-table>
+            <div slot="footer" class="dialog-footer">
+                <el-button type="primary" @click="mainProjectDialog = false" >关闭</el-button>
+                <el-button type="primary" @click="addManPro()" >新增主项目</el-button>
+            </div>
+        </el-dialog>
         <!-- 新增/编辑 分类条目 -->
         <el-dialog title="新增/修改分类条目" v-if="addClfDialog" :visible.sync="addClfDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
             <el-form ref="form2" :model="addClf" :rules="rules" label-width="100px">
-                <el-form-item label="分类名称" prop="name">
-                    <el-input v-model="addClf.name" placeholder="请输入名称" clearable></el-input>
+                <el-form-item label="主项目名称" prop="name">
+                    <el-input v-model="addClf.name" placeholder="请输入主项目名称" clearable></el-input>
                 </el-form-item>
             </el-form>
             <div slot="footer" class="dialog-footer">
@@ -516,6 +559,26 @@
                 <el-button type="primary" @click="submitClf" :loading="addLoading">提交</el-button>
             </div>
         </el-dialog>
+        <!-- 新增/编辑主项目 -->
+        <el-dialog title="新增/修改主项目" v-if="addFlgmainProjectDialog" :visible.sync="addFlgmainProjectDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            <el-form ref="form2" :model="addMainForm" :rules="rules" label-width="100px">
+                <el-form-item label="主项目名称" prop="name">
+                    <el-input v-model="addMainForm.name" placeholder="请输入名称" clearable></el-input>
+                </el-form-item>
+                <el-form-item label="主项目编号" prop="code">
+                    <el-input v-model="addMainForm.code" placeholder="请输入编号" clearable></el-input>
+                </el-form-item>
+                <el-form-item label="分类管理">
+                    <el-select v-model="addMainForm.categoryId" placeholder="请选择分类" clearable >
+                        <el-option v-for="item in baseClfList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+                    </el-select>
+                </el-form-item>
+            </el-form>
+            <div slot="footer" class="dialog-footer">
+                <el-button @click.native="addFlgmainProjectDialog = false">取消</el-button>
+                <el-button type="primary" @click="submitManPro" :loading="addLoading">提交</el-button>
+            </div>
+        </el-dialog>
 
         <el-dialog title="新增/修改成本项" v-if="addBaseItemDialog" :visible.sync="addBaseItemDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
             <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
@@ -703,6 +766,9 @@ a {
         components:{projectgantt},
         data() {
             return {
+                addFlgmainProjectDialog: false,
+                mainProjectList: [],
+                mainProjectDialog: false,
                 showImportResult: false,
                 importResultMsg:null,
                 isganttshow: false,
@@ -780,7 +846,8 @@ a {
                 },
                 temaddForm: {},
                 rules: {
-                    name: [{ required: true, message: "请输入名称", trigger: "blur" }]
+                    name: [{ required: true, message: "请输入名称", trigger: "blur" }],
+                    code: [{ required: true, message: "请输入编号", trigger: "blur" }]
                 },
                 ause: [],
                 auseList: [],
@@ -790,6 +857,12 @@ a {
                 showClfDialog: false,
                 addClfDialog:false,
                 addClf:{name:'',id:''},
+                addMainForm:{
+                    name:'',
+                    id:'',
+                    code: '',
+                    categoryId: ''
+                },
                 statusClf:null,
                 permissionsObj: {},
 
@@ -809,7 +882,8 @@ a {
                 addGroupPersonPdialog: false,
                 showColumnWidth: '300',
                 deleteVif: null,
-                isAddGroupPerson: true
+                isAddGroupPerson: true,
+                projectMainId: ''
                 
             };
         },
@@ -843,6 +917,42 @@ a {
             }
         },
         methods: {
+            addManPro(row) {
+                this.addFlgmainProjectDialog = true
+                if(!row) {
+                    this.addMainForm = {
+                        name: '',
+                        id: '',
+                        code: '',
+                        categoryId: ''
+                    }
+                } else {
+                    this.addMainForm = {
+                        id: row.id,
+                        code: row.code,
+                        name: row.name,
+                        categoryId: row.categoryId,
+                    }
+                }
+            },
+            // 获取主项目
+            getMainProject() {
+                this.http.post('/project-main/list',{},res => {
+                    if(res.code == 'ok'){
+                        this.mainProjectList = res.data
+                    }else {
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        })
+                    }
+                },err => {
+                    this.$message({
+                        message: err,
+                        type: 'error'
+                    })
+                })
+            },
             // 批量修改自定义维度
             checkedWudulist(e){
                 console.log(e);
@@ -1686,6 +1796,28 @@ a {
                         }
                     );
             },
+            // 提交
+            submitManPro() {
+                this.http.post('/project-main/addOrMod',this.addMainForm,
+                    res => {
+                        if (res.code == "ok") {
+                            this.addFlgmainProjectDialog = false;
+                            this.getMainProject()
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                        }
+                    );
+            },
             // 删除
             deleteClf(row) {
                 this.$confirm("该操作可能造成已有数据丢失,确定要删除吗?","删除分类条目", {
@@ -1724,6 +1856,44 @@ a {
                 })
                 .catch(() => {});
             },
+            // 删除主项目
+            deleteManPro(row) {
+                this.$confirm("该操作可能造成已有数据丢失,确定要删除吗?","删除主项目", {
+                    confirmButtonText: "确定",
+                    cancelButtonText: "取消",
+                    type: "warning"
+                })
+                .then(() => {
+                    this.listLoading = true;
+                    this.http.post('/project-main/delete',{ 
+                        id: row.id 
+                    },
+                    res => {
+                        this.listLoading = false;
+                        if (res.code == "ok") {
+                            this.$message({
+                                message: "删除成功",
+                                type: "success"
+                            });
+                            this.getMainProject();
+                        } else {
+                            this.$message({
+                                message: res.msg,
+                                type: "error"
+                            });
+                        }
+                    },
+                    error => {
+                        this.listLoading = false;
+                        this.$message({
+                            message: error,
+                            type: "error"
+                        });
+                        }
+                    );
+                })
+                .catch(() => {});
+            },
             // 分类筛选
             searchClfList(){
                 this.page = 1;
@@ -2049,7 +2219,8 @@ a {
                     keyword:this.keyword,
                     searchField: this.searchField,
                     status: this.status,
-                    category: this.statusClf
+                    category: this.statusClf,
+                    projectMainId: this.projectMainId
                     // 
                 },
                 res => {
@@ -2131,7 +2302,8 @@ a {
                         chosenLeaders:[],
                         taskGpIncharge: 0,
                         category:null,
-                        creatorId: this.user.id
+                        creatorId: this.user.id,
+                        projectMainId: ''
                     }
                     this.projectBaseCostData = [];
                     this.auseList = [];
@@ -2175,7 +2347,8 @@ a {
                         customerId:item.customerId==0?null:item.customerId,
                         taskGpIncharge: item.taskGpIncharge,
                         category:item.category,
-                        projectDesc: item.projectDesc
+                        projectDesc: item.projectDesc,
+                        projectMainId: item.projectMainId
                     }
                     this.deleteVif = item.creatorId
                     console.log("handleadd",this.deleteVif,this.addForm.id)
@@ -2400,8 +2573,11 @@ a {
                         if(this.addForm.category != null) {
                             formData.append("category", this.addForm.category);
                         }
+                        if(this.user.timeType.mainProjectState == '1') {
+                            formData.append("projectMainId", this.addForm.projectMainId);
+                        }
                         // formData.append("associateDegreeNames", listName)
-                        // console.log("addform",formData);
+                        // console.log("addform",this.addForm);
                         // return
                         this.http.uploadFile(this.port.project.add,formData,
                         res => {
@@ -2537,6 +2713,7 @@ a {
             this.getProjectBaseConfigList();
             this.getClfConfigList()
             this.yanjiuzx()
+            this.getMainProject()
         }
     };
 </script>

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/quanx/quanx.vue

@@ -2,7 +2,7 @@
   <div>
       <!-- 表头 -->
       <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
-          <el-form :inline="true" style="width: 81%">
+          <el-form :inline="true" style="width: 87%">
               <el-form-item label="角色权限">
               </el-form-item>
               <el-form-item >

+ 3 - 1
fhKeeper/formulahousekeeper/timesheet/src/views/settings/timetype.vue

@@ -310,7 +310,7 @@
         <!-- 是否开启主项目管理 -->
         <!-- <div class="yanjiu">
             <p style="margin-left:10px;color:#666;">是否开启主项目管理</p>
-            <el-switch style="margin-left: 55px" v-model="timeType.mainProjectState" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
+            <el-switch style="margin-left: 41px" v-model="timeType.mainProjectState" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
             <span v-if="timeType.mainProjectState == 1" style="margin-left:10px;color:#999;">待定</span>
         </div> -->
 
@@ -913,6 +913,7 @@
                         param.fillOvertime = param.fillOvertime ? 1 : 0
                         param.lockWorktime = param.lockWorktime ? 1 : 0
                         param.fillAhead = param.fillAhead ? 1 : 0
+                        param.mainProjectState = param.mainProjectState ? 1 : 0
                         if(param.lockWorktime){
                             param.fillOvertime = 0
                             param.payOvertime = 0
@@ -983,6 +984,7 @@
                             this.timeType.customDegreeStatus = this.timeType.customDegreeStatus ? true : false
                             this.timeType.customDataStatus = this.timeType.customDataStatus ? true : false
                             this.timeType.fillAhead = this.timeType.fillAhead ? true : false
+                            this.timeType.mainProjectState = this.timeType.mainProjectState ? true : false
                             this.timeChange();
                             let userlist = res.data.userList
                             this.whiteList = []