如何将检验单使用决策表体备注信息携带到MRB评审单表体备注信息

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

如何将检验单使用决策表体备注信息携带到MRB评审单表体备注信息

由于检验单使用决策表体信息携带的MRB评审单是在单据转换插件中处理的,所以要处理备注信息的携带需要二开检验单到MRB评审单的单据转换插件。具体思路如下:

1、二开单据转换插件继承BaseBillConvertServicePlugIn,在AfertConvert事件中获取MRB评审单表体的检验单使用决策分录内码信息;

2、根据获取的检验单使用决策分录内码查找检验单使用决策表体的备注信息,注意此处需要将检验单使用决策表体的FDETAILID一起取出;

3、根据MRB评审单表体分录的检验单使用决策分录内码信息从第2步的查询结果中找到匹配项,将对应的备注信息取出赋值给当前MRB评审单分录的备注信息字段即可;

4、打开检验单到MRB评审单的单据转换规则,在插件策略中将二开的单据转换插件注册上即可;(注意二开的单据转换插件必须注册到标准产品单据转换插件之后)

image.webp

 二开单据转换插件示例代码如下:

using Kingdee.BOS.Core;

using Kingdee.K3.Core.MFG.EnumConst;

using Kingdee.K3.MFG.App.ConvertPlugIn;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Kingdee.K3.Core.MFG.EntityHelper;

using Kingdee.BOS.Orm.DataEntity;

using Kingdee.BOS.Util;

using Kingdee.BOS;

using Kingdee.K3.MFG.App;


namespace Kingdee.K3.MFG.QM.App.BillConvertServicePlugIn

{

    public class MenoTest : BaseBillConvertServicePlugIn

    {

        public override void AfterConvert(BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)

        {

            base.AfterConvert(e);

            ExtendedDataEntity[] headDatas =e.Result.FindByEntityKey(CONST_QM_MRBReviewBill.CONST_FBillHead.ENTITY_FBillHead);            

            List<long> ibPolicyDetailIds = new List<long>();

            foreach (ExtendedDataEntity headData in headDatas)

            {

                DynamicObjectCollection MrbEntrys = headData.DataEntity.GetDynamicValue<DynamicObjectCollection>(CONST_QM_MRBReviewBill.CONST_FEntity.ENTITY_ORM_Entity);

                List<long> entryIds = MrbEntrys.Where(o => o.GetDynamicValue<long>(CONST_QM_MRBReviewBill.CONST_FEntity.ORM_QCDetailId) > 0).Select(g => g.GetDynamicValue<long>(CONST_QM_MRBReviewBill.CONST_FEntity.ORM_QCDetailId)).ToList();              

                if (entryIds.IsEmpty()) continue;

                ibPolicyDetailIds.AddRange(entryIds.Distinct());

            }

            if (ibPolicyDetailIds.IsEmpty()) return;

            DynamicObjectCollection result = GetIbPolicyMenoInfos(this.Context, ibPolicyDetailIds);

            if (result.IsNullOrEmpty()) return;

            Dictionary<long, IGrouping<long, DynamicObject>> entryInfos = result.GroupBy(g => g.GetDynamicValue<long>("FIBDETAILID")).ToDictionary(d => d.Key);

            foreach (ExtendedDataEntity headData in headDatas)

            {

                DynamicObjectCollection MrbEntrys = headData.DataEntity.GetDynamicValue<DynamicObjectCollection>(CONST_QM_MRBReviewBill.CONST_FEntity.ENTITY_ORM_Entity);

                foreach (DynamicObject entry in MrbEntrys)

                {

                    long ibPolicyDetailId =

                        entry.GetDynamicValue<long>(CONST_QM_MRBReviewBill.CONST_FEntity.ORM_QCDetailId);

                    if (ibPolicyDetailId <= 0) continue;

                    IGrouping<long, DynamicObject> ibPolicyInfo = null;

                    if (!entryInfos.TryGetValue(ibPolicyDetailId, out ibPolicyInfo)) continue;

                    entry.SetDynamicObjectItemValue(CONST_QM_MRBReviewBill.CONST_FEntity.ORM_Memo, ibPolicyInfo.FirstOrDefault().GetDynamicValue<string>("FIBMEMO"));

                }              

            }

        }


        public DynamicObjectCollection GetIbPolicyMenoInfos(Context ctx,List<long> ibDetailIds)

        {

            if (ibDetailIds.IsEmpty()) return null;

            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendLine(" SELECT  ");

            sbSql.AppendLine(" IBPE.FDETAILID AS FIBDETAILID, ");

            sbSql.AppendLine(" IBPEL.FMEMO AS FIBMEMO ");           

            sbSql.AppendLine(" FROM T_QM_IBPOLICYDETAIL IBPE ");

            sbSql.AppendFormat("INNER JOIN T_QM_IBPOLICYDETAIL_L IBPEL ON IBPEL.FDETAILID=IBPE.FDETAILID AND IBPEL.FLOCALEID={0} ", ctx.UserLocale.LCID);

            sbSql.AppendLine(" INNER JOIN" + StringUtils.GetSqlWithCardinality(ibDetailIds.Distinct().Count(), "@FID", 1, true) + @"T ON T.FID=IBPE.FDETAILID ");

            List<SqlParam> sqlParam = new List<SqlParam>();

            sqlParam.Add(new SqlParam("@FID", KDDbType.udt_inttable, ibDetailIds.Distinct().ToArray()));

            return AppServiceContext.DbUtils.ExecuteDynamicObject(ctx, sbSql.ToString(), sqlParam.ToArray());

        }

    }

}


如何将检验单使用决策表体备注信息携带到MRB评审单表体备注信息

由于检验单使用决策表体信息携带的MRB评审单是在单据转换插件中处理的,所以要处理备注信息的携带需要二开检验单到MRB评审单的单据转换插件...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息