| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.yonge.cooleshow.biz.dal.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.IdWorker; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.google.common.collect.Lists; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -14,14 +15,15 @@ import com.yonge.cooleshow.biz.dal.dao.ImGroupDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dao.ImGroupMemberAuditDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dto.ImGroupResultDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.dto.ImGroupSearchDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.entity.CourseGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.entity.ImGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.entity.ImGroupMember; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.entity.Teacher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.ClientEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.ImGroupType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.entity.Teacher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.enums.ClientEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.enums.ImGroupType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.entity.StudentStar; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.CourseGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.ImGroupMemberService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -33,6 +35,9 @@ import com.yonge.cooleshow.biz.dal.service.TeacherService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.base.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.base.util.ThreadPool; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.rong.RongCloud; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.rong.methods.message.history.History; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import io.rong.models.Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.rong.models.group.GroupMember; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.rong.models.group.GroupModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections.CollectionUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -42,20 +47,20 @@ import org.redisson.api.RedissonClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.charset.StandardCharsets; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.MessageFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Collections; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Optional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Set; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.UUID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.concurrent.TimeUnit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.zip.ZipEntry; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.zip.ZipFile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.zip.ZipInputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 即时通讯群组(ImGroup)表服务实现类 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -102,6 +107,13 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ImConfigProperties imConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${cn.rongcloud.im.appkey}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String appKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${cn.rongcloud.im.secret}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String appSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SysConfigService sysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -532,5 +544,65 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return group; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 同步即时通讯聊天记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param date 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Result historyGet(String date) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return getHistory().get(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void saveImHistoryMessage(File file)  { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ZipInputStream zin = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            zin = new ZipInputStream(new FileInputStream(file), StandardCharsets.UTF_8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ZipFile zf = new ZipFile(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ZipEntry ze; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Set<ImHistoryMessage> historyMessages = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            while ((ze = zin.getNextEntry()) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String line; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                while ((line = br.readLine()) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        historyMessages.add(JSONObject.parseObject(line.substring(line.indexOf("{")), ImHistoryMessage.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//						if(historyMessages.size() >= 2000){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//							historyMessageDao.batchInsert(new ArrayList<>(historyMessages),HistoryMessage.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//							historyMessages.clear(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                br.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(historyMessages.size() > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //imGroupDao.batchInsert(historyMessages.stream().sorted(Comparator.comparing(ImHistoryMessage::getDateTime)).collect(Collectors.toList()),HistoryMessage.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } finally { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (zin != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    zin.closeEntry(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } catch (IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private History getHistory(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        History history = new History(appKey, appSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        history.setRongCloud(rongCloud); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return history; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |