Min 10 달 전
부모
커밋
2135bb595a

+ 16 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -1477,16 +1477,28 @@ public class ProjectController {
         return projectService.groupExpendProcessList(startDate,endDate,projectId,pageIndex,pageSize);
     }
 
-    //依斯倍定制 分组耗用进度
+    //依斯倍定制 分组耗用
     @RequestMapping("/groupExpendProcessListForChart")
     public HttpRespMsg groupExpendProcessListForChart(String startDate,String endDate,String projectIds,String groupNames){
         return projectService.groupExpendProcessListForChart(startDate,endDate,projectIds,groupNames);
     }
 
-    //依斯倍定制 分组耗用表针对部门人员
+    //依斯倍定制 分组耗用人员分组耗用
     @RequestMapping("/groupExpendProcessListForUser")
-    public HttpRespMsg groupExpendProcessListForUser(String startDate,String endDate,String projectIds,String groupNames,String deptIdStr){
-        return projectService.groupExpendProcessListForUser(startDate,endDate,projectIds,groupNames,deptIdStr);
+    public HttpRespMsg groupExpendProcessListForUser(String startDate,String endDate,String projectIds,String groupNames,String deptIdStr,Integer pageIndex,Integer pageSize){
+        return projectService.groupExpendProcessListForUser(startDate,endDate,projectIds,groupNames,deptIdStr,pageIndex,pageSize);
+    }
+
+    //依斯倍定制 分组耗用人员分组耗用
+    @RequestMapping("/exportGroupExpendProcessListForUser")
+    public HttpRespMsg exportGroupExpendProcessListForUser(String startDate,String endDate,String projectIds,String groupNames,String titleStr,String deptIdStr){
+        return projectService.exportGroupExpendProcessListForUser(startDate,endDate,projectIds,groupNames,titleStr,deptIdStr);
+    }
+
+    //依斯倍定制 分组耗用表项目占比
+    @RequestMapping("/groupExpendProcessListForProject")
+    public HttpRespMsg groupExpendProcessListForProject(String startDate,String endDate,String projectIds,String groupNames,String deptIdStr,Integer pageIndex,Integer pageSize){
+        return projectService.groupExpendProcessListForProject(startDate,endDate,projectIds,groupNames,deptIdStr,pageIndex,pageSize);
     }
 
     //依斯倍定制 导出分组耗用进度表

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

@@ -9,6 +9,7 @@ import com.management.platform.entity.vo.StageCost;
 import com.management.platform.entity.vo.UserCateTimeVo;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
+import org.omg.CORBA.INTERNAL;
 
 import java.time.LocalDate;
 import java.util.HashMap;
@@ -187,5 +188,11 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
     List<Map<String, Object>> groupExpendProcessListForChart(String userId, Integer companyId, String startDate, String endDate,@Param("list") List<Integer> deptIds,@Param("listSecond") List<Integer> regularDeptIds,@Param("listThird") List<Integer> projectIdList,@Param("listFour") List<String> groupNameList);
 
-    List<Map<String, Object>> groupExpendProcessListForUser(Object o, Integer companyId, String startDate, String endDate,@Param("list") List<Integer> deptIds,@Param("listSecond") List<Integer> regularDeptIds, @Param("listThird")List<Integer> projectIdList,@Param("listFour") List<String> groupNameList,@Param("listFive") List<Integer> deptIdList);
+    List<Map<String, Object>> groupExpendProcessListForUser(String userId, Integer companyId, String startDate, String endDate, @Param("list") List<Integer> deptIds, @Param("listSecond") List<Integer> regularDeptIds, @Param("listThird")List<Integer> projectIdList, @Param("listFour") List<String> groupNameList, @Param("listFive") List<Integer> deptIdList,Integer start,Integer size);
+
+    Integer groupExpendProcessListForUserCount(String userId, Integer companyId, String startDate, String endDate, @Param("list") List<Integer> deptIds, @Param("listSecond") List<Integer> regularDeptIds, @Param("listThird")List<Integer> projectIdList, @Param("listFour") List<String> groupNameList, @Param("listFive") List<Integer> deptIdList);
+
+    List<Map<String, Object>> groupExpendProcessListForProject(String userId,  Integer companyId, String startDate, String endDate, @Param("list") List<Integer> deptIds, @Param("listSecond") List<Integer> regularDeptIds, @Param("listThird")List<Integer> projectIdList, @Param("listFour") List<String> groupNameList, @Param("listFive") List<Integer> deptIdList,Integer start,Integer size);
+
+    Integer groupExpendProcessListForProjectCount(String userId, Integer companyId, String startDate, String endDate, @Param("list") List<Integer> deptIds, @Param("listSecond") List<Integer> regularDeptIds, @Param("listThird")List<Integer> projectIdList, @Param("listFour") List<String> groupNameList, @Param("listFive") List<Integer> deptIdList);
 }

