diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java
index 63c6b37..df94e7c 100644
--- a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java
+++ b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java
@@ -26,12 +26,27 @@ import java.util.Map;
*
* @author youHong.ai
*/
-@Path("/ebu7-dev1/common/log")
+@Path("/ebu7-dev1/common/log/")
public class GetLogController {
private final Logger log = Util.getLogger();
private final GetLogService service = new GetLogService();
+
+ @GET
+ @Path("ipList")
+ @Produces(MediaType.APPLICATION_JSON)
+ public String getIpList(@Context HttpServletRequest request, @Context HttpServletResponse response) {
+ try {
+ User loginUser = HrmUserVarify.getUser(request, response);
+ String path = request.getRealPath("/");
+ return ApiResult.success(service.getIpList(loginUser, path));
+ } catch (Exception e) {
+ log.error("获取ip节点出错 : " + e.getMessage());
+ log.error(Util.getErrString(e));
+ return ApiResult.error("获取ip节点出错!");
+ }
+ }
@GET
@Path("get")
diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java
index 58b0094..6b437c5 100644
--- a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java
+++ b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java
@@ -2,10 +2,14 @@ package com.api.ebu7dev1.common.getlog.service;
import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
+import com.api.ebu7dev1.common.getlog.util.GetLogUtil;
+import org.apache.commons.collections.CollectionUtils;
import weaver.hrm.User;
import javax.ws.rs.core.Response;
+import java.io.File;
import java.util.Map;
+import java.util.Set;
/**
*
获取日志
@@ -18,13 +22,52 @@ public class GetLogService {
public Response get(User loginUser) {
return null;
}
+
+ /**
+ * 获取所有的ip地址
+ * @author xuanran.wang
+ * @dateTime 2023/7/1 14:19
+ * @param ecologyPath ec路径
+ * @return 集群ip 以及 本地ip
+ **/
+ public Set getIpList(User loginUser, String ecologyPath){
+ GetLogUtil.checkUser(loginUser);
+ String weaverPropertiesPath;
+ String resinPath = System.getProperty("user.dir") + File.separator;
+ if (ecologyPath.endsWith(File.separator)) {
+ weaverPropertiesPath = ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
+ } else {
+ weaverPropertiesPath = ecologyPath + File.separator + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties";
+ }
+ String localIp = GetLogUtil.getInnerIp();
+ Set ipList = GetLogUtil.readEcologyProp(weaverPropertiesPath);
+ if(CollectionUtils.isEmpty(ipList)){
+ String resinBinPath = resinPath + "bin" + File.separator + "startresin.sh";
+ ipList.addAll(GetLogUtil.readResinProp(resinBinPath));
+ }
+ if (ipList.size() != 0) {//没有集群的时候
+ boolean status = false;
+ for (String ip : ipList) {
+ if (ip.contains(localIp) || "127.0.0.1".equals(ip) || "127.0.0.1".equals(localIp)) {
+ status = true;
+ break;
+ }
+ }
+ if (!status) {
+ ipList.add(localIp);
+ }
+ }else {
+ ipList.add(localIp);
+ }
+ return ipList;
+ }
public String collectLogInfo(User loginUser, Map params) {
- if (loginUser.getUID() != 1) {
- throw new CustomerException("无权限查看!");
- }
+ GetLogUtil.checkUser(loginUser);
String startDate = Util.null2String(params.get("startDate"));
String endDate = Util.null2String(params.get("endDate"));
return null;
}
+
+
}
diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java
index f0e6658..1df7d7a 100644
--- a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java
+++ b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java
@@ -1,6 +1,7 @@
package weaver.xuanran.wang.eny.data_async.mapper;
import aiyh.utils.annotation.recordset.*;
+import io.swagger.models.auth.In;
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail;
import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
@@ -53,6 +54,13 @@ public interface DataAsyncMapper {
@ParamMapper("min") Integer min,
@ParamMapper("max") Integer max);
+ @Select("select id from $t{tableName} where $t{foreignKey} between #{min} and #{max}")
+ @CaseConversion(value = false)
+ List selectDataIdsByForeignKey(@ParamMapper("tableName") String tableName,
+ @ParamMapper("foreignKey") String foreignKey,
+ @ParamMapper("min") Integer min,
+ @ParamMapper("max") Integer max);
+
@Select(custom = true)
String selectCustomerSql(@SqlString String sql, Map map);
diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java
index eb9e28a..0a6fe6e 100644
--- a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java
+++ b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java
@@ -21,6 +21,7 @@ import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain;
import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper;
import weaver.xuanran.wang.eny.data_async.util.EyDataAsyncTokenUtil;
import weaver.xuanran.wang.eny.data_async.util.ValueRuleMethod;
+
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
@@ -71,7 +72,7 @@ public class DataAsyncServiceImpl {
**/
public DataAsyncConfigMain getConfig(String onlyMark) {
DataAsyncConfigMain config = asyncMapper.selectConfigByOnlyMark(onlyMark);
- if(Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())){
+ if (Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())) {
throw new CustomerException("该唯一标识在配置表中未找到对应的配置!或存在该配置但是明细数据为空!");
}
return config;
@@ -79,13 +80,14 @@ public class DataAsyncServiceImpl {
/**
* 数据同步 有一个点 就是如果接口请求过程中报错了 怎么重新处理
+ *
+ * @param config 配置对象
+ * @param tokenUrl token地址
+ * @param params token 参数
* @author xuanran.wang
* @dateTime 2023/6/9 13:28
- * @param config 配置对象
- * @param tokenUrl token地址
- * @param params token 参数
**/
- public void asyncData(DataAsyncConfigMain config, String tokenUrl, Map params){
+ public void asyncData(DataAsyncConfigMain config, String tokenUrl, Map params) {
long startTime = System.currentTimeMillis();
log.info("数据开始同步时间 : " + TimeUtil.getCurrentTimeString());
String asyncUrl = config.getAsync_url();
@@ -101,12 +103,18 @@ public class DataAsyncServiceImpl {
CountDownLatch latch = null;
int preNum = 0;
// 如果不是第一页就先定位到指定位置
- if(pageNo > 1){
+ if (pageNo > 1) {
count += (pageNo - 1) * pageSize;
preNum = count;
}
+ List configDetailList = config.getConfigDetailList();
+ List primaryKeyList = configDetailList.stream().filter(item -> item.getPrimary_key() == 0).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(primaryKeyList)) {
+ throw new CustomerException("请先配置主键字段!");
+ }
+ DataAsyncConfigDetail primaryKey = primaryKeyList.get(0);
boolean show = true;
- while (count < total){
+ while (count < total) {
// 从缓存中获取token
String token = EyDataAsyncTokenUtil.getToken(tokenUrl, params);
header.put("Authorization", "Bearer " + token);
@@ -118,11 +126,11 @@ public class DataAsyncServiceImpl {
try {
// 获取接口数据
data = requestMasterPlate.apiPost(url, new HashMap<>(), header, dataSuccess);
- total = Util.getIntValue(Util.null2DefaultStr(data.get("total"),""), -1);
- if(show){
+ total = Util.getIntValue(Util.null2DefaultStr(data.get("total"), ""), -1);
+ if (show) {
log.info("接口数据条数total : " + total);
}
- if(latch == null){
+ if (latch == null) {
// 应该传入 total / pageSize
latch = new CountDownLatch(total);
}
@@ -130,52 +138,57 @@ public class DataAsyncServiceImpl {
count += pageSize;
List