|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.constant.Constant;
|
|
|
+import com.management.platform.controller.WeiXinCorpController;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.UserVO;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -26,9 +27,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
@@ -64,6 +63,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
public String appId;
|
|
|
@Value("${wx.app_secret}")
|
|
|
public String appSecret;
|
|
|
+ @Value("${corpId}")
|
|
|
+ private String corpId;
|
|
|
+ @Value("${providerSecret}")
|
|
|
+ private String providerSecret;
|
|
|
public static final String GET_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
|
|
|
public static final String GET_USERINFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=accessToken&openid=openId&lang=zh_CN";
|
|
|
@Resource
|
|
@@ -145,6 +148,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
private CompanyReportMapper companyReportMapper;
|
|
|
@Resource
|
|
|
private ThirdPartyInterfaceMapper thirdPartyInterfaceMapper;
|
|
|
+ @Resource
|
|
|
+ SysConfigMapper sysConfigMapper;
|
|
|
//登录网页端
|
|
|
@Override
|
|
|
public HttpRespMsg loginAdmin(String username, String password) {
|
|
@@ -400,7 +405,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private boolean judgeIsLeader(String userId) {
|
|
|
int cnt = projectAuditorMapper.selectCount(new QueryWrapper<ProjectAuditor>().eq("auditor_id", userId));
|
|
|
return cnt>0;
|
|
@@ -427,11 +431,80 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//获取员工的列表
|
|
|
@Override
|
|
|
public HttpRespMsg getEmployeeList(Integer departmentId, String keyword, Integer status, Integer roleId, Integer onlyDirect, Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ Integer WXCompanyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", WXCompanyId));
|
|
|
+ if (wxCorpInfo!=null && keyword!=null && keyword!="" && departmentId == -1){
|
|
|
+ if (wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ String AccessUrl = "https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token";
|
|
|
+ String url = "https://qyapi.weixin.qq.com/cgi-bin/service/contact/search?provider_access_token=ACCESS_TOKEN";
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
+ //获取服务商id
|
|
|
+ JSONObject AccessRequestMap = new JSONObject();
|
|
|
+ AccessRequestMap.put("corpid", corpId);
|
|
|
+ AccessRequestMap.put("provider_secret", providerSecret);
|
|
|
+ HttpEntity<JSONObject> AccessEntity = new HttpEntity<>(AccessRequestMap, headers);
|
|
|
+ ResponseEntity<String> AccessResponseEntity = restTemplate.postForEntity(AccessUrl, AccessEntity, String.class);
|
|
|
+ String providerToken ="";
|
|
|
+ if (AccessResponseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
+ String AccessResp = AccessResponseEntity.getBody();
|
|
|
+ JSONObject json = JSONObject.parseObject(AccessResp);
|
|
|
+ providerToken = json.getString("provider_access_token");
|
|
|
+ }else {
|
|
|
+ httpRespMsg.setError("服务商token获取失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ //搜索通讯录名单
|
|
|
+ url = url.replace("ACCESS_TOKEN", providerToken);
|
|
|
+ JSONObject requestMap = new JSONObject();
|
|
|
+ requestMap.put("auth_corpid", wxCorpInfo.getCorpid());
|
|
|
+ requestMap.put("query_word", keyword);
|
|
|
+ requestMap.put("query_type", 1);
|
|
|
+ requestMap.put("query_range", 1);
|
|
|
+ requestMap.put("limit", 200);
|
|
|
+ //requestMap.put("cursor", pageSize);
|
|
|
+ HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
|
|
|
+ ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
|
|
|
+ if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
+ String resp = ResponseEntity.getBody();
|
|
|
+ JSONObject json = JSONObject.parseObject(resp);
|
|
|
+ JSONObject queryResult = json.getJSONObject("query_result");
|
|
|
+ if (!queryResult.isEmpty()){
|
|
|
+ JSONArray jsonArray = queryResult.getJSONObject("user").getJSONArray("open_userid");
|
|
|
+ if (jsonArray.size()!=0){
|
|
|
+ Object[] user = jsonArray.toArray();
|
|
|
+ List<User> users = userMapper.selectList(new QueryWrapper<User>().in("corpwx_userid", user));
|
|
|
+ HashMap<String, Object> data = new HashMap<>();
|
|
|
+ data.put("records",users);
|
|
|
+ data.put("total",0);
|
|
|
+ httpRespMsg.data=data;
|
|
|
+ return httpRespMsg;
|
|
|
+ }else {
|
|
|
+ HashMap<String, Object> data = new HashMap<>();
|
|
|
+ ArrayList<Object> records = new ArrayList<>();
|
|
|
+ data.put("records",records);
|
|
|
+ data.put("total",0);
|
|
|
+ httpRespMsg.data=data;
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ HashMap<String, Object> data = new HashMap<>();
|
|
|
+ ArrayList<Object> records = new ArrayList<>();
|
|
|
+ data.put("records",records);
|
|
|
+ data.put("total",0);
|
|
|
+ httpRespMsg.data=data;
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
try {
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|