From f7c5cbb56ad0627fd33396f7251b84aa5bb5e0c6 Mon Sep 17 00:00:00 2001 From: xiezhiwen Date: Wed, 12 Sep 2018 10:53:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=87=AD=E8=AF=81=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E8=AF=95=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VoucherSysJointNCServiceImpl.java | 285 ++++++++++++------ 1 file changed, 199 insertions(+), 86 deletions(-) diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java index a64ad0193..e7d38adcf 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java @@ -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> 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> 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> 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> rs = DataOperatorUtil.getDataBySql(Sqlca,sql,null); for(int i=0; i>list, Map 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 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(); } } } From 4cfd3ce2fa798c5c9a17eb9b5fe35e210ef5700f Mon Sep 17 00:00:00 2001 From: xiezhiwen Date: Wed, 12 Sep 2018 12:08:55 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=87=AD=E8=AF=81=E7=9B=B8=E5=85=B3-?= =?UTF-8?q?=E9=A2=84=E6=94=B6=E7=A7=91=E7=9B=AE=E5=AE=A2=E6=88=B7=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InsertVoucherRentIncome.java | 4 ++-- .../serviceImp/CreateVoucherServiceImpl.java | 2 +- .../VoucherSysJointNCServiceImpl.java | 22 ++++++++----------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src_core/com/tenwa/voucher/CreateVoucherProcess/InsertVoucherRentIncome.java b/src_core/com/tenwa/voucher/CreateVoucherProcess/InsertVoucherRentIncome.java index 5ee8bb402..88aa435a7 100644 --- a/src_core/com/tenwa/voucher/CreateVoucherProcess/InsertVoucherRentIncome.java +++ b/src_core/com/tenwa/voucher/CreateVoucherProcess/InsertVoucherRentIncome.java @@ -49,7 +49,7 @@ public class InsertVoucherRentIncome { if(vouch!=null){ //收到的租金--网银 if("PZ2018072100000024".equals(VOUCHERNO)||"PZ2018080400000081".equals(VOUCHERNO)){ - sql_where="INSERT INTO voucher_v8 (id,evidence_message,periodyear,f1,f3,f5,f6,f7,f8,f12,f15,f49,f50,f51,f52,f59,f60,f61,f62,f64,f65,f73,f76,v8_status,generate_date,v8_flag,module_name,entrydc,inputuserid,f58) SELECT REPLACE(UUID(),'-','') id,'凭证输出' evidence_message,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4) periodyear,DATE_FORMAT(SYSDATE(),'%Y/%m/%d') f1,lvri.voucher_f3,'收到的租金',lv.LOAN_SUBJECT,CASE WHEN lv.LOAN_DIRECTION='1' THEN lvri.rent ELSE 0.00 END,CASE WHEN lv.LOAN_DIRECTION='2' THEN lvri.rent ELSE 0.00 END,'IT管理员',DATE_FORMAT(SYSDATE(),'%Y/%m/%d'),lv.OWNED_COMPANY,lv.OWNED_COMPANY,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4),SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),5,2),lv.sort_number,lci.contract_number,CASE WHEN lv.loan_direction='1' THEN '业务系统待查客户' ELSE lvri.cust_name END AS cust_name,lv.loan_subject,CASE WHEN lv.loan_direction='2' THEN '04' ELSE '' END,CASE WHEN lv.loan_direction='1' THEN '0203440110' ELSE lvri.cust_id END,CASE WHEN lv.loan_direction='2' THEN '02' ELSE '' END,lvri.OWN_NUMBER,'已完整',NOW(3),'0',lv.modular_number,CASE WHEN lv.loan_direction='1' THEN '1' ELSE '-1' END,'admin',lvri.income_id FROM lv_rent_income lvri LEFT JOIN lb_contract_info lci ON lci.id=lvri.contract_id LEFT JOIN (SELECT lvc.PROJ_TYPE,lvl.id,lvl.LOAN_DIRECTION,lvc.OWNED_COMPANY ,lvl.sort_number,lvl.loan_subject,lvc.modular_number FROM lv_voucher_config lvc LEFT JOIN lv_voucher_loan lvl ON lvl.VOUCHER_ID=lvc.id WHERE lvc.voucher_no IN ('PZ2018072100000024','PZ2018080400000081')) lv ON lv.proj_type=lci.LEAS_FORM WHERE lvri.income_id NOT IN (SELECT f58 FROM voucher_v8 WHERE module_name LIKE '%-收到的租金%' and f58 is not null) and lvri.rent>0 and lvri.EBANK_NUMBER is not null and lvri.EBANK_NUMBER<>'' ORDER BY lvri.voucher_f3 "; + sql_where="INSERT INTO voucher_v8 (id,evidence_message,periodyear,f1,f3,f5,f6,f7,f8,f12,f15,f49,f50,f51,f52,f59,f60,f61,f62,f64,f65,f73,f76,v8_status,generate_date,v8_flag,module_name,entrydc,inputuserid,f58) SELECT REPLACE(UUID(),'-','') id,'凭证输出' evidence_message,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4) periodyear,DATE_FORMAT(SYSDATE(),'%Y/%m/%d') f1,lvri.voucher_f3,'收到的租金',lv.LOAN_SUBJECT,CASE WHEN lv.LOAN_DIRECTION='1' THEN lvri.rent ELSE 0.00 END,CASE WHEN lv.LOAN_DIRECTION='2' THEN lvri.rent ELSE 0.00 END,'IT管理员',DATE_FORMAT(SYSDATE(),'%Y/%m/%d'),lv.OWNED_COMPANY,lv.OWNED_COMPANY,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4),SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),5,2),lv.sort_number,lci.contract_number,CASE WHEN lv.loan_direction='1' THEN '业务系统待查客户' ELSE lvri.cust_name END AS cust_name,lv.loan_subject,CASE WHEN lv.loan_direction='2' THEN '04' ELSE '' END,CASE WHEN lv.loan_direction='1' THEN 'APZL00000000DC' ELSE lvri.cust_id END,CASE WHEN lv.loan_direction='2' THEN '02' ELSE '' END,lvri.OWN_NUMBER,'已完整',NOW(3),'0',lv.modular_number,CASE WHEN lv.loan_direction='1' THEN '1' ELSE '-1' END,'admin',lvri.income_id FROM lv_rent_income lvri LEFT JOIN lb_contract_info lci ON lci.id=lvri.contract_id LEFT JOIN (SELECT lvc.PROJ_TYPE,lvl.id,lvl.LOAN_DIRECTION,lvc.OWNED_COMPANY ,lvl.sort_number,lvl.loan_subject,lvc.modular_number FROM lv_voucher_config lvc LEFT JOIN lv_voucher_loan lvl ON lvl.VOUCHER_ID=lvc.id WHERE lvc.voucher_no IN ('PZ2018072100000024','PZ2018080400000081')) lv ON lv.proj_type=lci.LEAS_FORM WHERE lvri.income_id NOT IN (SELECT f58 FROM voucher_v8 WHERE module_name LIKE '%-收到的租金%' and f58 is not null) and lvri.rent>0 and lvri.EBANK_NUMBER is not null and lvri.EBANK_NUMBER<>'' ORDER BY lvri.voucher_f3 "; } //收到的租金--卡扣 if("PZ2018082100000142".equals(VOUCHERNO)||"PZ2018082100000143".equals(VOUCHERNO)){ @@ -57,7 +57,7 @@ public class InsertVoucherRentIncome { } //收到的逾期利息--网银 if("PZ2018072100000025".equals(VOUCHERNO)||"PZ2018080400000082".equals(VOUCHERNO)){ - sql_where="INSERT INTO voucher_v8 (id,evidence_message,periodyear,f1,f3,f5,f6,f7,f8,f12,f15,f49,f50,f51,f52,f59,f60,f61,f62,f64,f65,f73,f76,v8_status,generate_date,v8_flag,module_name,entrydc,inputuserid,f58) SELECT REPLACE(UUID(),'-','') id,'凭证输出' evidence_message,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4) periodyear,DATE_FORMAT(SYSDATE(),'%Y/%m/%d') f1,lvri.voucher_f3,'收到的逾期利息',lv.LOAN_SUBJECT,CASE WHEN lv.sort_number='1' THEN lvri.penalty ELSE 0.00 END AS f7,CASE WHEN lv.sort_number='2' THEN ROUND(lvri.penalty/CASE WHEN lci.leas_form='01' THEN 1.16 ELSE 1.06 END,2) WHEN lv.sort_number='3' THEN lvri.penalty-(ROUND(lvri.penalty/CASE WHEN lci.leas_form='01' THEN 1.16 ELSE 1.06 END,2)) ELSE 0.00 END AS f8,'IT管理员',DATE_FORMAT(SYSDATE(),'%Y/%m/%d'),lv.OWNED_COMPANY,lv.OWNED_COMPANY,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4),SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),5,2),lv.sort_number,lci.contract_number,CASE WHEN lv.loan_direction='1' THEN '业务系统待查客户' ELSE lvri.cust_name END AS cust_name,lv.loan_subject,CASE WHEN lv.loan_direction='2' THEN '04' ELSE '' END,CASE WHEN lv.loan_direction='1' THEN '0203440110' ELSE lvri.cust_id END,CASE WHEN lv.loan_direction='2' THEN '02' ELSE '' END,lvri.OWN_NUMBER,'已完整',NOW(3),'0',lv.modular_number,CASE WHEN lv.loan_direction='1' THEN '1' ELSE '-1' END,'admin',lvri.income_id FROM lv_penalty_income lvri LEFT JOIN lb_contract_info lci ON lci.id=lvri.contract_id LEFT JOIN (SELECT lvc.PROJ_TYPE,lvl.id,lvl.LOAN_DIRECTION,lvc.OWNED_COMPANY ,lvl.sort_number,lvl.loan_subject,lvc.modular_number FROM lv_voucher_config lvc LEFT JOIN lv_voucher_loan lvl ON lvl.VOUCHER_ID=lvc.id WHERE lvc.voucher_no IN ('PZ2018072100000025','PZ2018080400000082')) lv ON lv.proj_type=lci.LEAS_FORM WHERE lvri.income_id NOT IN (SELECT f58 FROM voucher_v8 WHERE module_name LIKE '%-收到的逾期利息%' AND f58 IS NOT NULL) AND lvri.penalty>0 AND lvri.EBANK_NUMBER IS NOT NULL AND lvri.EBANK_NUMBER<>'' ORDER BY lvri.voucher_f3"; + sql_where="INSERT INTO voucher_v8 (id,evidence_message,periodyear,f1,f3,f5,f6,f7,f8,f12,f15,f49,f50,f51,f52,f59,f60,f61,f62,f64,f65,f73,f76,v8_status,generate_date,v8_flag,module_name,entrydc,inputuserid,f58) SELECT REPLACE(UUID(),'-','') id,'凭证输出' evidence_message,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4) periodyear,DATE_FORMAT(SYSDATE(),'%Y/%m/%d') f1,lvri.voucher_f3,'收到的逾期利息',lv.LOAN_SUBJECT,CASE WHEN lv.sort_number='1' THEN lvri.penalty ELSE 0.00 END AS f7,CASE WHEN lv.sort_number='2' THEN ROUND(lvri.penalty/CASE WHEN lci.leas_form='01' THEN 1.16 ELSE 1.06 END,2) WHEN lv.sort_number='3' THEN lvri.penalty-(ROUND(lvri.penalty/CASE WHEN lci.leas_form='01' THEN 1.16 ELSE 1.06 END,2)) ELSE 0.00 END AS f8,'IT管理员',DATE_FORMAT(SYSDATE(),'%Y/%m/%d'),lv.OWNED_COMPANY,lv.OWNED_COMPANY,SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),1,4),SUBSTR(DATE_FORMAT(SYSDATE(),'%Y%m%d'),5,2),lv.sort_number,lci.contract_number,CASE WHEN lv.loan_direction='1' THEN '业务系统待查客户' ELSE lvri.cust_name END AS cust_name,lv.loan_subject,CASE WHEN lv.loan_direction='2' THEN '04' ELSE '' END,CASE WHEN lv.loan_direction='1' THEN 'APZL00000000DC' ELSE lvri.cust_id END,CASE WHEN lv.loan_direction='2' THEN '02' ELSE '' END,lvri.OWN_NUMBER,'已完整',NOW(3),'0',lv.modular_number,CASE WHEN lv.loan_direction='1' THEN '1' ELSE '-1' END,'admin',lvri.income_id FROM lv_penalty_income lvri LEFT JOIN lb_contract_info lci ON lci.id=lvri.contract_id LEFT JOIN (SELECT lvc.PROJ_TYPE,lvl.id,lvl.LOAN_DIRECTION,lvc.OWNED_COMPANY ,lvl.sort_number,lvl.loan_subject,lvc.modular_number FROM lv_voucher_config lvc LEFT JOIN lv_voucher_loan lvl ON lvl.VOUCHER_ID=lvc.id WHERE lvc.voucher_no IN ('PZ2018072100000025','PZ2018080400000082')) lv ON lv.proj_type=lci.LEAS_FORM WHERE lvri.income_id NOT IN (SELECT f58 FROM voucher_v8 WHERE module_name LIKE '%-收到的逾期利息%' AND f58 IS NOT NULL) AND lvri.penalty>0 AND lvri.EBANK_NUMBER IS NOT NULL AND lvri.EBANK_NUMBER<>'' ORDER BY lvri.voucher_f3"; } //收到的逾期利息--卡扣 if("PZ2018082100000144".equals(VOUCHERNO)||"PZ2018082100000145".equals(VOUCHERNO)){ diff --git a/src_core/com/tenwa/voucher/serviceImp/CreateVoucherServiceImpl.java b/src_core/com/tenwa/voucher/serviceImp/CreateVoucherServiceImpl.java index d3b22b386..caaee22ec 100644 --- a/src_core/com/tenwa/voucher/serviceImp/CreateVoucherServiceImpl.java +++ b/src_core/com/tenwa/voucher/serviceImp/CreateVoucherServiceImpl.java @@ -305,7 +305,7 @@ public class CreateVoucherServiceImpl { subData.put("CUSTID",dataTemp.get("DISTRIBUTOR_ID"));//经销商id subData.put("CUSTNAME",dataTemp.get("DISTRIBUTOR_NAME"));//经销商名称 }else if("PZ2018072100000037".equals(VOUCHERNO)||"PZ2018080400000091".equals(VOUCHERNO) || "PZ2018072100000038".equals(VOUCHERNO)||"PZ2018080400000092".equals(VOUCHERNO)){ - subData.put("CUSTID","0203440110");//经销商id + subData.put("CUSTID","APZL00000000DC");//经销商id subData.put("CUSTNAME","业务系统待查客户");//经销商名称 }else { subData.put("CUSTID",dataTemp.get("CUSTID"));//客商id diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java index e7d38adcf..5592f6059 100644 --- a/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java @@ -986,6 +986,8 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { */ public static void InterActionToNC(Transaction Sqlca,String OutURL) { try { + // 定义全局变量 + String updSql=""; /** * 获取对方post连接 */ @@ -1011,7 +1013,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { /** * 获取回执信息 */ - /*InputStream inputStream = connection.getInputStream(); + InputStream inputStream = connection.getInputStream(); InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader bufreader = new BufferedReader(isr); String xmlString = ""; @@ -1023,9 +1025,9 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { input.close(); System.out.println("----" + xmlString); - *//** + /** * 将获取到的回执信息生成本地xml - *//* + */ Document resDoc = DocumentHelper.parseText(xmlString); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); @@ -1039,9 +1041,9 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { 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(); @@ -1054,19 +1056,13 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { }else if(resSuc.equals("Y")){ System.out.println("导入成功"); //接下来的代码,修改状态 - List list = root.elements(); - for (Element element : list) { - String name = element.getName(); - if("".equals(name)) { - //update操作 - } - } + updSql="UPDATE 表名 set 字段='1'"; }else{ System.out.println("出现未知错误"); } }else{ System.out.println("未找到successful属性"); - } */ + } } catch (Exception e) { e.printStackTrace(); } From 3e95164443ced13c0ecd22d36714b9f2c2f94768 Mon Sep 17 00:00:00 2001 From: liuzhao Date: Wed, 12 Sep 2018 16:12:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8F=91=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apzl/InvoiceManager/InvoiceRentDirect.jsp | 67 ++ .../InvoiceConfirmDetailList.jsp | 4 + .../ConfirmInvoice/InvoiceConfirmList.jsp | 5 +- WebContent/WEB-INF/etc/jbo/jbo_calc.xml | 2 +- WebContent/WEB-INF/etc/jbo/jbo_comm.xml | 3 +- .../rentPlanInvoiceDirectManager.java | 713 ++++++++++++++++++ 6 files changed, 790 insertions(+), 4 deletions(-) create mode 100644 WebContent/Tenwa/Apzl/InvoiceManager/InvoiceRentDirect.jsp create mode 100644 src_tenwa/com/tenwa/apzl/invoicemanager/rentplaninvoice/rentPlanInvoiceDirectManager.java diff --git a/WebContent/Tenwa/Apzl/InvoiceManager/InvoiceRentDirect.jsp b/WebContent/Tenwa/Apzl/InvoiceManager/InvoiceRentDirect.jsp new file mode 100644 index 000000000..5bf3e3381 --- /dev/null +++ b/WebContent/Tenwa/Apzl/InvoiceManager/InvoiceRentDirect.jsp @@ -0,0 +1,67 @@ +<%@ page contentType="text/html; charset=GBK"%> +<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><% + /* + Author: undefined 2018-09-11 + Content: + History Log: + */ + ASObjectModel doTemp = new ASObjectModel("InvoiceRentDirect"); + ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request); + dwTemp.Style="1"; //--设置为Grid风格-- + dwTemp.MultiSelect = true; //多选 + dwTemp.ReadOnly = "1"; //只读模式 + dwTemp.setPageSize(10); + dwTemp.genHTMLObjectWindow(""); + + //0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标,CSS层叠样式 10、风格 + String sButtons[][] = { + //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, + //{"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, + //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + {"true","","Button","申请开票","申请开票","ApplyRentInvoice()","","","","btn_icon_add",""}, + }; +%><%@include file="/Frame/resources/include/ui/include_list.jspf"%> + +<%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmDetailList.jsp b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmDetailList.jsp index 4dac26739..bc7e52b71 100644 --- a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmDetailList.jsp +++ b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmDetailList.jsp @@ -17,6 +17,7 @@ //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + {"true","","Button","返回","返回","returnList()","","","","btn_icon_return",""}, }; %><%@include file="/Frame/resources/include/ui/include_list.jspf"%> <%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp index 5b232a2c1..1dd3f2e47 100644 --- a/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp +++ b/WebContent/Tenwa/Core/InvoiceManager/ConfirmInvoice/InvoiceConfirmList.jsp @@ -16,8 +16,8 @@ String sButtons[][] = { //{"true","All","Button","新增","新增","newRecord()","","","","btn_icon_add",""}, {"true","","Button","详情","详情","viewAndEdit()","","","","btn_icon_detail",""}, - {"true","","Button","查询","查询","selectInvoice()","","","","",""} - //{"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0,'alert(getRowCount(0))')","","","","btn_icon_delete",""}, + {"true","","Button","查询","查询","selectInvoice()","","","","",""}, + {"true","","Button","删除","删除","if(confirm('确实要删除吗?'))as_delete(0)","","","","btn_icon_delete",""}, }; %><%@include file="/Frame/resources/include/ui/include_list.jspf"%> <%@ include file="/Frame/resources/include/include_end.jspf"%> \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml index 23762601e..bbf7d51e0 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml @@ -3501,7 +3501,7 @@ - + diff --git a/WebContent/WEB-INF/etc/jbo/jbo_comm.xml b/WebContent/WEB-INF/etc/jbo/jbo_comm.xml index b5d2d7eeb..08f9fa9c3 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_comm.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_comm.xml @@ -773,7 +773,8 @@ - + + diff --git a/src_tenwa/com/tenwa/apzl/invoicemanager/rentplaninvoice/rentPlanInvoiceDirectManager.java b/src_tenwa/com/tenwa/apzl/invoicemanager/rentplaninvoice/rentPlanInvoiceDirectManager.java new file mode 100644 index 000000000..df1b6ac1d --- /dev/null +++ b/src_tenwa/com/tenwa/apzl/invoicemanager/rentplaninvoice/rentPlanInvoiceDirectManager.java @@ -0,0 +1,713 @@ +package com.tenwa.apzl.invoicemanager.rentplaninvoice; + +import java.io.File; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.lang.StringUtils; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import jbo.app.tenwa.calc.LC_RENT_PLAN; +import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM; +import jbo.app.tenwa.calc.LI_INVOICE_CONFIRM_DETAIL; +import jbo.app.tenwa.calc.LI_INVOICE_RESULT; +import jbo.app.tenwa.calc.VI_INVOICE_RENT_PLAN_CONFIRM; +import jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS; +import jbo.app.tenwa.calc.VI_LI_INVOICE_RENT_DIRECT; +import jbo.app.tenwa.customer.CUSTOMER_FAMILY; +import jbo.app.tenwa.customer.CUSTOMER_PERSON; +import jbo.awe.USER_INFO; +import jbo.com.tenwa.entity.comm.invoice.LI_RENT_INVOICE_INFO; +import jbo.com.tenwa.entity.comm.own.OWN_ACCOUNT; +import jbo.com.tenwa.entity.comm.own.OWN_INFO; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOException; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.Configure; +import com.tenwa.app.invoice.action.InvoiceRequest; +import com.tenwa.app.invoice.data.ResponseEnum; +import com.tenwa.app.invoice.pojo.ResultPojo; +import com.tenwa.app.invoice.request.InvoiceRequestBase; +import com.tenwa.app.invoice.request.InvoiceRequestHead; +import com.tenwa.app.invoice.utils.DownloadPdfUtil; +import com.tenwa.app.invoice.utils.JaxbUtil; +import com.tenwa.app.invoice.utils.MathUtil; +import com.tenwa.app.invoice.utils.Num2ChineseUtil; +import com.tenwa.app.invoice.utils.PasswordGenerateUtil; +import com.tenwa.app.invoice.utils.ResultUtil; +import com.tenwa.flow.action.comm.BaseTable; +import com.tenwa.util.SecurityUtil; + +public class rentPlanInvoiceDirectManager extends BaseTable{ + + private String planIds; + private String ids; + private String moneyTypes; + private String sid; + + public String getPlanIds() { + return planIds; + } + public void setPlanIds(String planIds) { + this.planIds = planIds; + } + public String getIds() { + return ids; + } + public void setIds(String ids) { + this.ids = ids; + } + + + public String getMoneyTypes() { + return moneyTypes; + } + public void setMoneyTypes(String moneyTypes) { + this.moneyTypes = moneyTypes; + } + + public String getSid() { + return sid; + } + public void setSid(String sid) { + this.sid = sid; + } + /** + * 选择申请开票的数据--直租 + * @param tx + * @return + * @throws Exception + */ + public String ApplyRentInvoice(JBOTransaction tx) throws Exception{ + + BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); + BizObjectManager viInvoiceRentManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_RENT_DIRECT.CLASS_NAME); + + tx.join(lriiManager); + tx.join(viInvoiceRentManager); + String[] planIds = this.getPlanIds().split("@"); + String invoice_status = "1"; + String bill_type = "invoice"; + String invoice_money = ""; + String tax_type = ""; + String plan_id = ""; + String PAYMENT_NUMBER = ""; + String TAX_REG_CODE=""; + String TAX_BANK=""; + String TAX_ACC=""; + String contract_id=""; + + for(int i=0;i viInvoiceRent = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.VI_LI_INVOICE_RENT", "plan_id=:plan_id").setParameter("plan_id", planId).getResultList(false); + for (BizObject bizObject : viInvoiceRent) { + String id=UUID.randomUUID().toString().replaceAll("-", ""); + + invoice_money = bizObject.getAttribute("plan_money").toString(); + plan_id = bizObject.getAttribute("plan_id").toString(); + PAYMENT_NUMBER = bizObject.getAttribute("payment_number").toString(); + TAX_REG_CODE = bizObject.getAttribute("cert_id").toString(); + TAX_BANK = bizObject.getAttribute("bank_name").toString(); + TAX_ACC = bizObject.getAttribute("acc_number").toString(); + contract_id = bizObject.getAttribute("contract_id").toString(); + tax_type = bizObject.getAttribute("tax_type").toString(); + + if("利息".equals(tax_type)){ + tax_type = "interest"; + }else if("逾期利息".equals(tax_type)){ + tax_type = "overinterest"; + } + + + BizObject lriiObject = lriiManager.createQuery("plan_id=:plan_id and tax_type=:tax_type").setParameter("plan_id", planId).setParameter("tax_type", tax_type).getSingleResult(false); + if(lriiObject!=null){ + lriiManager.createQuery("update o set invoice_status='1' where plan_id=:plan_id").setParameter("plan_id", planId).executeUpdate(); + }else{ + + BizObject rentInvoiceInfo = lriiManager.newObject(); + rentInvoiceInfo.setAttributeValue("id", id); + rentInvoiceInfo.setAttributeValue("invoice_status", invoice_status); + rentInvoiceInfo.setAttributeValue("bill_type", bill_type); + rentInvoiceInfo.setAttributeValue("invoice_money", invoice_money); + + /*if("利息".equals(tax_type)){ + rentInvoiceInfo.setAttributeValue("tax_type", "interest"); + }else if("逾期利息".equals(tax_type)){ + rentInvoiceInfo.setAttributeValue("tax_type", "overinterest"); + + }else{ + return "金额类型为空!"; + }*/ + + if("".equals(tax_type) || tax_type==null){ + return "金额类型为空!"; + }else{ + rentInvoiceInfo.setAttributeValue("tax_type", tax_type); + } + + + + rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE", "0.00"); + rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00"); + rentInvoiceInfo.setAttributeValue("plan_id", plan_id); + rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER", PAYMENT_NUMBER); + rentInvoiceInfo.setAttributeValue("TAX_REG_CODE", TAX_REG_CODE);// 纳税人识别号 + rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);//开户行 + rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);//开户账号 + rentInvoiceInfo.setAttributeValue("contract_id", contract_id); + + rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo); + lriiManager.saveObject(rentInvoiceInfo); + } + } + + } + + return "开票成功"; + } +public String selectApplyOtherConfirm(JBOTransaction tx) throws Exception{ + + BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); + BizObjectManager viInvoiceOtherManager = JBOFactory.getBizObjectManager(VI_LI_INVOICE_OTHERS.CLASS_NAME); + + tx.join(lriiManager); + tx.join(viInvoiceOtherManager); + String[] moneyTypes = this.getMoneyTypes().split("@"); + + String invoice_status = "1"; + String bill_type = "invoice"; + String invoice_money = ""; + String plan_id = ""; + String PAYMENT_NUMBER = ""; + String TAX_REG_CODE=""; + String TAX_BANK=""; + String TAX_ACC=""; + String moneytype = ""; + String contract_id=""; + + for(int i=0;i map = new HashMap(); + //map.put("contract_id", contract_id); + //map.put("moneytype", moneytype); + + //BizObject viInvoiceOther = DataOperatorUtil.getJBOBySQL("SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O", "jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS", map, tx); + //BizObject viInvoiceOther = viInvoiceOtherManager.createQuery("contract_id=:contract_id AND moneytype=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false); + + BizObject viInvoiceOther = JBOFactory.createBizObjectQuery("jbo.app.tenwa.calc.VI_LI_INVOICE_OTHERS", "SELECT invoice_price,PAYMENT_NUMBER,cert_id,bank_name,acc_number from O where contract_id=:contract_id AND moneytype=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false); + + invoice_money = viInvoiceOther.getAttribute("invoice_price").toString(); + PAYMENT_NUMBER = viInvoiceOther.getAttribute("PAYMENT_NUMBER").toString(); + TAX_REG_CODE = viInvoiceOther.getAttribute("cert_id").toString(); + TAX_BANK = viInvoiceOther.getAttribute("bank_name").toString(); + TAX_ACC = viInvoiceOther.getAttribute("acc_number").toString(); + + BizObject lriiObject = lriiManager.createQuery("contract_id=:contract_id and tax_type=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).getSingleResult(false); + if(lriiObject !=null){ + lriiManager.createQuery("update o set invoice_status='1' where contract_id=:contract_id and tax_type=:moneytype").setParameter("contract_id", contract_id).setParameter("moneytype", moneytype).executeUpdate(); + }else{ + + BizObject rentInvoiceInfo = lriiManager.newObject(); + rentInvoiceInfo.setAttributeValue("id", id); + rentInvoiceInfo.setAttributeValue("invoice_status", invoice_status); + rentInvoiceInfo.setAttributeValue("bill_type", bill_type); + rentInvoiceInfo.setAttributeValue("invoice_money", invoice_money); + if("gps".equals(moneytype)){ + rentInvoiceInfo.setAttributeValue("tax_type", moneytype); + }else if("sxf".equals(moneytype)){ + rentInvoiceInfo.setAttributeValue("tax_type", moneytype); + }else if("myhj".equals(moneytype)){ + rentInvoiceInfo.setAttributeValue("tax_type", moneytype); + }else{ + return "金额类型为空!"; + } + rentInvoiceInfo.setAttributeValue("TEMPORARY_NOINVOICE", "0.00"); + rentInvoiceInfo.setAttributeValue("NOINVOICE", "0.00"); + rentInvoiceInfo.setAttributeValue("plan_id", plan_id); + rentInvoiceInfo.setAttributeValue("PAYMENT_NUMBER", PAYMENT_NUMBER); + rentInvoiceInfo.setAttributeValue("TAX_REG_CODE", TAX_REG_CODE);// 纳税人识别号 + rentInvoiceInfo.setAttributeValue("TAX_BANK", TAX_BANK);//开户行 + rentInvoiceInfo.setAttributeValue("TAX_ACC", TAX_ACC);//开户账号 + rentInvoiceInfo.setAttributeValue("contract_id", contract_id); + + rentInvoiceInfo = this.initTabeUserInfo(rentInvoiceInfo); + lriiManager.saveObject(rentInvoiceInfo); + } + + } + + return "开票成功"; + } + /** + * 开票确认提交 + * @param tx + * @return + * @throws Exception + */ + public String invoiceConfirmSubmit(JBOTransaction tx) throws Exception{ + + BizObjectManager ownAccountManager = JBOFactory.getBizObjectManager(OWN_ACCOUNT.CLASS_NAME); + BizObject ownAccount = ownAccountManager.createQuery("state_=:state and acc_type=:acc_type and money_type=:money_type and account_type=:account_type") + .setParameter("state", "0010").setParameter("acc_type", "0010") + .setParameter("money_type", "01").setParameter("account_type", "invoice").getSingleResult(false); + if(ownAccount==null || "".equals(ownAccount)){ + return "您的本方银行账户为空!"; + } + String[] rentInvoiceids = this.getIds().split("@"); + List rentPlanIdList = new ArrayList(); + + for(int i=0;i checkInvoiceList= (List)invoiceManager.createQuery("SELECT DISTINCT O.customer_name,O.CUSTOMER_ID FROM O WHERE O.id IN ("+rentPlanstr+")").getResultList(false); + if(checkInvoiceList!=null &&checkInvoiceList.size()>1){ + return "选择的不是同一个客户!"; + }else if(checkInvoiceList!=null &&checkInvoiceList.size()==1){ + customerid = checkInvoiceList.get(0).getAttribute("CUSTOMER_ID").toString(); + customerName = checkInvoiceList.get(0).getAttribute("customer_name").toString(); + }else{ + return "ERROR[02]"; + } + + String confirmId=UUID.randomUUID().toString().replaceAll("-", ""); + Double hjje =0.00; + Double hjse = 0.00; + Double jshj = 0.00; + List confirmDetailList = new ArrayList(); + + DecimalFormat df2 = new DecimalFormat(".00"); + DecimalFormat df6 = new DecimalFormat(".000000"); + + BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); + Double sl = 0.06; + for(int i=0;i0){ + BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME); + tx.join(confirmManager); + BizObject confirmBizObject = confirmManager.newObject(); + + String ownId = ownAccount.getAttribute("own_id").toString(); + BizObjectManager ownInfoManager = JBOFactory.getBizObjectManager(OWN_INFO.CLASS_NAME); + BizObject ownInfo = ownInfoManager.createQuery("OWN_NUMBER=:OWN_NUMBER").setParameter("OWN_NUMBER", ownId).getSingleResult(false); + String xhdwdzdh = ownInfo.getAttribute("LEASE_TEL").toString();//销货单位地址电话 + + BizObjectManager customerPersonManager = JBOFactory.getBizObjectManager(CUSTOMER_PERSON.CLASS_NAME); + BizObjectManager customerFamilyManager = JBOFactory.getBizObjectManager(CUSTOMER_FAMILY.CLASS_NAME); + + BizObject customerPerson = customerPersonManager.createQuery("SELECT o.certid,caa.fulladdress,o.mobile,ca.acc_number,ca.bank_name from o JOIN jbo.app.tenwa.customer.CUSTOMER_ACCOUNT ca ON ca.customerid=o.customerid JOIN jbo.app.tenwa.customer.CUSTOMER_ADDRESS caa ON caa.customerid=ca.customerid where o.customerid=:customerid") + .setParameter("customerid", customerid).getSingleResult(false); + + BizObject customerFamily = customerFamilyManager.createQuery("customerid=:customerid").setParameter("customerid", customerid).getSingleResult(false); + String familyTel=""; + if(customerFamily!=null){ + familyTel = customerFamily.getAttribute("tel").toString(); + } + String certid=""; + String fulladdress=""; + String mobile=""; + String acc_number=""; + String bank_name=""; + String acc_bank=""; + String address_tel=""; + if(customerPerson!=null){ + certid=customerPerson.getAttribute("certid").toString(); + fulladdress=customerPerson.getAttribute("fulladdress").toString(); + mobile=customerPerson.getAttribute("mobile").toString(); + acc_number=customerPerson.getAttribute("acc_number").toString(); + bank_name=customerPerson.getAttribute("bank_name").toString(); + + acc_bank = "["+bank_name+"]["+acc_number+"]"; + address_tel = "["+mobile+"]["+fulladdress+"]"; + + } + BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME); + BizObject contractInfo = contractInfoManager.createQuery("SELECT o.leas_form,lul.customer_id,ci.customertype FROM o JOIN jbo.com.tenwa.lease.comm.LB_UNION_LESSEE lul ON o.id=lul.contract_id JOIN jbo.app.tenwa.customer.CUSTOMER_INFO ci ON ci.customerid=lul.customer_id WHERE O.businesstype='1' AND lul.customer_id=:customerid").setParameter("customerid",customerid).getSingleResult(false); + String customertype = contractInfo.getAttribute("customertype").toString();//客户类型:自然人或法人 + + + BizObjectManager userInfoManager = JBOFactory.getBizObjectManager(USER_INFO.CLASS_NAME); + BizObject userInfo = userInfoManager.createQuery("userid=:userid").setParameter("userid", CurUserID).getSingleResult(false); + String username=userInfo.getAttribute("username").toString();//开票人 + + confirmBizObject.setAttributeValue("id", confirmId); + confirmBizObject.setAttributeValue("sid", PasswordGenerateUtil.getRandom(64, PasswordGenerateUtil.TYPE.LETTER_CAPITAL)); + confirmBizObject.setAttributeValue("yylxdm", "1"); + confirmBizObject.setAttributeValue("fplxdm", "026"); + confirmBizObject.setAttributeValue("kplx", "0"); + confirmBizObject.setAttributeValue("tspz", "00"); + confirmBizObject.setAttributeValue("xhdwdzdh", xhdwdzdh); + confirmBizObject.setAttributeValue("xhdwyhzh", ownAccount.getAttribute("acc_number").toString()); + confirmBizObject.setAttributeValue("ghdwsbh", certid); + confirmBizObject.setAttributeValue("ghdwmc", customerName); + confirmBizObject.setAttributeValue("ghdwdzdh", address_tel); + confirmBizObject.setAttributeValue("ghdwyhzh", acc_bank); + confirmBizObject.setAttributeValue("hsslbs", "0"); + confirmBizObject.setAttributeValue("zhsl", ""); + confirmBizObject.setAttributeValue("hjje", hjje); + confirmBizObject.setAttributeValue("hjse", hjse); + confirmBizObject.setAttributeValue("jshj", MathUtil.add( hjje,hjse )); + confirmBizObject.setAttributeValue("fhr", ""); + confirmBizObject.setAttributeValue("kpr", username); + confirmBizObject.setAttributeValue("zyspmc", ""); + confirmBizObject.setAttributeValue("spsm", ""); + confirmBizObject.setAttributeValue("ssyf", ""); + confirmBizObject.setAttributeValue("tzdbh", ""); + confirmBizObject.setAttributeValue("yfpdm", ""); + confirmBizObject.setAttributeValue("yfphm", ""); + confirmBizObject.setAttributeValue("GMF_DZYX", ""); + if("01".equals(customertype)){ + confirmBizObject.setAttributeValue("GMF_SJHM", familyTel); + }else{ + confirmBizObject.setAttributeValue("GMF_SJHM", mobile); + } + confirmBizObject.setAttributeValue("GMF_OPENID", ""); + + + confirmBizObject = this.initTabeUserInfo(confirmBizObject); + confirmManager.saveObject(confirmBizObject); + + InvoiceRequest invoiceRequest = new InvoiceRequest(); + + ResultPojo result = invoiceRequest.send(confirmBizObject,confirmDetailList); + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + System.out.println("[OK][SUCCESS]"); + for(BizObject confirmDetailBizObject : confirmDetailList){ + String invoiceId = confirmDetailBizObject.getAttribute("invoice_id").toString(); + String invoice_type = confirmDetailBizObject.getAttribute("invoice_type").toString(); + //if("fund".equals(invoice_type)){ + //invoiceFundManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate(); + //}else{ + invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","3").executeUpdate(); + //} + } + return "开票申请成功"; + }else{ + return returnmsg; + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + return result.getMsg(); + } + + }else{ + return "操作失败!"; + } + } + /** + * 退回申请开票 + * @param tx + * @return + * @throws Exception + */ + public String backInvoice(JBOTransaction tx) throws Exception{ + BizObjectManager lriiManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME); + //BizObjectManager lfiiManager = JBOFactory.getBizObjectManager(LI_FUND_INVOICE_INFO.CLASS_NAME); + tx.join(lriiManager); + //tx.join(lfiiManager); + String[] rentPlanids = this.getIds().split("@"); + for(int i=0;i[INVOICE_LOCAL_PATH]不存在"; + } + + String sid = this.getSid(); + InvoiceRequestBase invoiceRequestBase = new InvoiceRequestBase(); + InvoiceRequestHead invoiceRequestHead = new InvoiceRequestHead(); + invoiceRequestHead.setAppid(appId); + invoiceRequestHead.setSid(sid); + + invoiceRequestBase.setHead(invoiceRequestHead); + invoiceRequestBase.setComment("查询开票结果"); + invoiceRequestBase.setId("CXKPJG"); + invoiceRequestBase.setVersion("1.0"); + + String xml = JaxbUtil.convertToXml(invoiceRequestBase); + ResultPojo result = doPost(xml); + + //根据sid拿到LI_INVOICE_CONFIRM表的id(租金发票表的id和此表id都保存在LI_INVOICE_CONFIRM_Detail表中) + BizObjectManager confirmManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM.CLASS_NAME); + BizObject confirm = confirmManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false); + String invoice_confirm_id = confirm.getAttribute("id").toString(); + + String id=UUID.randomUUID().toString().replaceAll("-", ""); + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + String fplxdm = responseBase.getBody().getFplxdm(); + String fpdm = responseBase.getBody().getFpdm(); + String fphm = responseBase.getBody().getFphm(); + String kprq = responseBase.getBody().getKprq(); + String hjje = responseBase.getBody().getHjje(); + String skm = responseBase.getBody().getSkm(); + String jym = responseBase.getBody().getJym(); + String pdfurl = ""; + String localFile = ""; + String path=""; + if("0".equals(returncode)){ + pdfurl = responseBase.getBody().getPdfurl(); + SimpleDateFormat dateFormat = new SimpleDateFormat("YYYYMMdd"); + String ydm = dateFormat.format(new Date()); + + path = File.separator + ydm.substring(0, 4)+File.separator + ydm.substring(4, 6)+File.separator + ydm.substring(6, 8); + path = path+File.separator+PasswordGenerateUtil.getRandom(50, PasswordGenerateUtil.TYPE.LETTER_CAPITAL)+".pdf"; + localFile = INVOICE_LOCAL_PATH+path; + try { + DownloadPdfUtil.go(pdfurl,localFile); + } catch (Exception e) { + e.printStackTrace(); + return "下载PDF失败"; + } + } + try { + path = SecurityUtil.encrypt(path, "invoice"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + BizObjectManager confirmResultManager = JBOFactory.getBizObjectManager(LI_INVOICE_RESULT.CLASS_NAME); + BizObject confirmResult = confirmResultManager.createQuery("sid=:sid").setParameter("sid", sid).getSingleResult(false); + if(confirmResult==null){ + BizObject confirmResultNew = confirmResultManager.newObject(); + confirmResultNew.setAttributeValue("ID",id); + confirmResultNew.setAttributeValue("sid",sid); + confirmResultNew.setAttributeValue("fplxdm",fplxdm); + confirmResultNew.setAttributeValue("fpdm",fpdm ); + confirmResultNew.setAttributeValue("fphm",fphm); + confirmResultNew.setAttributeValue("kprq",kprq); + confirmResultNew.setAttributeValue("hjje",hjje); + confirmResultNew.setAttributeValue("skm",skm); + confirmResultNew.setAttributeValue("jym",jym); + confirmResultNew.setAttributeValue("pdfurl",pdfurl); + confirmResultNew.setAttributeValue("localFile",path ); + confirmResultNew.setAttributeValue("returncode",returncode); + confirmResultNew.setAttributeValue("returnmsg",returnmsg); + confirmResultManager.saveObject(confirmResultNew); + }else{ + confirmResultManager.createQuery("update o set fplxdm=:fplxdm,fpdm=:fpdm,fphm=:fphm,kprq=:kprq,hjje=:hjje,skm=:skm,jym=:jym,pdfurl=:pdfurl,localFile=:localFile,returncode=:returncode,returnmsg=:returnmsg where sid=:sid ") + .setParameter("sid",sid).setParameter("fplxdm","fplxdm") + .setParameter("fpdm",fpdm).setParameter("fphm","fphm") + .setParameter("kprq",kprq).setParameter("hjje","hjje") + .setParameter("skm",skm).setParameter("jym","jym") + .setParameter("pdfurl",pdfurl).setParameter("localFile","localFile") + .setParameter("returncode",returncode).setParameter("returnmsg","returnmsg") + .executeUpdate(); + + } + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + //System.out.println("[OK][SUCCESS]"); + //修改租金发票信息表的状态 + BizObjectManager confirmDetailManager = JBOFactory.getBizObjectManager(LI_INVOICE_CONFIRM_DETAIL.CLASS_NAME); + BizObject confirmDetail = confirmDetailManager.createQuery("invoice_confirm_id=:invoice_confirm_id").setParameter("invoice_confirm_id", invoice_confirm_id).getSingleResult(false); + String invoiceId = confirmDetail.getAttribute("invoice_id").toString(); + + BizObjectManager invoiceRentManager = JBOFactory.getBizObjectManager(LI_RENT_INVOICE_INFO.CLASS_NAME, tx); + invoiceRentManager.createQuery("update o set INVOICE_STATUS=:invoicestatus where ID=:id ").setParameter("id",invoiceId).setParameter("invoicestatus","5").executeUpdate(); + + + return "开票申请成功"; + }else{ + return returnmsg; + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + return result.getMsg(); + } + /* + if(result.getCode().toString()!="0"){ + return "查询失败"; + } + + System.out.println("result=>>>"+JSONObject.toJSONString(result)); + showResult(result); + return "查询成功";*/ + + +} + public ResultPojo doPost(String xml){ + Configure config = Configure.getInstance(); + String url=""; + try { + url = config.getConfigure("INVOICE_URL"); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + HttpHeaders httpHeaders = new HttpHeaders(); + MultiValueMap param = new LinkedMultiValueMap<>(); + httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + param.add("bw",xml) ; + RestTemplate restTemplate = new RestTemplate(); + HttpEntity> entity = new HttpEntity<>(param, httpHeaders); + ResponseEntity response = null ; + try { + response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); + }catch (Exception e){ + return ResultUtil.error(ResponseEnum.NETWORK.getMsg()); + } + System.out.println(response.getBody()); + InvoiceRequestBase r = JaxbUtil.converyToJavaBean(response.getBody(), InvoiceRequestBase.class); + return ResultUtil.success(r); + } + private void showResult(ResultPojo result) { + if(result.getCode()==0){ + InvoiceRequestBase responseBase = (InvoiceRequestBase) result.getData(); + String returncode = responseBase.getBody().getReturncode(); + String returnmsg = responseBase.getBody().getReturnmsg(); + + System.out.println("[OK][returncode]=>>>"+returncode); + System.out.println("[OK][returnmsg]=>>>"+returnmsg); + if("0".equals(returncode)){ + System.out.println("[OK][SUCCESS]"); + } + }else{ + System.out.println("[FAIL]=>>>"+result.getMsg()); + } + } + +} From a3e54422a4498835698514288e5ae5ba7d2f91d4 Mon Sep 17 00:00:00 2001 From: liuzhao Date: Wed, 12 Sep 2018 18:13:35 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BD=A3=E9=87=91=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tenwa/apzl/commission/commissionSet.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src_tenwa/com/tenwa/apzl/commission/commissionSet.java b/src_tenwa/com/tenwa/apzl/commission/commissionSet.java index e3e0c4a8f..f9b33dd73 100644 --- a/src_tenwa/com/tenwa/apzl/commission/commissionSet.java +++ b/src_tenwa/com/tenwa/apzl/commission/commissionSet.java @@ -93,29 +93,37 @@ public class commissionSet { Transaction Sqlca=null; tx= JBOFactory.createJBOTransaction(); Sqlca=Transaction.createTransaction(tx); + String endDate = this.getEndDate(); + endDate = endDate.replaceAll("/", ""); + int end = Integer.parseInt(endDate); int start = 0; String sql="SELECT MIN(effect_start) AS effect_start FROM LB_PRODUCT_SALVAGE WHERE product_id=:product_id AND effect_start>:effect_start"; SqlObject asql = new SqlObject(sql).setParameter("product_id", leasForm).setParameter("effect_start", startDate); try { ASResultSet rs = Sqlca.getResultSet(asql); - if(rs.next()){ - String effectStart = rs.getString(1); - effectStart = effectStart.replaceAll("/", ""); - start = Integer.parseInt(effectStart); - } + + + if(rs.next()){ + String effectStart = rs.getString(1); + if(effectStart==null || "".equals(effectStart)){ + return "success"; + }else{ + + effectStart = effectStart.replaceAll("/", ""); + start = Integer.parseInt(effectStart); + } + } + } catch (Exception e) { e.printStackTrace(); } - - String endDate = this.getEndDate(); - endDate = endDate.replaceAll("/", ""); - int end = Integer.parseInt(endDate); - if(end>=start){ return "fail"; }else{ return "success"; } + + } } From 5477aa568104a83b93645f1a2877166b4139a6b8 Mon Sep 17 00:00:00 2001 From: liuzhao Date: Wed, 12 Sep 2018 18:15:33 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BD=A3=E9=87=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebContent/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp b/WebContent/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp index e72666c56..fbb2d9e0b 100644 --- a/WebContent/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp +++ b/WebContent/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp @@ -145,7 +145,7 @@ var startDate=getItemValue(0,0,"effect_start"); var endDate=getItemValue(0,0,"effect_end"); - alert(endDate); + //alert(endDate); var Result = AsControl.RunJavaMethod("com.tenwa.apzl.commission.commissionSet", "editEnd","endDate="+endDate+",leasForm="+leas_form+",startDate="+startDate); if(Result=='success'){ alert("保存成功!");