Browse Source

获取按周填报数据

seyason 1 year ago
parent
commit
49f1a0aeae

+ 5 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java

@@ -409,6 +409,11 @@ public class Report extends Model<Report> {
     @TableField(exist = false)
     private List<SapProjectService> serviceList;
 
+    @TableField(exist = false)
+    private String projectName;
+    @TableField(exist = false)
+    private String taskName;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -165,4 +165,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> getTimeCostByToken(Integer companyId, String startDate, String endDate);
 
     List<UserCateTimeVo> getMembProjectCateTime(Integer companyId, String startDate, String endDate);
+
+    @Update("update project set incharger_id = null, finish_date = null, plan_start_date = null, plan_end_date=null, level=null,contract_amount=null,man_day=null,where id = #{id} and is_public = 1")
+    void cleanPublicProjectData(Integer id);
 }

+ 5 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -693,6 +693,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         User user = userMapper.selectById(request.getHeader("Token"));
         Integer companyId = user.getCompanyId();
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
+        Company company = companyMapper.selectById(companyId);
         boolean isNew = true;
         //检查负责人要在参与人中
         if (!StringUtils.isEmpty(inchargerId)) {
@@ -1252,6 +1253,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
                 }
             }
+            //针对启用了简单非项目模式的情况,确保项目经理,级别,合同金额,开始日期,截止日期,预估工时都是null
+            if (company.getNonProjectSimple() == 1 && isPublic == 1) {
+                projectMapper.cleanPublicProjectData(id);
+            }
         }
         return httpRespMsg;
     }

+ 83 - 32
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5476,33 +5476,37 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             if (company.getIsInternational() == 1) {
                                 operateDate = operateDate.plusSeconds(offsetSeconds);
                             }
+							
+								
                             String time = dtf.format(operateDate);
                             String msg= "";
-                            if(needCorpWxTranslate){
-                                Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(audit.getOperatorId())).findFirst();
-                                if(first.isPresent()){
-                                    String corpwxUserId = first.get().getCorpwxUserid();
-                                    if (auditMsg.contains(corpwxUserId)) {
-                                        if(auditMsg.contains("提交了")){
-                                            int i = auditMsg.indexOf("提");
-                                            String substring = auditMsg.substring(0, i);
-                                            msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
-                                        }else if(auditMsg.contains("审核通过了")){
-                                            int i = auditMsg.indexOf("审");
-                                            String substring = auditMsg.substring(0, i);
-                                            msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
-                                        }else if(auditMsg.contains("驳回了")) {
-                                            int i = auditMsg.indexOf("驳");
-                                            String substring = auditMsg.substring(0, i);
-                                            msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
-                                        }
-                                    } else {
-                                        msg = time+" " + auditMsg;
-                                    }
-                                }
-                            }else {
-                                msg = time+" " + auditMsg;
-                            }
+							if (auditMsg != null) {
+								if(needCorpWxTranslate){
+									Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(audit.getOperatorId())).findFirst();
+									if(first.isPresent()){
+										String corpwxUserId = first.get().getCorpwxUserid();
+										if (!StringUtils.isEmpty(corpwxUserId) && auditMsg.contains(corpwxUserId)) {
+											if(auditMsg.contains("提交了")){
+												int i = auditMsg.indexOf("提");
+												String substring = auditMsg.substring(0, i);
+												msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
+											}else if(auditMsg.contains("审核通过了")){
+												int i = auditMsg.indexOf("审");
+												String substring = auditMsg.substring(0, i);
+												msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
+											}else if(auditMsg.contains("驳回了")) {
+												int i = auditMsg.indexOf("驳");
+												String substring = auditMsg.substring(0, i);
+												msg = time+" " + auditMsg.replace(substring,"\\$userName="+corpwxUserId+"\\$");
+											}
+										} else {
+											msg = time+" " + auditMsg;
+										}
+									}
+								}else {
+									msg = time+" " + auditMsg;
+								}
+							} 
                             if (!isFirst) {
                                 sb.append("->");
                             } else {
@@ -7126,6 +7130,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         HttpRespMsg msg = new HttpRespMsg();
         String userId = request.getHeader("TOKEN");
         User user = userMapper.selectById(userId);
+        Company company = companyMapper.selectById(user.getCompanyId());
         //根据targetDate获取本周的日期
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate date = LocalDate.parse(targetDate, dtf);
@@ -7141,10 +7146,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         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<User> auditorList = new ArrayList<>();
         //加载这段时间内已填报过的项目
         List<Project> projectList = new ArrayList<>();
         if (collect.size() > 0) {
             projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", collect));
+            auditorList = userMapper.selectList(new QueryWrapper<User>().in("id", reportList.stream().map(Report::getProjectAuditorId).collect(Collectors.toList())));
         } else {
             //没有项目,默认加载最近填报过的项目
             List<Report> oldReport = reportMapper.selectList(new QueryWrapper<Report>().select("distinct project_id").eq("creator_id", userId).orderByDesc("id").last("limit 5"));
@@ -7152,13 +7159,57 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", oldReport.stream().map(Report::getProjectId).collect(Collectors.toList())));
             }
         }
