银行前置机接口访问

注意事项

1、tcp请求

2、ip白名单限制

3、传参xml文件 字符串时,前面要加字节

在这个string前加一个十位数的   这个十位数分成两个部分 前五位:统计xml长度 比如长度是111  前五位就是00111   长度是30   那前五位就是00030     后五位就用00000

 

实现思路如下

在银企服务器内的bos工具编写main方法请求测试

package mztest;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;
import org.xml.sax.SAXException;
import com.kingdee.util.CharSet;
public class TcpTest {

	
	  public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
		  
		  String   sCMWebfilePath="C:\\Users\\Administrator\\Desktop\\新建文件夹\\1010定期账户明细查询.xml";
	      String   xml = getJsonFromFile(sCMWebfilePath).trim();
          sendSocket (  "10.64.xxxx.240",  9888, "0050600000"+xml );
	  }
	
	  
	  
	  
	  
	  /**
	   * 发送请求
	   *
	   * @param host    地址
	   * @param port    端口
	   * @param message 报文
	   * @return 响应
	   */
	  private static String sendSocket(String host, Integer port, String message) {
//	     System.out.println("请求地址:{},端口:{},报文:{}"+host+port+message);
	      Socket socket = null;
	      OutputStream outputStream = null;
	      InputStream inputStream = null;
	      BufferedReader bufferedReader = null;
	      try {
	          socket = new Socket(host, port);
	          
	          socket.setSoTimeout(20000);
	          // 建立连接后获得输出流
	          outputStream = socket.getOutputStream();
	          outputStream.write(message.getBytes(CharSet.GBK));
	          outputStream.flush();

	          inputStream = socket.getInputStream();
	          bufferedReader = new BufferedReader(new InputStreamReader(inputStream,CharSet.GBK));
	       
	          String str="";
	          System.out.println("####################响应报文##########################");
				try{
					while((str=bufferedReader.readLine())!=null){
						System.out.println(str);
					}
				}catch(IOException e){
					e.printStackTrace();
				}
 
	       
	      } catch (IOException e) {
	    	  System.out.println("socket发送异常:{}"+ e.toString());
	      } finally {
	          try {
	              if(bufferedReader != null){
	                  bufferedReader.close();
	              }
	              if (inputStream != null) {
	                  inputStream.close();
	              }
	              if (outputStream != null) {
	                  outputStream.close();
	              }
	              if (socket != null) {
	                  socket.close();
	              }
	          } catch (IOException e) {
	        	  System.out.println("socket关闭异常:{}"+ e.toString());
	          }
	      }
	      return null;
	  }

	  
	  
	  
	  /**
	     *读取json数据
	     * @param file
	     * @return
	     */
	    public static   String  getJsonFromFile( String  file   ){
	    	  FileInputStream fis = null;
	  		try {
	  			fis = new FileInputStream( file);
	  		} catch (FileNotFoundException e) {
	  			e.printStackTrace();
	  		}

	           String jsonData = null;
	           byte[] content = new byte[1048576];

	           int readCount = 0;
	           int destPos = 0;
	           try {
	          	 byte[] b = new byte[1024];
	          	 while ((readCount = fis.read(b)) != -1) {
	          		 System.arraycopy(b, 0, content, destPos, readCount);
	          		 destPos += readCount;
	          	 }
	           } catch (IOException e) {
	  			e.printStackTrace();
	  		} finally {
	          	 try {
	  				fis.close();
	  			} catch (IOException e) {
	  				e.printStackTrace();
	  			}
	           }
	           try {
	  			jsonData = new String(content, 0, destPos, "utf-8");
	  		} catch (UnsupportedEncodingException e) {
	  			e.printStackTrace();
	  		}
			return jsonData;
	    }
	  
	
	
	
}

--------------------------------------------------------------------------------------------------------------------------

工具类

package com.kingdee.eas.custom.bankinterface;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.kingdee.util.CharSet;
public class CommonUtils {

	
	
