|
|
@@ -14580,7 +14580,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getReportListForExport(String startDate, String endDate, Integer projectId, Integer state, Integer departmentId, Integer pageIndex, Integer pageSize, String targetUserId, String orderBy, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
String userId = request.getHeader("Token");
|
|
|
@@ -14595,50 +14595,49 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (!StringUtils.isEmpty(departmentId)) {
|
|
|
branchDepartment = departmentService.getDeptIncludeSubDeptIds(departmentId, departments);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-// List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
|
|
|
-
|
|
|
-// if (functionList.size() == 0) {
|
|
|
-// // 检查是否是部门负责人
|
|
|
-// List<Integer> allVisibleDeptIdList = getAllVisibleDeptIdList(user, null);
|
|
|
-// if (allVisibleDeptIdList.size() > 0) {
|
|
|
-// allReportByDate = reportMapper.getDeptMembReportByDate(startDate, null, allVisibleDeptIdList, endDate, projectId, stateKey, branchDepartment, user.getId(), field, fieldValue);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (allReportByDate == null) {
|
|
|
-// allReportByDate = new ArrayList<>();
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// }
|
|
|
// 有查看全公司工时权限
|
|
|
- List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDateForExport(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment);
|
|
|
-
|
|
|
- // 分页处理
|
|
|
- int total = allReportByDate.size();
|
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
|
- int endIndex = Math.min(startIndex + pageSize, total);
|
|
|
-
|
|
|
- List<HashMap<String, Object>> pagedData = new ArrayList<>();
|
|
|
- if (startIndex < total) {
|
|
|
- pagedData = new ArrayList<>(allReportByDate.subList(startIndex, endIndex));
|
|
|
- //处理日期显示
|
|
|
- for (int i = 0; i < pagedData.size(); i++) {
|
|
|
- HashMap mapItem = pagedData.get(i);
|
|
|
- String createDate = new SimpleDateFormat("yyyy-MM-dd")
|
|
|
- .format((java.sql.Date) mapItem.get("createDate"));
|
|
|
- mapItem.put("createDate", createDate);
|
|
|
- //计算非加班工时
|
|
|
- double workingTime = (Double) mapItem.get("duration");
|
|
|
- double overtime = (Double) mapItem.get("overtimeHours");
|
|
|
- mapItem.put("normalWorkingTime", workingTime - overtime);
|
|
|
- //处理部门审核人
|
|
|
- String deptAuditorId = (String)mapItem.get("deptAuditorName");
|
|
|
- if (deptAuditorId != null) {
|
|
|
- User targetUser = allUserList.stream().filter(us->us.getId().equals(deptAuditorId)).findFirst().orElse(null);
|
|
|
- if (targetUser != null) {
|
|
|
- mapItem.put("deptAuditorName", targetUser.getName());
|
|
|
+ List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDateForExport(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment, startIndex, pageSize, orderBy);
|
|
|
+ // 处理数据
|
|
|
+ // 分页处理
|
|
|
+ int total = reportMapper.getAllReportByDateForExportCount(startDate, companyId, targetUserId, endDate, projectId, state, branchDepartment);
|
|
|
+ DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ //处理日期显示
|
|
|
+ for (int i = 0; i < allReportByDate.size(); i++) {
|
|
|
+ HashMap mapItem = allReportByDate.get(i);
|
|
|
+ String createDate = new SimpleDateFormat("yyyy-MM-dd")
|
|
|
+ .format((java.sql.Date) mapItem.get("createDate"));
|
|
|
+ mapItem.put("createDate", createDate);
|
|
|
+ //计算非加班工时
|
|
|
+ double workingTime = (Double) mapItem.get("duration");
|
|
|
+ double overtime = (Double) mapItem.get("overtimeHours");
|
|
|
+ mapItem.put("normalWorkingTime", workingTime - overtime);
|
|
|
+ //处理部门审核人
|
|
|
+ String deptAuditorId = (String)mapItem.get("deptAuditorName");
|
|
|
+ if (deptAuditorId != null) {
|
|
|
+ User targetUser = allUserList.stream().filter(us->us.getId().equals(deptAuditorId)).findFirst().orElse(null);
|
|
|
+ if (targetUser != null) {
|
|
|
+ mapItem.put("deptAuditorName", targetUser.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String lastOperateTime = mapItem.get("lastOperateTime") == null ? "" : mapItem.get("lastOperateTime").toString();
|
|
|
+ //计算时间
|
|
|
+ if (lastOperateTime != null && !lastOperateTime.equals("")) {
|
|
|
+ LocalDateTime time = LocalDateTime.parse(lastOperateTime, hmDtf);
|
|
|
+ //计算与当前时间的间隔
|
|
|
+ Duration duration = Duration.between(time, LocalDateTime.now());
|
|
|
+ long days = duration.toDays();
|
|
|
+ long hours = duration.toHours() % 24;
|
|
|
+ long minutes = duration.toMinutes() % 60;
|
|
|
+ //时间格式化
|
|
|
+ if (days == 0) {
|
|
|
+ if (hours == 0) {
|
|
|
+ mapItem.put("timeText", minutes + "分");
|
|
|
+ } else {
|
|
|
+ mapItem.put("timeText", hours + "小时" + minutes + "分");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ mapItem.put("timeText", days + "天" + hours + "小时" + minutes + "分");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -14649,7 +14648,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
resultMap.put("pageIndex", pageIndex);
|
|
|
resultMap.put("pageSize", pageSize);
|
|
|
resultMap.put("totalPages", (int) Math.ceil((double) total / pageSize));
|
|
|
- resultMap.put("list", pagedData);
|
|
|
+ resultMap.put("list", allReportByDate);
|
|
|
|
|
|
httpRespMsg.setData(resultMap);
|
|
|
} catch (Exception e) {
|
|
|
@@ -14664,7 +14663,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
// 调用getReportListForExport获取全部数据(不分页)
|
|
|
- HttpRespMsg queryResult = getReportListForExport(startDate, endDate, projectId, state, departmentId, 1, Integer.MAX_VALUE, targetUserId, request);
|
|
|
+ HttpRespMsg queryResult = getReportListForExport(startDate, endDate, projectId, state, departmentId, null, null, targetUserId,null, request);
|
|
|
|
|
|
if (queryResult.code != null && !queryResult.code.equals("ok")) {
|
|
|
return queryResult; // 返回错误信息
|
|
|
@@ -14698,6 +14697,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
titles.add("加班时长(h)");
|
|
|
titles.add("工作内容");
|
|
|
titles.add("当前审核人");
|
|
|
+ titles.add("审核滞留时长");
|
|
|
titles.add("审核状态");
|
|
|
|
|
|
dataList.add(titles);
|
|
|
@@ -14705,15 +14705,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
// 填充数据
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
DecimalFormat df = new DecimalFormat("0.0");
|
|
|
-
|
|
|
+ DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
for (HashMap<String, Object> map : allReportByDate) {
|
|
|
List<String> item = new ArrayList<>();
|
|
|
|
|
|
// 员工
|
|
|
if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
item.add("$userName=" + (map.get("corpwxUserId") == null ? "" : map.get("corpwxUserId")) + "$");
|
|
|
- } else if (dingding != null && dingding.getContactNeedTranslate() == 1) {
|
|
|
- item.add("$userName=" + (map.get("name") == null ? "" : map.get("name")) + "$");
|
|
|
} else {
|
|
|
item.add((String) map.get("name"));
|
|
|
}
|
|
|
@@ -14724,8 +14722,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
// 所属部门
|
|
|
if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
item.add("$departmentName=" + (map.get("corpwxDeptId") == null ? "" : map.get("corpwxDeptId")) + "$");
|
|
|
- } else if (dingding != null && dingding.getContactNeedTranslate() == 1) {
|
|
|
- item.add("$departmentName=" + (map.get("departmentName") == null ? "" : map.get("departmentName")) + "$");
|
|
|
} else {
|
|
|
item.add(map.get("departmentName") != null ? (String) map.get("departmentName") : "");
|
|
|
}
|
|
|
@@ -14775,6 +14771,28 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
// 工作内容
|
|
|
item.add(map.get("content") != null ? (String) map.get("content") : "");
|
|
|
|
|
|
+ String lastOperateTime = map.get("lastOperateTime") == null ? "" : map.get("lastOperateTime").toString();
|
|
|
+ //计算时间
|
|
|
+ String timeText = "";
|
|
|
+ if (lastOperateTime != null && !lastOperateTime.equals("")) {
|
|
|
+ LocalDateTime time = LocalDateTime.parse(lastOperateTime, hmDtf);
|
|
|
+ //计算与当前时间的间隔
|
|
|
+ Duration duration = Duration.between(time, LocalDateTime.now());
|
|
|
+ long days = duration.toDays();
|
|
|
+ long hours = duration.toHours() % 24;
|
|
|
+ long minutes = duration.toMinutes() % 60;
|
|
|
+ //时间格式化
|
|
|
+ if (days == 0) {
|
|
|
+ if (hours == 0) {
|
|
|
+ timeText = minutes + "分";
|
|
|
+ } else {
|
|
|
+ timeText = hours + "小时" + minutes + "分";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ timeText = days + "天" + hours + "小时" + minutes + "分";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 审核状态
|
|
|
Integer stateValue = (Integer) map.get("state");
|
|
|
String auditStatus = "";
|
|
|
@@ -14802,6 +14820,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
} else {
|
|
|
item.add("-");
|
|
|
}
|
|
|
+ item.add(timeText);
|
|
|
+
|
|
|
item.add(auditStatus);
|
|
|
|
|
|
dataList.add(item);
|
|
|
@@ -14819,7 +14839,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getReportGroupByDay(String startDate, String endDate, String userId, Integer departmentId, Integer projectId, Integer state, String orderBy, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
String token = request.getHeader("Token");
|
|
|
@@ -14877,14 +14897,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
// 查询按人按天汇总的数据
|
|
|
List<Map<String, Object>> groupedReportList = reportMapper.getReportGroupByDay(
|
|
|
- companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds, pageStart, pageSize);
|
|
|
+ companyId, startDate, endDate, userId, projectId, state, visibleDeptIds, pageStart, pageSize, orderBy);
|
|
|
|
|
|
// 获取总数
|
|
|
Integer totalCount = reportMapper.getReportGroupByDayCount(
|
|
|
- companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds);
|
|
|
+ companyId, startDate, endDate, userId, projectId, state, visibleDeptIds);
|
|
|
|
|
|
// 获取考勤数据
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
if (groupedReportList.size() > 0 && (timeType.getShowCorpwxCardtime() == 1 || timeType.getShowDdCardtime() == 1 || timeType.getSyncFanwei() == 1)) {
|
|
|
List<String> dateList = groupedReportList.stream().map(m -> (String)m.get("reportDate")).distinct().collect(Collectors.toList());
|
|
|
String minDate = dateList.stream().min(Comparator.comparing(String::toString)).get();
|
|
|
@@ -14983,8 +15004,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
map.put("cardRecord", "");
|
|
|
}
|
|
|
|
|
|
- // 13. 审核流程 - auditWorkflow已在SQL中拼接
|
|
|
-
|
|
|
+
|
|
|
// 14. 审核状态
|
|
|
Integer auditState = (Integer)map.get("auditState");
|
|
|
String auditStatusText = "";
|
|
|
@@ -15010,6 +15030,32 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
map.put("auditStatusText", auditStatusText);
|
|
|
+
|
|
|
+ //计算审核滞留时长
|
|
|
+ String auditWorkflow = (String)map.get("auditWorkflow");
|
|
|
+ if (auditWorkflow != null) {
|
|
|
+ String[] array = auditWorkflow.split("->");
|
|
|
+ String lastOperate = array[array.length - 1];
|
|
|
+ String[] array2 = lastOperate.split(" ");
|
|
|
+ String lastOperateTime = array2[0] + " " + array2[1];//最后一次操作时间
|
|
|
+ // 日期格式化
|
|
|
+ LocalDateTime lastOperateDate = LocalDateTime.parse(lastOperateTime, hmDtf);
|
|
|
+ //计算距离现在的时间间隔
|
|
|
+ Duration duration = Duration.between(lastOperateDate, LocalDateTime.now());
|
|
|
+ long days = duration.toDays();
|
|
|
+ long hours = duration.toHours() % 24;
|
|
|
+ long minutes = duration.toMinutes() % 60;
|
|
|
+ //时间格式化
|
|
|
+ if (days == 0) {
|
|
|
+ if (hours == 0) {
|
|
|
+ map.put("timeText", minutes + "分");
|
|
|
+ } else {
|
|
|
+ map.put("timeText", hours + "小时" + minutes + "分");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ map.put("timeText", days + "天" + hours + "小时" + minutes + "分");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//处理加班申请
|
|
|
List<Overtime> overtimeList = userIds.size() > 0?overtimeMapper.selectList(new QueryWrapper<Overtime>().eq("company_id", companyId)
|
|
|
@@ -15100,10 +15146,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
// 查询按人按天汇总的数据
|
|
|
List<Map<String, Object>> groupedReportList = reportMapper.getReportGroupByDay(
|
|
|
- companyId, startDate, endDate, userId, departmentId, projectId, state, visibleDeptIds, null, null);
|
|
|
+ companyId, startDate, endDate, userId, projectId, state, visibleDeptIds, null, null, null);
|
|
|
|
|
|
// 获取考勤数据
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter hmDtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
if (groupedReportList.size() > 0 && (timeType.getShowCorpwxCardtime() == 1 || timeType.getShowDdCardtime() == 1 || timeType.getSyncFanwei() == 1)) {
|
|
|
List<String> dateList = groupedReportList.stream().map(m -> (String)m.get("reportDate")).distinct().collect(Collectors.toList());
|
|
|
String minDate = dateList.stream().min(Comparator.comparing(String::toString)).get();
|
|
|
@@ -15229,7 +15276,34 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
map.put("auditStatusText", auditStatusText);
|
|
|
+
|
|
|
+ String auditWorkflow = (String)map.get("auditWorkflow");
|
|
|
+ //计算时间
|
|
|
+ if (auditWorkflow != null) {
|
|
|
+ String[] array = auditWorkflow.split("->");
|
|
|
+ String lastOperate = array[array.length - 1];
|
|
|
+ String[] array2 = lastOperate.split(" ");
|
|
|
+ String lastOperateTime = array2[0] + " " + array2[1];//最后一次操作时间
|
|
|
+ // 日期格式化
|
|
|
+ LocalDateTime lastOperateDate = LocalDateTime.parse(lastOperateTime, hmDtf);
|
|
|
+ //计算距离现在的时间间隔
|
|
|
+ Duration duration = Duration.between(lastOperateDate, LocalDateTime.now());
|
|
|
+ long days = duration.toDays();
|
|
|
+ long hours = duration.toHours() % 24;
|
|
|
+ long minutes = duration.toMinutes() % 60;
|
|
|
+ //时间格式化
|
|
|
+ if (days == 0) {
|
|
|
+ if (hours == 0) {
|
|
|
+ map.put("timeText", minutes + "分");
|
|
|
+ } else {
|
|
|
+ map.put("timeText", hours + "小时" + minutes + "分");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ map.put("timeText", days + "天" + hours + "小时" + minutes + "分");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//处理加班申请
|
|
|
List<Overtime> overtimeList = userIds.size() > 0?overtimeMapper.selectList(new QueryWrapper<Overtime>().eq("company_id", companyId)
|
|
|
.between("date", startDate, endDate).in("user_id", userIds)): new ArrayList<>();
|
|
|
@@ -15261,6 +15335,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
titles.add("[加班工时]明细条数");
|
|
|
titles.add("审核流程");
|
|
|
titles.add("当前审核人");
|
|
|
+ titles.add("审核滞留时长");
|
|
|
titles.add("审核状态");
|
|
|
|
|
|
dataList.add(titles);
|
|
|
@@ -15358,6 +15433,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
} else {
|
|
|
item.add("-");
|
|
|
}
|
|
|
+ item.add((String)map.get("timeText"));
|
|
|
// 审核状态
|
|
|
item.add(map.get("auditStatusText") != null ? (String) map.get("auditStatusText") : "");
|
|
|
|
|
|
@@ -15366,7 +15442,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
// 生成Excel文件导出
|
|
|
String fileName = "工时日报列表_" + startDate + "至" + endDate + "_" + System.currentTimeMillis();
|
|
|
- System.out.println("到处日报文件==>" + fileName);
|
|
|
return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, dingding, fileName, dataList, path);
|
|
|
|
|
|
} catch (Exception e) {
|