浏览代码

fix 客服同步接口

zoujiajian 2 年之前
父节点
当前提交
0111ec8db9

+ 4 - 37
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpServiceImpl.java

@@ -7,7 +7,6 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
-import com.cyksj.common.util.ListsUtil;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.common.util.Xmls;
 import com.cyksj.common.util.corp.WxCryptUtil;
@@ -201,6 +200,10 @@ public class CorpServiceImpl implements CorpService {
 					e.printStackTrace();
 					return;
 				}
+				if (!userInfo.getDepartment().contains(2)) {
+					System.out.println("不是客服");
+					return;
+				}
 				CorpFollow corpFollow = new CorpFollow();
 				BeanUtil.copyProperties(userInfo, corpFollow);
 				CorpFollow follow = corpFollowMapper.selectOne(Wrappers.lambdaQuery(CorpFollow.class).eq(CorpFollow::getUserid, corpFollow.getUserid()).eq(CorpFollow::getWxCorpId, wxCorpId));
@@ -211,42 +214,6 @@ public class CorpServiceImpl implements CorpService {
 					corpFollow.setId(follow.getId());
 					corpFollowMapper.updateById(corpFollow);
 				}
-
-				List<String> externalList = null;
-				try {
-					externalList = wxCorpOps.listExternalContacts(corpId, userId);
-				} catch (Exception e) {
-					e.printStackTrace();
-					return;
-				}
-				if (externalList.size() > 1000) {
-					List<List<String>> lists = ListsUtil.averageAssign(externalList, 5);
-					for (List<String> list : lists) {
-						THREAD_POOL.execute(() -> {
-							for (String externalUserid : list) {
-								try {
-									CorpXmlMessage message = new CorpXmlMessage();
-									message.setToUserName(corpId);
-									message.setExternalUserId(externalUserid);
-									corpEventActionService.addExternalContact(message, null);
-								} catch (Exception e) {
-									e.printStackTrace();
-								}
-							}
-						});
-					}
-				} else {
-					for (String externalUserid : externalList) {
-						try {
-							CorpXmlMessage message = new CorpXmlMessage();
-							message.setToUserName(corpId);
-							message.setExternalUserId(externalUserid);
-							corpEventActionService.addExternalContact(message, null);
-						} catch (Exception e) {
-							e.printStackTrace();
-						}
-					}
-				}
 			});
 		}
 		return "";

+ 3 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -224,8 +224,9 @@ public class WxCorpController {
 	/**
 	 * 初始化企业微信入库信息
 	 */
-	@GetMapping("/dataInit/{corpId}")
-	public Result<String> dataInitByCorpId(@PathVariable("corpId") String corpId) throws Exception {
+	@GetMapping("/dataInit")
+	public Result<String> dataInitByCorpId(String corpId) throws Exception {
+		corpId = Optional.ofNullable(corpId).orElse(yhlxWxCorpConfig.getCorpId());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(corpService.dataInitByCorpId(corpId));
 	}