+ 6 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -301,5 +301,10 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg groupExpendProcessListForChart(String startDate, String endDate, String projectIds, String groupNames);
 
-    HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr);
+    HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize);
+
+    HttpRespMsg groupExpendProcessListForProject(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize);
+
+    HttpRespMsg exportGroupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames,String titleStr, String deptIdStr);
+
 }

+ 149 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -14409,12 +14409,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr) {
+    public HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize) {
         HttpRespMsg msg=new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
         List<Department> departments = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()));
         NumberFormat percentFormat = NumberFormat.getPercentInstance();
         percentFormat.setMaximumFractionDigits(2);
+        Integer start=null;
+        Integer size=null;
+        if(pageIndex!=null&&pageSize!=null){
+            size=pageSize;
+            start=(pageIndex-1)*size;
+        }
         Integer companyId = user.getCompanyId();
         List<String> groupNameList=new ArrayList<>();
         List<Integer> projectIdList=new ArrayList<>();
@@ -14432,6 +14438,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责部门分组耗用进度表");
         List<Department> allDeptList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
         List<Map<String,Object>> resultList;
+        Integer total;
         //是否具有查看全部数据的权限
         //针对依斯呗 指定部门
         List<Integer> regularDeptIds=new ArrayList<>();
@@ -14451,7 +14458,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         if(!viewAll){
             if(!incharger){
                 //只能查看本人的数据
-                resultList=projectMapper.groupExpendProcessListForUser(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
+                resultList=projectMapper.groupExpendProcessListForUser(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList,start,size);
+                total=projectMapper.groupExpendProcessListForUserCount(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
             }else {
                 List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getManagerId, user.getId()));
                 List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
@@ -14465,16 +14473,152 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
                     deptIds.addAll(branchDepartment);
                 }
-                resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
+                resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
+                total=projectMapper.groupExpendProcessListForUserCount(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
             }
         }else {
-            resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
+            resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
+            total=projectMapper.groupExpendProcessListForUserCount(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
         }
         resultList.forEach(r->{
             Optional<Department> department = departments.stream().filter(d -> d.getDepartmentId().equals(Integer.valueOf(String.valueOf(r.get("departmentId"))))).findFirst();
             r.put("departmentName",departmentService.getSupDepartment(department.get(),departments));
         });
-        msg.setData(resultList);
+        Map<String,Object> map=new HashMap<>();
+        map.put("record",resultList);
+        map.put("total",total);
+        msg.setData(map);
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg groupExpendProcessListForProject(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize) {
+        HttpRespMsg msg=new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<Department> departments = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()));
+        NumberFormat percentFormat = NumberFormat.getPercentInstance();
+        percentFormat.setMaximumFractionDigits(2);
+        Integer start=null;
+        Integer size=null;
+        if(pageIndex!=null&&pageSize!=null){
+            size=pageSize;
+            start=(pageIndex-1)*size;
+        }
+        Integer companyId = user.getCompanyId();
+        List<String> groupNameList=new ArrayList<>();
+        List<Integer> projectIdList=new ArrayList<>();
+        List<Integer> deptIdList=new ArrayList<>();
+        if(!StringUtils.isEmpty(groupNames)){
+            groupNameList = Arrays.asList(groupNames.split(","));
+        }
+        if(!StringUtils.isEmpty(projectIds)){
+            projectIdList=Arrays.asList(projectIds.split(",")).stream().map(i->Integer.valueOf(i)).collect(Collectors.toList());
+        }
+        if(!StringUtils.isEmpty(deptIdStr)){
+            deptIdList=Arrays.asList(deptIdStr.split(",")).stream().map(i->Integer.valueOf(i)).collect(Collectors.toList());
+        }
+        boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "全部分组耗用进度表");
+        boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责部门分组耗用进度表");
+        List<Department> allDeptList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
+        List<Map<String,Object>> resultList;
+        Integer total;
+        //是否具有查看全部数据的权限
+        //针对依斯呗 指定部门
+        List<Integer> regularDeptIds=new ArrayList<>();
+        if(user.getCompanyId()==3092){
+            List<String> nameString=new ArrayList<>();
+            nameString.add("4");
+            nameString.add("46");
+            nameString.add("45");
+            List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()).in(Department::getDepartmentName, nameString));
+            List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+            theCollect.add(-1);
+            for (Integer integer : theCollect) {
+                List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
+                regularDeptIds.addAll(branchDepartment);
+            }
+        }
+        if(!viewAll){
+            if(!incharger){
+                //只能查看本人的数据
+                resultList=projectMapper.groupExpendProcessListForProject(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList,start,size);
+                total=projectMapper.groupExpendProcessListForProjectCount(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
+            }else {
+                List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getManagerId, user.getId()));
+                List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
+                List<Integer> deptIds=new ArrayList<>();
+                List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                theCollect.add(-1);
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
+                otherCollect.add(-1);
+                theCollect.addAll(otherCollect);
+                for (Integer integer : theCollect) {
+                    List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
+                    deptIds.addAll(branchDepartment);
+                }
+                resultList=projectMapper.groupExpendProcessListForProject(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
+                total=projectMapper.groupExpendProcessListForProjectCount(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
+            }
+        }else {
+            resultList=projectMapper.groupExpendProcessListForProject(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
+            total=projectMapper.groupExpendProcessListForProjectCount(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
+        }
+        //计算占比
+        double workTime = resultList.stream().mapToDouble(r -> Double.valueOf(String.valueOf(r.get("workTime")))).sum();
+        resultList.forEach(r->{
+            BigDecimal time = new BigDecimal(String.valueOf(r.get("workTime")));
+            time=time.divide(new BigDecimal(workTime),4,RoundingMode.HALF_UP);
+            time=time.multiply(new BigDecimal(100));
+//            String format = percentFormat.format(time.doubleValue());
+            r.put("percent",time.doubleValue()+"%");
+        });
+        Map<String,Object> map=new HashMap<>();
+        map.put("record",resultList);
+        map.put("total",total);
+        msg.setData(map);
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg exportGroupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames,String titleStr, String deptIdStr) {
+        User user = userMapper.selectById(request.getHeader("token"));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
+        List<List<String>> dataList=new ArrayList<>();
+        List<String> titleList=new ArrayList<>();
+        titleList.add("所属部门");
+        titleList.add("工号");
+        titleList.add("员工");
+        if(!StringUtils.isEmpty(titleStr)){
+            List<String> strings = Arrays.asList(titleStr.split(","));
+            titleList.addAll(strings);
+        }
+        dataList.add(titleList);
+        HttpRespMsg msg = groupExpendProcessListForUser(startDate, endDate, projectIds, groupNames, deptIdStr, null, null);
+        Map<String, Object> data = (Map<String, Object>)  msg.data;
+        List<Map<String, Object>> mapList = (List<Map<String, Object>>) data.get("record");
+        for (Map<String, Object> map : mapList) {
+            List<String> item=new ArrayList<>();
+            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                item.add("$departmentName="+String.valueOf(map.get("departmentName"))+"$");
+            }else {
+                item.add(String.valueOf(map.get("departmentName")));
+            }
+            item.add(String.valueOf(map.get("jobNumber")));
+            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                item.add("$userName="+String.valueOf(map.get("userName"))+"$");
+            }else {
+                item.add(String.valueOf(map.get("userName")));
+            }
+            for (String s : titleList) {
+                item.add(String.valueOf(map.get(s)));
+            }
+            dataList.add(item);
+        }
+        try {
+            return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,null,"人员分组耗用表",dataList,path);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return msg;
     }
 }

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

