Browse Source

企业微信考勤同步修改
项目导入针对审核类型增加日报审核人

yurk 2 years ago
parent
commit
1114928666

+ 9 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -713,10 +713,16 @@ public class ProjectController {
         heads.add(MessageUtils.message("entry.Participants"));
         heads.add(MessageUtils.message("entry.Participants"));
         //heads.add("项目经理");
         //heads.add("项目经理");
         heads.add(MessageUtils.message("entry.projectManager"));
         heads.add(MessageUtils.message("entry.projectManager"));
+        if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4){
+            heads.add("日报审核人");
+        }
         //heads.add("级别");
         //heads.add("级别");
         heads.add(MessageUtils.message("entry.level"));
         heads.add(MessageUtils.message("entry.level"));
         exampleDataList.add("张三");
         exampleDataList.add("张三");
         exampleDataList.add("张三");
         exampleDataList.add("张三");
+        if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4){
+            exampleDataList.add("张三");
+        }
         exampleDataList.add("");
         exampleDataList.add("");
         if(timeType.getProjectWithDept()==1){
         if(timeType.getProjectWithDept()==1){
             //heads.add("所属部门");
             //heads.add("所属部门");
@@ -966,14 +972,13 @@ public class ProjectController {
                                     comment.setString(new HSSFRichTextString(MessageUtils.message("excel.manyPeople")));
                                     comment.setString(new HSSFRichTextString(MessageUtils.message("excel.manyPeople")));
                                     cell.setCellComment(comment);
                                     cell.setCellComment(comment);
                                     break;
                                     break;
-                                /*case "项目经理":
-                                case "project manager":
+                                case "日报审核人":
                                     comment = drawing.createCellComment(anchor);
                                     comment = drawing.createCellComment(anchor);
                                     // 输入批注信息
                                     // 输入批注信息
                                     //comment.setString(new HSSFRichTextString("项目经理需存在于参与人中"));
                                     //comment.setString(new HSSFRichTextString("项目经理需存在于参与人中"));
-                                    comment.setString(new HSSFRichTextString(MessageUtils.message("excel.projectManager")));
+                                    comment.setString(new HSSFRichTextString("多个审核人使用中文逗号(,)隔开"));
                                     cell.setCellComment(comment);
                                     cell.setCellComment(comment);
-                                    break;*/
+                                    break;
                                 case "开始日期":
                                 case "开始日期":
                                 case "Start Date":
                                 case "Start Date":
                                 case "截止日期":
                                 case "截止日期":

+ 210 - 68
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -3250,10 +3250,16 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     XSSFCell subNameCell = row.getCell(4);
                     XSSFCell subNameCell = row.getCell(4);
                     XSSFCell participatorCell = row.getCell(5);
                     XSSFCell participatorCell = row.getCell(5);
                     XSSFCell inchargerCell = row.getCell(6);
                     XSSFCell inchargerCell = row.getCell(6);
-                    XSSFCell levelCell = row.getCell(7);
-                    XSSFCell startDateCell = row.getCell(8);
-                    XSSFCell endDateCell = row.getCell(9);
-                    XSSFCell amountCell = row.getCell(10);
+                    XSSFCell reportAuditorsCell=null;
+                    int i=0;
+                    if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4){
+                        i++;
+                        reportAuditorsCell = row.getCell(6+i);
+                    }
+                    XSSFCell levelCell = row.getCell(7+i);
+                    XSSFCell startDateCell = row.getCell(8+i);
+                    XSSFCell endDateCell = row.getCell(9+i);
+                    XSSFCell amountCell = row.getCell(10+i);
 
 
 
 
                     if (codeCell != null)codeCell.setCellType(CellType.STRING);
                     if (codeCell != null)codeCell.setCellType(CellType.STRING);
@@ -3263,6 +3269,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     if (subNameCell != null)subNameCell.setCellType(CellType.STRING);
                     if (subNameCell != null)subNameCell.setCellType(CellType.STRING);
                     if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
                     if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
                     if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
                     if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
+                    if (reportAuditorsCell != null)reportAuditorsCell.setCellType(CellType.STRING);
                     if (levelCell != null)levelCell.setCellType(CellType.STRING);
                     if (levelCell != null)levelCell.setCellType(CellType.STRING);
                     if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
                     if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
                     if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
                     if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
@@ -3434,9 +3441,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     }
                     }
                     //导入项目参与人,遵守只增不减的原则, 避免误删
                     //导入项目参与人,遵守只增不减的原则, 避免误删
                     List<Participation> oldPartList = new ArrayList<>();
                     List<Participation> oldPartList = new ArrayList<>();
