江蘇銀行業務對接,現金管理平臺,銀企直聯
注:如果沒有與銀行合作,銀行是不會提供開發文件與測試賬號的,請確保合作後看以下內容,否則看了也沒用,因為重要的詳細資訊都在銀行提供的文件中,我寫的只是實際開發的程式碼;
查詢銀行到賬資訊程式碼示例:
介紹:此業務我是用時間定時器做的,每30秒獲取銀行到賬的明細,並存入資料庫;
開發前請認真閱讀銀行給的開發文件,按文件要求安裝和配置前置機;
我們只需要把請求傳送給前置機,由前置機與銀行互動然後返回我們,前置機裝在我們公司本地區域網中,所以資料可不加密,前置機會加密與銀行互動;
獲取到銀行賬資訊的資料有兩種情況,一種是資料量很小 2K以內的資料銀行會以拼接url的方式返回;如果資料超出2k需要自己傳送下載檔案的請求,請求完畢後需要關閉檔案,所有我們需要解析兩種資料,具體詳細銀行會有對接文件參考;
1.配置檔案:
conf/MortgageBankofjiangsucainfo.properties
#-------------------------江蘇銀行配置表------銀行業務 編碼GBK-------http://cron.qqe2.com/-------http://www.shnydb.com/----- #xxxx公司銀行賬號 ACNO = 32280xxxxxxxxxx #賬號對應的戶名 ACNAME = xxxxxxxxxx #交易碼 ;查詢賬戶明細(200xxx交易) TR_CODE_QUERY = 200xxx #交易碼 ;對外支付(300xxx交易) TR_CODE_PAY = 300xxx #渠道標識 CHANNEL = 5 #檔案標識 0-報文,1-檔案 FILE_FLAG = 0 #前置機IP FRONT_END_PROCESSOR_IP = 192.168.x.xxx #前置機交易埠 DEAL_PROT = 10xxx #前置機檔案埠 FILE_PROT = 20xxx #日期模板 DATETEMPLATE = yyyyMMdd #時間模板 TIMETEMPLATE = HHmmss #幣種 (人民幣) CUR_CODE = 01 #收款戶名 測試付款用 REV_ACNAME = xxx #定時獲取到賬資訊; JIANGSUBANK_GETACCOUNTINFO_TIME = 0/120 * * * * ? #每間隔 N 時間獲取一次資料,這裡的時間與定時器 JIANGSUBANK_GETACCOUNTINFO_TIME 的時間保持一致(單位秒) JIANGSUBANK_GETACCOUNTINFO_RUNTIME = 120 #未防止獲取的資料丟失,每天晚上 23點50分 定時 觸發一次獲取當天所有銀行到賬資料;晚上23:58分執行 * 58 23 * * ? All_A_DAY_JIANGSUBANK_GETACCOUNTINFO_TIME = * 58 23 * * ?
SpringMVC.xml載入配置檔案
<bean id="prop" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="locations"> <!--<array>--> <value>classpath:conf/MortgageBankofjiangsucainfo.properties</value> <!--</array>--> </property>
com.tcwl.vsmp.mortgage.common.MortgageBankofjiangsucainfoConstant.java
package com.tcwl.vsmp.mortgage.common;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* 江蘇銀行業務常量定義類
*
* 銀行業務 編碼GBK
*/
@Component
public class MortgageBankofjiangsucainfoConstant {
/*public static*/
/*======================銀行=======================*/
/**
* 請求頭
* @throws Exception
*/
// tr_code 交易碼 ;查詢賬戶明細 200110 MortgageBankofjiangsucainfoConstant.TR_CODE_QUERY
public static String TR_CODE_QUERY ;
//交易碼 ;對外支付(300001交易) MortgageBankofjiangsucainfoConstant.TR_CODE_PAY
public static String TR_CODE_PAY;
//cms_corp_no 現金管理客戶號 企業不需要賦值,由銀企前置機進行賦值。 MortgageBankofjiangsucainfoConstant.CMS_CORP_NO
public static String CMS_CORP_NO = "";
//user_no 使用者號 企業不需要賦值,由銀企前置機進行賦值。MortgageBankofjiangsucainfoConstant.USER_NO
public static String USER_NO = "";
//org_code 機構號 企業不需要賦值,由銀企前置機進行賦值。MortgageBankofjiangsucainfoConstant.ORG_CODE
public static String ORG_CODE = "";
//serial_no 交易流水號 送空,由現金管理系統產生 MortgageBankofjiangsucainfoConstant.SERIAL_NO
public static String SERIAL_NO = "";
//req_no 請求號 企業ERP的流水號 MortgageBankofjiangsucainfoConstant.REQ_NO
public static String REQ_NO = "";
//channel 渠道標識 ERP送‘5’ MortgageBankofjiangsucainfoConstant.CHANNEL
public static String CHANNEL ;
//sign 簽名標識 0-報文未簽名 ; 1-報文已簽名; 企業送空,由銀企前置進行傳送. MortgageBankofjiangsucainfoConstant.SIGN
public static String SIGN = "";
//file_flag 檔案標識0-報文1-檔案 MortgageBankofjiangsucainfoConstant.FILE_FLAG
public static String FILE_FLAG;
//reserved 保留欄位
public static String RESERVED = "";
/**
* 請求體
* @throws Exception
*/
//坦程自己公司賬號 MortgageBankofjiangsucainfoConstant.ACNO
public static String ACNO;
//自己公司賬號對應的戶名 MortgageBankofjiangsucainfoConstant.ACNAME
public static String ACNAME ;
//cur_code 幣種 01 -人民幣 MortgageBankofjiangsucainfoConstant.CUR_CODE
public static String CUR_CODE ;
/**
* 請求IP地址
*/
//前置機ip MortgageBankofjiangsucainfoConstant.FRONT_END_PROCESSOR_IP
public static String FRONT_END_PROCESSOR_IP;
//前置機交易埠prot MortgageBankofjiangsucainfoConstant.DEAL_PROT
public static String DEAL_PROT ;
//前置機檔案埠prot MortgageBankofjiangsucainfoConstant.FILE_PROT
public static String FILE_PROT;
//日期模板 MortgageBankofjiangsucainfoConstant.DATETEMPLATE
public static String DATETEMPLATE ;
//時間模板 MortgageBankofjiangsucainfoConstant.TIME_TEMPLATE
public static String TIME_TEMPLATE ;
/* ============================操作狀態================================================*/
//操作狀態【非金鑫獲取的資料,由自己寫入】 0為未操作,1為操作,資料庫預設為0,MortgageBankofjiangsucainfoConstant.STSTUS_NO
public static Integer STSTUS_NO = 0;
public static Integer STSTUS_YES = 1;
@Value("#{prop.TR_CODE_QUERY}")
public void setTrCodeQuery(String trCodeQuery) {
TR_CODE_QUERY = trCodeQuery;
}
@Value("#{prop.TR_CODE_PAY}")
public void setTrCodePay(String trCodePay) {
TR_CODE_PAY = trCodePay;
}
public void setCmsCorpNo(String cmsCorpNo) {
CMS_CORP_NO = cmsCorpNo;
}
public void setUserNo(String userNo) {
USER_NO = userNo;
}
public void setOrgCode(String orgCode) {
ORG_CODE = orgCode;
}
public void setSerialNo(String serialNo) {
SERIAL_NO = serialNo;
}
public void setReqNo(String reqNo) {
REQ_NO = reqNo;
}
@Value("#{prop.CHANNEL}")
public void setCHANNEL(String CHANNEL) {
MortgageBankofjiangsucainfoConstant.CHANNEL = CHANNEL;
}
public void setSIGN(String SIGN) {
MortgageBankofjiangsucainfoConstant.SIGN = SIGN;
}
@Value("#{prop.FILE_FLAG}")
public void setFileFlag(String fileFlag) {
FILE_FLAG = fileFlag;
}
public void setRESERVED(String RESERVED) {
MortgageBankofjiangsucainfoConstant.RESERVED = RESERVED;
}
@Value("#{prop.ACNO}")
public void setACNO(String ACNO) {
MortgageBankofjiangsucainfoConstant.ACNO = ACNO;
}
@Value("#{prop.CUR_CODE}")
public void setCurCode(String curCode) {
CUR_CODE = curCode;
}
//自己公司賬號對應的戶名
@Value("#{prop.ACNAME}")
public void setAcName(String acName) {
ACNAME = acName;
}
@Value("#{prop.FRONT_END_PROCESSOR_IP}")
public void setFrontEndProcessorIp(String frontEndProcessorIp) {
FRONT_END_PROCESSOR_IP = frontEndProcessorIp;
}
@Value("#{prop.DEAL_PROT}")
public void setDealProt(String dealProt) {
DEAL_PROT = dealProt;
}
@Value("#{prop.FILE_PROT}")
public void setFilePort(String filePort) {
FILE_PROT = filePort;
}
@Value("#{prop.DATETEMPLATE}")
public void setDATETEMPLATE(String DATETEMPLATE) {
MortgageBankofjiangsucainfoConstant.DATETEMPLATE = DATETEMPLATE;
}
@Value("#{prop.TIMETEMPLATE}")
public void setTimeTemplate(String timeTemplate) {
TIME_TEMPLATE = timeTemplate;
}
}
2.工具類
傳送工具
com.tcwl.vsmp.weizhang.util.HttpClientUtil.java
package com.tcwl.vsmp.weizhang.util;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import com.tcwl.vsmp.weizhang.vo.KeyValueObject;
/**
* <p>Title: TSP</p>
* <p>Description: 本類用於對外http請求工具類</p>
* <p>Copyright: Copyright (c) 2011 Wuxi Tan Cheng IOT Technology Co., Ltd.</p>
*
* @author lizhijian
* @version 1.0
* <p>2014-3-4</p>
* @since 1.6.0
*/
public class HttpClientUtil
{
/**
*
* @author: 蘇凱
* @Title: httpPostWithXml
* @Description: 江蘇銀行 傳送請求 2018-10-24
* @param: @return String 型別,string是請求介面返回的報文資訊拼接的字串
* @return: String
* @throws MalformedURLException,IOException
*
*/
public static BufferedReader httpPostWithXml(String requestBody1,String url,String requestHeader) {
String urlStr = "";
String line = "";
StringBuffer resultSting = new StringBuffer();
BufferedReader br = null;
try {
//urlStr,寫在了配置檔案中,直接進行獲取
//宣告URL
URL url1 = new URL(url);
//1.建立連結
URLConnection con = url1.openConnection();
//2.封裝報文傳輸進行傳輸
String xmlInfo = requestBody1;
byte[] xmlData = xmlInfo.getBytes("GBK");
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(false);
con.setRequestProperty("Pragma:", "no-cache");
con.setRequestProperty("Cache-Control", "no-cache");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");// requestHeader
con.setRequestProperty("Content-length",String.valueOf(xmlData.length));
OutputStreamWriter out = new OutputStreamWriter(
con.getOutputStream());
System.out.println(">>>>>>>>>>介面地址為urlStr=" + urlStr);
System.out.println(">>>>>>>>>>傳入的報文xmlInfo=" + xmlInfo);
out.write(new String(xmlInfo.getBytes("GBK")));
/* out.write(new String(xmlInfo.getBytes("GBK")));*/
out.flush();
out.close();
//3.獲取返回報文
br = new BufferedReader(new InputStreamReader(
con.getInputStream(),"gbk"));
/*br = new BufferedReader(new InputStreamReader(
con.getInputStream(),"ISO-8859-1"));*/
//對返回值報文進行列印
/* for (line = br.readLine(); line != null; line = br.readLine()) {
//對返回的報文進行結果判斷<RspCode>0000</RspCode>
System.out.println(">>>>>>>>>>>>>>>>>>>返回的結果報文內容為:---------"+line);
//對返回的報文進行拼接,然後返回給業務層,在業務層進行判斷
resultSting.append(line);
}*/
System.out.println(">>>>>>>>>>>>>>>>>>>返回的結果報文內容為resultSting.toString():---------"+resultSting.toString());
return br;
/*return resultSting.toString();*/
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return br;
}
/**
*
* @author: 蘇凱
* @Title: httpPostWithXml
* @Description: 江蘇銀行獲取返回檔案的大小
* @param: String sizeUrl
* @return: BufferedReader
* @throws MalformedURLException,IOException
* http://127.0.0.1:20010/?00SIZE FILENAME
*
*/
public static BufferedReader getFileSizeForJiangSu(String sizeUrl) throws Exception {
//宣告URL
URL url1 = new URL(sizeUrl);
//1.建立連結
URLConnection con = url1.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(
con.getInputStream(), "gbk"));
return br;
}
/**
*
* @author: 蘇凱
* @Title: httpPostWithXml
* @Description: 江蘇銀行獲取返回檔案的資料
* @param: String sizeUrl
* @return: BufferedReader
* @throws MalformedURLException,IOException
* http://127.0.0.1:20010/?00GET FILENAME 0 FILELENGTH
*
*/
public static BufferedReader getFileForJiangSu(String fileUrl) throws Exception {
URL url2 = new URL(fileUrl);
//1.建立連結
URLConnection conn = url2.openConnection();
// 傳送POST請求必須設定如下兩行
/*conn.setDoOutput(true);
conn.setDoInput(true);*/
BufferedReader br = new BufferedReader(new InputStreamReader(
conn.getInputStream(), "gbk"));
return br;
}
/**
*
* @author: 蘇凱
* @Title: httpPostWithXml
* @Description: 江蘇銀行關閉檔案;每次下載結束必須關閉,否則偏移量往後偏移1(檔案位元組大小加1)
* @param: String sizeUrl
* @return: BufferedReader
* @throws MalformedURLException,IOException
* http://127.0.0.1:20010/?00QUIT
* 2018-10-26
*/
public static BufferedReader offFileForJiangSu(String offFileUrl) throws Exception {
URL url = new URL(offFileUrl);
//1.建立連結
URLConnection conn31 = url.openConnection();
conn31.setDoOutput(true);
conn31.setDoInput(true);
//遍歷引數,對返回值報文進行列印
String lineT13;
BufferedReader br = new BufferedReader(new InputStreamReader(
conn31.getInputStream(), "gbk"));
return br;
}
}
如果這行報錯就把這行註釋了
con.setRequestProperty("Pragma:", "no-cache");
【java.lang.IllegalArgumentException: Illegal character(s) in message header field: Pragma:】
XmlAndString互轉工具:
com.tcwl.vsmp.mortgage.utils.XmlAndString.java
package com.tcwl.vsmp.mortgage.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
* xml,String互轉
* 蘇凱
* 2018-10-24
*/
public class XmlAndString {
/**
*
* @param document
* Document物件(讀xml生成的)
* @return String字串
* @throws Throwable
*/
public String xmlToString(Document document) throws Throwable {
TransformerFactory ft = TransformerFactory.newInstance();
Transformer ff = ft.newTransformer();
ff.setOutputProperty("encoding", "GB2312");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ff.transform(new DOMSource(document), new StreamResult(bos));
return bos.toString();
}
/**
* xml形狀的str串
* @param
* @return Document 物件
*/
public Document StringTOXml(String str) {
StringBuilder sXML = new StringBuilder();
sXML.append(str);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document doc = null;
try {
/*InputStream is = new ByteArrayInputStream(sXML.toString().getBytes("utf-8"));*/
/* InputStream is = new ByteArrayInputStream(sXML.toString().getBytes());*/
InputStream is = new ByteArrayInputStream(sXML.toString().getBytes("GBK"));
System.out.println("is==null"+is==null);
doc = dbf.newDocumentBuilder().parse(is);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return doc;
}
/**
*
* @param document
* @return 某個節點的值 前提是需要知道xml格式,知道需要取的節點相對根節點所在位置
*/
public String getNodeValue(Document document, String nodePaht) {
XPathFactory xpfactory = XPathFactory.newInstance();
XPath path = xpfactory.newXPath();
String servInitrBrch = "";
try {
servInitrBrch = path.evaluate(nodePaht, document);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
return servInitrBrch;
}
/**
*
* @param document
* @param nodePath
* 需要修改的節點相對根節點所在位置
* @param vodeValue
* 替換的值
*/
public void setNodeValue(Document document, String nodePath, String vodeValue) {
XPathFactory xpfactory = XPathFactory.newInstance();
XPath path = xpfactory.newXPath();
Node node = null;
;
try {
node = (Node) path.evaluate(nodePath, document, XPathConstants.NODE);
} catch (XPathExpressionException e) {
e.printStackTrace();
}
node.setTextContent(vodeValue);
}
public static void main(String[] args) throws Throwable {
// 讀取xml檔案,生成document物件
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
// 檔案的位置在工作空間的根目錄(位置隨意,只要寫對就ok)
Document document = builder.parse(new File("a.xml"));
XmlAndString t = new XmlAndString();
// XML————》String
String str = t.xmlToString(document);
System.out.println("str:" + str);
// String ————》XML
Document doc = t.StringTOXml(str);
String nodePath = "/transaction/header/msg/sndMbrCd";
// getNodeValue
String nodeValue = t.getNodeValue(doc, nodePath);
System.out.println("修改前nodeValue:" + nodeValue);
// setNodeValue
t.setNodeValue(doc, nodePath, nodeValue + "hello");
System.out.println("修改後nodeValue:" + t.getNodeValue(doc, nodePath));
}
}
編碼查詢,utf-8 與 GBK 編碼互轉工具:
com.tcwl.vsmp.mortgage.utils.EncodeQueryAndTransition,java
package com.tcwl.vsmp.mortgage.utils;
/**
* 編碼查詢,utf-8 與 GBK 編碼互轉
* 蘇凱
* 2018-10-24
*/
import java.io.UnsupportedEncodingException;
/**
* 編碼查詢與轉換
*/
public class EncodeQueryAndTransition {
//編碼轉換
/**
* gbk轉utf-8
* @param gbk
* @return
* @throws UnsupportedEncodingException
*/
public static byte[] gbk2UtfByte(String gbk)throws UnsupportedEncodingException {
char[]c= gbk.toCharArray();
byte[]fullByte=new byte[3*c.length];
for(int i=0;i<c.length;i++){
String binary=Integer.toBinaryString(c[i]);
StringBuffer sb=new StringBuffer();
int len=16-binary.length();
//前面補零
for(int j=0;j<len;j++){
sb.append("0");
}
sb.append(binary);
//增加位,達到到24位3個位元組
sb.insert(0,"1110");
sb.insert(8,"10");
sb.insert(16,"10");
fullByte[i*3]=Integer.valueOf(sb.substring(0,8),2).byteValue();//二進位制字串建立整型
fullByte[i*3+1]=Integer.valueOf(sb.substring(8,16),2).byteValue();
fullByte[i*3+2]=Integer.valueOf(sb.substring(16,24),2).byteValue();
}
//模擬UTF-8編碼的網站顯示
System.out.println(new String(fullByte,"UTF-8"));
return fullByte;
}
/**
* utf-8 轉GBK
* @param gbkStr
* @return
*/
public static byte[] getUTF8BytesFromGBKString(String gbkStr) {
int n = gbkStr.length();
byte[] utfBytes = new byte[3 * n];
int k = 0;
for (int i = 0; i<n;i++){
int m=gbkStr.charAt(i);
if(m<128&&m>=0){
utfBytes[k++]=(byte)m;
continue;
}
utfBytes[k++]=(byte)(0xe0|(m>>12));
utfBytes[k++]=(byte)(0x80|((m>>6)&0x3f));
utfBytes[k++]=(byte)(0x80|(m&0x3f));
}
if(k<utfBytes.length){
byte[]tmp=new byte[k];
System.arraycopy(utfBytes,0,tmp,0,k);
return tmp;
}
return utfBytes;
}
/**
* 編碼查詢
*/
public static String getEncoding(String str) {
String encode = "GB2312";
try {
if (str.equals(new String(str.getBytes(encode), encode))) { //判斷是不是GB2312
String s = encode;
return s; //是的話,返回“GB2312“,以下程式碼同理
}
} catch (Exception exception) {
}
encode = "ISO-8859-1";
try {
if (str.equals(new String(str.getBytes(encode), encode))) { //判斷是不是ISO-8859-1
String s1 = encode;
return s1;
}
} catch (Exception exception1) {
}
encode = "UTF-8";
try {
if (str.equals(new String(str.getBytes(encode), encode))) { //判斷是不是UTF-8
String s2 = encode;
return s2;
}
} catch (Exception exception2) {
}
encode = "GBK";
try {
if (str.equals(new String(str.getBytes(encode), encode))) { //判斷是不是GBK
String s3 = encode;
return s3;
}
} catch (Exception exception3) {
}
return ""; //如果都不是,說明輸入的內容不屬於常見的編碼格式。
}
}
3.建立資料庫表和類
mortgage_bankofjiangsucainfo 表:
CREATE TABLE `tanchengwulian`.`Untitled` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '江蘇銀行賬戶到賬查詢資訊 ',
`serial_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '平臺流水號(C20)',
`acno` varchar(35) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '賬號(C35)',
`cur_code` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '貨幣碼(C2)',
`tr_acdt` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '交易日期(C8)',
`tr_time` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易時間交易日期(C6)',
`host_serial_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '主機流水號(C20)',
`tr_bankno` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易行號(C12)',
`acname` varchar(70) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '戶名(C70)',
`opp_acno` varchar(35) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '對方賬號(C35)',
`opp_cur_code` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '對方貨幣碼(C2)',
`opp_acname` varchar(70) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '對方賬號戶名(C70)',
`opp_bankname` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '對方賬號開戶行(C60)',
`opp_bankno` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '對方行號(C12)',
`tr_type` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易類別(C1)\r\n1-自身收付款\r\n2-資金歸集\r\n3-結息\r\n4-收費\r\n5-資金池劃撥戶結息或清息\r\n',
`csh_dra_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '鈔匯標誌(C1)',
`bank_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '他行標誌(C1)',
`area_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '同城異地標誌(C1)',
`tr_from` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易來源(C1)',
`trans_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '發生額標誌(C1)',
`old_serial_no` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '被沖銷流水號(C12)',
`old_acdt` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '原交易日期(C8)',
`cash_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '現轉標誌(C1)',
`crdr_flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '借貸標誌(C1)',
`balance` decimal(16, 2) DEFAULT NULL COMMENT '餘額(N16.2)',
`freeze_amt` decimal(16, 2) UNSIGNED ZEROFILL DEFAULT NULL COMMENT '凍結金額(N16.2)',
`cert_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '憑證種類(C20)',
`cert_batchno` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '憑證批次號(C20)',
`cert_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '憑證號碼(C20)',
`tr_code` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易碼(C6)',
`user_no` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '櫃員號(C10)',
`sub_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '傳票號(C20)',
`purpose` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '摘要(C30)【訂單編號,用這個去loan_table中與bugGood_order_no欄位匹配獲取交易型別buyGoods_Id】',
`postscript` varchar(70) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '附言(C60)',
`tr_timestamp` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '交易時間戳',
`reserved1` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '備註欄位一(C60)',
`reserved2` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '備註欄位二(C60)',
`tr_bankname` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '交易行名(C70)',
`bank_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '支付系統聯行行號(C20)',
`bankname` varchar(70) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '支付系統聯行行名(C70)',
`printcount` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '' COMMENT '回單列印次數(C8)',
`payamt` decimal(16, 2) DEFAULT NULL COMMENT '借出金額(N16,2)',
`Rcvamt` decimal(16, 2) DEFAULT NULL COMMENT '借入金額(N16,2)',
`amt` decimal(16, 2) DEFAULT NULL COMMENT '交易金額(N16.2)',
`fee_amt` decimal(16, 2) DEFAULT NULL COMMENT '手續費(N16.2)',
`last_bal` decimal(16, 2) DEFAULT NULL COMMENT '上筆餘額(N16.2)',
`ststus` int(3) DEFAULT 0 COMMENT '0為未操作,1為操作,資料庫預設為0,【非金鑫獲取的資料,由自己寫入】',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `serial_no_key`(`serial_no`) USING BTREE COMMENT '平臺流水號(C20) 必須唯一,不然影響呈現執行'
) ENGINE = InnoDB AUTO_INCREMENT = 713 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
實體類:
com.tcwl.vsmp.mortgage.po.MortgageBankofjiangsucainfo.java
package com.tcwl.vsmp.mortgage.po;
import java.math.BigDecimal;
/**
* 江蘇銀行賬戶到賬查詢資訊
* 蘇凱
* 2018-10-22
*
* http://cron.qqe2.com/
*/
public class MortgageBankofjiangsucainfo {
private Long id;
/* ============返回引數頭head(資料庫無對應表和欄位)===========================================*/
//交易碼
private String tr_code_head;
//現金管理客戶號
private String cms_corp_no_head;
//請求號 企業ERP的流水號,原樣返回
private String req_no_head;
//交易時間 格式hhmmss
private String tr_time_head;
//交易日期 格式YYYYMMDD
private String tr_acdt_head;
//成功標識; 0- 表示成功 ; 1- 表示通訊機超時 ; 8- 表示主機結果未知 ;其它-交易失敗
private String succ_flag_head;
//返回資訊
private String ret_info_head;
//返回碼 0000表示成功,正常返回
private String ret_code_head;
//返回附加資訊
private String ext_info_head;
//保留欄位
private String reserved_head;
//檔案標識 傳送0-報文,1-檔案,或為空
private String file_flag_head;
//機構號 公共返回,企業可不用
private String org_code_head;
//
private String total_head;
// 交易流水號 由現金管理系統產生的流水號
private String serial_no_head;
/* ============返回引數身體body (資料庫無對應表和欄位)==========================================*/
//記錄條數;視記錄數而定
private String record_num_body;
// 欄位數; 視域數而定
private String field_num_body;
//資料域 節點<2K,如果file_flag為1則無該節點
private String serial_record_body;
//檔名 如果file_flag為0則無該節點
private String file_name_body;
/* ===========返回引數body中的 serial_record ; serial_record_body資料域(資料庫有對應表和欄位) ====================*/
//平臺流水號(C20)
private String serial_no;
//賬號(C35)
private String acno;
//貨幣碼(C2)
private String cur_code;
//交易日期(C8)
private String tr_acdt;
//交易時間交易日期(C6)
private String tr_time;
//主機流水號(C20)
private String host_serial_no;
//交易行號(C12)
private String tr_bankno;
//戶名(C70)
private String acname;
//對方賬號(C35)
private String opp_acno;
//對方貨幣碼(C2)
private String opp_cur_code;
//對方賬號戶名(C70)
private String opp_acname;
//對方賬號開戶行(C60)
private String opp_bankname;
//對方行號(C12)
private String opp_bankno;
//交易類別(C1)
private String tr_type;
//鈔匯標誌(C1)
private String csh_dra_flag;
//他行標誌(C1)
private String bank_flag;
//同城異地標誌(C1)
private String area_flag;
//交易來源(C1)
private String tr_from;
//發生額標誌(C1)
private String trans_flag;
//被沖銷流水號(C12)
private String old_serial_no;
//原交易日期(C8)
private String old_acdt;
//現轉標誌(C1)
private String cash_flag;
//借貸標誌(C1)
private String crdr_flag;
//餘額(N16.2)
private BigDecimal balance;
//凍結金額(N16.2)
private BigDecimal freeze_amt;
//憑證種類(C20)
private String cert_type;
//憑證批次號(C20)
private String cert_batchno;
//憑證號碼(C20)
private String cert_no;
//交易碼(C6)
private String tr_code;
//櫃員號(C10)
private String user_no;
//傳票號(C20)
private String sub_no;
//摘要(C30)【訂單編號,用這個表MortgageBankofjiangsucainfo的這個purpose去loan_table中與bugGood_order_no欄位匹配獲取交易型別buyGoods_Id】
private String purpose;
//附言(C60)
private String postscript;
//交易時間戳
private String tr_timestamp;
//備註欄位一(C60)
private String reserved1;
//備註欄位二(C60)
private String reserved2;
//交易行名(C70)
private String tr_bankname;
//支付系統聯行行號(C20)
private String bank_no;
//支付系統聯行行名(C70)
private String bankname;
//回單列印次數(C8)
private String printcount;
//借出金額(N16,2)
private BigDecimal payamt;
//借入金額(N16,2)
private BigDecimal rcvamt;
//交易金額(N16.2)
private BigDecimal amt;
//手續費(N16.2)
private BigDecimal fee_amt;
//上筆餘額(N16.2)
private BigDecimal last_bal;
//操作狀態 ;0為未操作,1為操作,資料庫預設為0,【非金鑫獲取的資料,由自己寫入】
private Integer ststus;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSerial_no() {
return serial_no;
}
public void setSerial_no(String serial_no) {
this.serial_no = serial_no == null ? null : serial_no.trim();
}
public String getAcno() {
return acno;
}
public void setAcno(String acno) {
this.acno = acno == null ? null : acno.trim();
}
public String getCur_code() {
return cur_code;
}
public void setCur_code(String cur_code) {
this.cur_code = cur_code == null ? null : cur_code.trim();
}
public String getTr_acdt() {
return tr_acdt;
}
public void setTr_acdt(String tr_acdt) {
this.tr_acdt = tr_acdt == null ? null : tr_acdt.trim();
}
public String getTr_time() {
return tr_time;
}
public void setTr_time(String tr_time) {
this.tr_time = tr_time == null ? null : tr_time.trim();
}
public String getHost_serial_no() {
return host_serial_no;
}
public void setHost_serial_no(String host_serial_no) {
this.host_serial_no = host_serial_no == null ? null : host_serial_no.trim();
}
public String getTr_bankno() {
return tr_bankno;
}
public void setTr_bankno(String tr_bankno) {
this.tr_bankno = tr_bankno == null ? null : tr_bankno.trim();
}
public String getAcname() {
return acname;
}
public void setAcname(String acname) {
this.acname = acname == null ? null : acname.trim();
}
public String getOpp_acno() {
return opp_acno;
}
public void setOpp_acno(String opp_acno) {
this.opp_acno = opp_acno == null ? null : opp_acno.trim();
}
public String getOpp_cur_code() {
return opp_cur_code;
}
public void setOpp_cur_code(String opp_cur_code) {
this.opp_cur_code = opp_cur_code == null ? null : opp_cur_code.trim();
}
public String getOpp_acname() {
return opp_acname;
}
public void setOpp_acname(String opp_acname) {
this.opp_acname = opp_acname == null ? null : opp_acname.trim();
}
public String getOpp_bankname() {
return opp_bankname;
}
public void setOpp_bankname(String opp_bankname) {
this.opp_bankname = opp_bankname == null ? null : opp_bankname.trim();
}
public String getOpp_bankno() {
return opp_bankno;
}
public void setOpp_bankno(String opp_bankno) {
this.opp_bankno = opp_bankno == null ? null : opp_bankno.trim();
}
public String getTr_type() {
return tr_type;
}
public void setTr_type(String tr_type) {
this.tr_type = tr_type == null ? null : tr_type.trim();
}
public String getCsh_dra_flag() {
return csh_dra_flag;
}
public void setCsh_dra_flag(String csh_dra_flag) {
this.csh_dra_flag = csh_dra_flag == null ? null : csh_dra_flag.trim();
}
public String getBank_flag() {
return bank_flag;
}
public void setBank_flag(String bank_flag) {
this.bank_flag = bank_flag == null ? null : bank_flag.trim();
}
public String getArea_flag() {
return area_flag;
}
public void setArea_flag(String area_flag) {
this.area_flag = area_flag == null ? null : area_flag.trim();
}
public String getTr_from() {
return tr_from;
}
public void setTr_from(String tr_from) {
this.tr_from = tr_from == null ? null : tr_from.trim();
}
public String getTrans_flag() {
return trans_flag;
}
public void setTrans_flag(String trans_flag) {
this.trans_flag = trans_flag == null ? null : trans_flag.trim();
}
public String getOld_serial_no() {
return old_serial_no;
}
public void setOld_serial_no(String old_serial_no) {
this.old_serial_no = old_serial_no == null ? null : old_serial_no.trim();
}
public String getOld_acdt() {
return old_acdt;
}
public void setOld_acdt(String old_acdt) {
this.old_acdt = old_acdt == null ? null : old_acdt.trim();
}
public String getCash_flag() {
return cash_flag;
}
public void setCash_flag(String cash_flag) {
this.cash_flag = cash_flag == null ? null : cash_flag.trim();
}
public String getCrdr_flag() {
return crdr_flag;
}
public void setCrdr_flag(String crdr_flag) {
this.crdr_flag = crdr_flag == null ? null : crdr_flag.trim();
}
public BigDecimal getBalance() {
return balance;
}
public void setBalance(BigDecimal balance) {
this.balance = balance;
}
public BigDecimal getFreeze_amt() {
return freeze_amt;
}
public void setFreeze_amt(BigDecimal freeze_amt) {
this.freeze_amt = freeze_amt;
}
public String getCert_type() {
return cert_type;
}
public void setCert_type(String cert_type) {
this.cert_type = cert_type == null ? null : cert_type.trim();
}
public String getCert_batchno() {
return cert_batchno;
}
public void setCert_batchno(String cert_batchno) {
this.cert_batchno = cert_batchno == null ? null : cert_batchno.trim();
}
public String getCert_no() {
return cert_no;
}
public void setCert_no(String cert_no) {
this.cert_no = cert_no == null ? null : cert_no.trim();
}
public String getTr_code() {
return tr_code;
}
public void setTr_code(String tr_code) {
this.tr_code = tr_code == null ? null : tr_code.trim();
}
public String getUser_no() {
return user_no;
}
public void setUser_no(String user_no) {
this.user_no = user_no == null ? null : user_no.trim();
}
public String getSub_no() {
return sub_no;
}
public void setSub_no(String sub_no) {
this.sub_no = sub_no == null ? null : sub_no.trim();
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose == null ? null : purpose.trim();
}
public String getPostscript() {
return postscript;
}
public void setPostscript(String postscript) {
this.postscript = postscript == null ? null : postscript.trim();
}
public String getTr_timestamp() {
return tr_timestamp;
}
public void setTr_timestamp(String tr_timestamp) {
this.tr_timestamp = tr_timestamp == null ? null : tr_timestamp.trim();
}
public String getReserved1() {
return reserved1;
}
public void setReserved1(String reserved1) {
this.reserved1 = reserved1 == null ? null : reserved1.trim();
}
public String getReserved2() {
return reserved2;
}
public void setReserved2(String reserved2) {
this.reserved2 = reserved2 == null ? null : reserved2.trim();
}
public String getTr_bankname() {
return tr_bankname;
}
public void setTr_bankname(String tr_bankname) {
this.tr_bankname = tr_bankname == null ? null : tr_bankname.trim();
}
public String getBank_no() {
return bank_no;
}
public void setBank_no(String bank_no) {
this.bank_no = bank_no == null ? null : bank_no.trim();
}
public String getBankname() {
return bankname;
}
public void setBankname(String bankname) {
this.bankname = bankname == null ? null : bankname.trim();
}
public String getPrintcount() {
return printcount;
}
public void setPrintcount(String printcount) {
this.printcount = printcount == null ? null : printcount.trim();
}
public BigDecimal getPayamt() {
return payamt;
}
public void setPayamt(BigDecimal payamt) {
this.payamt = payamt;
}
public BigDecimal getRcvamt() {
return rcvamt;
}
public void setRcvamt(BigDecimal rcvamt) {
this.rcvamt = rcvamt;
}
public BigDecimal getAmt() {
return amt;
}
public void setAmt(BigDecimal amt) {
this.amt = amt;
}
public BigDecimal getFee_amt() {
return fee_amt;
}
public void setFee_amt(BigDecimal fee_amt) {
this.fee_amt = fee_amt;
}
public BigDecimal getLast_bal() {
return last_bal;
}
public void setLast_bal(BigDecimal last_bal) {
this.last_bal = last_bal;
}
public String getTr_code_head() {
return tr_code_head;
}
public void setTr_code_head(String tr_code_head) {
this.tr_code_head = tr_code_head;
}
public String getCms_corp_no_head() {
return cms_corp_no_head;
}
public void setCms_corp_no_head(String cms_corp_no_head) {
this.cms_corp_no_head = cms_corp_no_head;
}
public String getReq_no_head() {
return req_no_head;
}
public void setReq_no_head(String req_no_head) {
this.req_no_head = req_no_head;
}
public String getTr_time_head() {
return tr_time_head;
}
public void setTr_time_head(String tr_time_head) {
this.tr_time_head = tr_time_head;
}
public String getTr_acdt_head() {
return tr_acdt_head;
}
public void setTr_acdt_head(String tr_acdt_head) {
this.tr_acdt_head = tr_acdt_head;
}
public String getSucc_flag_head() {
return succ_flag_head;
}
public void setSucc_flag_head(String succ_flag_head) {
this.succ_flag_head = succ_flag_head;
}
public String getRet_info_head() {
return ret_info_head;
}
public void setRet_info_head(String ret_info_head) {
this.ret_info_head = ret_info_head;
}
public String getRet_code_head() {
return ret_code_head;
}
public void setRet_code_head(String ret_code_head) {
this.ret_code_head = ret_code_head;
}
public String getExt_info_head() {
return ext_info_head;
}
public void setExt_info_head(String ext_info_head) {
this.ext_info_head = ext_info_head;
}
public String getReserved_head() {
return reserved_head;
}
public void setReserved_head(String reserved_head) {
this.reserved_head = reserved_head;
}
public String getFile_flag_head() {
return file_flag_head;
}
public void setFile_flag_head(String file_flag_head) {
this.file_flag_head = file_flag_head;
}
public String getOrg_code_head() {
return org_code_head;
}
public void setOrg_code_head(String org_code_head) {
this.org_code_head = org_code_head;
}
public String getTotal_head() {
return total_head;
}
public void setTotal_head(String total_head) {
this.total_head = total_head;
}
public String getSerial_no_head() {
return serial_no_head;
}
public void setSerial_no_head(String serial_no_head) {
this.serial_no_head = serial_no_head;
}
public String getRecord_num_body() {
return record_num_body;
}
public void setRecord_num_body(String record_num_body) {
this.record_num_body = record_num_body;
}
public String getField_num_body() {
return field_num_body;
}
public void setField_num_body(String field_num_body) {
this.field_num_body = field_num_body;
}
public String getSerial_record_body() {
return serial_record_body;
}
public void setSerial_record_body(String serial_record_body) {
this.serial_record_body = serial_record_body;
}
public String getFile_name_body() {
return file_name_body;
}
public void setFile_name_body(String file_name_body) {
this.file_name_body = file_name_body;
}
public Integer getStstus() {
return ststus;
}
public void setStstus(Integer ststus) {
this.ststus = ststus;
}
@Override
public String toString() {
return "MortgageBankofjiangsucainfo{" +
"id=" + id +
", tr_code_head='" + tr_code_head + '\'' +
", cms_corp_no_head='" + cms_corp_no_head + '\'' +
", req_no_head='" + req_no_head + '\'' +
", tr_time_head='" + tr_time_head + '\'' +
", tr_acdt_head='" + tr_acdt_head + '\'' +
", succ_flag_head='" + succ_flag_head + '\'' +
", ret_info_head='" + ret_info_head + '\'' +
", ret_code_head='" + ret_code_head + '\'' +
", ext_info_head='" + ext_info_head + '\'' +
", reserved_head='" + reserved_head + '\'' +
", file_flag_head='" + file_flag_head + '\'' +
", org_code_head='" + org_code_head + '\'' +
", total_head='" + total_head + '\'' +
", serial_no_head='" + serial_no_head + '\'' +
", record_num_body='" + record_num_body + '\'' +
", field_num_body='" + field_num_body + '\'' +
", serial_record_body='" + serial_record_body + '\'' +
", file_name_body='" + file_name_body + '\'' +
", serial_no='" + serial_no + '\'' +
", acno='" + acno + '\'' +
", cur_code='" + cur_code + '\'' +
", tr_acdt='" + tr_acdt + '\'' +
", tr_time='" + tr_time + '\'' +
", host_serial_no='" + host_serial_no + '\'' +
", tr_bankno='" + tr_bankno + '\'' +
", acname='" + acname + '\'' +
", opp_acno='" + opp_acno + '\'' +
", opp_cur_code='" + opp_cur_code + '\'' +
", opp_acname='" + opp_acname + '\'' +
", opp_bankname='" + opp_bankname + '\'' +
", opp_bankno='" + opp_bankno + '\'' +
", tr_type='" + tr_type + '\'' +
", csh_dra_flag='" + csh_dra_flag + '\'' +
", bank_flag='" + bank_flag + '\'' +
", area_flag='" + area_flag + '\'' +
", tr_from='" + tr_from + '\'' +
", trans_flag='" + trans_flag + '\'' +
", old_serial_no='" + old_serial_no + '\'' +
", old_acdt='" + old_acdt + '\'' +
", cash_flag='" + cash_flag + '\'' +
", crdr_flag='" + crdr_flag + '\'' +
", balance=" + balance +
", freeze_amt=" + freeze_amt +
", cert_type='" + cert_type + '\'' +
", cert_batchno='" + cert_batchno + '\'' +
", cert_no='" + cert_no + '\'' +
", tr_code='" + tr_code + '\'' +
", user_no='" + user_no + '\'' +
", sub_no='" + sub_no + '\'' +
", purpose='" + purpose + '\'' +
", postscript='" + postscript + '\'' +
", tr_timestamp='" + tr_timestamp + '\'' +
", reserved1='" + reserved1 + '\'' +
", reserved2='" + reserved2 + '\'' +
", tr_bankname='" + tr_bankname + '\'' +
", bank_no='" + bank_no + '\'' +
", bankname='" + bankname + '\'' +
", printcount='" + printcount + '\'' +
", payamt=" + payamt +
", rcvamt=" + rcvamt +
", amt=" + amt +
", fee_amt=" + fee_amt +
", last_bal=" + last_bal +
", ststus=" + ststus +
'}';
}
}
介面:
com.tcwl.vsmp.mortgage.service.impl.MortgageBankofjiangsucainfoServiceImpl.java
package com.tcwl.vsmp.mortgage.service.impl;
import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
import com.tcwl.vsmp.common.BaseController;
import com.tcwl.vsmp.common.ExceptionInfo;
import com.tcwl.vsmp.common.OilConstant;
import com.tcwl.vsmp.customer.po.Customer;
import com.tcwl.vsmp.external.service.HzCapitalService;
import com.tcwl.vsmp.loanmgt.po.LoanTable;
import com.tcwl.vsmp.loanmgt.service.LoanQueryService;
import com.tcwl.vsmp.mortgage.common.MortgageBankofjiangsucainfoConstant;
import com.tcwl.vsmp.mortgage.dao.MortgageBankofjiangsucainfoMapper;
import com.tcwl.vsmp.mortgage.po.MortgageBankofjiangsucainfo;
import com.tcwl.vsmp.mortgage.service.MortgageBankofjiangsucainfoService;
import com.tcwl.vsmp.mortgage.utils.EncodeQueryAndTransition;
import com.tcwl.vsmp.oil.dao.CardApplyDao;
import com.tcwl.vsmp.oil.po.CardApply;
import com.tcwl.vsmp.oil.po.Card_info;
import com.tcwl.vsmp.oil.service.Card_infoService;
import com.tcwl.vsmp.oil.service.OilCardOperationService;
import com.tcwl.vsmp.passcard.common.PassCardConstant;
import com.tcwl.vsmp.passcard.po.stk.ChargeInfo;
import com.tcwl.vsmp.passcard.po.stk.ChargeReq;
import com.tcwl.vsmp.passcard.service.STCPassCardChargeRecordService;
import com.tcwl.vsmp.passcard.util.STCRechargeUtil;
import com.tcwl.vsmp.utils.BatchNumber;
import com.tcwl.vsmp.utils.DateUtil;
import com.tcwl.vsmp.utils.JsonAndBaseUtils;
import com.tcwl.vsmp.utils.RandNumUtils;
import com.tcwl.vsmp.weizhang.util.HttpClientUtil;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.shiro.SecurityUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import quartz.jiangSuBank.JiangSuBank;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 江蘇銀行賬戶到賬查詢資訊
* 蘇凱
* 2018-10-22
* Service介面實現
*/
@Service
public class MortgageBankofjiangsucainfoServiceImpl implements MortgageBankofjiangsucainfoService{
private static final Logger logger = LoggerFactory.getLogger(JiangSuBank.class);
/* @Autowired
private MortgageBankofjiangsucainfoService mortgageBankofjiangsucainfoService;*/
@Autowired
private STCPassCardChargeRecordService sTCPassCardChargeRecordService;//通行卡表
@Autowired
private HzCapitalService hzCapitalService;
@Autowired
private LoanQueryService loanQueryService;//借款查詢表
@Autowired
private Card_infoService card_infoService;//油卡詳細
@Autowired
private OilCardOperationService oilCardOperationService;//油卡充值介面
/**
* 車應用Dao.
* 油卡業務
*/
@Autowired
private CardApplyDao cardApplyDao;
/**
* 請求頭
* @throws Exception
*/
// tr_code 交易碼 C6 M
@Value("#{prop.TR_CODE_QUERY}")
private String tr_code; //查詢賬戶明細 200110
//cms_corp_no 現金管理客戶號 C20 M 企業不需要賦值,由銀企前置機進行賦值。
private String cms_corp_no = "";
//user_no 使用者號 C10 M 企業不需要賦值,由銀企前置機進行賦值。
private String user_no = "";
//org_code 機構號 C20 M 企業不需要賦值,由銀企前置機進行賦值。
private String org_code = "";
//serial_no 交易流水號 C20 C 送空,由現金管理系統產生
private String serial_no = "";
//req_no 請求號 C40 C 企業ERP的流水號
private String req_no = "";
//tr_acdt 交易日期 C8 M 格式 YYYYMMDD
private String tr_acdt = null;
//tr_time 交易時間 C6 M 格式hhmmss
private String tr_time = null;
//channel 渠道標識 C1 M ERP送‘5’
private String channel ="5";
//sign 簽名標識 0-報文未簽名 ; 1-報文已簽名; 企業送空,由銀企前置進行傳送.
private String sign = "";
//file_flag 檔案標識 0-報文1-檔案
private String file_flag = "0";
//reserved 保留欄位
private String reserved = "";
/**
* 請求體
* @throws Exception
*/
@Value("#{prop.ACNO}")
//acno 賬號 C35 M ,自己公司賬號
private String acno;
@Value("#{prop.CUR_CODE}")
//cur_code 幣種 C2 M 01 人民幣
private String cur_code ;
//start_date 起始日期 C8 M 日期格式:YYYYMMDD ;日期時間段不能超過3個月的時間
private String start_date = "";
//end_date 終止日期 C8 M 日期格式:YYYYMMDD
private String end_date = "";
/**
* 請求地址
*/
@Value("#{prop.FRONT_END_PROCESSOR_IP}")
//前置機ip
private String FRONT_END_PROCESSOR_IP;
@Value("#{prop.DEAL_PROT}")
//前置機交易埠prot
private String DEAL_PROT ;
//前置機檔案埠prot MortgageBankofjiangsucainfoConstant.FILE_PROT
@Value("#{prop.FILE_PROT}")
public String FILE_PROT;
@Value("#{prop.DATETEMPLATE}")
//日期模板
private String dateTemplate ;
@Value("#{prop.TIMETEMPLATE}")
//時間模板
private String timeTemplate ;
@Value("#{prop.JIANGSUBANK_GETACCOUNTINFO_RUNTIME}")
//每間隔 N 時間獲取一次資料,這裡的時間與定時器的時間保持一致(單位換算成秒)
private String runTime;
//當log為false 時查詢全天所有的資料
private Boolean log = true;
@Resource
private MortgageBankofjiangsucainfoMapper mortgageBankofjiangsucainfoMapper;
/**
* 根據ID刪除資料
* @param id
* @return
*/
@Override
public int deleteByPrimaryKey(Long id)throws Exception {
int i = mortgageBankofjiangsucainfoMapper.deleteByPrimaryKey(id);
return i;
}
/**
* 增加資料
* @param record
* @return
*/
@Override
public int insert(MortgageBankofjiangsucainfo record) throws Exception{
int i = mortgageBankofjiangsucainfoMapper.insert(record);
return i;
}
/**
* 增加資料(Null值不增加)
* @param record
* @return
*/
@Override
public int insertSelective(MortgageBankofjiangsucainfo record) throws Exception{
int i = mortgageBankofjiangsucainfoMapper.insertSelective(record);
return i;
}
/**
* 按主鍵查詢資料
* @param id
* @return
*/
@Override
public MortgageBankofjiangsucainfo selectByPrimaryKey(Long id)throws Exception {
MortgageBankofjiangsucainfo mortgageBankofjiangsucainfo = mortgageBankofjiangsucainfoMapper.selectByPrimaryKey(id);
return mortgageBankofjiangsucainfo;
}
/**
* 按操作狀態查詢
* @param ststus
* @return
*/
@Override
public List<MortgageBankofjiangsucainfo> selectByStstus(int ststus)throws Exception {
List<MortgageBankofjiangsucainfo> mortgageBankofjiangsucainfos = mortgageBankofjiangsucainfoMapper.selectByStstus(ststus);
return mortgageBankofjiangsucainfos;
}
/**
* 按主鍵更新資料(Null值不更新)
* @param record
* @return
*/
@Override
public int updateByPrimaryKeySelective(MortgageBankofjiangsucainfo record)throws Exception {
int i = mortgageBankofjiangsucainfoMapper.updateByPrimaryKeySelective(record);
return i;
}
/**
* 按主鍵更新資料
* @param record
* @return
*/
@Override
public int updateByPrimaryKey(MortgageBankofjiangsucainfo record) throws Exception{
int i = mortgageBankofjiangsucainfoMapper.updateByPrimaryKey(record);
return i;
}
/**
* 獲取江蘇銀行到賬資訊,存入資料庫
* 當getDayInfo為true s時查詢當天所有資料;查詢完成後需要 成員變數 getDayInfo設為false 不查詢當天所有
* 成員變數 int x 控制手動執行獲取當天全天銀行資料的次數為1次,避免死迴圈
* 當呼叫的此getJiangSuBankAccountInfo方法 返回true時 [成員變數 X = 0 與 成員變數getDayInfo = false 值還得設回預設]
* @throws Exception
*/
public synchronized Boolean getJiangSuBankAccountInfo(Boolean getDayInfo,int x) throws Exception{//當log為false 時查詢全部
System.out.println("--------------------------------------------log-----------------------------------------------: "+ log);
System.out.println("--------------------------------------------getDayInfo-----------------------------------------------: "+ getDayInfo);
System.out.println("執行江蘇銀行獲取到賬資訊任務sys!");
//儲存到賬的資訊
List<Map<String, String>> mapList =null ;
try{
//url
String url = "http://" + FRONT_END_PROCESSOR_IP + ":" + DEAL_PROT;
SimpleDateFormat sData = new SimpleDateFormat(dateTemplate);
String data = sData.format(new Date());//當前日期
SimpleDateFormat sTime = new SimpleDateFormat(timeTemplate);
String time = sTime.format(new Date());//當前時間
String line = "";
//tr_acdt 交易日期
tr_acdt = data;
//tr_time 交易時間
tr_time = time;
//start_date 起始日期
start_date = data;
//end_date 終止日期
end_date = data;
System.out.println("tr_acdt:" + tr_acdt + " tr_time:" + tr_time + "start_date:" + start_date + "end_date:" + end_date);
String requestHeader = "application/x-www-form-urlencoded";
//1.設定傳送的報文
StringBuilder sb = getStringBuilderWithSetXML();
String requestBody = sb.toString();
System.out.println("0:" + EncodeQueryAndTransition.getEncoding(requestBody));
byte[] requestBodyBytes = requestBody.getBytes();
String requestBody1 = new String(requestBodyBytes, "GBK");
System.out.println("=========requestBody=========" + requestBody);
//2.向銀行傳送GBK資料,BufferedReader br並收到返回引數如有中文字元用 EncodeQueryAndTransition.getUTF8BytesFromGBKString(String gbkStr)方法 將中文單獨轉成 GBK
BufferedReader br = HttpClientUtil.httpPostWithXml(requestBody1, url, requestHeader);
System.out.println("1:" + EncodeQueryAndTransition.getEncoding(requestBody));//獲取編碼格式
//3.收到返回的資料,遍歷引數,對返回值報文進行列印
for (line = br.readLine(); line != null; line = br.readLine()) {
//對返回的報文進行結果判斷<RspCode>0000</RspCode>
System.out.println(">>>>>>>>>>>>>>>>>>>返回的結果報aaa文內容為:---------" + line);
//對返回的報文進行拼接,然後返回給業務層,在業務層進行判斷
System.out.println("line:" + EncodeQueryAndTransition.getEncoding(line));
//4.返回值轉換xml 去除00 ,拼接頭 <?xml version="1.0" encoding="UTF-8"?>
String lineXML = line.substring(2, (line.length()));
System.out.println("-------------lineXML----------:" + lineXML);
if(lineXML == null){
continue;
}
Document dom = DocumentHelper.parseText(lineXML);
System.out.println("dom==null" + (dom == null));
if(dom == null){
continue;
}
Element root = dom.getRootElement();
if (root == null) {
continue;
}
//應答報頭體
Element head = root.element("head");
String tr_code = null; //交易碼 C6 M
String cms_corp_no = null; //現金管理客戶號 C20 M 公共返回,企業可不用
String user_no = null; //使用者號 C10 M 公共返回,企業可不用
String org_code = null; //機構號 C20 M 公共返回,企業可不用
String serial_no = null; //交易流水號 C20 C 由現金管理系統產生的流水號
String req_no = null; //請求號 C40 C 企業ERP的流水號,原樣返回
String tr_acdt = null; //交易日期 C8 M 格式YYYYMMDD
String tr_time = null;//交易時間 C6 M 格式hhmmss
String succ_flag = null; //成功標識 C1 M ; 0- 表示成功 1- 表示通訊機超時 8-表示主機結果未知 其它-交易失敗
String ret_code = null; //返回碼 C4 M 0000表示成功,正常返回
String ret_info = null; //返回資訊 C60 M
String ext_info = null; //返回附加資訊 C255 C
String file_flag = null; //檔案標識 C1 C 傳送0-報文 1-檔案,或為空
String reserved = null; //保留欄位 C60 C
if (head != null) {
Element tr_codeElement = head.element("tr_code");//交易碼 C6 M
Element tr_acdtElement = head.element("tr_acdt"); //交易日期 C8 M 格式YYYYMMDD
Element tr_timeElement = head.element("tr_time");//交易時間 C6 M 格式hhmmss
Element file_flagElement = head.element("file_flag");//檔案標識 C1 C 傳送0-報文1-檔案,或為空
Element ret_infoElement = head.element("ret_info");//返回資訊 C60 M
Element cms_corp_noElement = head.element("cms_corp_no");//現金管理客戶號 C20 M 公共返回,企業可不用
Element user_noElement = head.element("user_no");//使用者號 C10 M 公共返回,企業可不用
Element org_codeElement = head.element("org_code"); //機構號 C20 M 公共返回,企業可不用
Element serial_noElement = head.element("serial_no"); //交易流水號 C20 C 由現金管理系統產生的流水號
Element req_noElement = head.element("req_no");//請求號 C40 C 企