zouxuan 4 年之前
父节点
当前提交
f2f25293fc

+ 0 - 10
mec-common/audit-log/src/main/java/com/yonge/log/dal/model/HistoryMessage.java

@@ -8,8 +8,6 @@ import java.io.Serializable;
 @Document(collection = "im_history_message")
 public class HistoryMessage implements Serializable {
     @Id
-    private String id;
-
     private String msgUID;
 
     private String fromUserId;
@@ -38,14 +36,6 @@ public class HistoryMessage implements Serializable {
 
     private String content;
 
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
     public String getFromUserId() {
         return fromUserId;
     }

+ 4 - 4
mec-common/audit-log/src/main/java/com/yonge/log/service/impl/HistoryMessageServiceImpl.java

@@ -50,8 +50,8 @@ public class HistoryMessageServiceImpl extends BaseServiceImplWithMongo<String,
 			zin = new ZipInputStream(new FileInputStream(file), StandardCharsets.UTF_8);
 			ZipFile zf = new ZipFile(file);
 			ZipEntry ze;
-			while ((ze = zin.getNextEntry()) != null) {
 			List<HistoryMessage> historyMessages = new ArrayList<>();
+			while ((ze = zin.getNextEntry()) != null) {
 				BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze)));
 				String line;
 				while ((line = br.readLine()) != null) {
@@ -65,12 +65,12 @@ public class HistoryMessageServiceImpl extends BaseServiceImplWithMongo<String,
 						e.printStackTrace();
 					}
 				}
-				if(historyMessages.size() > 0){
-					historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
-				}
 				br.close();
 				break;
 			}
+			if(historyMessages.size() > 0){
+				historyMessageDao.batchInsert(historyMessages,HistoryMessage.class);
+			}
 		} catch (IOException e) {
 			e.printStackTrace();
 		} finally {

+ 6 - 6
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -120,17 +120,17 @@ public class TaskController extends BaseController {
 	@GetMapping(value = "/syncImHistoryMessageTask")
 	// 同步即时通讯聊天记录
 	public void syncImHistoryMessageTask(String date) throws Exception {
-		date = "2021060710";
+//		date = "2021060214";
 		if(date == null){
 			date = DateUtil.format(DateUtil.addHours(new Date(),-2), DateUtil.YEAR_MONTH_DAY_HOUR);
 		}
 		Object o = imFeignService.historyGet(date);
 		JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o));
 		if(jsonObject.get("code").equals(200)){
-//			Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + date,date);
-//			if(!success){
-//				return;
-//			}
+			Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + date,date);
+			if(!success){
+				return;
+			}
 			String url = jsonObject.getString("url");
 			if(StringUtils.isEmpty(url)){
 				return;
@@ -139,7 +139,7 @@ public class TaskController extends BaseController {
 //			File file = new File("/Users/chenxiaoyu/Documents/" + url.substring(url.lastIndexOf("/")));
 			URL url1 = new URL(url);
 			FileUtils.copyURLToFile(url1,file);
-//			UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
+			UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
 			historyMessageService.saveImHistoryMessage(new File(file.getAbsolutePath()));
 		}
 	}