|
@@ -1,6 +1,8 @@
|
|
|
package com.fs.his.task;
|
|
package com.fs.his.task;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -62,9 +64,12 @@ import com.fs.hisStore.service.IFsStorePaymentScrmService;
|
|
|
import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
|
|
import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
|
|
+import com.fs.im.config.IMConfig;
|
|
|
import com.fs.im.dto.*;
|
|
import com.fs.im.dto.*;
|
|
|
import com.fs.im.service.IImService;
|
|
import com.fs.im.service.IImService;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
import com.fs.im.service.OpenIMService;
|
|
|
|
|
+import com.fs.im.service.impl.OpenIMServiceImpl;
|
|
|
|
|
+import com.fs.im.vo.OpenImResponseUserVO;
|
|
|
import com.fs.qw.domain.QwCompany;
|
|
import com.fs.qw.domain.QwCompany;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwRestrictionPushRecordMapper;
|
|
import com.fs.qw.mapper.QwRestrictionPushRecordMapper;
|
|
@@ -78,7 +83,9 @@ import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.utils.OrderContextHolder;
|
|
import com.fs.utils.OrderContextHolder;
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
|
+import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -1865,4 +1872,114 @@ public class Task {
|
|
|
// 等待所有异步任务完成
|
|
// 等待所有异步任务完成
|
|
|
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
|
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 同步Im系统中的用户昵称
|
|
|
|
|
+ */
|
|
|
|
|
+ public void updateIMUserName() {
|
|
|
|
|
+ String adminToken = openIMService.getAdminToken();
|
|
|
|
|
+// String adminToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiJpbUFkbWluIiwiUGxhdGZvcm1JRCI6MTAsImV4cCI6MTc3NDMxNzk3NiwiaWF0IjoxNzY2NTQxOTcxfQ.3LNnzvZQfCdLf5HWc2wvU_Hw0j_JfBGJtc88vwQmzBc";
|
|
|
|
|
+ List<OpenIMServiceImpl.UserInfo> userInfos = getImUserId(adminToken);
|
|
|
|
|
+ // 过滤出以U开头的用户ID
|
|
|
|
|
+ List<String> userIds = userInfos.stream().filter(user -> user.getUserID().startsWith("U"))
|
|
|
|
|
+ .map(s -> s.getUserID().length() > 1 ? s.getUserID().substring(1) : "")
|
|
|
|
|
+ .filter(ObjectUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
|
|
+ log.info("过滤出以U开头的用户ID:{}", userIds);
|
|
|
|
|
+ List<FsUser> fsUsers = fsUserMapper.selectUserNameByIds(userIds.toString());
|
|
|
|
|
+// List<FsUser> fsUsers = fsUserMapper.selectlistBylimit(userIds.toString());
|
|
|
|
|
+ List<Long> collect = fsUsers.stream().filter(Objects::isNull).map(FsUser::getUserId).collect(Collectors.toList());
|
|
|
|
|
+ log.info("查询的用户id:,{}", collect);
|
|
|
|
|
+ Map<String, String> userInfosMap = userInfos.stream()
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toMap(OpenIMServiceImpl.UserInfo::getUserID, OpenIMServiceImpl.UserInfo::getNickname, (n1, n2) -> n1));
|
|
|
|
|
+ log.info("IM的用户Map:{}", userInfosMap);
|
|
|
|
|
+ //名字对不上的用户集合
|
|
|
|
|
+ List<FsUser> fsUserList = fsUsers.stream().filter(Objects::nonNull)
|
|
|
|
|
+ .filter(fsUser -> {
|
|
|
|
|
+ String imName = userInfosMap.get("U" + fsUser.getUserId());
|
|
|
|
|
+ return imName != null && !Objects.equals(fsUser.getNickName(), imName);
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ log.info("名字对不上的用户集合:{}", fsUserList);
|
|
|
|
|
+ requestImUpdate(adminToken, fsUserList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取Im系统中U开头的用户信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return U开头用户信息集合
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<OpenIMServiceImpl.UserInfo> getImUserId(String adminToken) {
|
|
|
|
|
+ int pageSize = 5000;
|
|
|
|
|
+ int pageNumber = 1;
|
|
|
|
|
+ List<OpenIMServiceImpl.UserInfo> users;
|
|
|
|
|
+ while (true) {
|
|
|
|
|
+ // 构建分页查询请求体
|
|
|
|
|
+ org.json.JSONObject requestPage = new org.json.JSONObject();
|
|
|
|
|
+ org.json.JSONObject pagination = new org.json.JSONObject();
|
|
|
|
|
+ pagination.put("pageNumber", pageNumber);
|
|
|
|
|
+ pagination.put("showNumber", pageSize);
|
|
|
|
|
+ requestPage.put("pagination", pagination);
|
|
|
|
|
+ log.info("IM系统URL地址:https://web.jnmyim.ylrzfs.com/api/user/get_users");
|
|
|
|
|
+ String result = HttpRequest.post("https://web.jnmyim.ylrzfs.com/api/user/get_users")
|
|
|
|
|
+ .header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
|
|
+ .header("token", adminToken)
|
|
|
|
|
+ .body(requestPage.toString())
|
|
|
|
|
+ .execute()
|
|
|
|
|
+ .body();
|
|
|
|
|
+ OpenImResponseUserVO responseDTO = JSONUtil.toBean(result, OpenImResponseUserVO.class);
|
|
|
|
|
+ users = responseDTO.getData().getUsers();
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtil.isEmpty(users)) {
|
|
|
|
|
+ log.info("数据为空,处理结束");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("已处理第 {} 页,共处理用户数:{}", pageNumber, users.size());
|
|
|
|
|
+ if (users.size() < pageSize) {
|
|
|
|
|
+ log.info("已是最后一页,处理完毕!");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ pageNumber++; // 下一页
|
|
|
|
|
+ }
|
|
|
|
|
+ return users;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 请求Im系统更改用户昵称
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param adminToken
|
|
|
|
|
+ * @param fsUserList 名字对不上的用户集合
|
|
|
|
|
+ */
|
|
|
|
|
+ private void requestImUpdate(String adminToken, List<FsUser> fsUserList) {
|
|
|
|
|
+ if (CollectionUtil.isEmpty(fsUserList)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ OpenImResponseDTO responseDTO = null;
|
|
|
|
|
+ UpdateUserInfo updateUserInfo = new UpdateUserInfo();
|
|
|
|
|
+ for (FsUser user : fsUserList) {
|
|
|
|
|
+ updateUserInfo.setUserID("U" + user.getUserId().toString());
|
|
|
|
|
+ updateUserInfo.setNickname(user.getNickName());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> bodyMap = new HashMap<>();
|
|
|
|
|
+ bodyMap.put("userInfo", updateUserInfo);
|
|
|
|
|
+ String jsonBody1 = JSONUtil.toJsonStr(bodyMap);
|
|
|
|
|
+ String result2 = HttpRequest.post("https://web.jnmyim.ylrzfs.com/api/user/update_user_info_ex")
|
|
|
|
|
+ .header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
|
|
+ .header("token", adminToken)
|
|
|
|
|
+ .body(jsonBody1)
|
|
|
|
|
+ .execute()
|
|
|
|
|
+ .body();
|
|
|
|
|
+ responseDTO = JSONUtil.toBean(result2, OpenImResponseDTO.class);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("IM系统响应返回:code:{},msg:{}", responseDTO.getErrCode(), responseDTO.getErrMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Data
|
|
|
|
|
+ public class UpdateUserInfo {
|
|
|
|
|
+ private String userID;
|
|
|
|
|
+ private String nickname;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|