|
@@ -10286,29 +10286,85 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//date格式为2024-09, 需要获取该月的第一天和最后一天
|
|
|
LocalDate firstDay = LocalDate.parse(date + "-01");
|
|
|
LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
- if (user.getCorpwxUserid() != null) {
|
|
|
- userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).eq("corpwx_userid", user.getCorpwxUserid()).between("create_date", firstDay, lastDay));
|
|
|
+ //检查权限,有查看全公司数值的权限
|
|
|
+ boolean canViewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全公司工时");
|
|
|
+ List<User> manageUserList = new ArrayList<>();
|
|
|
+ if (canViewAll) {
|
|
|
+ userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).between("create_date", firstDay, lastDay));
|
|
|
+ manageUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
} else {
|
|
|
- userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).eq("name", user.getName()).between("create_date", firstDay, lastDay));
|
|
|
+ //是否是部门负责人
|
|
|
+ List<Integer> allDeptIds = getAllVisibleDeptIdList(user, departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId)));
|
|
|
+ if (allDeptIds.size() > 0) {
|
|
|
+ //有部门工时的查看权限
|
|
|
+ //取部门的人员
|
|
|
+ manageUserList = userMapper.selectList(new QueryWrapper<User>().in("department_id", allDeptIds));
|
|
|
+ //如果自己不在manageUserList中,加进去
|
|
|
+ if (!manageUserList.stream().anyMatch(u -> u.getId().equals(user.getId()))) {
|
|
|
+ manageUserList.add(user);
|
|
|
+ }
|
|
|
+ List<String> userCorpwxidList = manageUserList.stream().filter(u->u.getCorpwxUserid() != null).map(User::getCorpwxUserid).collect(Collectors.toList());
|
|
|
+ if (userCorpwxidList.size() > 0) {
|
|
|
+ userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).in("corpwx_userid", userCorpwxidList).between("create_date", firstDay, lastDay));
|
|
|
+ }
|
|
|
+ //如果存在corpwxUserid位空的用户,按姓名匹配
|
|
|
+ List<String> nameList = manageUserList.stream().filter(u->u.getCorpwxUserid() == null).map(User::getName).collect(Collectors.toList());
|
|
|
+ if (nameList.size() == 0) {
|
|
|
+ userCorpwxTimeList.addAll(userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).in("name", nameList).between("create_date", firstDay, lastDay)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //个人看自己的
|
|
|
+ if (user.getCorpwxUserid() != null) {
|
|
|
+ userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).eq("corpwx_userid", user.getCorpwxUserid()).between("create_date", firstDay, lastDay));
|
|
|
+ } else {
|
|
|
+ userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("company_id", companyId).eq("name", user.getName()).between("create_date", firstDay, lastDay));
|
|
|
+ }
|
|
|
+ manageUserList.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取填报工时记录表
|
|
|
+ List<Report> reportList = new ArrayList<>();
|
|
|
+ if (canViewAll) {
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").eq("company_id", companyId).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date"));
|
|
|
+ } else if (manageUserList.size() > 0) {
|
|
|
+ List<String> userIdList = manageUserList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").in("creator_id", userIdList).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date"));
|
|
|
+ } else {
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").eq("creator_id", user.getId()).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date"));
|
|
|
}
|
|
|
- //获取个人每日填报工时记录表
|
|
|
- List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").eq("creator_id", user.getId()).between("create_date", firstDay, lastDay).groupBy("create_date"));
|
|
|
//比对userCorpwxTimeList和reportList,找出工时未填满的记录
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
for (UserCorpwxTime corpwxTime : userCorpwxTimeList) {
|
|
|
boolean isMatch = true;
|
|
|
double reportTime = 0;
|
|
|
- for (Report report : reportList) {
|
|
|
- if (corpwxTime.getCreateDate().isEqual(report.getCreateDate())) {
|
|
|
- reportTime = report.getWorkingTime();
|
|
|
- //不一致
|
|
|
- if (Math.abs(corpwxTime.getWorkHours() - report.getWorkingTime()) > 0.01) {
|
|
|
- isMatch = false;
|
|
|
+ User targetUser = null;
|
|
|
+ if (corpwxTime.getCorpwxUserid() != null) {
|
|
|
+ Optional<User> first = manageUserList.stream().filter(u -> corpwxTime.getCorpwxUserid().equals(u.getCorpwxUserid())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ targetUser = first.get();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Optional<User> first = manageUserList.stream().filter(u -> u.getName().equals(corpwxTime.getName())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ targetUser = first.get();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (targetUser != null) {
|
|
|
+ for (Report report : reportList) {
|
|
|
+ if (report.getCreatorId().equals(targetUser.getId()) && corpwxTime.getCreateDate().isEqual(report.getCreateDate())) {
|
|
|
+ reportTime = report.getWorkingTime();
|
|
|
+ //不一致
|
|
|
+ if (Math.abs(corpwxTime.getWorkHours() - report.getWorkingTime()) > 0.01) {
|
|
|
+ isMatch = false;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (!isMatch) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("name", corpwxTime.getName()==null?corpwxTime.getCorpwxUserid():corpwxTime.getName());
|
|
@@ -10321,12 +10377,21 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//反向,检测有填报日报但是没有考勤的数据
|
|
|
for (Report report : reportList) {
|
|
|
boolean hasCardTime = false;
|
|
|
+ Optional<User> first = manageUserList.stream().filter(u -> u.getId().equals(report.getCreatorId())).findFirst();
|
|
|
+ if (!first.isPresent()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ User targetUser = first.get();
|
|
|
for (UserCorpwxTime corpwxTime : userCorpwxTimeList) {
|
|
|
- if (corpwxTime.getCreateDate().isEqual(report.getCreateDate())) {
|
|
|
- if (corpwxTime.getWorkHours() > 0) {
|
|
|
- hasCardTime = true;
|
|
|
+ if ((targetUser.getCorpwxUserid() != null && targetUser.getCorpwxUserid().equals(corpwxTime.getCorpwxUserid()))
|
|
|
+ || (targetUser.getCorpwxUserid() == null && targetUser.getName().equals(corpwxTime.getName()))) {
|
|
|
+ //人员匹配上了,匹配日期
|
|
|
+ if (corpwxTime.getCreateDate().isEqual(report.getCreateDate())) {
|
|
|
+ if (corpwxTime.getWorkHours() > 0) {
|
|
|
+ hasCardTime = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
if (!hasCardTime) {
|