Commit 0f4d5fe6 authored by 5359's avatar 5359

中登网开发

parent c928c017
package com.hand.app.zhongDengWang.dto;
/**
* Auto Generated By Hap Code Generator
**/
import com.hand.hap.mybatis.annotation.ExtensionAttribute;
import com.hand.hap.system.dto.BaseDTO;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@ExtensionAttribute(disable = true)
@Table(name = "FND_ZHONG_DENG_BATCH")
public class FndZhongDengBatch extends BaseDTO {
private Long batchId;
private Long lineId;
public void setBatchId(Long batchId) {
this.batchId = batchId;
}
public Long getBatchId() {
return batchId;
}
public void setLineId(Long lineId) {
this.lineId = lineId;
}
public Long getLineId() {
return lineId;
}
}
package com.hand.app.zhongDengWang.mapper;
import com.hand.app.zhongDengWang.dto.FndZhongDengBatch;
import com.hand.hap.mybatis.common.Mapper;
public interface FndZhongDengBatchMapper extends Mapper<FndZhongDengBatch> {
}
\ No newline at end of file
...@@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSONObject;
import com.hand.app.zhongDengWang.service.IZdwWsRequestsService; import com.hand.app.zhongDengWang.service.IZdwWsRequestsService;
import com.hand.app.zhongDengWang.dto.ZdwLoginTokenInterface; import com.hand.app.zhongDengWang.dto.ZdwLoginTokenInterface;
import com.hand.app.zhongDengWang.dto.FndZhongDengLines; import com.hand.app.zhongDengWang.dto.FndZhongDengLines;
import com.hand.app.zhongDengWang.dto.FndZhongDengBatch;
import com.hand.app.zhongDengWang.service.IFndZhongDengLinesService;
import com.hand.app.zhongDengWang.mapper.ZdwLoginTokenInterfaceMapper; import com.hand.app.zhongDengWang.mapper.ZdwLoginTokenInterfaceMapper;
import com.hand.app.zhongDengWang.mapper.FndZhongDengLinesMapper; 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.utils.ClientUtils;
import com.hand.app.zhongDengWang.ws.init.WSInitRegisterService; import com.hand.app.zhongDengWang.ws.init.WSInitRegisterService;
import com.hand.app.zhongDengWang.ws.init.WSInitRegisterServiceService; import com.hand.app.zhongDengWang.ws.init.WSInitRegisterServiceService;
...@@ -14,6 +17,7 @@ import com.hand.app.zhongDengWang.ws.login.WSLoginServiceService; ...@@ -14,6 +17,7 @@ import com.hand.app.zhongDengWang.ws.login.WSLoginServiceService;
import com.hand.app.zhongDengWang.dto.FndAtmAttachmentDto; import com.hand.app.zhongDengWang.dto.FndAtmAttachmentDto;
import com.hand.app.zhongDengWang.mapper.FndAtmAttachmentMapper; import com.hand.app.zhongDengWang.mapper.FndAtmAttachmentMapper;
import com.hand.hap.core.IRequest; import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.DTOStatus;
import com.rfp.sm.utils.SM2Utils; import com.rfp.sm.utils.SM2Utils;
import org.json.XML; import org.json.XML;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -33,7 +37,12 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService { ...@@ -33,7 +37,12 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
@Autowired @Autowired
FndZhongDengLinesMapper fndZhongDengLinesMapper; FndZhongDengLinesMapper fndZhongDengLinesMapper;
@Autowired @Autowired
IFndZhongDengLinesService fndZhongDengLinesService;
@Autowired
FndAtmAttachmentMapper fndAtmAttachmentMapper; FndAtmAttachmentMapper fndAtmAttachmentMapper;
@Autowired
FndZhongDengBatchMapper fndZhongDengBatchMapper;
@Value("${zdw.login.clientKey}") @Value("${zdw.login.clientKey}")
private String clientKey; private String clientKey;
...@@ -107,9 +116,15 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService { ...@@ -107,9 +116,15 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
***/ ***/
public JSONObject initRegisterService(IRequest request, Long batchId) { public JSONObject initRegisterService(IRequest request, Long batchId) {
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
List<Long> lineIds = new ArrayList<>();
lineIds.add(batchId); /*根据批次ID获取所有上报请求id*/
if (lineIds.size() == 0) { List<FndZhongDengBatch> fndZhongDengBatches = new ArrayList<>();
FndZhongDengBatch fndZhongDengBatch = new FndZhongDengBatch();
fndZhongDengBatch.setBatchId(batchId);
fndZhongDengBatches = fndZhongDengBatchMapper.select(fndZhongDengBatch);
if (fndZhongDengBatches.size() == 0) {
resultJson.put("code", "000"); resultJson.put("code", "000");
resultJson.put("info", "000"); resultJson.put("info", "000");
return resultJson; return resultJson;
...@@ -135,21 +150,25 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService { ...@@ -135,21 +150,25 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
resultJson.put("info", errorInfo); resultJson.put("info", errorInfo);
} else { } else {
List<FndZhongDengLines> fndZhongDengLinesList = new ArrayList<>();
/*根据传入ids循环上报中登网*/ /*根据传入ids循环上报中登网*/
for (Long lineId : lineIds) { for (FndZhongDengBatch batch : fndZhongDengBatches) {
FndZhongDengLines fndZhongDengLines = new FndZhongDengLines(); FndZhongDengLines fndZhongDengLines = new FndZhongDengLines();
fndZhongDengLines.setLineId(lineId); fndZhongDengLines.setLineId(batch.getLineId());
fndZhongDengLines = fndZhongDengLinesMapper.selectByPrimaryKey(fndZhongDengLines); fndZhongDengLines = fndZhongDengLinesMapper.selectByPrimaryKey(fndZhongDengLines);
if (Objects.nonNull(fndZhongDengLines)) { if (Objects.nonNull(fndZhongDengLines)) {
try { try {
String returnMsg = ""; String registerResult = "";
String registerNumber = "";
String authorizationCode = "";
String error = "";
org.json.JSONObject returnJson; org.json.JSONObject returnJson;
FndAtmAttachmentDto fndAtmAttachmentDto=new FndAtmAttachmentDto(); FndAtmAttachmentDto fndAtmAttachmentDto = new FndAtmAttachmentDto();
fndAtmAttachmentDto.setAttachmentId(fndZhongDengLines.getAttachmentXmlId()); fndAtmAttachmentDto.setAttachmentId(fndZhongDengLines.getAttachmentXmlId());
fndAtmAttachmentDto=fndAtmAttachmentMapper.selectByPrimaryKey(fndAtmAttachmentDto); fndAtmAttachmentDto = fndAtmAttachmentMapper.selectByPrimaryKey(fndAtmAttachmentDto);
/*解析xml文件内容*/ /*解析xml文件内容*/
xmlFileContent = new String(ClientUtils.getxmlFileContent(fndAtmAttachmentDto.getFilePath())); xmlFileContent = new String(ClientUtils.getxmlFileContent(fndAtmAttachmentDto.getFilePath()));
...@@ -159,23 +178,50 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService { ...@@ -159,23 +178,50 @@ public class ZdwWsRequestsServiceImpl implements IZdwWsRequestsService {
xmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey); xmlFileContent = SM2Utils.encryptByKeyStr(xmlFileContent, clientKey);
platformAuthCode = SM2Utils.encryptByKeyStr(platformAuthCode, clientKey); platformAuthCode = SM2Utils.encryptByKeyStr(platformAuthCode, clientKey);
WSInitRegisterServiceService service = new WSInitRegisterServiceService(); // WSInitRegisterServiceService service = new WSInitRegisterServiceService();
WSInitRegisterService reg = service.getWSInitRegisterServicePort(); // WSInitRegisterService reg = service.getWSInitRegisterServicePort();
byte[] returns = reg.initRegister(fndZhongDengLines.getTypebz().getBytes(), platformAuthCode.getBytes(), loginToken.getBytes(), "lr".getBytes(), xmlFileContent.getBytes(), ClientUtils.getAttachmentZip(attachmentZipPath)); // byte[] returns = reg.initRegister(fndZhongDengLines.getTypebz().getBytes(), platformAuthCode.getBytes(), loginToken.getBytes(), "lr".getBytes(), xmlFileContent.getBytes(), ClientUtils.getAttachmentZip(attachmentZipPath));
returnMsg = new String(returns); 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();
returnJson = XML.toJSONObject(returnMsg); returnJson = XML.toJSONObject(new String(returns));
registerResult = returnJson.getJSONObject("feedback").getString("registerresult");
registerNumber = returnJson.getJSONObject("feedback").getString("registernumber");
authorizationCode = returnJson.getJSONObject("feedback").getString("authorizationcode");
if (Objects.nonNull(registerResult) && "001".equalsIgnoreCase(registerResult)) {
fndZhongDengLines.setRegisterNumber(registerNumber);
fndZhongDengLines.setAuthorizationCode(authorizationCode);
fndZhongDengLines.setUpStatus("SUCCESS");
fndZhongDengLines.setReturnMsg("上报成功");
} else {
error = returnJson.getJSONObject("feedback").getString("errors");
fndZhongDengLines.setUpStatus("FAIL");
fndZhongDengLines.setReturnMsg(error);
}
fndZhongDengLines.set__status(DTOStatus.UPDATE);
System.out.println("dddd" + new String(returns)); System.out.println("dddd" + new String(returns));
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
fndZhongDengLines.setUpStatus("FAIL");
fndZhongDengLines.setReturnMsg(e.getMessage());
} }
fndZhongDengLinesList.add(fndZhongDengLines);
} }
} }
if (fndZhongDengLinesList.size() > 0) {
fndZhongDengLinesService.batchUpdate(request, fndZhongDengLinesList);
}
resultJson.put("code", "000");
resultJson.put("info", "000");
} }
return resultJson; return resultJson;
} }
......
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