Merge branch 'dev' into docker_package

This commit is contained in:
wangliwen 2022-07-15 17:19:42 +08:00
commit e335b27933
5 changed files with 36 additions and 13 deletions

View File

@ -19,6 +19,7 @@ import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -44,6 +46,14 @@ import java.util.stream.Collectors;
@RequestMapping("/census/center/v2") @RequestMapping("/census/center/v2")
public class CensusControllerV2 { public class CensusControllerV2 {
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES))
.retryOnConnectionFailure(false)
.build();
@Value("${project.place}") @Value("${project.place}")
private Integer projectPlace; private Integer projectPlace;
@Value("${project.higher}") @Value("${project.higher}")
@ -359,7 +369,6 @@ public class CensusControllerV2 {
case TSINGTAO_XHA: { // 青岛西海岸 case TSINGTAO_XHA: { // 青岛西海岸
allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目 allAmount = CompletableFuture.supplyAsync(() -> { // 获取平台总基础设施数目
List<Long> result_ = new CopyOnWriteArrayList<>(); List<Long> result_ = new CopyOnWriteArrayList<>();
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10); String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10);
logger.info(url); logger.info(url);
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
@ -465,7 +474,6 @@ public class CensusControllerV2 {
} }
break; break;
case TSINGTAO_XHA: { // 青岛西海岸 case TSINGTAO_XHA: { // 青岛西海岸
OkHttpClient client = new OkHttpClient();
Long total = 0L; Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) { try (Response response = client.newCall(request).execute()) {
@ -500,9 +508,8 @@ public class CensusControllerV2 {
}); });
} }
OkHttpClient client1 = new OkHttpClient();
Request request1 = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build(); Request request1 = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build();
try (Response response = client1.newCall(request1).execute()) { try (Response response = client.newCall(request1).execute()) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string()); JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) { if (jsonObject.containsKey("data")) {

View File

@ -5,17 +5,27 @@ import com.alibaba.fastjson.JSONObject;
import io.renren.common.domain.Tsingtao_xhaProperties; import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.modules.resource.dataResource.AbstractDataResourceService; import io.renren.modules.resource.dataResource.AbstractDataResourceService;
import io.renren.modules.resource.dto.GetDataResourceListDto; import io.renren.modules.resource.dto.GetDataResourceListDto;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
/** /**
* 青岛西海岸数据资源 * 青岛西海岸数据资源
*/ */
public class TsingtaoXHADataResourceService extends AbstractDataResourceService { public class TsingtaoXHADataResourceService extends AbstractDataResourceService {
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES))
.retryOnConnectionFailure(false)
.build();
private static final Logger logger = LoggerFactory.getLogger(TsingtaoXHADataResourceService.class); private static final Logger logger = LoggerFactory.getLogger(TsingtaoXHADataResourceService.class);
Tsingtao_xhaProperties tsingtao_xhaProperties; Tsingtao_xhaProperties tsingtao_xhaProperties;
@ -24,11 +34,10 @@ public class TsingtaoXHADataResourceService extends AbstractDataResourceService
} }
@Override @Override
public Object getDataResource(GetDataResourceListDto dto){ public Object getDataResource(GetDataResourceListDto dto) {
JSONObject result = null; JSONObject result = null;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getSjzy(), Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getSjzy(),
dto.getServiceName(), dto.getOrderField(), dto.getOrderType(), dto.getPageNum(), dto.getPageSize())).build(); dto.getServiceName(), dto.getOrderField(), dto.getOrderType(), dto.getPageNum(), dto.getPageSize())).build();
try (Response response = client.newCall(request).execute()) { try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string()); JSONObject jsonObject = JSON.parseObject(response.body().string());

View File

@ -394,7 +394,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
if ("基础设施".equals(resourceDTO.getType())) { // 基础设施 if ("基础设施".equals(resourceDTO.getType())) { // 基础设施
logger.info("西海岸基础设施"); logger.info("西海岸基础设施");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), StringUtils.isNotBlank(resourceDTO.getName()) ? resourceDTO.getName() : "", pageNum, pageSize); String url = String.format(tsingtao_xhaProperties.getCloudcam(), StringUtils.isNotBlank(resourceDTO.getName()) ? resourceDTO.getName() : "", pageNum, pageSize);
logger.info(url); logger.info(url);
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
@ -539,7 +538,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Long> result_ = new CopyOnWriteArrayList<>(); List<Long> result_ = new CopyOnWriteArrayList<>();
CompletableFuture cloud = CompletableFuture cloud =
CompletableFuture.runAsync(() -> { // 云脑专网 CompletableFuture.runAsync(() -> { // 云脑专网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10); String url = String.format(tsingtao_xhaProperties.getCloudcam(), "", 1, 10);
logger.info(url); logger.info(url);
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
@ -558,7 +556,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}, executor); }, executor);
CompletableFuture local = CompletableFuture local =
CompletableFuture.runAsync(() -> { // 金宏网 CompletableFuture.runAsync(() -> { // 金宏网
OkHttpClient client = new OkHttpClient();
String url = String.format(tsingtao_xhaProperties.getLocalcam(), "", 1, 10); String url = String.format(tsingtao_xhaProperties.getLocalcam(), "", 1, 10);
logger.info(url); logger.info(url);
Request request = new Request.Builder().url(url).build(); Request request = new Request.Builder().url(url).build();
@ -586,7 +583,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
}); });
}); });
OkHttpClient client = new OkHttpClient();
Long total = 0L; Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build(); Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) { try (Response response = client.newCall(request).execute()) {

View File

@ -4,19 +4,28 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.renren.common.domain.BaoTouProperties; import io.renren.common.domain.BaoTouProperties;
import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService; import io.renren.modules.resource.videoPreview.AbstractVideoPreviewService;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
/** /**
* 包头预览 * 包头预览
*/ */
public class BaoTouVideoPreviewService extends AbstractVideoPreviewService { public class BaoTouVideoPreviewService extends AbstractVideoPreviewService {
private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class); private static Logger logger = LoggerFactory.getLogger(BaoTouVideoPreviewService.class);
private static final OkHttpClient client = new OkHttpClient(); private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.connectionPool(new ConnectionPool(cpuNUm * 2, 2, TimeUnit.MINUTES))
.retryOnConnectionFailure(false)
.build();
private BaoTouProperties baoTouProperties; private BaoTouProperties baoTouProperties;

View File

@ -21,9 +21,11 @@ import java.util.concurrent.TimeUnit;
* 青岛西海岸 * 青岛西海岸
*/ */
public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService { public class TsingtaoXHAVideoPreviewService extends AbstractVideoPreviewService {
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static Logger logger = LoggerFactory.getLogger(TsingtaoXHAVideoPreviewService.class); private static Logger logger = LoggerFactory.getLogger(TsingtaoXHAVideoPreviewService.class);
Tsingtao_xhaProperties tsingtao_xhaProperties; Tsingtao_xhaProperties tsingtao_xhaProperties;
private static final Integer cpuNUm = Runtime.getRuntime().availableProcessors();
private static final OkHttpClient client = new OkHttpClient().newBuilder() private static final OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(1, TimeUnit.MINUTES) .connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES) .readTimeout(1, TimeUnit.MINUTES)