【应用场景】
任务的输出界面进行二开时,需要可以统计所有下层任务的输出,并且可以统一对输出物发起流程。
【注意】
此案例仅适用于任务的输出,任务的输入也可参考修改。
【案例演示】
点击菜单【获取下层任务所有输出】,获取所有下层任务的输出,批量选择输出对象选择启动流程统一对输出物发起流程。
【实现步骤】
<1>编写表单插件
(如何编写二次开发插件配置等请参考:二次开发扩展程序开发之插件模式
更多星空PLM二次开发指南请参考:【汇总】星空PLM二开指南(持续更新)
更多金蝶云星空BOS二次开发指南请参考:金蝶云星空BOS二次开发指南 )
添加引用:
代码如下:
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。
<3>BOSIDE修改扩展输出,新增菜单,注册表单插件,保存元数据,开发完毕,更新业务模型。
【功能验证】
<1>登录业务站点,打开任务输出界面,点击菜单【获取下层任务所有输出】,即可获取所有下层任务的输出,批量选择输出对象选择启动流程即可统一对输出物发起流程。
---------------------------------------------------------------------------------------------------------
【知识点】
推荐阅读