feat:口门对接设备
parent
74bcd9c715
commit
7c3f37a0cb
|
|
@ -5,7 +5,7 @@ application:
|
|||
name: zcloud-gbs-primeport
|
||||
version:
|
||||
gateway: primeport
|
||||
cn-name: 一级口门管理
|
||||
cn-name: 口门门禁管理
|
||||
spring:
|
||||
application:
|
||||
name: ${application.name}${application.version}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
sdk:
|
||||
server:
|
||||
# app-key: bbab676d39e443cfacc037ee15fdad37
|
||||
#港务局线上appKey
|
||||
app-key: c7fbb137c1a0484c8b0cca8ac9937c55
|
||||
#港务局线上appKey c7fbb137c1a0484c8b0cca8ac9937c55
|
||||
client:
|
||||
gateway:
|
||||
url: ${common.gateway.network.http.external}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,294 @@
|
|||
package com.zcloud.primeport.mjDevice;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.zcloud.primeport.domain.enums.FileTypeEnum;
|
||||
import com.zcloud.primeport.domain.enums.SaveTypeEnum;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
public class OauthUtil {
|
||||
|
||||
// private final String publicKeyUrl = "https://192.168.42.194/evo-apigw/evo-oauth/1.0.0/oauth/public-key";
|
||||
|
||||
@Value("${icc.clientId}")
|
||||
private String clientId;
|
||||
@Value("${icc.publicKeyUrl}")
|
||||
private String publicKeyUrl;
|
||||
@Value("${icc.clientSecret}")
|
||||
private String clientSecret;
|
||||
@Value("${icc.username}")
|
||||
private String username;
|
||||
@Value("${icc.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${icc.url}")
|
||||
private String iccUrl;
|
||||
@Value("${icc.request.getGenerateIdUrl}")
|
||||
private String iccGenerateIdUrl;
|
||||
@Value("${icc.request.getGenerateIdListUrl}")
|
||||
private String iccGenerateIdListUrl;
|
||||
@Value("${icc.request.imgInspectUrl}")
|
||||
private String iccImgInspectUrl;
|
||||
@Value("${icc.request.getDepartmentIdUrl}")
|
||||
private String iccDepartmentIdUrl;
|
||||
@Value("${icc.request.getDepartmentIdListUrl}")
|
||||
private String iccDepartmentIdListUrl;
|
||||
|
||||
/**
|
||||
* 获取RestTemplate实例
|
||||
* @return RestTemplate实例
|
||||
*/
|
||||
public RestTemplate getRestTemplate() {
|
||||
RestTemplate restTemplate = null;
|
||||
try {
|
||||
// 创建一个信任所有证书的 SSL 上下文
|
||||
SSLContext sslContext = new SSLContextBuilder()
|
||||
.loadTrustMaterial(null, (chain, authType) -> true)
|
||||
.build();
|
||||
|
||||
// 创建一个忽略主机名验证的 SSL 连接套接字工厂
|
||||
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
|
||||
|
||||
// 创建 HttpClient
|
||||
CloseableHttpClient httpClient = HttpClients.custom()
|
||||
.setSSLSocketFactory(sslsf)
|
||||
.build();
|
||||
|
||||
// 创建 ClientHttpRequestFactory
|
||||
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
||||
|
||||
// 创建 RestTemplate 并设置请求工厂
|
||||
restTemplate = new RestTemplate(requestFactory);
|
||||
|
||||
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return restTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公钥
|
||||
* @return 公钥字符串
|
||||
*/
|
||||
public String getPublicKey() {
|
||||
ResponseEntity<String> response = getRestTemplate().getForEntity(publicKeyUrl, String.class);
|
||||
System.out.println("getPublicKey,response:"+response.getBody());
|
||||
Map data = (Map) JSON.parseObject(response.getBody(), new TypeReference<Map<String, Object>>(){}).get("data");
|
||||
String publicKey = data.get("publicKey").toString();
|
||||
System.out.println("getPublicKey, publicKey:"+ publicKey);
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @return token
|
||||
* @date 2025-05-10
|
||||
* @author hyx
|
||||
*/
|
||||
public String getToken() {
|
||||
String token = null;
|
||||
// 准备请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Content-Type", "application/json");
|
||||
//获取公钥
|
||||
OauthUtil oauthUtil = new OauthUtil();
|
||||
String publicKey = oauthUtil.getPublicKey();
|
||||
if (StringUtils.isEmpty(publicKey)) {
|
||||
System.out.println("get publicKey failed.");
|
||||
} else {
|
||||
try {
|
||||
// 准备请求体
|
||||
Map requestBody = new HashMap();
|
||||
requestBody.put("grant_type", "password");
|
||||
requestBody.put("username", username);
|
||||
requestBody.put("password", RSAUtils.encrypt(password,publicKey));
|
||||
requestBody.put("client_id", clientId);
|
||||
requestBody.put("client_secret", clientSecret);
|
||||
requestBody.put("public_key", publicKey);
|
||||
// 创建 HttpEntity 对象
|
||||
HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(requestBody), headers);
|
||||
System.out.println("getToken, request: " + JSON.toJSONString(requestBody));
|
||||
// 调用 POST 接口
|
||||
String url = iccUrl + "/evo-apigw/evo-oauth/1.0.0/oauth/extend/token";
|
||||
ResponseEntity<String> response = getRestTemplate().exchange(url, HttpMethod.POST, entity, String.class);
|
||||
// 输出响应内容
|
||||
System.out.println("getToken, response: " + response.getBody());
|
||||
Map responseBody = JSON.parseObject(response.getBody(), new TypeReference<Map<String, Object>>(){});
|
||||
Map data = (Map) responseBody.get("data");
|
||||
String code = (String) responseBody.get("code");
|
||||
if(!code.equals("0")){
|
||||
System.out.println("get token failed.");
|
||||
}else {
|
||||
String accessToken = data.get("access_token").toString();
|
||||
String tokenType = data.get("token_type").toString();
|
||||
token = tokenType + ' ' + accessToken;
|
||||
System.out.println("getToken, token:" + token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局用户ID公用方法
|
||||
* @return 全局用户ID
|
||||
* @throws Exception
|
||||
* @date 2025-05-10
|
||||
* @author hyx
|
||||
*/
|
||||
public Long getGenerateId() throws Exception {
|
||||
String body = HttpRequest.get(iccUrl + iccGenerateIdUrl).header("Authorization", getToken()).execute().body();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
return new JSONObject(jsonObject.get("data")).getLong("id");
|
||||
}else {
|
||||
throw new RuntimeException("获取全局用户ID失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局用户ID列表公共方法
|
||||
* @param idCount 获取ID数量
|
||||
* @return List<Long>
|
||||
* @date 2025-05-10
|
||||
* @author hyx
|
||||
*/
|
||||
public List<Long> getGenerateIdList(Integer idCount){
|
||||
String body = HttpRequest
|
||||
.get(iccUrl + iccGenerateIdListUrl + idCount)
|
||||
.header("Authorization", getToken())
|
||||
.execute()
|
||||
.body();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
return JSON.parseObject(new JSONObject(jsonObject.get("data")).get("idList").toString(), new TypeReference<List<Long>>(){});
|
||||
}else {
|
||||
throw new RuntimeException("获取全局用户ID失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片质量检测公用方法
|
||||
*
|
||||
* @param map {@link FileTypeEnum}
|
||||
* 根据FileTypeEnum获取相应文件
|
||||
* @return R
|
||||
* @date 2025-05-10
|
||||
* @author hyx
|
||||
*/
|
||||
public HashMap imgInspect(Map<String,Object> map) {
|
||||
Map<String,Object> requestMap = new HashMap<>();
|
||||
requestMap.put("saveType", SaveTypeEnum.SAVE_TYPE3.getCode());
|
||||
requestMap.put("ossType",1);
|
||||
if (FileTypeEnum.FILE_TYPE1.getCode().equals(map.get("fileType"))){
|
||||
//文件格式
|
||||
requestMap.put("file", map.get("file"));
|
||||
requestMap.put("fileType", FileTypeEnum.FILE_TYPE1.getCode());
|
||||
} else if (FileTypeEnum.FILE_TYPE2.getCode().equals(map.get("fileType"))) {
|
||||
//url格式
|
||||
requestMap.put("fileUrl", map.get("fileUrl"));
|
||||
requestMap.put("fileType", FileTypeEnum.FILE_TYPE2.getCode());
|
||||
}else if (FileTypeEnum.FILE_TYPE3.getCode().equals(map.get("fileType"))) {
|
||||
//base64格式
|
||||
requestMap.put("fileBase64", map.get("fileBase64"));
|
||||
requestMap.put("fileType", FileTypeEnum.FILE_TYPE3.getCode());
|
||||
}
|
||||
String body = HttpRequest
|
||||
.post(iccUrl + iccImgInspectUrl)
|
||||
.contentType("multipart/form-data")
|
||||
.header("Authorization", getToken())
|
||||
.form(requestMap)
|
||||
.execute()
|
||||
.body();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
HashMap<String,Object> result = new HashMap<String,Object>();
|
||||
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
if ("0".equals(jsonObject.getJSONObject("data").get("result"))){
|
||||
result.put("fileUrl",jsonObject.getJSONObject("data").get("fileUrl").toString());
|
||||
return result;
|
||||
// return R.ok("图片质检成功").put("fileUrl",jsonObject.getJSONObject("data").get("fileUrl").toString());
|
||||
}else {
|
||||
return result;
|
||||
// return R.error("图片质检失败");
|
||||
}
|
||||
}else {
|
||||
return result;
|
||||
// return R.error(jsonObject.get("errMsg").toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局部门ID公共方法
|
||||
* @return 全局部门ID
|
||||
* @throws Exception
|
||||
* @author hyx
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
public Long getDepartmentId() throws Exception {
|
||||
String body = HttpRequest.get(iccUrl + iccDepartmentIdUrl).header("Authorization", getToken()).execute().body();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
return new JSONObject(jsonObject.get("data")).getLong("id");
|
||||
}else {
|
||||
throw new RuntimeException("获取全局部门ID失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局部门ID列表公共方法
|
||||
* @param idCount 获取ID数量
|
||||
* @return List<Long>
|
||||
* @author hyx
|
||||
* @date 2025-05-12
|
||||
*/
|
||||
public List<Long> getDepartmentIdList(Integer idCount){
|
||||
String body = HttpRequest
|
||||
.get(iccUrl + iccGenerateIdListUrl + idCount)
|
||||
.header("Authorization", getToken())
|
||||
.execute()
|
||||
.body();
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
if ("true".equals(jsonObject.get("success").toString())) {
|
||||
return JSON.parseObject(new JSONObject(jsonObject.get("data")).get("idList").toString(), new TypeReference<List<Long>>(){});
|
||||
}else {
|
||||
throw new RuntimeException("获取全局部门ID失败");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(RSAUtils.encrypt("3093164@qzs"
|
||||
,"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzId+G65rq/ZSSKjOtd8VwIPdgDsz08RZK5fG/d2ZeIhg2P44kWvtZSSp7RPR/3sJdx9w0PzdQg14Sn6jn+eGfJIQsbs8af9QIqDVlv7M7eeoEabzRgU+4SBxo8dvokLMnNw3PUiZFjhchyLctlERoeTZ5rH6qdz/DtvEi9ypzVQIDAQAB"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.zcloud.primeport.mjDevice;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class RSATest {
|
||||
|
||||
/**
|
||||
* 基于原生RSA公钥加密
|
||||
* @param password 用户密码
|
||||
* @param publicKey 公钥
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encrypt(String password, String publicKey) throws Exception {
|
||||
//base64编码的公钥
|
||||
byte[] decoded = java.util.Base64.getDecoder().decode(publicKey);
|
||||
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
|
||||
//RSA加密
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
|
||||
String outStr;
|
||||
byte[] inputArray = password.getBytes("UTF-8");
|
||||
int inputLength = inputArray.length;
|
||||
// 最大加密字节数,超出最大字节数需要分组加密
|
||||
int MAX_ENCRYPT_BLOCK = 117;
|
||||
// 标识
|
||||
int offSet = 0;
|
||||
byte[] resultBytes = {};
|
||||
byte[] cache = {};
|
||||
while (inputLength - offSet > 0) {
|
||||
if (inputLength - offSet > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(inputArray, offSet, MAX_ENCRYPT_BLOCK);
|
||||
offSet += MAX_ENCRYPT_BLOCK;
|
||||
} else {
|
||||
cache = cipher.doFinal(inputArray, offSet, inputLength - offSet);
|
||||
offSet = inputLength;
|
||||
}
|
||||
resultBytes = Arrays.copyOf(resultBytes, resultBytes.length + cache.length);
|
||||
System.arraycopy(cache, 0, resultBytes, resultBytes.length - cache.length, cache.length);
|
||||
}
|
||||
outStr = java.util.Base64.getEncoder().encodeToString(resultBytes);
|
||||
return outStr;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String encrypt = RSATest.encrypt("Qzs@3093164"
|
||||
, "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaZPQ5y2K8hM3uPKQRDwykl7t3e8OxxWTcIRk7WtAHOrMEvYCVvabn7jZvvBAej0MZnuFcIsHLX7jxqU7" +
|
||||
"//JjHczBKvCd26x5huIKn7J3gCYF90uG9jRVqKsaorFTz9T3Y25Fhl+bTm5pYh2FX6NIgl/DICc8025zbuSq+vJxIZQIDAQAB");
|
||||
System.out.println(encrypt);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.zcloud.primeport.mjDevice;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.security.*;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* RSA公钥/私钥/签名工具包
|
||||
* <p>
|
||||
* 字符串格式的密钥在未在特殊说明情况下都为BASE64编码格式<br/>
|
||||
* 由于非对称加密速度极其缓慢,一般文件不使用它来加密而是使用对称加密,<br/>
|
||||
* 非对称加密算法可以用来对对称加密的密钥加密,这样保证密钥的安全也就保证了数据的安全
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public class RSAUtils {
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 加密算法RSA
|
||||
*/
|
||||
public static final String KEY_ALGORITHM = "RSA";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 签名算法
|
||||
*/
|
||||
public static final String SIGNATURE_ALGORITHM = "MD5withRSA";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 获取公钥的key
|
||||
*/
|
||||
private static final String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUoHAavCikaZxjlDM6Km8cX+ye78F4oF39AcEfnE1p2Yn9pJ9WFxYZ4Vkh6F8SKMi7k4nYsKceqB1RwG996SvHQ5C3pM3nbXCP4K15ad6QhN4a7lzlbLhiJcyIKszvvK8ncUDw8mVQ0j/2mwxv05yH6LN9OKU6Hzm1ninpWeE+awIDAQAB\n";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* 获取私钥的key
|
||||
*/
|
||||
private static final String PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBANSgcBq8KKRpnGOUMzoqbxxf7J7vwXigXf0BwR+cTWnZif2kn1YXFhnhWSHoXxIoyLuTidiwpx6oHVHAb33pK8dDkLekzedtcI/grXlp3pCE3hruXOVsuGIlzIgqzO+8rydxQPDyZVDSP/abDG/TnIfos304pTofObWeKelZ4T5rAgMBAAECgYEAt2Dvjn885h+Xm2JTlBTI40Xvw1uwFqLorK54qxSYx3OwySrTqOIcU5HA17ebVwQJq40hU9t3Jr+DGeDHx2X0NEJ0LXuDMzeWxUwUMbdxxM7OXS6Zuhy73C99DyAweLP9K1H2J/y1+eJ4Zx/0mTiAgCKJFNWAQBZwGl5Zu2zoHOECQQDw0UlrOUfloxK3hfVSWlfL7+onP+z/qa9bzemSg676sAJqA8d5ao8V532OBOtZxfPSlh4igC0lpY2vnCRHrwJZAkEA4ggpMS4o+rfFmNslNzI0m3VFDiLYmghYIqTLHtLYqAbY8QVfFd8bl920t5LQAlTsI3q9Spsu8y7AnAWmYydGYwJAN+tBMya/7TDqvbbbel4EGRUCuE59x/gtAhJUdHMjhI6uYNOz1BvMUffJDdtSkywGLBYztSsyUJWayvZk7khTMQJAALM7xW46LESjdQzAucILDaw4UYnkF94Mv9a41lia2TJkO6Ljn4K4aCkEpUjsIgW3UYjQy0ldxN0RNaqC0G3PtwJAFafiLzcls6qzyAlh5PqM5cJrs+Xa0rHR322/AlSyuxW6wRzUX/zSoorP34JCjRPT5DzUeHMVvr6S2BE8k/8XYg==";
|
||||
|
||||
/** */
|
||||
/**
|
||||
* RSA最大加密明文大小
|
||||
*/
|
||||
private static final int MAX_ENCRYPT_BLOCK = 117;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* RSA最大解密密文大小
|
||||
*/
|
||||
private static final int MAX_DECRYPT_BLOCK = 128;
|
||||
|
||||
/** */
|
||||
/**
|
||||
* <p>
|
||||
* 生成密钥对(公钥和私钥)
|
||||
* </p>
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Map<String, Object> genKeyPair() throws Exception {
|
||||
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
|
||||
keyPairGen.initialize(1024);
|
||||
KeyPair keyPair = keyPairGen.generateKeyPair();
|
||||
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
|
||||
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
|
||||
Map<String, Object> keyMap = new HashMap<String, Object>(2);
|
||||
keyMap.put(PUBLIC_KEY, publicKey);
|
||||
keyMap.put(PRIVATE_KEY, privateKey);
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 基于原生RSA公钥加密
|
||||
* @param password 用户密码
|
||||
* @param publicKey 公钥
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encrypt(String password, String publicKey) throws Exception {
|
||||
//base64编码的公钥
|
||||
byte[] decoded = java.util.Base64.getDecoder().decode(publicKey);
|
||||
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
|
||||
//RSA加密
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
|
||||
String outStr;
|
||||
byte[] inputArray = password.getBytes("UTF-8");
|
||||
int inputLength = inputArray.length;
|
||||
// 最大加密字节数,超出最大字节数需要分组加密
|
||||
int MAX_ENCRYPT_BLOCK = 117;
|
||||
// 标识
|
||||
int offSet = 0;
|
||||
byte[] resultBytes = {};
|
||||
byte[] cache = {};
|
||||
while (inputLength - offSet > 0) {
|
||||
if (inputLength - offSet > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(inputArray, offSet, MAX_ENCRYPT_BLOCK);
|
||||
offSet += MAX_ENCRYPT_BLOCK;
|
||||
} else {
|
||||
cache = cipher.doFinal(inputArray, offSet, inputLength - offSet);
|
||||
offSet = inputLength;
|
||||
}
|
||||
resultBytes = Arrays.copyOf(resultBytes, resultBytes.length + cache.length);
|
||||
System.arraycopy(cache, 0, resultBytes, resultBytes.length - cache.length, cache.length);
|
||||
}
|
||||
outStr = java.util.Base64.getEncoder().encodeToString(resultBytes);
|
||||
return outStr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.zcloud.primeport.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum FileTypeEnum {
|
||||
FILE_TYPE1(1,"File格式"),
|
||||
FILE_TYPE2(2,"url格式"),
|
||||
FILE_TYPE3(3,"base64格式")
|
||||
;
|
||||
private Integer code;
|
||||
private String typeName;
|
||||
|
||||
FileTypeEnum(Integer code, String typeName) {
|
||||
this.code = code;
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public FileTypeEnum setCode(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FileTypeEnum setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.zcloud.primeport.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum SaveTypeEnum {
|
||||
SAVE_TYPE1(1,"无论检测结果如何,保留图片"),
|
||||
SAVE_TYPE2(2,"无论检测结果如何,删除oss图片"),
|
||||
SAVE_TYPE3(3,"检测通过保留,否则删除")
|
||||
;
|
||||
private Integer code;
|
||||
private String typeName;
|
||||
|
||||
SaveTypeEnum(Integer code, String typeName) {
|
||||
this.code = code;
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public SaveTypeEnum setCode(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SaveTypeEnum setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.zcloud.primeport.persistence.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -32,7 +33,7 @@ public interface VehicleApplyMapper extends BaseMapper<VehicleApplyDO> {
|
|||
IPage<FgsVehicleCountDto> fgsCount(Page<Map<String, Object>> page, @Param("params") HashMap<String, String> qry);
|
||||
|
||||
VehicleApplyDO getInfoById(Long id);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<VehicleApplyDO> getAppCount(@Param("params") Map<String, Object> parmas);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,54 +153,7 @@
|
|||
tmp.audit_user_id,
|
||||
COUNT( 1 ) wait_audit_count
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
'one_level_car' type,
|
||||
vap.vehicle_belong_type belong_type,
|
||||
va.audit_user_id,
|
||||
va.audit_user_name,
|
||||
va.audit_status
|
||||
FROM
|
||||
vehicle_audit va
|
||||
LEFT JOIN vehicle_apply vap ON va.vehicle_apply_id = vap.id
|
||||
WHERE
|
||||
va.delete_enum = 'FALSE'
|
||||
AND va.audit_status = 1
|
||||
AND vap.delete_enum = 'FALSE' UNION ALL
|
||||
SELECT
|
||||
'two_level_car' type,
|
||||
caca.car_belong_type belong_type,
|
||||
caca.audit_person_user_id audit_user_id,
|
||||
caca.audit_person_user_name audit_user_name,
|
||||
caca.audit_flag audit_status
|
||||
FROM
|
||||
closed_area_car_apply caca
|
||||
WHERE
|
||||
caca.delete_enum = 'FALSE'
|
||||
AND caca.audit_flag = 1 UNION ALL
|
||||
SELECT
|
||||
'one_level_person' type,
|
||||
xap.person_belong_type,
|
||||
xap.audit_user_id,
|
||||
xap.audit_user_name,
|
||||
xap.audit_flag
|
||||
FROM
|
||||
xgf_apply_person xap
|
||||
WHERE
|
||||
xap.delete_enum = 'FALSE'
|
||||
AND xap.audit_flag = 1 UNION ALL
|
||||
SELECT
|
||||
'two_level_person' type,
|
||||
capa.person_belong_type,
|
||||
capa.audit_person_user_id audit_user_id,
|
||||
capa.audit_person_user_name audit_user_name,
|
||||
capa.audit_flag
|
||||
FROM
|
||||
closed_area_person_apply capa
|
||||
WHERE
|
||||
capa.delete_enum = 'FALSE'
|
||||
AND capa.audit_flag = 1
|
||||
) tmp
|
||||
vi_app_user_todo tmp
|
||||
where tmp.audit_user_id = #{params.userId}
|
||||
GROUP BY
|
||||
tmp.type,
|
||||
|
|
|
|||
Loading…
Reference in New Issue