Browse Source

修改企业微信导出

yurk 2 years ago
parent
commit
0c82fef232

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

@@ -191,6 +191,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     GroupTemplateMapper GroupTemplateMapper;
     @Resource
     WxCorpInfoMapper wxCorpInfoMapper;
+    @Resource
+    WxCorpInfoService wxCorpInfoService;
 
     @Resource
     private HttpServletResponse response;
@@ -3095,7 +3097,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(userId);
         TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
-        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
         //然后处理文件
         String fileName = multipartFile.getOriginalFilename();
         File file = new File(fileName == null ? "file" : fileName);
@@ -3144,6 +3146,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 projectLevelMap.put(MessageUtils.message("excel.MedRisk"), 6);
                 projectLevelMap.put(MessageUtils.message("excel.highRisk"), 7);
                 List<String> existCodeList = new ArrayList<>();
+                List<String> userNameList=new ArrayList<>();
+                for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
+                    XSSFRow row = sheet.getRow(rowIndex);
+                    if (row == null) {
+                        continue;
+                    }
+                    //跳过空行
+                    if (ExcelUtil.isRowEmpty(row)) {
+                        continue;
+                    }
+                    XSSFCell participatorCell = row.getCell(5);
+                    if (participatorCell!=null)participatorCell.setCellType(CellType.STRING);
+                    String part = participatorCell.getStringCellValue().trim();
+                    String[] partSplit = part.split("\\,|\\,");
+                    for (String s : partSplit) {
+                        if(userNameList.contains(s)){
+                            continue;
+                        }
+                        userNameList.add(s);
+                    }
+                }
+                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;
                 int importCount = 0;
                 for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
                     XSSFRow row = sheet.getRow(rowIndex);
@@ -3243,15 +3273,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Optional<User> first;
                             Integer exception=null;
                             if(split.length==1){
-                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                                }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                                }
                                 exception=0;
                             }else {
-                                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();
+                                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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                }else {
+                                    first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                }
                             }
                             if (first.isPresent()) {
                                 project.setInchargerId(first.get().getId());
@@ -3339,15 +3375,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         Optional<User> first;
                         Integer exception=null;
                         if(split.length==1){
-                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                            }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                            }
                             exception=0;
                         }else {
-                            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();
+                            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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                            }else {
+                                first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                            }
                         }
                         Participation p = new Participation();
                         if (first.isPresent()) {
@@ -3379,15 +3421,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Optional<User> first;
                                 Integer exception=null;
                                 if(split.length==1){
-                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                                    }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                                    }
                                     exception=0;
                                 }else {
-                                    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();
+                                    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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                    }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();
@@ -3482,6 +3530,43 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     projectLevelMap.put(MessageUtils.message("excel.MedRisk"), 6);
                     projectLevelMap.put(MessageUtils.message("excel.highRisk"), 7);
                 }
+                List<String> userNameList=new ArrayList<>();
+                for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
+                    HSSFRow row = sheet.getRow(rowIndex);
+                    if (row == null) {
+                        continue;
+                    }
+                    //跳过空行
+                    if (ExcelUtil.isRowEmpty(row)) {
+                        continue;
+                    }
+                    HSSFCell participatorCell=null;
+                    int c=0;
+                    if(company.getId()==936){
+                        c++;
+                    }
+                    if(timeType.getMainProjectState()==1){
+                        participatorCell = row.getCell(4+c);
+                    }else {
+                        participatorCell = row.getCell(5+c);
+                    }
+                    if (participatorCell!=null)participatorCell.setCellType(CellType.STRING);
+                    String part = participatorCell.getStringCellValue().trim();
+                    String[] partSplit = part.split("\\,|\\,");
+                    for (String s : partSplit) {
+                        if(userNameList.contains(s)){
+                            continue;
+                        }
+                        userNameList.add(s);
+                    }
+                }
+                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;
                 List<String> existCodeList = new ArrayList<>();
                 int importCount = 0;
                 for (int rowIndex = 0; rowIndex <= rowNum; rowIndex++) {
@@ -3754,22 +3839,28 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                             Optional<User> first;
                             Integer exception=null;
                             if(split.length==1){
-                                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                                }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                                }
                                 exception=0;
                             }else {
-                                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();
+                                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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                }else {
+                                    first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                }
                             }
                             if (first.isPresent()) {
                                 project.setInchargerId(first.get().getId());
                                 project.setInchargerName(first.get().getName());
                             } else {
                                 switch (exception){
-                                    case 0:throw new Exception(wxCorpInfo!=null&&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]+"]姓名与工号不匹配");
                                 }
                             }
