|
@@ -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表中获取请假时长
|