@@ -1970,8 +1970,125 @@
     </select>
 
     <select id="groupExpendProcessListForUser" resultType="java.util.Map">
-        SELECT departmentId, departmentName,jobNumber,userName ,groupName,IFNULL(SUM(workTime),0) as workTime FROM (
-        SELECT d.`department_id` AS departmentId,d.`department_name` AS departmentName,u.`job_number` AS jobNumber,u.`name` AS userName ,tg.name AS groupName,rr.realHour AS workTime,u.id
+        SELECT departmentId, departmentName,jobNumber,userName,
+        SUM(CASE WHEN groupName='方案设计' THEN workTime ELSE 0 END) AS '方案设计' ,
+        SUM(CASE WHEN groupName='研发部' THEN workTime ELSE 0 END) AS '研发部' ,
+        SUM(CASE WHEN groupName='研发部工艺调试' THEN workTime ELSE 0 END) AS '研发部工艺调试',
+        SUM(CASE WHEN groupName='研发部工艺调试验收' THEN workTime ELSE 0 END) AS '研发部工艺调试验收' ,
+        SUM(CASE WHEN groupName='研发部工艺设计' THEN workTime ELSE 0 END) AS '研发部工艺设计' ,
+        SUM(CASE WHEN groupName='研发部BIM设计' THEN workTime ELSE 0 END) AS '研发部BIM设计' ,
+        SUM(CASE WHEN groupName='研发部电气调试验收' THEN workTime ELSE 0 END) AS '研发部电气调试验收' ,
+        SUM(CASE WHEN groupName='研发部电气设计' THEN workTime ELSE 0 END) AS '研发部电气设计' ,
+        SUM(CASE WHEN groupName='研发部售后' THEN workTime ELSE 0 END) AS '研发部售后' ,
+        SUM(CASE WHEN groupName='工程部配合运维' THEN workTime ELSE 0 END) AS '工程部配合运维' ,
+        SUM(CASE WHEN groupName='研发部运维' THEN workTime ELSE 0 END) AS '研发部运维' ,
+        SUM(CASE WHEN groupName='生产部' THEN workTime ELSE 0 END) AS '生产部' ,
+        SUM(CASE WHEN groupName='生产部车间' THEN workTime ELSE 0 END) AS '生产部车间' ,
+        SUM(CASE WHEN groupName='生产部电气' THEN workTime ELSE 0 END) AS '生产部电气' ,
+        SUM(CASE WHEN groupName='工程部配合调试' THEN workTime ELSE 0 END) AS '工程部配合调试' ,
+        SUM(CASE WHEN groupName='工程部' THEN workTime ELSE 0 END) AS '工程部' ,
+        SUM(CASE WHEN groupName='工程部售后' THEN workTime ELSE 0 END) AS '工程部售后' ,
+        SUM(CASE WHEN groupName='工程部现场安装施工' THEN workTime ELSE 0 END) AS '工程部现场安装施工',
+        SUM(workTime) AS 'totalWorkTime'
+        FROM (
+            SELECT  d.`department_id` AS departmentId,d.`department_name` AS departmentName,u.`job_number` AS jobNumber,u.`name` AS userName ,tg.name AS groupName,rr.realHour AS workTime,u.id
+            FROM task_executor te
+            LEFT JOIN task t ON t.id=te.task_id
+            LEFT JOIN `user` u ON te.executor_id=u.id
+            LEFT JOIN task_group tg ON tg.id=t.group_id
+            LEFT JOIN project p ON p.id=tg.project_id
+            LEFT JOIN department d ON d.department_id=u.department_id
+            LEFT JOIN (
+            SELECT r.creator_id AS creatorId,SUM(r.working_time) AS realHour,tg.id AS groupId
+            FROM report r
+            LEFT JOIN task_group tg ON r.group_id=tg.`id`
+            WHERE r.state=1 AND r.project_id IS NOT NULL
+            <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
+                AND r.create_date  BETWEEN #{startDate} AND #{endDate}
+            </if>  AND r.company_id=#{companyId}
+            GROUP BY r.creator_id,tg.id ) rr ON rr.groupId=tg.`id` AND rr.creatorId=u.id
+            WHERE u.company_id=#{companyId}
+            <if test="listThird!=null and listThird.size()>0">
+                AND tg.project_id in
+                <foreach collection="listThird" separator="," open="(" close=")" item="item">
+                    #{item}
+                </foreach>
+            </if>
+            AND tg.name IN ('方案设计','研发部','生产部','工程部','生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
+            <if test="listFour!=null and listFour.size()>0">
+                and tg.name in
+                <foreach collection="listFour" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            GROUP BY u.`id`,tg.id
+            ) AS t
+            <where>
+            <if test="listFive!=null and listFive.size()>0">
+                t.departmentId in
+                <foreach collection="listFive" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            </where>
+            GROUP BY t.id
+            <if test="start!=null and size!=null">
+                limit #{start},#{size}
+            </if>
+    </select>
+
+    <select id="groupExpendProcessListForUserCount" resultType="java.lang.Integer">
+        select count(1) from (
+        SELECT departmentId,departmentName,jobNumber,userName
+        FROM (
+            SELECT d.`department_id` AS departmentId,d.`department_name` AS departmentName,u.`job_number` AS jobNumber,u.`name` AS userName ,tg.name AS groupName,rr.realHour AS workTime,u.id
+            FROM task_executor te
+            LEFT JOIN task t ON t.id=te.task_id
+            LEFT JOIN `user` u ON te.executor_id=u.id
+            LEFT JOIN task_group tg ON tg.id=t.group_id
+            LEFT JOIN project p ON p.id=tg.project_id
+            LEFT JOIN department d ON d.department_id=u.department_id
+            LEFT JOIN (
+            SELECT r.creator_id AS creatorId,SUM(r.working_time) AS realHour,tg.id AS groupId
+            FROM report r
+            LEFT JOIN task_group tg ON r.group_id=tg.`id`
+            WHERE r.state=1 AND r.project_id IS NOT NULL
+            <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
+                AND r.create_date  BETWEEN #{startDate} AND #{endDate}
+            </if>  AND r.company_id=#{companyId}
+            GROUP BY r.creator_id,tg.id ) rr ON rr.groupId=tg.`id` AND rr.creatorId=u.id
+            WHERE u.company_id=#{companyId}
+            <if test="listThird!=null and listThird.size()>0">
+                AND tg.project_id in
+                <foreach collection="listThird" separator="," open="(" close=")" item="item">
+                    #{item}
+                </foreach>
+            </if>
+            AND tg.name IN ('方案设计','研发部','生产部','工程部','生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
+            <if test="listFour!=null and listFour.size()>0">
+                and tg.name in
+                <foreach collection="listFour" close=")" open="(" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+            GROUP BY u.`id`,tg.id
+            ) AS t
+            <where>
+                <if test="listFive!=null and listFive.size()>0">
+                    t.departmentId in
+                    <foreach collection="listFive" close=")" open="(" separator="," item="item">
+                        #{item}
+                    </foreach>
+                </if>
+            </where>
+            GROUP BY t.id
+        ) as total
+    </select>
+
+    <select id="groupExpendProcessListForProject" resultType="java.util.Map">
+        SELECT projectName,projectId,projectCode,SUM(realHour) AS workTime  FROM (
+        SELECT p.project_name AS projectName,p.project_code as projectCode,p.id AS projectId,tg.id AS groupId,tg.name AS groupName,
+        IFNULL(r.realHour,0) AS realHour
         FROM task_executor te
         LEFT JOIN task t ON t.id=te.task_id
         LEFT JOIN `user` u ON te.executor_id=u.id
@@ -1979,15 +2096,12 @@
         LEFT JOIN project p ON p.id=tg.project_id
         LEFT JOIN department d ON d.department_id=u.department_id
         LEFT JOIN (
-        SELECT r.creator_id AS creatorId,SUM(r.working_time) AS realHour,tg.id AS groupId
-        FROM report r
-        LEFT JOIN task_group tg ON r.group_id=tg.`id`
-        WHERE state=1
+        SELECT SUM(working_time) AS realHour,group_id,dept_id
+        FROM report  WHERE state=1
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            AND r.create_date BETWEEN #{startDate} AND #{endDate}
+            AND create_date  BETWEEN #{startDate} AND #{endDate}
         </if>
-        AND r.project_id IS NOT NULL AND r.company_id=#{companyId}
-        GROUP BY r.creator_id,tg.id ) rr ON rr.groupId=tg.`id` AND rr.creatorId=u.id
+        AND project_id IS NOT NULL AND company_id=#{companyId} GROUP BY group_id) r ON r.group_id=tg.`id`
         WHERE u.company_id=#{companyId}
         <if test="listThird!=null and listThird.size()>0">
             AND tg.project_id in
@@ -1995,24 +2109,75 @@
                 #{item}
             </foreach>
         </if>
-        <if test="listFive!=null and listFive.size()>0">
-            AND  d.id in
-            <foreach collection="listFive" separator="," open="(" close=")" item="item">
+        AND tg.name IN ('方案设计','研发部','生产部','工程部','生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
+        <if test="listFour!=null and listFour.size()>0">
+            and tg.name in
+            <foreach collection="listFour" close=")" open="(" separator="," item="item">
                 #{item}
             </foreach>
         </if>
-        AND tg.name IN ('研发部','生产部','工程部','生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
-        GROUP BY u.`id`,tg.id
-        ) AS t
+        GROUP BY p.id,tg.id ORDER BY p.id,d.department_id) AS f
         <where>
+            realHour>0
+            <if test="listThird!=null and listThird.size()>0">
+                and
+                projectId in
+                <foreach collection="listThird" separator="," open="(" close=")" item="item">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        GROUP BY  projectId
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
+    </select>
+
+    <select id="groupExpendProcessListForProjectCount" resultType="java.lang.Integer">
+        select count(1) from (
+            SELECT projectName,projectId,projectCode,SUM(realHour) AS workTime  FROM (
+            SELECT p.project_name AS projectName,p.project_code as projectCode,p.id AS projectId,tg.id AS groupId,tg.name AS groupName,
+            IFNULL(r.realHour,0) AS realHour
+            FROM task_executor te
+            LEFT JOIN task t ON t.id=te.task_id
+            LEFT JOIN `user` u ON te.executor_id=u.id
+            LEFT JOIN task_group tg ON tg.id=t.group_id
+            LEFT JOIN project p ON p.id=tg.project_id
+            LEFT JOIN department d ON d.department_id=u.department_id
+            LEFT JOIN (
+            SELECT SUM(working_time) AS realHour,group_id,dept_id
+            FROM report  WHERE state=1
+            <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
+                AND create_date  BETWEEN #{startDate} AND #{endDate}
+            </if>
+            AND project_id IS NOT NULL AND company_id=#{companyId} GROUP BY group_id) r ON r.group_id=tg.`id`
+            WHERE u.company_id=#{companyId}
+            <if test="listThird!=null and listThird.size()>0">
+                AND tg.project_id in
+                <foreach collection="listThird" separator="," open="(" close=")" item="item">
+                    #{item}
+                </foreach>
+            </if>
+            AND tg.name IN ('方案设计','研发部','生产部','工程部','生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
             <if test="listFour!=null and listFour.size()>0">
-                t.groupName in
+                and tg.name in
                 <foreach collection="listFour" close=")" open="(" separator="," item="item">
                     #{item}
                 </foreach>
             </if>
-        </where>
-        GROUP BY t.id,t.groupName
+            GROUP BY p.id,tg.id ORDER BY p.id,d.department_id) AS f
+            <where>
+                realHour>0
+                <if test="listThird!=null and listThird.size()>0">
+                    and
+                    projectId in
+                    <foreach collection="listThird" separator="," open="(" close=")" item="item">
+                        #{item}
+                    </foreach>
+                </if>
+            </where>
+            GROUP BY  projectId
+        ) as total
     </select>
 
     <select id="projectExpendProcessList" resultType="java.util.Map">