Browse Source

修复项目导入负责人bug

QuYueTing 14 hours ago
parent
commit
923e222f18

+ 38 - 36
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -7614,43 +7614,45 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     List<Participation> participationList = new ArrayList<>();
                     if(inchargerCell!=null){
                         String value = inchargerCell.getStringCellValue();
-                        String s1;
-                        if(value.startsWith("/")){
-                            s1=value.substring(1,value.length());
-                        }else s1=value;
-                        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)||(dingding!=null&&dingding.getContactNeedTranslate()==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()))||(u.getDingdingUserid()!=null&&u.getDingdingUserid().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)||(dingding!=null&&dingding.getContactNeedTranslate()==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()))||(u.getDingdingUserid()!=null&&u.getDingdingUserid().equals(optional.get().getCorpwxUserid()))))).findFirst();
-                                exception=1;
+                        if (!StringUtils.isEmpty(value)) {
+                            String s1;
+                            if(value.startsWith("/")){
+                                s1=value.substring(1,value.length());
+                            }else s1=value;
+                            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)||(dingding!=null&&dingding.getContactNeedTranslate()==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()))||(u.getDingdingUserid()!=null&&u.getDingdingUserid().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 {
-                                first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                if((wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1)||(dingding!=null&&dingding.getContactNeedTranslate()==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()))||(u.getDingdingUserid()!=null&&u.getDingdingUserid().equals(optional.get().getCorpwxUserid()))))).findFirst();
+                                    exception=1;
+                                }else {
+                                    first= userList.stream().filter(u -> u.getName().equals(split[1])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                }
                             }
-                        }
-                        Participation p = new Participation();
-                        if (first.isPresent()) {
-                            p.setUserId(first.get().getId());
-                            p.setProjectId(project.getId());
-                            participationList.add(p);
-                        } else {
-                            switch (exception){
-                                case 0:throw new Exception("["+split[0]+"]在系统中不存在");
-                                case 1:throw new Exception("["+split[1]+"]在系统中不存在");
+                            Participation p = new Participation();
+                            if (first.isPresent()) {
+                                p.setUserId(first.get().getId());
+                                p.setProjectId(project.getId());
+                                participationList.add(p);
+                            } else {
+                                switch (exception){
+                                    case 0:throw new Exception("["+split[0]+"]在系统中不存在");
+                                    case 1:throw new Exception("["+split[1]+"]在系统中不存在");
+                                }
                             }
                         }
                     }
@@ -7886,7 +7888,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     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());
+                        List<ProjectAuditor> addAuditorList = projectAuditorList.stream().filter(newP-> !finalOldAuditorList.stream().anyMatch(oldP->oldP.getAuditorId()!=null&&oldP.getAuditorId().equals(newP.getAuditorId()))).collect(Collectors.toList());
                         if (addAuditorList.size() > 0) {
                             projectAuditorService.saveBatch(addAuditorList);
                         }