Bladeren bron

分页查看日报

seyason 1 jaar geleden
bovenliggende
commit
bd92bdaf33

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

@@ -215,8 +215,10 @@ public class ReportController {
     }
 
     @RequestMapping("/getReportList")
-    public HttpRespMsg getReportList(@RequestParam String date, @RequestParam(required = false) Integer deptId, @RequestParam(required = false) String userId) {
-        return reportService.getReportList(date, deptId, userId, request);
+    public HttpRespMsg getReportList(@RequestParam String date, @RequestParam(required = false) Integer deptId,
+                                     @RequestParam(required = false) String userId, Integer pageIndex, //从0开始
+                                     @RequestParam(required = false, defaultValue="10") Integer pageSize) {
+        return reportService.getReportList(date, deptId, userId, pageIndex, pageSize, request);
     }
 
     /**

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

@@ -91,7 +91,12 @@ public interface ReportMapper extends BaseMapper<Report> {
     List<Map<String, Object>> getReportNameByDateAndDept(@Param("date") String date,
                                                          @Param("deptIds") List<Integer> deptIds,
                                                          @Param("userId") String userId,
-                                                         @Param("companyId") Integer company);
+                                                         @Param("companyId") Integer companyId, Integer pageStart, Integer pageSize);
+
+    Integer getReportNameByDateAndDeptCount(@Param("date") String date,
+                                                         @Param("deptIds") List<Integer> deptIds,
+                                                         @Param("userId") String userId,
+                                                         @Param("companyId") Integer companyId);
     List<Map<String, Object>> getDetailByStateInMyProfession(@Param("state") Integer state,
                                                @Param("companyId") Integer companyId,
                                                @Param("leaderId") String leaderId);

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

@@ -25,7 +25,7 @@ import java.util.Map;
  * @since 2019-12-31
  */
 public interface ReportService extends IService<Report> {
-    HttpRespMsg getReportList(String date, Integer deptId, String userId, HttpServletRequest request);
+    HttpRespMsg getReportList(String date, Integer deptId, String userId, Integer pageIndex, Integer pageSize, HttpServletRequest request);
 
     HttpRespMsg exportReport(@RequestParam String startDate, @RequestParam String endDate,Integer exportType, Integer projectId,Integer stateKey,Integer departmentId, HttpServletRequest request);
 

+ 67 - 40
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -225,15 +225,22 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
     //获取报告列表
     @Override
-    public HttpRespMsg getReportList(String date,  Integer deptId, String targetUid, HttpServletRequest request) {
+    public HttpRespMsg getReportList(String date,  Integer deptId, String targetUid, Integer pageIndex,
+                                     @RequestParam(required = false, defaultValue="10") Integer pageSize, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
+            Integer pageStart = null;
+            //pageIndex从0开始
+            if (pageIndex != null) {
+                pageStart = pageIndex * pageSize;
+            }
             //首先根据日期获取当天所有提交过日志的人
             String userId = request.getHeader("Token");
             User user = userMapper.selectById(userId);
             TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
             List<Map<String, Object>> nameList = new ArrayList<>();
             List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
+            Integer totalMembCount = 0;
             if (functionList.size() == 0) {
                 String leaderId = user.getId();
                 //不是项目经理,只看自己的报告
@@ -241,40 +248,43 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 //没有指定员工或者指定的就是自己
                 if (targetUid == null || targetUid.equals(user.getId())) {
                     //查看自己的日报
-                    Map<String, Object> map = new HashMap<>();
-                    map.put("id", user.getId());
-                    map.put("name", user.getName());
-                    list = reportMapper.getReportByDate(date, (String) map.get("id"));
-                    if (list.size() > 0) {
-                        //个人日报
-                        nameList.add(map);
-                        map.put("data", list);
-                        double reportTime = 0;
-                        BigDecimal total = new BigDecimal(0);
-                        int state = (int)list.get(0).get("state");
-                        boolean hasDeny = false;
-                        boolean hasWaiting = false;
-                        for (Map<String, Object> m : list) {
-                            double t = (double) m.get("time");
-                            reportTime += t;
-                            total = total.add((BigDecimal)m.get("cost"));
-                            int curState = (int)m.get("state");
-                            if (curState == 2) {
-                                hasDeny = true;
+                    if (pageIndex != null && pageIndex == 0) {
+                        //仅第一页显示自己的
+                        Map<String, Object> map = new HashMap<>();
+                        map.put("id", user.getId());
+                        map.put("name", user.getName());
+                        list = reportMapper.getReportByDate(date, (String) map.get("id"));
+                        if (list.size() > 0) {
+                            //个人日报
+                            nameList.add(map);
+                            map.put("data", list);
+                            double reportTime = 0;
+                            BigDecimal total = new BigDecimal(0);
+                            int state = (int)list.get(0).get("state");
+                            boolean hasDeny = false;
+                            boolean hasWaiting = false;
+                            for (Map<String, Object> m : list) {
+                                double t = (double) m.get("time");
+                                reportTime += t;
+                                total = total.add((BigDecimal)m.get("cost"));
+                                int curState = (int)m.get("state");
+                                if (curState == 2) {
+                                    hasDeny = true;
+                                }
+                                if (curState == 0) {
+                                    hasWaiting = true;
+                                }
                             }
-                            if (curState == 0) {
-                                hasWaiting = true;
+                            if(hasDeny) {
+                                state = 2;
+                            } else if (hasWaiting) {
+                                state = 0;
                             }
+                            DecimalFormat df = new DecimalFormat("0.00");
+                            map.put("reportTime", df.format(reportTime));
+                            map.put("cost", total);
+                            map.put("state", state);
                         }
-                        if(hasDeny) {
-                            state = 2;
-                        } else if (hasWaiting) {
-                            state = 0;
-                        }
-                        DecimalFormat df = new DecimalFormat("0.00");
-                        map.put("reportTime", df.format(reportTime));
-                        map.put("cost", total);
-                        map.put("state", state);
                     }
                 }
 
@@ -284,7 +294,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     if (nameList.size() > 0) {
                         //自己填写的日报
                         List<Map<String, Object>> deptNameList = reportMapper.getReportNameByDateAndDept(date,
-                                allVisibleDeptIdList, targetUid, null);
+                                allVisibleDeptIdList, targetUid, null, pageStart, pageSize);
+                        totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, allVisibleDeptIdList, targetUid, null);
                         for (Map<String, Object> deptNameItem : deptNameList) {
                             if (!deptNameItem.get("id").equals(user.getId())) {
                                 nameList.add(deptNameItem);
@@ -292,7 +303,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         }
                     } else {
                         nameList = reportMapper.getReportNameByDateAndDept(date,
-                                allVisibleDeptIdList, targetUid, null);
+                                allVisibleDeptIdList, targetUid, null, pageStart, pageSize);
+                        totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, allVisibleDeptIdList, targetUid, null);
                     }
                     if (nameList.size() > 0) {
                         List<String> userIds = new ArrayList<>();
@@ -443,7 +455,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                 }
                 nameList = reportMapper.getReportNameByDateAndDept(date,
-                        ids, targetUid, companyId);
+                        ids, targetUid, companyId, pageStart, pageSize);
+                totalMembCount = reportMapper.getReportNameByDateAndDeptCount(date, ids, targetUid, companyId);
                 if (nameList.size() > 0) {
                     List<String> userIds = new ArrayList<>();
                     nameList.forEach(n->{
@@ -629,7 +642,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
             }
 
-            httpRespMsg.data = nameList;
+            if (pageStart == null) {
+                //老版本,不带分页的情况
+                httpRespMsg.data = nameList;
+            } else {
+                //新版,分页请求
+                HashMap retMap = new HashMap();
+                retMap.put("data", nameList);
+                retMap.put("pageIndex", pageIndex);
+                retMap.put("hasMore", pageIndex * pageSize + pageSize < totalMembCount);
+                httpRespMsg.data = retMap;
+            }
         } catch (NullPointerException e) {
             e.printStackTrace();
             //httpRespMsg.setError("验证失败");
@@ -750,7 +773,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().eq("user_id", r.getCreatorId()));
                         if (groupParticipatorList.size() > 0) {
                             List<Integer> groupIds = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
-                            List<TaskGroup> findGroups = taskGroups.stream().filter(tg->groupIds.contains(tg.getId()) || userId.equals(tg.getInchargerId())).collect(Collectors.toList());
+                            List<TaskGroup> findGroups = taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId()) && (groupIds.contains(tg.getId()) || userId.equals(tg.getInchargerId()))).collect(Collectors.toList());
                             r.setTaskGroups(findGroups);
                             if (r.getGroupId() != null && r.getGroupId() != 0) {
                                 Optional<TaskGroup> optinal = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
@@ -2951,7 +2974,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
         List<DepartmentVO> list = null;
         List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(curUser.getRoleId(), "查看全公司工时");
-
         if (functionList.size() > 0) {
             //查看全部的
             HttpRespMsg departmentList = departmentService.getDepartmentList(request);
@@ -3012,7 +3034,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
             list = realMDeptList;
         }
-
+        long t2 = System.currentTimeMillis();
         if (list.size() > 0) {
             //存在查看权限的部门
             //获取公司全部人员; 按照人员状态,如果是已经离职的,当前日期在离职日期以后的,不需要显示该人员
@@ -3020,13 +3042,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             queryWrapper.and(wrapper->wrapper.eq("is_active", 1).eq("report_status",0)
                     .or(wrapper2->wrapper2.eq("is_active", 0).gt("inactive_date", date)));
             List<User> userList = userMapper.selectList(queryWrapper);
-            List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(new QueryWrapper<LeaveSheet>().eq("company_id", companyId));
+            List<LeaveSheet> leaveSheetList = leaveSheetMapper.selectList(
+                    new QueryWrapper<LeaveSheet>().select("id, owner_id, start_date, end_date, leave_type, time_type, time_days, time_hours").eq("company_id", companyId));
+            long t3 = System.currentTimeMillis();
+            System.out.println("获取人员请假列表耗时:" + (t3 - t2) + "ms");
             LocalDate localDate = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             List<HashMap> userMapList = new ArrayList<>();
             LocalDate curDate = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 
             //获取当日已填写的人员报告
             List<Map<String, Object>> reportNameByDate = reportMapper.getReportNameByDate(date, companyId, null);
+            long t4 = System.currentTimeMillis();
+            System.out.println("获取当日已填写的人员报告耗时:" + (t4 - t3) + "ms");
             Company company = companyMapper.selectById(companyId);
             TimeType timeType = timeTypeMapper.selectById(companyId);
             //如果没有开通OA模块,有开通企业微信同步考勤,从user_corpwx_time表中获取请假时长

+ 25 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -682,6 +682,31 @@
         <if test="userId != null">
             AND b.id=#{userId}
         </if>
+        <if test="pageStart != null">
+            limit #{pageStart}, #{pageSize}
+        </if>
+    </select>
+
+    <select id="getReportNameByDateAndDeptCount" resultType="java.lang.Integer">
+        SELECT count(DISTINCT b.id) as count
+        FROM report AS a
+        JOIN user AS b ON a.creator_id=b.id
+        WHERE 1=1
+        <if test="date != null and date != ''">
+            AND a.create_date=#{date}
+        </if>
+        <if test="deptIds != null">
+            AND b.department_id in
+            <foreach item="item" collection="deptIds" separator="," open="(" close=")" index="">
+                #{item, jdbcType=INTEGER}
+            </foreach>
+        </if>
+        <if test="companyId != null">
+            AND b.company_id = #{companyId}
+        </if>
+        <if test="userId != null">
+            AND b.id=#{userId}
+        </if>
     </select>
 
     <!--专业待审核的报告列表-->

+ 28 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -334,6 +334,7 @@
                                         </el-timeline>
                                     </div>
                                 </div>
+                                <div v-if="hasMore && !listLoading" style="width:100%;font-size:17px;text-align:center;padding-bottom:15px;"><el-link @click="reqMore" :underline=false style="color:#20a0ff;">加载更多日报</el-link></div>
                                 <!-- 简陋的无报告提示 -->
                                 <div v-if="reportList.length==0" style="width:100%;font-size:17px;text-align:center;color:#aaa;">{{curDate}}{{$t('other.noReportYet')}}</div>
                             </div>
@@ -1982,6 +1983,8 @@
         },
         data() {
             return {
+                pageIndex: 0,
+                hasMore: true,
                 exportType: 0,
                 exportingData: false,
                 roleList:[{value: 1,label: 'CRC&LM'},{value: 2,label: 'PM'}],
@@ -5281,9 +5284,15 @@
                 curDate.setDate(0);
                 return curDate.getDate();
             },
-
-            //获取日报列表
-            getReportList() {
+            reqMore() {
+                if (this.hasMore) {
+                    this.pageIndex++;
+                    this.requestHttpReports();
+                }
+            },
+            //加载日报数据
+            requestHttpReports() {
+                //请求数据
                 this.listLoading = true;
                 let day = (this.choseDay + 1) > 9 ? "-" + (this.choseDay + 1) : "-0" + (this.choseDay + 1);
                 let param = {date: this.date + day};
@@ -5293,11 +5302,17 @@
                 if (this.targetUid) {
                     param.userId = this.targetUid;
                 }
+                //传页码
+                if (this.hasMore) {
+                    param.pageIndex = this.pageIndex;
+                }
                 this.http.post( this.port.report.list, param,
                 res => {
                     this.listLoading = false;
                     if (res.code == "ok") {
-                        this.reportList = res.data;
+                        //扩增
+                        this.reportList = this.reportList.concat(res.data.data);
+                        this.hasMore = res.data.hasMore;//标记是否还有更多数据
                         if(document.querySelector("#day"+this.choseDay)){
                             document.querySelector("#day"+this.choseDay).scrollIntoView(true);
                         }
@@ -5316,6 +5331,15 @@
                     });
                 });
             },
+
+            //获取日报列表
+            getReportList() {
+                //初始化,重置数据
+                this.pageIndex = 0;
+                this.hasMore = true;
+                this.reportList = [];
+                this.requestHttpReports();
+            },
             // 处理数据
             // dealWith() {
             //     var tianxie = 0