|
|
@@ -10032,53 +10032,56 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
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 firstDayOfWeek = date.with(DayOfWeek.MONDAY);
|
|
|
- //需要填报的最后一天
|
|
|
- LocalDate lastDayOfWeek = date.with(DayOfWeek.SUNDAY);
|
|
|
-// int days = sunday.lengthOfMonth() - sunday.getDayOfMonth();
|
|
|
-// if (days <= 3) {
|
|
|
-// //周日距离月底相差天数在3天以内,比如周日是10.28,则10.29,10.30和10.31也算在本周内
|
|
|
-// lastDayOfWeek = sunday.plusDays(days);
|
|
|
-// }
|
|
|
- //如果上周只有2天以内工作日,需要并到这周来
|
|
|
-// 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);
|
|
|
-// boolean hasMoreWorkDays = false;
|
|
|
-// while (lastMonday.isBefore(lastSaturday)) {
|
|
|
-// if (WorkDayCalculateUtils.isWorkDay(lastMonday)) {
|
|
|
-// hasMoreWorkDays = true;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// lastMonday = lastMonday.plusDays(1);
|
|
|
-// }
|
|
|
-// if (!hasMoreWorkDays) {
|
|
|
-// firstDayOfWeek = lastSaturday;
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// //剔除被合并到上周的情况,如果本周一周二周三中有工作日,但是是上个月的月末,会被合并到上周去,本周要去掉
|
|
|
-// boolean hasFirstDayOfMonth = false;
|
|
|
-// LocalDate checkDate = firstDayOfWeek;
|
|
|
-// int beforeDays = 0;
|
|
|
-// while (!checkDate.isAfter(lastDayOfWeek)) {
|
|
|
-// if (checkDate.getDayOfMonth() == 1) {
|
|
|
-// hasFirstDayOfMonth = true;
|
|
|
-// break;
|
|
|
-// } else {
|
|
|
-// beforeDays++;
|
|
|
-// }
|
|
|
-// checkDate = checkDate.plusDays(1);
|
|
|
-// }
|
|
|
-// if (hasFirstDayOfMonth && beforeDays <= 3) {
|
|
|
-// firstDayOfWeek = checkDate;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
+ if (timeType.getEnableNewWeeklyfill() == 1) {
|
|
|
+ //根据targetDate获取本周的日期
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate date = LocalDate.parse(targetDate, dtf);
|
|
|
+ LocalDate firstDayOfWeek = date.with(DayOfWeek.MONDAY);
|
|
|
+ LocalDate sunday = date.with(DayOfWeek.SUNDAY);
|
|
|
+ //需要填报的最后一天
|
|
|
+ LocalDate lastDayOfWeek = sunday;
|
|
|
+ int days = sunday.lengthOfMonth() - sunday.getDayOfMonth();
|
|
|
+ if (days <= 3) {
|
|
|
+ //周日距离月底相差天数在3天以内,比如周日是10.28,则10.29,10.30和10.31也算在本周内
|
|
|
+ lastDayOfWeek = sunday.plusDays(days);
|
|
|
+ }
|
|
|
+ //如果上周只有2天以内工作日,需要并到这周来
|
|
|
+ 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);
|
|
|
+ boolean hasMoreWorkDays = false;
|
|
|
+ while (lastMonday.isBefore(lastSaturday)) {
|
|
|
+ if (WorkDayCalculateUtils.isWorkDay(lastMonday)) {
|
|
|
+ hasMoreWorkDays = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ lastMonday = lastMonday.plusDays(1);
|
|
|
+ }
|
|
|
+ if (!hasMoreWorkDays) {
|
|
|
+ firstDayOfWeek = lastSaturday;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //剔除被合并到上周的情况,如果本周一周二周三中有工作日,但是是上个月的月末,会被合并到上周去,本周要去掉
|
|
|
+ boolean hasFirstDayOfMonth = false;
|
|
|
+ LocalDate checkDate = firstDayOfWeek;
|
|
|
+ int beforeDays = 0;
|
|
|
+ while (!checkDate.isAfter(lastDayOfWeek)) {
|
|
|
+ if (checkDate.getDayOfMonth() == 1) {
|
|
|
+ hasFirstDayOfMonth = true;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ beforeDays++;
|
|
|
+ }
|
|
|
+ checkDate = checkDate.plusDays(1);
|
|
|
+ }
|
|
|
+ if (hasFirstDayOfMonth && beforeDays <= 3) {
|
|
|
+ firstDayOfWeek = checkDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// if (WorkDayCalculateUtils.isWorkDay(firstDayOfWeek) && firstDayOfWeek.getDayOfMonth() >= 30) {
|
|
|
// firstDayOfWeek = firstDayOfWeek.plusDays(1);
|
|
|
@@ -10086,96 +10089,297 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
// firstDayOfWeek = firstDayOfWeek.plusDays(1);
|
|
|
// }
|
|
|
// }
|
|
|
- //死代码 2025-01-27 周一 合并到1-26号那一周
|
|
|
-// LocalDate specialDate = LocalDate.of(2025, 1, 27);
|
|
|
-// if(lastDayOfWeek.plusDays(1).isEqual(specialDate)){
|
|
|
-// lastDayOfWeek = specialDate;
|
|
|
-// }
|
|
|
+ //死代码 2025-01-27 周一 合并到1-26号那一周
|
|
|
+ LocalDate specialDate = LocalDate.of(2025, 1, 27);
|
|
|
+ if(lastDayOfWeek.plusDays(1).isEqual(specialDate)){
|
|
|
+ lastDayOfWeek = specialDate;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
- //再按照当前用户的入职离职日期进行过滤
|
|
|
- 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, Object> reportMap = new HashMap<>();
|
|
|
- if (needFill) {
|
|
|
- String summary = null;
|
|
|
- String attachment = null;
|
|
|
- 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"));
|
|
|
- //已填日报设置审核人姓名
|
|
|
- if (reportList.size() > 0) {
|
|
|
- Integer batchId = reportList.get(0).getBatchId();
|
|
|
- if (batchId != null) {
|
|
|
- //获取周总结
|
|
|
- ReportBatch batch = reportBatchMapper.selectById(batchId);
|
|
|
- //老数据可能出现batchId错误的情况,已经被删掉了,就不处理了。
|
|
|
- if (batch != null) {
|
|
|
- summary = batch.getSummary();
|
|
|
- attachment = batch.getAttachment();
|
|
|
- }
|
|
|
- }
|
|
|
- List<String> collect = reportList.stream().map(Report::getProjectAuditorId).distinct().collect(Collectors.toList());
|
|
|
- if (collect.size() > 0) {
|
|
|
- List<User> auditorUserList = userMapper.selectList(new QueryWrapper<User>().in("id", collect));
|
|
|
- reportList.forEach(r->{
|
|
|
- if (r.getProjectAuditorId() != null) {
|
|
|
- Optional<User> first = auditorUserList.stream().filter(au -> au.getId().equals(r.getProjectAuditorId())).findFirst();
|
|
|
- if (first.isPresent()) {
|
|
|
- r.setProjectAuditorName(first.get().getName());
|
|
|
+ //再按照当前用户的入职离职日期进行过滤
|
|
|
+ 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, Object> reportMap = new HashMap<>();
|
|
|
+ if (needFill) {
|
|
|
+ String summary = null;
|
|
|
+ String attachment = null;
|
|
|
+ String startDate = firstDayOfWeek.format(dtf);
|
|
|
+ String endDate = lastDayOfWeek.format(dtf);
|
|
|
+ //获取日报详情
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("creator_id", userId).between("create_date", startDate, endDate).orderByAsc("create_date"));
|
|
|
+ //已填日报设置审核人姓名
|
|
|
+ if (reportList.size() > 0) {
|
|
|
+ Integer batchId = reportList.get(0).getBatchId();
|
|
|
+ if (batchId != null) {
|
|
|
+ //获取周总结
|
|
|
+ ReportBatch batch = reportBatchMapper.selectById(batchId);
|
|
|
+ //老数据可能出现batchId错误的情况,已经被删掉了,就不处理了。
|
|
|
+ if (batch != null) {
|
|
|
+ summary = batch.getSummary();
|
|
|
+ attachment = batch.getAttachment();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> collect = reportList.stream().map(Report::getProjectAuditorId).distinct().collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<User> auditorUserList = userMapper.selectList(new QueryWrapper<User>().in("id", collect));
|
|
|
+ reportList.forEach(r->{
|
|
|
+ if (r.getProjectAuditorId() != null) {
|
|
|
+ Optional<User> first = auditorUserList.stream().filter(au -> au.getId().equals(r.getProjectAuditorId())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ r.setProjectAuditorName(first.get().getName());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
- List<Integer> collect = reportList.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
- final List<ReportExtraDegree> degreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<Integer> collect = reportList.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
+ final List<ReportExtraDegree> degreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", user.getCompanyId()));
|
|
|
|
|
|
- //加载这段时间内已填报过的项目
|
|
|
- List<Project> projectList = new ArrayList<>();
|
|
|
- if (collect.size() > 0) {
|
|
|
- projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
- final List<Project> finalProjectList = projectList;
|
|
|
- //获取项目的任务分组列表
|
|
|
-
|
|
|
-
|
|
|
- QueryWrapper<TaskGroup> taskGroupQueryWrapper = new QueryWrapper<TaskGroup>().in("project_id", collect);
|
|
|
- if (timeType.getReportAuditType() == 1) {//分组负责人审核模式,需要按参与的任务分组显示
|
|
|
+ //加载这段时间内已填报过的项目
|
|
|
+ List<Project> projectList = new ArrayList<>();
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
+ final List<Project> finalProjectList = projectList;
|
|
|
+ //获取项目的任务分组列表
|
|
|
//需要是他参与的任务分组
|
|
|
List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().eq("user_id", userId));
|
|
|
List<Integer> joinGroupList = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
|
|
|
if (joinGroupList.size() > 0) {
|
|
|
- taskGroupQueryWrapper.in("id", joinGroupList);
|
|
|
- } else {
|
|
|
- taskGroupQueryWrapper.eq("id", -1);//没有分组
|
|
|
+ List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", collect).in("id", joinGroupList));
|
|
|
+ //获取负责人的用户集合
|
|
|
+ List<String> inchargerIds = taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList());
|
|
|
+ if (inchargerIds.size() == 0) {
|
|
|
+ inchargerIds.add("-1");
|
|
|
+ }
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", inchargerIds));
|
|
|
+ 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)) {
|
|
|
+ Integer dpId = user.getDepartmentId();
|
|
|
+ if (dpId != null && dpId > 0) {
|
|
|
+ Department department = departmentMapper.selectById(dpId);
|
|
|
+ if (department != null) {
|
|
|
+ gp.setInchargerId(department.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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置项目名称
|
|
|
+ Optional<Project> optional = finalProjectList.stream().filter(p->p.getId().equals(r.getProjectId())).findFirst();
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ r.setProjectName(optional.get().getProjectName());
|
|
|
+ }
|
|
|
+ //设置自定义维度
|
|
|
+ if (timeType.getCustomDegreeActive() == 1) {
|
|
|
+ if (timeType.getCustomDegreeWithPro() == 1) {
|
|
|
+ String associateDegrees = optional.get().getAssociateDegrees();
|
|
|
+ List<HashMap> degreeMapList = new ArrayList<>();
|
|
|
+ if (associateDegrees != null) {
|
|
|
+ String[] split = associateDegrees.split("\\,");
|
|
|
+ for (int i=0;i<split.length; i++) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ if (!StringUtils.isEmpty(split[i])) {
|
|
|
+ Integer id = Integer.parseInt(split[i]);
|
|
|
+ map.put("id", id);
|
|
|
+ map.put("name", degreeList.stream().filter(d->d.getId().equals(id)).findFirst().get().getName());
|
|
|
+ degreeMapList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ r.setDegreeList(degreeMapList);
|
|
|
+ } else {
|
|
|
+ //把degreeList改成HashMap结构
|
|
|
+ List<HashMap> mapDegreeList = new ArrayList<>();
|
|
|
+ for (ReportExtraDegree degree : degreeList) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("id", degree.getId());
|
|
|
+ map.put("name", degree.getName());
|
|
|
+ mapDegreeList.add(map);
|
|
|
+ }
|
|
|
+ r.setDegreeList(mapDegreeList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
- List<TaskGroup> taskGroups = taskGroupMapper.selectList(taskGroupQueryWrapper);
|
|
|
- //获取负责人的用户集合
|
|
|
- List<String> inchargerIds = taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList());
|
|
|
- if (inchargerIds.size() == 0) {
|
|
|
- inchargerIds.add("-1");
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", inchargerIds));
|
|
|
- reportList.forEach(r->{
|
|
|
- r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
+ //241226 当日期为 25-01-27 周一 时,去掉列表
|
|
|
+ if(firstDayOfWeek.isEqual(specialDate)){
|
|
|
+ dateList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ reportMap.put("dateList", dateList);
|
|
|
+ //查询考勤请假状态
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (wxCorpInfo != null && dateList.size() > 0) {
|
|
|
+ List<UserCorpwxTime> userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList.stream().map(r -> (String) r.get("date")).collect(Collectors.toList())));
|
|
|
+ for (HashMap item : dateList) {
|
|
|
+ String curDate = (String) item.get("date");
|
|
|
+ UserCorpwxTime userCorpwxTime = userCorpwxTimeList.stream().filter(r -> r.getCreateDate().isEqual(LocalDate.parse(curDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))).findFirst().orElse(null);
|
|
|
+ if (userCorpwxTime != null) {
|
|
|
+ item.put("time", userCorpwxTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reportMap.put("summary", summary);
|
|
|
+ reportMap.put("weeklyAttachment", attachment);
|
|
|
+ } else {
|
|
|
+ reportMap.put("dateList", new ArrayList());
|
|
|
+ }
|
|
|
+
|
|
|
+ msg.data = reportMap;
|
|
|
+ return msg;
|
|
|
+ } else {
|
|
|
+ //根据targetDate获取本周的日期
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate date = LocalDate.parse(targetDate, dtf);
|
|
|
+ LocalDate firstDayOfWeek = date.with(DayOfWeek.MONDAY);
|
|
|
+ //需要填报的最后一天
|
|
|
+ LocalDate lastDayOfWeek = date.with(DayOfWeek.SUNDAY);
|
|
|
+
|
|
|
+ //再按照当前用户的入职离职日期进行过滤
|
|
|
+ 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, Object> reportMap = new HashMap<>();
|
|
|
+ if (needFill) {
|
|
|
+ String summary = null;
|
|
|
+ String attachment = null;
|
|
|
+ String startDate = firstDayOfWeek.format(dtf);
|
|
|
+ String endDate = lastDayOfWeek.format(dtf);
|
|
|
+ //获取日报详情
|
|
|
+ List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("creator_id", userId).between("create_date", startDate, endDate).orderByAsc("create_date"));
|
|
|
+ //已填日报设置审核人姓名
|
|
|
+ if (reportList.size() > 0) {
|
|
|
+ Integer batchId = reportList.get(0).getBatchId();
|
|
|
+ if (batchId != null) {
|
|
|
+ //获取周总结
|
|
|
+ ReportBatch batch = reportBatchMapper.selectById(batchId);
|
|
|
+ //老数据可能出现batchId错误的情况,已经被删掉了,就不处理了。
|
|
|
+ if (batch != null) {
|
|
|
+ summary = batch.getSummary();
|
|
|
+ attachment = batch.getAttachment();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> collect = reportList.stream().map(Report::getProjectAuditorId).distinct().collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<User> auditorUserList = userMapper.selectList(new QueryWrapper<User>().in("id", collect));
|
|
|
+ reportList.forEach(r->{
|
|
|
+ if (r.getProjectAuditorId() != null) {
|
|
|
+ Optional<User> first = auditorUserList.stream().filter(au -> au.getId().equals(r.getProjectAuditorId())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ r.setProjectAuditorName(first.get().getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<Integer> collect = reportList.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
+ final List<ReportExtraDegree> degreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", user.getCompanyId()));
|
|
|
+
|
|
|
+ //加载这段时间内已填报过的项目
|
|
|
+ List<Project> projectList = new ArrayList<>();
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
|
|
|
+ final List<Project> finalProjectList = projectList;
|
|
|
+ //获取项目的任务分组列表
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<TaskGroup> taskGroupQueryWrapper = new QueryWrapper<TaskGroup>().in("project_id", collect);
|
|
|
+ if (timeType.getReportAuditType() == 1) {//分组负责人审核模式,需要按参与的任务分组显示
|
|
|
+ //需要是他参与的任务分组
|
|
|
+ List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>().eq("user_id", userId));
|
|
|
+ List<Integer> joinGroupList = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
|
|
|
+ if (joinGroupList.size() > 0) {
|
|
|
+ taskGroupQueryWrapper.in("id", joinGroupList);
|
|
|
+ } else {
|
|
|
+ taskGroupQueryWrapper.eq("id", -1);//没有分组
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TaskGroup> taskGroups = taskGroupMapper.selectList(taskGroupQueryWrapper);
|
|
|
+ //获取负责人的用户集合
|
|
|
+ List<String> inchargerIds = taskGroups.stream().map(TaskGroup::getInchargerId).collect(Collectors.toList());
|
|
|
+ if (inchargerIds.size() == 0) {
|
|
|
+ inchargerIds.add("-1");
|
|
|
+ }
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", inchargerIds));
|
|
|
+ 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)) {
|
|
|
@@ -10202,96 +10406,96 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
- //设置项目名称
|
|
|
- Optional<Project> optional = finalProjectList.stream().filter(p->p.getId().equals(r.getProjectId())).findFirst();
|
|
|
- if (optional.isPresent()) {
|
|
|
- r.setProjectName(optional.get().getProjectName());
|
|
|
- }
|
|
|
- //设置自定义维度
|
|
|
- if (timeType.getCustomDegreeActive() == 1) {
|
|
|
- if (timeType.getCustomDegreeWithPro() == 1) {
|
|
|
- String associateDegrees = optional.get().getAssociateDegrees();
|
|
|
- List<HashMap> degreeMapList = new ArrayList<>();
|
|
|
- if (associateDegrees != null) {
|
|
|
- String[] split = associateDegrees.split("\\,");
|
|
|
- for (int i=0;i<split.length; i++) {
|
|
|
- HashMap map = new HashMap();
|
|
|
- if (!StringUtils.isEmpty(split[i])) {
|
|
|
- Integer id = Integer.parseInt(split[i]);
|
|
|
- map.put("id", id);
|
|
|
- map.put("name", degreeList.stream().filter(d->d.getId().equals(id)).findFirst().get().getName());
|
|
|
- degreeMapList.add(map);
|
|
|
+ //设置项目名称
|
|
|
+ Optional<Project> optional = finalProjectList.stream().filter(p->p.getId().equals(r.getProjectId())).findFirst();
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ r.setProjectName(optional.get().getProjectName());
|
|
|
+ }
|
|
|
+ //设置自定义维度
|
|
|
+ if (timeType.getCustomDegreeActive() == 1) {
|
|
|
+ if (timeType.getCustomDegreeWithPro() == 1) {
|
|
|
+ String associateDegrees = optional.get().getAssociateDegrees();
|
|
|
+ List<HashMap> degreeMapList = new ArrayList<>();
|
|
|
+ if (associateDegrees != null) {
|
|
|
+ String[] split = associateDegrees.split("\\,");
|
|
|
+ for (int i=0;i<split.length; i++) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ if (!StringUtils.isEmpty(split[i])) {
|
|
|
+ Integer id = Integer.parseInt(split[i]);
|
|
|
+ map.put("id", id);
|
|
|
+ map.put("name", degreeList.stream().filter(d->d.getId().equals(id)).findFirst().get().getName());
|
|
|
+ degreeMapList.add(map);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ r.setDegreeList(degreeMapList);
|
|
|
+ } else {
|
|
|
+ //把degreeList改成HashMap结构
|
|
|
+ List<HashMap> mapDegreeList = new ArrayList<>();
|
|
|
+ for (ReportExtraDegree degree : degreeList) {
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("id", degree.getId());
|
|
|
+ map.put("name", degree.getName());
|
|
|
+ mapDegreeList.add(map);
|
|
|
+ }
|
|
|
+ r.setDegreeList(mapDegreeList);
|
|
|
}
|
|
|
- r.setDegreeList(degreeMapList);
|
|
|
- } else {
|
|
|
- //把degreeList改成HashMap结构
|
|
|
- List<HashMap> mapDegreeList = new ArrayList<>();
|
|
|
- for (ReportExtraDegree degree : degreeList) {
|
|
|
- HashMap map = new HashMap();
|
|
|
- map.put("id", degree.getId());
|
|
|
- map.put("name", degree.getName());
|
|
|
- mapDegreeList.add(map);
|
|
|
- }
|
|
|
- r.setDegreeList(mapDegreeList);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- reportMap.put("projectList", projectList);
|
|
|
- //计算日期,进行返回
|
|
|
- List<HashMap> dateList = new ArrayList<>();
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- LocalDate itemDate = firstDayOfWeek;
|
|
|
- while(true) {
|
|
|
- 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("projectList", projectList);
|
|
|
+ //计算日期,进行返回
|
|
|
+ List<HashMap> dateList = new ArrayList<>();
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate itemDate = firstDayOfWeek;
|
|
|
+ while(true) {
|
|
|
+ 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);
|
|
|
- //查询考勤请假状态
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- if (wxCorpInfo != null && dateList.size() > 0) {
|
|
|
- List<UserCorpwxTime> userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList.stream().map(r -> (String) r.get("date")).collect(Collectors.toList())));
|
|
|
- for (HashMap item : dateList) {
|
|
|
- String curDate = (String) item.get("date");
|
|
|
- UserCorpwxTime userCorpwxTime = userCorpwxTimeList.stream().filter(r -> r.getCreateDate().isEqual(LocalDate.parse(curDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))).findFirst().orElse(null);
|
|
|
- if (userCorpwxTime != null) {
|
|
|
- item.put("time", userCorpwxTime);
|
|
|
+ reportMap.put("dateList", dateList);
|
|
|
+ //查询考勤请假状态
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (wxCorpInfo != null && dateList.size() > 0) {
|
|
|
+ List<UserCorpwxTime> userCorpwxTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).in("create_date", dateList.stream().map(r -> (String) r.get("date")).collect(Collectors.toList())));
|
|
|
+ for (HashMap item : dateList) {
|
|
|
+ String curDate = (String) item.get("date");
|
|
|
+ UserCorpwxTime userCorpwxTime = userCorpwxTimeList.stream().filter(r -> r.getCreateDate().isEqual(LocalDate.parse(curDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")))).findFirst().orElse(null);
|
|
|
+ if (userCorpwxTime != null) {
|
|
|
+ item.put("time", userCorpwxTime);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ reportMap.put("summary", summary);
|
|
|
+ reportMap.put("weeklyAttachment", attachment);
|
|
|
+ } else {
|
|
|
+ reportMap.put("dateList", new ArrayList());
|
|
|
}
|
|
|
- reportMap.put("summary", summary);
|
|
|
- reportMap.put("weeklyAttachment", attachment);
|
|
|
- } else {
|
|
|
- reportMap.put("dateList", new ArrayList());
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
- msg.data = reportMap;
|
|
|
- return msg;
|
|
|
+ msg.data = reportMap;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -14551,7 +14755,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) {
|
|
|
@@ -14992,6 +15195,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
titles.add("是否为异常申报");
|
|
|
titles.add("日报汇报日期");
|
|
|
titles.add("填写人");
|
|
|
+ titles.add("填报时间");
|
|
|
titles.add("当日考勤记录");
|
|
|
titles.add("当日加班申请");
|
|
|
|
|
|
@@ -15031,7 +15235,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
} else {
|
|
|
item.add((String) map.get("userName"));
|
|
|
}
|
|
|
-
|
|
|
+ item.add((String) map.get("createTime"));
|
|
|
//考勤
|
|
|
item.add(map.get("cardRecord") != null ? (String) map.get("cardRecord") : "");
|
|
|
|