From 51b5334c30bca8ef2cdd0f13e6553a2ab8e3c561 Mon Sep 17 00:00:00 2001 From: amarsoft Date: Mon, 27 Aug 2018 15:27:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=AD=E8=AF=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/VoucherSysJointNCService.java | 6 ++ .../VoucherSysJointNCServiceImpl.java | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src_core/com/tenwa/voucher/service/VoucherSysJointNCService.java create mode 100644 src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java diff --git a/src_core/com/tenwa/voucher/service/VoucherSysJointNCService.java b/src_core/com/tenwa/voucher/service/VoucherSysJointNCService.java new file mode 100644 index 000000000..5578ae685 --- /dev/null +++ b/src_core/com/tenwa/voucher/service/VoucherSysJointNCService.java @@ -0,0 +1,6 @@ +package com.tenwa.voucher.service; + +public interface VoucherSysJointNCService { + public void sendVoucherData()throws Exception; + +} diff --git a/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java new file mode 100644 index 000000000..48b26eea3 --- /dev/null +++ b/src_core/com/tenwa/voucher/serviceImp/VoucherSysJointNCServiceImpl.java @@ -0,0 +1,84 @@ +package com.tenwa.voucher.serviceImp; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; + +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.awe.util.Transaction; +import com.amarsoft.dict.als.cache.CacheLoaderFactory; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.voucher.service.VoucherSysJointNCService; + +public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService { + + @Override + public void sendVoucherData() throws Exception { + + + } + + + private static List getDataList() throws Exception{ + Transaction Sqlca =null; + Map map=new HashMap(); + List f3list=new ArrayList(); + Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource()); + String sql="select F3 from voucher_v8 where v8_flag='1' or v8_flag='-1'"; + List> dataList=DataOperatorUtil.getDataBySql(Sqlca, sql, map); + for(Map ma:dataList){ + f3list.add(ma.get("F3").toString()); + } + return f3list; + + } + + public static void DOM4Jcreate(File file)throws Exception{ + Document document=DocumentHelper.createDocument(); + List f3list=getDataList(); + //String s = String.Join(",", f3list.toArray()); + Element root=document.addElement("ufinterface"); + root.addAttribute("account", "develop"); + root.addAttribute("billtype", "vouchergl"); + root.addAttribute("businessunitcode", "develop"); + root.addAttribute("filename", ""); + root.addAttribute("groupcode", ""); + root.addAttribute("isexchange", ""); + root.addAttribute("orgcode", ""); + root.addAttribute("receiver", "0001121000000000JIYO"); + root.addAttribute("replace", ""); + root.addAttribute("roottag", ""); + root.addAttribute("sender", "001"); + + + Element voucher=root.addElement("voucher"); + Element voucherHead=voucher.addElement("voucher_head"); + Element pkVoucher=voucherHead.addElement("pk_voucher"); + //这个取值待定 + pkVoucher.setText("10111210000000005JUK"); + // + XMLWriter writer=new XMLWriter(new FileOutputStream(file),OutputFormat.createPrettyPrint()); + writer.setEscapeText(false);//字符是否转义,默认true + writer.write(document); + writer.close(); + } + + public static void main(String[] args) { + File file=new File("C:\\Users\\amarsoft\\Desktop\\123.xml"); + try { + //DOM4Jcreate(file); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +}