Browse Source

修改费用报销导入 工时导入

yurk 2 years ago
parent
commit
2a500615da

+ 14 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -63,6 +63,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     private SysFunctionMapper sysFunctionMapper;
     @Resource
     private ExpenseTypeMapper expenseTypeMapper;
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
     @Override
     public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -217,6 +219,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     public HttpRespMsg importData(HttpServletRequest request,MultipartFile[] files) {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         //然后处理文件
         for (MultipartFile multipartFile : files) {
             String fileName = multipartFile.getOriginalFilename();
@@ -294,12 +297,21 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 LocalDate localDate = Instant.ofEpochMilli(reportDateCell.getDateCellValue().getTime())
                         .atZone(ZoneId.systemDefault()).toLocalDate();
                 expenseSheet.setCreateDate(localDate);
-                Optional<User> first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())).findFirst();
+                Optional<User> first;
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())).findFirst();
+                }else {
+                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())||(us.getJobNumber()!=null&&us.getJobNumber().equals(reimburserCell.getStringCellValue()))).findFirst();
+                }
                 if (first.isPresent()) {
                     expenseSheet.setOwnerId(first.get().getId());
                     expenseSheet.setOwnerName(first.get().getName());
                 } else {
-                    throw new Exception("报销人[" +reimburserCell+"]不存在");
+                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                        throw new Exception("报销人[" +reimburserCell+"]不存在");
+                    }else {
+                        throw new Exception("报销人/工号[" +reimburserCell+"]不存在");
+                    }
                 }
                 expenseSheet.setOperatorId(user.getId());
                 expenseSheet.setRemark(remarksCell.getStringCellValue());

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

@@ -3219,12 +3219,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Optional<User> first;
                             Integer exception=null;
                             if(split.length==1){
-                                if(wxCorpInfo.getSaasSyncContact()!=1){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                     first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                                 }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                                 exception=0;
                             }else {
-                                if(wxCorpInfo.getSaasSyncContact()!=1){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                     first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                     exception=1;
                                 }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -3234,7 +3234,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 project.setInchargerName(first.get().getName());
                             } else {
                                 switch (exception){
-                                    case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"项目负责人工号为["+split[0]+"]的人员不存在":"项目负责人姓名/工号为["+split[0]+"]的人员不存在");
+                                    case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"项目负责人工号为["+split[0]+"]的人员不存在":"项目负责人姓名/工号为["+split[0]+"]的人员不存在");
                                     case 1:throw new Exception("项目负责人["+split[0]+"]姓名与工号不匹配");
                                 }
                             }
@@ -3315,12 +3315,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         Optional<User> first;
                         Integer exception=null;
                         if(split.length==1){
-                            if(wxCorpInfo.getSaasSyncContact()!=1){
+                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                 first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                             }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                             exception=0;
                         }else {
-                            if(wxCorpInfo.getSaasSyncContact()!=1){
+                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                 first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                 exception=1;
                             }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -3332,7 +3332,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             participationList.add(p);
                         } else {
                             switch (exception){
-                                case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
+                                case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
                                 case 1:throw new Exception("参与人["+split[0]+"]姓名与工号不匹配");
                             }
                         }
@@ -3355,12 +3355,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Optional<User> first;
                                 Integer exception=null;
                                 if(split.length==1){
-                                    if(wxCorpInfo.getSaasSyncContact()!=1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                         first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                                     }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                                     exception=0;
                                 }else {
-                                    if(wxCorpInfo.getSaasSyncContact()!=1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                         first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                         exception=1;
                                     }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -3375,7 +3375,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                     }
                                 } else {
                                     switch (exception){
-                                        case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
+                                        case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
                                         case 1:throw new Exception("参与人["+split[0]+"]姓名与工号不匹配");
                                     }
                                 }
@@ -3730,12 +3730,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Optional<User> first;
                             Integer exception=null;
                             if(split.length==1){
-                                if(wxCorpInfo.getSaasSyncContact()!=1){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                     first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                                 }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                                 exception=0;
                             }else {
-                                if(wxCorpInfo.getSaasSyncContact()!=1){
+                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                     first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                     exception=1;
                                 }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -3745,7 +3745,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 project.setInchargerName(first.get().getName());
                             } else {
                                 switch (exception){
-                                    case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"项目负责人工号为["+split[0]+"]的人员不存在":"项目负责人姓名/工号为["+split[0]+"]的人员不存在");
+                                    case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"项目负责人工号为["+split[0]+"]的人员不存在":"项目负责人姓名/工号为["+split[0]+"]的人员不存在");
                                     case 1:throw new Exception("项目负责人["+split[0]+"]姓名与工号不匹配");
                                 }
                             }