+                    List<ProjectAuditor> oldAuditorList = new ArrayList<>();
                     if (exists) {
                     if (exists) {
                         //更新的项目,检查已经存在的项目参与人
                         //更新的项目,检查已经存在的项目参与人
                         oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
                         oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
+                        oldAuditorList = projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().eq("project_id", project.getId()));
                     }
                     }
                     List<Participation> participationList = new ArrayList<>();
                     List<Participation> participationList = new ArrayList<>();
                     if(inchargerCell!=null){
                     if(inchargerCell!=null){
@@ -3547,6 +3556,67 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             participationService.saveBatch(addPartList);
                             participationService.saveBatch(addPartList);
                         }
                         }
                     }
                     }
+                    List<ProjectAuditor> projectAuditorList = new ArrayList<>();
+                    if (reportAuditorsCell != null) {
+                        String part = reportAuditorsCell.getStringCellValue().trim();
+                        if (!StringUtils.isEmpty(part)) {
+                            String[] partSplit = part.split("\\,|\\,");
+                            for (String str : partSplit) {
+                                ProjectAuditor projectAuditor = new ProjectAuditor();
+                                String s1;
+                                if(str.startsWith("/")){
+                                    s1=str.substring(1,str.length());
+                                }else s1=str;
+                                String s2;
+                                if(s1.endsWith("/")){
+                                    s2=s1.substring(0,s1.length()-1);
+                                }else s2=s1;
+                                String[] split = str.split("/");
+                                Optional<User> first;
+                                Integer exception=null;
+                                if(split.length==1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                        Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
+                                        first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
+                                    }else {
+                                        first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
+                                    }
+                                    exception=0;
+                                }else {
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                        Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
+                                        first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
+                                        exception=1;
+                                    }else {
+                                        first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                    }
+                                }
+                                if (first.isPresent()) {
+                                    User partMemb = first.get();
+//                                    System.out.println("参与人:"+partMemb.getName());
+                                    if (!projectAuditorList.stream().anyMatch(partOne->partOne.getAuditorId().equals(partMemb.getId()))) {
+                                        projectAuditor.setAuditorId(partMemb.getId());
+                                        projectAuditor.setAuditorName(partMemb.getName());
+                                        projectAuditor.setProjectId(project.getId());
+                                        projectAuditorList.add(projectAuditor);
+                                    }
+                                } else {
+                                    switch (exception){
+                                        case 0:throw new Exception("["+split[0]+"]在系统中不存在");
+                                        case 1:throw new Exception("["+split[0]+"]在系统中不存在");
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if (projectAuditorList.size() > 0) {
+                        //批量保存
+                        List<ProjectAuditor> finalOldAuditorList = oldAuditorList;
+                        List<ProjectAuditor> addAuditorList = projectAuditorList.stream().filter(newP-> !finalOldAuditorList.stream().anyMatch(oldP->oldP.getAuditorId().equals(newP.getAuditorId()))).collect(Collectors.toList());
+                        if (addAuditorList.size() > 0) {
+                            projectAuditorService.saveBatch(addAuditorList);
+                        }
+                    }
                 }
                 }
                 //msg.data = "成功导入"+importCount+"条数据。";
                 //msg.data = "成功导入"+importCount+"条数据。";
                 msg.data = MessageUtils.message("data.importSucRow",importCount);
                 msg.data = MessageUtils.message("data.importSucRow",importCount);
@@ -3686,6 +3756,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     HSSFCell nameCell=null;
                     HSSFCell nameCell=null;
                     HSSFCell participatorCell=null;
                     HSSFCell participatorCell=null;
                     HSSFCell inchargerCell=null;
                     HSSFCell inchargerCell=null;
+                    HSSFCell reportAuditorsCell=null;
                     HSSFCell levelCell=null;
                     HSSFCell levelCell=null;
                     HSSFCell deptCell=null;
                     HSSFCell deptCell=null;
                     HSSFCell customerCell=null;
                     HSSFCell customerCell=null;
@@ -3723,6 +3794,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     int k=0;
                     int k=0;
                     int c=0;
                     int c=0;
                     int d=0;
                     int d=0;
+                    int e=0;
                     if(timeType.getMainProjectState()==1){
                     if(timeType.getMainProjectState()==1){
                         mainNameCell = row.getCell(0);
                         mainNameCell = row.getCell(0);
                         codeCell = row.getCell(1);
                         codeCell = row.getCell(1);
@@ -3734,13 +3806,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         nameCell = row.getCell(3+c);
                         nameCell = row.getCell(3+c);
                         participatorCell = row.getCell(4+c);
                         participatorCell = row.getCell(4+c);
                         inchargerCell = row.getCell(5+c);
                         inchargerCell = row.getCell(5+c);
-                        levelCell = row.getCell(6+c);
+                        if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4){
+                            e++;
+                            reportAuditorsCell=row.getCell(5+c+e);
+                        }
+                        levelCell = row.getCell(6+c+e);
                         if(timeType.getProjectWithDept()==1){
                         if(timeType.getProjectWithDept()==1){
-                            deptCell=row.getCell(7+c);
+                            deptCell=row.getCell(7+c+e);
                             d++;
                             d++;
                         }
                         }
                         if(company.getPackageCustomer()==1){
                         if(company.getPackageCustomer()==1){
-                            customerCell=row.getCell(7+c+d);
+                            customerCell=row.getCell(7+c+d+e);
                             i++;
                             i++;
                         }
                         }
                         if(company.getPackageProvider()==1){
                         if(company.getPackageProvider()==1){
@@ -3750,35 +3826,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        startDateCell = row.getCell(7+i+k+c+d);
-                        endDateCell = row.getCell(8+i+k+c+d);
-                        amountCell = row.getCell(9+i+k+c+d);
+                        startDateCell = row.getCell(7+i+k+c+d+e);
+                        endDateCell = row.getCell(8+i+k+c+d+e);
+                        amountCell = row.getCell(9+i+k+c+d+e);
                         if(company.getId()==936){
                         if(company.getId()==936){
-                            warrantyStartDateCell=row.getCell(10+i+k+c+d);
-                            warrantyEndDateCell=row.getCell(11+i+k+c+d);
-                            projectCategorySubCell=row.getCell(12+i+k+c+d);
-                            regionCell=row.getCell(13+i+k+c+d);
-                            buCell=row.getCell(14+i+k+c+d);
-                            stateCell=row.getCell(15+i+k+c+d);
-                            stageCell=row.getCell(16+i+k+c+d);
-                            plate1=row.getCell(17+i+k+c+d);
-                            plate2=row.getCell(18+i+k+c+d);
-                            plate3=row.getCell(19+i+k+c+d);
-                            plate4=row.getCell(20+i+k+c+d);
-                            plate5=row.getCell(21+i+k+c+d);
-                            plate6=row.getCell(22+i+k+c+d);
-                            plate7=row.getCell(23+i+k+c+d);
-                            plate8=row.getCell(24+i+k+c+d);
-                            plate9=row.getCell(25+i+k+c+d);
-                            plate10=row.getCell(26+i+k+c+d);
-                            plate11=row.getCell(27+i+k+c+d);
-                            plate12=row.getCell(28+i+k+c+d);
-                            plate13=row.getCell(29+i+k+c+d);
-                            plate14=row.getCell(30+i+k+c+d);
-                            plate15=row.getCell(31+i+k+c+d);
-                            plate16=row.getCell(32+i+k+c+d);
-                            plate17=row.getCell(33+i+k+c+d);
-                            plate18=row.getCell(34+i+k+c+d);
+                            warrantyStartDateCell=row.getCell(10+i+k+c+d+e);
+                            warrantyEndDateCell=row.getCell(11+i+k+c+d+e);
+                            projectCategorySubCell=row.getCell(12+i+k+c+d+e);
+                            regionCell=row.getCell(13+i+k+c+d+e);
+                            buCell=row.getCell(14+i+k+c+d+e);
+                            stateCell=row.getCell(15+i+k+c+d+e);
+                            stageCell=row.getCell(16+i+k+c+d+e);
+                            plate1=row.getCell(17+i+k+c+d+e);
+                            plate2=row.getCell(18+i+k+c+d+e);
+                            plate3=row.getCell(19+i+k+c+d+e);
+                            plate4=row.getCell(20+i+k+c+d+e);
+                            plate5=row.getCell(21+i+k+c+d+e);
+                            plate6=row.getCell(22+i+k+c+d+e);
+                            plate7=row.getCell(23+i+k+c+d+e);
+                            plate8=row.getCell(24+i+k+c+d+e);
+                            plate9=row.getCell(25+i+k+c+d+e);
+                            plate10=row.getCell(26+i+k+c+d+e);
+                            plate11=row.getCell(27+i+k+c+d+e);
+                            plate12=row.getCell(28+i+k+c+d+e);
+                            plate13=row.getCell(29+i+k+c+d+e);
+                            plate14=row.getCell(30+i+k+c+d+e);
+                            plate15=row.getCell(31+i+k+c+d+e);
+                            plate16=row.getCell(32+i+k+c+d+e);
+                            plate17=row.getCell(33+i+k+c+d+e);
+                            plate18=row.getCell(34+i+k+c+d+e);
                         }
                         }
                     }else {
                     }else {
                         codeCell = row.getCell(0);
                         codeCell = row.getCell(0);
@@ -3792,13 +3868,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         subNameCell = row.getCell(4+c);
                         subNameCell = row.getCell(4+c);
                         participatorCell = row.getCell(5+c);
                         participatorCell = row.getCell(5+c);
                         inchargerCell = row.getCell(6+c);
                         inchargerCell = row.getCell(6+c);
-                        levelCell = row.getCell(7+c);
+                        if(timeType.getReportAuditType()==0||timeType.getReportAuditType()==4){
+                            e++;
+                            reportAuditorsCell=row.getCell(6+c+e);
+                        }
+                        levelCell = row.getCell(7+c+e);
                         if(timeType.getProjectWithDept()==1){
                         if(timeType.getProjectWithDept()==1){
-                            deptCell=row.getCell(8+c);
+                            deptCell=row.getCell(8+c+e);
                             d++;
                             d++;
                         }
                         }
                         if(company.getPackageCustomer()==1){
                         if(company.getPackageCustomer()==1){
-                            customerCell=row.getCell(8+c+d);
+                            customerCell=row.getCell(8+c+d+e);
                             i++;
                             i++;
                         }
                         }
                         if(company.getPackageProvider()==1){
                         if(company.getPackageProvider()==1){
@@ -3808,35 +3888,35 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        startDateCell = row.getCell(8+i+k+c+d);
-                        endDateCell = row.getCell(9+i+k+c+d);
-                        amountCell = row.getCell(10+i+k+c+d);
+                        startDateCell = row.getCell(8+i+k+c+d+e);
+                        endDateCell = row.getCell(9+i+k+c+d+e);
+                        amountCell = row.getCell(10+i+k+c+d+e);
                         if(company.getId()==936){
                         if(company.getId()==936){
-                            warrantyStartDateCell=row.getCell(11+i+k+c+d);
-                            warrantyEndDateCell=row.getCell(12+i+k+c+d);
-                            projectCategorySubCell=row.getCell(13+i+k+c+d);
-                            regionCell=row.getCell(14+i+k+c+d);
-                            buCell=row.getCell(15+i+k+c+d);
-                            stateCell=row.getCell(16+i+k+c+d);
-                            stageCell=row.getCell(17+i+k+c+d);
-                            plate1=row.getCell(18+i+k+c+d);
-                            plate2=row.getCell(19+i+k+c+d);
-                            plate3=row.getCell(20+i+k+c+d);
-                            plate4=row.getCell(21+i+k+c+d);
-                            plate5=row.getCell(22+i+k+c+d);
-                            plate6=row.getCell(23+i+k+c+d);
-                            plate7=row.getCell(24+i+k+c+d);
-                            plate8=row.getCell(25+i+k+c+d);
-                            plate9=row.getCell(26+i+k+c+d);
-                            plate10=row.getCell(27+i+k+c+d);
-                            plate11=row.getCell(28+i+k+c+d);
-                            plate12=row.getCell(29+i+k+c+d);
-                            plate13=row.getCell(30+i+k+c+d);
-                            plate14=row.getCell(31+i+k+c+d);
-                            plate15=row.getCell(32+i+k+c+d);
-                            plate16=row.getCell(33+i+k+c+d);
-                            plate17=row.getCell(34+i+k+c+d);
-                            plate18=row.getCell(35+i+k+c+d);
+                            warrantyStartDateCell=row.getCell(11+i+k+c+d+e);
+                            warrantyEndDateCell=row.getCell(12+i+k+c+d+e);
+                            projectCategorySubCell=row.getCell(13+i+k+c+d+e);
+                            regionCell=row.getCell(14+i+k+c+d+e);
+                            buCell=row.getCell(15+i+k+c+d+e);
+                            stateCell=row.getCell(16+i+k+c+d+e);
+                            stageCell=row.getCell(17+i+k+c+d+e);
+                            plate1=row.getCell(18+i+k+c+d+e);
+                            plate2=row.getCell(19+i+k+c+d+e);
+                            plate3=row.getCell(20+i+k+c+d+e);
+                            plate4=row.getCell(21+i+k+c+d+e);
+                            plate5=row.getCell(22+i+k+c+d+e);
+                            plate6=row.getCell(23+i+k+c+d+e);
+                            plate7=row.getCell(24+i+k+c+d+e);
+                            plate8=row.getCell(25+i+k+c+d+e);
+                            plate9=row.getCell(26+i+k+c+d+e);
+                            plate10=row.getCell(27+i+k+c+d+e);
+                            plate11=row.getCell(28+i+k+c+d+e);
+                            plate12=row.getCell(29+i+k+c+d+e);
+                            plate13=row.getCell(30+i+k+c+d+e);
+                            plate14=row.getCell(31+i+k+c+d+e);
+                            plate15=row.getCell(32+i+k+c+d+e);
+                            plate16=row.getCell(33+i+k+c+d+e);
+                            plate17=row.getCell(34+i+k+c+d+e);
+                            plate18=row.getCell(35+i+k+c+d+e);
                         }
                         }
                     }
                     }
                     if (codeCell != null)codeCell.setCellType(CellType.STRING);
                     if (codeCell != null)codeCell.setCellType(CellType.STRING);
@@ -3847,6 +3927,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     if (mainNameCell != null)mainNameCell.setCellType(CellType.STRING);
                     if (mainNameCell != null)mainNameCell.setCellType(CellType.STRING);
                     if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
                     if (participatorCell != null)participatorCell.setCellType(CellType.STRING);
                     if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
                     if (inchargerCell != null)inchargerCell.setCellType(CellType.STRING);
+                    if (reportAuditorsCell != null)reportAuditorsCell.setCellType(CellType.STRING);
                     if (levelCell != null)levelCell.setCellType(CellType.STRING);
                     if (levelCell != null)levelCell.setCellType(CellType.STRING);
                     if (deptCell != null)deptCell.setCellType(CellType.STRING);
                     if (deptCell != null)deptCell.setCellType(CellType.STRING);
                     if (customerCell != null)customerCell.setCellType(CellType.STRING);
                     if (customerCell != null)customerCell.setCellType(CellType.STRING);
@@ -3965,8 +4046,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             }
                             }
                         }
                         }
                     }
                     }
