|
|
@@ -35,10 +35,7 @@ import reactor.core.publisher.Flux;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -348,6 +345,56 @@ public class PlanNewController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 海报模版复制
|
|
|
+ *
|
|
|
+ * @param posterTemplateId
|
|
|
+ * @return {@link Mono}<{@link RStatus}<{@link Long}>>
|
|
|
+ */
|
|
|
+ @GetMapping("copyPosterTemById/{posterTemplateId}")
|
|
|
+ public Mono<RStatus<Long>> copyPosterTemById(@PathVariable("posterTemplateId") @NotNull Long posterTemplateId) {
|
|
|
+ String userName = BaseContextHandler.getUserName();
|
|
|
+ String userId = BaseContextHandler.getUserId();
|
|
|
+ Mono<Long> longMono = template.selectOne(Query.query(Criteria.where("poster_template_id")
|
|
|
+ .is(posterTemplateId)), PosterTemplate.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("通过海报模版id查询 返回结果为空")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new BaseException("查询异常" + throwable.getMessage())))
|
|
|
+ .flatMap(fm -> {
|
|
|
+ PosterTemplate posterTemplate = new PosterTemplate(null,
|
|
|
+ fm.posterTemplateName() +"-"+ goGenerateService.get7Str(),
|
|
|
+ userName,
|
|
|
+ userId,
|
|
|
+ ZonedDateTime.now(),
|
|
|
+ null);
|
|
|
+ Mono<PosterTemplate> insert = template.insert(posterTemplate);
|
|
|
+ Mono<List<Poster>> poster_template_id1 = template.select(Query.query(Criteria
|
|
|
+ .where("poster_template_id").is(posterTemplateId)), Poster.class).collectList().switchIfEmpty(Mono.just(List.of()));
|
|
|
+ return Mono.zip(insert, poster_template_id1).flatMap(f -> {
|
|
|
+ PosterTemplate t1 = f.getT1();
|
|
|
+ List<Poster> t2 = f.getT2();
|
|
|
+ Mono<List<Poster>> listMono ;
|
|
|
+ if (!t2.isEmpty()) {
|
|
|
+ listMono = Flux.fromIterable(t2).flatMap(fm1 -> {
|
|
|
+ Poster poster = new Poster(null,
|
|
|
+ t1.posterTemplateId(),
|
|
|
+ fm1.posterTemplate(),
|
|
|
+ userName,
|
|
|
+ userId,
|
|
|
+ ZonedDateTime.now(),
|
|
|
+ null,
|
|
|
+ fm1.generateImagesJson(),
|
|
|
+ fm1.generateImagesUrl());
|
|
|
+ return template.insert(poster);
|
|
|
+ }).collectList();
|
|
|
+ }else {
|
|
|
+ listMono = Mono.just(List.of());
|
|
|
+ }
|
|
|
+ return Mono.zip(listMono, Mono.just(t1)).flatMap(end -> Mono.just(end.getT2().posterTemplateId()));
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return RStatus.success(longMono);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 海报模版-编辑回显详情
|
|
|
*
|
|
|
* @param posterTemplateId
|