|  | @@ -12,7 +12,6 @@ import com.microsvc.toolkit.middleware.im.message.GroupMemberWrapper;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.middleware.im.message.MessageWrapper;
 | 
	
		
			
				|  |  |  import com.microsvc.toolkit.middleware.im.message.TencentRequest;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | -import com.ym.mec.auth.api.enums.SysUserType;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.ImGroupDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.ImGroupMemberDao;
 | 
	
	
		
			
				|  | @@ -78,6 +77,7 @@ import java.time.LocalDateTime;
 | 
	
		
			
				|  |  |  import java.time.ZoneId;
 | 
	
		
			
				|  |  |  import java.time.format.DateTimeFormatter;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.concurrent.*;
 | 
	
		
			
				|  |  |  import java.util.function.Function;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -891,6 +891,9 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void groupTransfer(String startTime, String endTime) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 100个线程的无界线程池
 | 
	
		
			
				|  |  | +        ExecutorService executorService = Executors.newFixedThreadPool(100);
 | 
	
		
			
				|  |  |          int page = 1;
 | 
	
		
			
				|  |  |          int size = 100;
 | 
	
		
			
				|  |  |          QueryInfo queryInfo = new QueryInfo();
 | 
	
	
		
			
				|  | @@ -899,8 +902,12 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |          queryInfo.setImportFlag(false);
 | 
	
		
			
				|  |  |          PageInfo<ImGroup> imGroupPageInfo = this.queryPage(queryInfo);
 | 
	
		
			
				|  |  |          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  | +        int total = imGroupPageInfo.getTotal();
 | 
	
		
			
				|  |  |          int importImGroupCount = 0;
 | 
	
		
			
				|  |  | -        while (!imGroupPageInfo.getRows().isEmpty()) {
 | 
	
		
			
				|  |  | +        int num = (int) Math.ceil(total / 100);
 | 
	
		
			
				|  |  | +        for (int i = 0; i <=num ; i++) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            imGroupPageInfo = this.queryPage(queryInfo);
 | 
	
		
			
				|  |  |              List<ImGroup> rows = imGroupPageInfo.getRows();
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  if (StringUtils.isNotEmpty(startTime)) {
 | 
	
	
		
			
				|  | @@ -920,34 +927,62 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |              } catch (ParseException e) {
 | 
	
		
			
				|  |  |                  throw new BizException("时间区间参数错误,格式为:yyyy-MM-dd");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            groupTransfer(rows);
 | 
	
		
			
				|  |  | +            List<Future<?>> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            rows.forEach(imGroup -> {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                list.add(executorService.submit(() -> {
 | 
	
		
			
				|  |  | +                    log.info("群销毁开始:{}", imGroup.getId());
 | 
	
		
			
				|  |  | +                    // 先删除群组
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        // 解散群
 | 
	
		
			
				|  |  | +                        imPluginContext.getPluginService().groupDismiss(imGroup.getId(), new ArrayList<>());
 | 
	
		
			
				|  |  | +                    } catch (Exception e) {
 | 
	
		
			
				|  |  | +                        log.error(String.format("群迁移删除群聊失败:%s", e.getMessage()), e);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }));
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            for (Future<?> future : list) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    future.get();
 | 
	
		
			
				|  |  | +                } catch (Exception e){
 | 
	
		
			
				|  |  | +                    log.error("群销毁失败",e);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                Thread.sleep(1500);
 | 
	
		
			
				|  |  | +            } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                log.error("线程休眠失败",e);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            list.clear();
 | 
	
		
			
				|  |  | +            for (ImGroup row : rows) {
 | 
	
		
			
				|  |  | +                list.add(executorService.submit(() -> {
 | 
	
		
			
				|  |  | +                    groupTransfer(Lists.newArrayList(row));
 | 
	
		
			
				|  |  | +                }));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (Future<?> future : list) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    future.get();
 | 
	
		
			
				|  |  | +                } catch (Exception e){
 | 
	
		
			
				|  |  | +                    log.error("群迁移失败",e);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              importImGroupCount += rows.size();
 | 
	
		
			
				|  |  |              log.info("------------------------------- import im group --------------------------------------------");
 | 
	
		
			
				|  |  | -            log.info("import im group success count:{}/{}", importImGroupCount, imGroupPageInfo.getTotal());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            page++;
 | 
	
		
			
				|  |  | -            queryInfo.setPage(page);
 | 
	
		
			
				|  |  | -            imGroupPageInfo = this.queryPage(queryInfo);
 | 
	
		
			
				|  |  | +            log.info("import im group success count:{}/{}", importImGroupCount, total);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          log.info("-------------------- import im group finished and success! -------------------------------");
 | 
	
		
			
				|  |  | +        executorService.shutdown();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void groupTransfer(List<ImGroup> records) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for (ImGroup imGroup : records) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            log.info("群销毁开始:{}", imGroup.getId());
 | 
	
		
			
				|  |  | -            // 先删除群组
 | 
	
		
			
				|  |  | -            try {
 | 
	
		
			
				|  |  | -                // 解散群
 | 
	
		
			
				|  |  | -                imPluginContext.getPluginService().groupDismiss(imGroup.getId(), new ArrayList<>());
 | 
	
		
			
				|  |  | -            } catch (Exception e) {
 | 
	
		
			
				|  |  | -                log.error(String.format("群迁移删除群聊失败:%s", e.getMessage()), e);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        for (ImGroup imGroup : records) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              log.info("群迁移开始:{}", imGroup.getId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              GroupMemberQueryInfo groupMemberQueryInfo = new GroupMemberQueryInfo();
 | 
	
	
		
			
				|  | @@ -967,29 +1002,44 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  importGroup.setType("Public");
 | 
	
		
			
				|  |  |                  importGroup.setGroupId(imGroup.getId());
 | 
	
		
			
				|  |  | -                importGroup.setName(imGroup.getName());
 | 
	
		
			
				|  |  | +                importGroup.setName(StringUtils.isBlank(imGroup.getName())?imGroup.getId():imGroup.getName());
 | 
	
		
			
				|  |  |                  importGroup.setIntroduction(imGroup.getIntroduce());
 | 
	
		
			
				|  |  |                  importGroup.setNotification(imGroup.getMemo());
 | 
	
		
			
				|  |  |                  importGroup.setFaceUrl(imGroup.getImg());
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(imGroup.getImg())) {
 | 
	
		
			
				|  |  | -                    importGroup.setFaceUrl(imGroup.getGroupType().getAvatar());
 | 
	
		
			
				|  |  | +                    importGroup.setFaceUrl(Optional.ofNullable(imGroup.getGroupType()).orElse(ImGroup.GroupTypeEnum.NORMAL).getAvatar());
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  importGroup.setApplyJoinOption("FreeAccess");
 | 
	
		
			
				|  |  | -                importGroup.setCreateTime(imGroup.getCreateTime().getTime() / 1000);
 | 
	
		
			
				|  |  | -                if (admin != null) {
 | 
	
		
			
				|  |  | -                    register(admin.getUserId().toString(), getClientType(admin.getRoleType()),"");
 | 
	
		
			
				|  |  | +                if (imGroup.getCreateTime() == null) {
 | 
	
		
			
				|  |  | +                    imGroup.setCreateTime(DateTime.now().plusYears(-1).toDate());
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +                importGroup.setCreateTime(imGroup.getCreateTime().getTime() / 1000);
 | 
	
		
			
				|  |  | +//                if (admin != null) {
 | 
	
		
			
				|  |  | +//                    register(admin.getUserId().toString(), getClientType(admin.getRoleType()),"");
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  |                  imPluginContext.getPluginService().importGroup(importGroup);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  List<ImGroupMember> groupMembers = pageInfo.getRows().stream()
 | 
	
		
			
				|  |  |                          .filter(next -> !next.getIsAdmin()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                groupMembers = groupMembers
 | 
	
		
			
				|  |  | +                    .stream()
 | 
	
		
			
				|  |  | +                    .filter(next -> next.getUserId() != null && next.getUserId() > 0)
 | 
	
		
			
				|  |  | +                    .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  if (groupMembers.isEmpty()) {
 | 
	
		
			
				|  |  |                      imGroupDao.updateImportStatusSuccess(imGroup.getId());
 | 
	
		
			
				|  |  |                      continue;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                for (ImGroupMember member : groupMembers) {
 | 
	
		
			
				|  |  | -                    register(member.getUserId().toString(), getClientType(member.getRoleType()),"");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//                for (ImGroupMember member : groupMembers) {
 | 
	
		
			
				|  |  | +//                    try {
 | 
	
		
			
				|  |  | +//                        register(member.getUserId().toString(), getClientType(member.getRoleType()),"");
 | 
	
		
			
				|  |  | +//                    }catch (Exception e){
 | 
	
		
			
				|  |  | +//                        log.error("用户注册失败",e);
 | 
	
		
			
				|  |  | +//                    }
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  |                  MessageWrapper.ImportGroupMember importGroupMember = new MessageWrapper.ImportGroupMember();
 | 
	
		
			
				|  |  |                  importGroupMember.setGroupId(imGroup.getId());
 | 
	
		
			
				|  |  |                  Date date = new DateTime(imGroup.getCreateTime()).plusSeconds(3).toDate();
 | 
	
	
		
			
				|  | @@ -998,6 +1048,9 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                              MessageWrapper.ImportGroupMemberData data = new MessageWrapper.ImportGroupMemberData();
 | 
	
		
			
				|  |  |                              data.setMemberAccount(getImUserId(next.getUserId().toString(),
 | 
	
		
			
				|  |  |                                      getClientType(next.getRoleType())));
 | 
	
		
			
				|  |  | +                            if (next.getCreateTime() == null){
 | 
	
		
			
				|  |  | +                                next.setCreateTime(DateTime.now().plusMonths(-6).toDate());
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                              if (next.getCreateTime().getTime() / 1000 <= importGroup.getCreateTime()) {
 | 
	
		
			
				|  |  |                                  data.setJoinTime(date.getTime() / 1000);
 | 
	
		
			
				|  |  |                              } else {
 | 
	
	
		
			
				|  | @@ -1011,14 +1064,14 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  imGroupDao.updateImportStatusSuccess(imGroup.getId());
 | 
	
		
			
				|  |  |              } catch (Exception e) {
 | 
	
		
			
				|  |  |                  log.error(String.format("群迁移失败,失败群组:%s", JSON.toJSONString(imGroup)));
 | 
	
		
			
				|  |  | -                log.error(String.format("群迁移失败:%s", e.getMessage()));
 | 
	
		
			
				|  |  | +                log.error("群迁移失败:", e);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              log.info("群迁移成功:{}", imGroup.getId());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void register(String userId, String clientType,String avatar) {
 | 
	
		
			
				|  |  | -        SysUser user = sysUserService.queryUserById(Integer.valueOf(userId));
 | 
	
		
			
				|  |  | +        SysUser user = teacherDao.getUser(Integer.valueOf(userId));
 | 
	
		
			
				|  |  |          if (user == null) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -1039,6 +1092,7 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |  //            imGroupCoreService.register(userId,clientType, username, sysUserService.getImAvatar(user));
 | 
	
		
			
				|  |  |              imGroupCoreService.register(userId,clientType, username, avatar);
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("register user error,userId:{}", userId);
 | 
	
		
			
				|  |  |              log.error("register user error", e);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1064,12 +1118,21 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void importUser() {
 | 
	
		
			
				|  |  |          int page = 1;
 | 
	
		
			
				|  |  | -        int rows = 200;
 | 
	
		
			
				|  |  | +        int rows = 100;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          int count = 0;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // 100个线程的无界线程池
 | 
	
		
			
				|  |  | +        ThreadPoolExecutor executorService =  new ThreadPoolExecutor(100, 100,
 | 
	
		
			
				|  |  | +            0L, TimeUnit.MILLISECONDS,
 | 
	
		
			
				|  |  | +            new LinkedBlockingQueue<Runnable>());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          log.info("------------------------------- import user student ---------------------------");
 | 
	
		
			
				|  |  | +        // 学生花费时间计算
 | 
	
		
			
				|  |  | +        long start = System.currentTimeMillis();
 | 
	
		
			
				|  |  |          List<String[]> student = getStudent(page, rows);
 | 
	
		
			
				|  |  | +        long end = System.currentTimeMillis();
 | 
	
		
			
				|  |  | +        log.info("查询学生花费时间:{}毫秒", end - start);
 | 
	
		
			
				|  |  |          SysConfig studentAvatar = sysConfigService.findByParamName(SysConfigService.STUDENT_DEFAULT_AVATAR);
 | 
	
		
			
				|  |  |          while (!student.isEmpty()) {
 | 
	
		
			
				|  |  |              for (String[] next : student) {
 | 
	
	
		
			
				|  | @@ -1077,8 +1140,17 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(avatar)) {
 | 
	
		
			
				|  |  |                      avatar = studentAvatar.getParanValue();
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                register(next[0], next[1], avatar);
 | 
	
		
			
				|  |  | +                String finalAvatar = avatar;
 | 
	
		
			
				|  |  | +                executorService.execute(() -> {
 | 
	
		
			
				|  |  | +                    register(next[0], next[1], finalAvatar);
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        Thread.sleep(1000);
 | 
	
		
			
				|  |  | +                    } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                        log.error("线程等待异常", e);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              count += student.size();
 | 
	
		
			
				|  |  |              log.info("import im student success count:{}", count);
 | 
	
		
			
				|  |  |              page++;
 | 
	
	
		
			
				|  | @@ -1090,15 +1162,28 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |          count = 0;
 | 
	
		
			
				|  |  |          page = 1;
 | 
	
		
			
				|  |  |          SysConfig staffAvatar = sysConfigService.findByParamName(SysConfigService.USER_DEFAULT_AVATAR);
 | 
	
		
			
				|  |  | +        start = System.currentTimeMillis();
 | 
	
		
			
				|  |  |          List<String[]> staff = getStaff(page, rows);
 | 
	
		
			
				|  |  | +        end = System.currentTimeMillis();
 | 
	
		
			
				|  |  | +        log.info("查询老师花费时间:{}毫秒", end - start);
 | 
	
		
			
				|  |  |          while (!staff.isEmpty()) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              for (String[] next : staff) {
 | 
	
		
			
				|  |  |                  String avatar = next[2];
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(avatar)) {
 | 
	
		
			
				|  |  |                      avatar = staffAvatar.getParanValue();
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                register(next[0], next[1], avatar);
 | 
	
		
			
				|  |  | +                String finalAvatar = avatar;
 | 
	
		
			
				|  |  | +                executorService.execute(() -> {
 | 
	
		
			
				|  |  | +                    register(next[0], next[1], finalAvatar);
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        Thread.sleep(1000);
 | 
	
		
			
				|  |  | +                    } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                        log.error("线程等待异常", e);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              count += staff.size();
 | 
	
		
			
				|  |  |              log.info("import im staff success count:{}", count);
 | 
	
		
			
				|  |  |              page++;
 | 
	
	
		
			
				|  | @@ -1117,7 +1202,15 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(avatar)) {
 | 
	
		
			
				|  |  |                      avatar = empAvatar.getParanValue();
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                register(next[0], next[1], avatar);
 | 
	
		
			
				|  |  | +                String finalAvatar = avatar;
 | 
	
		
			
				|  |  | +                executorService.execute(() -> {
 | 
	
		
			
				|  |  | +                    register(next[0], next[1], finalAvatar);
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        Thread.sleep(1000);
 | 
	
		
			
				|  |  | +                    } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                        log.error("线程等待异常", e);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              count += emps.size();
 | 
	
		
			
				|  |  |              log.info("import im emps success count:{}", count);
 | 
	
	
		
			
				|  | @@ -1136,7 +1229,15 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(avatar)) {
 | 
	
		
			
				|  |  |                      avatar = teacherAvatar.getParanValue();
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                register(next[0], next[1], avatar);
 | 
	
		
			
				|  |  | +                String finalAvatar = avatar;
 | 
	
		
			
				|  |  | +                executorService.execute(() -> {
 | 
	
		
			
				|  |  | +                    register(next[0], next[1], finalAvatar);
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        Thread.sleep(1000);
 | 
	
		
			
				|  |  | +                    } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                        log.error("线程等待异常", e);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              count += teachers.size();
 | 
	
		
			
				|  |  |              log.info("import im teacher success count:{}", count);
 | 
	
	
		
			
				|  | @@ -1144,12 +1245,21 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |              teachers = getTeachers(page, rows);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        while (executorService.getQueue().size() > 0) {
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                log.info("线程池中正在执行的任务数量:{},等待数量:{}", executorService.getActiveCount(),executorService.getQueue().size());
 | 
	
		
			
				|  |  | +                Thread.sleep(1000);
 | 
	
		
			
				|  |  | +            } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                log.error("线程等待异常", e);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        executorService.shutdown();
 | 
	
		
			
				|  |  |          log.info("------------------------------- import user success ---------------------------");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public int queryInfoCount() {
 | 
	
		
			
				|  |  | -        long count = historyMessageService.selectCount(0,new DateTime().plusMonths(-2).toDate());
 | 
	
		
			
				|  |  | +    public int queryInfoCount(int targetType) {
 | 
	
		
			
				|  |  | +        long count = historyMessageService.selectCount(0,new DateTime().plusMonths(-2).toDate(),targetType);
 | 
	
		
			
				|  |  |          return (int) count;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1211,8 +1321,8 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public com.yonge.mongodb.PageInfo<HistoryMessage> getRongYunInfo( int page, int size) {
 | 
	
		
			
				|  |  | -        com.yonge.mongodb.PageInfo<HistoryMessage> pageInfo = historyMessageService.selectPage(page, size, 0,new DateTime().plusMonths(-2).toDate());
 | 
	
		
			
				|  |  | +    public com.yonge.mongodb.PageInfo<HistoryMessage> getRongYunInfo(int page, int size, int targetType) {
 | 
	
		
			
				|  |  | +        com.yonge.mongodb.PageInfo<HistoryMessage> pageInfo = historyMessageService.selectPage(page, size, 0,new DateTime().plusMonths(-2).toDate(),targetType);
 | 
	
		
			
				|  |  |          //List<HistoryMessage> imHistoryMessageslist = imGroupDao.selectAll(result,size);
 | 
	
		
			
				|  |  |          return pageInfo;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1226,7 +1336,7 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |      public void importInfo(List<HistoryMessage> info) throws Exception {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          for (HistoryMessage i : info) {//判断消息类型
 | 
	
		
			
				|  |  | -            log.info("消息导入 HistoryMessage:{}", JSON.toJSONString(i));
 | 
	
		
			
				|  |  | +//            log.info("消息导入 HistoryMessage:{}", JSON.toJSONString(i));
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  Integer type = i.getTargetType();
 | 
	
		
			
				|  |  |                  if (type == 1) {
 | 
	
	
		
			
				|  | @@ -1262,8 +1372,21 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                      //设置接收人
 | 
	
		
			
				|  |  |                      privateImportMessage.setToAccount(targetIdUserId);
 | 
	
		
			
				|  |  |                      //设置随机数
 | 
	
		
			
				|  |  | -                    privateImportMessage.setMsgRandom(new Random().nextInt());
 | 
	
		
			
				|  |  | +                    if (i.getMsgRandom() == null) {
 | 
	
		
			
				|  |  | +                        int nextInt = Math.abs(new Random().nextInt());
 | 
	
		
			
				|  |  | +                        privateImportMessage.setMsgRandom(nextInt);
 | 
	
		
			
				|  |  | +                        i.setMsgRandom(nextInt);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        privateImportMessage.setMsgRandom(i.getMsgRandom());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                    if (i.getMsgSeq() == null) {
 | 
	
		
			
				|  |  | +                        int nextInt = Math.abs(new Random().nextInt());
 | 
	
		
			
				|  |  | +                        i.setMsgSeq(nextInt);
 | 
	
		
			
				|  |  | +                        privateImportMessage.setMsgSeq(nextInt);
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        privateImportMessage.setMsgSeq(i.getMsgSeq());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                      //设置发送时间
 | 
	
		
			
				|  |  |                      String time = i.getDateTime();
 | 
	
		
			
				|  |  |                      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
	
		
			
				|  | @@ -1271,7 +1394,13 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                          Date date = df.parse(time);
 | 
	
		
			
				|  |  |                          long dateTime = date.getTime();
 | 
	
		
			
				|  |  |                          dateTime = dateTime / (1000);
 | 
	
		
			
				|  |  | -                        privateImportMessage.setMsgTimeStamp(dateTime);
 | 
	
		
			
				|  |  | +                        if (i.getMsgTimeStamp() == null) {
 | 
	
		
			
				|  |  | +                            privateImportMessage.setMsgTimeStamp(dateTime);
 | 
	
		
			
				|  |  | +                            i.setMsgTimeStamp(dateTime);
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            privateImportMessage.setMsgTimeStamp(i.getMsgTimeStamp());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      } catch (ParseException e) {
 | 
	
		
			
				|  |  |                          e.printStackTrace();
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -1316,6 +1445,8 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                          imPluginContext.getPluginService().importPrivateMessage(privateImportMessage);
 | 
	
		
			
				|  |  |                          //为已导入数据更改标识
 | 
	
		
			
				|  |  |                          updateStatus(i,1);
 | 
	
		
			
				|  |  | +                        historyMessageService.updateMsg(i.getMsgUID(),i.getMsgSeq(),i.getMsgRandom(),i.getMsgTimeStamp());
 | 
	
		
			
				|  |  | +                        log.info("导入私聊消息成功");
 | 
	
		
			
				|  |  |                      } catch (Exception e) {
 | 
	
		
			
				|  |  |                          updateStatus(i,2);
 | 
	
		
			
				|  |  |                          log.error("导入私聊IM消息失败 msg:{},entity:{}", list, i, e);
 | 
	
	
		
			
				|  | @@ -1392,11 +1523,11 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                          imPluginContext.getPluginService().importGroupMessage(groupImportMessage);
 | 
	
		
			
				|  |  |                          //为已导入数据更改标识
 | 
	
		
			
				|  |  |                          updateStatus(i,1);
 | 
	
		
			
				|  |  | +                        log.info("导入消息成功");
 | 
	
		
			
				|  |  |                      } catch (Exception e) {
 | 
	
		
			
				|  |  |                          updateStatus(i,2);
 | 
	
		
			
				|  |  |                          log.error("导入群组IM消息失败 msg:{},entity:{}", list, i, e);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    log.info("导入消息成功:{}", i);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }catch (Exception e) {
 | 
	
		
			
				|  |  |                  log.error("导入消息失败:", e);
 | 
	
	
		
			
				|  | @@ -1432,14 +1563,22 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |                  tencent.setGroupId(historyMessage.getGroupId());
 | 
	
		
			
				|  |  |                  bodyList = getGroupMessage(historyMessage,jsonObject);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                historyMessage.setSyncFlag(1);
 | 
	
		
			
				|  |  | +                historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (CollectionUtils.isEmpty(bodyList)) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                historyMessage.setSyncFlag(1);
 | 
	
		
			
				|  |  | +                historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              bodyList = bodyList.stream().filter(Objects::nonNull).collect(Collectors.toList());
 | 
	
		
			
				|  |  |              if (CollectionUtils.isEmpty(bodyList)) {
 | 
	
		
			
				|  |  | +                historyMessage.setSyncFlag(1);
 | 
	
		
			
				|  |  | +                historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 发送人
 | 
	
	
		
			
				|  | @@ -1472,7 +1611,7 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |              String content = jsonObject.getString("content");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // http开头的链接 扩展字段没有值 放在扩展字段里
 | 
	
		
			
				|  |  | -            if (content.startsWith("http")) {
 | 
	
		
			
				|  |  | +            if (StringUtils.isNotBlank(content) && content.startsWith("http")) {
 | 
	
		
			
				|  |  |                  String extra = jsonObject.getString("extra");
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(extra)) {
 | 
	
		
			
				|  |  |                      jsonObject.put("extra", content);
 | 
	
	
		
			
				|  | @@ -1550,7 +1689,7 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
 | 
	
		
			
				|  |  |              String content = jsonObject.getString("content");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // http开头的链接 扩展字段没有值 放在扩展字段里
 | 
	
		
			
				|  |  | -            if (content.startsWith("http")) {
 | 
	
		
			
				|  |  | +            if (StringUtils.isNotBlank(content) && content.startsWith("http")) {
 | 
	
		
			
				|  |  |                  String extra = jsonObject.getString("extra");
 | 
	
		
			
				|  |  |                  if (StringUtils.isEmpty(extra)) {
 | 
	
		
			
				|  |  |                      jsonObject.put("extra", content);
 |