@@ -4306,12 +4306,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         Optional<User> first;
                         Integer exception=null;
                         if(split.length==1){
-                            if(wxCorpInfo.getSaasSyncContact()!=1){
+                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                 first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                             }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                             exception=0;
                         }else {
-                            if(wxCorpInfo.getSaasSyncContact()!=1){
+                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                 first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                 exception=1;
                             }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -4323,7 +4323,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             participationList.add(p);
                         } else {
                             switch (exception){
-                                case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
+                                case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
                                 case 1:throw new Exception("参与人["+split[0]+"]姓名与工号不匹配");
                             }
                         }
@@ -4345,12 +4345,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Optional<User> first;
                                 Integer exception=null;
                                 if(split.length==1){
-                                    if(wxCorpInfo.getSaasSyncContact()!=1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                         first= userList.stream().filter(u -> u.getName().equals(split[0])||(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();
                                     }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
                                     exception=0;
                                 }else {
-                                    if(wxCorpInfo.getSaasSyncContact()!=1){
+                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
                                         first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
                                         exception=1;
                                     }else first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
@@ -4366,7 +4366,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                     }
                                 } else {
                                     switch (exception){
-                                        case 0:throw new Exception(wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
+                                        case 0:throw new Exception(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1?"参与人工号为["+split[0]+"]的人员不存在":"参与人姓名/工号为["+split[0]+"]的人员不存在");
                                         case 1:throw new Exception("参与人["+split[0]+"]姓名与工号不匹配");
                                     }
                                 }

+ 12 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -3402,6 +3402,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         HttpRespMsg msg = new HttpRespMsg();
         String token = request.getHeader("TOKEN");
         User user = userMapper.selectById(token);
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         //对于存在预算成本的公司,暂不支持导入工时
         Company company = companyMapper.selectById(companyId);
@@ -3522,10 +3523,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                     String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
                     //检查人员是否存在
-                    Optional<User> any = allUserList.stream().filter(u -> u.getName().equals(username)).findAny();
+                    Optional<User> any;
+                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                        any = allUserList.stream().filter(u -> u.getName().equals(username)).findAny();
+                    }else {
+                        any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))).findAny();
+                    }
                     if (!any.isPresent()) {
                         //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
-                        msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
+                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                            msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
+                        }else {
+                            msg.setError(MessageUtils.message("staff.peopleNullAndAddPlus",username));
+                        }
                         return msg;
                     }
                     User reportCreator = any.get();

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages.properties

@@ -350,6 +350,7 @@ role.deleteErrorByHavePeople=该角色存在相关人员,请将他们修改为
 #员工相关
 staff.nameNullByRow=第"{0}"行缺少员工姓名
 staff.peopleNullAndAdd=人员["{0}"]不存在,请先在组织结构中添加或者通过钉钉同步导入
+staff.peopleNullAndAddPlus=人员/工号["{0}"]不存在,请先在组织结构中添加或者通过钉钉同步导入
 staff.proportionError=人员["{0}"]"+"分摊比例不满足100%,当前比例["{1}"%],请检查
 staff.workingHoursNull=工号为"{0}"的员工在工时系统中不存在
 staff.deleteErrorByDaily=该员工存在填写的日报,无法删除。

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages_en_US.properties

@@ -350,6 +350,7 @@ role.deleteErrorByHavePeople=There are related persons in this role. Please modi
 #员工相关
 staff.nameNullByRow=Employee name is missing in row "{0}".
 staff.peopleNullAndAdd=The person ["{0}"] does not exist. Please add it in the organization structure first or import it synchronously through Ding Talk.
+staff.peopleNullAndAddPlus=The person/jobNumber ["{0}"] does not exist. Please add it in the organization structure first or import it synchronously through Ding Talk.
 staff.proportionError=The personnel ["{0}"] "+" allocation proportion does not meet 100%. The current proportion ["{1}"%], please check.
 staff.workingHoursNull=The employee with job number "{0}" does not exist in the work hour system.
 staff.deleteErrorByDaily=The employee has daily reports filled in and cannot be deleted.