|
|
@@ -80,9 +80,13 @@ public class GoGenerateService {
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);//cusqrcode
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
-
|
|
|
+ Optional<Item> firstImage = goRequest.getItem().stream().filter(ft -> "image".equals(ft.getT())).findFirst();
|
|
|
+ Long imageGroupId=0L;
|
|
|
+ if (firstImage.isPresent() && Objects.nonNull(firstImage.get().getGroupTypeIdSc())) {
|
|
|
+ imageGroupId=firstImage.get().getGroupTypeIdSc();
|
|
|
+ }
|
|
|
Mono<Poster> posterMono1 = getPosterResMono1(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1(),getTextListsTitle()))
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(), getImageSaveOrUpdatePoster(imageGroupId), getTextListsPoster(imageGroupId),getImageType1Poster(imageGroupId),getTextListsTitleSaveOrUpdatePoster(posterRequset)))
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
.flatMap(f -> template.insert(f));
|
|
|
@@ -96,62 +100,151 @@ public class GoGenerateService {
|
|
|
private Mono<List<Image>> getImageType1(){
|
|
|
return template.select(Query.query(Criteria.where("type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
-
|
|
|
+ private Mono<List<Image>> getImageType1Poster(Long groupTypeId){
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(1)
|
|
|
+ .and("group_type_id").is(groupTypeId)
|
|
|
+ .and("size_type").is(1)
|
|
|
+ .and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ }
|
|
|
+ private Mono<List<Image>> getImageType1Plan(Long groupTypeId){
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(1)
|
|
|
+ .and("group_type_id").is(groupTypeId)
|
|
|
+ .and("size_type").is(1)
|
|
|
+ .and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ }
|
|
|
private Mono<List<Material>> getTextLists() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(14).and("deleted_at").isNull()), Material.class)
|
|
|
.collectList();
|
|
|
}
|
|
|
+
|
|
|
+ private Mono<List<Material>> getTextListsPoster(Long groupTypeId) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(14)
|
|
|
+ .and("group_type_id").is(groupTypeId)
|
|
|
+ .and("deleted_at").isNull()), Material.class)
|
|
|
+ .collectList();
|
|
|
+ }
|
|
|
+ private Mono<List<Material>> getTextListsPlan(Long groupTypeId) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(14)
|
|
|
+ .and("group_type_id").is(groupTypeId)
|
|
|
+ .and("deleted_at").isNull()), Material.class)
|
|
|
+ .collectList();
|
|
|
+ }
|
|
|
private Mono<List<Material>> getTextListsTitle() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(6).and("deleted_at").isNull()), Material.class)
|
|
|
.collectList();
|
|
|
}
|
|
|
+ private Mono<List<Material>> getTextListsTitleH5(Long groupTypeId) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(6)
|
|
|
+ .and("group_type_id").is(groupTypeId)
|
|
|
+ .and("deleted_at").isNull()), Material.class)
|
|
|
+ .collectList();
|
|
|
+ }
|
|
|
+ private Mono<List<Material>> getTextListsTitleSaveOrUpdatePlan(GoRequest goRequest) {
|
|
|
+ Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT())).findFirst();
|
|
|
+ if (first.isPresent() && Objects.nonNull(first.get().getGroupTypeIdSc())) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(6)
|
|
|
+ .and("group_type_id").is(first.get().getGroupTypeIdSc())
|
|
|
+ .and("deleted_at").isNull()), Material.class)
|
|
|
+ .collectList();
|
|
|
+ }else {
|
|
|
+ return Mono.just(List.of(getMaterialNull()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ private Mono<List<Material>> getTextListsTitleSaveOrUpdatePoster(PosterRequest posterRequset) {
|
|
|
+ String posterTemplate = posterRequset.getPosterTemplate();
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
+ GoRequest goRequest = new GoRequest();
|
|
|
+ BeanUtil.copyProperties(jsonObject,goRequest);//cusqrcode
|
|
|
+ Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT())).findFirst();
|
|
|
+ if (first.isPresent() && Objects.nonNull(first.get().getGroupTypeIdSc())) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(6).and("group_type_id").is(first.get().getGroupTypeIdSc()).and("deleted_at").isNull()), Material.class)
|
|
|
+ .collectList();
|
|
|
+ }else {
|
|
|
+ return Mono.just(List.of(getMaterialNull()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Material getMaterialNull() {
|
|
|
+ return new Material(null, null, null, null, null, null, null, null, null, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
//背景
|
|
|
private Mono<List<Image>> getBgImage() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(2).and("deleted_at").isNull()), Image.class)
|
|
|
.collectList();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* H5 第二个接口 自动生成图片
|
|
|
* @param goRequest
|
|
|
* @param stringBuilderMono
|
|
|
* @return
|
|
|
*/
|
|
|
- public Mono<String> getOutTemPosterYx(GoRequest goRequest,Mono<List<StringBuilder>> stringBuilderMono){
|
|
|
- return getStringMonoOut(goRequest, stringBuilderMono, getBgImageYx(), getFmImageListsYx(), getTextListsYx(),getImageTypeYx(),getTextListsTitle());
|
|
|
+ public Mono<String> getOutTemPosterYx(GoRequest goRequest,Mono<List<StringBuilder>> stringBuilderMono,Long groupId){
|
|
|
+ Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT())).findFirst();
|
|
|
+// Long groupId;
|
|
|
+// if (first.isPresent() && Objects.nonNull(first.get().getGroupTypeIdSc())) {
|
|
|
+// groupId= first.get().getGroupTypeIdSc();
|
|
|
+// }else {
|
|
|
+// groupId=0L;
|
|
|
+// }
|
|
|
+ return getStringMonoOut(goRequest, stringBuilderMono, getBgImageYx(), getFmImageListsYx(groupId), getTextListsYx(groupId),getImageTypeYx(groupId),getTextListsTitleH5(groupId));
|
|
|
}
|
|
|
|
|
|
- public Mono<String> getOutTemPosterQs(GoRequest goRequest,Mono<List<StringBuilder>> stringBuilderMono){
|
|
|
- return getStringMonoOut(goRequest, stringBuilderMono, getBgImageQs(), getFmImageListsQs(), getTextListsQs(),getImageTypeQs(),getTextListsTitle());
|
|
|
+ public Mono<String> getOutTemPosterQs(GoRequest goRequest,Mono<List<StringBuilder>> stringBuilderMono, Long groupId){
|
|
|
+ Optional<Item> first = goRequest.getItem().stream().filter(ft -> "title".equals(ft.getT())).findFirst();
|
|
|
+// Long groupId;
|
|
|
+// if (first.isPresent() && Objects.nonNull(first.get().getGroupTypeIdQs())) {
|
|
|
+// groupId= first.get().getGroupTypeIdQs();
|
|
|
+// }else {
|
|
|
+// groupId=0L;
|
|
|
+// }
|
|
|
+ return getStringMonoOut(goRequest,
|
|
|
+ stringBuilderMono,
|
|
|
+ getBgImageQs(),
|
|
|
+ getFmImageListsQs(groupId),
|
|
|
+ getTextListsQs(groupId),
|
|
|
+ getImageTypeQs(groupId),
|
|
|
+ getTextListsTitleH5(groupId));
|
|
|
}
|
|
|
private Mono<List<Image>> getBgImageQs() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(2).and("group_type").is(2).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
- private Mono<List<Image>> getFmImageListsQs() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(10).and("group_type").is(2).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ private Mono<List<Image>> getFmImageListsQs(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(10)
|
|
|
+ .and("group_type").is(2)
|
|
|
+ .and("group_type_id").is(id)
|
|
|
+ .and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
- private Mono<List<Material>> getTextListsQs() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(14).and("group_type").is(2).and("deleted_at").isNull()), Material.class).collectList();
|
|
|
+ private Mono<List<Material>> getTextListsQs(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(14)
|
|
|
+ .and("group_type").is(2)
|
|
|
+ .and("group_type_id").is(id)
|
|
|
+ .and("deleted_at").isNull()), Material.class).collectList();
|
|
|
}
|
|
|
- private Mono<List<Image>> getImageTypeQs(){
|
|
|
- return template.select(Query.query(Criteria.where("type").is(1).and("group_type").is(2).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ private Mono<List<Image>> getImageTypeQs(Long id){
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(1)
|
|
|
+ .and("group_type").is(2)
|
|
|
+ .and("group_type_id").is(id)
|
|
|
+ .and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Mono<List<Material>> getTextListsYx() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(14).and("group_type").is(1).and("deleted_at").isNull()), Material.class).collectList();
|
|
|
+ private Mono<List<Material>> getTextListsYx(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(14) .and("group_type_id").is(id)
|
|
|
+ .and("group_type").is(1).and("deleted_at").isNull()), Material.class).collectList();
|
|
|
}
|
|
|
private Mono<List<Image>> getBgImageYx() {
|
|
|
return template.select(Query.query(Criteria.where("type").is(2).and("group_type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
- private Mono<List<Image>> getFmImageListsYx() {
|
|
|
- return template.select(Query.query(Criteria.where("type").is(10).and("group_type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ private Mono<List<Image>> getFmImageListsYx(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(10) .and("group_type_id").is(id).and("group_type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
- private Mono<List<Image>> getImageTypeYx(){
|
|
|
- return template.select(Query.query(Criteria.where("type").is(1).and("group_type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
+ private Mono<List<Image>> getImageTypeYx(Long id){
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(1) .and("group_type_id").is(id).and("group_type").is(1).and("deleted_at").isNull()), Image.class).collectList();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -161,42 +254,99 @@ public class GoGenerateService {
|
|
|
|
|
|
Mono<String> stringMono = Mono.zip(bgImage, fmImage, text, stringBuilderMono,fm1,title).flatMap(f -> {
|
|
|
|
|
|
- List<Material> t6 = f.getT6();
|
|
|
+
|
|
|
+ List<Material> t6 = f.getT6().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
if (Objects.nonNull(t6) &&!t6.isEmpty()) {
|
|
|
Optional.ofNullable(t6.get(RandomUtil.randomInt(0,t6.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
.filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> {item.setV(material.content());}));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ throw new BaseException("海报标题素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
+// List<Material> t6 = f.getT6();
|
|
|
+// if (Objects.nonNull(t6) &&!t6.isEmpty()) {
|
|
|
+// Optional.ofNullable(t6.get(RandomUtil.randomInt(0,t6.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
+// .filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+// .findFirst()
|
|
|
+// .ifPresent(item -> {item.setV(material.content());}));
|
|
|
+// }
|
|
|
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("客服二维码"));
|
|
|
}
|
|
|
+ Optional<Item> first2 = goRequest.getItem().stream().filter(fc -> "cusqrcode".equals(fc.getT()) && (Objects.isNull(fc.getV()) || "".equals(fc.getV()))).findFirst();
|
|
|
+ if (first2.isPresent()) {
|
|
|
+ throw new BaseException("自定义二维码素材为空");
|
|
|
+ }
|
|
|
Optional<Image> first = f.getT1().stream().findFirst();
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
}
|
|
|
//封面
|
|
|
- if( Objects.nonNull(f.getT5()) &&!f.getT5().isEmpty()){
|
|
|
+ List<Image> t5 = f.getT5().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t5) &&!t5.isEmpty()) {
|
|
|
+ goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst()
|
|
|
+ .ifPresent(item -> item.setV(t5.get(RandomUtil.randomInt(0, t5.size())).image()));
|
|
|
+ }else {
|
|
|
Optional<Item> first1 = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst();
|
|
|
- first1.ifPresent(item -> item.setV(f.getT5().get(RandomUtil.randomInt(0, f.getT5().size())).image()));
|
|
|
+ if (first1.isPresent()) {
|
|
|
+ throw new BaseException("群封面素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
+// if( Objects.nonNull(f.getT5()) &&!f.getT5().isEmpty()){
|
|
|
+// Optional<Item> first1 = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst();
|
|
|
+// first1.ifPresent(item -> item.setV(f.getT5().get(RandomUtil.randomInt(0, f.getT5().size())).image()));
|
|
|
+// }
|
|
|
//图片
|
|
|
- if( Objects.nonNull(f.getT2()) &&!f.getT2().isEmpty()){
|
|
|
- Optional.ofNullable(f.getT2().get(RandomUtil.randomInt(0, f.getT2().size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
+ List<Image> t2 = f.getT2().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t2) &&!t2.isEmpty()) {
|
|
|
+ Optional.ofNullable(t2.get(RandomUtil.randomInt(0, t2.size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
.filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom() )
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> item.setV(image.image())));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first1 = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .findFirst();
|
|
|
+ if (first1.isPresent()) {
|
|
|
+ throw new BaseException("图片素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
+// if( Objects.nonNull(f.getT2()) &&!f.getT2().isEmpty()){
|
|
|
+// 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())));
|
|
|
+// }
|
|
|
//文本
|
|
|
- if( Objects.nonNull(f.getT3()) &&!f.getT3().isEmpty()){
|
|
|
- Optional.ofNullable(f.getT3().get(RandomUtil.randomInt(0,f.getT3().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()) {
|
|
|
+ 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())
|
|
|
+// .findFirst()
|
|
|
+// .ifPresent(item -> {item.setV(material.content());}));
|
|
|
+// }
|
|
|
String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
return Mono.just(s1);
|
|
|
});
|
|
|
@@ -211,8 +361,24 @@ public class GoGenerateService {
|
|
|
* @return
|
|
|
*/
|
|
|
|
|
|
- public Mono<String> saveAndUpdatePlanGenerateImage0(GoRequest goRequest, Mono<List<StringBuilder>> stringBuilderMono, ServiceGroupSettingItemRequest qsSetting, PlanReq saveRequest ){
|
|
|
- return saveAndUpdatePlanGenerateImage1(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1(), qsSetting, saveRequest,getTextListsTitle());
|
|
|
+ public Mono<String> saveAndUpdatePlanGenerateImage0(GoRequest goRequest,
|
|
|
+ Mono<List<StringBuilder>> stringBuilderMono,
|
|
|
+ ServiceGroupSettingItemRequest qsSetting,
|
|
|
+ PlanReq saveRequest ){
|
|
|
+
|
|
|
+ Optional<Item> firstImage = goRequest.getItem().stream().filter(ft -> "image".equals(ft.getT())).findFirst();
|
|
|
+ Long imageGroupId=0L;
|
|
|
+ if (firstImage.isPresent() && Objects.nonNull(firstImage.get().getGroupTypeIdSc())) {
|
|
|
+ imageGroupId=firstImage.get().getGroupTypeIdSc();
|
|
|
+ }
|
|
|
+ return saveAndUpdatePlanGenerateImage1(goRequest, stringBuilderMono,
|
|
|
+ getBgImage(),
|
|
|
+ getImageSaveOrUpdatePlan(imageGroupId),
|
|
|
+ getTextListsPlan(imageGroupId),
|
|
|
+ getImageType1Plan(imageGroupId),
|
|
|
+ qsSetting,
|
|
|
+ saveRequest,
|
|
|
+ getTextListsTitleSaveOrUpdatePlan( goRequest));
|
|
|
}
|
|
|
/**
|
|
|
* 计划保存修改生成图片
|
|
|
@@ -235,23 +401,41 @@ public class GoGenerateService {
|
|
|
}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()) {
|
|
|
+ throw new BaseException("自定义二维码素材为空");
|
|
|
+ }
|
|
|
if (Objects.nonNull(f.getT4()) && !f.getT4().isEmpty()) {
|
|
|
Optional<Image> first = f.getT1().stream().findFirst();
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
}
|
|
|
}
|
|
|
- List<Material> t7 = f.getT7();
|
|
|
+
|
|
|
+ List<Material> t7 = f.getT7().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
if (Objects.nonNull(t7) &&!t7.isEmpty()) {
|
|
|
Optional.ofNullable(t7.get(RandomUtil.randomInt(0,t7.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
.filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> {item.setV(material.content());}));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ throw new BaseException("海报标题素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
//封面
|
|
|
- if( Objects.nonNull(f.getT5()) &&!f.getT5().isEmpty()) {
|
|
|
+ List<Image> t5 = f.getT5().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t5) &&!t5.isEmpty()) {
|
|
|
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()));
|
|
|
+ .ifPresent(item -> item.setV(t5.get(RandomUtil.randomInt(0, t5.size())).image()));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first1 = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst();
|
|
|
+ if (first1.isPresent()) {
|
|
|
+ throw new BaseException("群封面素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
Optional<Item> first5 = goRequest.getItem().stream().filter(f1 -> "qrcode".equals(f1.getT())).findFirst();
|
|
|
if (first5.isPresent()) {
|
|
|
@@ -267,26 +451,47 @@ public class GoGenerateService {
|
|
|
item.setV(s);
|
|
|
item.setName("客服二维码");
|
|
|
}
|
|
|
+ }else {
|
|
|
+ throw new BaseException("客服二维码 上传图片 为空");
|
|
|
}
|
|
|
}else if(Objects.nonNull(qsSetting.getStatus()) && qsSetting.getStatus()==0 ) {
|
|
|
StringBuilder t6 = f.getT6();
|
|
|
+ if ("".equals(t6)) {
|
|
|
+ throw new BaseException("获取H5链接为空");
|
|
|
+ }
|
|
|
item.setV(t6.toString());
|
|
|
item.setName("H5二维码");
|
|
|
}
|
|
|
}
|
|
|
//图片
|
|
|
- if( Objects.nonNull(f.getT2()) &&!f.getT2().isEmpty()){
|
|
|
- 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())));
|
|
|
+ List<Image> t2 = f.getT2().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t2) &&!t2.isEmpty()) {
|
|
|
+ Optional.ofNullable(t2.get(RandomUtil.randomInt(0, t2.size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom() )
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(item -> item.setV(image.image())));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first1 = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".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()
|
|
|
+ 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("文字素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
String ret = goGenerateStr(s1);
|
|
|
@@ -304,7 +509,6 @@ public class GoGenerateService {
|
|
|
}
|
|
|
public Mono<StringBuilder> getStringBuilderMono(PlanReq saveRequest) {
|
|
|
if (Objects.isNull(saveRequest.getPlanNewId())) {
|
|
|
-
|
|
|
return template.select(Query.query(Criteria.where("group_type_id").is(saveRequest.getGroupId())
|
|
|
.and("status").is(1).and("type").is(1).and("deleted_at").isNull()), DomainSelect.class)
|
|
|
.collectList()
|
|
|
@@ -405,34 +609,67 @@ public class GoGenerateService {
|
|
|
}else{
|
|
|
goRequest.getItem().stream().filter(fc->"cusqrcode".equals(fc.getT())).forEach(fe->fe.setName("客服二维码"));
|
|
|
}
|
|
|
- List<Material> t6 = f.getT6();
|
|
|
+ Optional<Item> first2 = goRequest.getItem().stream().filter(fc -> "cusqrcode".equals(fc.getT()) && (Objects.isNull(fc.getV()) || "".equals(fc.getV()))).findFirst();
|
|
|
+ if (first2.isPresent()) {
|
|
|
+ throw new BaseException("自定义二维码素材为空");
|
|
|
+ }
|
|
|
+ List<Material> t6 = f.getT6().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
if (Objects.nonNull(t6) &&!t6.isEmpty()) {
|
|
|
Optional.ofNullable(t6.get(RandomUtil.randomInt(0,t6.size()))).ifPresent(material -> goRequest.getItem().stream()
|
|
|
.filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> {item.setV(material.content());}));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "title".equals(ff.getT()) && ff.getIsRandom())
|
|
|
+ .findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ throw new BaseException("海报标题素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
Optional<Image> first = f.getT1().stream().findFirst();
|
|
|
if (goRequest.getIsRandom()) {
|
|
|
first.ifPresent(image -> goRequest.setBg_img_src(image.image()));
|
|
|
}
|
|
|
//封面
|
|
|
- if (Objects.nonNull(f.getT5()) &&!f.getT5().isEmpty()) {
|
|
|
+ List<Image> t5 = f.getT5().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t5) &&!t5.isEmpty()) {
|
|
|
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()));
|
|
|
+ .ifPresent(item -> item.setV(t5.get(RandomUtil.randomInt(0, t5.size())).image()));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first1 = goRequest.getItem().stream().filter(ff -> "cover".equals(ff.getT()) && ff.getIsRandom()).findFirst();
|
|
|
+ if (first1.isPresent()) {
|
|
|
+ throw new BaseException("群封面素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
//图片
|
|
|
- if (Objects.nonNull(f.getT2()) &&!f.getT2().isEmpty()) {
|
|
|
- Optional.ofNullable(f.getT2().get(RandomUtil.randomInt(0, f.getT2().size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
+ List<Image> t2 = f.getT2().stream().filter(ft->Objects.nonNull(ft.id())).collect(Collectors.toList());
|
|
|
+ if (Objects.nonNull(t2) &&!t2.isEmpty()) {
|
|
|
+ Optional.ofNullable(t2.get(RandomUtil.randomInt(0, t2.size()))).ifPresent(image -> goRequest.getItem().stream()
|
|
|
.filter(ff -> "image".equals(ff.getT()) && ff.getIsRandom() )
|
|
|
.findFirst()
|
|
|
.ifPresent(item -> item.setV(image.image())));
|
|
|
+ }else {
|
|
|
+ Optional<Item> first1 = goRequest.getItem().stream()
|
|
|
+ .filter(ff -> "image".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()
|
|
|
+ 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("文字素材为空");
|
|
|
+ }
|
|
|
}
|
|
|
//文本
|
|
|
String s1 = JSONUtil.toJsonStr(goRequest);
|
|
|
@@ -590,34 +827,27 @@ public class GoGenerateService {
|
|
|
|
|
|
}
|
|
|
public Mono<RStatus<Poster>> updatePoster(@RequestBody PosterRequest posterRequset){
|
|
|
-
|
|
|
String posterTemplate = posterRequset.getPosterTemplate();
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
|
|
|
GoRequest goRequest = new GoRequest();
|
|
|
BeanUtil.copyProperties(jsonObject,goRequest);
|
|
|
Mono<List<StringBuilder>> stringBuilderMono = getStringBuilderMono(goRequest);
|
|
|
+ Optional<Item> firstImage = goRequest.getItem().stream().filter(ft -> "image".equals(ft.getT())).findFirst();
|
|
|
+ Long imageGroupId=0L;
|
|
|
+ if (firstImage.isPresent() && Objects.nonNull(firstImage.get().getGroupTypeIdSc())) {
|
|
|
+ imageGroupId=firstImage.get().getGroupTypeIdSc();
|
|
|
+ }
|
|
|
Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
- getStringMono(goRequest, stringBuilderMono, getBgImage(), getFmImageLists0(), getTextLists(),getImageType1(),getTextListsTitle()),posterRequset)
|
|
|
+ getStringMono(goRequest, stringBuilderMono, getBgImage(),
|
|
|
+ getImageSaveOrUpdatePoster(imageGroupId),
|
|
|
+ getTextListsPoster(imageGroupId),
|
|
|
+ getImageType1Poster(imageGroupId),
|
|
|
+ getTextListsTitleSaveOrUpdatePoster(posterRequset)),
|
|
|
+ posterRequset)
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
.flatMap(f -> template.update(f));
|
|
|
return RStatus.success(posterMono1);
|
|
|
-// if (goRequest.getIsRandom()) {
|
|
|
-// Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(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));
|
|
|
-// return RStatus.success(posterMono1);
|
|
|
-// }else {
|
|
|
-// Mono<Poster> posterMono1 = getPosterResMonoUpdate(Mono.just(posterRequset),
|
|
|
-// stringBuilderMono.flatMap(f -> Mono.just(goGenerateStr(JSONUtil.toJsonStr(goRequest)))),posterRequset)
|
|
|
-// .switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
|
|
|
-// .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())))
|
|
|
-// .flatMap(f -> template.update(f));
|
|
|
-// return RStatus.success(posterMono1);
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private Mono<List<Image>> getFmImageLists0() {
|
|
|
@@ -625,4 +855,12 @@ public class GoGenerateService {
|
|
|
.collectList();
|
|
|
}
|
|
|
|
|
|
+ private Mono<List<Image>> getImageSaveOrUpdatePoster(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(10).and("group_type_id").is(id).and("deleted_at").isNull()), Image.class)
|
|
|
+ .collectList();
|
|
|
+ }
|
|
|
+ private Mono<List<Image>> getImageSaveOrUpdatePlan(Long id) {
|
|
|
+ return template.select(Query.query(Criteria.where("type").is(10).and("group_type_id").is(id).and("deleted_at").isNull()), Image.class)
|
|
|
+ .collectList();
|
|
|
+ }
|
|
|
}
|