【二开插件】使用WebApi进行代码下推并自动保存审核单据
WebApi下推
优点:只需要知道上游单据编号或者内码就可以,构造的下推参数比较简单,设置保存审核也简单
缺点:会自动保存
代码:
if (webApiAutoPushInvoice(ctx, msg, out string message)) { LogObject log = new LogObject { pkValue = "0", Description = "下推发票成功,发票号:"+message , OperateName = "下推发票_成功", ObjectTypeId = "BOS_SCHEDULETYPE", SubSystemId = "BOS", Environment = OperatingEnvironment.BizOperate }; logs.Add(log); } else { LogObject log = new LogObject { pkValue = "0", Description = "自动下推发票失败,失败原因:" + message , OperateName = "下推发票_失败", ObjectTypeId = "BOS_SCHEDULETYPE", SubSystemId = "BOS", Environment = OperatingEnvironment.BizOperate }; logs.Add(log); }
下推保存代码
private bool webApiAutoPushInvoice(Context ctx, string msg, out string message) { bool result = false; message = string.Empty; JObject data = new JObject { { "Numbers", msg }, { "RuleId", "IV_ReceivableToSalesOC_Entry" }, { "IsDraftWhenSaveFail", "false" } }; //下推 Dictionary<string, object> pushResult = WebApiServiceCall.Push(ctx, "AR_receivable", data.ToString()) as Dictionary<string, object>; Dictionary<string, object> response = (pushResult["Result"] as Dictionary<string, object>)["ResponseStatus"] as Dictionary<string, object>; if (Convert.ToBoolean(response["IsSuccess"])) { //自动保存提交审核 Dictionary<string, object> successEntity = (response["SuccessEntitys"] as List<object>).First() as Dictionary<string, object>; string FID = successEntity["Id"].ToString(); Dictionary<string, object> saveResult = WebApiServiceCall.Save(ctx, "IV_SALESOC", GetSaveParamStr(FID)) as Dictionary<string, object>; Dictionary<string, object> saveResponse = (saveResult["Result"] as Dictionary<string, object>)["ResponseStatus"] as Dictionary<string, object>; if (!Convert.ToBoolean(saveResponse["IsSuccess"])) { Dictionary<string, object> Errors = (saveResponse["Errors"] as List<object>).First() as Dictionary<string, object>; message = Errors["Message"].ToString(); } else { result = true; message =successEntity["Number"].ToString(); } } else { Dictionary<string, object> Errors = (response["Errors"] as List<object>).First() as Dictionary<string, object>; message = Errors["Message"].ToString(); } return result; }
自动保存审核参数构造
private string GetSaveParamStr(string FID) { JObject param = new JObject(); param.Add("Creator", ""); JArray needUpdateFields = new JArray(); param.Add("NeedUpDateFields", needUpdateFields); param.Add("NeedReturnFields", new JArray()); param.Add("IsDeleteEntry", true); param.Add("SubSystemId", ""); param.Add("IsVerifyBaseDataField", false); param.Add("IsEntryBatchFill", true); param.Add("ValidateFlag", true); param.Add("NumberSearch", true); param.Add("InterationFlags", ""); param.Add("IsAutoSubmitAndAudit", true); //设置true就是自动提交审核 JObject order = new JObject(); param.Add("Model", order); order.Add("FID", FID); return param.ToString(); }
如果是明细行下推
JObject data = new JObject { { "EntryIds", string.Join(",", ids) }, //分录内码 { "RuleId", "DeliveryNotice-OutStock" }, { "IsDraftWhenSaveFail", "false" } };
【二开插件】使用WebApi进行代码下推并自动保存审核单据
WebApi下推优点:只需要知道上游单据编号或者内码就可以,构造的下推参数比较简单,设置保存审核也简单缺点:会自动保存代码: if (webApiA...
点击下载文档
本文2024-09-16 17:16:42发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14668.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章