-
-
                     if (levelCell != null) {
                     if (levelCell != null) {
                         String levelStr = levelCell.getStringCellValue();
                         String levelStr = levelCell.getStringCellValue();
                         if (!StringUtils.isEmpty(levelStr)) {
                         if (!StringUtils.isEmpty(levelStr)) {
@@ -4521,9 +4600,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     importCount++;
                     importCount++;
                     //导入项目参与人,遵守只增不减的原则, 避免误删
                     //导入项目参与人,遵守只增不减的原则, 避免误删
                     List<Participation> oldPartList = new ArrayList<>();
                     List<Participation> oldPartList = new ArrayList<>();
+                    List<ProjectAuditor> oldAuditorList = new ArrayList<>();
                     if (exists) {
                     if (exists) {
                         //更新的项目,检查已经存在的项目参与人
                         //更新的项目,检查已经存在的项目参与人
                         oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
                         oldPartList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
+                        oldAuditorList = projectAuditorMapper.selectList(new QueryWrapper<ProjectAuditor>().eq("project_id", project.getId()));
                         System.out.println("获取到已有项目参与人:"+oldPartList.size());
                         System.out.println("获取到已有项目参与人:"+oldPartList.size());
                     }
                     }
                     List<Participation> participationList = new ArrayList<>();
                     List<Participation> participationList = new ArrayList<>();
@@ -4628,6 +4709,67 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             participationService.saveBatch(addPartList);
                             participationService.saveBatch(addPartList);
                         }
                         }
                     }
                     }
