二开案例. 任务的输出界面统计所有下层任务的输出,并发起流程原创
金蝶云社区-开饭了
开饭了
15人赞赏了该文章 1,187次浏览 未经作者许可,禁止转载编辑于2022年08月12日 14:40:25

【应用场景】

任务的输出界面进行二开时,需要可以统计所有下层任务的输出,并且可以统一对输出物发起流程。

【注意】

此案例仅适用于任务的输出,任务的输入也可参考修改。

【案例演示】

点击菜单【获取下层任务所有输出】,获取所有下层任务的输出,批量选择输出对象选择启动流程统一对输出物发起流程。

图片.png

【实现步骤】

<1>编写表单插件

(如何编写二次开发插件配置等请参考:二次开发扩展程序开发之插件模式

更多星空PLM二次开发指南请参考:【汇总】星空PLM二开指南(持续更新)

更多金蝶云星空BOS二次开发指南请参考:金蝶云星空BOS二次开发指南

添加引用:

图片.png

代码如下:

using System;

using System.ComponentModel;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;

using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;

using Kingdee.BOS.Util;

 

using Kingdee.K3.PLM.Business.PlugIn;

using Kingdee.K3.PLM.Common.Core.Common;

 

namespace ISV.ProjectTest.Common.BusinessEntity

{

       public class ButtonFormPlugin : AbstractPLMBillPlugIn

{

         /// <summary>

        /// 递归获取下层所有任务ID集合

        /// </summary>

        /// <param name="taskId"></param>

        /// <returns></returns>

        private List<long> GetTaskIds(Int64 taskId)

        {

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

            ids.Add(taskId);

            var sonTasks = Kingdee.K3.PLM.STD.Common.BusinessEntity.Project.TaskModel.Instance.GetByTask(PLMContext, taskId);

            foreach (var item in sonTasks)

            {

                var cid = Convert.ToInt64(item["FID"]);

                var ccids = GetTaskIds(cid);

                foreach (var cc in ccids)

                {

                    ids.Add(cc);

                }

            }

            return ids;

        }

 

         public override void EntryBarItemClick(BarItemClickEventArgs e)

           {

            base.EntryBarItemClick(e);

            if (e.BarItemKey.Equals("GetAllTaskOutPut", StringComparison.OrdinalIgnoreCase))

            {

 

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

                string relatedObjectEntity = "FPlmRelatedObject";

                this.View.Refresh();

                this.Model.DeleteEntryData(relatedObjectEntity);

                this.Model.ClearNoDataRow();

                var taskid = Math.Abs(long.Parse(this.View.OpenParameter.PkValue.ToString()));

                EntryGrid grid = this.View.GetControl<EntryGrid>(relatedObjectEntity);

                var taskids = GetTaskIds(taskid);

                foreach (var baseID in taskids)

                {

                    var relatedObjects = Kingdee.K3.PLM.CFG.Common.BusinessEntity.Manager.ProjectRelationManager.Instance.GetAllProjectRelatedObject(PLMContext, baseID, 1);

 

                    foreach (var data in relatedObjects)

                    {

                        long reObjId = long.Parse(data["FRELATEDOBJECT"].GetString());

                        long entryId = long.Parse(data["ID"].GetString());

                        long reObjectId = 0;

 

                        reObjectId = reObjId;

                        if (reObjectId != 0)

                        {

                            if (!objIds.Contains(reObjectId))

                            {

                                var reobject = Kingdee.K3.PLM.CFG.Common.BusinessEntity.Manager.GlobalObjectManager.Instance(PLMContext).Get(PLMContext, reObjectId);

                                var visions = Kingdee.K3.PLM.CFG.Common.BusinessEntity.Manager.Project.ProjectRelationVisionManager.Instance.GetVision(PLMContext, reObjId.GetString(), taskid.GetString());

                                if (visions.Count > 0)

                                 {

                                    var vision = visions[0];

                                    reobject["VerNO"] = vision["FVerNO"];

                                    reobject["BuildVer"] = vision["FBuildVer"];

                                    reobject["LifeCircleStage"] = vision["FLifeCircleStage"];

                                    var icon = reobject["Icon"].GetString();

                                    if (icon.Length >= 2)

                                    {

                                        icon = icon.GetSubstring(0, icon.Length - 2);

                                        icon += vision["FLifeCircleStage"].GetString().ToLower();

                                    }

                                    reobject["Icon"] = icon;

                                }

 

                                this.Model.CreateNewEntryRow(relatedObjectEntity);

                                var row = this.Model.GetEntryCurrentRowIndex(relatedObjectEntity);

                                this.Model.SetValue("FRelatedObject_Id", reObjectId, row);

                                this.Model.SetValue("FRelatedObject", reobject, row);

                                this.Model.SetValue("FRelationType", 1, row);

                                this.Model.SetValue("FDataType", data["FDATATYPE"], row);

                                this.Model.SetValue("FOperType", data["FOPERTYPE"], row);

                                var stage = Kingdee.K3.PLM.CFG.Common.BusinessEntity.Manager.LifeCycle.StageManager.Instance.LoadSingle(PLMContext, string.Format("FValue='{0}'", reobject["LifeCircleStage"]));

                                if (stage != null)

                                {

                                    this.Model.SetValue("FRE_FLifeCircleStage", stage["Name"].GetString(), row);

                                    grid.SetForecolor("FRelatedObject", "#0000FF", row);

                                }

                                objIds.Add(reObjectId);

                      

                            }

                        }

                    }

                }

                if (objIds.Count == 0)

                {

                    this.Model.CreateNewEntryRow(relatedObjectEntity);

                }

                this.View.UpdateView(relatedObjectEntity);

            }

        }

}

<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。


 图片.png

<3>BOSIDE修改扩展输出,新增菜单,注册表单插件,保存元数据,开发完毕,更新业务模型。

图片.png

图片.png

图片.png







【功能验证】

<1>登录业务站点,打开任务输出界面,点击菜单【获取下层任务所有输出】,即可获取所有下层任务的输出,批量选择输出对象选择启动流程即可统一对输出物发起流程。

图片.png

图片.png

图片.png





 


---------------------------------------------------------------------------------------------------------

【知识点】

 

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