Commit 21644c07 by 翟柏林

[chg]解决视频转发的bug

1 parent e4e2862d
......@@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* .
......@@ -35,13 +37,14 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F
if (allForward == null || allForward.size() == 0) {
return null;
}
List<Forward> forwardList = allForward.stream().filter(forward -> forward.getStatus() == 0).collect(Collectors.toList());
String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate");
ForwardContent forwardContent = new ForwardContent();
forwardContent.setJson(item.toJSONString());
forwardContent.setForwardList(allForward);
forwardContent.setForwardList(forwardList);
return forwardContent;
}
......
......@@ -29,6 +29,7 @@ import javax.annotation.Resource;
import java.io.File;
import java.time.Duration;
import java.util.Date;
import java.util.List;
/**
* .
......@@ -92,16 +93,19 @@ public class DataReceiveController {
}
FileUtils.copyToFile(videoResult.getFile().getInputStream(), file);
videoResult.setFile(null);
for (Forward forward : cacheUtils.getAllForward()) {
List<Forward> allForward = cacheUtils.getAllForward();
log.info("需要转发的地址的数量为{},分别为{}",allForward.size(),allForward);
for (Forward forward : allForward) {
if (forward.getStatus() == 1) {
ForwardApp.THREAD_POOL_EXECUTOR.submit(() -> {
try {
log.info("需要转发的地址的为{}",forward.getUrl());
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("refid", videoResult.getRefid());
param.add("format", videoResult.getFormat());
param.add("file", new FileSystemResource(file));
Mono<String> response = WebClientUtils.buildClient(null).post().uri(forward.getUrl()).contentType(MediaType.MULTIPART_FORM_DATA).contentLength(file.length()).body(BodyInserters.fromMultipartData(param)).retrieve().bodyToMono(String.class);
Mono<String> response = WebClientUtils.buildClient(null).post().uri(forward.getUrl()).contentType(MediaType.MULTIPART_FORM_DATA).body(BodyInserters.fromMultipartData(param)).retrieve().bodyToMono(String.class);
String block = response.block(Duration.ofSeconds(10));
log.info("发送视频文件完成,对接名称:[{}],结果:[{}]", forward.getName(), block);
} catch (Exception e) {
......
......@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.TimeZone;
import java.util.UUID;
/**
......@@ -50,7 +52,10 @@ public class PicUtils {
int i = unid.hashCode();
i ^= (i >>> 16);
i = 127 & i;
String dateStr = DateUtil.format("yyyyMMdd", date);
//String dateStr = DateUtil.format("yyyyMMdd", date);
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyyMMdd");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
String dateStr = simpleDateFormat.format(date);
return basePath + File.separator + dateStr + File.separator + i + File.separator + unid + "." + format;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!