|
@@ -5206,6 +5206,50 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getNotFullReportUserList(Integer companyId, LocalDate localStart, LocalDate localEnd) {
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id,create_date,creator_id, state").eq("company_id", companyId).between("create_date", localStart, localEnd));
|
|
|
+ List<User> allRangeUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("report_status",0));
|
|
|
+
|
|
|
+ List<Map<String, Object>> noReportDataList = new ArrayList<Map<String, Object>>();
|
|
|
+ long cnt = localStart.until(localEnd, ChronoUnit.DAYS);
|
|
|
+ //已驳回的数据
|
|
|
+ //按人员过滤
|
|
|
+ for (User curUser: allRangeUserList){
|
|
|
+ for (int i=0;i<=cnt; i++) {
|
|
|
+ LocalDate date = localStart.plusDays(i);
|
|
|
+ //入职日期以前 不需要添加 跳出
|
|
|
+ if(curUser.getInductionDate()!=null&&date.isBefore(curUser.getInductionDate())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //当前日期在离职日期之后 不需要再添加 跳出
|
|
|
+ if((curUser.getIsActive()==0&& curUser.getInactiveDate() != null &&date.isAfter(curUser.getInactiveDate()))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //去掉非工作日
|
|
|
+ Boolean workDay = timeTypeService.isWorkDay(companyId, date);
|
|
|
+ if (!workDay){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //不存在已提交或者已通过的日报,视为未提交。包括未填写,待提交,已驳回,已撤销这些状态
|
|
|
+ if (!reportList.stream().anyMatch(item->item.getCreatorId().equals(curUser.getId())&&item.getCreateDate().isEqual(date)&&(item.getState() == 0 || item.getState() == 1))) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("corpwxUserid", curUser.getCorpwxUserid());
|
|
|
+ map.put("name", curUser.getName());
|
|
|
+ map.put("days", 1);
|
|
|
+ if (!noReportDataList.stream().anyMatch(noItem->noItem.get("corpwxUserid").equals(curUser.getCorpwxUserid()))) {
|
|
|
+ noReportDataList.add(map);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Map<String, Object> findUser = noReportDataList.stream().filter(data -> data.get("corpwxUserid").equals(curUser.getCorpwxUserid())).findFirst().get();
|
|
|
+ Object days = findUser.get("days");
|
|
|
+ findUser.put("days", (Integer)days + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return noReportDataList;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg exportNoReportUserList(HttpServletRequest request, String startDate, String endDate) {
|
|
|
HttpRespMsg msg = getNoReportUserList(request, startDate, endDate);
|
|
@@ -6525,18 +6569,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//根据targetDate获取本周的日期
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
LocalDate date = LocalDate.parse(targetDate, dtf);
|
|
|
- LocalDate monday = date.with(DayOfWeek.MONDAY);
|
|
|
+ LocalDate firstDayOfWeek = date.with(DayOfWeek.MONDAY);
|
|
|
LocalDate sunday = date.with(DayOfWeek.SUNDAY);
|
|
|
//需要填报的最后一天
|
|
|
- LocalDate lastDay = sunday;
|
|
|
+ LocalDate lastDayOfWeek = sunday;
|
|
|
int days = sunday.lengthOfMonth() - sunday.getDayOfMonth();
|
|
|
if (days <= 2) {
|
|
|
//周日距离月底相差天数在2天以内,比如周日是10.29,则10.30和10.31也算在本周内
|
|
|
- lastDay = sunday.plusDays(days);
|
|
|
+ lastDayOfWeek = sunday.plusDays(days);
|
|
|
}
|
|
|
//如果上周只有2天以内工作日,需要并到这周来
|
|
|
- LocalDate lastSunday = monday.minusDays(1);
|
|
|
+ LocalDate lastSunday = firstDayOfWeek.minusDays(1);
|
|
|
LocalDate lastSaturday = lastSunday.with(DayOfWeek.SATURDAY);
|
|
|
+
|
|
|
if (WorkDayCalculateUtils.isWorkDay(lastSunday) && WorkDayCalculateUtils.isWorkDay(lastSaturday)) {
|
|
|
//上周周末两天是工作日,并且只有2天以内工作日,需要并到这周来
|
|
|
LocalDate lastMonday = lastSunday.with(DayOfWeek.MONDAY);
|
|
@@ -6549,95 +6594,109 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
lastMonday = lastMonday.plusDays(1);
|
|
|
}
|
|
|
if (!hasMoreWorkDays) {
|
|
|
- monday = lastSaturday;
|
|
|
+ firstDayOfWeek = lastSaturday;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果本周一周二中有工作日,但是是上个月的月末,会被合并到上周去,本周要去掉
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(firstDayOfWeek) && firstDayOfWeek.getDayOfMonth() >= 30) {
|
|
|
+ firstDayOfWeek = firstDayOfWeek.plusDays(1);
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(firstDayOfWeek) && firstDayOfWeek.getDayOfMonth() >= 30) {
|
|
|
+ firstDayOfWeek = firstDayOfWeek.plusDays(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String startDate = monday.format(dtf);
|
|
|
- String endDate = lastDay.format(dtf);
|
|
|
- TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
- //获取日报详情
|
|
|
- List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("creator_id", userId).between("create_date", startDate, endDate).orderByAsc("create_date"));
|
|
|
- List<Integer> collect = reportList.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
- //加载这段时间内已填报过的项目
|
|
|
- List<Project> projectList = new ArrayList<>();
|
|
|
- if (collect.size() > 0) {
|
|
|
- projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
- //获取项目的任务分组列表
|
|
|
- List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", collect));
|
|
|
- //获取负责人的用户集合
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList())));
|
|
|
- reportList.forEach(r->{
|
|
|
- r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
- for (TaskGroup gp : r.getTaskGroups()) {
|
|
|
- if (!StringUtils.isEmpty(gp.getInchargerId()) ) {
|
|
|
- if (gp.getInchargerId().equals(userId)) {
|
|
|
- //自己担任任务分组的负责人,自己的审核人是项目经理
|
|
|
- gp.setInchargerId(projectMapper.selectById(r.getProjectId()).getInchargerId());
|
|
|
- //不存在的话,加上项目经理
|
|
|
- if (!userList.stream().anyMatch(u->u.getId().equals(gp.getInchargerId()))) {
|
|
|
- userList.add(userMapper.selectById(gp.getInchargerId()));
|
|
|
+ //再按照当前用户的入职离职日期进行过滤
|
|
|
+ LocalDate entryDate = user.getInductionDate();
|
|
|
+ LocalDate leaveDate = user.getInactiveDate();
|
|
|
+ boolean needFill = true;
|
|
|
+ if (entryDate != null && entryDate.isAfter(firstDayOfWeek)) {
|
|
|
+ if (lastDayOfWeek.isBefore(entryDate)) {
|
|
|
+ //最后一天也在入职日期之前,不需要填报
|
|
|
+ needFill = false;
|
|
|
+ } else {
|
|
|
+ firstDayOfWeek = entryDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (user.getIsActive()==0 && leaveDate != null && leaveDate.isBefore(lastDayOfWeek)) {
|
|
|
+ lastDayOfWeek = leaveDate;
|
|
|
+ }
|
|
|
+ Map<String, List> reportMap = new HashMap<>();
|
|
|
+ if (needFill) {
|
|
|
+ String startDate = firstDayOfWeek.format(dtf);
|
|
|
+ String endDate = lastDayOfWeek.format(dtf);
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
+ //获取日报详情
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("creator_id", userId).between("create_date", startDate, endDate).orderByAsc("create_date"));
|
|
|
+ List<Integer> collect = reportList.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
+ //加载这段时间内已填报过的项目
|
|
|
+ List<Project> projectList = new ArrayList<>();
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
+ //获取项目的任务分组列表
|
|
|
+ List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", collect));
|
|
|
+ //获取负责人的用户集合
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList())));
|
|
|
+ reportList.forEach(r->{
|
|
|
+ r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
+ for (TaskGroup gp : r.getTaskGroups()) {
|
|
|
+ if (!StringUtils.isEmpty(gp.getInchargerId()) ) {
|
|
|
+ if (gp.getInchargerId().equals(userId)) {
|
|
|
+ //自己担任任务分组的负责人,自己的审核人是项目经理
|
|
|
+ gp.setInchargerId(projectMapper.selectById(r.getProjectId()).getInchargerId());
|
|
|
+ //如果自己就是项目经理,审核人变成自己的部门负责人
|
|
|
+ if (gp.getInchargerId().equals(userId)) {
|
|
|
+ gp.setInchargerId(departmentMapper.selectById(user.getDepartmentId()).getManagerId());
|
|
|
+ }
|
|
|
+ //不存在的话,加上项目经理
|
|
|
+ if (!userList.stream().anyMatch(u->u.getId().equals(gp.getInchargerId()))) {
|
|
|
+ userList.add(userMapper.selectById(gp.getInchargerId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(gp.getInchargerId())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ gp.setInchargerName(first.get().getName());
|
|
|
}
|
|
|
}
|
|
|
- gp.setInchargerName(userList.stream().filter(u->u.getId().equals(gp.getInchargerId())).findFirst().get().getName());
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-// List cardTimeList = new ArrayList();
|
|
|
-// if (timeType.getShowDdCardtime() == 1) {
|
|
|
-// List<UserDingdingTime> dingdingTimes = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>()
|
|
|
-// .eq("user_id", userId).between("work_date", startDate, endDate));
|
|
|
-// cardTimeList = dingdingTimes;
|
|
|
-// } else if(timeType.getSyncFanwei()==1){
|
|
|
-// List<UserFvTime> userFvTimes = userFvTimeMapper.selectList(new QueryWrapper<UserFvTime>()
|
|
|
-// .eq("user_id", userId).between("work_date", startDate, endDate));
|
|
|
-// cardTimeList = userFvTimes;
|
|
|
-// } else if (timeType.getShowCorpwxCardtime() == 1) {
|
|
|
-// List<UserCorpwxTime> corpwxTimes = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
|
|
|
-// .eq("corpwx_userid", user.getCorpwxUserid()).between("create_date", startDate, endDate));
|
|
|
-// cardTimeList = corpwxTimes;
|
|
|
-// }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- Map<String, List> reportMap = new HashMap<>();
|
|
|
-// reportMap.put("reportList", reportList);
|
|
|
-// reportMap.put("cardTimeList", cardTimeList);
|
|
|
- reportMap.put("projectList", projectList);
|
|
|
- //计算日期,进行返回
|
|
|
- List<HashMap> dateList = new ArrayList<>();
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- LocalDate itemDate = monday;
|
|
|
- while(true) {
|
|
|
- System.out.println("itemDate=="+itemDate.toString());
|
|
|
- if (WorkDayCalculateUtils.isWorkDay(itemDate)) {
|
|
|
- HashMap item = new HashMap();
|
|
|
- item.put("date", itemDate.format(dtf));
|
|
|
- //计算显示的周几
|
|
|
- item.put("weekDayTxt", DateTimeUtil.getWeekDayTxt(itemDate.getDayOfWeek().getValue()));
|
|
|
- //不可提前填报
|
|
|
- if (timeType.getFillAhead() == 0 && itemDate.isAfter(today)) {
|
|
|
- item.put("canFill", 0);
|
|
|
- } else {
|
|
|
- item.put("canFill", 1);
|
|
|
- }
|
|
|
- //放入当天对应的日报
|
|
|
- final LocalDate finalItemDate = itemDate;
|
|
|
- List<Report> dateReportList = reportList.stream().filter(r -> r.getCreateDate().isEqual(finalItemDate)).collect(Collectors.toList());
|
|
|
- item.put("reportList", dateReportList);
|
|
|
- double sum = dateReportList.stream().mapToDouble(Report::getWorkingTime).sum();
|
|
|
- item.put("filledTime", sum);
|
|
|
- dateList.add(item);
|
|
|
- }
|
|
|
- //往后推一天
|
|
|
- itemDate = itemDate.plusDays(1);
|
|
|
- //超过最后一天了,跳出循环
|
|
|
- if (itemDate.isAfter(lastDay)) {
|
|
|
- break;
|
|
|
+ reportMap.put("projectList", projectList);
|
|
|
+ //计算日期,进行返回
|
|
|
+ List<HashMap> dateList = new ArrayList<>();
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate itemDate = firstDayOfWeek;
|
|
|
+ while(true) {
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(itemDate)) {
|
|
|
+ HashMap item = new HashMap();
|
|
|
+ item.put("date", itemDate.format(dtf));
|
|
|
+ //计算显示的周几
|
|
|
+ item.put("weekDayTxt", DateTimeUtil.getWeekDayTxt(itemDate.getDayOfWeek().getValue()));
|
|
|
+ //不可提前填报
|
|
|
+ if (timeType.getFillAhead() == 0 && itemDate.isAfter(today)) {
|
|
|
+ item.put("canFill", 0);
|
|
|
+ } else {
|
|
|
+ item.put("canFill", 1);
|
|
|
+ }
|
|
|
+ //放入当天对应的日报
|
|
|
+ final LocalDate finalItemDate = itemDate;
|
|
|
+ List<Report> dateReportList = reportList.stream().filter(r -> r.getCreateDate().isEqual(finalItemDate)).collect(Collectors.toList());
|
|
|
+ item.put("reportList", dateReportList);
|
|
|
+ double sum = dateReportList.stream().mapToDouble(Report::getWorkingTime).sum();
|
|
|
+ item.put("filledTime", sum);
|
|
|
+ dateList.add(item);
|
|
|
+ }
|
|
|
+ //往后推一天
|
|
|
+ itemDate = itemDate.plusDays(1);
|
|
|
+ //超过最后一天了,跳出循环
|
|
|
+ if (itemDate.isAfter(lastDayOfWeek)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ reportMap.put("dateList", dateList);
|
|
|
+ } else {
|
|
|
+ reportMap.put("dateList", new ArrayList());
|
|
|
}
|
|
|
- reportMap.put("dateList", dateList);
|
|
|
msg.data = reportMap;
|
|
|
return msg;
|
|
|
}
|