|
@@ -5872,4 +5872,147 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
return new HttpRespMsg();
|
|
return new HttpRespMsg();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getAIReport(String date, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ String userId = request.getHeader("token");
|
|
|
|
+ Integer companyId = userMapper.selectById(userId).getCompanyId();
|
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
|
+ //先判断用户是否填写过日报
|
|
|
|
+ QueryWrapper<Report> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("creator_id",userId).orderByDesc("id").last("limit 1");
|
|
|
|
+ Report report = reportMapper.selectOne(queryWrapper);
|
|
|
|
+ if (report != null) {
|
|
|
|
+ queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("creator_id", userId).eq("create_date", report.getCreateDate());
|
|
|
|
+ //获取最近填写的那一天的全部日报
|
|
|
|
+ List<Report> reports = reportMapper.selectList(queryWrapper);
|
|
|
|
+ List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>()
|
|
|
|
+ .eq("company_id", companyId).eq("status", 1));
|
|
|
|
+ //仅保留进行中的项目的日报
|
|
|
|
+ reports = reports.stream().filter(r->allProjectList.stream().anyMatch(p->p.getId().equals(r.getProjectId()))).collect(Collectors.toList());
|
|
|
|
+ try {
|
|
|
|
+ List<Integer> integerList = reports.stream().map(Report::getProjectId).collect(Collectors.toList());
|
|
|
|
+ //开启状态的子项目
|
|
|
|
+ List<SubProject> subProjects = subProjectMapper.selectList(new QueryWrapper<SubProject>().in("project_id", integerList).eq("status", 1));
|
|
|
|
+ List<SubProject> subProjectList = integerList.size() > 0?subProjects:new ArrayList<>();
|
|
|
|
+ List<ProjectAuditor> auditorList = integerList.size() > 0?projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().in("project_id", integerList)): new ArrayList<>();
|
|
|
|
+ List<Profession> professions = professionMapper.selectList(new QueryWrapper<Profession>().eq("company_id", companyId));
|
|
|
|
+ List<ReportExtraDegree> degreeList = reportExtraDegreeMapper.selectList(new QueryWrapper<ReportExtraDegree>().eq("company_id", companyId));
|
|
|
|
+ List<TaskGroup> taskGroups = integerList.size() > 0?taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", integerList)):new ArrayList<>();
|
|
|
|
+ List<Stages> stagesList = integerList.size() > 0?stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", integerList)) : new ArrayList<>();
|
|
|
|
+ //获取当前项目的子项目列表,任务分组,任务列表,项目相关维度列表
|
|
|
|
+ reports.forEach(r->{
|
|
|
|
+ r.setContent(null);
|
|
|
|
+ r.setSubProjectList(subProjectList.stream().filter(s->s.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
|
+ r.setTaskList(taskMapper.recentSimpleList(r.getProjectId(), userId));
|
|
|
|
+ //获取当前项目的工程专业进度
|
|
|
|
+ List<ReportProfessionProgress> progressList = reportProfessionProgressService.list(new QueryWrapper<ReportProfessionProgress>().eq("report_id", r.getId()));
|
|
|
|
+ //去掉当前项目上已经不存在的专业
|
|
|
|
+ List<ProjectProfession> projectProfessions = projectProfessionMapper.selectList(new QueryWrapper<ProjectProfession>().eq("project_id", r.getProjectId()));
|
|
|
|
+ progressList = progressList.stream().filter(p->projectProfessions.stream().anyMatch(pp->pp.getProfessionId().equals(p.getProfessionId()))).collect(Collectors.toList());
|
|
|
|
+ progressList.stream().forEach(p->{
|
|
|
|
+ p.setProfessionName(professions.stream().filter(m->m.getId().equals(p.getProfessionId())).findFirst().get().getName());
|
|
|
|
+ });
|
|
|
|
+ r.setProfessionProgressList(progressList);
|
|
|
|
+ //获取任务阶段列表
|
|
|
|
+ if (company.getPackageProject() == 1 && r.getGroupId() != null && r.getGroupId() != 0) {
|
|
|
|
+ r.setStages(stagesList.stream().filter(s->s.getGroupId() !=null && s.getGroupId().equals(r.getGroupId())).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //处理维度列表数据
|
|
|
|
+ if (timeTypeMapper.selectById(companyId).getCustomDegreeActive() == 1) {
|
|
|
|
+ Project project = allProjectList.stream().filter(p -> p.getId().equals(r.getProjectId())).findFirst().get();
|
|
|
|
+ String associateDegrees = project.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);
|
|
|
|
+ }
|
|
|
|
+ int reportAuditType = timeTypeMapper.selectById(companyId).getReportAuditType();
|
|
|
|
+ //分组
|
|
|
|
+ if (company.getPackageProject() == 1) {
|
|
|
|
+ if (reportAuditType == 0) {
|
|
|
|
+ r.setTaskGroups(taskGroups.stream().filter(tg->tg.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
|
+ if (r.getGroupId() != null && r.getGroupId() != 0) {
|
|
|
|
+ Optional<TaskGroup> optinal = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
|
|
|
|
+ if (optinal.isPresent()) {
|
|
|
|
+ r.setGroupName(optinal.get().getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (reportAuditType == 1 || reportAuditType == 2){
|
|
|
|
+ List<GroupParticipator> groupParticipatorList = groupParticipatorMapper.selectList(new QueryWrapper<GroupParticipator>());
|
|
|
|
+ if (groupParticipatorList.size() > 0) {
|
|
|
|
+ List<Integer> groupIds = groupParticipatorList.stream().map(GroupParticipator::getGroupId).collect(Collectors.toList());
|
|
|
|
+ List<TaskGroup> findGroups = taskGroups.stream().filter(tg->groupIds.contains(tg.getId()) || userId.equals(tg.getInchargerId())).collect(Collectors.toList());
|
|
|
|
+ r.setTaskGroups(findGroups);
|
|
|
|
+ if (r.getGroupId() != null && r.getGroupId() != 0) {
|
|
|
|
+ Optional<TaskGroup> optinal = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
|
|
|
|
+ if (optinal.isPresent()) {
|
|
|
|
+ r.setGroupName(optinal.get().getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //项目的审核人
|
|
|
|
+ if (reportAuditType == 0) {
|
|
|
|
+ r.setAuditUserList(auditorList.stream().filter(au->au.getProjectId().equals(r.getProjectId())).collect(Collectors.toList()));
|
|
|
|
+ if (r.getProjectAuditorId() != null) {
|
|
|
|
+ Optional<ProjectAuditor> auItem = auditorList.stream().filter(au->au.getAuditorId().equals(r.getProjectAuditorId())).findFirst();
|
|
|
|
+ if (auItem.isPresent()) {
|
|
|
|
+ r.setProjectAuditorName(auItem.get().getAuditorName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (reportAuditType == 1 || reportAuditType == 2) {
|
|
|
|
+ if (r.getGroupId() != null && r.getGroupId() != 0) {
|
|
|
|
+ //直接获取分组的负责人作为审核人
|
|
|
|
+ Optional<TaskGroup> tgoup = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
|
|
|
|
+ if (tgoup.isPresent()) {
|
|
|
|
+ TaskGroup curGroup = tgoup.get();
|
|
|
|
+ if (curGroup.getInchargerId() != null) {
|
|
|
|
+ User user = userMapper.selectById(curGroup.getInchargerId());
|
|
|
|
+ HashMap map = new HashMap();
|
|
|
|
+ map.put("auditorId", user.getId());
|
|
|
|
+ map.put("auditorName", user.getName());
|
|
|
|
+ List list = new ArrayList();
|
|
|
|
+ list.add(map);
|
|
|
|
+ r.setAuditUserList(list);
|
|
|
|
+ if (r.getProjectAuditorId() != null) {
|
|
|
|
+ r.setProjectAuditorName(user.selectById(r.getProjectAuditorId()).getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (reportAuditType == 3) {
|
|
|
|
+ //获取日报对应已经设置好的审核人和抄送人
|
|
|
|
+ r.setAuditorSetting(reportAuditorSettingMapper.selectById(r.getId()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ msg.data = reports;
|
|
|
|
+ } catch (NullPointerException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ //httpRespMsg.setError("验证失败");
|
|
|
|
+ msg.setError(MessageUtils.message("Company.validationError"));
|
|
|
|
+ return msg;
|
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
|
+ //httpRespMsg.setError("日期格式有误");
|
|
|
|
+ msg.setError(MessageUtils.message("date.formatError"));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|