Browse Source

提交民生诉求对接

v2
chenrui 2 years ago
parent
commit
d347ea684d
  1. 2
      lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java
  2. 45
      lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java
  3. 5
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml
  4. 333
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/MssqAddOrder.java
  5. 65
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/MssqBaseDomain.java
  6. 13
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/QrCodeGenerateHistory.java
  7. 2
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java
  8. 293
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/utils/ServiceInvocation.java
  9. 7
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/QrCodeGenerateHistoryMapper.xml

2
lib/EmergencyBaseLib/EmergencyCommon/src/main/java/com/zdxt/common/util/IdCardCryptoUtil.java

@ -34,7 +34,7 @@ public class IdCardCryptoUtil {
String userNameCode = IdCardCryptoUtil.symmetricEncryptIdCard("eWIzY3BMRVNEQXhvUUlXMA==", "汪鑫");
// String secret = IdCardCryptoUtil.symmetricEncryptIdCard("eWIzY3BMRVNEQXhvUUlXMA==", "ae739d8c-86ed-4898-b57d-eed3be42debf");
String phone = IdCardCryptoUtil.symmetricDecryptIdCard("VRJHzFqJpsSZhwnsKTWNspv_GZMxTWl-bgH6DyE9Ty0", "31nylKvncOOOz4z0RNiEcQDv5OcXNQowwTb9vUh8RCo=");
String phone = IdCardCryptoUtil.symmetricDecryptIdCard("VRJHzFqJpsSZhwnsKTWNspv_GZMxTWl-bgH6DyE9Ty0", "3qQTst9aURL3pN5EzKtqVJnQv2Q0Ob3r+Gc9DXX/I30=");
// System.out.println(userIdCode);
// System.out.println(phone);

45
lib/EmergencyService/zdxtEmergencyAppService/src/main/java/com/zdxt/app/controller/AppThirdLoginController.java

@ -9,6 +9,7 @@ import com.zdxt.auth.project.system.user.service.IUserService;
import com.zdxt.code.domain.SiqLogin;
import com.zdxt.code.service.ThirdLoginService;
import com.zdxt.code.utils.HttpUtil;
import com.zdxt.code.utils.ServiceInvocation;
import com.zdxt.common.util.IdCardCryptoUtil;
import com.zdxt.code.utils.ZwSmsClient;
import com.zdxt.common.ZDResponse;
@ -26,6 +27,9 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import static com.zdxt.code.utils.ServiceInvocation.gatewaySignEncode;
import static com.zdxt.code.utils.ServiceInvocation.httpRequest;
/**
* 第三方登录控制层
*/
@ -280,4 +284,45 @@ public class AppThirdLoginController {
return ZDResponse.success("校验成功",aBoolean);
}
@GetMapping("/getMssqToken")
@ResponseBody
public ZDResponse getMssqToken(String appId,String appKey,String generateTokenUrl) throws Exception {
// zwSmsClient.sendMessage(phone,content);
// Boolean aBoolean = thirdLoginService.checkIsLawOfficer(idCards);
// 参数设定
// String appId = "67a83c8a136346cd98f844359902a23c";
// String appKey = "NjdhODNjOGExMzYzNDZjZDk4Zjg0NDM1OTkwMmEyM2M6TXNzcTIwMjQ=";
/*String appId = "ea5acb3cceb24365b415e9affa560d49";
String appKey = "ZWE1YWNiM2NjZWIyNDM2NWI0MTVlOWFmZmE1NjBkNDk6eDEyMzQ1Ng==";*/
String currTime = String.valueOf(System.currentTimeMillis());
//服务聚合获取tokenUrl
// String generateTokenUrl = "http://10.132.108.3/mssqApi/auth/token";
// String invokingServiceUrl="http://10.132.108.3/mssqApi/auth/token";
String invokingServiceRequestMethod="POST";
// 服务调用的请求方法
// 1.获取本地签名
String tokenSign = gatewaySignEncode(appId, appKey, currTime);
// 2.调用获取token接口
JSONObject jsonObject = ServiceInvocation.httpRequest(generateTokenUrl, "POST", "", appId, currTime, tokenSign);
JSONObject jsonObjectBody = JSONObject.parseObject(jsonObject.getString("body"));
log.info("民生诉求获取token接口:{}",jsonObject);
if (jsonObjectBody != null) {
String accessToken = jsonObjectBody.getString("access_token");
// 3.在获得服务调用秘钥access_token后,根据自己的appKey使用AES解密算法对返回值进行解密,最终获取签名密钥secretKey
String secretKey = ServiceInvocation.gatewayAesDecode(appKey, accessToken);
// 4.获取本地签名
String sign = ServiceInvocation.gatewaySignEncode(appId, secretKey, currTime);
// //4.调用服务接口
// JSONObject serviceJsonData = httpRequestForInterface(invokingServiceUrl, invokingServiceRequestMethod, "", appId, currTime, sign);
// String codeValue = serviceJsonData.getString("code");
// if (codeValue.equals("200")) {
// log.info("请求url:{},响应成功!",invokingServiceUrl);
// } else {
// log.error("请求url:{},响应失败!",invokingServiceUrl);
// }
} else {}
return ZDResponse.success("校验成功",null);
}
}

