手动和定时拉取sap应付凭证日志优化
This commit is contained in:
parent
d371af4a52
commit
3371a1522e
|
|
@ -358,6 +358,11 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
} else {
|
||||
// List<DynamicObject> bills = new ArrayList<>();
|
||||
Map<String, DynamicObject> bills = new HashMap<>();
|
||||
// 定义往来类型和对应值的映射
|
||||
Map<String, String> asstactTypeMap = new HashMap<>();
|
||||
asstactTypeMap.put("供应商", "bd_supplier");
|
||||
asstactTypeMap.put("客户", "bd_customer");
|
||||
|
||||
for (int selectRow : selectRows) {
|
||||
String fkBillNum = (String) this.getModel().getValue("shjh_vouchernumber", selectRow);//凭证号
|
||||
|
||||
|
|
@ -390,10 +395,6 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
return;
|
||||
}
|
||||
|
||||
// 定义往来类型和对应值的映射
|
||||
Map<String, String> asstactTypeMap = new HashMap<>();
|
||||
asstactTypeMap.put("供应商", "bd_supplier");
|
||||
asstactTypeMap.put("客户", "bd_customer");
|
||||
// 往来类型
|
||||
String asstacttype = (String) this.getModel().getValue("shjh_payee", selectRow);
|
||||
// 检查往来类型是否为空或无效
|
||||
|
|
@ -520,8 +521,6 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
ap_payapply.set(currencyType, currency);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//汇率
|
||||
BigDecimal exchangerate = (BigDecimal) this.getModel().getValue("shjh_exchangerate", selectRow);//汇率
|
||||
try {
|
||||
|
|
@ -847,9 +846,7 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
//参照发票号
|
||||
String refertoinvoicenumber = (String) this.getModel().getValue("shjh_czfph", selectRow);
|
||||
ap_payapply.set("shjh_czfph", refertoinvoicenumber);
|
||||
|
||||
// ap_payapply.set("shjh_sapwhetherlocking",true);
|
||||
|
||||
//来源系统
|
||||
ap_payapply.set("shjh_sourcesystem", "A");//SAP
|
||||
//到期日
|
||||
|
|
@ -863,10 +860,11 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
|
||||
}
|
||||
//若多条数据相同,则合并为一条数据处理
|
||||
for (DynamicObject ap_payapply : bills.values()) {
|
||||
String fkBillNum = ap_payapply.getString("shjh_vouchernum");
|
||||
OperateOption option = OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(false)); // 不执行警告级别校验器
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(false)); //不执行警告级别校验器
|
||||
String fkBillNum;
|
||||
for (DynamicObject ap_payapply : bills.values()) {
|
||||
fkBillNum = ap_payapply.getString("shjh_vouchernum");
|
||||
// 新增数据
|
||||
OperationResult saveResult = OperationServiceHelper.executeOperate("save", AP_PAYAPPLY, new DynamicObject[]{ap_payapply}, option);
|
||||
if (!saveResult.isSuccess()) {
|
||||
|
|
@ -891,8 +889,8 @@ public class SappzFormPlugin extends AbstractFormPlugin {
|
|||
this.getView().showErrorNotification(errorMessage);
|
||||
return;
|
||||
}
|
||||
log.error("审核成功,凭证号:" + fkBillNum);
|
||||
JhzjUtils.saveLog(fkBillNum, apimenthod, null, null, true, "API");
|
||||
log.info("审核成功,凭证号:" + fkBillNum);
|
||||
JhzjUtils.saveLog(fkBillNum, apimenthod, ap_payapply.getString("shjh_sapuniquevalue"), "审核成功", true, "API");
|
||||
}
|
||||
this.getView().showSuccessNotification("同步成功");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,34 +84,33 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
JSONArray IT_ITEMs = (JSONArray) data.get("IT_ITEM");
|
||||
if (!IT_ITEMs.isEmpty()) {
|
||||
Map<String, DynamicObject> payapplys = getPayapply(IT_ITEMs);
|
||||
|
||||
//若多条数据相同,则合并为一条数据处理
|
||||
if (payapplys != null) {
|
||||
for (DynamicObject ap_payapply : payapplys.values()) {
|
||||
String fkBillNum = ap_payapply.getString("shjh_vouchernum");
|
||||
OperateOption option = OperateOption.create();
|
||||
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(false)); // 不执行警告级别校验器
|
||||
String fkBillNum;
|
||||
String sapuniquevalue;
|
||||
for (DynamicObject ap_payapply : payapplys.values()) {
|
||||
fkBillNum = ap_payapply.getString("shjh_vouchernum");//凭证号
|
||||
sapuniquevalue = ap_payapply.getString("shjh_sapuniquevalue");//凭证唯一码
|
||||
// 新增数据
|
||||
OperationResult saveResult = OperationServiceHelper.executeOperate("save", AP_PAYAPPLY, new DynamicObject[]{ap_payapply}, option);
|
||||
if (!saveResult.isSuccess()) {
|
||||
handleAndLogError(saveResult, "保存失败", apimenthod, fkBillNum, IT_ITEMs.toString());
|
||||
handleAndLogError(saveResult, "保存失败", apimenthod, fkBillNum, sapuniquevalue);
|
||||
continue;
|
||||
}
|
||||
OperationResult submitResult = OperationServiceHelper.executeOperate("submit", AP_PAYAPPLY, new DynamicObject[]{ap_payapply}, option);
|
||||
if (!submitResult.isSuccess()) {
|
||||
// 提交失败,将保存的数据删除,记录日志
|
||||
OperationServiceHelper.executeOperate("delete", AP_PAYAPPLY, new DynamicObject[]{ap_payapply}, option);
|
||||
handleAndLogError(submitResult, "提交失败", apimenthod, fkBillNum, IT_ITEMs.toString());
|
||||
handleAndLogError(submitResult, "提交失败", apimenthod, fkBillNum, sapuniquevalue);
|
||||
continue;
|
||||
}
|
||||
OperationResult auditResult = OperationServiceHelper.executeOperate("audit", AP_PAYAPPLY, new DynamicObject[]{ap_payapply}, option);
|
||||
if (!auditResult.isSuccess()) {
|
||||
handleAndLogError(auditResult, "审核失败", apimenthod, fkBillNum, IT_ITEMs.toString());
|
||||
handleAndLogError(auditResult, "审核失败", apimenthod, fkBillNum, sapuniquevalue);
|
||||
continue;
|
||||
}
|
||||
logger.error("审核成功,凭证号:" + fkBillNum);
|
||||
JhzjUtils.saveLog(fkBillNum, apimenthod, IT_ITEMs.toString(), null, true, "API");
|
||||
}
|
||||
logger.info("审核成功,凭证号:" + sapuniquevalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,8 +122,19 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
*/
|
||||
private Map<String, DynamicObject> getPayapply(JSONArray IT_ITEMs){
|
||||
Map<String, DynamicObject> bills = new HashMap<>();
|
||||
JSONObject it_list;
|
||||
String shjh_payee = "";//往来类型
|
||||
String shjh_payeebanknum = "";//往来户名称
|
||||
// 定义往来类型和对应值的映射
|
||||
Map<String, String> asstactTypeMap = new HashMap<>();
|
||||
asstactTypeMap.put("供应商", "bd_supplier");
|
||||
asstactTypeMap.put("客户", "bd_customer");
|
||||
String[][] currencyInfo = {
|
||||
{"paycurrency", "付款币别"},
|
||||
{"settlecurrency", "结算币别"}
|
||||
};
|
||||
for (Object itItem : IT_ITEMs) {
|
||||
JSONObject it_list = (JSONObject) itItem;
|
||||
it_list = (JSONObject) itItem;
|
||||
String bukrs = it_list.getString("BUKRS");//公司编号
|
||||
String fkBillNum = it_list.getString("BELNR");//凭证号
|
||||
String gjahr = it_list.getString("GJAHR");//会计年度
|
||||
|
|
@ -157,8 +167,7 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
if (StringUtils.isNotEmpty(ZFBDT)) {
|
||||
ZFBDTs = StrToDate(ZFBDT);
|
||||
}
|
||||
String shjh_payee = "";//往来类型
|
||||
String shjh_payeebanknum = "";//往来户名称
|
||||
|
||||
String kunnr = it_list.getString("KUNNR");//客户(员工)
|
||||
String lifnr = it_list.getString("LIFNR");//供应商
|
||||
if (StringUtils.isNotEmpty(kunnr)) {
|
||||
|
|
@ -172,7 +181,7 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
//原因码
|
||||
String reasoncode =it_list.getString("RSTGR");
|
||||
//todo:资金计划分类
|
||||
String zreqDept = it_list.getString("ZREQ_DEPT");//二级部门
|
||||
// String zreqDept = it_list.getString("ZREQ_DEPT");//二级部门
|
||||
String procurementeam = it_list.getString("EKGRP");//采购组
|
||||
String isselfprocurment = it_list.getString("ZZXCG_FLAG");//是否自行采购
|
||||
String waers = it_list.getString("WAERS");//付款币别编号CNY,货币码 && 结算币别编号,货币码
|
||||
|
|
@ -260,14 +269,10 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
//请款事由
|
||||
ap_payapply.set("applycause", "");
|
||||
|
||||
//币别
|
||||
String[][] currencyInfo = {
|
||||
{"paycurrency", "付款币别"},
|
||||
{"settlecurrency", "结算币别"}
|
||||
};
|
||||
//币别-处理
|
||||
for (String[] info : currencyInfo) {
|
||||
String currencyType = info[0];
|
||||
String currencyTypeName = info[1];
|
||||
// String currencyTypeName = info[1];
|
||||
// 根据币别类型从 applybill 获取对应的币别编号
|
||||
String currencyNumber = waers;
|
||||
if ("RMB".equals(currencyNumber)) {
|
||||
|
|
@ -298,10 +303,7 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
DynamicObjectCollection entry = ap_payapply.getDynamicObjectCollection("entry");//明细
|
||||
entry.clear();
|
||||
DynamicObject ap_payapply_entry = entry.addNew();
|
||||
// 定义往来类型和对应值的映射
|
||||
Map<String, String> asstactTypeMap = new HashMap<>();
|
||||
asstactTypeMap.put("供应商", "bd_supplier");
|
||||
asstactTypeMap.put("客户", "bd_customer");
|
||||
|
||||
// 根据往来类型设置值
|
||||
ap_payapply_entry.set("e_asstacttype", asstactTypeMap.get(shjh_payee));
|
||||
// 往来户
|
||||
|
|
@ -312,7 +314,7 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
if ("供应商".equals(shjh_payee)) {
|
||||
DynamicObjectCollection bankentrys = party.getDynamicObjectCollection("entry_bank");//银行信息分录
|
||||
if (!bankentrys.isEmpty()) {
|
||||
boolean ispp = false;
|
||||
boolean ispp = false;//sap合作银行类型是否与金蝶供应商银行账号匹配
|
||||
for (DynamicObject bankentry : bankentrys) {
|
||||
if (assacct.equals(bankentry.getString("shjh_banktype"))) {
|
||||
ispp = true;
|
||||
|
|
@ -556,7 +558,8 @@ public class QuerySapCreatePayApplyTask extends AbstractTask {
|
|||
//SAP应付凭证ID:金蝶组装:公司编号+SAP应付凭证会计年度+SAP应付凭证号+SAP应付凭证行号
|
||||
ap_payapply.set("shjh_sapuniquevalue", bukrs + gjahr + fkBillNum + ebelp);
|
||||
bills.put(ap_payapply.getString("shjh_sapuniquevalue"), ap_payapply);
|
||||
|
||||
//付款申请单校验成功,保存日志,后续单子保存提交审核没问题的话,不再记录日志
|
||||
JhzjUtils.saveLog(fkBillNum, apimenthod, it_list.toJSONString(), "校验成功", true, "API");
|
||||
}
|
||||
return bills;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue