|
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
/**
|