+                    List<ProjectAuditor> projectAuditorList = new ArrayList<>();
+                    if (reportAuditorsCell != null) {
+                        String part = reportAuditorsCell.getStringCellValue().trim();
+                        if (!StringUtils.isEmpty(part)) {
+                            String[] partSplit = part.split("\\,|\\,");
+                            for (String str : partSplit) {
+                                String s1;
+                                if(str.startsWith("/")){
+                                    s1=str.substring(1,str.length());
+                                }else s1=str;
+                                String s2;
+                                if(s1.endsWith("/")){
+                                    s2=s1.substring(0,s1.length()-1);
+                                }else s2=s1;
+                                String[] split = s2.split("/");
+                                Optional<User> first;
+                                Integer exception=null;
+                                if(split.length==1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                        Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[0])).findFirst();
+                                        first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
+                                    }else {
+                                        first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
+                                    }
+                                    exception=0;
+                                }else {
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                                        Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(split[1])).findFirst();
+                                        first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
+                                        exception=1;
+                                    }else {
+                                        first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                    }
+                                }
+                                ProjectAuditor p = new ProjectAuditor();
+                                if (first.isPresent()) {
+                                    User partMemb = first.get();
+//                                    System.out.println("参与人:"+partMemb.getName());
+                                    if (!projectAuditorList.stream().anyMatch(partOne->partOne.getAuditorId().equals(partMemb.getId()))) {
+                                        p.setAuditorId(partMemb.getId());
+                                        p.setAuditorName(partMemb.getName());
+                                        p.setProjectId(project.getId());
+                                        projectAuditorList.add(p);
+                                    }
+                                } else {
+                                    switch (exception){
+                                        case 0:throw new Exception("["+split[0]+"]在系统中不存在");
+                                        case 1:throw new Exception("["+split[0]+"]在系统中不存在");
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if (projectAuditorList.size() > 0) {
+                        //批量保存
+                        List<ProjectAuditor> finalOldAuditorList = oldAuditorList;
+                        List<ProjectAuditor> addAuditorList = projectAuditorList.stream().filter(newP-> !finalOldAuditorList.stream().anyMatch(oldP->oldP.getAuditorId().equals(newP.getAuditorId()))).collect(Collectors.toList());
+                        if (addAuditorList.size() > 0) {
+                            projectAuditorService.saveBatch(addAuditorList);
+                        }
+                    }
                 }
                 }
                 //msg.data = "成功导入"+importCount+"条数据。";
                 //msg.data = "成功导入"+importCount+"条数据。";
                 msg.data = MessageUtils.message("data.importSucRow",importCount);
                 msg.data = MessageUtils.message("data.importSucRow",importCount);