@@ -4330,15 +4421,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         Optional<User> first;
                         Integer exception=null;
                         if(split.length==1){
-                            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                            }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                            }
                             exception=0;
                         }else {
-                            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();
+                            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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                            }else {
+                                first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                            }
                         }
                         Participation p = new Participation();
                         if (first.isPresent()) {
@@ -4369,15 +4466,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 Optional<User> first;
                                 Integer exception=null;
                                 if(split.length==1){
-                                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()!=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();
-                                    }else {first= userList.stream().filter(u ->(u.getJobNumber()!=null&&u.getJobNumber().equals(split[0]))).findFirst();}
+                                    }
                                     exception=0;
                                 }else {
-                                    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();
+                                    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.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                    }else {
+                                        first= userList.stream().filter(u -> u.getName().equals(split[0])&&(u.getJobNumber()!=null&&u.getJobNumber().equals(split[1]))).findFirst();
+                                    }
                                 }
                                 Participation p = new Participation();
                                 if (first.isPresent()) {
@@ -4565,6 +4668,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<String> nameList= (List<String>) resultMap.get("nameList");
         Company company = companyMapper.selectById(user.getCompanyId());
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", company.getId()));
+        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", company.getId()));
         List<String> headList = new ArrayList<String>();
 //        headList.add("项目编号");
@@ -4577,6 +4681,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 //        headList.add("结束日期");
 //        headList.add("创建人");
 //        headList.add("创建日期");
+        if(timeType.getMainProjectState()==1){
+            headList.add(MessageUtils.message("entry.mainProject"));
+        }
         headList.add(MessageUtils.message("entry.projectId"));
         headList.add(MessageUtils.message("entry.projectType"));
         headList.add(MessageUtils.message("entry.publicProject"));
@@ -4588,7 +4695,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         headList.add(MessageUtils.message("entry.creator"));
         headList.add(MessageUtils.message("entry.creDate"));
         //自定义维度
-        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         if (timeType.getCustomDegreeActive() == 1) {
             headList.add(timeType.getCustomDegreeName());
         }
@@ -4657,6 +4763,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         System.out.println("此处耗时----------------"+between1.toMillis());
         for (ProjectVO projectVO : projectVOList) {
             List<String> rowData = new ArrayList<>();
+            if(timeType.getMainProjectState()==1){
+                rowData.add(projectVO.getProjectMainName());
+            }
             rowData.add(projectVO.getProjectCode());
             rowData.add(projectVO.getCategoryName());
             //rowData.add(("1".equals(projectVO.getIsPublic())?"是":"否"));

+ 57 - 61
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1,29 +1,14 @@
 package com.management.platform.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.dingtalk.api.DefaultDingTalkClient;
-import com.dingtalk.api.DingTalkClient;
-import com.dingtalk.api.request.OapiAuthScopesRequest;
-import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
-import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
-import com.dingtalk.api.response.OapiAuthScopesResponse;
-import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
-import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-import com.management.platform.constant.Constant;
 import com.management.platform.controller.WeiXinCorpController;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
-import com.management.platform.service.SysRoleService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.*;
-import com.taobao.api.ApiException;
-import javafx.scene.effect.Light;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.utils.HttpClientUtils;
@@ -83,7 +68,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
 
     public static final String GET_USER_INFO_WITHDP = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID";
 
-    public static final String GET_BATCHSEARCH_USER_INFO = "https://qyapi.weixin.qq.com/cgi-bin/service/contact/batchsearch?provider_access_token=ACCESS_TOKEN";
+    public static final String GET_BATCH_SEARCH_USER_INFO = "https://qyapi.weixin.qq.com/cgi-bin/service/contact/batchsearch?provider_access_token=ACCESS_TOKEN";
 
     public static final int TEXT_CARD_MSG_BUSTRIP_WAITING_AUDIT = 0;//出差待审核
     public static final int TEXT_CARD_MSG_BUSTRIP_AGREE = 1;//出差审核通过
@@ -660,6 +645,62 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         }
         return result;
     }
