|
|
@@ -42,11 +42,12 @@ public class AnXinServiceImpl extends AbstractManager implements AnXinService{ |
|
|
|
|
|
|
|
final String txCode = request.getMethod(); |
|
|
|
String res; |
|
|
|
Map<String, String> jsonObject = JsonTools.json2Map(req,String.class,String.class); |
|
|
|
Map<String, Object> jsonObject = JsonTools.json2Map(req,String.class, Object.class); |
|
|
|
|
|
|
|
// 判断是否有文件 走不同的请求 |
|
|
|
if (StringTools.hasText(jsonObject.get("filePath"))) { |
|
|
|
File file = getByFilePath(jsonObject.get("filePath")); |
|
|
|
String path = (String) jsonObject.get("filePath"); |
|
|
|
if (hasText(path)) { |
|
|
|
File file = getByFilePath(jsonObject.get("filePath")+""); |
|
|
|
res = httpConnector.post("platId/" + Request.PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature, file); |
|
|
|
} else { |
|
|
|
res = httpConnector.post("platId/" + Request.PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature); |
|
|
@@ -55,26 +56,28 @@ public class AnXinServiceImpl extends AbstractManager implements AnXinService{ |
|
|
|
|
|
|
|
// 包装响应参数 |
|
|
|
InterfaceResponse interfaceResponse = new InterfaceResponse(); |
|
|
|
Map<String, String> resJson = JsonTools.json2Map(res, String.class, String.class); |
|
|
|
Map<String, Object> resJson = JsonTools.json2Map(res, String.class, Object.class); |
|
|
|
|
|
|
|
// 解析响应头 |
|
|
|
if (resJson.containsKey("head")) { |
|
|
|
String head = resJson.get("head"); |
|
|
|
Map<String, String> headJson = JsonTools.json2Map(head, String.class, String.class); |
|
|
|
interfaceResponse.setTxTime(headJson.get("txTime")); |
|
|
|
interfaceResponse.setRetCode(headJson.get("retCode")); |
|
|
|
interfaceResponse.setRetMessage(headJson.get("retMessage")); |
|
|
|
Object head = resJson.get("head"); |
|
|
|
if (head instanceof Map) { |
|
|
|
Map<String, String> headJson = (Map<String, String>) head; |
|
|
|
interfaceResponse.setTxTime(headJson.get("txTime")); |
|
|
|
interfaceResponse.setRetCode(headJson.get("retCode")); |
|
|
|
interfaceResponse.setRetMessage(headJson.get("retMessage")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 解析业务数据 |
|
|
|
if (resJson.containsKey("data")) { |
|
|
|
interfaceResponse.setBizContent(resJson.get("data")); |
|
|
|
interfaceResponse.setBizContent(resJson.get("data")+""); |
|
|
|
} |
|
|
|
|
|
|
|
// 解析错误信息 |
|
|
|
if (resJson.containsKey("errorCode")) { |
|
|
|
interfaceResponse.setErrorCode(resJson.get("errorCode")); |
|
|
|
interfaceResponse.setErrorMessage(resJson.get("errorMessage")); |
|
|
|
interfaceResponse.setErrorCode(resJson.get("errorCode")+""); |
|
|
|
interfaceResponse.setErrorMessage(resJson.get("errorMessage")+""); |
|
|
|
} |
|
|
|
|
|
|
|
return interfaceResponse; |
|
|
@@ -141,10 +144,10 @@ public class AnXinServiceImpl extends AbstractManager implements AnXinService{ |
|
|
|
return resStr; |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws ServiceHandleException { |
|
|
|
String req="{\"head\":{\"txTime\":\"20241216211541\"},\"costTime\":0,\"person\":{\"personName\":\"刘三十jiu\",\"identTypeCode\":\"1\",\"identNo\":\"110102200001071156\",\"email\":\"liu@cfca.com.cn\",\"mobilePhone\":\"95010117774\",\"authenticationMode\":\"公安部\",\"authenticationTime\":\"20241216211541\"}}"; |
|
|
|
public static void main(String[] args) throws ServiceHandleException, IOException { |
|
|
|
// String req="{\"head\":{\"txTime\":\"20241216211541\"},\"costTime\":0,\"person\":{\"personName\":\"刘三十jiu\",\"identTypeCode\":\"1\",\"identNo\":\"110102200001071156\",\"email\":\"liu@cfca.com.cn\",\"mobilePhone\":\"95010117774\",\"authenticationMode\":\"公安部\",\"authenticationTime\":\"20241216211541\"}}"; |
|
|
|
// String req="{\"costTime\":0,\"person\":{\"personName\":\"刘三十jiu\",\"identTypeCode\":\"1\",\"identNo\":\"110102200001071156\",\"email\":\"liu@cfca.com.cn\",\"mobilePhone\":\"95010117774\",\"authenticationMode\":\"公安部\",\"authenticationTime\":\"20241216211541\"}}"; |
|
|
|
System.out.println(packParam(req)); |
|
|
|
// System.out.println(packParam(req)); |
|
|
|
|
|
|
|
// try { |
|
|
|
// JSONObject resJson = JSON.parseObject(req); |
|
|
@@ -160,5 +163,37 @@ public class AnXinServiceImpl extends AbstractManager implements AnXinService{ |
|
|
|
// }catch (Exception e){ |
|
|
|
// System.out.println("响应参数解析失败"); |
|
|
|
// } |
|
|
|
|
|
|
|
String res = "{\"errorCode\":\"202\",\"errorMessage\":\"错误信息\",\"head\":{\"txTime\":\"20160102235959\",\"locale\":\"zh_CN\",\"retCode\":\"60000000\",\"retMessage\":\"OK\"},\"data\":{\"contract\":{\"contractNo\":\"QT20160413000000001\",\"contractTypeCode\":\"QT\",\"contractName\":\"信息咨询及管理服务协议(趸缴)(2联)\",\"contractState\":1,\"createTime\":\"20160413160220\",\"expiredDate\":\"20160513\",\"signatories\":[{\"userName\":\"xx网络科技有限公司\",\"identTypeCode\":\"3\",\"identNo\":\"110000017039721\",\"signmentState\":1,\"signTime\":20160413160220},{\"userName\":\"孙三的公司\",\"identTypeCode\":\"3\",\"identNo\":\"3301110017039721\",\"signmentState\":1,\"signTime\":20160413160220}]}}}"; |
|
|
|
|
|
|
|
InterfaceResponse interfaceResponse = new InterfaceResponse(); |
|
|
|
Map<String, Object> resJson = JsonTools.json2Map(res, String.class, Object.class); |
|
|
|
|
|
|
|
// 解析响应头 |
|
|
|
if (resJson.containsKey("head")) { |
|
|
|
Object head = resJson.get("head"); |
|
|
|
if (head instanceof Map) { |
|
|
|
Map<String, String> headJson = (Map<String, String>) head; |
|
|
|
interfaceResponse.setTxTime(headJson.get("txTime")); |
|
|
|
interfaceResponse.setRetCode(headJson.get("retCode")); |
|
|
|
interfaceResponse.setRetMessage(headJson.get("retMessage")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 解析业务数据 |
|
|
|
if (resJson.containsKey("data")) { |
|
|
|
Object data = resJson.get("data"); |
|
|
|
if (data instanceof Map) { |
|
|
|
interfaceResponse.setBizContent(data.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 解析错误信息 |
|
|
|
if (resJson.containsKey("errorCode")) { |
|
|
|
interfaceResponse.setErrorCode(resJson.get("errorCode")+""); |
|
|
|
interfaceResponse.setErrorMessage(resJson.get("errorMessage")+""); |
|
|
|
} |
|
|
|
|
|
|
|
System.out.println("==>"+interfaceResponse.toJson()); |
|
|
|
} |
|
|
|
} |