| | |
| | | } while (isHasPage); |
| | | } |
| | | } |
| | | |
| | | //补充accountId |
| | | dingAccoutId(employeeCodes,dingUserInfoList); |
| | | |
| | | JSONArray arr = new JSONArray(Collections.singletonList(dingUserInfoList)); |
| | | redisTemplate.opsForValue().set("userJsonList", arr.toJSONString()); |
| | | return dingUserInfoList; |
| | | } |
| | | //补充DingUserInfo中的accountId |
| | | private void insertAccoutId(Set<DingUserInfo> dingUserInfoList, List<String> employeeCodes) { |
| | | if(CollectionUtils.isNotEmpty(employeeCodes)) { |
| | | log.info("开始补充accountId"); |
| | | JSONArray users = getAccountId(employeeCodes); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONArray arr = new JSONArray(Collections.singletonList(dingUserInfoList)); |
| | | redisTemplate.opsForValue().set("userJsonList", arr.toJSONString()); |
| | | return dingUserInfoList; |
| | | //分批执行 |
| | | private void dingAccoutId(List<String> employeeCodes,Set<DingUserInfo> dingUserInfoList) { |
| | | // 每次插入的数量 |
| | | int batchSize = 99; |
| | | // 计算需要分多少批 |
| | | int batch = employeeCodes.size() / batchSize; |
| | | // 计算最后一批的大小 |
| | | int lastSize = employeeCodes.size() % batchSize; |
| | | |
| | | log.info("插入数量{},分多少批{},最后一批的大小{}", batchSize, batch, lastSize); |
| | | // 将筛选出的结果分批次添加 |
| | | int num = 1; |
| | | for (int i = batchSize; i <= batch * batchSize; i = i + batchSize) { |
| | | log.info("开始"); |
| | | // 截取本次要添加的数据 |
| | | List<String> insertList = employeeCodes.subList(i - batchSize, i); |
| | | // 添加本批次数据 |
| | | log.info("批量导入数据第{}次", num); |
| | | insertAccoutId(dingUserInfoList, insertList); |
| | | num++; |
| | | } |
| | | // 最后一批元素的大小是否为0 |
| | | if (lastSize != 0) { |
| | | // 如果元素有剩余则将所有元素一次性插入 |
| | | List<String> lastList = employeeCodes.subList(batchSize * batch, employeeCodes.size()); |
| | | log.info("最后一次导入数据"); |
| | | insertAccoutId(dingUserInfoList, lastList); |
| | | } |
| | | } |
| | | /** |
| | | * 根据员工code 获取员工accountId |
| | |
| | | } |
| | | postClient.addParameter("tenantId", dingConfig.getTenantId()); |
| | | String apiResult = postClient.post(); |
| | | log.info("获取员工accountId接口返回------>{}",apiResult); |
| | | JSONObject resObj = parsingJson(apiResult); |
| | | if (null != resObj) { |
| | | return resObj.getJSONArray("data"); |