Selaa lähdekoodia

同步im聊天记录

zouxuan 4 vuotta sitten
vanhempi
commit
fa6584d3e0

+ 2 - 1
mec-client-api/src/main/java/com/ym/mec/im/ImFeignService.java

@@ -15,6 +15,7 @@ import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.im.entity.GroupModel;
 import com.ym.mec.im.fallback.ImFeignServiceFallback;
+import org.springframework.web.bind.annotation.RequestParam;
 
 @FeignClient(name = "im-server", configuration = FeignConfiguration.class, fallback = ImFeignServiceFallback.class)
 public interface ImFeignService {
@@ -116,5 +117,5 @@ public interface ImFeignService {
 	 * @return
 	 */
 	@PostMapping(value = "history/get")
-	Object historyGet(String date);
+	Object historyGet(@RequestParam("date") String date);
 }

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

@@ -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);
 		}