【客户需求】关帐校验信息增加单据创建人原创
17人赞赏了该文章
594次浏览
编辑于2022年02月15日 09:38:07
如何实现系统库存关帐、存货关帐校验信息增加单据创建人
说明:
目前某些客户关帐时出现一些单据校验类不通过,想及时通知相关人员处理,需要在关帐校验信息中显示创建人,好及时知会对应人员处理。
系统库存关帐、存货关帐相关校验信息,是可以通过二开关帐插件处理。相关说明可以参考:
下面以具体的实现库存关帐、存货关帐关于:单据未审核、暂存、盘点单未审核校验信息增加创建人。供客户二开实现参考。
步骤:
(下面以实现:库存关帐、存货关帐关于 单据未审核、暂存、盘点单未审核 校验信息增加创建人)
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.管理员登陆系统-参数设置-库存管理,注册对应二开插件。
效果:
(处理后:库存关帐校验信息)
(处理后:存货关帐校验信息)
赞 17
17人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读