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