package com.linke.finance; import com.mhd.common.core.domain.dto.nc.*; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Date; public class Test { public static void main(String[] args) { //ys(); //sk(); } /* public static void ys(){Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = sdf.format(date); Ysitem item=new Ysitem(); item.setSo_deptid("NG040104"); item.setPk_deptid("NG040104"); item.setPk_psndoc("111"); item.setCustomer("11111"); item.setObjtype("0"); item.setDirection("1"); item.setScomment("南歧"); item.setPk_currtype("HKD"); item.setTaxrate("1"); item.setQuantity_de("0"); item.setMoney_de("1000.00"); item.setMoney_bal("1000.00"); item.setNotax_de("按税率计算"); Ysbodys bodys=new Ysbodys(); bodys.setItem(item); Ysbillhead billhead=new Ysbillhead(); billhead.setPk_group("CNK"); billhead.setPk_org("NG0401"); billhead.setSett_org("NG0401"); billhead.setCreationtime(dateString); billhead.setPk_billtype("F0"); billhead.setCreator("xiangna"); billhead.setPk_tradetype("D0"); billhead.setBillclass("ys"); billhead.setIsinit("N"); billhead.setBilldate(dateString); billhead.setSyscode("0"); billhead.setBillno("1111111"); billhead.setDef59("1111111"); billhead.setSrc_syscode("0"); billhead.setBillstatus("0"); billhead.setBillmaker("xiangna"); billhead.setPk_busitype(""); billhead.setBillyear("2025"); billhead.setBillperiod("12"); billhead.setEffectstatus("0"); billhead.setDef28("nqyw"); billhead.setDef29("11111111"); billhead.setBodys(bodys); Ysbill bill=new Ysbill(); bill.setId("1111"); bill.setBillhead(billhead); Ysufinterface ufinterface=new Ysufinterface(); ufinterface.setAccount("NKNC"); ufinterface.setBilltype("F0"); ufinterface.setBusinessunitcode(""); ufinterface.setFilename(""); ufinterface.setIsexchange("Y"); ufinterface.setOrgcode("NG0401"); ufinterface.setReceiver("NG0401"); ufinterface.setReplace("Y"); ufinterface.setRoottag(""); ufinterface.setSender("nqyw"); ufinterface.setBill(bill); JAXBContext jaxbContext = null; //String xmlString =""; try { jaxbContext = JAXBContext.newInstance(Ysufinterface.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 StringWriter sw = new StringWriter(); marshaller.marshal(ufinterface, sw); String xmlString = sw.toString(); // 这是要发送的XML字符串 System.out.println(xmlString); } catch (JAXBException e) { e.printStackTrace(); } }; public static void sk(){Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = sdf.format(date); SKitem item=new SKitem(); item.setSo_deptid("NG040104"); item.setPk_deptid("NG040104"); item.setCheckdirection("ar"); item.setPk_psndoc("111"); item.setCustomer("25849"); item.setPurchaseorder("sk96321"); item.setObjtype("0"); item.setDirection("1"); item.setScomment("新永鸿工业气体有限公司"); item.setPk_currtype("CMY"); item.setMoney_cr("1000.00"); item.setMoney_bal("1000.00"); SKbodys bodys=new SKbodys(); bodys.setItem(item); SKbillhead billhead=new SKbillhead(); billhead.setPk_group("CNK"); billhead.setPk_org("NG0401"); billhead.setSett_org("NG0401"); billhead.setCreationtime(dateString); billhead.setPk_billtype("F2"); billhead.setCreator("zhanghongming"); billhead.setPk_tradetype("D2"); billhead.setBillclass("sk"); billhead.setBilldate(dateString); billhead.setSyscode("0"); billhead.setBillno(""); billhead.setDef59("1111111"); billhead.setSrc_syscode("0"); billhead.setBillstatus("0"); billhead.setBillmaker("zhanghongming"); billhead.setPk_busitype(""); billhead.setBillyear("2025"); billhead.setBillperiod("12"); billhead.setEffectstatus("0"); billhead.setDef28("nqyw"); billhead.setDef29("11111111"); billhead.setBodys(bodys); SKbill bill=new SKbill(); bill.setId("1111"); bill.setBillhead(billhead); SKufinterface ufinterface=new SKufinterface(); ufinterface.setAccount("NKNC"); ufinterface.setBilltype("F2"); ufinterface.setBusinessunitcode(""); ufinterface.setFilename(""); ufinterface.setIsexchange("Y"); ufinterface.setOrgcode("NG0401"); ufinterface.setReceiver("NG0401"); ufinterface.setReplace("Y"); ufinterface.setRoottag(""); ufinterface.setSender("nqyw"); ufinterface.setBill(bill); JAXBContext jaxbContext = null; //String xmlString =""; try { jaxbContext = JAXBContext.newInstance(SKufinterface.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 StringWriter sw = new StringWriter(); marshaller.marshal(ufinterface, sw); String xmlString = sw.toString(); // 这是要发送的XML字符串 System.out.println(xmlString); } catch (JAXBException e) { e.printStackTrace(); } };*/ }