生产订单审核自动下推生产汇报单并自动提交审核原创
金蝶云社区-HN_楊華
HN_楊華
9人赞赏了该文章 953次浏览 未经作者许可,禁止转载编辑于2022年04月29日 22:21:14

1、在生产订单审核操作上配置自动下推服务,如下图:

image.png


2、二开服务端插件,挂在生产订单的审核操作上,代码如下

using Kingdee.BOS.Core.DynamicForm.PlugIn;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ComponentModel;

using Kingdee.BOS.Util;

using Kingdee.K3.Core.MFG.EntityHelper;

using Kingdee.BOS.Orm.DataEntity;

using Kingdee.BOS;

using Kingdee.K3.MFG.App;

using Kingdee.BOS.Core.DynamicForm;

using Kingdee.BOS.Core.Metadata;

using Kingdee.BOS.Orm;

 

namespace EK.Kingdee.K3.MFG.PRD.App.ServicePlugIn

{

    [Description("生产订单审核自动下推汇报单之后,汇报单自动提交,审核")]

    public class MoAudit : AbstractOperationServicePlugIn

    {

        /// <summary>

        /// 【生产订单.明细】实体名

        /// </summary>

        public static string KEY_Entity = "TreeEntity";


        public override void AfterExecuteOperationTransaction(global::Kingdee.BOS.Core.DynamicForm.PlugIn.Args.AfterExecuteOperationTransaction e)

        {

            base.AfterExecuteOperationTransaction(e);

            if (e.DataEntitys.IsEmpty()) return;

            var entryDatas = from data in e.DataEntitys

                             from row in data.GetDynamicValue<DynamicObjectCollection>(KEY_Entity)

                             select row;

            if (entryDatas.IsEmpty()) return;

            List<long> moEntryIds = entryDatas.Select(s => s.GetDynamicValue<long>("ID")).Distinct().ToList();

            string sql = string.Format(@"SELECT T.FID FROM T_PRD_MORPT TR

INNER JOIN T_PRD_MORPTENTRY T ON TR.FID=T.FID AND TR.FDOCUMENTSTATUS='A'

INNER JOIN {0} TT ON T.FMOENTRYID=TT.FID", StringUtils.GetSqlWithCardinality(moEntryIds.Distinct().Count(), "@MOENTRYIDS", 1));

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

            sqlParams.Add(new SqlParam("@MOENTRYIDS", KDDbType.udt_inttable, moEntryIds.Distinct().ToArray()));

            DynamicObjectCollection objs = AppServiceContext.DbUtils.ExecuteDynamicObject(this.Context, sql, sqlParams.ToArray());

            if (objs.IsEmpty()) return;

            //提交

            List<object> pkIds = new List<object>();

            List<KeyValuePair<object, object>> pkEntryIds = new List<KeyValuePair<object, object>>();

            foreach (DynamicObject targetBill in objs)

            {

                pkIds.Add(targetBill["FID"]);

                pkEntryIds.Add(new KeyValuePair<object, object>(targetBill["FID"], ""));

            }

 

            FormMetadata targetForm = (FormMetadata)AppServiceContext.MetadataService.Load(this.Context, "PRD_MORPT");

            OperateOption option = OperateOption.Create();

            IOperationResult submitOperateTarget = AppServiceContext.SubmitService.Submit(this.Context, targetForm.BusinessInfo, pkIds.ToArray(), "Submit", option);

 

            if (submitOperateTarget.IsSuccess)

            {

                //审核

                List<object> paraAudit = new List<object>();

                //1审核通过

                paraAudit.Add("1");

                //审核意见

                paraAudit.Add("");

                IOperationResult auditOperateTarget = AppServiceContext.SetStatusService.SetBillStatus(this.Context, targetForm.BusinessInfo, pkEntryIds, paraAudit, "Audit", option);

            }

        }

    }

}


图标赞 9
9人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!

您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!

请选择打赏金币数 *

10金币20金币30金币40金币50金币60金币
可用金币: 0