|
@@ -9,6 +9,9 @@ import com.management.platform.entity.vo.UserVO;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
import com.management.platform.service.impl.ExcelExportServiceImpl;
|
|
|
+import com.management.platform.service.impl.ReportServiceImpl;
|
|
|
+import com.management.platform.service.impl.TaskServiceImpl;
|
|
|
+import com.management.platform.service.impl.UserServiceImpl;
|
|
|
import com.management.platform.util.*;
|
|
|
import com.qq.weixin.mp.aes.AesException;
|
|
|
import com.qq.weixin.mp.aes.WXBizMsgCrypt;
|
|
@@ -143,7 +146,8 @@ public class WeiXinCorpController {
|
|
|
public LocalDateTime expireTime = null;
|
|
|
}
|
|
|
public static Map<String, AgentItem> agentCorpTicketMap = new HashMap<String,AgentItem>();
|
|
|
-
|
|
|
+ @Value("${configEnv.isDev}")
|
|
|
+ boolean isDev;
|
|
|
@Resource
|
|
|
SysConfigMapper sysConfigMapper;
|
|
|
@Resource
|
|
@@ -415,6 +419,9 @@ public class WeiXinCorpController {
|
|
|
result.setJobType(jobType);
|
|
|
corpwxJobResultMapper.insert(result);
|
|
|
ExcelExportServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
|
+ ReportServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
|
+ UserServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
|
+ TaskServiceImpl.corpwxJobCenter.put(jobId, result);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -846,7 +853,7 @@ public class WeiXinCorpController {
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(reqParam.toJSONString(), headers);
|
|
|
ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
|
|
|
HttpMethod.POST, requestEntity, String.class);
|
|
|
- boolean enableNewVersion = false;
|
|
|
+ boolean enableNewVersion = true;
|
|
|
if (responseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
String resp = responseEntity.getBody();
|
|
|
log.info(resp);
|
|
@@ -1599,6 +1606,7 @@ public class WeiXinCorpController {
|
|
|
.setCorpwxUserid(openUserid)
|
|
|
.setCorpwxRealUserid(curUserid)
|
|
|
.setColor(ColorUtil.randomColor())
|
|
|
+ .setPassword(MD5Util.getPassword("000000"))
|
|
|
.setJobNumber(curUserid)
|
|
|
.setCorpwxDeptid(maxDeptId);
|
|
|
allCorpWxUserList.add(user);
|
|
@@ -1656,6 +1664,7 @@ public class WeiXinCorpController {
|
|
|
.setCorpwxRealUserid(curUserid)
|
|
|
.setColor(ColorUtil.randomColor())
|
|
|
.setJobNumber(curUserid)
|
|
|
+ .setPassword(MD5Util.getPassword("000000"))
|
|
|
.setCorpwxDeptid(curDept.getCorpwxDeptid());
|
|
|
allCorpWxUserList.add(user);
|
|
|
}
|
|
@@ -1692,7 +1701,7 @@ public class WeiXinCorpController {
|
|
|
}
|
|
|
if (!userItem.getName().equals(oldUser.getName())) {
|
|
|
changeUser.setId(oldUser.getId());
|
|
|
- changeUser.setName(oldUser.getName());
|
|
|
+ changeUser.setName(userItem.getName());
|
|
|
}
|
|
|
if (!userItem.getCorpwxDeptid().equals(oldUser.getCorpwxDeptid())) {
|
|
|
changeUser.setId(oldUser.getId());
|
|
@@ -1713,6 +1722,8 @@ public class WeiXinCorpController {
|
|
|
//有变动
|
|
|
finalUpdateUserList.add(changeUser);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ System.out.println("没找到用户:"+userItem.getName()+", "+userItem.getCorpwxUserid());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1762,10 +1773,10 @@ public class WeiXinCorpController {
|
|
|
|
|
|
int companyRootDeptId = 1;
|
|
|
if (syncMembs == 1) {
|
|
|
- JSONArray allCorpWxUserJsonArray = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
|
|
|
+ JSONArray rootCorpUserJsonArray = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
|
|
|
//获取远程的带姓名的详情,通过企业通讯录的token获取
|
|
|
JSONArray remoteUnAUserList = null;
|
|
|
- if (allCorpWxUserJsonArray.size() > 0) {
|
|
|
+ if (rootCorpUserJsonArray.size() > 0) {
|
|
|
remoteUnAUserList = remoteGetDeptUserDetail(wxCorpInfo, corpContactAccessToken, companyRootDeptId);
|
|
|
//做id转化
|
|
|
List<String> corpUserIds = new ArrayList<>();
|
|
@@ -1797,15 +1808,12 @@ public class WeiXinCorpController {
|
|
|
|
|
|
List<User> updateUserList = new ArrayList<>();
|
|
|
|
|
|
- for (int m=0;m<allCorpWxUserJsonArray.size(); m++) {
|
|
|
- JSONObject userJson = allCorpWxUserJsonArray.getJSONObject(m);
|
|
|
+ for (int m=0;m<rootCorpUserJsonArray.size(); m++) {
|
|
|
+ JSONObject userJson = rootCorpUserJsonArray.getJSONObject(m);
|
|
|
String curUserid = userJson.getString("userid");
|
|
|
//跳过非激活状态的员工
|
|
|
if (userJson.getInteger("status") != 1) continue;
|
|
|
System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", department="+userJson.getJSONArray("department"));
|
|
|
-// if (userJson.getJSONArray("direct_leader").size() > 0) {
|
|
|
-// hasDirectLdMembs.add(userJson);
|
|
|
-// }
|
|
|
//不存在的人员, 进行插入
|
|
|
User user = new User();
|
|
|
|
|
@@ -2045,39 +2053,6 @@ public class WeiXinCorpController {
|
|
|
if (needUpdateDepts.size() > 0) {
|
|
|
departmentService.updateBatchById(needUpdateDepts);
|
|
|
}
|
|
|
- //更新人员的直属上级
|
|
|
-// if (hasDirectLdMembs.size() > 0) {
|
|
|
-// List<String> corpwxUids = new ArrayList<>();
|
|
|
-// for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
-// String curUserid = userJson.getString("userid");
|
|
|
-// //取第一个leaderId
|
|
|
-// JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
-// String string = directLeader.getString(0);
|
|
|
-// corpwxUids.add(curUserid);
|
|
|
-// if (!corpwxUids.contains(string)) {
|
|
|
-// corpwxUids.add(string);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, corpwx_userid, superior_id").in("corpwx_userid", corpwxUids));
|
|
|
-// List<User> updateUserList = new ArrayList<>();
|
|
|
-// for (JSONObject userJson : hasDirectLdMembs) {
|
|
|
-// String curUserid = userJson.getString("userid");
|
|
|
-// User user = userList.stream().filter(u -> u.getCorpwxUserid().equals(curUserid)).findFirst().get();
|
|
|
-// JSONArray directLeader = userJson.getJSONArray("direct_leader");
|
|
|
-// String leaderCorpWxuid = directLeader.getString(0);
|
|
|
-// //查找leader
|
|
|
-// User leader = userList.stream().filter(u -> u.getCorpwxUserid().equals(leaderCorpWxuid)).findFirst().get();
|
|
|
-// if (!leader.getId().equals(user.getSuperiorId())) {
|
|
|
-// user.setSuperiorId(leader.getId());
|
|
|
-// updateUserList.add(user);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if (updateUserList.size() > 0) {
|
|
|
-// //批量更新上级领导
|
|
|
-// userService.updateBatchById(updateUserList);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
//更新人员的deptcascade
|
|
|
updateUserDeptCascade(companyId);
|
|
|
|
|
@@ -2135,7 +2110,7 @@ public class WeiXinCorpController {
|
|
|
return msg;
|
|
|
}
|
|
|
int companyId = company.getId();
|
|
|
- //获取公司根部门人员,也就是没有分配部门的人员
|
|
|
+ //获取公司根部门人员,属于公司这个组织下面的人员
|
|
|
int companyRootDeptId = 1;
|
|
|
JSONArray unAssignedUserList = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
|
|
|
SysRole defaultRole = sysRoleMapper.selectOne(
|
|
@@ -2506,6 +2481,24 @@ public class WeiXinCorpController {
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/updateSuiteTicket")
|
|
|
+ public HttpRespMsg updateSuiteTicket(String suiteTicket) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String remoteHost = request.getRemoteHost();
|
|
|
+ System.out.println("请求来自:"+remoteHost);
|
|
|
+ if ("47.100.37.243".equals(remoteHost) && isDev) {
|
|
|
+ SysConfig config = sysConfigMapper.selectOne(new QueryWrapper<SysConfig>().eq("param_key", "wx_suite_ticket"));
|
|
|
+ if (config != null) {
|
|
|
+ config.setParamValue(suiteTicket);
|
|
|
+ config.setIndate(LocalDateTime.now());
|
|
|
+ sysConfigMapper.updateById(config);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//将部门id转换为部门层级
|
|
|
private String convertDepartmentIdToCascade(Integer id, List<Department> allDeptList) {
|
|
|
StringBuilder cascade = new StringBuilder();
|