对接北汽风控中台接口测试问题修复

This commit is contained in:
zhanglei@ap-leasing.com.cn 2023-09-05 16:06:19 +08:00
parent 3404b1ebac
commit 67d0dedb58
10 changed files with 1129 additions and 1112 deletions

View File

@ -57,7 +57,6 @@
//alert(getHtmlMessage('1'));//请选择一条信息!
return;
}
debugger;
var afsState = sReturn.split("@");
afsState = afsState[0];
if(typeof(curStatus)=="undefined" ||curStatus.length==0){

View File

@ -132,10 +132,6 @@
<servlet>
<servlet-name>AfsResultServlet</servlet-name>
<servlet-class>com.ample.esb.controller.AfsResultServlet</servlet-class>
<init-param>
<param-name>DataSource</param-name>
<param-value>als</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>ScoreResultServlet</servlet-name>

View File

@ -11,6 +11,9 @@ public class AmpRequest {
@XStreamOmitField
private String operatorId;
@XStreamOmitField
private String flowUnid;
public String getOperatorId() {
return operatorId;
}
@ -19,6 +22,14 @@ public class AmpRequest {
this.operatorId = operatorId;
}
public String getFlowUnid() {
return flowUnid;
}
public void setFlowUnid(String flowUnid) {
this.flowUnid = flowUnid;
}
public String getApplication() {
return application;
}

View File

@ -14,7 +14,6 @@ import com.ample.esb.util.DateUtils;
import com.ample.esb.util.GlobalSeqNo;
import com.ample.esb.util.XstreamUtil;
import com.ample.sms.FileUtil;
import com.thoughtworks.xstream.XStream;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
@ -36,8 +35,7 @@ public class EsbCommon implements EsbServise {
transaction.setMessageBody(messgeBody());
return transaction;
}
public MessageEsbHead getCommonEsbHead() {
MessageEsbHead esbHead = new MessageEsbHead();
public MessageEsbHead getCommonEsbHead(MessageEsbHead esbHead) {
esbHead.setSourceSystemId("APF");
esbHead.setOriginalSystemId("APF");
esbHead.setSourceMachineDate(DateUtils.dateNow());
@ -51,8 +49,7 @@ public class EsbCommon implements EsbServise {
esbHead.setEsbExpandContent("");
return esbHead;
}
public MessageAppHead getCommonAppHead(){
MessageAppHead appHead = new MessageAppHead();
public MessageAppHead getCommonAppHead(MessageAppHead appHead){
appHead.setBranchCode("20");
appHead.setSourceTranDate(DateUtils.dateNow());
appHead.setSourceTranTime(DateUtils.TimeNowAccurate());
@ -70,18 +67,17 @@ public class EsbCommon implements EsbServise {
appHead.setAppExpandContent("");
return appHead;
}
public MessageBody getCommonBody(){
MessageBody msgBody = new MessageBody();
public MessageBody getCommonBody(MessageBody msgBody){
return msgBody;
}
public MessageEsbHead esbHead(){
return this.getCommonEsbHead();
return this.getCommonEsbHead(new MessageEsbHead());
}
public MessageAppHead appHead(){
return this.getCommonAppHead();
return this.getCommonAppHead(new MessageAppHead());
}
public MessageBody messgeBody(){
return this.getCommonBody();
return this.getCommonBody(new MessageBody());
}
public String httpSend(String url , String xmlValue){
@ -110,29 +106,6 @@ public class EsbCommon implements EsbServise {
return result;
}
public String xmlConvert(Transaction tran) {
XStream xs = XstreamUtil.initXStream(true);
xs.autodetectAnnotations(true);
xs.aliasSystemAttribute(null,"class");
String xml = xs.toXML(tran);
//XStream的老毛病转译会将_转成__,所以在这里转回来
xml = xml.replace("__","_");
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xml;
return xml;
}
public Transaction objectConvert(String xml) {
if(xml.startsWith("<?xml")){
xml = xml.substring(xml.indexOf("?>")+2);
}
XStream xs = new XStream();
xs.ignoreUnknownElements();
xs.autodetectAnnotations(true);
xs.alias("TRANSACTION",Transaction.class);
Transaction response = (Transaction)xs.fromXML(xml);
return response;
}
/**
* ¹úÈýÕªÒª
* @param srcData

View File

@ -24,8 +24,8 @@ import java.io.PrintWriter;
public class AfsResultServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest request, HttpServletResponse response) {
System.out.println("反欺诈人工判定结果请求回调开始!");
response.setContentType("application/x-www-form-urlencoded;charset:utf-8");
System.out.println("============反欺诈人工判定结果请求回调开始!============");
response.setContentType("application/xml;charset:utf-8");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0L);
@ -48,7 +48,7 @@ public class AfsResultServlet extends HttpServlet {
out.print(updateResult(resultXml));
out.close();
System.out.println("============反欺诈人工判定结果请求回调结束!============");
}
public String updateResult(String requestXml){
@ -59,18 +59,8 @@ public class AfsResultServlet extends HttpServlet {
FileUtil.writeFile(logPath + projectNo +"_"+ globalSeqNo +"_request.txt", requestXml);
String fraudAlert = tran.getMessageBody().getAfsResultRequest().getFraudAlert();
String actionTaken = tran.getMessageBody().getAfsResultRequest().getActionTaken();
BizObjectManager bom = null;
BizObject boRsr = null;
try {
bom = JBOFactory.getBizObjectManager(RC_SCORE_RESULT.CLASS_NAME);
boRsr = bom.createQuery("project_no=:projectNo").setParameter("projectNo",projectNo).getSingleResult(true);
boRsr.setAttributeValue("fraud_alert_code",fraudAlert);
boRsr.setAttributeValue("fraud_taken_code",actionTaken);
boRsr.setAttributeValue("updatetime", DateUtils.dateTimeNowCore());
bom.saveObject(boRsr);
} catch (JBOException e) {
e.printStackTrace();
}
String RetCommStatus = "S";
Response rs = new Response();
rs.setResult("Successful");
MessageBody mb = new MessageBody();
@ -81,17 +71,35 @@ public class AfsResultServlet extends HttpServlet {
esbHead.setTargetMachineTime(DateUtils.TimeNowAccurate());
esbHead.setTargetReciveDate(DateUtils.dateNow());
esbHead.setTargetReciveTime(DateUtils.TimeNowAccurate());
esbHead.setRetCommStatus("S");
esbHead.setRetCode("000000");
esbHead.setRetMsg("成功");
esbHead.setRetSystemId("APF");
esbHead.setRetCode("000000");
esbHead.setRetMsg("成功");
BizObjectManager bom = null;
BizObject boRsr = null;
try {
bom = JBOFactory.getBizObjectManager(RC_SCORE_RESULT.CLASS_NAME);
boRsr = bom.createQuery("project_no=:projectNo").setParameter("projectNo",projectNo).getSingleResult(true);
boRsr.setAttributeValue("fraud_alert_code",fraudAlert);
boRsr.setAttributeValue("fraud_taken_code",actionTaken);
boRsr.setAttributeValue("update_time", DateUtils.dateTimeNowCore());
bom.saveObject(boRsr);
} catch (JBOException e) {
e.printStackTrace();
tran.setMessageBody(null);
RetCommStatus = "F";
esbHead.setRetCode("99999");
esbHead.setRetMsg("失败:"+e.getErrorMessage());
}
esbHead.setRetCommStatus(RetCommStatus);
MessageAppHead appHead = tran.getMessageAppHead();
appHead.setTargetTranDate(DateUtils.dateNow());
appHead.setTargetTranTime(DateUtils.TimeNowAccurate());
String responseXml = XstreamUtil.xmlConvert(tran);
FileUtil.writeFile(logPath + projectNo +"_"+ globalSeqNo +"_response.txt", responseXml);
FileUtil.writeFile(logPath + projectNo +"_"+ globalSeqNo + RetCommStatus +"_response.txt", responseXml);
return responseXml;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
package com.ample.esb.service;
import com.ample.esb.bean.amp.ApplicationTitle;
public interface AmpService extends EsbServise{
ApplicationTitle getApplicationTitle() throws Exception;
}

View File

@ -15,7 +15,8 @@ public class AccountSyncServiceImpl extends EsbCommon {
}
@Override
public MessageEsbHead esbHead() {
MessageEsbHead head = super.getCommonEsbHead();
MessageEsbHead head = new MessageEsbHead();
head = super.getCommonEsbHead(head);
head.setTargetSystemId("AFS");
head.setServiceId("SCN0003");
head.setServiceVersion("1.0.0");
@ -30,14 +31,16 @@ public class AccountSyncServiceImpl extends EsbCommon {
@Override
public MessageAppHead appHead() {
MessageAppHead head = super.getCommonAppHead();
MessageAppHead head = new MessageAppHead();
head = super.getCommonAppHead(head);
head.setOperatorId(accountSyncRequest.getOperatorId());
return head;
}
@Override
public MessageBody messgeBody() {
MessageBody body = super.getCommonBody();
MessageBody body = new MessageBody();
body = super.getCommonBody(body);
body.setRequest(accountSyncRequest);
return body;
}

File diff suppressed because it is too large Load Diff