|
@@ -11,6 +11,7 @@ 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.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.net.URL;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -118,12 +120,13 @@ public class TaskController extends BaseController {
|
|
|
@GetMapping(value = "/syncImHistoryMessageTask")
|
|
|
// 同步即时通讯聊天记录
|
|
|
public void syncImHistoryMessageTask(String date) throws Exception {
|
|
|
+ date = "2021060214";
|
|
|
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")){
|
|
|
+ if(jsonObject.get("code").equals(200)){
|
|
|
Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + date,date);
|
|
|
if(!success){
|
|
|
return;
|
|
@@ -132,7 +135,10 @@ public class TaskController extends BaseController {
|
|
|
if(StringUtils.isEmpty(url)){
|
|
|
return;
|
|
|
}
|
|
|
- File file = new File(url);
|
|
|
+ File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
|
|
|
+// 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);
|
|
|
historyMessageService.saveImHistoryMessage(file);
|
|
|
}
|