|
|
@@ -491,23 +491,55 @@ public class GoGenerateService {
|
|
|
// .findFirst()
|
|
|
// .ifPresent(item -> item.setV(image.image())));
|
|
|
// }
|
|
|
- // 文本
|
|
|
- List<Material> t3 = f.getT3().stream().filter(ft -> Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
- if (Objects.nonNull(t3) && !t3.isEmpty()) {
|
|
|
- Optional.ofNullable(t3.get(RandomUtil.randomInt(0, t3.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
+ //文本
|
|
|
+ List<Material> t3 = f.getT3().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t3) &&!t3.isEmpty()) {
|
|
|
+ List<Integer> collect = t3.stream().map(Material::groupTypeId).distinct().collect(Collectors.toList());
|
|
|
+ List<Long> collect1 = goRequest.getItem().stream()
|
|
|
.filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
- .findFirst()
|
|
|
- .ifPresent(item -> {
|
|
|
- item.setV(material.content());
|
|
|
- }));
|
|
|
- } else {
|
|
|
+ .map(Item::getGroupTypeIdSc)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(collect.size() != collect1.size()){
|
|
|
+ return Mono.error(new BaseException("文本素材个数不匹配"));
|
|
|
+ }
|
|
|
+ goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .forEach(fe->{
|
|
|
+ List<Material> collect2 = t3.stream()
|
|
|
+ .filter(fter -> Long.valueOf(fter.groupTypeId()).equals(fe.getGroupTypeIdSc()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Material material = collect2.get(RandomUtil.randomInt(0, collect2.size()));
|
|
|
+ if (Objects.isNull(material)) {
|
|
|
+ throw new BaseException("图片素材为空");
|
|
|
+ }
|
|
|
+ fe.setV(material.content());
|
|
|
+ });
|
|
|
+ }else{
|
|
|
Optional<Item> first1 = goRequest.getItem().stream()
|
|
|
.filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst();
|
|
|
if (first1.isPresent()) {
|
|
|
- throw new BaseException("文字素材为空");
|
|
|
+ return Mono.error(new BaseException("文字素材为空"));
|
|
|
}
|
|
|
}
|
|
|
+ // 文本
|
|
|
+// List<Material> t3 = f.getT3().stream().filter(ft -> Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+// if (Objects.nonNull(t3) && !t3.isEmpty()) {
|
|
|
+// Optional.ofNullable(t3.get(RandomUtil.randomInt(0, t3.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
+// .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+// .findFirst()
|
|
|
+// .ifPresent(item -> {
|
|
|
+// item.setV(material.content());
|
|
|
+// }));
|
|
|
+// } else {
|
|
|
+// Optional<Item> first1 = goRequest.getItem().stream()
|
|
|
+// .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+// .findFirst();
|
|
|
+// if (first1.isPresent()) {
|
|
|
+// throw new BaseException("文字素材为空");
|
|
|
+// }
|
|
|
+// }
|
|
|
// if( Objects.nonNull(f.getT3()) &&!f.getT3().isEmpty()){
|
|
|
// Optional.ofNullable(f.getT3().get(RandomUtil.randomInt(0,f.getT3().size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
// .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|