ソースを参照

重庆热线-数据交换功能改造

dev
Cruyse 1週間前
コミット
1233a3eb51
11個のファイルの変更311行の追加9行の削除
  1. +10
    -0
      ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteJobDataExchangeService.java
  2. +49
    -7
      ruoyi-auth/src/main/java/cc/mrbird/febs/auth/configure/CustomTokenServices.java
  3. +6
    -0
      ruoyi-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsAuthorizationServerConfigure.java
  4. +25
    -0
      ruoyi-common/ruoyi-common-core/pom.xml
  5. +145
    -0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportHeader.java
  6. +24
    -0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportRequest.java
  7. +12
    -0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportRequestInfo.java
  8. +27
    -0
      ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportResponse.java
  9. +10
    -0
      ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java
  10. +1
    -1
      ruoyi-modules/ruoyi-system-dataexchange/src/main/java/com/ruoyi/business/service/impl/DatabaseServiceImpl.java
  11. +2
    -1
      ruoyi-modules/ruoyi-system-dataexchange/src/main/java/com/ruoyi/business/service/impl/ServiceBusinessServiceImpl.java

+ 10
- 0
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteJobDataExchangeService.java ファイルの表示

@ -36,4 +36,14 @@ public interface RemoteJobDataExchangeService
*/
@GetMapping("/packageResolve")
public R<Boolean> filePackageResolve(@RequestParam("exchangeResolveId") String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
/**
*
* @param params 参数 文件解析配置主键
* @param source 请求来源
* @return 结果
* @throws Exception
*/
@GetMapping("/inBusiness")
public R<Boolean> inBusiness(@RequestParam("exchangeResolveId") String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
}

+ 49
- 7
ruoyi-auth/src/main/java/cc/mrbird/febs/auth/configure/CustomTokenServices.java ファイルの表示

@ -43,6 +43,14 @@ public class CustomTokenServices extends DefaultTokenServices {
private AuthenticationManager authenticationManager;
// 新增TransportClient依赖
private TransportClient transportClient;
// 新增TransportClient的setter方法
public void setTransportClient(TransportClient transportClient) {
this.transportClient = transportClient;
}
@Override
public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication) throws AuthenticationException {
OAuth2AccessToken existingAccessToken = tokenStore.getAccessToken(authentication);
@ -97,7 +105,22 @@ public class CustomTokenServices extends DefaultTokenServices {
return null;
}
int validitySeconds = getRefreshTokenValiditySeconds(authentication.getOAuth2Request());
String tokenValue = new String(Base64.encodeBase64URLSafe(DEFAULT_TOKEN_GENERATOR.generateKey()), US_ASCII);
// 修改点1根据认证模式区分来源
String grantType = authentication.getOAuth2Request().getGrantType();
boolean isClientCredential = "client_credentials".equals(grantType);
String tokenValue = "";
if(isClientCredential) {
try {
tokenValue = transportClient.getToken(); // 假设TransportClient有getToken()方法
} catch (Exception e) {
e.printStackTrace();
throw new AuthenticationException("Failed to generate token via TransportClient", e) {};
}
} else {
tokenValue = new String(Base64.encodeBase64URLSafe(DEFAULT_TOKEN_GENERATOR.generateKey()), US_ASCII);
}
if (validitySeconds > 0) {
return new DefaultExpiringOAuth2RefreshToken(tokenValue, new Date(System.currentTimeMillis()
+ (validitySeconds * 1000L)));
@ -106,11 +129,19 @@ public class CustomTokenServices extends DefaultTokenServices {
}
private OAuth2AccessToken createAccessToken(OAuth2Authentication authentication, OAuth2RefreshToken refreshToken) {
String sourceType = ServletUtils.getRequest().getHeader("SourceType");
// 第三方客户端调用
if(StringUtils.isEmpty(sourceType)) {
sourceType = "data_exchange";
}
// 修改点1根据认证模式区分来源
String grantType = authentication.getOAuth2Request().getGrantType();
boolean isClientCredential = "client_credentials".equals(grantType);
// 修改点2优先通过认证模式判断
String sourceType = isClientCredential ? "data_exchange_feign" : "data_exchange_login";
// String sourceType = ServletUtils.getRequest().getHeader("SourceType");
// // 第三方客户端调用
// if(StringUtils.isEmpty(sourceType)) {
// sourceType = "data_exchange";
// }
//密码模式
// if(authentication.getUserAuthentication() != null && authentication.getUserAuthentication() instanceof UsernamePasswordAuthenticationToken) {
// UsernamePasswordAuthenticationToken userAuthentication = (UsernamePasswordAuthenticationToken) authentication.getUserAuthentication();
@ -118,8 +149,19 @@ public class CustomTokenServices extends DefaultTokenServices {
// LinkedHashMap details = (LinkedHashMap) userAuthentication.getDetails();
// sourceType = details.get("sourceType") + "_";
// }
String tokenValue = "";
if(isClientCredential) {
try {
tokenValue = transportClient.getToken(); // 假设TransportClient有getToken()方法
} catch (Exception e) {
e.printStackTrace();
throw new AuthenticationException("Failed to generate token via TransportClient", e) {};
}
} else {
tokenValue = new String(Base64.encodeBase64URLSafe(DEFAULT_TOKEN_GENERATOR.generateKey()), US_ASCII);
}
String tokenValue = new String(Base64.encodeBase64URLSafe(DEFAULT_TOKEN_GENERATOR.generateKey()), US_ASCII);
DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(sourceType + "_" + tokenValue);
int validitySeconds = getAccessTokenValiditySeconds(authentication.getOAuth2Request());
if (validitySeconds > 0) {

+ 6
- 0
ruoyi-auth/src/main/java/cc/mrbird/febs/auth/configure/FebsAuthorizationServerConfigure.java ファイルの表示

@ -95,6 +95,7 @@ public class FebsAuthorizationServerConfigure extends AuthorizationServerConfigu
tokenServices.setTokenStore(tokenStore());
tokenServices.setSupportRefreshToken(true);
tokenServices.setClientDetailsService(redisClientDetailsService);
tokenServices.setTransportClient(transportClient());
return tokenServices;
}
@ -132,4 +133,9 @@ public class FebsAuthorizationServerConfigure extends AuthorizationServerConfigu
List<TokenGranter> granters = new ArrayList<>(Collections.singletonList(endpoints.getTokenGranter()));// 获取默认的granter集合
return new CompositeTokenGranter(granters);
}
@Bean
public TransportClient transportClient() {
return new TransportClient(); // 根据实际实现初始化
}
}

+ 25
- 0
ruoyi-common/ruoyi-common-core/pom.xml ファイルの表示

@ -153,6 +153,31 @@
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.2</version>
</dependency>
<!-- 新增 OkHttp3 客户端 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>cn.cttic</groupId>
<artifactId>tssh-crypto</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>

+ 145
- 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportHeader.java ファイルの表示

@ -0,0 +1,145 @@
package com.ruoyi.common.core.domain.vo;
import com.google.gson.annotations.SerializedName;
public class TransportHeader {
@SerializedName("SerialNum")
private String serialNumber;
@SerializedName("SystemId")
private String systemId;
@SerializedName("Source")
private String source;
@SerializedName("Target")
private String target;
@SerializedName("Version")
private String version;
@SerializedName("IPCType")
private String ipcType;
@SerializedName("ReqTime")
private String reqTime;
@SerializedName("CRC")
private String crc;
@SerializedName("ReqType")
private String reqType;
@SerializedName("Token")
private String token;
@SerializedName("Code")
private String code;
@SerializedName("Message")
private String message;
public TransportHeader(String serialNumber, String systemId, String source,
String target, String version, String ipcType,
String reqTime, String crc, String reqType,
String token, String code, String message) {
// 实际字段初始化原构造器实现为空
this.serialNumber = serialNumber;
this.systemId = systemId;
this.source = source;
this.target = target;
this.version = version;
this.ipcType = ipcType;
this.reqTime = reqTime;
this.crc = crc;
this.reqType = reqType;
this.token = token;
this.code = code;
this.message = message;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getSystemId() {
return systemId;
}
public void setSystemId(String systemId) {
this.systemId = systemId;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getIpcType() {
return ipcType;
}
public void setIpcType(String ipcType) {
this.ipcType = ipcType;
}
public String getReqTime() {
return reqTime;
}
public void setReqTime(String reqTime) {
this.reqTime = reqTime;
}
public String getCrc() {
return crc;
}
public void setCrc(String crc) {
this.crc = crc;
}
public String getReqType() {
return reqType;
}
public void setReqType(String reqType) {
this.reqType = reqType;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

+ 24
- 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportRequest.java ファイルの表示

@ -0,0 +1,24 @@
package com.ruoyi.common.core.domain.vo;
import com.google.gson.annotations.SerializedName;
// 数据模型类
public class TransportRequest {
@SerializedName("Header")
private TransportHeader header;
@SerializedName("Body")
private String body;
public TransportRequest(TransportHeader header, String body) {
this.header = header;
this.body = body;
}
public TransportHeader getHeader() {
return header;
}
public void setHeader(TransportHeader header) {
this.header = header;
}
}

+ 12
- 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportRequestInfo.java ファイルの表示

@ -0,0 +1,12 @@
package com.ruoyi.common.core.domain.vo;
import com.google.gson.annotations.SerializedName;
public class TransportRequestInfo {
@SerializedName("reqInfo")
private Object reqInfo;
public TransportRequestInfo(Object reqInfo) {
this.reqInfo = reqInfo;
}
}

+ 27
- 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/domain/vo/TransportResponse.java ファイルの表示

@ -0,0 +1,27 @@
package com.ruoyi.common.core.domain.vo;
import com.google.gson.annotations.SerializedName;
public class TransportResponse {
@SerializedName("Header")
private TransportHeader header;
@SerializedName("Body")
private String body;
// getters & setters...
public TransportHeader getHeader() {
return header;
}
public void setHeader(TransportHeader header) {
this.header = header;
}
public Object getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}

+ 10
- 0
ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/RyTask.java ファイルの表示

@ -49,4 +49,14 @@ public class RyTask
public void ryRemotePackageResolve(String params) throws Exception {
remoteJobDataExchangeService.filePackageResolve(params, SecurityConstants.INNER);
}
/**
* 远程调用打包解析
* @param params 文件解析配置主键
* @throws Exception
*/
public void ryRemoteInBusinessResolve(String params) throws Exception {
remoteJobDataExchangeService.inBusiness(params, SecurityConstants.INNER);
}
}

+ 1
- 1
ruoyi-modules/ruoyi-system-dataexchange/src/main/java/com/ruoyi/business/service/impl/DatabaseServiceImpl.java ファイルの表示

@ -290,7 +290,7 @@ public class DatabaseServiceImpl extends ServiceImpl i
Connection conn = getConnection(database.getId(), null);
//只查询jr开头的和sc_开头的表
String sqlStr = "select table_name `name`, table_comment as `remark` " +
"from information_schema.TABLES where TABLE_SCHEMA =? AND (table_name like 'jr_%' OR table_name like 'sc_%')";
"from information_schema.TABLES where TABLE_SCHEMA =? AND (table_name like 'jr_%' OR table_name like 'sc_%' OR table_name like 'cq_%')";
PreparedStatement st = conn.prepareStatement(sqlStr);
st.setString(1, database.getDbname());
ResultSet rs = st.executeQuery();

+ 2
- 1
ruoyi-modules/ruoyi-system-dataexchange/src/main/java/com/ruoyi/business/service/impl/ServiceBusinessServiceImpl.java ファイルの表示

@ -56,9 +56,10 @@ public class ServiceBusinessServiceImpl extends ServiceImpl
public List<ServiceBusiness> selectServiceBusinessList(ServiceBusiness serviceBusiness)
{
LambdaQueryWrapper<ServiceBusiness> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.apply(org.apache.commons.lang3.StringUtils.isNotEmpty(serviceBusiness.getType()), "FIND_IN_SET('" + serviceBusiness.getType() + "', type)");
queryWrapper
.eq(ServiceBusiness::getServiceId, serviceBusiness.getServiceId())
.eq(StringUtils.isNotEmpty(serviceBusiness.getType()),ServiceBusiness::getType,serviceBusiness.getType())
// .eq(StringUtils.isNotEmpty(serviceBusiness.getType()),ServiceBusiness::getType,serviceBusiness.getType())
.eq(StringUtils.isNotEmpty(serviceBusiness.getHasAudit()),ServiceBusiness::getHasAudit,serviceBusiness.getHasAudit())
.like(StringUtils.isNotEmpty(serviceBusiness.getOutName()),ServiceBusiness::getOutName,serviceBusiness.getOutName())
.like(StringUtils.isNotEmpty(serviceBusiness.getDatabaseName()),ServiceBusiness::getDatabaseName,serviceBusiness.getDatabaseName())

読み込み中…
キャンセル
保存