<0>背景:套打中只能取到审批人和审批意见两个字段,所以在打印预览时不能分清加签人对应的意见,想知道有没有办法实现审批人和审批意见对应显示。
<1>套打工作流相关逻辑:【套打】套打中审批路线、流程节点二开指南
针对指定节点,为多个审批子项时,调整处理意见输出为
{处理人1}:{处理人1.意见}\r\n{处理人2}:{处理人2.意见}……
效果:
实现通过表单插件干预套打数据包调整处理意见的值:
附:
using System.ComponentModel;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.BOS.Workflow.Model;
using Kingdee.BOS.Workflow.Models.EnumStatus;
using Kingdee.BOS.Workflow.Models.NotePrint;
using Kingdee.BOS.Workflow.ServiceHelper;
namespace NotePrintPlugin.Sample
{
[Kingdee.BOS.Util.HotUpdate]
[Description("套打流程节点数据干预示例")]
public class HandleWorlFlowProcessNode : AbstractDynamicFormPlugIn
{
/*
* 修改指定流程的指定节点的会签节点的处理意见
* 显示为 {处理人1}:{处理人1.意见}\r\n{处理人2}:{处理人2.意见}……
*/
/// <summary>
/// 目标流程模板Id
/// </summary>
private static readonly string TargetProcDefId = "5d636c8ab0442e";
/// <summary>
/// 目标流程节点Id
/// </summary>
private static int TargetProcessNodeId = 66;
public override void OnPrepareNotePrintData(PreparePrintDataEventArgs e)
{
if (e.DataObjects == null || e.DataObjects.Length <= 0 || e.DataObjects[0] == null)
return;
//工作流数据源默认以workflow作为数据源前缀
if (!e.DataSourceId.StartsWith("workflow."))
return;
string workflowBillId = e.BillIds.FirstOrDefault();
if (workflowBillId.IsNullOrEmptyOrWhiteSpace())
return;
string[] dataSourceArgs = e.DataSourceId.Split('.');
if (dataSourceArgs.Length < 2)
return;
//流程设计Id,判断是审批路线取数还是流程节点取数
string procDefId = dataSourceArgs[1];
if (procDefId.Equals("approveLine"))
{
//审批路线取数
return;
}
if (!procDefId.EqualsIgnoreCase(TargetProcDefId))
{
//仅修改指定流程的工作流数据
return;
}
//流程节点取数
//干预流程节点取数存在两种处理:
//<1>利用数据包结构进行内容调整(这个本质上和套打干预数据包结构的实现一致,不做演示)
//<2>根据工作流取数逻辑,调整部分套打结果
//示例:修改节点66(审批节点2,)的处理意见
string targetPropKey = string.Format("ac_{0}_{1}", TargetProcessNodeId, "Disposition");
DynamicObject workflowProcessObj = e.DataObjects[0];
//提前判断,如果数据包中没有对应节点数据,那么工作流也应该没有对应节点数据,没必要再做数据处理
if (!workflowProcessObj.DynamicObjectType.Properties.ContainsKey(targetPropKey))
return;
NotePrintProcessInstance procInst = GetCurProcessInstanceByBillId(workflowBillId);
if (procInst == null)
return;
//获取最后一次运行的节点任务
NotePrintAssign assign = procInst.GetLastActivityAssign(66);
if (assign == null || assign.ApprovalAssigns == null || assign.ApprovalAssigns.Count == 0 ||
assign.ApprovalAssigns[0] == null)
return;
//按处理时间升序排序
var approvalItemsOrderByCompletedTime =
new DynamicObjectViewCollection<NotePrintApprovalItem>(
assign.ApprovalAssigns[0].ApprovalItems.DynamicObjects);
approvalItemsOrderByCompletedTime.Sort(x => x.CompletedTime);
StringBuilder displayBuilder = new StringBuilder();
foreach (var approvalItem in approvalItemsOrderByCompletedTime)
{
//仅正向处理节点输出
if (approvalItem == null || approvalItem.Status != ApprovalItemStatus.Completed)
continue;
displayBuilder.AppendLine(string.Format("{0}:{1}", approvalItem.ReceiverName, approvalItem.Disposition));
}
workflowProcessObj[targetPropKey] = displayBuilder.ToString().TrimEnd();
}
/// <summary>
/// 获取当前视图对应业务对象的指定单据内码的套打流程实例
/// </summary>
/// <param name="billId"></param>
/// <returns></returns>
private NotePrintProcessInstance GetCurProcessInstanceByBillId(string billId)
{
string formId = this.View.BillBusinessInfo.GetForm().Id;
string procInstId = Kingdee.BOS.Workflow.ServiceHelper.WorkflowChartServiceHelper.GetProcInstIdByBillInst(Context, formId, billId);
if (procInstId.IsNullOrEmptyOrWhiteSpace())
return null;
bool isHisProcInst = WorkflowChartServiceHelper.HasHisProcInst(Context, procInstId);
QueryBuilderParemeter qbPara = new QueryBuilderParemeter();
qbPara.FilterClauseWihtKey = string.Format("FProcInstId = '{0}'", procInstId);
DynamicObject[] dataObjs;
if (isHisProcInst)
{ //查归档流程信息
qbPara.FormId = WFBillConst.ProcManageProcInstEndHis;
dataObjs = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Load(Context, NotePrintProcessInstanceHis.ProcessInstanceHisType, qbPara);
}
else
{
qbPara.FormId = WFBillConst.ProcManageProcInst;
dataObjs = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Load(Context, NotePrintProcessInstance.ProcessInstanceType, qbPara);
}
var procInsts = (from p in dataObjs select new NotePrintProcessInstance(p)).ToArray();
//获取时间最新的流程实例
var procInst = procInsts.OrderByDescending(p => p.CreateTime).FirstOrDefault();
return procInst;
}
}
}
HandleWorlFlowProcessNode.rar(2.20KB)
推荐阅读