	public static byte[] callMapToXML(Map map) {
//		System.out.println("将Map转成Xml, Map:" + map.toString());
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"GBK\"?>").append("\r\n");
		sb.append("<root>").append("\r\n");
		mapToXMLTest2(map, sb);
		sb.append("</root>");
		sb.append("\r\n");
//		System.out.println("将Map转成Xml, Xml:" + sb.toString());
		try {
			return sb.toString().getBytes("GBK");
		} catch (Exception e) {
			System.out.println(e);
		}
		return null;
	}
 
	
	
	
	
	
	private static void mapToXMLTest2(Map map, StringBuffer sb) {
		Set set = map.keySet();
		for (Iterator it = set.iterator(); it.hasNext();) {
			String key = (String) it.next();
			Object value = map.get(key);
			if (null == value)
				value = "";
			if (value.getClass().getName().equals("java.util.ArrayList")) {
				ArrayList list = (ArrayList) map.get(key);
				sb.append("<" + key + ">");
				for (int i = 0; i < list.size(); i++) {
					HashMap hm = (HashMap) list.get(i);
					mapToXMLTest2(hm, sb);
				}
				sb.append("</" + key + ">");
				sb.append("\r\n");
			} else {
				if (value instanceof HashMap) {
					sb.append("<" + key + ">");
					mapToXMLTest2((HashMap) value, sb);
					sb.append("</" + key + ">");
					sb.append("\r\n");
				} else {
					sb.append("<" + key + ">" + value + "</" + key + ">");
					sb.append("\r\n");
				}
 
			}
 
		}
	}
	
	
	 
	
	
	
	
	

	public static Map xmlToMap(String xmlStr, boolean needRootKey) throws DocumentException {
	    Document doc = DocumentHelper.parseText(xmlStr);
	    Element root = doc.getRootElement();
	    Map<String, Object> map = (Map<String, Object>) xml2map(root);
	    if(root.elements().size()==0 && root.attributes().size()==0){
	        return map;
	    }
	    if(needRootKey){
	        //在返回的map里加根节点键(如果需要)
	        Map<String, Object> rootMap = new HashMap<String, Object>();
	        rootMap.put(root.getName(), map);
	        return rootMap;
	    }
	    return map;
	}

	/**
	 * xml转map 不带属性
	 * @param e
	 * @return
	 */
	private static Map xml2map(Element e) {
	    Map map = new LinkedHashMap();
	    List list = e.elements();
	    if (list.size() > 0) {
	        for (int i = 0; i < list.size(); i++) {
	            Element iter = (Element) list.get(i);
	            List mapList = new ArrayList();

	            if (iter.elements().size() > 0) {
	                Map m = xml2map(iter);
	                if (map.get(iter.getName()) != null) {
	                    Object obj = map.get(iter.getName());
	                    if (!(obj instanceof List)) {
	                        mapList = new ArrayList();
	                        mapList.add(obj);
	                        mapList.add(m);
	                    }
	                    if (obj instanceof List) {
	                        mapList = (List) obj;
	                        mapList.add(m);
	                    }
	                    map.put(iter.getName(), mapList);
	                } else
	                    map.put(iter.getName(), m);
	            } else {
	                if (map.get(iter.getName()) != null) {
	                    Object obj = map.get(iter.getName());
	                    if (!(obj instanceof List)) {
	                        mapList = new ArrayList();
	                        mapList.add(obj);
	                        mapList.add(iter.getText());
	                    }
	                    if (obj instanceof List) {
	                        mapList = (List) obj;
	                        mapList.add(iter.getText());
	                    }
	                    map.put(iter.getName(), mapList);
	                } else
	                    map.put(iter.getName(), iter.getText());
	            }
	        }
	    } else
	        map.put(e.getName(), e.getText());
	    return map;
	}
 
	
	/**
	 * xml转map 带属性
	 * @param xmlStr
	 * @param needRootKey 是否需要在返回的map里加根节点键
	 * @return
	 * @throws DocumentException
	 */
	public static Map xml2mapWithAttr(String xmlStr, boolean needRootKey) throws DocumentException {
		Document doc = DocumentHelper.parseText(xmlStr);
		Element root = doc.getRootElement();
		Map<String, Object> map = (Map<String, Object>) xml2mapWithAttr(root);
		if(root.elements().size()==0 && root.attributes().size()==0){
			return map; //根节点只有一个文本内容
		}
		if(needRootKey){
			//在返回的map里加根节点键(如果需要)
			Map<String, Object> rootMap = new HashMap<String, Object>();
			rootMap.put(root.getName(), map);
			return rootMap;
		}
		return map;
	}

	/**
	 * xml转map 带属性
	 * @param e
	 * @return
	 */
	private static Map xml2mapWithAttr(Element element) {
		Map<String, Object> map = new LinkedHashMap<String, Object>();

		List<Element> list = element.elements();
		List<Attribute> listAttr0 = element.attributes(); // 当前节点的所有属性的list
		for (Attribute attr : listAttr0) {
			map.put("@" + attr.getName(), attr.getValue());
		}
		if (list.size() > 0) {

			for (int i = 0; i < list.size(); i++) {
				Element iter = list.get(i);
				List mapList = new ArrayList();

				if (iter.elements().size() > 0) {
					Map m = xml2mapWithAttr(iter);
					if (map.get(iter.getName()) != null) {
						Object obj = map.get(iter.getName());
						if (!(obj instanceof List)) {
							mapList = new ArrayList();
							mapList.add(obj);
							mapList.add(m);
						}
						if (obj instanceof List) {
							mapList = (List) obj;
							mapList.add(m);
						}
						map.put(iter.getName(), mapList);
					} else
						map.put(iter.getName(), m);
				} else {

					List<Attribute> listAttr = iter.attributes(); // 当前节点的所有属性的list
					Map<String, Object> attrMap = null;
					boolean hasAttributes = false;
					if (listAttr.size() > 0) {
						hasAttributes = true;
						attrMap = new LinkedHashMap<String, Object>();
						for (Attribute attr : listAttr) {
							attrMap.put("@" + attr.getName(), attr.getValue());
						}
					}

					if (map.get(iter.getName()) != null) {
						Object obj = map.get(iter.getName());
						if (!(obj instanceof List)) {
							mapList = new ArrayList();
							mapList.add(obj);
							// mapList.add(iter.getText());
							if (hasAttributes) {
								attrMap.put("#text", iter.getText());
								mapList.add(attrMap);
							} else {
								mapList.add(iter.getText());
							}
						}
						if (obj instanceof List) {
							mapList = (List) obj;
							// mapList.add(iter.getText());
							if (hasAttributes) {
								attrMap.put("#text", iter.getText());
								mapList.add(attrMap);
							} else {
								mapList.add(iter.getText());
							}
						}
						map.put(iter.getName(), mapList);
					} else {
						// map.put(iter.getName(), iter.getText());
						if (hasAttributes) {
							attrMap.put("#text", iter.getText());
							map.put(iter.getName(), attrMap);
						} else {
							map.put(iter.getName(), iter.getText());
						}
					}
				}
			}
		} else {
			// 根节点的
			if (listAttr0.size() > 0) {
				map.put("#text", element.getText());
			} else {
				map.put(element.getName(), element.getText());
			}
		}
		return map;
	}
	
	
	/**
	   * 发送请求
	   *
	   * @param host    地址
	   * @param port    端口
	   * @param message 报文
	   * @return 响应
	   */
	  public  static String sendSocket(String host, Integer port, String message) {
//	     System.out.println("请求地址:{},端口:{},报文:{}"+host+port+message);
		  StringBuffer bankInfo=new StringBuffer();
	      Socket socket = null;
	      OutputStream outputStream = null;
	      InputStream inputStream = null;
	      BufferedReader bufferedReader = null;
	      try {
	          socket = new Socket(host, port);
	          
	          socket.setSoTimeout(20000);
	          // 建立连接后获得输出流
	          outputStream = socket.getOutputStream();
	          outputStream.write(message.getBytes(CharSet.GBK));
	          outputStream.flush();

	          inputStream = socket.getInputStream();
	          bufferedReader = new BufferedReader(new InputStreamReader(inputStream,CharSet.GBK));
	          String str="";
	          System.out.println("####################响应报文##########################");
				try{
					while((str=bufferedReader.readLine())!=null){
						System.out.println(str);
						bankInfo.append(str);
					}
				}catch(IOException e){
					e.printStackTrace();
				}

	       
	      } catch (IOException e) {
	    	  System.out.println("socket发送异常:{}"+ e.toString());
	      } finally {
	          try {
	              if(bufferedReader != null){
	                  bufferedReader.close();
	              }
	              if (inputStream != null) {
	                  inputStream.close();
	              }
	              if (outputStream != null) {
	                  outputStream.close();
	              }
	              if (socket != null) {
	                  socket.close();
	              }
	          } catch (IOException e) {
	        	  System.out.println("socket关闭异常:{}"+ e.toString());
	          }
	      }
	      return bankInfo.toString();
	  }

	  
	  
	  
	  
	  
	  
	  public static   String  getFormatbtye( int  i   ) {
		  
		    String istr = String.format("%5d", i).replace(" ", "0");
//	        System.out.println(String.format("%5d", i).replace(" ", "0"));
//	        System.out.println(String.format("%-10s",istr).replace(" ", "0"));
	        return String.format("%-10s",istr).replace(" ", "0");
	  }
	  
	  
	  
	  
	  
	  
	  
	  /**
	     *读取json数据
	     * @param file
	     * @return
	     */
	    public static   String  getJsonFromFile( String  file   ){
	    	  FileInputStream fis = null;
	  		try {
	  			fis = new FileInputStream( file);
	  		} catch (java.io.FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
 
	           String jsonData = null;
	           byte[] content = new byte[1048576];
 
	           int readCount = 0;
	           int destPos = 0;
	           try {
	          	 byte[] b = new byte[1024];
	          	 while ((readCount = fis.read(b)) != -1) {
	          		 System.arraycopy(b, 0, content, destPos, readCount);
	          		 destPos += readCount;
	          	 }
	           } catch (IOException e) {
	  			e.printStackTrace();
	  		} finally {
	          	 try {
	  				fis.close();
	  			} catch (IOException e) {
	  				e.printStackTrace();
	  			}
	           }
	           try {
	  			jsonData = new String(content, 0, destPos, "GBK");
	  		} catch (UnsupportedEncodingException e) {
	  			e.printStackTrace();
	  		}
			return jsonData;
	    }
 
	
	
	
}

