Min 1 year ago
parent
commit
4de36d3953

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

@@ -95,7 +95,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     //获取项目的成本预警和实际工时表
     List<HashMap> getProjectCostAlarm(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId);
 
-    List getBaseCostAndRealCost(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId);
+    List getBaseCostAndRealCost(Integer companyId, Integer pageStart, Integer pageSize, Integer projectId,@Param("list")List<Integer> projectIds);
 
     List<Map<String, Object>> getProjectCostGroupByProject(Integer companyId, String startDate, String endDate, Integer projectId,List<String> userIdList,List<Integer> deptIds);
 

+ 26 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -7067,9 +7067,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         if (projectId != null) {
             queryWrapper.eq("id", projectId);
         }
-        int total = projectMapper.selectCount(queryWrapper);
         int pageStart = (pageIndex -1) * pageSize;
-        List projectList = projectMapper.getBaseCostAndRealCost(companyId, pageStart, pageSize, projectId);
+        boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "全部工时成本预警表");
+        boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责项目工时成本预警表");
+        List projectList=new ArrayList();
+        if(viewAll){
+            projectList = projectMapper.getBaseCostAndRealCost(companyId, pageStart, pageSize, projectId,null);
+        }else if(incharger){
+            List<Project> inchargerProjects = projectMapper.selectList(new LambdaQueryWrapper<Project>().select(Project::getId).eq(Project::getInchargerId, user.getId()));
+            List<Integer> projectIds = inchargerProjects.stream().map(Project::getId).distinct().collect(Collectors.toList());
+            projectIds.add(-1);
+            projectList = projectMapper.getBaseCostAndRealCost(companyId, pageStart, pageSize, projectId,projectIds);
+            if(projectIds!=null&&projectIds.size()>0){
+                queryWrapper.in("id",projectIds);
+            }
+        }
+        int total = projectMapper.selectCount(queryWrapper);
         //查询项目的各个成本项实际的成本
         List<Integer> pids = new ArrayList<>();
         for (int i=0;i<projectList.size(); i++) {
@@ -7124,7 +7137,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         User user = userMapper.selectById(request.getHeader("Token"));
         Integer companyId = user.getCompanyId();
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
-        List<HashMap> projectList = projectMapper.getBaseCostAndRealCost(companyId, null, null, null);
+        boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "全部工时成本预警表");
+        boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责项目工时成本预警表");
+        List<HashMap> projectList=new ArrayList();
+        if(viewAll){
+            projectList = projectMapper.getBaseCostAndRealCost(companyId, null, null, null,null);
+        }else if(incharger){
+            List<Project> inchargerProjects = projectMapper.selectList(new LambdaQueryWrapper<Project>().select(Project::getId).eq(Project::getInchargerId, user.getId()));
+            List<Integer> projectIds = inchargerProjects.stream().map(Project::getId).distinct().collect(Collectors.toList());
+            projectIds.add(-1);
+            projectList = projectMapper.getBaseCostAndRealCost(companyId, null, null, null,projectIds);
+        }
         List<List<String>> exportList = new ArrayList<>();
         //String[] titles = {"项目编号", "项目名称", "当前总预算","当前剩余预算","总剩余预算","已发生总工时成本"};
         String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.totalBudget"),MessageUtils.message("entry.curRemBud"),MessageUtils.message("entry.totalRemBud"),MessageUtils.message("entry.totalLaborCostIncurred")};

+ 18 - 17
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -972,6 +972,12 @@
         <if test="projectId != null">
             and project.id = #{projectId}
         </if>
+        <if test="list!=null and list.size()>0">
+            and project.id in
+            <foreach collection="list" open="(" close=")" item="item" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="pageStart != null and pageSize != null">
             LIMIT #{pageStart},#{pageSize}
         </if>
@@ -1780,7 +1786,7 @@
 
     <select id="userProjectProcessList" resultType="java.util.Map">
         select d.department_name as departmentName,d.corpwx_deptid as corpwxDeptId,u.corpwx_userid as corpwxUserId,u.name as userName,u.job_number as jobNumber,p.project_name as projectName,p.project_code as projectCode,
-        IFNULL(IFNULL(SUM(te.plan_hours),0)-IFNULL((select SUM(working_time) from report where task_id=te.task_id),0),0)as residueTime
+        IFNULL(IFNULL(SUM(te.plan_hours),0)-IFNULL((select SUM(working_time) from report where task_id=te.task_id and state=1),0),0)as residueTime
         from task_executor te
         left join  user u on u.id=te.executor_id
         left join department d on d.department_id=u.department_id
@@ -1838,18 +1844,18 @@
 
     <select id="groupExpendProcessList" resultType="java.util.Map">
         select d.department_name,d.corpwx_deptid as corpwxDeptId,tg.name as groupName,IFNULL(SUM(te.plan_hours),0) as planHour,
