凭证佣金分录变更

This commit is contained in:
xiezhiwen 2018-09-14 16:13:42 +08:00
parent 2ccdd08b0b
commit 6181b5e181
5 changed files with 100 additions and 71 deletions

View File

@ -62,7 +62,6 @@ public String CreateVoucher(String FlowUnid,String VOUCHERNO) throws Exception {
}
param.clear();
map.put("FLOWUNID", FlowUnid);
System.out.println();
List<Map<String,String>> dataList=DataOperatorUtil.getDataBySql(Sqlca, sql, map);
CreateVoucherServiceImpl vs=new CreateVoucherServiceImpl();

View File

@ -128,7 +128,6 @@ public String CreateVoucher(String FlowUnid,String VOUCHERNO) throws Exception {
param.put("CUSTID",DISTRIBUTOR_ID);
param.put("CUSTNAME",DISTRIBUTOR_NAME);
param.put("CUSTOMERTYPE",CUSTOMERTYPE);
param.put("BUSINESSTYPE",BUSINESSTYPE);
if("1".equals(BUSINESSTYPE)){
param.put("LEASFORMASSET", "04"); // ÈÚ×Ê×âÁÞ×ʲú
@ -139,9 +138,6 @@ public String CreateVoucher(String FlowUnid,String VOUCHERNO) throws Exception {
param.put("LEASINCOMEFORM", "01"); // BË
}
}
//param.put("FUNDTYPE", ""); // Ö÷ÓªÀàÐÍ
param.put("BUSINESSTYPE", "06");
param.put("FlowUnid", FlowUnid);
map.clear();
map.put("PROJ_TYPE", leas_form);

View File

@ -9,13 +9,13 @@ import com.tenwa.voucher.service.VoucherJavaParamService;
public class auxiliaryBusinessType implements VoucherJavaParamService {
@Override
public Map<String, String> getJavaParam(JBOTransaction tx,
Map<String, String> param) throws BusinessException {
Map<String,String>returnValue=new HashMap<String,String>();
String PLAN_LIST=param.get("PLAN_LIST");
returnValue.put("PLAN_LIST",PLAN_LIST);
return returnValue;
}
@Override
public Map<String, String> getJavaParam(JBOTransaction tx,Map<String, String> param) throws BusinessException {
Map<String,String>returnValue=new HashMap<String,String>();
String PLAN_LIST=param.get("PLAN_LIST");
String BUSINESSTYPE=param.get("BUSINESSTYPE");
returnValue.put("PLAN_LIST",PLAN_LIST);
returnValue.put("BUSINESSTYPE",BUSINESSTYPE);
return returnValue;
}
}

View File

@ -21,6 +21,7 @@ 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.lang.DataElement;
import com.amarsoft.are.log.Log;
import com.amarsoft.awe.Configure;
import com.tenwa.comm.exception.BusinessException;
@ -293,6 +294,12 @@ public class CreateVoucherServiceImpl {
subData.put("F6",sub.getAttribute("id").getString());//科目编码
subData.put("F1",dataTemp.get("ACCOUNT_DATE"));//会计处理日
String VOUCHERNO = param.get("VOUCHERNO");
String sort = bo.getAttribute("SORT_NUMBER").getString();
if("1".equals(sort)) {
param.put("BUSINESSTYPE", "9201");
}else if("2".equals(sort)) {
param.put("BUSINESSTYPE", "92");
}
if("1".equals(bo.getAttribute("LOAN_DIRECTION").getString())){//借贷方向
subData.put("F7", dataTemp.get("MONEY"));//借方金额
subData.put("F8", "0");//贷方金额

View File

@ -15,6 +15,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
@ -56,10 +58,15 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Transaction Sqlca = null;
Sqlca = Transaction.createTransaction(tx);
Map<String, String> map = new HashMap<String, String>();
// 获取vi_voucher_v8视图中的数据
List<Map<String, String>> list= getDataList(Sqlca);// 获取所有凭证编号
// 生成凭证信息xml文件
DOM4JcreateToVoucher(Sqlca,list,map);
// 生成客户信息xml文件
DOM4JcreateToCustomer(Sqlca);
// 生成经销商信息xml文件
DOM4JcreateToSupplier(Sqlca);
// 生成辅助合同信息xml文件
DOM4JcreateToDefdoc(Sqlca,list,map);
tx.commit();
} catch (Exception e) {
@ -82,8 +89,6 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
}
/**
* 获取数据库凭证信息表所有的待传F3凭证编号
* @param tx
* @return
* @throws Exception
*/
private static List<Map<String, String>> getDataList(JBOTransaction tx) throws Exception{
@ -97,29 +102,34 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
* @throws Exception
*/
private static void DOM4JcreateToVoucher(Transaction Sqlca,List<Map<String, String>>list, Map<String, String> map) throws Exception {
// 本地xml存放文件夹, 没有就创建
File file2 = new File("D:\\voucherXml_NC");
if (!file2.exists()) {
file2.mkdirs();
}
Document document=null;
File file=null;
XMLWriter writer=null;
String SUBJECT_ID=null;
String OWNED_COMPANY = null;
String ACC_YEAR = null;
String ACC_MONTH = null;
String VOUCHING_PERSON = null;
Date time = new Date(); // 获取当前时间对象, 并格式化
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
String year_month_day = formatter1.format(time); // 年月日
String timeAll = "";
int a = list.size(); // 获取凭证编号的长度
int b=1000; // 设置当前xml生成的条数
int c = (int)(a / b); // 获取循环次数, 最大循环值=c+1
for (int i = 0; i <=c; i++) { // 外围循环/ 决定生成几个xml
document = DocumentHelper.createDocument(); // 生成每个xml的头
Element root = document.addElement("ufinterface");
root.addAttribute("account", "0001");
if (!file2.exists()) {file2.mkdirs();}// 判断是否存在, 如果不存在就创建该文件夹
// 定义全局对象
Document document=null; // xml文件头
File file=null; // 生成的xml文件路径
XMLWriter writer=null; // 输出对象
String str=""; // xml主键id
String SUBJECT_ID=null; // 获取科目id
String OWNED_COMPANY = null; // 所属公司
String ACC_YEAR = null; // 会计期间/
String ACC_MONTH = null; // 会计期间/
String tableName="VOUCHER_V8"; // 表名
String flag="V8_FLAG"; // 状态名
String xmlId=""; // xml的id字段名
String updSql=""; // 定义更新语句对象
SqlObject sql; // sqlObject对象
Date time = new Date(); // 获取当前时间对象, 并格式化
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");// 年月日时分秒
String year_month_day = formatter1.format(time); // 年月日时分秒
String timeAll = ""; // 制单日期
int a = list.size(); // v8视图总数据量/ xml中生成的总条数
int b=1000; // 设置当前xml生成的条数
int c = (int)(a / b); // 获取生成xml文件的数量, 最大循环值=c+1
for (int i = 0; i <=c; i++) {
document = DocumentHelper.createDocument(); // 创建Document对象
Element root = document.addElement("ufinterface"); // 设置xml头
root.addAttribute("account", "0001"); // 设置xml头属性
root.addAttribute("billtype", "vouchergl");
root.addAttribute("businessunitcode", "develop");
root.addAttribute("filename", "");
@ -130,7 +140,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
root.addAttribute("replace", "Y");
root.addAttribute("roottag", "");
root.addAttribute("sender", "001");
for (int x = i * b; x < (i + 1) * b && x < a; x++) {// 决定当前xml生成的数据量
for (int x = i * b; x < (i + 1) * b && x < a; x++) { // 决定当前xml生成的数据量
// 获取凭证编号
String F3=list.get(x).get("F3");
map.clear();
@ -144,18 +154,17 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
// 获取v8表公共信息
for (Map<String, String> map2 : v2) {
OWNED_COMPANY=map2.get("f49");//本方id
ACC_YEAR = map2.get("f51");// 会计期间/
ACC_MONTH =map2.get("f52");// 会计期间/
VOUCHING_PERSON =map2.get("f12");// 制单人
timeAll =map2.get("f15");// 制单时间
OWNED_COMPANY=map2.get("f49"); // 本方id
ACC_YEAR = map2.get("f51"); // 会计期间/
ACC_MONTH =map2.get("f52"); // 会计期间/
timeAll =map2.get("f15"); // 制单时间
}
BizObject own = JBOFactory.createBizObjectQuery(OWN_INFO.CLASS_NAME, "id=:OWNED_COMPANY").setParameter("OWNED_COMPANY", OWNED_COMPANY).getSingleResult(false);
Element voucher = root.addElement("voucher");
Element voucherHead = voucher.addElement("voucher_head");
Element pkVoucher = voucherHead.addElement("pk_voucher");// 凭证主键/非空
//pkVoucher.setText(list.get(x).get("ID").toString());
pkVoucher.setText((x+1)+"凭证主键 如果没有那就是新增,有就是修改 可空");
str=UUID.randomUUID().toString().replace("-", "");
pkVoucher.setText(str);
Element pk_vouchertype = voucherHead.addElement("pk_vouchertype");// 凭证类别, 默认01/非空
pk_vouchertype.setText("1");//----------------------------------------------------------------------
Element year = voucherHead.addElement("year");// 会计年度/非空
@ -405,14 +414,18 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element pk_innercorp2 = cashflowitem2.addElement("pk_innercorp");// 内部单位主键,最大长度为64,类型为:String
pk_innercorp2.setText("");
}
// 执行update操作, 将生成的xml标签id存入v8表
/*updSql="UPDATE "+tableName+" SET xmlId='"+str+"' WHERE F3 ='"+F3+"' ";
sql = new SqlObject(updSql);
Sqlca.executeSQL(sql);*/
}
String URL="D:\\voucherXml_NC\\APleasing_VOUCHER_"+year_month_day+".xml";
String URL="data\\files\\apzl_leasing\\tmp\\XZW\\APleasing_VOUCHER_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
InterActionToNC(Sqlca,URL,tableName,flag,xmlId);
}
}
/**
@ -421,25 +434,28 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
* @throws Exception
*/
private static void DOM4JcreateToCustomer(Transaction Sqlca) throws Exception{
// 判断该文件夹是否存在, 如果不存在就创建
File file2 = new File("D:\\voucherXml_NC");
if(file2==null || "".equals(file2)) {
file2.mkdirs();//创建父文件夹
}
if(file2.exists()) {file2.mkdirs();}
// 定义全局对象
File file=null;
XMLWriter writer=null;
// 获取当前时间对象, 并格式化
Date time = new Date();
// 生成xml的路劲
File file=null;
// 输出对象
XMLWriter writer=null;
// 表名
String tableName="CUSTOMER_INFO";
// 状态字段
String flag="FLAG";
// xml传输id字段
String xmlId="";
// 获取时间对象, 格式为--年月日时分秒
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
// 年月日
String year_month_day = formatter1.format(time);
String cust_id="";
String updateSql="";
String year_month_day = formatter1.format(new Date());
String customer_num="";
String customername="";
String customertype="";
// 查询未传入客户信息
String sql="SELECT customer_num,customername,customertype,customerid FROM CUSTOMER_INFO WHERE (FLAG='' OR FLAG IS NULL)";
String sql="SELECT customer_num,customername,customertype,customerid FROM CUSTOMER_INFO WHERE FLAG <>'1' ";
List<Map<String, String>> rs = DataOperatorUtil.getDataBySql(Sqlca,sql,null);
// 客户xml头
Document document= DocumentHelper.createDocument(); // 生成每个xml的头
@ -715,13 +731,13 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
SqlObject updSql=new SqlObject(updateSql);
Sqlca.executeSQL(updSql);*/
}
String URL="D:\\voucherXml_NC\\APleasing_Customer_"+year_month_day+".xml";
String URL="data\\files\\apzl_leasing\\tmp\\XZW\\APleasing_Customer_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
InterActionToNC(Sqlca,URL,tableName,flag,xmlId);
}
/**
* 供应商信息xml生成, 每1000条生成一个xml
@ -735,6 +751,9 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
}
File file = null;
XMLWriter writer = null;
String tableName="DISTRIBUTOR_INFO";// 表名
String flag="FLAG"; // 状态名
String xmlId=""; // xml传输id
String DISTRIBUTOR_NAME = ""; // 经销商名称
String DISTRIBUTOR_CODING = ""; // 经销商id
String DISTRIBUTOR_ADDRESS=""; // 地区编码
@ -770,7 +789,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
root.addAttribute("replace", "Y");
root.addAttribute("roottag", "");
root.addAttribute("sender", "001");
String sql="SELECT DISTRIBUTOR_NAME,DISTRIBUTOR_CODING,DISTRIBUTOR_ADDRESS,FACT_ADDR,PROVINCES,POSTCODE,REGISTERED_ADDR,BUSINESS_SCOPE,SUBSIDIARY_COMPANY,TYPE,BUSINESS_LICENSE_NO,DISTRIBUTOR_STATUS,E_MAIL,FAX_NUMBER,REGISTERED_ASSET,DISTRIBUTORER,MBAFC_EARLYDISBURSEMENT_TYPE,URL,FLAG FROM DISTRIBUTOR_INFO WHERE (FLAG='' OR FLAG IS NULL)";
String sql="SELECT DISTRIBUTOR_NAME,DISTRIBUTOR_CODING,DISTRIBUTOR_ADDRESS,FACT_ADDR,PROVINCES,POSTCODE,REGISTERED_ADDR,BUSINESS_SCOPE,SUBSIDIARY_COMPANY,TYPE,BUSINESS_LICENSE_NO,DISTRIBUTOR_STATUS,E_MAIL,FAX_NUMBER,REGISTERED_ASSET,DISTRIBUTORER,MBAFC_EARLYDISBURSEMENT_TYPE,URL,FLAG FROM DISTRIBUTOR_INFO WHERE FLAG<>'1'";
List<Map<String, String>> rs = DataOperatorUtil.getDataBySql(Sqlca,sql,null);
for(int i=0; i<rs.size();i++) {
DISTRIBUTOR_NAME = rs.get(i).get("DISTRIBUTOR_NAME");
@ -919,19 +938,27 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
SqlObject updSql=new SqlObject(updateSql);
Sqlca.executeSQL(updSql);*/
}
String f="D:\\voucherXml_NC\\APleasing_Supplier_"+year_month_day+".xml";
//String f="D:\\voucherXml_NC\\APleasing_Supplier_"+year_month_day+".xml";
String f="data\\files\\apzl_leasing\\tmp\\XZW\\APleasing_Supplier_"+year_month_day+".xml";
file=new File(f);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,f);
InterActionToNC(Sqlca,f,tableName,flag,xmlId);
}
/**
* 辅助合同xml
* @throws Exception
*/
private static void DOM4JcreateToDefdoc(Transaction Sqlca,List<Map<String, String>>list, Map<String, String> map) throws Exception{
Document document=null;
File file=null;
XMLWriter writer=null;
String tableName="VOUCHER_V8";// 表名
String flag="V8_FLAG"; // 状态名
String xmlId=""; // xml传输id
Date time = new Date(); // 获取当前时间对象, 并格式化
File file2 = new File("D:\\voucherXml_NC");
if(file2==null || "".equals(file2)) {
@ -990,20 +1017,20 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
Element memo = billhead.addElement("memo");// 备注,最大长度为200,类型为:String
memo.setText("");
}
String URL="D:\\voucherXml_NC\\APleasing_Defdoc_"+year_month_day+".xml";
String URL="data\\files\\apzl_leasing\\tmp\\XZW\\APleasing_Defdoc_"+year_month_day+".xml";
file=new File(URL);
writer = new XMLWriter(new FileOutputStream(file), OutputFormat.createPrettyPrint());
writer.setEscapeText(false);// 字符是否转义,默认true
writer.write(document);
writer.close();
InterActionToNC(Sqlca,URL);
InterActionToNC(Sqlca,URL,tableName,flag,xmlId);
}
}
/**
* 像NC传输xml, 获取NC回执xml信息, 根据回执信息更改状态
*/
public static void InterActionToNC(Transaction Sqlca,String OutURL) {
public static void InterActionToNC(Transaction Sqlca,String inputURL,String tableName,String flag,String xmlId) {
try {
// 定义全局变量
String sql="";
@ -1022,7 +1049,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
/**
* 读取本地生成的xml, 传输到NC
*/
File file = new File(OutURL);
File file = new File(inputURL);
BufferedOutputStream out = new BufferedOutputStream(connection.getOutputStream());
BufferedInputStream input = new BufferedInputStream(new FileInputStream(file));
int length;
@ -1080,7 +1107,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
}else if(resSuc.equals("Y")){
System.out.println("导入成功");
//接下来的代码修改状态
sql="UPDATE 表名 set 字段 = '1' WHERE 状态字段 <> '1'";
sql="UPDATE tableName set flag = '1' WHERE flag <> '1'";
updSql = new SqlObject(sql);
Sqlca.executeSQL(updSql);
List<Element> list1 = root.elements();
@ -1090,7 +1117,7 @@ public class VoucherSysJointNCServiceImpl implements VoucherSysJointNCService {
resultcode = el.element("resultcode").getStringValue();
if(!"1".equals(resultcode)) {
bdocid = el.element("bdocid").getStringValue();
sql=" UPDATE 表名 SET 字段='"+resultcode+"' WHERE 标签id='"+bdocid+"' ";
sql=" UPDATE tableName SET flag='"+resultcode+"' WHERE xmlId='"+bdocid+"' ";
updSql = new SqlObject(sql);
Sqlca.executeSQL(updSql);
}