界面 edit

/**
 * output package name
 */
package com.kingdee.eas.custom.bankinterface.client;

import java.awt.event.ActionEvent;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.log4j.Logger;
import org.dom4j.DocumentException;

 
import com.alibaba.fastjson.JSONArray;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.basedata.assistant.AccountBankFactory;
import com.kingdee.eas.basedata.assistant.AccountBankInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.custom.borrow;
import com.kingdee.eas.custom.bankinterface.CommonUtils;
import com.kingdee.eas.custom.bankinterface.FixedaccountdetailsEntryInfo;
import com.kingdee.eas.custom.bankinterface.FixedaccountdetailsInfo;
import com.kingdee.eas.util.SysUtil;
import com.kingdee.eas.util.client.MsgBox;

/**
 * output class name
 */
public class FixedaccountdetailsEditUI extends AbstractFixedaccountdetailsEditUI
{
    private static final Logger logger = CoreUIObject.getLogger(FixedaccountdetailsEditUI.class);
    
    /**
     * output class constructor
     */
    public FixedaccountdetailsEditUI() throws Exception
    {
        super();
    }
    /**
     * output loadFields method
     */
    public void loadFields()
    {
        super.loadFields();
    }

    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }

    
    
    

    /**
     * output actionGetInfonFromBank_actionPerformed
     */
    public void actionGetInfonFromBank_actionPerformed(ActionEvent e) throws Exception
    {
    	
   	 super.storeFields();
	 editData.getEntrys().clear();
	   
	   Object  infonFromBank =  getInfonFromBank(this.editData);
	 
	 List  myList = null;
	 JSONArray parseArray =null;
	 Map map =null;
	 if(infonFromBank.getClass().getName().equals("java.util.ArrayList")){
		    myList=(ArrayList)infonFromBank;
	 }else{
		  map = (Map) infonFromBank;  
	 }
	 
	
	  if(null!=myList){
		  for (int i = 0; i < myList.size(); i++) {
			  map = (Map) myList.get(i);
			  FixedaccountdetailsEntryInfo entrysInfo = setEntrysInfo(  map  );
			  editData.getEntrys().add(entrysInfo);
		  }
		  super.loadFields();
		 
      }else  if(map!=null){
    	  FixedaccountdetailsEntryInfo entrysInfo = setEntrysInfo(       map   );
    	  editData.getEntrys().add(entrysInfo);
    	  super.loadFields();
	  }   	
    }
 
    
    
    
    public    FixedaccountdetailsEntryInfo  setEntrysInfo(    Map   jsonObject   ) throws ParseException{
    	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    	SimpleDateFormat sdf0 = new SimpleDateFormat("yyyyMMdd");
     
   	      String account = jsonObject.get("account").toString();//本方银行账号
		  String accountname = jsonObject.get("accountname").toString();//本方银行户名
		  String bankdocname = jsonObject.get("bankdocname").toString();//本方账号开户行
		  String acctype = jsonObject.get("acctype").toString();   //账户类型
		  
		  String dfbanktypename = jsonObject.get("dfbanktypename").toString();   //对方银行类别
		  String dfaccount = jsonObject.get("dfaccount").toString();  //对方银行账号
		  String dfaccountname = jsonObject.get("dfaccountname").toString();  //对方账号户名
		  String advisef = jsonObject.get("advisef").toString();  //通知种类
		  String direction = jsonObject.get("direction").toString();  //借贷标志
		  String itransmode = jsonObject.get("itransmode").toString();  //转存方式
		  String dbegindate = jsonObject.get("dbegindate").toString();  //存款日期
		  String rate = jsonObject.get("rate").toString();  //利率
		  String iperiods = jsonObject.get("iperiods").toString();  //存期
		  String cperiodunit = jsonObject.get("cperiodunit").toString();  //存期单位
		  String currtypename = jsonObject.get("currtypename").toString();  //币种
		  String amount = jsonObject.get("amount").toString();  //交易金额
		  String trantime = jsonObject.get("trantime").toString();  //交易时间
		  String use = jsonObject.get("use").toString();  //款项用途
		  
		  
		  
		  FixedaccountdetailsEntryInfo fixedaccountInformationEntryInfo = new FixedaccountdetailsEntryInfo();
		  fixedaccountInformationEntryInfo.setAccount(account);
		  fixedaccountInformationEntryInfo.setAccountname(accountname);
		  fixedaccountInformationEntryInfo.setBankdocname(bankdocname);
		  fixedaccountInformationEntryInfo.setAcctype(acctype);
		  fixedaccountInformationEntryInfo.setDfbanktypename(dfbanktypename);
		  fixedaccountInformationEntryInfo.setDfaccount(dfaccount);
		  fixedaccountInformationEntryInfo.setDfaccountname(dfaccountname);
		  fixedaccountInformationEntryInfo.setAdvisef(advisef);
		  if(direction.equals("1")){
			  fixedaccountInformationEntryInfo.setDirection(borrow.loan);
		  }else if(direction.equals("0")){
			  fixedaccountInformationEntryInfo.setDirection(borrow.lend);
		  }
		 
		  
		  Date parse = sdf0.parse(dbegindate);
		  fixedaccountInformationEntryInfo.setDbegindate(parse);
		  
		  fixedaccountInformationEntryInfo.setItransmode(itransmode);
		  
	       
	 
		  fixedaccountInformationEntryInfo.setRate(rate);
		  fixedaccountInformationEntryInfo.setIperiods(iperiods);
		  fixedaccountInformationEntryInfo.setCperiodunit(cperiodunit);
		  fixedaccountInformationEntryInfo.setCurrtypename(currtypename);
		  
		  DecimalFormat df1 = new DecimalFormat("###,###.##");
	       BigDecimal amount2 = new BigDecimal(amount).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
		   fixedaccountInformationEntryInfo.setAmount( df1.format(amount2) );
		   
		   SimpleDateFormat sdfhh = new SimpleDateFormat("hhMMss");
		   SimpleDateFormat sdfhh2 = new SimpleDateFormat("hh-MM-ss");
		   Date parse2 = sdfhh.parse(trantime);
		   fixedaccountInformationEntryInfo.setTrantime(sdfhh2.format(parse2)  );
		   fixedaccountInformationEntryInfo.setUse(use);
		   
		 
    	
    	return  fixedaccountInformationEntryInfo;
    }
    
    
    
    
    /**
     * 自定义方法
     * @param ctx
     * @param model
     * @return
     * @throws BOSException
     */
    protected  Object  getInfonFromBank(  IObjectValue model)throws BOSException
    {   
  	
  	 SimpleDateFormat sdf = new  SimpleDateFormat("yyyyMMdd");
  	   
   	 FixedaccountdetailsInfo  FixedaccountdetailsInfo=  (FixedaccountdetailsInfo)model;
  	  AccountBankInfo Account = FixedaccountdetailsInfo.getAccount(); //主账号
  	  if(null==Account){
  		 MsgBox.showWarning("主账号不能为空!"); 
  		 SysUtil.abort();
  	  }
  	  try {
  		Account= AccountBankFactory.getRemoteInstance().getAccountBankInfo(new ObjectUuidPK(Account.getId()));
		} catch (EASBizException e1) {
			e1.printStackTrace();
		}
   
  	 Date startDate = FixedaccountdetailsInfo.getBegin_Date();//查询开	始日期
  	 Date endDate = FixedaccountdetailsInfo.getEnd_Date();//查询结束日期
 
     
  	
  	if(null==startDate){
 		 MsgBox.showWarning("查询开始日期不能为空!"); 
 		 SysUtil.abort();
 	  }
  	
  	if(null==endDate){
 		 MsgBox.showWarning("查询结束日期不能为空!"); 
 		 SysUtil.abort();
 	  }
   	
  	 
  	 
  	 
		Map<String, Object> dataMap = new LinkedHashMap<String, Object>(); //默认
		dataMap.put("OpName", "1010");
		dataMap.put("Outsys_Code", "");
		dataMap.put("merch_id", "320002206030");
		dataMap.put("OpDate", sdf.format(new Date()));
		
		Map<String, Object> bizMap  = new LinkedHashMap<String, Object>();
		bizMap .put("Head", dataMap);//data节点是一个map

  	
		Map<String, Object> Param = new LinkedHashMap<String, Object>();
		Param.put("Account", Account.getBankAccountNumber( ));
		Param.put("Begin_Date",  null==startDate?"":sdf.format(startDate));
		Param.put("End_Date",null==endDate?"":sdf.format(endDate));
 		Param.put("Reserved1", "");
		Param.put("Reserved2", "");
		Param.put("Reserved3", "");
		Param.put("Reserved4", "");
		
		
		bizMap.put("Param", Param);
		
		byte[] callMapToXML = CommonUtils.callMapToXML(bizMap);
		
	 
		int length = callMapToXML.length;
		System.out.println("-----------xml信息------------");
		String strRead = new String(callMapToXML);
		   
		 
		 String formatbtye = CommonUtils.getFormatbtye(length);
		 StringBuffer xmlstr = new  StringBuffer();	
		 xmlstr.append(formatbtye).append(strRead);
	     String xml = CommonUtils.sendSocket("10.xx.xx.240", 9888, xmlstr.toString());
	  	
  	
  	
//	 	  System.out.println("-----------xml2Map------------");
//	      String   sCMWebfilePath="C:\\Users\\12593\\Desktop\\邮政银行接口\\1009返回信息.xml";
//		  String   xml = CommonUtils.getJsonFromFile(sCMWebfilePath).trim();
		    
		  // 将<root> 标签之前的都截取掉
		 StringBuffer stringBufferXml = new StringBuffer(xml);
	  	 int indexOfRoot = stringBufferXml.indexOf("<root>");
	  	 xml=stringBufferXml.substring(indexOfRoot, stringBufferXml.length());
		   
		  
			 Map xmlToMap = null;
			try {
				xmlToMap = CommonUtils.xmlToMap(xml.toString(),false);
			} catch (DocumentException e) {
				e.printStackTrace();
			}

		   Iterator iterator = xmlToMap.entrySet().iterator();
		    while(iterator.hasNext()){
		    	 Entry<String, Object>	  entry = (Entry<String, Object>) iterator.next();
		         System.out.println("key="+entry.getKey()+"  value="+entry.getValue());
		         if(entry.getKey().equals("Param")){
		        	 try {
						Map value = (Map) entry.getValue();
						 if( value.get("RecordSet").getClass().getName().equals("java.util.ArrayList")){
							 ArrayList recordSet = (ArrayList) value.get("RecordSet");
							 System.out.println(recordSet.toString());
							 return(recordSet );
						  }else{
							  Map recordSet = (Map) value.get("RecordSet");
							  System.out.println(recordSet.toString());
							  return(recordSet );
						  }
					} catch (Exception e) {
						 int indexOfmsg = xml.indexOf("<OpRetMsg>");
						 int indexOfmsgend = xml.indexOf("</OpRetMsg>");
					  	String msg=xml.substring(indexOfmsg, indexOfmsgend);
						 MsgBox.showError(msg);
						 SysUtil.abort();
					}
		         }
		      
		    }
		    
  	 
		return null;
  	 
  	
  }
    
   
    
    /**
     * output createNewDetailData method
     */
    protected IObjectValue createNewDetailData(KDTable table)
    {
		
        return null;
    }

    /**
     * output createNewData method
     */
    protected com.kingdee.bos.dao.IObjectValue createNewData()
    {
        com.kingdee.eas.custom.bankinterface.FixedaccountdetailsInfo objectValue = new com.kingdee.eas.custom.bankinterface.FixedaccountdetailsInfo();
				if (com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")) != null && com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")).getBoolean("isBizUnit"))
			objectValue.put("FICompany",com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentOrgUnit(com.kingdee.eas.basedata.org.OrgType.getEnum("Company")));
 
        objectValue.setCreator((com.kingdee.eas.base.permission.UserInfo)(com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentUser()));
		
        return objectValue;
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值