|
@@ -3,6 +3,7 @@ package com.webflux.launchadmin.mysql.controller.planNew;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
@@ -13,6 +14,7 @@ import com.webflux.launchadmin.mysql.controller.planNew.res.*;
|
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
import com.webflux.launchadmin.mysql.entity.listening.ListeningPlanNew;
|
|
|
import com.webflux.launchadmin.mysql.entity.planNew.*;
|
|
import com.webflux.launchadmin.mysql.entity.planNew.*;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
|
|
import com.webflux.launchadmin.mysql.service.planNew.goGenerate.GoGenerateService;
|
|
|
|
|
+import com.webflux.launchadmin.mysql.service.planNew.ipAnalyze.IpAnalyzeServiceInterface;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.GoRequest;
|
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
|
|
import com.webflux.launchadmin.mysql.service.planNew.structure.Item;
|
|
|
import com.webflux.launchcommon.returnObj.RStatus;
|
|
import com.webflux.launchcommon.returnObj.RStatus;
|
|
@@ -22,10 +24,14 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
|
import org.springframework.data.relational.core.query.Criteria;
|
|
import org.springframework.data.relational.core.query.Criteria;
|
|
|
import org.springframework.data.relational.core.query.Query;
|
|
import org.springframework.data.relational.core.query.Query;
|
|
|
|
|
+import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.server.ServerWebExchange;
|
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
|
|
+import java.net.InetSocketAddress;
|
|
|
|
|
+import java.net.http.HttpRequest;
|
|
|
import java.time.ZonedDateTime;
|
|
import java.time.ZonedDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
@@ -49,6 +55,9 @@ public class PlanNewOutController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private GoGenerateService goGenerateService;
|
|
private GoGenerateService goGenerateService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IpAnalyzeServiceInterface ipAnalyzeServiceInterface;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<String,Integer>();
|
|
private static final ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<String,Integer>();
|
|
@@ -171,7 +180,16 @@ public class PlanNewOutController {
|
|
|
* @return {@link Mono}<{@link RStatus}<{@link DataLists}>>
|
|
* @return {@link Mono}<{@link RStatus}<{@link DataLists}>>
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("hfoInfo")
|
|
@PostMapping("hfoInfo")
|
|
|
- public Mono<RStatus<DataLists>> hfoInfo(@RequestBody HfoRequest request){
|
|
|
|
|
|
|
+ public Mono<RStatus<DataLists>> hfoInfo(@RequestBody HfoRequest request, ServerWebExchange exchange){
|
|
|
|
|
+ ServerHttpRequest httpRequest = exchange.getRequest();
|
|
|
|
|
+ InetSocketAddress remoteAddress = httpRequest.getRemoteAddress();
|
|
|
|
|
+ String ipAddress;
|
|
|
|
|
+ if (remoteAddress != null) {
|
|
|
|
|
+ ipAddress = remoteAddress.getAddress().getHostAddress();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ipAddress = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Mono<PlanNew> code0 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
|
|
Mono<PlanNew> code0 = template.selectOne(Query.query(Criteria.where("code").is(request.getCode())), PlanNew.class)
|
|
|
.switchIfEmpty(Mono.error(new BaseException(" code错误")))
|
|
.switchIfEmpty(Mono.error(new BaseException(" code错误")))
|
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
.onErrorResume(throwable -> Mono.error(new Exception(throwable.getMessage())));
|
|
@@ -246,7 +264,23 @@ public class PlanNewOutController {
|
|
|
List<Material> collect1 = t4.stream().filter(fff -> !listTxt.contains(fff.id())).collect(Collectors.toList());
|
|
List<Material> collect1 = t4.stream().filter(fff -> !listTxt.contains(fff.id())).collect(Collectors.toList());
|
|
|
Material material = collect1.get(RandomUtil.randomInt(0,collect1.size()));
|
|
Material material = collect1.get(RandomUtil.randomInt(0,collect1.size()));
|
|
|
listTxt.add(material.id());
|
|
listTxt.add(material.id());
|
|
|
- h5ImageAndText.setName(material.content());
|
|
|
|
|
|
|
+ String content = material.content();
|
|
|
|
|
+ // 解析ip归属地
|
|
|
|
|
+ if (StrUtil.isNotBlank(ipAddress)) {
|
|
|
|
|
+ JSONObject ipInfo = ipAnalyzeServiceInterface.getIpInfo(ipAddress);
|
|
|
|
|
+ if (null != ipInfo) {
|
|
|
|
|
+ String city = ipInfo.getStr("city");
|
|
|
|
|
+ if (StrUtil.isNotBlank(city)) {
|
|
|
|
|
+ content = city + content;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String province = ipInfo.getStr("region");
|
|
|
|
|
+ if (StrUtil.isNotBlank(province)) {
|
|
|
|
|
+ content = province + content;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ h5ImageAndText.setName(content);
|
|
|
h5ImageAndText.setRemark(material.remark());
|
|
h5ImageAndText.setRemark(material.remark());
|
|
|
h5ImageAndTexts.add(h5ImageAndText);
|
|
h5ImageAndTexts.add(h5ImageAndText);
|
|
|
});
|
|
});
|
|
@@ -308,7 +342,7 @@ public class PlanNewOutController {
|
|
|
return RStatus.successList(dataListsMono1);
|
|
return RStatus.successList(dataListsMono1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
private ReturnLoop getReturnLoop() {
|
|
private ReturnLoop getReturnLoop() {
|
|
|
return new ReturnLoop(-1L, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
return new ReturnLoop(-1L, null, null, null, null, null, null, null, null, null, null, null, null, null);
|
|
|
}
|
|
}
|