凭证相关
This commit is contained in:
parent
eff25c1b16
commit
3aa2640029
@ -361,6 +361,7 @@ public class CreateVoucherServiceImpl {
|
||||
String LEAS_FORM = param.get("LEAS_FORM");
|
||||
// »ñÈ¡µ±Ç°Æ¾Ö¤½è´ûÐòºÅ
|
||||
String SORT_NUMBER = bo.getAttribute("SORT_NUMBER").getString();
|
||||
subData.put("SORT_NUMBER", "SORT_NUMBER");
|
||||
// Ö±×â¼Ç¼Ӷ½ð
|
||||
if("PZ2018082000000141".equals(VOUCHERNO)) {
|
||||
if("01".equals(LEAS_FORM)) {
|
||||
|
||||
244
src_core/com/tenwa/voucher/serviceImp/ExprotVoucherToXML.java
Normal file
244
src_core/com/tenwa/voucher/serviceImp/ExprotVoucherToXML.java
Normal file
@ -0,0 +1,244 @@
|
||||
package com.tenwa.voucher.serviceImp;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
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.ARE;
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.jbo.JBOTransaction;
|
||||
import com.amarsoft.are.log.Log;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||||
import com.tenwa.util.SerialNumberUtil;
|
||||
|
||||
import jbo.com.tenwa.entity.comm.own.OWN_INFO;
|
||||
|
||||
public class ExprotVoucherToXML {
|
||||
private static Log logger = ARE.getLog();
|
||||
// 方法页面传入参数
|
||||
public String ids;
|
||||
public String getIds() {
|
||||
return ids;
|
||||
}
|
||||
public void setIds(String ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
/**
|
||||
* 调用生成xml的方法
|
||||
*/
|
||||
public String ExprotVoucher(JBOTransaction tx){
|
||||
// 创建事物
|
||||
Transaction Sqlca = null;
|
||||
// 定义全局F3
|
||||
String f3="";
|
||||
try {
|
||||
Sqlca = Transaction.createTransaction(tx);
|
||||
System.out.println(ids);
|
||||
String year_month_day = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
||||
/**
|
||||
* 定义全局变量
|
||||
*/
|
||||
String batch = SerialNumberUtil.getVoucherPCNumber(Sqlca);// 获取批次号
|
||||
Map<String, String> map = new HashMap<String, String>(); // 参数map
|
||||
// 创建Document对象
|
||||
Document document = DocumentHelper.createDocument();
|
||||
// 设置xml头
|
||||
Element root = document.addElement("ufinterface"); // 设置xml头
|
||||
root.addAttribute("billtype", "gl"); // 设置xml头属性
|
||||
root.addAttribute("codeexchanged", "y");
|
||||
root.addAttribute("docid", "989898989898");
|
||||
root.addAttribute("proc", "add");
|
||||
root.addAttribute("receiver", "2000");
|
||||
root.addAttribute("roottag", "voucher");
|
||||
root.addAttribute("sender", "1278");
|
||||
String[] idArr = ids.split("_");
|
||||
for (String F3 : idArr) {
|
||||
f3=F3;
|
||||
// 设置参数
|
||||
map.clear();
|
||||
map.put("F3",F3);
|
||||
// 获取v8表数据
|
||||
String sql1 = "SELECT ID,F5,F6,F49,F51,F52,F59,F63,F64,F73,F74,F75,F76 FROM VOUCHER_V8 WHERE F3=:F3 ORDER BY F59 ";
|
||||
List<Map<String, String>> v1 = DataOperatorUtil.getDataBySql(Sqlca,sql1,map);
|
||||
String ownId = v1.get(0).get("F49");
|
||||
// 获取本方信息
|
||||
BizObject own = JBOFactory.createBizObjectQuery(OWN_INFO.CLASS_NAME, "id=:ownId").setParameter("ownId", ownId).getSingleResult(false);
|
||||
// 单条凭证头
|
||||
Element voucher = root.addElement("voucher");
|
||||
voucher.addAttribute("id", batch);
|
||||
Element voucherHead = voucher.addElement("voucher_head");
|
||||
Element company = voucherHead.addElement("company");// 本方公司名称
|
||||
company.setText(own.getAttribute("OWN_NAME").getString());
|
||||
Element voucher_type = voucherHead.addElement("voucher_type");
|
||||
voucher_type.setText("收款凭证");
|
||||
Element fiscal_year = voucherHead.addElement("fiscal_year");
|
||||
fiscal_year.setText(v1.get(0).get("F51"));
|
||||
Element accounting_period = voucherHead.addElement("accounting_period");
|
||||
accounting_period.setText(v1.get(0).get("F52"));
|
||||
Element voucher_id = voucherHead.addElement("voucher_id");
|
||||
voucher_id.setText("");
|
||||
Element attachment_number = voucherHead.addElement("attachment_number");
|
||||
attachment_number.setText("");
|
||||
Element date = voucherHead.addElement("date");
|
||||
date.setText("");
|
||||
Element enter = voucherHead.addElement("enter");
|
||||
enter.setText("");
|
||||
Element cashier = voucherHead.addElement("cashier");
|
||||
cashier.setText("");
|
||||
Element signature = voucherHead.addElement("signature");
|
||||
signature.setText("");
|
||||
Element checker = voucherHead.addElement("checker");
|
||||
checker.setText("");
|
||||
Element posting_date = voucherHead.addElement("posting_date");
|
||||
posting_date.setText("");
|
||||
Element posting_person = voucherHead.addElement("posting_person");
|
||||
posting_person.setText("");
|
||||
Element voucher_making_system = voucherHead.addElement("voucher_making_system");
|
||||
voucher_making_system.setText("");
|
||||
Element memo1 = voucherHead.addElement("memo1");
|
||||
memo1.setText("");
|
||||
Element memo2 = voucherHead.addElement("memo2");
|
||||
memo2.setText("");
|
||||
Element reserve1 = voucherHead.addElement("reserve1");
|
||||
reserve1.setText("");
|
||||
Element reserve2 = voucherHead.addElement("reserve2");
|
||||
reserve2.setText("");
|
||||
Element revokeflag = voucherHead.addElement("revokeflag");
|
||||
revokeflag.setText("");
|
||||
Element voucher_body = voucher.addElement("voucher_body");
|
||||
// 借贷配置信息
|
||||
for (Map<String, String> v8 : v1) {
|
||||
Element entry = voucher_body.addElement("entry");
|
||||
Element entry_id = entry.addElement("entry_id");
|
||||
entry_id.setText(v8.get("F59"));
|
||||
Element account_code = entry.addElement("account_code");
|
||||
account_code.setText("");
|
||||
Element abstract1 = entry.addElement("abstract");
|
||||
abstract1.setText(v8.get("F5"));
|
||||
Element settlement = entry.addElement("settlement");
|
||||
settlement.setText("");
|
||||
Element document_id = entry.addElement("document_id");
|
||||
document_id.setText("");
|
||||
Element document_date = entry.addElement("document_date");
|
||||
document_date.setText("");
|
||||
Element currency = entry.addElement("currency");
|
||||
currency.setText("人民币");
|
||||
Element unit_price = entry.addElement("unit_price");
|
||||
unit_price.setText("");
|
||||
Element exchange_rate1 = entry.addElement("exchange_rate1");
|
||||
exchange_rate1.setText("");
|
||||
Element exchange_rate2 = entry.addElement("exchange_rate2");
|
||||
exchange_rate2.setText("");
|
||||
Element debit_quantity = entry.addElement("debit_quantity");
|
||||
debit_quantity.setText("");
|
||||
Element primary_debit_amount = entry.addElement("primary_debit_amount");
|
||||
primary_debit_amount.setText("");
|
||||
Element secondary_debit_amount = entry.addElement("secondary_debit_amount");
|
||||
secondary_debit_amount.setText("");
|
||||
Element natural_debit_currency = entry.addElement("natural_debit_currency");
|
||||
natural_debit_currency.setText("");
|
||||
Element credit_quantity = entry.addElement("credit_quantity");
|
||||
credit_quantity.setText("");
|
||||
Element primary_credit_amount = entry.addElement("primary_credit_amount");
|
||||
primary_credit_amount.setText("");
|
||||
Element secondary_credit_amount = entry.addElement("secondary_credit_amount");
|
||||
secondary_credit_amount.setText("");
|
||||
Element natural_credit_currency = entry.addElement("natural_credit_currency");
|
||||
natural_credit_currency.setText("");
|
||||
Element bill_type = entry.addElement("bill_type");
|
||||
bill_type.setText("");
|
||||
Element bill_id = entry.addElement("bill_id");
|
||||
bill_id.setText("");
|
||||
Element bill_date = entry.addElement("bill_date");
|
||||
bill_date.setText("");
|
||||
Element auxiliary_accounting = entry.addElement("auxiliary_accounting");
|
||||
/**
|
||||
* 获取辅助账信息
|
||||
*/
|
||||
String AUXILIARYSQL = "SELECT LAA.AUX_NAME FROM LV_STACTS_CONFIG LSC LEFT JOIN LV_AUXILIARY_ACCOUNT LAA ON LSC.AUXILIARY_TYPE LIKE CONCAT('%',LAA.ID,'%') WHERE LSC.ID=:ID ";
|
||||
map.clear(); map.put("ID", v8.get("F6"));
|
||||
List<Map<String, String>> A1 = DataOperatorUtil.getDataBySql(Sqlca,AUXILIARYSQL,map);
|
||||
for (Map<String, String> fuzhu : A1) {
|
||||
// 后期调整, 辅助账名称变更好需要更改此处代码***
|
||||
if("融资租赁资产辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F64"));
|
||||
}
|
||||
if("部门辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F63"));
|
||||
}
|
||||
if("融资租赁收入类型辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F73"));
|
||||
}
|
||||
if("资金类型辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F74"));
|
||||
}
|
||||
if("主营类型辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F75"));
|
||||
}
|
||||
if("银行账户辅助核算".equals(fuzhu.get("AUX_NAME"))) {
|
||||
Element item = auxiliary_accounting.addElement("item");
|
||||
item.addAttribute("name", fuzhu.get("AUX_NAME"));
|
||||
item.setText(v8.get("F76"));
|
||||
}
|
||||
}
|
||||
Element detail = entry.addElement("detail");
|
||||
detail.setText("");
|
||||
}
|
||||
// 更改导出状态为已导出
|
||||
String updSql="UPDATE VOUCHER_V8 SET V8_FLAG='1' WHERE F3='"+F3+"' ";
|
||||
Sqlca.executeSQL(updSql);
|
||||
Sqlca.commit();
|
||||
logger.info("导出成功-凭证编号: "+F3);
|
||||
}
|
||||
String URL="D:\\voucherXml_NC\\APleasing_VOUCHER_"+year_month_day+".xml";
|
||||
File file = new File(URL);
|
||||
XMLWriter writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
|
||||
writer.setEscapeText(false);// 字符是否转义,默认true
|
||||
writer.write(document);
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
String updSql="UPDATE VOUCHER_V8 SET V8_FLAG='-1' WHERE F3='"+f3+"' ";
|
||||
Sqlca.executeSQL(updSql);
|
||||
Sqlca.commit();
|
||||
} catch (Exception e2) {
|
||||
logger.debug("导出失败-凭证编号: "+f3);
|
||||
e2.printStackTrace();
|
||||
}
|
||||
logger.info("生成失败");
|
||||
e.printStackTrace();
|
||||
return "false";
|
||||
}finally {
|
||||
if(Sqlca!=null) {
|
||||
try {
|
||||
Sqlca.disConnect();
|
||||
} catch (JBOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "true";
|
||||
}
|
||||
|
||||
}
|
||||
@ -124,7 +124,7 @@ public class VoucherToV8Impl implements VoucherService {
|
||||
d.put("F52", list.get(i).get("F1").substring(5,7));//会计期间-月
|
||||
}
|
||||
d.put("F12", user.getAttribute("username").getString());//制单人
|
||||
d.put("F59", i+1+"");
|
||||
d.put("F59", list.get(i).get("SORT_NUMBER"));
|
||||
d.put("F62",list.get(i).get("F6"));
|
||||
|
||||
d.put("F60",list.get(i).get("CONTRACT_NUMBER"));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user