فهرست منبع

plan-java v0.22

(cherry picked from commit 81a101fd8559b995ca1f64d8fc088bac0553ad0a)
MOKASZ\lw12420 2 سال پیش
والد
کامیت
0a435babd6

+ 1 - 1
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewController.java

@@ -53,7 +53,7 @@ public class PlanNewController {
     public String tt(){
         String str="{\"item\": [{\"a\": \"left\", \"c\": \"rgba(0, 0, 0, 1)\", \"h\": 20, \"s\": 14, \"t\": \"title\", \"v\": \"群聊,本地视频推荐\", \"w\": 140, \"x\": 100, \"y\": 100, \"fn\": \"ali-Regular\", \"rm\": \"备注\", \"bgc\": \"\", \"name\": \"海报标题\", \"uuid\": \"b3a10a5e-8c17-4a37-9a99-13600328868c\", \"warp\": false, \"weight\": 500}, {\"c\": \"rgba(0, 0, 0, 1)\", \"h\": 300, \"t\": \"qrcode\", \"v\": \"\", \"w\": 300, \"x\": 87, \"y\": 172, \"fn\": \"\", \"rm\": \"备注\", \"bgc\": \"#ffffff\", \"name\": \"二维码\", \"uuid\": \"2862c036-ad07-48d4-ab34-94fbb2c46c30\"}], \"width\": 458, \"height\": 709, \"bg_img_src\": \"\"}";
 
-        return goGenerateService.GoGenerate(str);
+        return goGenerateService.goGenerate(str);
     }
 
 

+ 80 - 9
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/PlanNewOutController.java

@@ -1,8 +1,16 @@
 package com.webflux.launchadmin.mysql.controller.planNew;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.webflux.launchadmin.config.BaseContextHandler;
 import com.webflux.launchadmin.mysql.controller.planNew.req.*;
 import com.webflux.launchadmin.mysql.controller.planNew.res.*;
 import com.webflux.launchadmin.mysql.entity.planNew.*;
+import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
+import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
+import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
 import com.webflux.launchcommon.returnObj.RStatus;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
@@ -12,10 +20,9 @@ import org.springframework.data.relational.core.query.Query;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import reactor.core.publisher.Mono;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+
+import java.time.ZonedDateTime;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -35,6 +42,9 @@ public class PlanNewOutController {
     @Resource
     private R2dbcEntityTemplate template;
 
+    @Resource
+    private GoGenerateService goGenerateService;
+
     private static final ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<String,Integer>();
     //清空用户Map数据
     @Scheduled(cron="1 1 4 * * ?")
@@ -255,11 +265,72 @@ public class PlanNewOutController {
             a.setAudio(b);
             return a;
         });
-//        zip.flatMap(fm->{
-//            Poster poster = fm.getPoster();
-//
-//        })
-        return RStatus.successList(zip);
+        Mono<DataLists0> dataLists0Mono1 = zip.flatMap(fm -> {
+            Poster poster = fm.getPoster();
+            if (Objects.isNull(poster)) {
+                return Mono.just(fm);
+            }
+            String posterTemplate = poster.posterTemplate();
+            GoRequest goRequest = null;
+            if (Objects.nonNull(request.getWx_user_id()) && !"".equals(request.getWx_user_id())) {
+                PlanNewBackgroupPoster qsSetting = fm.getQsSetting();
+                goRequest = setNameVal(posterTemplate, qsSetting);
+            } else {
+                PlanNewBackgroupPoster fxSetting = fm.getFxSetting();
+                goRequest = setNameVal(posterTemplate, fxSetting);
+
+            }
+            String ret = null;
+            if (Objects.nonNull(goRequest)) {
+                ret = goGenerateService.goGenerate(JSONUtil.toJsonStr(goRequest));
+            } else {
+                ret = goGenerateService.goGenerate(posterTemplate);
+            }
+            if (Objects.nonNull(ret)) {
+                JSONObject jsonObject1 = JSONUtil.parseObj(ret);
+                if (jsonObject1.containsKey("code") && jsonObject1.get("code", Integer.class) == 0 && jsonObject1.containsKey("data")) {
+                    JSONObject data = jsonObject1.get("data", JSONObject.class);
+                    if (data.containsKey("Url")) {
+                        String url = data.get("Url", String.class);
+                        if (Objects.nonNull(request.getWx_user_id()) && !"".equals(request.getWx_user_id())) {
+                            fm.setQsGenerateImagesUrl(url);
+                        } else {
+                            fm.setFxGenerateImagesUrl(url);
+                        }
+
+                    }
+                }
+            }
+            return Mono.just(fm);
+        });
+        return RStatus.successList(dataLists0Mono1);
+    }
+
+    private GoRequest setNameVal(String posterTemplate, PlanNewBackgroupPoster qsSetting) {
+        JSONObject jsonObject = JSONUtil.parseObj(posterTemplate);
+        GoRequest goRequest = new GoRequest();
+        BeanUtil.copyProperties(jsonObject,goRequest);
+        if(Objects.nonNull(qsSetting)){
+            Optional<Item> first = goRequest.getItem().stream().filter(f -> "qrcode".equals(f.getT())).findFirst();
+            if (first.isPresent()) {
+                Item item = first.get();
+                Boolean isRandom = item.getIsRandom();
+                if (isRandom && Objects.nonNull(qsSetting.status()) &&  qsSetting.status()==1
+                        &&Objects.nonNull(qsSetting.serviceGroupType()) &&  qsSetting.serviceGroupType()==2 ) {
+                    String kefu = qsSetting.kefu();
+                    if (Objects.nonNull(kefu) && kefu.contains("[") &&  kefu.contains("]")  ) {
+                        JSONArray jsonArray = JSONUtil.parseArray(kefu);
+                        if (!jsonArray.isEmpty()) {
+                            String s = jsonArray.get(0, String.class);
+                            log.info("item.setName(s);");
+                            item.setName(s);
+                            return goRequest;
+                        }
+                    }
+                }
+            }
+        }
+        return null;
     }
 
     /**

+ 8 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/controller/planNew/res/DataLists0.java

@@ -31,6 +31,14 @@ public class DataLists0 {
      * 清水-配置
      */
     private PlanNewBackgroupPoster qsSetting;