5
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/application.yml

@ -208,7 +208,7 @@ security:
allowed:
servernames: 10.76.108.1,10.76.108.3,10.132.108.3,139.186.135.156,jdm.szssfj.cn,58.250.157.161,127.0.0.1
servernames: 10.76.108.1,10.76.108.3,10.132.108.3,139.186.135.156,jdm.szssfj.cn,58.250.157.161,192.168.31.146,localhost,10.76.108.25
excel:
export: true
@ -268,6 +268,9 @@ srnwg:
# paasToken: e64638a4483e8bcfc33d935c3cbdf546
mssq:
appId: 67a83c8a136346cd98f844359902a23c
appkey: NjdhODNjOGExMzYzNDZjZDk4Zjg0NDM1OTkwMmEyM2M6TXNzcTIwMjQ=
#短信平台
sms:

333
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/MssqAddOrder.java

@ -0,0 +1,333 @@
package com.zdxt.code.domain;
import java.util.List;
/**
* 民生诉求工单DTO
*/
public class MssqAddOrder extends MssqBaseDomain {
/**
* 诉求标题
*/
private String requestTopic;
/**
* 诉求内容
*/
private String requestContent;
/**
* 联系人姓名
*/
private String contactName;
/**
* 联系人电话
*/
private String contactTel;
/**
* 证件类型字典参数类型zjlx
*/
private String certType;
/**
* 证件号码
*/
private String certCode;
/**
* 联系地址
*/
private String contactAddress;
/**
* 事发地址
*/
private String requestArea;
/**
* 事发详细地址X坐标
*/
private String addressX;
/**
* 事发详细地址Y坐标
*/
private String addressY;
/**
* 来源渠道字典参数类型sqly
*/
private Integer requestFrom;
/**
* 公开意向 y公开 n不公开
*/
private String pubIntent;
/**
* 工单类型字典参数类型sqlx
*/
private Integer orderType;
/**
* 是否党员: 1: ; 0:
*/
private Integer isParty;
/**
* 第三方系统工单id
*/
private String extendId;
/**
* 事发地址所属区
*/
private String area;
/**
* 事发地址所属街道
*/
private String street;
/**
* 是否保密 1: ; 0:
*/
private Integer isSecrecy;
/**
* 事项编码
*/
private String actCode;
/**
* 诉求分类个人/商事主体 1: 个人; 2: 商事主体
*/
private String formUserNature;
/**
* 涉事主体
*/
private String thingSubject;
/**
* 涉事主体地址****街道**
*/
private String subjectAddress;
/**
* 上传附件数据集
*/
private List<FileData> fileDatas;
private class FileData{
/**
* 附件名称
*/
private String fileName;
/**
* 附件数据流需要转成Base64编码格式
*/
private String fileBytes;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileBytes() {
return fileBytes;
}
public void setFileBytes(String fileBytes) {
this.fileBytes = fileBytes;
}
}
public String getRequestTopic() {
return requestTopic;
}
public void setRequestTopic(String requestTopic) {
this.requestTopic = requestTopic;
}
public String getRequestContent() {
return requestContent;
}
public void setRequestContent(String requestContent) {
this.requestContent = requestContent;
}
public String getContactName() {
return contactName;
}
public void setContactName(String contactName) {
this.contactName = contactName;
}
public String getContactTel() {
return contactTel;
}
public void setContactTel(String contactTel) {
this.contactTel = contactTel;
}
public String getCertType() {
return certType;
}
public void setCertType(String certType) {
this.certType = certType;
}
public String getCertCode() {
return certCode;
}
public void setCertCode(String certCode) {
this.certCode = certCode;
}
public String getContactAddress() {
return contactAddress;
}
public void setContactAddress(String contactAddress) {
this.contactAddress = contactAddress;
}
public String getRequestArea() {
return requestArea;
}
public void setRequestArea(String requestArea) {
this.requestArea = requestArea;
}
public String getAddressX() {
return addressX;
}
public void setAddressX(String addressX) {
this.addressX = addressX;
}
public String getAddressY() {
return addressY;
}
public void setAddressY(String addressY) {
this.addressY = addressY;
}
public Integer getRequestFrom() {
return requestFrom;
}
public void setRequestFrom(Integer requestFrom) {
this.requestFrom = requestFrom;
}
public String getPubIntent() {
return pubIntent;
}
public void setPubIntent(String pubIntent) {
this.pubIntent = pubIntent;
}
public Integer getOrderType() {
return orderType;
}
public void setOrderType(Integer orderType) {
this.orderType = orderType;
}
public Integer getIsParty() {
return isParty;
}
public void setIsParty(Integer isParty) {
this.isParty = isParty;
}
public String getExtendId() {
return extendId;
}
public void setExtendId(String extendId) {
this.extendId = extendId;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public Integer getIsSecrecy() {
return isSecrecy;
}
public void setIsSecrecy(Integer isSecrecy) {
this.isSecrecy = isSecrecy;
}
public String getActCode() {
return actCode;
}
public void setActCode(String actCode) {
this.actCode = actCode;
}
public String getFormUserNature() {
return formUserNature;
}
public void setFormUserNature(String formUserNature) {
this.formUserNature = formUserNature;
}
public String getThingSubject() {
return thingSubject;
}
public void setThingSubject(String thingSubject) {
this.thingSubject = thingSubject;
}
public String getSubjectAddress() {
return subjectAddress;
}
public void setSubjectAddress(String subjectAddress) {
this.subjectAddress = subjectAddress;
}
public List<FileData> getFileDatas() {
return fileDatas;
}
public void setFileDatas(List<FileData> fileDatas) {
this.fileDatas = fileDatas;
}
}

65
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/MssqBaseDomain.java

@ -0,0 +1,65 @@
package com.zdxt.code.domain;
public class MssqBaseDomain {
/**
* 认证token
*/
private String accessToken;
/**
* 分配的appId
*/
private String appId;
/**
* 请求头携带的appId
*/
private String gatewayAppId;
/**
* 请求头携带的签名
*/
private String gatewaySig;
/**
* 请求头携带的当前时间的时间戳
*/
private String gatewayRtime;
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getGatewayAppId() {
return gatewayAppId;
}
public void setGatewayAppId(String gatewayAppId) {
this.gatewayAppId = gatewayAppId;
}
public String getGatewaySig() {
return gatewaySig;
}
public void setGatewaySig(String gatewaySig) {
this.gatewaySig = gatewaySig;
}
public String getGatewayRtime() {
return gatewayRtime;
}
public void setGatewayRtime(String gatewayRtime) {
this.gatewayRtime = gatewayRtime;
}
}

13
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/QrCodeGenerateHistory.java

@ -43,6 +43,11 @@ public class QrCodeGenerateHistory extends BaseDomain
*/
private String reasonsChange;
/**
* 搜索时间
*/
private String searchDate;
public void setId(String id)
{
this.id = id;
@ -107,6 +112,14 @@ public class QrCodeGenerateHistory extends BaseDomain
this.reasonsChange = reasonsChange;
}
public String getSearchDate() {
return searchDate;
}
public void setSearchDate(String searchDate) {
this.searchDate = searchDate;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

2
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnterpriseInformationServiceImpl.java

@ -148,6 +148,8 @@ public class EnterpriseInformationServiceImpl implements IEnterpriseInformationS
qrCodeGenerateHistory.setQrCodeUrl(upload);
//统一信用代码
qrCodeGenerateHistory.setEnterpriseNumber(enterpriseInformation.getEnterpriseNumber());
//变更原因
qrCodeGenerateHistory.setReasonsChange("登记");
iQrCodeGenerateHistoryService.insertQrCodeGenerateHistory(qrCodeGenerateHistory);
}catch (Exception e){
e.printStackTrace();

293
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/utils/ServiceInvocation.java

@ -0,0 +1,293 @@
package com.zdxt.code.utils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.crypto.*;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
/**
* 民生诉求氢气
*/
@Slf4j
@Component
public class ServiceInvocation {
/**
* 密钥生成核心网关
*
* @param appKey 授权码
* @param appId 请求者标识
* @param rtime 请求时间戳
* @return 加密后的sign
*/
public static String gatewaySignEncode(String appId, String appKey, String rtime) throws Exception {
String inputString = appId + rtime;
return encode(appKey, inputString);
}
/**
* 应用公钥appKey进行HMAC-SHA256计算并进行base64转码产生签名
*
* @param appKey
* @param inputStr
* @return
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
* @throws InvalidKeyException
*/
private static String encode(String appKey, String inputStr) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
String sign;
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
byte[] keyBytes = appKey.getBytes("UTF-8");
hmacSha256.init(new SecretKeySpec(keyBytes, 0, keyBytes.length, "HmacSHA256"));
byte[] hmacSha256Bytes = hmacSha256.doFinal(inputStr.getBytes("UTF-8"));
sign = new String(Base64.encodeBase64(hmacSha256Bytes), "UTF-8");
return sign;
}
/**
* 解密 解密过程 1.构造密钥生成器 2.根据ecnodeRules规则初始化密钥生成器 3.产生密钥 4.创建和初始化密码器
* 5.将加密后的字符串反纺成byte[]数组 6.将加密内容解密
*/
public static String gatewayAesDecode(String encryptPass, String base64Content) {
byte[] content = cn.hutool.core.codec.Base64.decode(base64Content);
if (content.length < 28) {
throw new IllegalArgumentException();
} else {
GCMParameterSpec params = new GCMParameterSpec(128, content, 0, 12);
try {
Cipher cipher = Cipher.getInstance("AES/GCM/PKCS5Padding");
cipher.init(2, getSecretKey(encryptPass), params);
byte[] decryptData = cipher.doFinal(content, 12, content.length - 12);
return new String(decryptData);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException | InvalidKeyException var6) {
log.error("解密失败:{}", var6.getMessage());
return null;
}
}
}
private static SecretKeySpec getSecretKey(String encryptPass) throws NoSuchAlgorithmException {
KeyGenerator kg = KeyGenerator.getInstance("AES");
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.setSeed(encryptPass.getBytes());
kg.init(128, secureRandom);
SecretKey secretKey = kg.generateKey();
return new SecretKeySpec(secretKey.getEncoded(), "AES");
}
/**
* http请求过程
*
* @param requestUrl 请求的url在服务调用过程中url为获取token的url格式为ip:port/auth/token或者是服务调用的url
* @param requestMethod 获取token时请求方法为POST调用服务是请求方法依据服务注册时定义
* @param appIdorSecretKey 获取token时该参数为appId抵用服务时该参数为SecretKey
* @param currTime 该参数为当前时间
* @param sign 该参数为head参数gateway_sig由秘钥生成方法gatewaySignEncode生成
* @return
*/
public static JSONObject httpRequest(String requestUrl, String requestMethod, String reqBody, String appIdorSecretKey,
String currTime, String sign) throws Exception {
JSONObject jsonObject;
StringBuffer buffer = new StringBuffer();
InputStream inputStream = null;
try {
System.setProperty("http.agent", "Chrome");
URL url = new URL(requestUrl);
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
httpUrlConnection.setRequestMethod(requestMethod);
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setDoInput(true);
httpUrlConnection.setRequestProperty("gateway_appid", appIdorSecretKey);
httpUrlConnection.setRequestProperty("gateway_rtime", currTime);
httpUrlConnection.setRequestProperty("gateway_sig", sign);
if ("POST".equalsIgnoreCase(requestMethod) && StringUtils.isNotBlank(reqBody)) {
httpUrlConnection.setRequestProperty("Content-Type", "application/json");
httpUrlConnection.setRequestProperty("Accept", "application/json");
OutputStream os = httpUrlConnection.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
osw.write(reqBody);
osw.flush();
osw.close();
}
httpUrlConnection.connect();
inputStream = httpUrlConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferReader = new BufferedReader(inputStreamReader);
String str;
while ((str = bufferReader.readLine()) != null) {
buffer.append(str);
}
String buffer2str = buffer.toString();
jsonObject = JSONObject.parseObject(buffer2str);
bufferReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
httpUrlConnection.disconnect();
} catch (ConnectException ce) {
log.error("Server connect time out!",ce);
System.out.println("Server connect time out!");
throw new ConnectException();
} catch (IOException ioe) {
log.error("ioexception request error",ioe);
throw new IOException();
} catch (Exception e) {
log.error("http request error!",e);
throw e;
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
return jsonObject;
}
private static JSONObject httpRequestForInterface(String requestUrl, String requestMethod, String reqBody, String appIdorSecretKey,
String currTime, String sign) throws Exception {
JSONObject jsonObject=new JSONObject();
StringBuffer buffer = new StringBuffer();
InputStream inputStream = null;
try {
System.setProperty("http.agent", "Chrome");
URL url = new URL(requestUrl);
HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();
httpUrlConnection.setRequestMethod(requestMethod);
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setDoInput(true);
httpUrlConnection.setRequestProperty("gateway_appid", appIdorSecretKey);
httpUrlConnection.setRequestProperty("gateway_rtime", currTime);
httpUrlConnection.setRequestProperty("gateway_sig", sign);
if ("POST".equalsIgnoreCase(requestMethod) && StringUtils.isNotBlank(reqBody)) {
httpUrlConnection.setRequestProperty("Content-Type", "application/json");
httpUrlConnection.setRequestProperty("Accept", "application/json");
OutputStream os = httpUrlConnection.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
osw.write(reqBody);
osw.flush();
osw.close();
}
httpUrlConnection.connect();
inputStream = httpUrlConnection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferReader = new BufferedReader(inputStreamReader);
String str;
while ((str = bufferReader.readLine()) != null) {
buffer.append(str);
}
String buffer2str = buffer.toString();
jsonObject.put("code",httpUrlConnection.getResponseCode());
jsonObject.put("result",buffer2str);
bufferReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
httpUrlConnection.disconnect();
} catch (ConnectException ce) {
log.error("Server connect time out!",ce);
throw new ConnectException();
} catch (IOException ioe) {
log.error("ioexception request error",ioe);
throw new IOException();
} catch (Exception e) {
log.error("http request error!",e);
throw e;
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
return jsonObject;
}
private static void test(String id, String code,String invokingServiceRequestMethod, String invokingServiceUrl,String reqBodyForUrl) throws Exception {
// 参数设定
String appId = id;
String appKey = code;
String currTime = System.currentTimeMillis() + "";
//服务聚合获取tokenUrl
String generateTokenUrl = "http://10.132.108.3/mssqApi/auth/token";
// 服务调用的请求方法
// 1.获取本地签名
String tokenSign = gatewaySignEncode(appId, appKey, currTime);
// 2.调用获取token接口
JSONObject jsonObject = httpRequest(generateTokenUrl, "POST", "", appId, currTime, tokenSign);
JSONObject jsonObjectBody = JSONObject.parseObject(jsonObject.getString("body"));
if (jsonObjectBody != null) {
String accessToken = jsonObjectBody.getString("access_token");
// 3.在获得服务调用秘钥access_token后,根据自己的appKey使用AES解密算法对返回值进行解密,最终获取签名密钥secretKey
String secretKey = gatewayAesDecode(appKey, accessToken);
// 4.获取本地签名
String sign = gatewaySignEncode(appId, secretKey, currTime);
//4.调用服务接口
JSONObject serviceJsonData = httpRequestForInterface(invokingServiceUrl, invokingServiceRequestMethod, reqBodyForUrl, appId, currTime, sign);
String codeValue = serviceJsonData.getString("code");
if (codeValue.equals("200")) {
log.info("请求url:{},响应成功!",invokingServiceUrl);
} else {
log.error("请求url:{},响应失败!",invokingServiceUrl);
}
} else {
}
}
public static void main(String[] args) throws Exception {
// 参数设定
String appId = "67a83c8a136346cd98f844359902a23c";
String appKey = "NjdhODNjOGExMzYzNDZjZDk4Zjg0NDM1OTkwMmEyM2M6TXNzcTIwMjQ=";
/*String appId = "ea5acb3cceb24365b415e9affa560d49";
String appKey = "ZWE1YWNiM2NjZWIyNDM2NWI0MTVlOWFmZmE1NjBkNDk6eDEyMzQ1Ng==";*/
String currTime = String.valueOf(System.currentTimeMillis());
//服务聚合获取tokenUrl
String generateTokenUrl = "http://10.132.108.3/mssqApi/auth/token";
String invokingServiceUrl="http://10.132.108.3/mssqApi/auth/token";
String invokingServiceRequestMethod="POST";
// 服务调用的请求方法
// 1.获取本地签名
String tokenSign = gatewaySignEncode(appId, appKey, currTime);
// 2.调用获取token接口
JSONObject jsonObject = httpRequest(generateTokenUrl, "POST", "", appId, currTime, tokenSign);
JSONObject jsonObjectBody = JSONObject.parseObject(jsonObject.getString("body"));
System.out.println(jsonObject);
if (jsonObjectBody != null) {
String accessToken = jsonObjectBody.getString("access_token");
// 3.在获得服务调用秘钥access_token后,根据自己的appKey使用AES解密算法对返回值进行解密,最终获取签名密钥secretKey
String secretKey = gatewayAesDecode(appKey, accessToken);
// 4.获取本地签名
String sign = gatewaySignEncode(appId, secretKey, currTime);
// //4.调用服务接口
JSONObject serviceJsonData = httpRequestForInterface(invokingServiceUrl, invokingServiceRequestMethod, "", appId, currTime, sign);
// String codeValue = serviceJsonData.getString("code");
// if (codeValue.equals("200")) {
// log.info("请求url:{},响应成功!",invokingServiceUrl);
// } else {
// log.error("请求url:{},响应失败!",invokingServiceUrl);
// }
} else {}
// test(appId,appKey,"post","","");
}
}

7
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/QrCodeGenerateHistoryMapper.xml

@ -23,6 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="generateTime != null "> and generate_time = #{generateTime}</if>
<if test="qrCodeUrl != null and qrCodeUrl != ''"> and qr_code_url = #{qrCodeUrl}</if>
<if test="enterpriseNumber != null and enterpriseNumber != ''"> and enterprise_number = #{enterpriseNumber}</if>
<if test="searchValue != null and searchValue != ''"> and reasons_change like concat('%', #{searchValue}, '%')</if>
<if test="searchDate != null and searchDate != ''">
and DATE_FORMAT(generate_time, '%Y-%m') = #{searchDate}
</if>
</where>
order by generate_time desc
</select>
@ -46,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="qrCodeUrl != null and qrCodeUrl != ''">qr_code_url,</if>
<if test="enterpriseNumber != null and enterpriseNumber != ''">enterprise_number,</if>
<if test="status != null">status,</if>
<if test="reasonsChange != null and reasonsChange != ''">reasons_change,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
@ -53,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="qrCodeUrl != null and qrCodeUrl != ''">#{qrCodeUrl},</if>
<if test="enterpriseNumber != null and enterpriseNumber != ''">#{enterpriseNumber},</if>
<if test="status != null ">#{status},</if>
<if test="reasonsChange != null and reasonsChange != ''">#{reasonsChange},</if>
</trim>
</insert>

Loading…
Cancel
Save