|
|
@@ -15,6 +15,7 @@ import com.webflux.launchadmin.mysql.controller.planNew.req.PlanReq;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.PosterRequest;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.req.ServiceGroupSettingItemRequest;
|
|
|
import com.webflux.launchadmin.mysql.controller.planNew.res.PosterRes;
|
|
|
+import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
|
import com.webflux.launchadmin.mysql.entity.planNew.*;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
|
|
|
@@ -28,13 +29,11 @@ import org.springframework.data.relational.core.query.Update;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
+import reactor.core.publisher.Flux;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
@@ -80,7 +79,7 @@ public class GoGenerateService {
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);//cusqrcode
|
|
|
- Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
+ Mono<List<StringBuilder>> stringBuilderMono = setCusqrcodeSetV(goRequest);//getStringBuilderMono(goRequest);
|
|
|
|
|
|
List<Item> imageGroup = goRequest.getItem().stream().filter(ft -> "image".equals(ft.getT()) && ft.getIsRandom()).collect(Collectors.toList());
|
|
|
ArrayList<Long> imageGroupId = new ArrayList<>();
|
|
|
@@ -848,11 +847,11 @@ public class GoGenerateService {
|
|
|
) {
|
|
|
Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1,textTitle).flatMap(f -> {
|
|
|
List<StringBuilder> t4 = f.getT4();
|
|
|
- if (Objects.nonNull(t4) && !t4.isEmpty()) {
|
|
|
- goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("H5二维码"));
|
|
|
- }else{
|
|
|
- goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("客服二维码"));
|
|
|
- }
|
|
|
+// if (Objects.nonNull(t4) && !t4.isEmpty()) {
|
|
|
+// goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("H5二维码"));
|
|
|
+// }else{
|
|
|
+// goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("客服二维码"));
|
|
|
+// }
|
|
|
Optional<Item> first2 = goRequest.getItem()
|
|
|
.stream().filter(fc -> "cusqrcode".equals(fc.getT()) && (Objects.isNull(fc.getV()) || "".equals(fc.getV()))).findFirst();
|
|
|
if (first2.isPresent()) {
|
|
|
@@ -970,9 +969,83 @@ public class GoGenerateService {
|
|
|
return stringMono;
|
|
|
}
|
|
|
|
|
|
+ public Mono<List<StringBuilder>> setCusqrcodeSetV(GoRequest goRequest) {
|
|
|
+ goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("客服二维码"));
|
|
|
+ List<Item> collect0 = goRequest.getItem()
|
|
|
+ .stream()
|
|
|
+ .filter(f -> "cusqrcode".equals(f.getT()) && f.getIsRandom())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ long count = collect0.stream().filter(f -> Objects.isNull(f.getType()) || Objects.isNull(f.getPlanId())).count();
|
|
|
+ if (count > 0) {
|
|
|
+ throw new BaseException("自定义二维码存在planId,type错误");
|
|
|
+ }
|
|
|
+ if (!collect0.isEmpty()) {
|
|
|
+ Flux<Item> itemFlux = Flux.fromIterable(collect0);
|
|
|
+ return itemFlux.flatMap(ftm -> {
|
|
|
+ Long planId = ftm.getPlanId();
|
|
|
+ Long type = ftm.getType();
|
|
|
+ String column;
|
|
|
+ if (1 == type) {
|
|
|
+ column = "plan_new_id";
|
|
|
+ } else if (2 == type) {
|
|
|
+ column = "listenig_plan_new_id";
|
|
|
+ } else {
|
|
|
+ throw new BaseException("type错误::" + type);
|
|
|
+ }
|
|
|
+ Query query = Query.query(Criteria.where(column).is(planId)).columns("group_id", "code");
|
|
|
+ Mono<StringBuilder> stringMono;
|
|
|
+ if (1 == type) {
|
|
|
+ stringMono = template.selectOne(query, PlanNew.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划查询::PlanId 返回空结果::" + planId)))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+ .flatMap(f1 -> {
|
|
|
+ String code = f1.code();
|
|
|
+ return getDomainSetV(ftm, planId, type, f1.groupId(), code);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ stringMono = template.selectOne(query, ListeningPlanNew.class)
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("自定义二维码:听书计划查询::PlanId 返回空结果::" + planId)))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
+ .flatMap(f1 -> {
|
|
|
+ String code = f1.code();
|
|
|
+ return getDomainSetV(ftm, planId, type, f1.groupId(), code);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return stringMono;
|
|
|
+ }).collectList();
|
|
|
+ }
|
|
|
+ return Mono.just(List.of(new StringBuilder("无自定义二维码 随机事件")));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Mono<StringBuilder> getDomainSetV(Item ftm, Long planId, Long type, Long groupId, String code) {
|
|
|
+ return template.select(Query.query(Criteria.where("group_type_id").is(groupId)
|
|
|
+ .and("status").is(1)
|
|
|
+ .and("type").is(1)
|
|
|
+ .and("deleted_at").isNull()), DomainSelect.class)
|
|
|
+ .collectList()
|
|
|
+ .switchIfEmpty(Mono.error(new BaseException("自定义二维码:裂变计划类型查询域名::不存在::(planId::type)(" + planId + "::" + type + ")")))
|
|
|
+ .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage()))).flatMap(f2 -> {
|
|
|
+ DomainSelect domainSelect = f2.get(RandomUtil.randomInt(0, f2.size()));
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.append("http://");
|
|
|
+ stringBuilder.append(get6Str());
|
|
|
+ stringBuilder.append(".");
|
|
|
+ stringBuilder.append(domainSelect.domain());
|
|
|
+ stringBuilder.append("/index.html?code=");
|
|
|
+ stringBuilder.append(code);
|
|
|
+ stringBuilder.append("&sk=");
|
|
|
+ stringBuilder.append(IdUtil.fastSimpleUUID());
|
|
|
+ ftm.setV(stringBuilder.toString());
|
|
|
+ ftm.setName("H5二维码");
|
|
|
+ return Mono.just(stringBuilder);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
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;
|
|
|
+ List<Item> collect = goRequest.getItem().stream().filter(f -> "cusqrcode".equals(f.getT())
|
|
|
+ && Objects.nonNull(f.getPlanId())
|
|
|
+ && f.getIsRandom()).collect(Collectors.toList());
|
|
|
if (Objects.nonNull(collect) && !collect.isEmpty()) {
|
|
|
List<Long> collect1 = collect.stream().map(Item::getPlanId).collect(Collectors.toList());
|
|
|
stringBuilderMono = template.select(Query.query(Criteria.where("plan_new_id").in(collect1)), PlanNew.class)
|
|
|
@@ -1122,7 +1195,7 @@ public class GoGenerateService {
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);
|
|
|
- Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
+ Mono<List<StringBuilder>> stringBuilderMono = setCusqrcodeSetV(goRequest);//getStringBuilderMono(goRequest);
|
|
|
List<Item> imageGroup = goRequest.getItem().stream().filter(ft -> "image".equals(ft.getT()) && ft.getIsRandom()).collect(Collectors.toList());
|
|
|
//Long imageGroupId=0L;
|
|
|
ArrayList<Long> imageGroupId = new ArrayList<>();
|