From acea9131318ee6823d008b386e52fee573882b2e Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 18 十二月 2023 15:14:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java | 42 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java b/ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java index 9898fd2..471af60 100644 --- a/ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java +++ b/ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java @@ -313,7 +313,16 @@ } 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("寮�濮嬭ˉ鍏卆ccountId"); JSONArray users = getAccountId(employeeCodes); @@ -331,10 +340,36 @@ } } } + } - 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 @@ -350,6 +385,7 @@ } postClient.addParameter("tenantId", dingConfig.getTenantId()); String apiResult = postClient.post(); + log.info("鑾峰彇鍛樺伐accountId鎺ュ彛杩斿洖------>{}",apiResult); JSONObject resObj = parsingJson(apiResult); if (null != resObj) { return resObj.getJSONArray("data"); -- Gitblit v1.8.0