+    /**
+     * 分享-生成图片
+     */
+    private String fxGenerateImagesUrl;
+    /**
+     * 清水-生成图片
+     */
+    private String qsGenerateImagesUrl;
 
     /**
      * 音频

+ 5 - 5
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/goGenerate/GoGenerateService.java

@@ -48,7 +48,7 @@ public class GoGenerateService {
     ///api/image/createImage
 
     //http://wx-share-8.duiweize.com 正式
-    public String GoGenerate(String temStr){
+    public String goGenerate(String temStr){
         JSONObject jsonObject = JSONUtil.parseObj(temStr);
         GoRequest goRequest = new GoRequest();
         BeanUtil.copyProperties(jsonObject,goRequest);
@@ -91,7 +91,7 @@ public class GoGenerateService {
                         .findFirst()
                         .ifPresent(item -> item.setV(material.content())));
                 String s1 = JSONUtil.toJsonStr(goRequest);
-                String s = GoGenerate(s1);
+                String s = goGenerate(s1);
                 return Mono.just(s);
             });
             Mono<Poster> zip = getPosterResMono1(Mono.just(posterRequset), stringMono);
@@ -100,7 +100,7 @@ public class GoGenerateService {
             Mono<Poster> posterMono1 = posterMono.flatMap(f -> template.insert(f));
             return RStatus.success(posterMono1);
         }else {
-            String s = GoGenerate(JSONUtil.toJsonStr(goRequest));
+            String s = goGenerate(JSONUtil.toJsonStr(goRequest));
             Mono<Poster> zip = getPosterResMono1(Mono.just(posterRequset), Mono.just(s));
             Mono<Poster> posterMono = zip.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
                     .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
@@ -179,7 +179,7 @@ public class GoGenerateService {
                         .filter(ff -> "text".equals(ff.getT()))
                         .findFirst()
                         .ifPresent(item -> item.setV(material.content())));
-                String s = GoGenerate(JSONUtil.toJsonStr(goRequest));
+                String s = goGenerate(JSONUtil.toJsonStr(goRequest));
                 return Mono.just(s);
             });
             Mono<Poster> zip = getPosterResMono2(Mono.just(posterRequset), stringMono);
@@ -188,7 +188,7 @@ public class GoGenerateService {
             Mono<Poster> posterMono1 = posterMono.flatMap(f -> template.insert(f));
             return RStatus.success(posterMono1);
         }else {
-            String s = GoGenerate(JSONUtil.toJsonStr(goRequest));
+            String s = goGenerate(JSONUtil.toJsonStr(goRequest));
             Mono<Poster> zip = getPosterResMono2(Mono.just(posterRequset), Mono.just(s));
             Mono<Poster> posterMono = zip.switchIfEmpty(Mono.error(new BaseException(" 操作失败")))
                     .onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));

+ 2 - 0
launch-admin/src/main/java/com/webflux/launchadmin/mysql/service/planNew/structure/Item.java

@@ -43,4 +43,6 @@ public class Item {
 
     private String  b;
 
+    private Boolean isRandom;
+
 }