Pārlūkot izejas kodu

预估工时查询优化修改,导出修改

yusm 7 mēneši atpakaļ
vecāks
revīzija
eb047b60ef

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

@@ -220,4 +220,12 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> getCostTimeByUserForDay(Integer companyId, String startDate, String endDate);
 
     List<Map<String, Object>> getTotalProjectByTime(Integer companyId, String startDate, String endDate);
+
+    List<Map<String, Object>> selectProjectEestimatedWorkTimeList(@Param("map") Map<String, Object> map);
+
+    Integer selectProjectEestimatedWorkTimeCount(@Param("map") Map<String, Object> map);
+
+    List<Map<String, Object>> selectGroupEestimatedWorkTimeList(@Param("map") Map<String, Object> map);
+
+    Integer selectGroupEestimatedWorkTimeCount(@Param("map")Map<String, Object> map);
 }

+ 164 - 123
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -719,7 +719,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return httpRespMsg;
     }
 
-    @Override
+    /*@Override
     public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         //通过公司id获取该公司所有的项目列表
@@ -870,6 +870,88 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         resultMap.put("records",subList);
         httpRespMsg.data=resultMap;
         return httpRespMsg;
+    }*/
+
+
+    @Override
+    public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        //通过公司id获取该公司所有的项目列表
+        User user = userMapper.selectById(request.getHeader("Token"));
+        Integer companyId = user.getCompanyId();
+        EstimateTimeSetting estimateTimeSetting = estimateTimeSettingMapper.selectOne(new QueryWrapper<EstimateTimeSetting>().eq("company_id", companyId));
+        //该公司下的allday
+        float allday=timeTypeMapper.selectOne(new QueryWrapper<TimeType>()
+                .eq("company_id",companyId)).getAllday();
+
+        Integer projectWarningPercent = estimateTimeSetting.getProjectWarningPercent();
+        Integer groupWarningPercent = estimateTimeSetting.getGroupWarningPercent();
+
+        Map<String,Object> map=new  HashMap<String,Object>();
+        pageIndex=(pageIndex-1)*pageSize;
+        map.put("pageIndex", pageIndex);
+        map.put("pageSize", pageSize);
+        map.put("projectId",projectId );
+        map.put("isWarn",isWarn );
+        map.put("allday",allday );
+        map.put("companyId",companyId);
+
+
+        List<Map<String,Object>> list=new ArrayList<>();
+        Integer total=0;
+        if (type==0){
+            map.put("warningPercent",projectWarningPercent );
+
+            list= projectMapper.selectProjectEestimatedWorkTimeList(map);
+            if (!list.isEmpty()){
+                list.forEach(l-> {
+                    l.put("groupName", null);
+                    l.put("id", null);
+                    l.put("isRed",null);
+                    /*if (Double.parseDouble(l.get("remainWorkTime").toString())<0){
+                        l.put("remainWorkTime","\\");
+                    }*/
+                    if(l.get("remainWorkTimeProportion")!=null) {
+                        l.put("remainWorkTimeProportion",new BigDecimal(l.get("remainWorkTimeProportion").toString()).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+                        if (Double.parseDouble(l.get("remainWorkTimeProportion").toString())<Double.parseDouble(map.get("warningPercent").toString())){
+                            l.put("isRed",true );
+                        }
+                        l.put("remainWorkTimeProportion",l.get("remainWorkTimeProportion").toString()+"%");
+                    }else{
+                        l.put("remainWorkTimeProportion","\\");
+                    }
+                });
+            }
+            total= projectMapper.selectProjectEestimatedWorkTimeCount(map);
+        }else {
+            map.put("warningPercent",groupWarningPercent );
+
+            list= projectMapper.selectGroupEestimatedWorkTimeList(map);
+            if (!list.isEmpty()){
+                list.forEach(l-> {
+                    l.put("isRed",null);
+                    /*if (Double.parseDouble(l.get("remainWorkTime").toString())<0){
+                        l.put("remainWorkTime","\\");
+                    }*/
+                    if(l.get("remainWorkTimeProportion")!=null) {
+                        l.put("remainWorkTimeProportion",new BigDecimal(l.get("remainWorkTimeProportion").toString()).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+                        if (Double.parseDouble(l.get("remainWorkTimeProportion").toString())<Double.parseDouble(map.get("warningPercent").toString())){
+                            l.put("isRed",true );
+                        }
+                        l.put("remainWorkTimeProportion",l.get("remainWorkTimeProportion").toString()+"%");
+                    }else{
+                        l.put("remainWorkTimeProportion","\\");
+                    }
+                });
+            }
+            total= projectMapper.selectGroupEestimatedWorkTimeCount(map);
+        }
+
+        Map<String,Object> resultMap=new HashMap<>();
+        resultMap.put("total",total);
+        resultMap.put("records",list);
+        httpRespMsg.data=resultMap;
+        return httpRespMsg;
     }
 
     @Override
@@ -882,113 +964,61 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         //该公司下的allday
         float allday=timeTypeMapper.selectOne(new QueryWrapper<TimeType>()
                 .eq("company_id",companyId)).getAllday();
-        //根据公司的id搜索该公司有哪些项目  20231108之前完成的不统计,状态为进行中/已完成
-        List<Project> records = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).in("status", 1, 2)
-                .and(wrapper -> wrapper.isNull("finish_date").or()
-                        .ge("finish_date", "2023-11-08")).eq(projectId != null, "id", projectId));
 
