凭证接口传输试传

This commit is contained in:
xiezhiwen 2018-09-12 10:53:25 +08:00
parent 13175e1c8f
commit f7c5cbb56a

View File

@ -1,16 +1,30 @@
package com.tenwa.voucher.serviceImp;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.DocumentSource;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOException;
@ -21,18 +35,21 @@ import com.amarsoft.awe.util.Transaction;
import com.amarsoft.dict.als.manage.NameManager;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import com.tenwa.voucher.service.VoucherSysJointNCService;
import jbo.app.tenwa.customer.CUSTOMER_INFO;
import jbo.com.tenwa.entity.comm.own.OWN_INFO;
import jbo.voucher.LV_STACTS_CONFIG;
import jbo.voucher.LV_VOUCHER_CONFIG;
public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
/**
* 调用生成xml的方法
*/
public void sendVoucherData(JBOTransaction tx){
getVoucherToXML(tx);
}
/**
* 先获取V8视图中的凭证编号, 然后依次生成所需xml
* @param tx
*/
public static void getVoucherToXML(JBOTransaction tx) {
try {
Transaction Sqlca = null;
@ -86,8 +103,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
String ACC_MONTH = null;
String VOUCHING_PERSON = null;
Date time = new Date(); // 获取当前时间对象, 并格式化
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
String year_month_day = formatter1.format(time); // 年月日
String timeAll = "";
int a = list.size(); // 获取凭证编号的长度
@ -112,13 +128,11 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
String F3=list.get(x).get("F3");
map.clear();
map.put("F3",F3);
// 获取v8表借方数据
String sql1 = "SELECT f6,f5,f15,f63,f64,f73,f74,f75,f76 FROM VOUCHER_V8 WHERE F3=:F3 AND ENTRYDC='1'";
String sql1 = "SELECT f7,f6,f5,f15,f63,f64,f73,f74,f75,f76 FROM VOUCHER_V8 WHERE F3=:F3 AND ENTRYDC='1'";
List<Map<String, String>> v1 = DataOperatorUtil.getDataBySql(Sqlca,sql1,map);
// 获取v8表贷方数据
String sql2 = "SELECT f6,f5,f15,f63,f64,f73,f74,f75,f76,f49,f51,f52,f12 FROM VOUCHER_V8 WHERE F3=:F3 AND ENTRYDC='-1'";
String sql2 = "SELECT f8,f6,f5,f15,f63,f64,f73,f74,f75,f76,f49,f51,f52,f12 FROM VOUCHER_V8 WHERE F3=:F3 AND ENTRYDC='-1'";
List<Map<String, String>> v2 = DataOperatorUtil.getDataBySql(Sqlca,sql2,map);
// 获取v8表公共信息
@ -127,7 +141,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
ACC_YEAR = map2.get("f51");// 会计期间/
ACC_MONTH =map2.get("f52");// 会计期间/
VOUCHING_PERSON =map2.get("f12");// 制单人
timeAll =map2.get("f15");// 制单
timeAll =map2.get("f15");// 制单时间
}
BizObject own = JBOFactory.createBizObjectQuery(OWN_INFO.CLASS_NAME, "id=:OWNED_COMPANY").setParameter("OWNED_COMPANY", OWNED_COMPANY).getSingleResult(false);
Element voucher = root.addElement("voucher");
@ -138,17 +152,17 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_vouchertype = voucherHead.addElement("pk_vouchertype");// 凭证类别, 默认01/非空
pk_vouchertype.setText("1");//----------------------------------------------------------------------
Element year = voucherHead.addElement("year");// 会计年度/非空
year.setText(ACC_YEAR);
year.setText((ACC_YEAR==null)?"":ACC_YEAR);
Element pk_system = voucherHead.addElement("pk_system");// 来源系统/非空
pk_system.setText(own.getAttribute("OWN_NAME").getString()==null?"":own.getAttribute("OWN_NAME").getString());//----------------------------------------
pk_system.setText((own.getAttribute("OWN_NAME").toString()==null)?"":own.getAttribute("OWN_NAME").toString());//----------------------------------------
Element voucherkind = voucherHead.addElement("voucherkind");// 凭证类型值/非空
voucherkind.setText("0");
Element pk_accountingbook = voucherHead.addElement("pk_accountingbook");// 核算核算账簿/非空
pk_accountingbook.setText("核算核算账簿");
pk_accountingbook.setText("安鹏租赁核算账簿编码");
Element discardflag = voucherHead.addElement("discardflag");// 作废标志/可空
discardflag.setText("");
Element period = voucherHead.addElement("period");// 会计期间/非空
period.setText(ACC_MONTH);//--------------------------------------------------------------
period.setText((ACC_MONTH==null)?"":ACC_MONTH);//--------------------------------------------------------------
Element no = voucherHead.addElement("no");// 凭证号为空自动分配/非空
no.setText(F3);
Element attachment = voucherHead.addElement("attachment");// 附单据数/可空
@ -158,15 +172,15 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_prepared = voucherHead.addElement("pk_prepared");// 制单人/非空
pk_prepared.setText("制单人/非空");//-------------------------------------------
Element pk_casher = voucherHead.addElement("pk_casher");// 出纳
pk_casher.setText("出纳");//------------------------------------------
pk_casher.setText("");//------------------------------------------
Element signflag = voucherHead.addElement("signflag");// 签字标志
signflag.setText("签字标签");//-----------------------------------------------------
signflag.setText("");//-----------------------------------------------------
Element pk_checked = voucherHead.addElement("pk_checked");// 审核人
pk_checked.setText("审核人");//--------------------------------------------------
pk_checked.setText("");//--------------------------------------------------
Element tallydate = voucherHead.addElement("tallydate");// 记账日期
tallydate.setText(timeAll);//--------------------------
Element pk_manager = voucherHead.addElement("pk_manager");// 记账人
pk_manager.setText("记账人");
pk_manager.setText("");
Element memo1 = voucherHead.addElement("memo1");
memo1.setText("");
Element memo2 = voucherHead.addElement("memo2");
@ -193,7 +207,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element detailindex1 = item1.addElement("detailindex");// 分录号/非空
detailindex1.setText("分录号/非空");//------------------------------------
Element explanation1 = item1.addElement("explanation");// 摘要/非空
explanation1.setText(v8Lend.get("f5").toString());
explanation1.setText((v8Lend.get("f5")==null)?"":v8Lend.get("f5"));
Element verifydate1 = item1.addElement("verifydate");// 业务日期/可空
verifydate1.setText(timeAll);
Element price1 = item1.addElement("price");// 单价/可空
@ -202,8 +216,8 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
excrate21.setText("");//-----------------------------
Element debitquantity1 = item1.addElement("debitquantity");// 借方数量/可空
debitquantity1.setText(v1.size()+"");
Element debitamount1 = item1.addElement("原币借方金额");// 原币借方金额/可空
debitamount1.setText("原币借方金额/非空");//--------------------------------------------------
Element debitamount1 = item1.addElement("debitamount");// 原币借方金额/可空
debitamount1.setText((v8Lend.get("f7")==null)?"":v8Lend.get("f7"));//--------------------------------------------------
Element localdebitamount1 = item1.addElement("localdebitamount");// 本币借方金额/可空
localdebitamount1.setText("");//-------------------------------------------
Element groupdebitamount1 = item1.addElement("groupdebitamount");// 集团本币借方金额/可空
@ -213,7 +227,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_currtype1 = item1.addElement("pk_currtype");// 币种/非空
pk_currtype1.setText("CNY");//
Element pk_accasoa1 = item1.addElement("pk_accasoa");// 科目/非空
pk_accasoa1.setText(subject.getAttribute("SUBJECTS_NAME").getString());
pk_accasoa1.setText((subject.getAttribute("SUBJECTS_NAME").getString()==null)?"":subject.getAttribute("SUBJECTS_NAME").getString());
Element pk_unit1 = item1.addElement("pk_unit");// 所属二级核算单位/可空
pk_unit1.setText("");//---------------------------------------------------
Element pk_unit_v1 = item1.addElement("pk_unit_v");// 所属二级核算单位/版本可空
@ -225,7 +239,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype1 = ass_item1.addElement("pk_Checktype");
pk_Checktype1.setText("融资租赁资产");
Element pk_Checkvalue1 = ass_item1.addElement("pk_Checkvalue");
pk_Checkvalue1.setText(v8Lend.get("f64"));
pk_Checkvalue1.setText((v8Lend.get("f64")==null)?"":v8Lend.get("f64"));
}
// 部门名称
if(v8Lend.get("f63")!=null && !"".equals(v8Lend.get("f63"))) {// 部门名称
@ -233,7 +247,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype2 = ass_item2.addElement("pk_Checktype");
pk_Checktype2.setText("部门名称");
Element pk_Checkvalue2 = ass_item2.addElement("pk_Checkvalue");
pk_Checkvalue2.setText(v8Lend.get("f63"));
pk_Checkvalue2.setText((v8Lend.get("f63")==null)?"":v8Lend.get("f63"));
}
// 融资租赁收益类型
if(v8Lend.get("f73")!=null && !"".equals(v8Lend.get("f73"))) {
@ -241,7 +255,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype3 = ass_item3.addElement("pk_Checktype");
pk_Checktype3.setText("融资租赁收益类型");
Element pk_Checkvalue3 = ass_item3.addElement("pk_Checkvalue");
pk_Checkvalue3.setText(v8Lend.get("f73"));
pk_Checkvalue3.setText((v8Lend.get("f73")==null)?"":v8Lend.get("f73"));
}
// 资金类型
if(v8Lend.get("f74")!=null && !"".equals(v8Lend.get("f74"))) {
@ -249,7 +263,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype4 = ass_item4.addElement("pk_Checktype");
pk_Checktype4.setText("资金类型");
Element pk_Checkvalue4 = ass_item4.addElement("pk_Checkvalue");
pk_Checkvalue4.setText(v8Lend.get("f74"));
pk_Checkvalue4.setText((v8Lend.get("f74")==null)?"":v8Lend.get("f74"));
}
// 主营类型
if(v8Lend.get("f75")!=null && !"".equals(v8Lend.get("f75"))) {
@ -257,7 +271,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype5 = ass_item5.addElement("pk_Checktype");
pk_Checktype5.setText("主营类型");
Element pk_Checkvalue5 = ass_item5.addElement("pk_Checkvalue");
pk_Checkvalue5.setText(v8Lend.get("f75"));
pk_Checkvalue5.setText((v8Lend.get("f75")==null)?"":v8Lend.get("f75"));
}
// 银行账号
if(v8Lend.get("f76")!=null && !"".equals(v8Lend.get("f76"))) {
@ -265,7 +279,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_Checktype6 = ass_item6.addElement("pk_Checktype");
pk_Checktype6.setText("银行账号");
Element pk_Checkvalue6 = ass_item6.addElement("pk_Checkvalue");
pk_Checkvalue6.setText(v8Lend.get("f76"));
pk_Checkvalue6.setText((v8Lend.get("f76")==null)?"":v8Lend.get("f76"));
}
Element cashFlow = item1.addElement("cashFlow");
Element cashFlow_item1 = cashFlow.addElement("item");
@ -293,7 +307,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element creditquantity2 = item2.addElement("creditquantity");// 贷方数量 可空
creditquantity2.setText(v2.size()+"");
Element creditamount2 = item2.addElement("creditamount"); // 原币贷方金额 可空
creditamount2.setText("原币贷方金额/非空");
creditamount2.setText((v8loan.get("f8")==null)?"":v8loan.get("f8"));
Element localcreditamount2 = item2.addElement("localcreditamount");// 本币贷方金额 可空
localcreditamount2.setText("");
Element groupcreditamount2 = item2.addElement("groupcreditamount");// 集团本币贷方金额 可空
@ -303,7 +317,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element detailindex2 = item2.addElement("detailindex");// 分录号 非空
detailindex2.setText("分录号/ 非空");//-------------------------------------
Element explanation2 = item2.addElement("explanation");// 摘要 非空
explanation2.setText(v8loan.get("f5"));
explanation2.setText((v8loan.get("f5")==null)?"":v8loan.get("f5"));
Element verifydate2 = item2.addElement("verifydate");// 业务日期 可空
verifydate2.setText(timeAll);
Element price2 = item2.addElement("price");// 单价 可空
@ -313,7 +327,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_currtype2 = item2.addElement("pk_currtype");// 币种 非空
pk_currtype2.setText("CNY");
Element pk_accasoa2 = item2.addElement("pk_accasoa");// 科目 非空
pk_accasoa2.setText(subject.getAttribute("SUBJECTS_NAME").getString());
pk_accasoa2.setText((subject.getAttribute("SUBJECTS_NAME").getString()==null)?"":subject.getAttribute("SUBJECTS_NAME").getString());
Element pk_unit2 = item2.addElement("pk_unit");// 所属二级核算单位 可空 组织
pk_unit2.setText("");//------------------------------------------
Element pk_unit_v2 = item2.addElement("pk_unit_v");// 所属二级核算单位 版本可空 组织
@ -325,7 +339,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename21 = ass2_item1.addElement("checktypename");
checktypename21.setText("融资租赁资产");
Element checkvaluecode21 = ass2_item1.addElement("checkvaluecode");
checkvaluecode21.setText(v8loan.get("f64"));
checkvaluecode21.setText(((v8loan.get("f64")==null)?"":v8loan.get("f64")));
}
// 部门名称
if(v8loan.get("f63")!=null && !"".equals(v8loan.get("f63"))) {// 部门名称
@ -333,7 +347,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename22 = ass2_item2.addElement("checktypename");
checktypename22.setText("部门名称");
Element checkvaluecode22 = ass2_item2.addElement("checkvaluecode");
checkvaluecode22.setText(v8loan.get("f63"));
checkvaluecode22.setText((v8loan.get("f63")==null)?"":v8loan.get("f63"));
}
// 融资租赁收益类型
if(v8loan.get("f73")!=null && !"".equals(v8loan.get("f73"))) {
@ -341,7 +355,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename23 = ass2_item3.addElement("checktypename");
checktypename23.setText("融资租赁收益类型");
Element checkvaluecode23 = ass2_item3.addElement("checkvaluecode");
checkvaluecode23.setText(v8loan.get("f73"));
checkvaluecode23.setText((v8loan.get("f73")==null)?"":v8loan.get("f73"));
}
// 资金类型
if(v8loan.get("f74")!=null && !"".equals(v8loan.get("f74"))) {
@ -349,7 +363,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename24 = ass2_item4.addElement("checktypename");
checktypename24.setText("资金类型");
Element checkvaluecode24 = ass2_item4.addElement("checkvaluecode");
checkvaluecode24.setText(v8loan.get("f74"));
checkvaluecode24.setText((v8loan.get("f74")==null)?"":v8loan.get("f74"));
}
// 主营类型
if(v8loan.get("f75")!=null && !"".equals(v8loan.get("f75"))) {
@ -357,7 +371,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename25 = ass2_item5.addElement("checktypename");
checktypename25.setText("主营类型");
Element checkvaluecode25 = ass2_item5.addElement("checkvaluecode");
checkvaluecode25.setText(v8loan.get("f75"));
checkvaluecode25.setText((v8loan.get("f75")==null)?"":v8loan.get("f75"));
}
// 银行账号
if(v8loan.get("f76")!=null && !"".equals(v8loan.get("f76"))) {
@ -365,7 +379,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element checktypename26 = ass2_item6.addElement("checktypename");
checktypename26.setText("银行账号");
Element checkvaluecode26 = ass2_item6.addElement("checkvaluecode");
checkvaluecode26.setText(v8loan.get("f76"));
checkvaluecode26.setText((v8loan.get("f76")==null)?"":v8loan.get("f76"));
}
Element item2_cashFlow = item2.addElement("cashFlow");
Element cashflowitem2 = item2_cashFlow.addElement("item");
@ -384,13 +398,14 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_innercorp2 = cashflowitem2.addElement("pk_innercorp");// 内部单位主键,最大长度为64,类型为:String
pk_innercorp2.setText("");
}
}
String ss="D:\\voucher\\"+"APleasing_"+(i+1)+"_VOUCHER_"+year_month_day+".xml";
file=new File(ss);
}
String URL="D:\\APleasing_VOUCHER_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
}
}
/**
@ -404,7 +419,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
XMLWriter writer=null;
// 获取当前时间对象, 并格式化
Date time = new Date();
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");//
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
// 年月日
String year_month_day = formatter1.format(time);
String cust_id="";
@ -413,7 +428,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
String customername="";
String customertype="";
// 查询未传入客户信息
String sql="SELECT customer_num,customername,customertype FROM CUSTOMER_INFO WHERE (FLAG='' OR FLAG IS NULL)";
String sql="SELECT customer_num,customername,customertype,customerid FROM CUSTOMER_INFO WHERE (FLAG='' OR FLAG IS NULL)";
List<Map<String, String>> rs = DataOperatorUtil.getDataBySql(Sqlca,sql,null);
// 客户xml头
Document document= DocumentHelper.createDocument(); // 生成每个xml的头
@ -443,15 +458,15 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_org = billhead.addElement("pk_org");// 所属组织,最大长度为20,类型为:String
pk_org.setText("安鹏租赁业务单元编码");
Element code = billhead.addElement("code");// 客户编码,最大长度为40,类型为:String
code.setText(customer_num);
code.setText((customer_num==null)?"":customer_num);
Element name = billhead.addElement("name");// 客户名称,最大长度为200,类型为:String
name.setText(customername);
name.setText((customername==null)?"":customername);
Element shortname = billhead.addElement("shortname");// 客户简称,最大长度为200,类型为:String
shortname.setText(customername);
shortname.setText((customername==null)?"":customername);
Element mnecode = billhead.addElement("mnecode");// 助记码,最大长度为50,类型为:String
mnecode.setText("");
Element pk_custclass = billhead.addElement("pk_custclass");// 客户基本分类,最大长度为20,类型为:String
pk_custclass.setText(customertype);
pk_custclass.setText((customertype==null)?"":customertype);
Element pk_areacl = billhead.addElement("pk_areacl");// 地区分类,最大长度为20,类型为:String
pk_areacl.setText("");
Element issupplier = billhead.addElement("issupplier");// 供应商,最大长度为1,类型为:UFBoolean
@ -527,9 +542,9 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element item = custcontacts.addElement("item");
Element linkmanvo = item.addElement("linkmanvo");
Element code2 = linkmanvo.addElement("code");// 编码,最大长度为64,类型为:String
code2.setText(customer_num);
code2.setText((customer_num==null)?"":customer_num);
Element name2 = linkmanvo.addElement("name");// 名称,最大长度为64,类型为:String
name2.setText(customername);
name2.setText((customername==null)?"":customername);
Element sex = linkmanvo.addElement("sex");// 性别,最大长度为64,类型为:Integer
sex.setText("");
Element vjob = linkmanvo.addElement("vjob");// 职位,最大长度为64,类型为:String
@ -684,17 +699,18 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
acclimitcontrol.setText("基于上级客户账期控制,最大长度为1,类型为:UFBoolean");
Element creditlevel = item4.addElement("creditlevel");// 信用等级,最大长度为20,类型为:String
creditlevel.setText("信用等级,最大长度为20,类型为:String");*/
cust_id=rs.get(i).get("customerid");
updateSql="UPDATE CUSTOMER_INFO SET FLAG='1' WHERE CUSTOMERID='"+cust_id+"'";
/*cust_id=rs.get(i).get("customerid");
updateSql="UPDATE CUSTOMER_INFO SET FLAG='0' WHERE CUSTOMERID='"+cust_id+"'";
SqlObject updSql=new SqlObject(updateSql);
Sqlca.executeSQL(updSql);
Sqlca.executeSQL(updSql);*/
}
String URL="D:\\voucher\\"+"APleasing_Customer_"+year_month_day+".xml";
String URL="D:\\APleasing_Customer_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
}
/**
* 供应商信息xml生成, 每1000条生成一个xml
@ -722,9 +738,10 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
String REGISTERED_ASSET=""; // 注册资金
String DISTRIBUTORER=""; // 法人
String URL=""; // 网址
String updateSql=""; // 修改语句
String MBAFC_EARLYDISBURSEMENT_TYPE="";// 资金类型/支付类型
Date time = new Date(); // 获取当前时间对象, 并格式化
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");//
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");//
String year_month_day = formatter1.format(time); // 年月日
// 设置xml标签头
Document document = DocumentHelper.createDocument(); // 生成每个xml的头
@ -738,7 +755,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
root.addAttribute("replace", "Y");
root.addAttribute("roottag", "");
root.addAttribute("sender", "001");
String sql="SELECT DISTRIBUTOR_NAME,DISTRIBUTOR_CODING,DISTRIBUTOR_ADDRESS,FACT_ADDR,PROVINCES,POSTCODE,REGISTERED_ADDR,BUSINESS_SCOPE,SUBSIDIARY_COMPANY,TYPE,BUSINESS_LICENSE_NO,DISTRIBUTOR_STATUS,E_MAIL,FAX_NUMBER,REGISTERED_ASSET,DISTRIBUTORER,MBAFC_EARLYDISBURSEMENT_TYPE,URL FROM DISTRIBUTOR_INFO WHERE (FLAG='' OR FLAG IS NULL)";
String sql="SELECT DISTRIBUTOR_NAME,DISTRIBUTOR_CODING,DISTRIBUTOR_ADDRESS,FACT_ADDR,PROVINCES,POSTCODE,REGISTERED_ADDR,BUSINESS_SCOPE,SUBSIDIARY_COMPANY,TYPE,BUSINESS_LICENSE_NO,DISTRIBUTOR_STATUS,E_MAIL,FAX_NUMBER,REGISTERED_ASSET,DISTRIBUTORER,MBAFC_EARLYDISBURSEMENT_TYPE,URL,FLAG FROM DISTRIBUTOR_INFO WHERE (FLAG='' OR FLAG IS NULL)";
List<Map<String, String>> rs = DataOperatorUtil.getDataBySql(Sqlca,sql,null);
for(int i=0; i<rs.size();i++) {
DISTRIBUTOR_NAME = rs.get(i).get("DISTRIBUTOR_NAME");
@ -768,25 +785,25 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_org = billhead.addElement("pk_org");// 所属组织,最大长度为20,类型为:String
pk_org.setText("安鹏租赁业务单元编码");
Element code = billhead.addElement("code");// 供应商编号,最大长度为40,类型为:String
code.setText(DISTRIBUTOR_CODING);
code.setText((DISTRIBUTOR_CODING==null)?"":DISTRIBUTOR_CODING);
Element name = billhead.addElement("name");// 供应商名称,最大长度为200,类型为:String
name.setText(DISTRIBUTOR_NAME);
name.setText((DISTRIBUTOR_NAME==null)?"":DISTRIBUTOR_NAME);
Element shortname = billhead.addElement("shortname");// 供应商简称,最大长度为200,类型为:String
shortname.setText(DISTRIBUTOR_NAME);
shortname.setText((DISTRIBUTOR_NAME==null)?"":DISTRIBUTOR_NAME);
Element ename = billhead.addElement("ename");// 外文名称,最大长度为60,类型为:String
ename.setText("");
Element mnecode = billhead.addElement("mnecode");// 助记码,最大长度为50,类型为:String
mnecode.setText("");
Element trade = billhead.addElement("trade");// 所属行业,最大长度为20,类型为:String
trade.setText(BUSINESS_SCOPE);
trade.setText((BUSINESS_SCOPE==null)?"":BUSINESS_SCOPE);
Element pk_supplier_main = billhead.addElement("pk_supplier_main");// 上级供应商,最大长度为20,类型为:String
pk_supplier_main.setText(SUBSIDIARY_COMPANY);
pk_supplier_main.setText((SUBSIDIARY_COMPANY==null)?"":SUBSIDIARY_COMPANY);
Element supprop = billhead.addElement("supprop");// 供应商类型,最大长度为1,类型为:Integer
supprop.setText("外部单位");
Element pk_areacl = billhead.addElement("pk_areacl");// 地区分类,最大长度为20,类型为:String
pk_areacl.setText(region);
pk_areacl.setText((region==null)?"":region);
Element pk_supplierclass = billhead.addElement("pk_supplierclass");// 供应商基本分类,最大长度为20,类型为:String
pk_supplierclass.setText(TYPE);
pk_supplierclass.setText((TYPE==null)?"":TYPE);
Element iscustomer = billhead.addElement("iscustomer");// 客户,最大长度为1,类型为:UFBoolean
iscustomer.setText("");
Element corcustomer = billhead.addElement("corcustomer");// 对应客户,最大长度为20,类型为:String
@ -800,26 +817,26 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element taxpayerid = billhead.addElement("taxpayerid");// 纳税人登记号,最大长度为20,类型为:String
taxpayerid.setText("");
Element registerfund = billhead.addElement("registerfund");// 注册资金,最大长度为14,类型为:UFDouble
registerfund.setText(REGISTERED_ASSET);
registerfund.setText((REGISTERED_ASSET==null)?"":REGISTERED_ASSET);
Element legalbody = billhead.addElement("legalbody");// 法人,最大长度为20,类型为:String
legalbody.setText(DISTRIBUTORER);
legalbody.setText((DISTRIBUTORER==null)?"":DISTRIBUTORER);
Element ecotypesincevfive = billhead.addElement("ecotypesincevfive");// 经济类型,最大长度为20,类型为:String
ecotypesincevfive.setText(MBAFC_EARLYDISBURSEMENT_TYPE);
ecotypesincevfive.setText((MBAFC_EARLYDISBURSEMENT_TYPE==null)?"":MBAFC_EARLYDISBURSEMENT_TYPE);
Element pk_suptaxes = billhead.addElement("pk_suptaxes");// 供应商税类,最大长度为20,类型为:String
pk_suptaxes.setText("");
Element zipcode = billhead.addElement("zipcode");//
zipcode.setText("");
Element url = billhead.addElement("url");// Web网址,最大长度为60,类型为:String
url.setText(URL);
url.setText((URL==null)?"":URL);
Element memo = billhead.addElement("memo");//
memo.setText("");
Element suplinkman = billhead.addElement("suplinkman");// 企业地址明细
Element item1 = suplinkman.addElement("item");// 编码,最大长度为64,类型为:String
Element linkmanvo = item1.addElement("linkmanvo");
Element code2 = linkmanvo.addElement("code"); // 编码,最大长度为64,类型为:String
code2.setText(DISTRIBUTOR_CODING);
code2.setText((DISTRIBUTOR_CODING==null)?"":DISTRIBUTOR_CODING);
Element name2 = linkmanvo.addElement("name"); // 名称,最大长度为64,类型为:String
name2.setText(DISTRIBUTOR_NAME);
name2.setText((DISTRIBUTOR_NAME==null)?"":DISTRIBUTOR_NAME);
Element sex = linkmanvo.addElement("sex"); // 性别,最大长度为64,类型为:Integer
sex.setText("");
Element vjob2 = linkmanvo.addElement("vjob"); // 职位,最大长度为64,类型为:String
@ -835,11 +852,11 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element email = linkmanvo.addElement("email"); // email,最大长度为64,类型为:String
email.setText("");
Element webaddress = linkmanvo.addElement("webaddress"); // Web网址,最大长度为64,类型为:String
webaddress.setText("");
webaddress.setText((URL==null)?"":URL);
Element address = linkmanvo.addElement("address"); // 住址,最大长度为64,类型为:String
address.setText("");
Element postcode = linkmanvo.addElement("postcode"); // 邮编,最大长度为64,类型为:String
postcode.setText(POSTCODE);
postcode.setText((POSTCODE==null)?"":POSTCODE);
Element memo2 = linkmanvo.addElement("memo"); // 其它,最大长度为64,类型为:String
memo2.setText("");
Element pk_linkman = item1.addElement("pk_linkman");// 联系人,最大长度为20,类型为:String
@ -853,11 +870,11 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element tel3 = billhead.addElement("tel3");// 电话3,最大长度为50,类型为:String
tel3.setText("");
Element fax1 = billhead.addElement("fax1");// 传真1,最大长度为50,类型为:String
fax1.setText(FAX_NUMBER);
fax1.setText((FAX_NUMBER==null)?"":FAX_NUMBER);
Element fax2 = billhead.addElement("fax2");// 传真2,最大长度为50,类型为:String
fax2.setText("");
Element email2 = billhead.addElement("email");// e-mail地址,最大长度为50,类型为:String
email2.setText(E_MAIL);
email2.setText((E_MAIL==null)?"":E_MAIL);
Element pk_country = billhead.addElement("pk_country");// 国家/地区,最大长度为20,类型为:String
pk_country.setText("CN");
Element pk_timezone = billhead.addElement("pk_timezone");// 时区,最大长度为20,类型为:String
@ -865,31 +882,35 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_format = billhead.addElement("pk_format");// 数据格式,最大长度为20,类型为:String
pk_format.setText("ZH-CN");
Element enablestate = billhead.addElement("enablestate");// 启用状态,最大长度为0,类型为:Integer
enablestate.setText(DISTRIBUTOR_STATUS);
enablestate.setText((DISTRIBUTOR_STATUS==null)?"":DISTRIBUTOR_STATUS);
Element aaa = billhead.addElement("企业地址");//
Element code3 = aaa.addElement("code");// 编码,最大长度为64,类型为:String
code3.setText(BUSINESS_LICENSE_NO);
code3.setText((BUSINESS_LICENSE_NO==null)?"":BUSINESS_LICENSE_NO);
Element country = aaa.addElement("country");// 国家,最大长度为64,类型为:String
country.setText("");
Element detailinfo = aaa.addElement("detailinfo");// 详细地址,最大长度为64,类型为:String
detailinfo.setText(REGISTERED_ADDR);
detailinfo.setText((REGISTERED_ADDR==null)?"":REGISTERED_ADDR);
Element postcode3 = aaa.addElement("postcode");// 邮编,最大长度为64,类型为:String
postcode3.setText(POSTCODE);
postcode3.setText((POSTCODE==null)?"":POSTCODE);
Element province = aaa.addElement("province");// 省份,最大长度为64,类型为:String
province.setText(PROVINCES);
province.setText((PROVINCES==null)?"":PROVINCES);
Element status = aaa.addElement("status");// status,最大长度为64,类型为:Integer
status.setText("0");
Element vsection = aaa.addElement("vsection");// 区县,最大长度为64,类型为:String
vsection.setText(region);
vsection.setText((region==null)?"":region);
Element corpaddress = aaa.addElement("corpaddress");// 企业地址主键,最大长度为20,类型为:String
corpaddress.setText(FACT_ADDR);
}
String f="D:\\voucher\\"+"APleasing_Supplier_"+year_month_day+".xml";
corpaddress.setText((FACT_ADDR==null)?"":FACT_ADDR);
/* updateSql="UPDATE DISTRIBUTOR_INFO SET FLAG='0' WHERE DISTRIBUTOR_CODING='"+DISTRIBUTOR_CODING+"'";
SqlObject updSql=new SqlObject(updateSql);
Sqlca.executeSQL(updSql);*/
}
String f="D:\\APleasing_Supplier_"+year_month_day+".xml";
file=new File(f);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,f);
}
private static void DOM4JcreateToDefdoc(Transaction Sqlca,List<Map<String, String>>list, Map<String, String> map) throws Exception{
@ -897,7 +918,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
File file=null;
XMLWriter writer=null;
Date time = new Date(); // 获取当前时间对象, 并格式化
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");//
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");//
String year_month_day = formatter1.format(time); // 年月日
int a = list.size(); // 获取凭证编号的长度
int b=1000; // 设置当前xml生成的条数
@ -938,11 +959,11 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_org = billhead.addElement("pk_org");// 所属组织,最大长度为20,类型为:String
pk_org.setText("安鹏租赁业务单元编码");
Element code = billhead.addElement("code");// 档案编码,最大长度为40,类型为:String
code.setText(contract_number);
code.setText((contract_number==null)?"":contract_number);
Element name = billhead.addElement("name");// 档案名称,最大长度为200,类型为:String
name.setText(contract_name);
name.setText((contract_name==null)?"":contract_name);
Element shortname = billhead.addElement("shortname");// 简称,最大长度为200,类型为:String
shortname.setText(contract_name);
shortname.setText((contract_name==null)?"":contract_name);
Element mnecode = billhead.addElement("mnecode");// 助记码,最大长度为50,类型为:String
mnecode.setText("");
Element pid = billhead.addElement("pid");// 上级档案,最大长度为20,类型为:String
@ -950,12 +971,104 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element memo = billhead.addElement("memo");// 备注,最大长度为200,类型为:String
memo.setText("");
}
String URL="D:\\voucher\\"+"APleasing_"+(i+1)+"_Defdoc_"+year_month_day+".xml";
String URL="D:\\APleasing_Defdoc_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
}
}
/**
*
*/
public static void InterActionToNC(Transaction Sqlca,String OutURL) {
try {
/**
* 获取对方post连接
*/
String url = "http://172.16.0.19/service/XChangeServlet?account=00001&groupcode=001";
URL realURL = new URL(url);
HttpURLConnection connection = (HttpURLConnection)realURL.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-type", "text/xml");
connection.setRequestMethod("POST");
/**
* 读取本地生成的xml, 传输到NC
*/
File file = new File(OutURL);
BufferedOutputStream out = new BufferedOutputStream(connection.getOutputStream());
BufferedInputStream input = new BufferedInputStream(new FileInputStream(file));
int length;
byte[] buffer = new byte[1000];
while ((length = input.read(buffer, 0, 1000)) != -1) {
out.write(buffer, 0, length);
}
input.close();
out.close();
/**
* 获取回执信息
*/
/*InputStream inputStream = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(inputStream);
BufferedReader bufreader = new BufferedReader(isr);
String xmlString = "";
int c;
while ((c = bufreader.read()) != -1) {
System.out.print((char) c);
xmlString += (char) c;
}
input.close();
System.out.println("----" + xmlString);
*//**
* 将获取到的回执信息生成本地xml
*//*
Document resDoc = DocumentHelper.parseText(xmlString);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DocumentSource source = new DocumentSource(resDoc);
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
//设置文档的换行与缩进
transformer.setOutputProperty(OutputKeys.INDENT, "YES");
// 将回执信息输出到本地
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss");
String resFile = "D:\\"+fmt.format(new Date())+".xml";
StreamResult result = new StreamResult(new File(resFile));
transformer.transform(source,result);
*//**
* 解析xml, 根据回执信息更新状态
*//*
SAXReader sr = new SAXReader();
Document doc = sr.read(resFile);
Element root= doc.getRootElement();
//获取根元素,得到导入用友是否成功successful的值,值为Y:成功 N:失败
String resSuc = root.attributeValue("successful");
//后面对回执结果做判断,然后改变导入状态就行了
if(null != resSuc){
if(resSuc.equals("N")){
System.out.println("导入失败");
}else if(resSuc.equals("Y")){
System.out.println("导入成功");
//接下来的代码修改状态
List<Element> list = root.elements();
for (Element element : list) {
String name = element.getName();
if("".equals(name)) {
//update操作
}
}
}else{
System.out.println("出现未知错误");
}
}else{
System.out.println("未找到successful属性");
} */
} catch (Exception e) {
e.printStackTrace();
}
}
}