Browse Source

任务列表加分页

yurk 2 years ago
parent
commit
18b801ff87

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/StagesController.java

@@ -197,7 +197,7 @@ public class StagesController {
         } else {
             queryWrapper.orderByAsc(order);
         }
-        List<Task> tasks = taskService.simpleList(queryWrapper);
+        List<Task> tasks = taskService.simpleList(queryWrapper,null,null);
         //没有权限只能看到自己创建的,负责的和待分配的任务
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部任务");
         if (functionList.size() == 0 && !userId.equals(project.getInchargerId())) {
@@ -206,7 +206,7 @@ public class StagesController {
         List<Task> subTasks = new ArrayList<>();
         if (tasks.size() > 0) {
             List<Integer> collect = tasks.stream().map(Task::getId).collect(Collectors.toList());
-            List<Task> subLists = taskService.simpleList(new QueryWrapper<Task>().in("parent_tid", collect));
+            List<Task> subLists = taskService.simpleList(new QueryWrapper<Task>().in("parent_tid", collect),null,null);
             if (functionList.size() == 0 && !userId.equals(project.getInchargerId())) {
                 subLists = subLists.stream().filter(t->t.getExecutorId() == null || t.getExecutorId().contains(userId) || userId.equals(t.getCreaterId())).collect(Collectors.toList());
             }

+ 13 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java

@@ -3,7 +3,10 @@ package com.management.platform.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.IPage;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
@@ -289,7 +292,7 @@ public class TaskController {
 
     private void updateProjectProgress(Integer projectId) {
         //只有里程碑才更新项目进度, 非已撤销状态的
-        List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1));
+        List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1),null,null);
         Project project = new Project();
         project.setId(projectId);
         if (all.size() > 0) {
@@ -441,8 +444,10 @@ public class TaskController {
 
 
     @RequestMapping("/list")
-    public HttpRespMsg list(Task task, Integer viewId, String order, boolean isDesc) {
+    public HttpRespMsg list(Task task, Integer viewId, String order, boolean isDesc,Integer pageIndex,Integer pageSize) {
         HttpRespMsg msg = new HttpRespMsg();
+        Integer size=pageSize;
+        Integer start=(pageIndex-1)*pageSize;
         String userId = request.getHeader("Token");
         User user = userMapper.selectById(userId);
         Project project = projectService.getById(task.getProjectId());
@@ -480,8 +485,8 @@ public class TaskController {
             //已超期的任务,未完成的任务
             queryWrapper.lt("end_date", LocalDate.now()).eq("task_status", 0);
         }
-        List<Task> list = taskService.simpleList(queryWrapper);
-
+        List<Task> list = taskService.simpleList(queryWrapper,start,size);
+        int total = taskMapper.selectCount(queryWrapper);
         //没有权限只能看到自己创建的,负责的和待分配的任务
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部任务");
         if (functionList.size() == 0 && !userId.equals(project.getInchargerId())) {
@@ -495,7 +500,10 @@ public class TaskController {
             }
 
         });
-        msg.data = list;
+        Map map=new HashMap();
+        map.put("records",list);
+        map.put("total",total);
+        msg.data = map;
         return msg;
     }
 

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

@@ -1,6 +1,7 @@
 package com.management.platform.mapper;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.management.platform.entity.Task;
@@ -24,7 +25,7 @@ public interface TaskMapper extends BaseMapper<Task> {
     List getStagesPanel(Integer projectId);
     List getTopCostTask(Integer projectId);
 
-    List<Task> simpleList(@Param(Constants.WRAPPER) Wrapper wrapper);
+    List<Task> simpleList(@Param(Constants.WRAPPER) Wrapper wrapper,Integer start,Integer size);
 
     List<Task> nameList(@Param(Constants.WRAPPER) Wrapper wrapper);
 

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/TaskService.java

@@ -1,6 +1,7 @@
 package com.management.platform.service;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.Task;
 import com.management.platform.entity.TaskGroup;
@@ -27,7 +28,7 @@ public interface TaskService extends IService<Task> {
     HttpRespMsg getTopCostTask(Integer projectId);
 
     //获取不带任务描述的列表数据
-    List<Task> simpleList(Wrapper<Task> queryWrapper);
+    List<Task> simpleList(Wrapper<Task> queryWrapper,Integer start,Integer size);
     List<Task> nameList(Wrapper<Task> queryWrapper);
 
 

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

@@ -1509,7 +1509,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     @Override
     public HttpRespMsg taskSum(Integer id, HttpServletRequest request) {
-        List<Task> allTask = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", id));
+        List<Task> allTask = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", id),null,null);
         long finishCount = allTask.stream().filter(t -> t.getTaskStatus() == 1).count();
         long unfinishCount = allTask.stream().filter(t -> t.getTaskStatus() == 0).count();
         long timeupCount = allTask.stream().filter(t -> t.getTaskStatus() == 0 && t.getEndDate() != null && t.getEndDate().isBefore(LocalDate.now())).count();

+ 44 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -97,6 +97,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private SysFunctionMapper sysFunctionMapper;
     @Resource
+    private UserFvTimeMapper userFvTimeMapper;
+    @Resource
     private ProjectBasecostSettingMapper projectBasecostSettingMapper;
     @Resource
     private UserDingdingTimeMapper userDingdingTimeMapper;
@@ -658,6 +660,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     UserDingdingTime time = dingdingTimes.get(0);
                     resultMap.put("time", time);
                 }
+            }else if(timeType.getSyncFanwei()==1){
+                List<UserFvTime> userFvTimeList = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
+                        .eq("user_id", userId).eq("work_date", date));
+                if (userFvTimeList.size() > 0) {
+                    UserFvTime time = userFvTimeList.get(0);
+                    resultMap.put("time", time);
+                }
             } else if (timeType.getShowCorpwxCardtime() == 1) {
                 User user = userMapper.selectById(userId);
                 List<UserCorpwxTime> corpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
@@ -713,7 +722,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 UserDingdingTime time = dingdingTimes.get(0);
                 msg.data = time;
             }
-        } else if (timeType.getShowCorpwxCardtime() == 1) {
+        }else if(timeType.getSyncFanwei()==1){
+            List<UserFvTime> userFvTimeList = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
+                    .eq("user_id", userId).eq("work_date", date));
+            if (userFvTimeList.size() > 0) {
+                UserFvTime time = userFvTimeList.get(0);
+                msg.data=time;
+            }
+        }  else if (timeType.getShowCorpwxCardtime() == 1) {
             List<UserCorpwxTime> corpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
                     .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
             if (corpwxTimes.size() > 0) {
@@ -1246,6 +1262,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         }
                     }
                 }