-//
-//        List<TaskGroup> allGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", projectList.stream().map(Project::getId).collect(Collectors.toList())));
-//        //获取当前日报项目下的所有任务分组
-//        for (Report report : reportList) {
-//            Integer targetPid = report.getProjectId();
-//            report.setTaskGroups(allGroupList.stream().filter(tg->tg.getProjectId().equals(targetPid)).collect(Collectors.toList()));
-//        }
+        List<SapProjectService> sapProjectServices = new ArrayList<>();
+        if (company.getId() == 3092) {
+            sapProjectServices = sapProjectServiceMapper.selectList(new QueryWrapper<SapProjectService>().eq("company_id",company.getId()));
+        }
+        //专业版要取任务分组
+        List<TaskGroup> allGroupList = new ArrayList<>();
+        List<Task> taskList = new ArrayList<>();
+        if (projectList.size() > 0) {
+            if (company.getPackageProject() == 1) {
+                allGroupList = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>().in("project_id", projectList.stream().map(Project::getId).collect(Collectors.toList())));
+                taskList = taskMapper.selectList(new QueryWrapper<Task>().select("id, name").in("project_id", projectList.stream().map(Project::getId).collect(Collectors.toList())));
+            }
+            //获取当前日报项目下的所有任务分组
+            for (Report report : reportList) {
+                Integer targetPid = report.getProjectId();
+                if (company.getPackageProject() == 1) {
+                    report.setTaskGroups(allGroupList.stream().filter(tg->tg.getProjectId().equals(targetPid)).collect(Collectors.toList()));
+                    if (report.getGroupId() != null) {
+                        //设置已经填报的任务分组名称
+                        Optional<TaskGroup> optional = allGroupList.stream().filter(tg->tg.getId().equals(report.getGroupId())).findFirst();
+                        if (optional.isPresent()) {
+                            report.setGroupName(optional.get().getName());
+                        }
+                    }
+                    //任务名称设置
+                    if (report.getTaskId() != null) {
+                        Optional<Task> optional = taskList.stream().filter(t->t.getId().equals(report.getTaskId())).findFirst();
+                        if (optional.isPresent()) {
+                            report.setTaskName(optional.get().getName());
+                        }
+                    }
+                }
+                //设置项目名称
+                Optional<Project> optional = projectList.stream().filter(p->p.getId().equals(report.getProjectId())).findFirst();
+                if (optional.isPresent()) {
+                    report.setProjectName(optional.get().getProjectName());
+                }
+                //设置ProjectAuditorName
+                Optional<User> optionalUser = auditorList.stream().filter(u->u.getId().equals(report.getProjectAuditorId())).findFirst();
+                if (optionalUser.isPresent()) {
+                    report.setProjectAuditorName(optionalUser.get().getName());
+                }
+                if (company.getId() == 3092) {
+                    //依斯倍有SapServiceName
+                    Optional<SapProjectService> optionalSap = sapProjectServices.stream().filter(s->s.getId().equals(report.getSapServiceId())).findFirst();
+                    if (optionalSap.isPresent()) {
+                        report.setSapServiceName(optionalSap.get().getServiceName());
+                    }
+                }
+            }
+        }
 
         List cardTimeList = new ArrayList();
         if (timeType.getShowDdCardtime() == 1) {