凭证接口属于业务接口,调用业务接口之前,需先调用登录接口。
金蝶EAS接口调用时,可以先下载相应的WSDL文件,需要知道金蝶应用服务器地址,下载路径例如:
http://192.168.1.199:6888/web/services(或)
http://192.168.1.199:6888/ormrpc/services
(实际IP地址、端口根据应用服务器的具体情况)
package com.demo.modules.si.test;import com.demo.modules.si.util.LoginUtil;import mon.si.gl.wsvoucher.WSWSVoucher;import mon.si.gl.WSGLWebServiceFacadeSrvProxyServiceLocator;/*** 凭证接口测试,演示程序,仅供参考* 涉及生成凭证、删除凭证,需先下载WSDL文件生成WebService客户端代码* @author 郭旭**/public class Test {/*** 凭证接口调用测试*/public static void main(String[] args) throws Exception {// 调用业务接口之前进行验权boolean login = LoginUtil.login();if(login){// 生成凭证// importVoucher();// 删除凭证deleteVoucher();}}/*** 凭证生成,供第三方系统调用,直接生成金蝶EAS凭证*/public static void importVoucher() throws Exception {String[] results = null; //导入凭证操作的反馈信息WSWSVoucher[] vouchers = new WSWSVoucher[2];vouchers[0] = getWSVoucher1("1122.02", 0, 1, "测试数据50", "测试数据"); //借方分录vouchers[1] = getWSVoucher2("6001.01.01", 0, 2, "测试数据50", "测试数据"); //贷方分录WSGLWebServiceFacadeSrvProxyServiceLocator locator = null;locator = new WSGLWebServiceFacadeSrvProxyServiceLocator();// 需引入现金流量时,最后一个参数为1,否则为0// 需直接生成提交状态的凭证时,第二个参数为1,否则为0results = locator.getWSGLWebServiceFacade().importVoucher(vouchers, 0, 0, 0);System.out.println("返回值数组长度:" + results.length);for(String result : results){System.out.println(result);}}/*** 凭证删除,供第三方系统调用,用于删除金蝶EAS凭证*/public static void deleteVoucher() throws Exception {WSGLWebServiceFacadeSrvProxyServiceLocator locator = null;locator = new WSGLWebServiceFacadeSrvProxyServiceLocator();String companyNumber = "M006"; //公司编码String period = ".01"; //期间String voucherNumber = "暂071"; //凭证号String fexp = "测试数据50"; //参考信息// 删除凭证时,所需参数均为金蝶EAS系统对应的实际参数int result = locator.getWSGLWebServiceFacade().deleteVoucher(companyNumber, period, voucherNumber, fexp);if(result == 0){System.out.println("删除凭证成功!");} else {System.out.println("删除凭证失败!错误码:" + result);}}/*** 封装凭证分录(借方)* @param accmountNumber 科目编码* @param amount 金额* @param entrySeq 分录行号* @param desc 参考信息* @param abst 凭证摘要* */public static WSWSVoucher getWSVoucher1(String accmountNumber, double amount, int entrySeq, String desc, String abst) throws Exception {WSWSVoucher voucher = new WSWSVoucher();voucher.setVoucherNumber(""); //凭证号voucher.setCompanyNumber("M006"); //公司编码voucher.setBookedDate("-01-15"); //记账日期voucher.setBizDate("-01-15"); //业务日期voucher.setPeriodYear(); //年voucher.setPeriodNumber(1); //期间(月)voucher.setVoucherType("记"); //凭证类型voucher.setDescription(desc);voucher.setAccountNumber(accmountNumber); //科目编码voucher.setEntrySeq(entrySeq); //分录行号voucher.setEntryDC(1); //借贷方向:1,借;0(-1),贷voucher.setCurrencyNumber("BB01"); //币别编码voucher.setCreator("冯博"); //制单人voucher.setVoucherAbstract(abst);voucher.setOriginalAmount(amount); //原币金额voucher.setDebitAmount(amount); //借方金额voucher.setCreditAmount(0); //贷方金额voucher.setAsstSeq(1); //辅助账行voucher.setAsstActType1("客户"); //辅助核算voucher.setAsstActNumber1("G001G001000007"); //核算项目编码voucher.setAsstActName1("刘苒苒"); //核算项目名称voucher.setItemFlag(0); //现金流量标记return voucher;}/*** 封装凭证分录(贷方)* @param accmountNumber 科目编码* @param amount 金额* @param entrySeq 分录行号* @param desc 参考信息* @param abst 凭证摘要* */public static WSWSVoucher getWSVoucher2(String accmountNumber, double amount, int entrySeq, String desc, String abst) throws Exception {WSWSVoucher voucher = new WSWSVoucher();voucher.setVoucherNumber(""); //凭证号voucher.setCompanyNumber("M006"); //公司编码voucher.setBookedDate("-01-15"); //记账日期voucher.setBizDate("-01-15"); //业务日期voucher.setPeriodYear(); //年voucher.setPeriodNumber(1); //期间(月)voucher.setVoucherType("记"); //凭证类型voucher.setDescription(desc);voucher.setAccountNumber(accmountNumber); //科目编码voucher.setEntrySeq(entrySeq); //分录行号voucher.setEntryDC(-1); //借贷方向:1,借;0(-1),贷voucher.setCurrencyNumber("BB01"); //币别编码voucher.setCreator("冯博"); //制单人voucher.setVoucherAbstract(abst);voucher.setOriginalAmount(amount); //原币金额voucher.setDebitAmount(0); //借方金额voucher.setCreditAmount(amount); //贷方金额voucher.setItemFlag(0); //现金流量标记return voucher;}}