Commit 61fee2ba authored by Sora's avatar Sora

[feat]增加变更、展期、注销登记方法

parent 81d8cd97
......@@ -46,9 +46,7 @@ public class ZdwWsRequestsController extends BaseController {
@ResponseBody
public JSONObject initRegister(HttpServletRequest request, @RequestBody Long batchId) {
IRequest requestContext = createRequestContext(request);
JSONObject resultJson = new JSONObject();
resultJson = service.initRegisterService(requestContext, batchId);
return resultJson;
return service.initRegisterService(requestContext, batchId);
}
}
\ No newline at end of file
package com.hand.app.zhongDengWang.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hand.app.zhongDengWang.service.IZdwWsRequestsService;
import com.hand.app.zhongDengWang.dto.ZdwLoginTokenInterface;
......@@ -13,12 +14,18 @@ import com.hand.app.zhongDengWang.mapper.ZdwLoginTokenInterfaceMapper;
import com.hand.app.zhongDengWang.mapper.FndZhongDengLinesMapper;
import com.hand.app.zhongDengWang.mapper.FndZhongDengBatchMapper;
import com.hand.app.zhongDengWang.utils.ClientUtils;
import com.hand.app.zhongDengWang.ws.amend.WSAmendRegisterService;
import com.hand.app.zhongDengWang.ws.amend.WSAmendRegisterServiceService;
import com.hand.app.zhongDengWang.ws.extend.WSExtendRegisterService;
import com.hand.app.zhongDengWang.ws.extend.WSExtendRegisterServiceService;
import com.hand.app.zhongDengWang.ws.init.WSInitRegisterService;
import com.hand.app.zhongDengWang.ws.init.WSInitRegisterServiceService;
import com.hand.app.zhongDengWang.ws.login.WSLoginService;
import com.hand.app.zhongDengWang.ws.login.WSLoginServiceService;
import com.hand.app.zhongDengWang.dto.FndAtmAttachmentDto;
import com.hand.app.zhongDengWang.mapper.FndAtmAttachmentMapper;
import com.hand.app.zhongDengWang.ws.terminate.WSTerminateRegisterService;
import com.hand.app.zhongDengWang.ws.terminate.WSTerminateRegisterServiceService;
import com.hand.hap.core.IRequest;
import com.hand.hap.lock.components.DatabaseLockProvider;
import com.hand.hap.system.dto.DTOStatus;
......@@ -30,10 +37,7 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -142,17 +146,40 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
return hlsWsRequests;
}
public JSONObject registerInit(String registerTypeBz, String platformAuthCode, String loginToken, String xmlFileName, String xmlFileContent, Long lineId) {
JSONObject resultJson = new JSONObject();
/**
* 设置错误信息
* @param resultJson 返回给前端的结果集
* @param hlsWsRequests 储存给数据库的请求体
* @param e 异常
*/
public void setErrData(JSONObject resultJson, HlsWsRequests hlsWsRequests, Exception e){
resultJson.put("code", "-1");
resultJson.put("info", e.getMessage());
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
}
/**
* 设置返回信息
* @param resultJson 返回给前端的结果集
* @param hlsWsRequests 储存给数据库的请求体
* @param resData 返回字符串
*/
public void setResData(JSONObject resultJson, HlsWsRequests hlsWsRequests, String resData){
resultJson.put("code", "0");
resultJson.put("info", resData);
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponseClob(resData);
}
public JSONObject registerInit(String registerTypeBz, String platformAuthCode, String loginToken, String xmlFileName, String xmlFileContent, Long lineId) {
JSONObject resultJson = new JSONObject();
String encryXmlFileContent = "";
String encryLoginToken = "";
String attachmentZipPath = "";
String encryPlatformAuthCode = "";
HlsWsRequests hlsWsRequests = new HlsWsRequests();
try {
/*SM2算法加密*/
encryLoginToken = SM2Utils.encryptByKeyStr(loginToken, clientKey);
encryXmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey);
......@@ -167,25 +194,132 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
// byte[] returns = reg.initRegister(registerTypeBz.getBytes(), encryPlatformAuthCode.getBytes(), encryLoginToken.getBytes(), xmlFileName.getBytes(), encryXmlFileContent.getBytes(), ClientUtils.getAttachmentZip(attachmentZipPath));
byte[] returns = "<feedback>\n<registertype>LR</registertype>\n<registerresult>001</registerresult>\n<registernumber>I0000001</registernumber>\n<authorizationcode>A0000001</authorizationcode>\n<errors>\n<error>RegInfoError:100_001</error>\n</errors>\n</feedback>\n".getBytes();
resultJson.put("code", "0");
resultJson.put("info", new String(returns));
hlsWsRequests.setReturnStatus("S");
hlsWsRequests.setResponseClob(new String(returns));
setResData(resultJson, hlsWsRequests, new String(returns));
System.out.println("dddd" + new String(returns));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
resultJson.put("code", "-1");
resultJson.put("info", e.getMessage());
hlsWsRequests.setReturnStatus("E");
hlsWsRequests.setResponsedDate(new Date());
setErrData(resultJson, hlsWsRequests, e);
}
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
public JSONObject registerAmend(String platformAuthCode, String loginToken, String xmlFileContent, String attachmentZipPath, FndZhongDengLines line, FndAtmAttachmentDto attachmentDto){
JSONObject resultJson = new JSONObject();
HlsWsRequests hlsWsRequests = new HlsWsRequests();
try {
/*SM2算法加密*/
String encryLoginToken = SM2Utils.encryptByKeyStr(loginToken, clientKey);
String encryXmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey);
String encryPlatformAuthCode = SM2Utils.encryptByKeyStr(platformAuthCode, clientKey);
String encryAuthorizationCode = SM2Utils.encryptByKeyStr(line.getAuthorizationCode(), clientKey);
String encryRegisterCode = SM2Utils.encryptByKeyStr(line.getRegisterNumber(), clientKey);
//搭建服务
WSAmendRegisterServiceService service = new WSAmendRegisterServiceService();
WSAmendRegisterService amend = service.getWSAmendRegisterServicePort();
//插入接口日志表
hlsWsRequests = createRequestLog("https://ws.zhongdengwang.org.cn/mfrs_ws_test/services/AmendRegisterService?wsdl", xmlFileContent, line.getLineId());
//获取数据
byte[] resBytes = amend.amendRegister(line.getTypebz().getBytes(), encryPlatformAuthCode.getBytes(),
encryLoginToken.getBytes(), encryRegisterCode.getBytes(), encryAuthorizationCode.getBytes(),
attachmentDto.getFileName().getBytes(), encryXmlFileContent.getBytes(),
ClientUtils.getAttachmentZip(attachmentZipPath));
String resData = new String(resBytes);
setResData(resultJson, hlsWsRequests, resData);
} catch (Exception e) {
e.printStackTrace();
setErrData(resultJson, hlsWsRequests, e);
}
//返回结果 给数据库和前端
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
public JSONObject registerExtend(String platformAuthCode, String loginToken, String xmlFileContent, String attachmentZipPath, FndZhongDengLines line, FndAtmAttachmentDto attachmentDto){
JSONObject resultJson = new JSONObject();
HlsWsRequests hlsWsRequests = new HlsWsRequests();
try {
/*SM2算法加密*/
String encryLoginToken = SM2Utils.encryptByKeyStr(loginToken, clientKey);
String encryXmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey);
String encryPlatformAuthCode = SM2Utils.encryptByKeyStr(platformAuthCode, clientKey);
String encryAuthorizationCode = SM2Utils.encryptByKeyStr(line.getAuthorizationCode(), clientKey);
String encryRegisterCode = SM2Utils.encryptByKeyStr(line.getRegisterNumber(), clientKey);
//搭建服务
WSExtendRegisterServiceService service = new WSExtendRegisterServiceService();
WSExtendRegisterService extend = service.getWSExtendRegisterServicePort();
//插入接口日志表
hlsWsRequests = createRequestLog("https://ws.zhongdengwang.org.cn/mfrs_ws_test/services/ExtendRegisterService?wsdl", xmlFileContent, line.getLineId());
//获取数据
byte[] resBytes = extend.extendRegister(line.getTypebz().getBytes(), encryPlatformAuthCode.getBytes(),
encryLoginToken.getBytes(), encryRegisterCode.getBytes(), encryAuthorizationCode.getBytes(),
attachmentDto.getFileName().getBytes(), encryXmlFileContent.getBytes(),
ClientUtils.getAttachmentZip(attachmentZipPath));
String resData = new String(resBytes);
setResData(resultJson, hlsWsRequests, resData);
}
catch (Exception e){
e.printStackTrace();
setErrData(resultJson, hlsWsRequests, e);
}
//返回结果 给数据库和前端
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
public JSONObject registerTerminate(String platformAuthCode, String loginToken, String xmlFileContent, FndZhongDengLines line, FndAtmAttachmentDto attachmentDto){
JSONObject resultJson = new JSONObject();
HlsWsRequests hlsWsRequests = new HlsWsRequests();
try {
/*SM2算法加密*/
String encryLoginToken = SM2Utils.encryptByKeyStr(loginToken, clientKey);
String encryXmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey);
String encryPlatformAuthCode = SM2Utils.encryptByKeyStr(platformAuthCode, clientKey);
String encryAuthorizationCode = SM2Utils.encryptByKeyStr(line.getAuthorizationCode(), clientKey);
String encryRegisterCode = SM2Utils.encryptByKeyStr(line.getRegisterNumber(), clientKey);
//搭建服务
WSTerminateRegisterServiceService service = new WSTerminateRegisterServiceService();
WSTerminateRegisterService terminate = service.getWSTerminateRegisterServicePort();
//插入接口日志表
hlsWsRequests = createRequestLog("https://ws.zhongdengwang.org.cn/mfrs_ws_test/services/TerminateRegisterService?wsdl", xmlFileContent, line.getLineId());
//获取数据
byte[] resBytes = terminate.terminateRegister(line.getTypebz().getBytes(), encryPlatformAuthCode.getBytes(),
encryLoginToken.getBytes(), encryRegisterCode.getBytes(), encryAuthorizationCode.getBytes(),
attachmentDto.getFileName().getBytes(), encryXmlFileContent.getBytes());
String resData = new String(resBytes);
setResData(resultJson, hlsWsRequests, resData);
}
catch (Exception e){
e.printStackTrace();
setErrData(resultJson, hlsWsRequests, e);
}
//返回结果 给数据库和前端
hlsWsRequestsMapper.updateByPrimaryKeySelective(hlsWsRequests);
return resultJson;
}
/***
* 融资租赁-登记入口方法;
* @param
......@@ -197,7 +331,6 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
/*根据传入ids循环上报中登网*/
synchronized (lock) {
for (FndZhongDengBatch batch : fndZhongDengBatches) {
FndZhongDengLines fndZhongDengLines = new FndZhongDengLines();
fndZhongDengLines.setLineId(batch.getLineId());
fndZhongDengLines = fndZhongDengLinesMapper.selectByPrimaryKey(fndZhongDengLines);
......@@ -213,12 +346,22 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
fndAtmAttachmentDto = fndAtmAttachmentMapper.selectByPrimaryKey(fndAtmAttachmentDto);
/*解析xml文件内容*/
xmlFileContent = new String(ClientUtils.getxmlFileContent(fndAtmAttachmentDto.getFilePath()));
xmlFileContent = new String(Objects.requireNonNull(ClientUtils.getxmlFileContent(fndAtmAttachmentDto.getFilePath())));
/*插入接口日志表*/
if ("INIT".equalsIgnoreCase(fndZhongDengLines.getUpStage())) {
resultJson = registerInit(fndZhongDengLines.getTypebz(), platformAuthCode, loginToken, fndAtmAttachmentDto.getFileName(), xmlFileContent, fndZhongDengLines.getLineId());
}
else if("AMEND".equalsIgnoreCase(fndZhongDengLines.getUpStage())){
resultJson = registerAmend(platformAuthCode, loginToken, xmlFileContent, attachmentZipPath, fndZhongDengLines, fndAtmAttachmentDto);
}
else if("EXTEND".equalsIgnoreCase(fndZhongDengLines.getUpStage())){
resultJson = registerExtend(platformAuthCode, loginToken, xmlFileContent, attachmentZipPath, fndZhongDengLines, fndAtmAttachmentDto);
}
else if("TERMINATE".equalsIgnoreCase(fndZhongDengLines.getUpStage())){
resultJson = registerTerminate(platformAuthCode, loginToken, xmlFileContent, fndZhongDengLines, fndAtmAttachmentDto);
}
String returns = "";
if ("0".equalsIgnoreCase(resultJson.getString("code"))) {
returns = resultJson.getString("info");
......@@ -276,6 +419,7 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
* @param request
* @param batchId
***/
@Override
public JSONObject initRegisterService(IRequest request, Long batchId) {
JSONObject resultJson = new JSONObject();
......@@ -315,8 +459,9 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
/*启用新线程进行异步处理中登网接口请求*/
ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
cachedThreadPool.execute(new Runnable() {
@Override
public void run() {
// do
// d
try {
registerThread(request, fndZhongDengBatchList, loginToken);
} catch (Exception e) {
......@@ -407,4 +552,9 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
}
return resultJson;
}
}
\ No newline at end of file
......@@ -91,4 +91,5 @@
<logger name="com.timevale" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.hand.app.zhongDengWang.mapper" level="DEBUG"/>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment