From 9b208eb3947358169df8f46472a246eb6ea8ca32 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 18 十二月 2023 17:08:09 +0800 Subject: [PATCH] 工作通知 --- ycl-platform/src/main/java/com/ycl/common/dingding/DingCommon.java | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 45 insertions(+), 4 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..e36d906 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 @@ -62,7 +62,6 @@ // 鍒ゆ柇ding 淇℃伅鏄惁瀛樺湪 boolean hasDing = redisTemplate.hasKey("ding"); if (hasDing) { - log.info("redis姝e父鏈夋秷鎭�"); String dingStr = redisTemplate.opsForValue().get("ding"); JSONObject dingObj = JSONObject.parseObject(dingStr); String getToken = dingObj.getString("token"); @@ -86,6 +85,12 @@ DingUserInfo dingUserInfo = BeanUtil.toBean(resObj, DingUserInfo.class); String accId = DingEncodeUtil.getMD5(resObj.getString("employeeCode").getBytes()); dingUserInfo.setUserId(Long.parseLong(accId)); + String employeeCode = resObj.getString("employeeCode"); + JSONArray users = getAccountId(Arrays.asList(employeeCode)); + JSONObject jsonObject = users.getJSONObject(0); + String accountId = jsonObject.getString("accountId"); + dingUserInfo.setAccountId(Long.parseLong(accountId)); + return dingUserInfo; } } @@ -313,7 +318,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 +345,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 +390,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