Commit 21644c07 by 翟柏林

[chg]解决视频转发的bug

1 parent e4e2862d
...@@ -13,6 +13,8 @@ import org.springframework.stereotype.Component; ...@@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; 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 ...@@ -35,13 +37,14 @@ public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, F
if (allForward == null || allForward.size() == 0) { if (allForward == null || allForward.size() == 0) {
return null; return null;
} }
List<Forward> forwardList = allForward.stream().filter(forward -> forward.getStatus() == 0).collect(Collectors.toList());
String eventType = item.getString("event_type"); String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate"); String eventCate = item.getString("event_cate");
ForwardContent forwardContent = new ForwardContent(); ForwardContent forwardContent = new ForwardContent();
forwardContent.setJson(item.toJSONString()); forwardContent.setJson(item.toJSONString());
forwardContent.setForwardList(allForward); forwardContent.setForwardList(forwardList);
return forwardContent; return forwardContent;
} }
......
...@@ -29,6 +29,7 @@ import javax.annotation.Resource; ...@@ -29,6 +29,7 @@ import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.time.Duration; import java.time.Duration;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* . * .
...@@ -92,16 +93,19 @@ public class DataReceiveController { ...@@ -92,16 +93,19 @@ public class DataReceiveController {
} }
FileUtils.copyToFile(videoResult.getFile().getInputStream(), file); FileUtils.copyToFile(videoResult.getFile().getInputStream(), file);
videoResult.setFile(null); 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) { if (forward.getStatus() == 1) {
ForwardApp.THREAD_POOL_EXECUTOR.submit(() -> { ForwardApp.THREAD_POOL_EXECUTOR.submit(() -> {
try { try {
log.info("需要转发的地址的为{}",forward.getUrl());
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("refid", videoResult.getRefid()); param.add("refid", videoResult.getRefid());
param.add("format", videoResult.getFormat()); param.add("format", videoResult.getFormat());
param.add("file", new FileSystemResource(file)); 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)); String block = response.block(Duration.ofSeconds(10));
log.info("发送视频文件完成,对接名称:[{}],结果:[{}]", forward.getName(), block); log.info("发送视频文件完成,对接名称:[{}],结果:[{}]", forward.getName(), block);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component; ...@@ -7,8 +7,10 @@ import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Base64; import java.util.Base64;
import java.util.Date; import java.util.Date;
import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -50,7 +52,10 @@ public class PicUtils { ...@@ -50,7 +52,10 @@ public class PicUtils {
int i = unid.hashCode(); int i = unid.hashCode();
i ^= (i >>> 16); i ^= (i >>> 16);
i = 127 & i; 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; 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!