-        IFNULL(IFNULL((select SUM(working_time) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        IFNULL(IFNULL((select SUM(working_time) from report where group_id=tg.id and state=1 <if test="startDate!=null and endDate!=null">
           and  create_date between #{startDate} and #{endDate}
-        </if> ),0)-IFNULL((select SUM(overtime_hours) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        </if> ),0)-IFNULL((select SUM(overtime_hours) from report where group_id=tg.id and state=1 <if test="startDate!=null and endDate!=null">
           and create_date between #{startDate} and #{endDate}
         </if>),0),0) as normalHour,
-        IFNULL((select SUM(overtime_hours) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        IFNULL((select SUM(overtime_hours) from report where group_id=tg.id and state=1 <if test="startDate!=null and endDate!=null">
           and create_date between #{startDate} and #{endDate}
         </if>),0) as overHour,
-        IFNULL((select SUM(working_time) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        IFNULL((select SUM(working_time) from report where group_id=tg.id and state=1 <if test="startDate!=null and endDate!=null">
           and create_date between #{startDate} and #{endDate}
         </if>),0) as realHour,
-        IFNULL((select SUM(cost) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        IFNULL((select SUM(cost) from report where group_id=tg.id and state=1 <if test="startDate!=null and endDate!=null">
           and create_date between #{startDate} and #{endDate}
         </if>),0) as realCost
         from task_executor te
@@ -1898,9 +1904,9 @@
 
     <select id="projectExpendProcessList" resultType="java.util.Map">
         select p.project_name as projectName,pc.name as categoryName,p.project_code as projectCode,IFNULL(SUM(te.plan_hours),0) as planHour,
-        IFNULL((select SUM(working_time) from report where project_id=p.id),0) as realHour, IFNULL((select SUM(cost) from report where project_id=p.id),0) as realCost,
-        IFNULL(IFNULL(SUM(te.plan_hours),0)-IFNULL((select SUM(working_time) from report where project_id=p.id),0),0) as residueHour,
-        GROUP_CONCAT(CONCAT_WS('|',te.executor_name,IFNULL((select SUM(working_time) from report where creator_id=te.executor_id and project_id=p.id),0))) as executorString
+        IFNULL((select SUM(working_time) from report where project_id=p.id and state=1),0) as realHour, IFNULL((select SUM(cost) from report where project_id=p.id and state=1),0) as realCost,
+        IFNULL(IFNULL(SUM(te.plan_hours),0)-IFNULL((select SUM(working_time) from report where project_id=p.id and state=1),0),0) as residueHour,
+        GROUP_CONCAT(CONCAT_WS('|',te.executor_name,IFNULL((select SUM(working_time) from report where creator_id=te.executor_id and project_id=p.id and state=1),0))) as executorString
         from task_executor te
         left join  user u on u.id=te.executor_id
         left join department d on u.department_id=d.department_id
@@ -1931,11 +1937,7 @@
 
     <select id="projectExpendProcessListCount" resultType="java.lang.Long">
         select count(1) from (
-        select p.project_name as projectName,pc.name as categoryName,p.project_code as projectCode,IFNULL(SUM(te.plan_hours),0) as planHour,
-        IFNULL((select SUM(working_time) from report where task_id=te.task_id),0) as realHour,
-        IFNULL((select SUM(cost) from report where task_id=te.task_id),0) as realCost,
-        IFNULL(IFNULL(SUM(te.plan_hours),0)-IFNULL((select SUM(working_time) from report where task_id=te.task_id),0),0) as residueHour,
-        GROUP_CONCAT(CONCAT_WS('|',te.executor_name,CONCAT_WS('',FORMAT(IFNULL(IFNULL((select SUM(working_time) from report where creator_id=te.executor_id and task_id=t.id),0)/(IFNULL((select SUM(working_time) from report where task_id=te.task_id),0)),0)*100,2),'%'))) as executorString
+        select p.project_name as projectName
         from task_executor te
         left join  user u on u.id=te.executor_id
         left join department d on u.department_id=d.department_id
@@ -1964,7 +1966,7 @@
 
     <select id="userTaskProcessList" resultType="java.util.Map">
         select d.department_name as departmentName,d.corpwx_deptid as corpwxDeptId,u.corpwx_userid as corpwxUserId,t.name as taskName,IFNULL(t.plan_hours,0) as planHour,u.name as userName,u.job_number as jobNumber,p.project_name as projectName,p.project_code as projectCode,
-        IFNULL((select SUM(working_time) from report where task_id=te.task_id),0)as consumeTime
+        IFNULL((select SUM(working_time) from report where task_id=te.task_id and state=1),0)as consumeTime
         from task_executor te
         left join  user u on u.id=te.executor_id
         left join department d on d.department_id=u.department_id
@@ -1998,8 +2000,7 @@
 
     <select id="userTaskProcessListCount" resultType="java.lang.Long">
         select count(1) from (
-        select d.department_name as departmentName,d.corpwx_deptid as corpwxDeptId,u.corpwx_userid as corpwxUserId,t.name as taskName,IFNULL(t.plan_hours,0) as planHour,u.name as userName,u.job_number as jobNumber,p.project_name as projectName,p.project_code as projectCode,
-        IFNULL((select SUM(working_time) from report where task_id=te.task_id),0)as consumeTime
+        select d.department_name as departmentName
         from task_executor te
         left join  user u on u.id=te.executor_id
         left join department d on d.department_id=u.department_id

+ 1 - 1
fhKeeper/formulahousekeeper/timesheet/src/permissions.js

@@ -199,7 +199,7 @@ const StringUtil = {
         arr[i] == '管理专业证书' ? obj.structureCertificate = true : ''
         arr[i] == '查看加班成本' ? obj.reportCost = true : ''
         arr[i] == '下拨成本预算' ? obj.projectAllocate = true : ''
-        arr[i] == '工时成本预警表' ? obj.reportCostWarning = true : ''
+        arr[i] == '全部工时成本预警表' || arr[i] == '负责项目工时成本预警表' ? obj.reportCostWarning = true : ''
         arr[i] == '查看阶段成本' ? obj.reportPhaseCost = true : ''
         arr[i] == '全公司工时分配' ? obj.reportAllTimeDivide = true : ''
         arr[i] == '负责部门工时分配' ? obj.reportTimeDivide = true : ''