161 lines
4.3 KiB
Java
161 lines
4.3 KiB
Java
package com.tenwa.invoice;
|
|
|
|
import java.rmi.RemoteException;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
|
|
import javax.xml.rpc.ServiceException;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
import com.amarsoft.awe.util.Transaction;
|
|
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
|
|
|
|
public class IAutokpDo {
|
|
String invoiceParam;
|
|
public String getInvoiceParam() {
|
|
return invoiceParam;
|
|
}
|
|
public void setInvoiceParam(String invoiceParam) {
|
|
this.invoiceParam = invoiceParam;
|
|
}
|
|
public String invoice(){
|
|
Transaction Sqlca = null;
|
|
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
|
|
|
String invoiceParam = this.invoiceParam.replaceAll("@", ",");
|
|
String requestParam = "";
|
|
IAutokpXML ivoiceXML = new IAutokpXML();
|
|
//根据合同号进行分组
|
|
Map<String,List<Map<String,String>>> map = ivoiceXML.getParam(invoiceParam);
|
|
for(Map.Entry<String, List<Map<String, String>>> lsm: map.entrySet()){
|
|
String contract_no=lsm.getKey();
|
|
String responseParam="";
|
|
try {
|
|
requestParam = ivoiceXML.createInvoiceXML(lsm);
|
|
if(!requestParam.startsWith("error")&&requestParam!=null&&!"".equals(requestParam)){
|
|
IAutokpUtils.saveFile(requestParam, contract_no);
|
|
IAutokpserviceLocator kpl = new IAutokpserviceLocator();
|
|
IAutokp autoKP = kpl.getIAutokpPort();
|
|
responseParam = autoKP.invoice(requestParam);
|
|
}
|
|
|
|
} catch (RemoteException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (ServiceException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
//开票成功
|
|
if(!"".endsWith(responseParam)){
|
|
IAutokpUtils.saveFile(responseParam, contract_no);
|
|
Map<String,String> responseResult = IAutokpUtils.getResponseResult(responseParam);
|
|
if("4011".equals(responseResult.get("fl"))){
|
|
|
|
}else{
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println();
|
|
return null;
|
|
}
|
|
/**
|
|
* 发票打印
|
|
* @return
|
|
*/
|
|
public String invoice_pr(){
|
|
String requestParam="";
|
|
String responseParam="";
|
|
String SID = "Invoice_getfph";
|
|
try {
|
|
IAutokpserviceLocator kpl = new IAutokpserviceLocator();
|
|
IAutokp autoKP = kpl.getIAutokpPort();
|
|
responseParam = autoKP.invoice_pr(requestParam);
|
|
} catch (ServiceException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (RemoteException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
/**
|
|
* 发票作废
|
|
* @return
|
|
*/
|
|
public String invoice_fpzf(){
|
|
String requestParam="";
|
|
String responseParam="";
|
|
String SID = "Invoice_getfph";
|
|
try {
|
|
IAutokpserviceLocator kpl = new IAutokpserviceLocator();
|
|
IAutokp autoKP = kpl.getIAutokpPort();
|
|
responseParam = autoKP.invoice_fpzf(requestParam);
|
|
} catch (ServiceException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (RemoteException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
/**
|
|
* 获取待开发票号
|
|
* @return
|
|
*/
|
|
public String getfph(){
|
|
String requestParam="";
|
|
String responseParam="";
|
|
String SID = "Invoice_getfph";
|
|
try {
|
|
IAutokpserviceLocator kpl = new IAutokpserviceLocator();
|
|
IAutokp autoKP = kpl.getIAutokpPort();
|
|
responseParam = autoKP.getfph(requestParam);
|
|
} catch (ServiceException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (RemoteException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
/**
|
|
* 发票清单打印
|
|
* @return
|
|
*/
|
|
public String invoice_qdpr(){
|
|
String requestParam="";
|
|
String responseParam="";
|
|
String SID = "Invoice_qdpr";
|
|
try {
|
|
IAutokpserviceLocator kpl = new IAutokpserviceLocator();
|
|
IAutokp autoKP = kpl.getIAutokpPort();
|
|
responseParam = autoKP.invoice_qdpr(requestParam);
|
|
} catch (ServiceException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (RemoteException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|