手动和定时拉取sap应付凭证常量字段优化
This commit is contained in:
parent
8b2641ba38
commit
aab997b901
|
|
@ -362,6 +362,22 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
Map<String, String> asstactTypeMap = new HashMap<>();
|
||||
asstactTypeMap.put("供应商", "bd_supplier");
|
||||
asstactTypeMap.put("客户", "bd_customer");
|
||||
//币别常量
|
||||
String[][] currencyInfo = {
|
||||
{"paycurrency", "付款币别"},
|
||||
{"settlecurrency", "结算币别"}
|
||||
};
|
||||
DynamicObject paytype_g = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE,
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "JH001")});//对公
|
||||
DynamicObject paytype_s = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE,
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "JH002")});//对私
|
||||
//单据类型
|
||||
DynamicObject billtype = BusinessDataServiceHelper.loadSingle(BOS_BILLTYPE,
|
||||
new QFilter[]{new QFilter("name", QCP.equals, "其他付款申请")});
|
||||
|
||||
//汇率表
|
||||
DynamicObject exrate = BusinessDataServiceHelper.loadSingle(BD_EXRATETABLE,
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "ERT-01")});
|
||||
|
||||
for (int selectRow : selectRows) {
|
||||
String fkBillNum = (String) this.getModel().getValue("shjh_vouchernumber", selectRow);//凭证号
|
||||
|
|
@ -492,10 +508,7 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
//币别
|
||||
String paymentcurrency = (String) this.getModel().getValue("shjh_paymentcurrency", selectRow);//付款币别编号
|
||||
String settlementcurrency = (String) this.getModel().getValue("shjh_settlementcurrency", selectRow);//结算币别编号
|
||||
String[][] currencyInfo = {
|
||||
{"paycurrency", "付款币别"},
|
||||
{"settlecurrency", "结算币别"}
|
||||
};
|
||||
|
||||
for (String[] info : currencyInfo) {
|
||||
String currencyType = info[0];
|
||||
String currencyTypeName = info[1];
|
||||
|
|
@ -650,17 +663,9 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
|
||||
//付款类型:取值范围:对公付款、对私付款;SAP:科目编号1221020200 对私付款。费控:劳务人员报销单 对私付款。其他均赋值为对公付款。
|
||||
if ("1221020200".equals(accountingsubject)) {
|
||||
QFilter Q9 = new QFilter("name", QCP.equals, "对私付款");
|
||||
DynamicObject paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{Q9});
|
||||
if (null != paytype) {
|
||||
ap_payapply_entry.set("e_paymenttype", paytype);
|
||||
}
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_s);//对私付款
|
||||
} else {
|
||||
QFilter Q9 = new QFilter("name", QCP.equals, "对公付款");
|
||||
DynamicObject paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{Q9});
|
||||
if (null != paytype) {
|
||||
ap_payapply_entry.set("e_paymenttype", paytype);
|
||||
}
|
||||
ap_payapply_entry.set("e_paymenttype", paytype_g);//对公付款
|
||||
}
|
||||
|
||||
//部门
|
||||
|
|
@ -674,18 +679,10 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
---------------------------------------------------默认字段----------------------------------------------------
|
||||
*/
|
||||
//单据类型
|
||||
QFilter Q8 = new QFilter("name", QCP.equals, "其他付款申请");
|
||||
DynamicObject billtype = BusinessDataServiceHelper.loadSingle(BOS_BILLTYPE, new QFilter[]{Q8});
|
||||
if (null != billtype) {
|
||||
ap_payapply.set("billtype", billtype);
|
||||
}
|
||||
ap_payapply.set("billtype", billtype);
|
||||
|
||||
//汇率表
|
||||
QFilter Q10 = new QFilter("number", QCP.equals, "ERT-01");
|
||||
DynamicObject exrate = BusinessDataServiceHelper.loadSingle(BD_EXRATETABLE, new QFilter[]{Q10});
|
||||
if (null != exrate) {
|
||||
ap_payapply.set("exratetable", exrate);
|
||||
}
|
||||
ap_payapply.set("exratetable", exrate);
|
||||
ap_payapply.set("billstatus", "A");//状态:暂存
|
||||
|
||||
//select * from t_ap_applypaybill where fid = 2148014743875508224 or fid = 2148018902158815232
|
||||
|
|
@ -752,10 +749,7 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
//单据号
|
||||
String uuid = (String) this.getModel().getValue("shjh_uuid", selectRow);
|
||||
ap_payapply.set("shjh_fkdjbh",uuid);//单据号
|
||||
QFilter qq1 = new QFilter("number", QCP.equals, "JH001");//对公
|
||||
QFilter qq2 = new QFilter("number", QCP.equals, "JH002");//对私
|
||||
DynamicObject paytype_g = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{qq1});
|
||||
DynamicObject paytype_s = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{qq2});
|
||||
|
||||
//付款类型 外部系统单据类型
|
||||
if (uuid.contains("JKY")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","A");//员工借款单
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import java.util.Map;
|
|||
|
||||
import static shjh.jhzj7.fi.fi.plugin.form.SappzFormPlugin.*;
|
||||
import static shjh.jhzj7.fi.fi.utils.SapUtils.vouchers_payable;
|
||||
import static shjh.jhzj7.fi.fi.webapi.ApplyAdjustBillControler.setPaymentType;
|
||||
import static shjh.jhzj7.fi.fi.webapi.ApplyBillControler.*;
|
||||
|
||||
/**
|
||||
|
|
@ -133,6 +132,20 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
{"paycurrency", "付款币别"},
|
||||
{"settlecurrency", "结算币别"}
|
||||
};
|
||||
//常量字段处理
|
||||
DynamicObject ds_paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE,
|
||||
new QFilter[]{new QFilter("name", QCP.equals, "对私付款")});
|
||||
DynamicObject dg_paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE,
|
||||
new QFilter[]{new QFilter("name", QCP.equals, "对公付款")});
|
||||
DynamicObject default_settletype = BusinessDataServiceHelper.loadSingle("bd_settlementtype",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "T")});//银企直连
|
||||
//单据类型
|
||||
DynamicObject billtype = BusinessDataServiceHelper.loadSingle(BOS_BILLTYPE,
|
||||
new QFilter[]{new QFilter("name", QCP.equals, "其他付款申请")});
|
||||
//汇率表
|
||||
DynamicObject exrate = BusinessDataServiceHelper.loadSingle(BD_EXRATETABLE,
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "ERT-01")});
|
||||
|
||||
for (Object itItem : IT_ITEMs) {
|
||||
it_list = (JSONObject) itItem;
|
||||
String bukrs = it_list.getString("BUKRS");//公司编号
|
||||
|
|
@ -233,10 +246,10 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
if (null != ap_payapplys) {
|
||||
boolean shjhSapwhetherlocking = ap_payapplys.getBoolean("shjh_sapwhetherlocking");//SAP是否锁定
|
||||
if (shjhSapwhetherlocking) {
|
||||
logger.error("同步失败,凭证号:" + fkBillNum + "的费控单据已锁定");
|
||||
logger.error("同步失败,凭证号:" + fkBillNum + "的单据SAP已锁定");
|
||||
continue;
|
||||
} else {
|
||||
//todo:存在且单据中SAP锁定状态为未锁定,更新数据
|
||||
//存在付款申请单且单据中SAP锁定状态为未锁定,更新数据
|
||||
ap_payapply = ap_payapplys;
|
||||
}
|
||||
}
|
||||
|
|
@ -271,9 +284,7 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
JhzjUtils.saveLog(fkBillNum, apimenthod, it_list.toJSONString(), "同步失败,SAP会计科目为空", false, "API");
|
||||
continue;
|
||||
}
|
||||
|
||||
//请款事由
|
||||
ap_payapply.set("applycause", "");
|
||||
ap_payapply.set("applycause", "");//请款事由
|
||||
|
||||
//币别-处理
|
||||
for (String[] info : currencyInfo) {
|
||||
|
|
@ -391,7 +402,6 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
// return null;
|
||||
}
|
||||
}
|
||||
|
||||
//到期日
|
||||
ap_payapply_entry.set("e_duedate", FAEDTs);
|
||||
//分录申请金额
|
||||
|
|
@ -400,42 +410,18 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
ap_payapply_entry.set("e_appseleamount", dmbtr);
|
||||
//表头申请金额
|
||||
ap_payapply.set("applyamount", amount);
|
||||
|
||||
//凭证抬头文本
|
||||
String shjh_bktxt = it_list.getString("BKTXT");
|
||||
ap_payapply.set("shjh_voucherheadertext", shjh_bktxt);
|
||||
ap_payapply.set("shjh_voucherheadertext", it_list.getString("BKTXT"));
|
||||
|
||||
//付款类型:取值范围:对公付款、对私付款;SAP:科目编号1221020200 对私付款。费控:劳务人员报销单 对私付款。其他均赋值为对公付款。
|
||||
//付款类型:对公付款、对私付款;SAP:科目编号1221020200 对私付款。费控:劳务人员报销单 对私付款。其他均赋值为对公付款。
|
||||
if ("1221020200".equals(accountingsubject)) {
|
||||
QFilter Q9 = new QFilter("name", QCP.equals, "对私付款");
|
||||
DynamicObject paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{Q9});
|
||||
if (null != paytype) {
|
||||
ap_payapply_entry.set("e_paymenttype", paytype);
|
||||
}
|
||||
ap_payapply_entry.set("e_paymenttype", ds_paytype);//对私付款
|
||||
} else {
|
||||
QFilter Q9 = new QFilter("name", QCP.equals, "对公付款");
|
||||
DynamicObject paytype = BusinessDataServiceHelper.loadSingle(CAS_PAYMENTBILLTYPE, new QFilter[]{Q9});
|
||||
if (null != paytype) {
|
||||
ap_payapply_entry.set("e_paymenttype", paytype);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
---------------------------------------------------默认字段----------------------------------------------------
|
||||
*/
|
||||
//单据类型
|
||||
QFilter Q8 = new QFilter("name", QCP.equals, "其他付款申请");
|
||||
DynamicObject billtype = BusinessDataServiceHelper.loadSingle(BOS_BILLTYPE, new QFilter[]{Q8});
|
||||
if (null != billtype) {
|
||||
ap_payapply.set("billtype", billtype);
|
||||
}
|
||||
|
||||
//汇率表
|
||||
QFilter Q10 = new QFilter("number", QCP.equals, "ERT-01");
|
||||
DynamicObject exrate = BusinessDataServiceHelper.loadSingle(BD_EXRATETABLE, new QFilter[]{Q10});
|
||||
if (null != exrate) {
|
||||
ap_payapply.set("exratetable", exrate);
|
||||
ap_payapply_entry.set("e_paymenttype", dg_paytype);//对公付款
|
||||
}
|
||||
//------------------------------默认字段--------------------------------
|
||||
ap_payapply.set("billtype", billtype);//单据类型
|
||||
ap_payapply.set("exratetable", exrate);//汇率表
|
||||
ap_payapply.set("billstatus", "A");//状态:暂存
|
||||
|
||||
//select * from t_ap_applypaybill where fid = 2148014743875508224 or fid = 2148018902158815232
|
||||
|
|
@ -493,11 +479,8 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
ap_payapply.set("shjh_bookkeepingdate", BUDATs);
|
||||
//凭证日期
|
||||
ap_payapply.set("shjh_documentdate", BLDATs);
|
||||
//结算方式
|
||||
DynamicObject settlementtypes = BusinessDataServiceHelper.loadSingle("bd_settlementtype",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, "T")});//银企直连
|
||||
// 标记是否设置了结算方式
|
||||
boolean isSettlementSet = false;
|
||||
//结算方式-先设置一个默认值 银企直连,然后根据供应商分录判断重新赋值
|
||||
ap_payapply_entry.set("e_settlementtype", default_settletype);
|
||||
|
||||
if ("供应商".equals(shjh_payee)) {
|
||||
DynamicObjectCollection shjhEntrySap = party.getDynamicObjectCollection("shjh_entry_sap");
|
||||
|
|
@ -509,17 +492,12 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
new QFilter[]{new QFilter("number", QCP.equals, object.getString("shjh_settlementmethod"))});
|
||||
if (settlementtype != null) {
|
||||
ap_payapply_entry.set("e_settlementtype", settlementtype);
|
||||
isSettlementSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果未设置结算方式,则使用默认的银企直连
|
||||
if (!isSettlementSet) {
|
||||
ap_payapply_entry.set("e_settlementtype", settlementtypes);
|
||||
}
|
||||
String uuid = it_list.getString("XBLNR");//单据号
|
||||
ap_payapply.set("shjh_fkdjbh", uuid);
|
||||
String bizbig = it_list.getString("ZYWDLCODE");//业务大类编
|
||||
|
|
@ -533,23 +511,24 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("shjh_bizsmalltype", new QFilter[]{new QFilter("shjh_fknumber", QCP.equals, bizsmall)});
|
||||
ap_payapply.set("shjh_basedatafield", dynamicObject);
|
||||
}
|
||||
String department = it_list.getString("ZREQ_DEPT");
|
||||
QFilter q8 = new QFilter("number", QCP.equals, department);
|
||||
DynamicObject adminorg = BusinessDataServiceHelper.loadSingle("bos_adminorg", new QFilter[]{q8});
|
||||
if (null != adminorg) {
|
||||
String department = it_list.getString("ZREQ_DEPT");//部门编号
|
||||
if (kd.bos.util.StringUtils.isNotEmpty(department)) {
|
||||
DynamicObject adminorg = BusinessDataServiceHelper.loadSingle("bos_adminorg",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, department)});
|
||||
ap_payapply.set("shjh_secondarydept", adminorg);
|
||||
}
|
||||
|
||||
// 设置付款类型 //付款类型 外部系统单据类型
|
||||
setPaymentType(ap_payapply, uuid);
|
||||
// 设置付款类型 外部系统单据类型
|
||||
setPaymentType(ap_payapply, uuid, dg_paytype, ds_paytype);
|
||||
|
||||
//凭证类型
|
||||
String blart = it_list.getString("BLART");
|
||||
DynamicObject vouchertype = BusinessDataServiceHelper.loadSingle("gl_vouchertype",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, blart)});
|
||||
if (null != vouchertype) {
|
||||
if (kd.bos.util.StringUtils.isNotEmpty(blart)) {
|
||||
DynamicObject vouchertype = BusinessDataServiceHelper.loadSingle("gl_vouchertype",
|
||||
new QFilter[]{new QFilter("number", QCP.equals, blart)});
|
||||
ap_payapply.set("shjh_documenttype", vouchertype);//凭证类型
|
||||
}
|
||||
|
||||
//基准日期
|
||||
ap_payapply.set("shjh_basedate", ZFBDTs);
|
||||
//付款条件
|
||||
|
|
@ -569,4 +548,66 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
}
|
||||
return bills;
|
||||
}
|
||||
|
||||
private void setPaymentType(DynamicObject ap_payapply, String uuid, DynamicObject paytype_g, DynamicObject paytype_s){
|
||||
//根据单据号 uuid 判断
|
||||
DynamicObjectCollection entry = ap_payapply.getDynamicObjectCollection("entry");
|
||||
//付款类型 外部系统单据类型
|
||||
if (uuid.contains("JKY")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","A");//员工借款单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_s);//对私
|
||||
}
|
||||
}else if (uuid.contains("TYB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","B");//通用报销单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_s);//对私
|
||||
}
|
||||
}else if (uuid.contains("CLB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","C");//差旅报销单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_s);//对私
|
||||
}
|
||||
}else if (uuid.contains("LWB")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","D");//劳务人员报销单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_s);//对私
|
||||
}
|
||||
}else if (uuid.contains("YFK")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","E");//预付款单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公
|
||||
}
|
||||
}else if (uuid.contains("JCW")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","F");//请款单无订单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公
|
||||
}
|
||||
}else if (uuid.contains("FWK")) { //服务付款单
|
||||
ap_payapply.set("shjh_externalsystemdocume","G");
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公
|
||||
}
|
||||
}else if (uuid.contains("TFK")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","I");//其他付款单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公
|
||||
}
|
||||
}else if (uuid.contains("SPA")) {
|
||||
ap_payapply.set("shjh_externalsystemdocume","J");//SPA会员退卡申请单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公
|
||||
}
|
||||
}else if (uuid.contains("JCH")) {
|
||||
// ap_payapply.set("shjh_externalsystemdocume","JC");//TPM_请款单
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_g);//对公JKY0000001
|
||||
}
|
||||
}else if (uuid.contains("TYH")) { //TPM_通用报销单
|
||||
// ap_payapply.set("shjh_externalsystemdocume","TY");
|
||||
if (!entry.isEmpty()) {
|
||||
entry.get(0).set("e_paymenttype", paytype_s);//对私
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue