|
@@ -6517,4 +6517,129 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getWeeklyFillReportData(String targetDate, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String userId = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ //根据targetDate获取本周的日期
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate date = LocalDate.parse(targetDate, dtf);
|
|
|
+ LocalDate monday = date.with(DayOfWeek.MONDAY);
|
|
|
+ LocalDate sunday = date.with(DayOfWeek.SUNDAY);
|
|
|
+ //需要填报的最后一天
|
|
|
+ LocalDate lastDay = sunday;
|
|
|
+ int days = sunday.lengthOfMonth() - sunday.getDayOfMonth();
|
|
|
+ if (days <= 2) {
|
|
|
+ //周日距离月底相差天数在2天以内,比如周日是10.29,则10.30和10.31也算在本周内
|
|
|
+ lastDay = sunday.plusDays(days);
|
|
|
+ }
|
|
|
+ //如果上周只有2天以内工作日,需要并到这周来
|
|
|
+ LocalDate lastSunday = monday.minusDays(1);
|
|
|
+ LocalDate lastSaturday = lastSunday.with(DayOfWeek.SATURDAY);
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(lastSunday) && WorkDayCalculateUtils.isWorkDay(lastSaturday)) {
|
|
|
+ //上周周末两天是工作日,并且只有2天以内工作日,需要并到这周来
|
|
|
+ LocalDate lastMonday = lastSunday.with(DayOfWeek.MONDAY);
|
|
|
+ boolean hasMoreWorkDays = false;
|
|
|
+ while (lastMonday.isBefore(lastSaturday)) {
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(lastMonday)) {
|
|
|
+ hasMoreWorkDays = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ lastMonday = lastMonday.plusDays(1);
|
|
|
+ }
|
|
|
+ if (!hasMoreWorkDays) {
|
|
|
+ monday = lastSaturday;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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("dateList", dateList);
|
|
|
+ msg.data = reportMap;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
}
|