Forráskód Böngészése

修改企业微信导出

yurk 2 éve
szülő
commit
928f33f412

+ 2 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -667,7 +667,6 @@ public class ProjectController {
         HttpRespMsg msg = new HttpRespMsg();
         List<String> heads = new ArrayList<>();
         Company company = companyMapper.selectById(companyId);
-        WxCorpInfo wxCorpInfo=wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",companyId));
         List<ProjectStage> projectStageList = projectStageMapper.selectList(new QueryWrapper<ProjectStage>().eq("company_id", company.getId()));
         List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
         List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
@@ -930,8 +929,7 @@ public class ProjectController {
                                 case "Participants":
                                     comment = drawing.createCellComment(anchor);
                                     // 输入批注信息
-                                    comment.setString(
-                                            wxCorpInfo.getSaasSyncContact()!=1? new HSSFRichTextString(MessageUtils.message("excel.manyPeople")):new HSSFRichTextString(MessageUtils.message("excel.manyPeoplePlus")));
+                                    comment.setString(new HSSFRichTextString(MessageUtils.message("excel.manyPeople")));
                                     cell.setCellComment(comment);
                                     break;
                                 case "项目经理":
@@ -939,8 +937,7 @@ public class ProjectController {
                                     comment = drawing.createCellComment(anchor);
                                     // 输入批注信息
                                     //comment.setString(new HSSFRichTextString("项目经理需存在于参与人中"));
-                                    comment.setString(
-                                            wxCorpInfo.getSaasSyncContact()!=1?new HSSFRichTextString(MessageUtils.message("excel.projectManager")):new HSSFRichTextString(MessageUtils.message("excel.projectManagerPlus")));
+                                    comment.setString(new HSSFRichTextString(MessageUtils.message("excel.projectManager")));
                                     cell.setCellComment(comment);
                                     break;
                                 case "开始日期":

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/WxCorpInfoService.java

@@ -7,8 +7,6 @@ import com.management.platform.entity.User;
 import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.util.HttpRespMsg;
 
-import javax.servlet.http.HttpServletRequest;
-import java.io.File;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -57,4 +55,6 @@ public interface WxCorpInfoService extends IService<WxCorpInfo> {
     String getUserInfoWithDepartment(String accessToken, Integer wxDeptid);
 
     User generateUserInfo(Integer companyId, String corpwxOpenId);
+
+    HttpRespMsg getBatchSearchUserInfo(WxCorpInfo wxCorpInfo, List<String> userNameList) throws Exception;
 }

+ 20 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -321,7 +321,19 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 XSSFCell reportDateCell = firstRow.getCell(1);
                 XSSFCell expenseTypeCell = firstRow.getCell(2);
                 XSSFCell remarksCell = firstRow.getCell(3);
-
+                List<String> userNameList=new ArrayList<>();
+                String value = reimburserCell.getStringCellValue();
+                if(userNameList.contains(value)){
+                    continue;
+                }
+                userNameList.add(value);
+                System.out.println("参与搜素的人员列表"+userNameList);
+                HttpRespMsg respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList);
+                if(respMsg.code.equals("0")){
+                    msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
+                    return msg;
+                }
+                List<User> targetUserList= (List<User>) respMsg.data;
                 if (reimburserCell != null) reimburserCell.setCellType(CellType.STRING);
                 if (reportDateCell != null) reportDateCell.setCellType(CellType.NUMERIC);
                 if (expenseTypeCell != null) expenseTypeCell.setCellType(CellType.STRING);
@@ -362,19 +374,20 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                         .atZone(ZoneId.systemDefault()).toLocalDate();
                 expenseSheet.setCreateDate(localDate);
                 Optional<User> first;
-                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
-                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())).findFirst();
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(reimburserCell.getStringCellValue())).findFirst();
+                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())||(us.getJobNumber()!=null&&us.getJobNumber().equals(reimburserCell.getStringCellValue()))||(optional.isPresent()&&us.getCorpwxUserid()!=null&&us.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findFirst();
                 }else {
-                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())||(us.getJobNumber()!=null&&us.getJobNumber().equals(reimburserCell.getStringCellValue()))).findFirst();
+                    first = userList.stream().filter(us -> us.getName().equals(reimburserCell.getStringCellValue())).findFirst();
                 }
                 if (first.isPresent()) {
                     expenseSheet.setOwnerId(first.get().getId());
                     expenseSheet.setOwnerName(first.get().getName());
                 } else {
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
-                        throw new Exception("报销人[" +reimburserCell+"]不存在");
-                    }else {
+                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                         throw new Exception("报销人/工号[" +reimburserCell+"]不存在");
+                    }else {
+                        throw new Exception("报销人[" +reimburserCell+"]不存在");
                     }
                 }
                 expenseSheet.setOperatorId(user.getId());

+ 30 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -3523,6 +3523,29 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<Report> reportList = new ArrayList<>();
             int projectNameStartIndex = (withCheckIn==null?2:6);
             int dataCount = 0;
+            List<String> userNameList=new ArrayList<>();
+            for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
+                Row row = sheet.getRow(rowIndex);
+                if (row == null) {
+                    continue;
+                }
+                if (ExcelUtil.isRowEmpty(row)) {
+                    continue;
+                }
+                dataCount++;
+                String username = withCheckIn==null?row.getCell(1).getStringCellValue().trim():row.getCell(2).getStringCellValue().trim();
+                if(userNameList.contains(username)){
+                    continue;
+                }
+                userNameList.add(username);
+            }
+            System.out.println("参与搜素的人员列表"+userNameList);
+            HttpRespMsg respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList);
+            if(respMsg.code.equals("0")){
+                msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
+                return msg;
+            }
+            List<User> targetUserList= (List<User>) respMsg.data;
             for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
                 Row row = sheet.getRow(rowIndex);
                 if (row == null) {
@@ -3595,17 +3618,18 @@ 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;
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
-                        any = allUserList.stream().filter(u -> u.getName().equals(username)).findAny();
+                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                        Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(username)).findFirst();
+                        any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))||(optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid()))).findAny();
                     }else {
-                        any = allUserList.stream().filter(u -> u.getName().equals(username)||(u.getJobNumber()!=null&&u.getJobNumber().equals(username))).findAny();
+                        any = allUserList.stream().filter(u -> u.getName().equals(username)).findAny();
                     }
                     if (!any.isPresent()) {
                         //msg.setError("人员["+username+"]不存在,请先在组织结构中添加或者通过钉钉同步导入");
-                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=1){
-                            msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
-                        }else {
+                        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                             msg.setError(MessageUtils.message("staff.peopleNullAndAddPlus",username));
+                        }else {
+                            msg.setError(MessageUtils.message("staff.peopleNullAndAdd",username));
                         }
                         return msg;
                     }