+ 25 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -931,11 +931,31 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                             }
                             }
                         }
                         }
                     }
                     }
+                    String baseMorningStart="09:00";
+                    String baseMorningEnd="12:00";
+                    String baseAfternoonStart="13:00";
+                    String baseAfternoonEnd="18:00";
                     double restTime = 0.0;//小时为单位
                     double restTime = 0.0;//小时为单位
                     for (int k = 0; k < optionDatas.size(); k++) {
                     for (int k = 0; k < optionDatas.size(); k++) {
                         if(optionDatas.getJSONObject(k).get("userid").equals(objects[i])){
                         if(optionDatas.getJSONObject(k).get("userid").equals(objects[i])){
                             JSONObject group = optionDatas.getJSONObject(k).getJSONObject("group");
                             JSONObject group = optionDatas.getJSONObject(k).getJSONObject("group");
                             JSONArray workRules = group.getJSONArray("checkindate").getJSONObject(0).getJSONArray("checkintime");
                             JSONArray workRules = group.getJSONArray("checkindate").getJSONObject(0).getJSONArray("checkintime");
+                            //获取上下午的考勤打卡规则
+                            baseMorningStart = workRules.size() <= 1 ? "09:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("work_sec"));
+                            baseMorningEnd = workRules.size() <= 1 ? "12:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("off_work_sec"));
+                            baseAfternoonStart = workRules.size() <= 1 ? "13:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("work_sec"));
+                            baseAfternoonEnd = workRules.size() <= 1 ? "18:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("off_work_sec"));
+                            if (workRules.size() == 1) {
+                                baseMorningStart = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("work_sec"));
+                                baseMorningEnd = "12:00";
+                                baseAfternoonStart = "13:00";
+                                baseAfternoonEnd = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("off_work_sec"));
+                            } else {
+                                baseMorningStart = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("work_sec"));
+                                baseMorningEnd = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("off_work_sec"));
+                                baseAfternoonStart = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("work_sec"));
+                                baseAfternoonEnd = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("off_work_sec"));
+                            }
                             if (workRules.size() <= 1) {
                             if (workRules.size() <= 1) {
                                 restTime = 1.0;//一个小时午休
                                 restTime = 1.0;//一个小时午休
                             } else {
                             } else {
@@ -962,8 +982,11 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     userCorpwxTime.setWeekDay(date.getDayOfWeek().getValue());
                     userCorpwxTime.setWeekDay(date.getDayOfWeek().getValue());
                     userCorpwxTime.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(userCorpwxTime.getWeekDay()));
                     userCorpwxTime.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(userCorpwxTime.getWeekDay()));
                     BigDecimal bigDecimal=new BigDecimal(Duration.between(LocalTime.parse(minTime,df).plusHours(8),LocalTime.parse(maxTime,df).plusHours(8)).toMinutes());
                     BigDecimal bigDecimal=new BigDecimal(Duration.between(LocalTime.parse(minTime,df).plusHours(8),LocalTime.parse(maxTime,df).plusHours(8)).toMinutes());
-                    bigDecimal=bigDecimal.divide(BigDecimal.valueOf(60),0,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(restTime));
-                    double time = bigDecimal.doubleValue();
+                    if (LocalTime.parse(maxTime,df).plusHours(8).compareTo(LocalTime.parse(baseAfternoonStart,df)) >= 0) {
+                        //重新计算打卡工时时,需要减去中间午休时间
+                        bigDecimal=bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(restTime));
+                    }
+                    double time = bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP).doubleValue();
                     if (time < 0) {
                     if (time < 0) {
                         time = 0;
                         time = 0;
                     }
                     }

BIN
fhKeeper/formulahousekeeper/management-platform/src/main/resources/upload/项目导入模板.xlsx