|
@@ -1,11 +1,15 @@
|
|
|
package com.ym.mec.web.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.biz.dal.enums.IndexDataType;
|
|
|
import com.ym.mec.biz.event.source.CourseEventSource;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.UploadReturnBean;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.redis.service.RedisCache;
|
|
|
+import com.ym.mec.im.ImFeignService;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import com.yonge.log.service.HistoryMessageService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -15,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RequestMapping("task")
|
|
@@ -107,13 +112,30 @@ public class TaskController extends BaseController {
|
|
|
private HistoryMessageService historyMessageService;
|
|
|
@Autowired
|
|
|
private UploadFileService uploadFileService;
|
|
|
+ @Autowired
|
|
|
+ private ImFeignService imFeignService;
|
|
|
|
|
|
@GetMapping(value = "/syncImHistoryMessageTask")
|
|
|
// 同步即时通讯聊天记录
|
|
|
- public void syncImHistoryMessageTask(){
|
|
|
-// File file = new File(fileDir);
|
|
|
-// UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
|
|
|
-// historyMessageService.saveImHistoryMessage(file);
|
|
|
+ public void syncImHistoryMessageTask(String date) throws Exception {
|
|
|
+ if(date == null){
|
|
|
+ date = DateUtil.format(new Date(), 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;
|
|
|
+ }
|
|
|
+ String url = jsonObject.getString("url");
|
|
|
+ if(StringUtils.isEmpty(url)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File file = new File(url);
|
|
|
+ UploadReturnBean uploadReturnBean = uploadFileService.uploadImHistoryMsgFile(file);
|
|
|
+ historyMessageService.saveImHistoryMessage(file);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/autoAffirmReceiveTask")
|