71 lines
2.3 KiB
Java
71 lines
2.3 KiB
Java
package com.tenwa.invoice;
|
|
|
|
import java.io.BufferedWriter;
|
|
import java.io.File;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.ResourceBundle;
|
|
|
|
import org.dom4j.Document;
|
|
import org.dom4j.DocumentException;
|
|
import org.dom4j.DocumentHelper;
|
|
import org.dom4j.Element;
|
|
|
|
public class IAutokpUtils {
|
|
public static void saveFile(String str,String contractNo){
|
|
ResourceBundle resource = ResourceBundle.getBundle("com/tenwa/invoice/InvoiceConfig");
|
|
String saveFilePath = resource.getString("saveFilePath");
|
|
File file = new File(saveFilePath+"/invoice_"+contractNo+".txt");
|
|
FileWriter fw = null;
|
|
try {
|
|
fw = new FileWriter(file);
|
|
BufferedWriter out = new BufferedWriter(fw);
|
|
out.write(str, 0, str.length());
|
|
out.close();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
public static Map<String,String> getResponseResult(String xmlResult){
|
|
Map<String,String> responseResult = new HashMap<String,String>();
|
|
try {
|
|
//添加根节点,便于解析
|
|
xmlResult = "<xml>"+xmlResult+"</xml>";
|
|
Document document = DocumentHelper.parseText(xmlResult);
|
|
Element rootElement = document.getRootElement();
|
|
/*Iterator<Element> iter = rootElement.elementIterator();
|
|
while(iter.hasNext()){
|
|
Element name = iter.next();
|
|
System.out.println("value = " + name.getText());
|
|
}*/
|
|
String fl = rootElement.element("fl").getTextTrim();
|
|
String mess = rootElement.element("mess").getTextTrim();
|
|
String fpdm = rootElement.element("fpdm").getTextTrim();
|
|
String fphm = rootElement.element("fphm").getTextTrim();
|
|
responseResult.put("fl", fl);
|
|
responseResult.put("mess", mess);
|
|
responseResult.put("fpdm", fpdm);
|
|
responseResult.put("fphm", fphm);
|
|
System.out.println("解析完成:\n fl:"+fl+"\n mess:"+mess+"\n fpdm:"+fpdm+"\n fphm:"+fphm);
|
|
} catch (DocumentException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
return responseResult;
|
|
}
|
|
|
|
static void addUserInfo(Element rootEle) {
|
|
ResourceBundle resource = ResourceBundle.getBundle("com/tenwa/invoice/InvoiceConfig");
|
|
Element Ele_wsname = rootEle.addElement("wsname");
|
|
Ele_wsname.setText(resource.getString("wsname"));
|
|
Element Ele_wspwd = rootEle.addElement("wspwd");
|
|
Ele_wspwd.setText(resource.getString("wspwd"));
|
|
|
|
|
|
}
|
|
}
|