+            } else if(timeType.getSyncFanwei()==1){
+                //泛微的情况
+                QueryWrapper<UserFvTime> userFvTimeQueryWrapper = new QueryWrapper<>();
+                if (nameList.size() > 0) {
+                    for (Map map : nameList) {
+                        String itemUid = (String)map.get("userId");
+                        String dateStr = (String)map.get("dateStr");
+                        userFvTimeQueryWrapper.or(wrapper->wrapper.eq("user_id", itemUid).eq("work_date", dateStr));
+                    }
+                    List<UserFvTime> timeList = userFvTimeMapper.selectList(userFvTimeQueryWrapper);
+                    //过滤匹配当前的数据
+                    for (Map map : nameList) {
+                        String itemUid = (String)map.get("userId");
+                        String dateStr = (String)map.get("dateStr");
+                        Optional<UserFvTime> first = timeList.stream().filter(time -> time.getUserId().equals(itemUid) && dtf.format(time.getWorkDate()).equals(dateStr)).findFirst();
+                        if (first.isPresent()) {
+                            double wh = first.get().getWorkHours();
+                            //赋值打卡时长
+                            map.put("cardHours", wh);
+                        }
+                    }
+                }
             }
             httpRespMsg.data = nameList;
         } catch (NullPointerException e) {
@@ -4949,7 +4987,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<UserDingdingTime> dingdingTimes = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>()
                     .eq("user_id", userId).in("work_date", dateList));
             msg.data = dingdingTimes;
-        } else if (timeType.getShowCorpwxCardtime() == 1) {
+        } else if(timeType.getSyncFanwei()==1){
+            List<UserFvTime> userFvTimes = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
+                    .eq("user_id", userId).in("work_date", dateList));
+            msg.data = userFvTimes;
+        }else if (timeType.getShowCorpwxCardtime() == 1) {
             List<UserCorpwxTime> corpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
                     .eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList));
             msg.data = corpwxTimes;

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

@@ -103,10 +103,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     }
 
     @Override
-    public List<Task> simpleList(Wrapper<Task> queryWrapper) {
-        return taskMapper.simpleList(queryWrapper);
+    public List<Task> simpleList(Wrapper<Task> queryWrapper,Integer start,Integer size) {
+        return taskMapper.simpleList(queryWrapper,start,size);
     }
 
+
     @Override
     public List<Task> nameList(Wrapper<Task> queryWrapper) {
         return taskMapper.nameList(queryWrapper);
@@ -692,5 +693,4 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         httpRespMsg.data=list;
         return httpRespMsg;
     }
-
 }

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TaskMapper.xml

@@ -98,6 +98,9 @@
         select id, name, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date
         from task
         ${ew.customSqlSegment}
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
     </select>
     <select id="nameList" resultMap="BaseResultMap">
         select id, name, task_level, stages_id, company_id, indate,  group_id, seq,task_type,task_desc