|
|
@@ -78,51 +78,90 @@ public class GoGenerateService {
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);//cusqrcode
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
+ Mono<Poster> posterMono1 ;
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
-// // 背景
|
|
|
-// Mono<List<Image>> bgImage = getBgImage();
|
|
|
-// //封面
|
|
|
-// Mono<List<Image>> fmImage = getFmImageLists0();
|
|
|
-// //文字
|
|
|
-// Mono<List<Material>> text = getTextLists();
|
|
|
- Mono<Poster> posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists()))
|
|
|
+ posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()))
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
.flatMap(f -> template.insert(f));
|
|
|
- return RStatus.success(posterMono1);
|
|
|
}else {
|
|
|
- Mono<Poster> posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
+ posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))))
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
.flatMap(f -> template.insert(f));
|
|
|
- return RStatus.success(posterMono1);
|
|
|
+ // return RStatus.success(posterMono1);
|
|
|
}
|
|
|
+ return RStatus.success(posterMono1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 群封面
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Mono<List<Image>> getImageType1(){
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(1)), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
private Mono<List<Material>> getTextLists() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(1)), Material.class).collectList();
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(14)), Material.class).collectList();
|
|
|
}
|
|
|
|
|
|
private Mono<List<Image>> getBgImage() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(2)), Image.class).collectList();
|
|
|
}
|
|
|
+ public Mono<String> getOutTemPoster(GoRequest goRequest,Mono<List<StringBuilder>> stringBuilderMono){
|
|
|
+ return getStringMonoOut(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1());
|
|
|
+ }
|
|
|
|
|
|
- private Mono<String> getStringMono(GoRequest goRequest, Mono<List<StringBuilder>> stringBuilderMono, Mono<List<Image>> bgImage, Mono<List<Image>> fmImage, Mono<List<Material>> text) {
|
|
|
- Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono).flatMap(f -> {
|
|
|
+ public Mono<String> getStringMonoOut(GoRequest goRequest, Mono<List<StringBuilder>> stringBuilderMono,
|
|
|
+ Mono<List<Image>> bgImage, Mono<List<Image>> fmImage, Mono<List<Material>> text,Mono<List<Image>> fm1) {
|
|
|
+ Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1).flatMap(f -> {
|
|
|
List<StringBuilder> t4 = f.getT4();
|
|
|
+
|
|
|
+ // System.out.println(t4);
|
|
|
+ Optional<Image> first = f.getT1().stream().findFirst();
|
|
|
+ first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
+ //封面
|
|
|
+ goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst()
|
|
|
+ .ifPresent(item -> item.setV(f.getT5().get(RandomUtil.randomInt(0, f.getT5().size())).image()));
|
|
|
+ //图片
|
|
|
+ Optional.ofNullable(f.getT2().get(RandomUtil.randomInt(0, f.getT2().size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom() )
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(item -> item.setV(image.image())));
|
|
|
+ //文本
|
|
|
+ Optional.ofNullable(f.getT3().get(RandomUtil.randomInt(0,f.getT3().size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(item -> item.setV(material.content())));
|
|
|
+ String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
+ // String s = goGenerateStr(s1);
|
|
|
+ return Mono.just(s1);
|
|
|
+ });
|
|
|
+ return stringMono;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Mono<String> getStringMono(GoRequest goRequest, Mono<List<StringBuilder>> stringBuilderMono,
|
|
|
+ Mono<List<Image>> bgImage, Mono<List<Image>> fmImage, Mono<List<Material>> text,Mono<List<Image>> fm1) {
|
|
|
+ Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1).flatMap(f -> {
|
|
|
+ List<StringBuilder> t4 = f.getT4();
|
|
|
+
|
|
|
// System.out.println(t4);
|
|
|
Optional<Image> first = f.getT1().stream().findFirst();
|
|
|
first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
- Optional<Image> first1 = f.getT2().stream().findFirst();
|
|
|
- first1.ifPresent(image -> goRequest.getItem().stream()
|
|
|
- .filter(ff -> "image".equals(ff.getT()))
|
|
|
+ //封面
|
|
|
+ goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst()
|
|
|
+ .ifPresent(item -> item.setV(f.getT5().get(RandomUtil.randomInt(0, f.getT5().size())).image()));
|
|
|
+ //图片
|
|
|
+ Optional.ofNullable(f.getT2().get(RandomUtil.randomInt(0, f.getT2().size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom() )
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> item.setV(image.image())));
|
|
|
- Optional<Material> first2 = f.getT3().stream().findFirst();
|
|
|
- first2.ifPresent(material -> goRequest.getItem().stream()
|
|
|
- .filter(ff -> "text".equals(ff.getT()))
|
|
|
+ //文本
|
|
|
+ Optional.ofNullable(f.getT3().get(RandomUtil.randomInt(0,f.getT3().size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "text".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> item.setV(material.content())));
|
|
|
String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
@@ -132,7 +171,7 @@ public class GoGenerateService {
|
|
|
return stringMono;
|
|
|
}
|
|
|
|
|
|
- private Mono<List<StringBuilder>> getStringBuilderMono(GoRequest goRequest) {
|
|
|
+ public Mono<List<StringBuilder>> getStringBuilderMono(GoRequest goRequest) {
|
|
|
List<Item> collect = goRequest.getItem().stream().filter(f -> "cusqrcode".equals(f.getT()) && Objects.nonNull(f.getPlanId()) && f.getIsRandom()).collect(Collectors.toList());
|
|
|
Mono<List<StringBuilder>> stringBuilderMono =null;
|
|
|
if (Objects.nonNull(collect) && !collect.isEmpty()) {
|
|
|
@@ -294,7 +333,7 @@ public class GoGenerateService {
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists()),posterRequset)
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1()),posterRequset)
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
.flatMap(f -> template.update(f));
|
|
|
@@ -311,7 +350,7 @@ public class GoGenerateService {
|
|
|
}
|
|
|
|
|
|
private Mono<List<Image>> getFmImageLists0() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(1)), Image.class).collectList();
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(10)), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
}
|