+    @Override
+    public HttpRespMsg getBatchSearchUserInfo(WxCorpInfo wxCorpInfo, List<String> userNameList)throws Exception{
+        HttpRespMsg msg=new HttpRespMsg();
+        List<User> userList=new ArrayList<>();
+        String url = GET_BATCH_SEARCH_USER_INFO.replace("ACCESS_TOKEN",getProviderAccessToken());
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        JSONObject jsonObject=new JSONObject();
+        jsonObject.put("auth_corpid","wwf11426cf618e1703");
+        jsonObject.put("agentid","1000066");
+        JSONArray jsonArray=new JSONArray();
+        for (String s : userNameList) {
+            JSONObject item=new JSONObject();
+            item.put("query_word",s);
+            item.put("query_type",1);
+            item.put("query_range",1);
+            item.put("limit",50);
+            item.put("full_match_field",1);
+            item.put("cursor",CURSOR.get("cursor"));
+            jsonArray.add(item);
+        }
+        jsonObject.put("query_request_list",jsonArray);
+        HttpEntity<String> requestEntity = new HttpEntity<String>(jsonObject.toJSONString(), headers);
+        ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
+                HttpMethod.POST, requestEntity, String.class);
+        if (responseEntity.getStatusCode() == HttpStatus.OK) {
+            String resp = responseEntity.getBody();
+            JSONObject json = JSONObject.parseObject(resp);
+            if(json.getIntValue("errcode")>0){
+                throw new Exception(json.toJSONString());
+            }
+            JSONArray resultList = json.getJSONArray("query_result_list");
+            for (int i = 0; i < resultList.size(); i++) {
+                User user=new User();
+                JSONObject item = resultList.getJSONObject(i);
+                JSONObject result = item.getJSONObject("query_result");
+                JSONObject request = item.getJSONObject("query_request");
+                String userName= request.getString("query_word");
+                user.setName(userName);
+                JSONObject userOb = result.getJSONObject("user");
+                if(userOb==null){
+                    continue;
+                }
+                List<String> openUseridList = (List<String>) userOb.get("open_userid");
+                if(openUseridList.size()>1){
+                    msg.data=userName;
+                    msg.code="0";
+                    return msg;
+                }
+                user.setCorpwxUserid(openUseridList.get(0));
+                userList.add(user);
+            }
+        }
+        msg.data=userList;
+        return msg;
+    }
 
     @Override
     public synchronized User generateUserInfo(Integer companyId, String corpwxOpenId) {
@@ -705,51 +746,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         return find;
     }
 
-    @Override
-    public HttpRespMsg getBatchSearchUserInfo(WxCorpInfo wxCorpInfo, List<String> userNameList) throws Exception {
-        HttpRespMsg msg=new HttpRespMsg();
-        String url = GET_BATCHSEARCH_USER_INFO.replace("ACCESS_TOKEN",getProviderAccessToken());
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.APPLICATION_JSON);
-        JSONObject jsonObject=new JSONObject();
-        jsonObject.put("auth_corpid",wxCorpInfo.getCorpid());
-        jsonObject.put("agentid",wxCorpInfo.getAgentid());
-        JSONArray jsonArray=new JSONArray();
-        for (String s : userNameList) {
-            JSONObject item=new JSONObject();
-            item.put("query_word",s);
-            item.put("query_type",1);
-            item.put("query_range",1);
-            item.put("limit",50);
-            item.put("full_match_field",1);
-            item.put("cursor",CURSOR.get("cursor"));
-            jsonArray.add(item);
-        }
-        jsonObject.put("query_request_list",jsonArray);
-        HttpEntity<String> requestEntity = new HttpEntity<String>(jsonObject.toJSONString(), headers);
-        ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
-                HttpMethod.POST, requestEntity, String.class);
-        if (responseEntity.getStatusCode() == HttpStatus.OK) {
-            String resp = responseEntity.getBody();
-            JSONObject json = JSONObject.parseObject(resp);
-            if(json.getIntValue("errcode")>0){
-                throw new Exception(json.toJSONString());
-            }
-            JSONArray resultList = json.getJSONArray("query_result_list");
-            for (int i = 0; i < resultList.size(); i++) {
-                User user=new User();
-                JSONObject dataItem = resultList.getJSONObject(i);
-                JSONObject request = dataItem.getJSONObject("query_request");
-                user.setName(request.getString("query_word"));
-                JSONObject result = dataItem.getJSONObject("query_result");
-                JSONObject userTarget = result.getJSONObject("user");
-            }
-
-        }
-        getProviderAccessToken();
-        return msg;
-    }
-
 
     public void reqPunchRecord(WxCorpInfo corpInfo, long startTime, long endTime, Object[] objects, boolean showLog,String userId,LocalDate date)throws Exception {
         DateTimeFormatter mdFormat = DateTimeFormatter.ofPattern("yyyy/M/d");