【客户需求】关帐校验信息增加单据创建人
如何实现系统库存关帐、存货关帐校验信息增加单据创建人
说明:
目前某些客户关帐时出现一些单据校验类不通过,想及时通知相关人员处理,需要在关帐校验信息中显示创建人,好及时知会对应人员处理。
系统库存关帐、存货关帐相关校验信息,是可以通过二开关帐插件处理。相关说明可以参考:
下面以具体的实现库存关帐、存货关帐关于:单据未审核、暂存、盘点单未审核校验信息增加创建人。供客户二开实现参考。
步骤:
(下面以实现:库存关帐、存货关帐关于 单据未审核、暂存、盘点单未审核 校验信息增加创建人)
1.二开关帐校验插件,继承AbstractInvAccountValidatorPlugIn,重载InvAccountOffModifyErrInfo,根据已校验的相关信息,再获取对应单据创建人信息,追加至校验信息中。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using Kingdee.K3.Core.SCM.STK; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Contracts; using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Core.SqlBuilder; using Kingdee.BOS; namespace TestInvAccountValidatorPlugIn { [Description("校验信息增加创建人-关账插件")] public class AddCreatorForInvAccountInfo : AbstractInvAccountValidatorPlugIn { public override bool InvAccountOffModifyErrInfo(bool isCallByOwner, List<StockOrgOperateResult> errInfo) { bool bModified = false; List<OperateErrorInfo> stkBillErrInfos = new List<OperateErrorInfo>(); foreach (var info in errInfo) { //库存非忽略性异常校验信息:包含未审核单据校验信息 if (info.ErrInfo != null) { var errinfo = info.ErrInfo.Where(p => p.ErrType == 100).ToList(); if (errinfo != null && errinfo.Count > 0) stkBillErrInfos.AddRange(info.ErrInfo.Where(p => p.ErrType == 100)); } //暂存单据校验信息 if (info.StkBillDraftErrInfo != null && info.StkBillDraftErrInfo.Count > 0) stkBillErrInfos.AddRange(info.StkBillDraftErrInfo); //盘点单校验信息 if (info.StkCountBillAuditErrInfo != null && info.StkCountBillAuditErrInfo.Count > 0) stkBillErrInfos.AddRange(info.StkCountBillAuditErrInfo); } //无上述校验信息时,返回不处理 if (stkBillErrInfos.Count <= 0) return bModified; Dictionary<string, string> dCrearorInfo = new Dictionary<string, string>(); FormMetadata billMeta; IMetaDataService metaService = Kingdee.BOS.Contracts.ServiceFactory.GetService<IMetaDataService>(this.Context); IQueryService service = Kingdee.BOS.App.ServiceHelper.GetService<IQueryService>(); Dictionary<string, List<string>> dFormidToKeys = stkBillErrInfos.GroupBy(p => p.ErrObjType).ToDictionary(p => p.Key, o => o.Select(p => p.ErrObjKeyID).ToList()); foreach (var dInfo in dFormidToKeys) { billMeta = (FormMetadata)metaService.Load(this.Context, dInfo.Key); var createrField = billMeta.BusinessInfo.GetFieldList().Where(p => p is CreaterField).FirstOrDefault(); if (createrField == null) continue; List<SelectorItemInfo> selector = new List<SelectorItemInfo>(); selector.Add(new SelectorItemInfo("FID")); selector.Add(new SelectorItemInfo(createrField.Key)); selector.AddRange(SelectorItemInfo.CreateItems(createrField.Key + ".FName as FCreatorName")); List<SqlParam> sqlParas = new List<SqlParam>(); string strFilter; if (dInfo.Value.Count > 50) { strFilter = string.Format(" FID IN (SELECT /*+ cardinality(a {0})*/ a.FID FROM table(fn_StrSplit(@FID, ',', 1)) a ) " , dInfo.Value.Count); sqlParas.Add(new SqlParam("@FID", KDDbType.udt_inttable, Array.ConvertAll(dInfo.Value.ToArray(), int.Parse))); } else { strFilter = string.Format(" FID IN ({0}) ", string.Join(",", dInfo.Value)); } QueryBuilderParemeter para = new QueryBuilderParemeter { FormId = dInfo.Key, SelectItems = selector, FilterClauseWihtKey = strFilter }; var billDatas = service.GetDynamicObjectCollection(this.Context, para, sqlParas); foreach (var billdata in billDatas) { string key = dInfo.Key + Convert.ToString(billdata["FID"]); if (!dCrearorInfo.ContainsKey(key)) dCrearorInfo.Add(key, string.Format("创建人为:{0}", Convert.ToString(billdata["FCreatorName"]))); } } foreach (var info in stkBillErrInfos) { string key = info.ErrObjType + info.ErrObjKeyID; if (dCrearorInfo.ContainsKey(key)) { info.ErrMsg = info.ErrMsg + dCrearorInfo[key]; bModified = true; } } return bModified; } } }
2.管理员登陆系统-参数设置-库存管理,注册对应二开插件。
效果:
(处理后:库存关帐校验信息)
(处理后:存货关帐校验信息)
这个能不能做成现成的可以直接导入的呀~
【客户需求】关帐校验信息增加单据创建人
如何实现系统库存关帐、存货关帐校验信息增加单据创建人说明:目前某些客户关帐时出现一些单据校验类不通过,想及时通知相关人员处理,需要...
点击下载文档
本文2024-09-16 19:06:02发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-26390.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章