-        List<Integer> collectIds = records.stream().map(Project::getId).collect(Collectors.toList());
+        Integer projectWarningPercent = estimateTimeSetting.getProjectWarningPercent();
+        Integer groupWarningPercent = estimateTimeSetting.getGroupWarningPercent();
 
-        //根据查询道德project列表查询总的reporeList
-        List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>()
-                .in("project_id", collectIds));
-        //根据查询道德project列表查询总的task_groupList
-        List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>()
-                .in("project_id", collectIds));
+        Map<String,Object> map=new  HashMap<String,Object>();
+        map.put("projectId",projectId );
+        map.put("isWarn",isWarn );
+        map.put("allday",allday );
+        map.put("companyId",companyId);
 
-        DecimalFormat df = new DecimalFormat("0.00");
-        List<GroupEstimatedWorkVO> lastList=new ArrayList<>();
-        for (Project project : records) {
 
-            List<TaskGroup> taskGroupCollect = taskGroups.stream().filter(t -> t.getProjectId().equals(project.getId())).collect(Collectors.toList());
+        List<Map<String,Object>> list=new ArrayList<>();
 
-            //0代表按项目查看
-            if (type==0){
-                GroupEstimatedWorkVO estimatedWorkVO = new GroupEstimatedWorkVO();
-                Double reallWorkTime = reportList.stream().filter(r -> r.getProjectId() .equals( project.getId())&&r.getWorkingTime()!=null)
-                        .mapToDouble(Report::getWorkingTime).sum();
-                String rWorkTime=reallWorkTime==null ? "0":df.format(reallWorkTime);
-                estimatedWorkVO.setProjectId(project.getId());
-                estimatedWorkVO.setProjectName(project.getProjectName());
-                estimatedWorkVO.setProjectCode(project.getProjectCode());
-                estimatedWorkVO.setWorkTime(rWorkTime);
-                String pEstimatedWork=project.getManDay()==null? "0": (project.getManDay()*allday+"");
-                estimatedWorkVO.setEstimatedWorkTime(pEstimatedWork);
-                if (project.getManDay()==null){
-                    estimatedWorkVO.setRemainWorkTime("\\");
-                    estimatedWorkVO.setRemainWorkTimeProportion("\\");
-                }else{
-                    double rWorkTimeDouble = Double.parseDouble(rWorkTime);
-                    double pEstimatedWorkDouble = Double.parseDouble(pEstimatedWork);
-                    double remainDouble = pEstimatedWorkDouble - rWorkTimeDouble;
-                    estimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
-                    double proportion = (remainDouble / pEstimatedWorkDouble)*100;
-                    estimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
-                }
-                lastList.add(estimatedWorkVO);
+        if (type==0){
+            map.put("warningPercent",projectWarningPercent );
+
+            list= projectMapper.selectProjectEestimatedWorkTimeList(map);
+            if (!list.isEmpty()){
+                list.forEach(l-> {
+                    l.put("groupName", null);
+                    l.put("id", null);
+                    l.put("isRed",null);
+                    /*if (Double.parseDouble(l.get("remainWorkTime").toString())<0){
+                        l.put("remainWorkTime","\\");
+                    }*/
+                    if(l.get("remainWorkTimeProportion")!=null) {
+                        l.put("remainWorkTimeProportion",new BigDecimal(l.get("remainWorkTimeProportion").toString()).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+                        if (Double.parseDouble(l.get("remainWorkTimeProportion").toString())<Double.parseDouble(map.get("warningPercent").toString())){
+                            l.put("isRed",true );
+                        }
+                    }else{
+                        l.put("remainWorkTimeProportion","\\");
+                    }
+                });
             }
-            else {
-                if (taskGroupCollect.size()>0){
-                    List<Integer> groupIds = taskGroupCollect.stream().map(TaskGroup::getId).collect(Collectors.toList());
-                    List<Report> getByProjectAndGroup = reportMapper.selectList(new QueryWrapper<Report>()
-                            .eq("project_id", project.getId())
-                            .in("group_id", groupIds));
-                    for (TaskGroup taskGroup : taskGroupCollect) {
-                        Double gReallWorkTime = getByProjectAndGroup.stream().filter(r -> r.getGroupId().equals( taskGroup.getId()))
-                                .mapToDouble(r->r.getWorkingTime()).sum();
-                        GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
-                        String grWorkTime=gReallWorkTime==null ? "0":gReallWorkTime+"";
-                        String gEstimatedWork=taskGroup.getManDay()==null ? 0*allday+"": taskGroup.getManDay()*allday+"";
 
-                        if (taskGroup.getManDay()==null){
-                            groupEstimatedWorkVO.setRemainWorkTime("\\");
-                            groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
-                        }else{
-                            double grWorkTimeDouble = Double.parseDouble(grWorkTime);
-                            double gEstimatedWorkDouble = Double.parseDouble(gEstimatedWork);
-                            double remainDouble = gEstimatedWorkDouble - grWorkTimeDouble;
-                            groupEstimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
-                            double proportion = (remainDouble / gEstimatedWorkDouble)*100;
-                            groupEstimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
+        }else {
+            map.put("warningPercent",groupWarningPercent );
+
+            list= projectMapper.selectGroupEestimatedWorkTimeList(map);
+            if (!list.isEmpty()){
+                list.forEach(l-> {
+                    l.put("isRed",null);
+                    /*if (Double.parseDouble(l.get("remainWorkTime").toString())<=0){
+                        l.put("remainWorkTime","\\");
+                    }*/
+                    if(l.get("remainWorkTimeProportion")!=null) {
+                        l.put("remainWorkTimeProportion",new BigDecimal(l.get("remainWorkTimeProportion").toString()).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP));
+                        if (Double.parseDouble(l.get("remainWorkTimeProportion").toString())<Double.parseDouble(map.get("warningPercent").toString())){
+                            l.put("isRed",true );
                         }
-
-                        groupEstimatedWorkVO.setWorkTime(grWorkTime);
-                        groupEstimatedWorkVO.setEstimatedWorkTime(gEstimatedWork);
-                        groupEstimatedWorkVO.setId(taskGroup.getId());
-                        groupEstimatedWorkVO.setGroupName(taskGroup.getName());
-                        groupEstimatedWorkVO.setProjectId(project.getId());
-                        groupEstimatedWorkVO.setProjectName(project.getProjectName());
-
-                        lastList.add(groupEstimatedWorkVO);
+                    }else{
+                        l.put("remainWorkTimeProportion","\\");
                     }
-                }
-                else {
-                    GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
-                    groupEstimatedWorkVO.setWorkTime("");
-                    groupEstimatedWorkVO.setEstimatedWorkTime("");
-                    groupEstimatedWorkVO.setId(null);
-                    groupEstimatedWorkVO.setGroupName("");
-                    groupEstimatedWorkVO.setProjectId(project.getId());
-                    groupEstimatedWorkVO.setProjectName(project.getProjectName());
-                    groupEstimatedWorkVO.setRemainWorkTime("\\");
-                    groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
-                    lastList.add(groupEstimatedWorkVO);
-                }
-            }
-        }
-        Integer projectWarningPercent = estimateTimeSetting.getProjectWarningPercent();
-        Integer groupWarningPercent = estimateTimeSetting.getGroupWarningPercent();
-        if (isWarn!=null){
-            lastList = lastList.stream().
-                    filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")).collect(Collectors.toList());
-            if (type==0){
-                lastList = lastList.stream().
-                        filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
-                        .collect(Collectors.toList());
-            }else {
-                lastList = lastList.stream().
-                        filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < groupWarningPercent)
-                        .collect(Collectors.toList());
+                });
             }
         }
 
@@ -1006,20 +1036,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<List<String>> allList = new ArrayList<>();
             allList.add(headList);
 
-            if (!lastList.isEmpty()){
-                for (int i = 0; i < lastList.size(); i++) {
-                    ArrayList<String> list = new ArrayList<>();
-                    list.add(StringUtils.isEmpty(lastList.get(i).getProjectName())?"":lastList.get(i).getProjectName());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getEstimatedWorkTime())?"":lastList.get(i).getEstimatedWorkTime());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getWorkTime())?"":lastList.get(i).getWorkTime());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTime())?"":lastList.get(i).getRemainWorkTime());
-                    if (!StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())&&lastList.get(i).getRemainWorkTimeProportion().equals("\\")){
-                        list.add("\\");
+            if (!list.isEmpty()){
+                for (int i = 0; i < list.size(); i++) {
+                    ArrayList<String> listString = new ArrayList<>();
+                    listString.add(StringUtils.isEmpty(list.get(i).get("projectName").toString())?"":list.get(i).get("projectName").toString());
+                    listString.add(StringUtils.isEmpty(list.get(i).get("estimatedWorkTime").toString())?"":list.get(i).get("estimatedWorkTime").toString());
+                    listString.add(StringUtils.isEmpty(list.get(i).get("workTime").toString())?"":list.get(i).get("workTime").toString());
+                    listString.add(StringUtils.isEmpty(list.get(i).get("remainWorkTime").toString())?"":list.get(i).get("remainWorkTime").toString());
+
+                    if (!StringUtils.isEmpty(list.get(i).get("remainWorkTimeProportion"))&&list.get(i).get("remainWorkTimeProportion").equals("\\")){
+                        listString.add("\\");
                     }else {
-                        list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())?"":lastList.get(i).getRemainWorkTimeProportion()+"%");
-                    }
+                        listString.add((StringUtils.isEmpty(list.get(i).get("remainWorkTimeProportion").toString())?"":list.get(i).get("remainWorkTimeProportion").toString())+"%");
 
-                    allList.add(list);
+                    }
+                    allList.add(listString);
                 }
             }
             try {
@@ -1043,20 +1074,30 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<List<String>> allList = new ArrayList<>();
             allList.add(headList);
 
-            if (!lastList.isEmpty()){
-                for (int i = 0; i < lastList.size(); i++) {
-                    ArrayList<String> list = new ArrayList<>();
-                    list.add(StringUtils.isEmpty(lastList.get(i).getProjectName())?"":lastList.get(i).getProjectName());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getGroupName())?"":lastList.get(i).getGroupName());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getEstimatedWorkTime())?"":lastList.get(i).getEstimatedWorkTime());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getWorkTime())?"":lastList.get(i).getWorkTime());
-                    list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTime())?"":lastList.get(i).getRemainWorkTime());
-                    if (!StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())&&lastList.get(i).getRemainWorkTimeProportion().equals("\\")){
-                        list.add("\\");
+            if (!list.isEmpty()){
+                for (int i = 0; i < list.size(); i++) {
+                    ArrayList<String> listString = new ArrayList<>();
+                    if (list.get(i).get("projectName")!=null){
+                        listString.add(StringUtils.isEmpty(list.get(i).get("projectName").toString())?"":list.get(i).get("projectName").toString());
+                    }
+                    else {
+                        listString.add("");
+                    }
+                    if (list.get(i).get("groupName")!=null){
+                        listString.add(StringUtils.isEmpty(list.get(i).get("groupName").toString())?"":list.get(i).get("groupName").toString());
+                    }else {
+                        listString.add("");
+                    }
+                    listString.add(StringUtils.isEmpty(list.get(i).get("estimatedWorkTime").toString())?"":list.get(i).get("estimatedWorkTime").toString());
+                    listString.add(StringUtils.isEmpty(list.get(i).get("workTime").toString())?"":list.get(i).get("workTime").toString());
+                    listString.add(StringUtils.isEmpty(list.get(i).get("remainWorkTime").toString())?"":list.get(i).get("remainWorkTime").toString());
+
+                    if (!StringUtils.isEmpty(list.get(i).get("remainWorkTimeProportion"))&&list.get(i).get("remainWorkTimeProportion").equals("\\")){
+                        listString.add("\\");
                     }else {
-                        list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())?"":lastList.get(i).getRemainWorkTimeProportion()+"%");
+                        listString.add((StringUtils.isEmpty(list.get(i).get("remainWorkTimeProportion").toString())?"":list.get(i).get("remainWorkTimeProportion").toString())+"%");
                     }
-                    allList.add(list);
+                    allList.add(listString);
                 }
             }
             try {

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

@@ -2532,5 +2532,144 @@
         AND b.state = 1
         GROUP BY projectId
     </select>
+    <select id="selectProjectEestimatedWorkTimeList" resultType="java.util.Map">
+        SELECT
+            p.id AS projectId,
+            p.project_code AS projectCode,
+            p.project_name AS projectName,
+            CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END AS estimatedWorkTime,
+            SUM(CASE WHEN r.working_time IS NULL THEN 0 ELSE r.working_time END) AS workTime,
+            (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL THEN 0 ELSE r.working_time END)) AS remainWorkTime,
+            CASE
+            WHEN (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END) = 0 THEN NULL
+            ELSE ROUND((CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL THEN 0 ELSE r.working_time END)) / (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END), 4)
+            END AS remainWorkTimeProportion
+        FROM
+        project p
+        LEFT JOIN
+        report r ON p.id = r.project_id
+        WHERE
+        p.company_id = #{map.companyId}
+        AND p.`status` IN (1, 2)
+        AND (p.finish_date IS NULL OR p.finish_date >= '2023-11-08')
+        <if test="map.projectId!=null">
+            AND p.id = #{map.projectId}
+        </if>
+        GROUP BY
+        p.id, p.project_code, p.project_name
+        <if test="map.isWarn!=null and map.isWarn==1 ">
+            HAVING remainWorkTimeProportion *100 &lt; #{map.warningPercent}
+        </if>
+        <if test="map.pageIndex!=null and map.pageSize!=null ">
+            LIMIT #{map.pageIndex}, #{map.pageSize}
+        </if>
+    </select>
+    <select id="selectProjectEestimatedWorkTimeCount" resultType="java.lang.Integer">
+        SELECT
+            count(1) total
+        FROM
+           (
+        SELECT
+        p.id AS projectId,
+        (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL THEN 0 ELSE r.working_time END)) AS remainWorkTime,
+        CASE
+        WHEN (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END) = 0 THEN NULL
+        ELSE ROUND((CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL THEN 0 ELSE r.working_time END)) / (CASE WHEN p.man_day IS NULL THEN 0 ELSE p.man_day * #{map.allday} END), 4)
+        END AS remainWorkTimeProportion
+        FROM
+        project p
+        LEFT JOIN
+        report r ON p.id = r.project_id
+        WHERE
+        p.company_id = #{map.companyId}
+        AND p.`status` IN (1, 2)
+        AND (p.finish_date IS NULL OR p.finish_date >= '2023-11-08')
+        <if test="map.projectId!=null">
+            AND p.id = #{map.projectId}
+        </if>
+        GROUP BY
+        p.id, p.project_code, p.project_name
+        <if test="map.isWarn!=null and map.isWarn==1 ">
+            HAVING remainWorkTimeProportion *100 &lt; #{map.warningPercent}
+        </if>
+           ) a
+    </select>
+    <select id="selectGroupEestimatedWorkTimeList" resultType="java.util.Map">
+        SELECT
+            p.id AS projectId,
+            p.project_code AS projectCode,
+            p.project_name AS projectName,
+            g.`name`  groupName,
+            g.id id,
+            CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END AS estimatedWorkTime,
+            SUM(CASE WHEN r.working_time IS NULL OR g.id IS NULL THEN 0 ELSE
+            CASE WHEN r.group_id = g.id THEN r.working_time ELSE 0 END
+            END) AS workTime,
+            (CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL OR g.id IS NULL THEN 0 ELSE
+            CASE WHEN r.group_id = g.id THEN r.working_time ELSE 0 END
+            END)) AS remainWorkTime,
+            CASE
+            WHEN (CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END) = 0 THEN NULL
+            ELSE ROUND((CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL OR g.id IS NULL THEN 0 ELSE
+            CASE WHEN r.group_id = g.id THEN r.working_time ELSE 0 END
+            END)) / (CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END),4)
+            END AS remainWorkTimeProportion
+        FROM
+        project p
+        LEFT JOIN
+        report r ON p.id = r.project_id
+        LEFT JOIN
+        task_group g ON g.project_id =p.id
+        WHERE
+        p.company_id = #{map.companyId}
+        AND p.`status` IN (1, 2)
+        AND (p.finish_date IS NULL OR p.finish_date >= '2023-11-08')
+        <if test="map.projectId!=null">
+            AND p.id = #{map.projectId}
+        </if>
+        GROUP BY
+        p.id,g.`name`,g.id
+        <if test="map.isWarn!=null and map.isWarn==1 ">
+            HAVING remainWorkTimeProportion *100 &lt; #{map.warningPercent}
+        </if>
+        <if test="map.pageIndex!=null and map.pageSize!=null ">
+            LIMIT #{map.pageIndex}, #{map.pageSize}
+        </if>
+    </select>
+    <select id="selectGroupEestimatedWorkTimeCount" resultType="java.lang.Integer">
+        SELECT
+            count(*)
+        FROM
+            (
+        SELECT
+        p.id AS projectId,
+        g.`name`  groupName,
+        g.id id,
+        CASE
+        WHEN (CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END) = 0 THEN NULL
+        ELSE ROUND((CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END - SUM(CASE WHEN r.working_time IS NULL OR g.id IS NULL THEN 0 ELSE
+        CASE WHEN r.group_id = g.id THEN r.working_time ELSE 0 END
+        END)) / (CASE WHEN g.man_day IS NULL THEN 0 ELSE g.man_day * #{map.allday} END),4)
+        END AS remainWorkTimeProportion
+        FROM
+        project p
+        LEFT JOIN
+        report r ON p.id = r.project_id
+        LEFT JOIN
+        task_group g ON g.project_id =p.id
+        WHERE
+        p.company_id = #{map.companyId}
+        AND p.`status` IN (1, 2)
+        AND (p.finish_date IS NULL OR p.finish_date >= '2023-11-08')
+        <if test="map.projectId!=null">
+            AND p.id = #{map.projectId}
+        </if>
+        GROUP BY
+        p.id,g.`name`,g.id
+        <if test="map.isWarn!=null and map.isWarn==1 ">
+            HAVING remainWorkTimeProportion *100 &lt; #{map.warningPercent}
+        </if>
+            ) a
+    </select>
 
 </mapper>