图片(文件服务),图片(数据库)字段目前在单据转换字段映射中是无法配置携带的,需要通过转换插件实现,实现代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Kingdee.BOS;
using Kingdee.BOS.Core;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Core.Const;
using Kingdee.BOS.Orm.DataEntity;
namespace Kingdee.BOS.TestPlugIn
{
[HotUpdate]
[Description("单据A到单据B携带图片字段")]
public class TakeImageConvertPlugIn : AbstractConvertPlugIn
{
/// <summary>
/// 增加需要取数的源单字段
/// </summary>
/// <param name="e"></param>
public override void OnQueryBuilderParemeter(QueryBuilderParemeterEventArgs e)
{
base.OnQueryBuilderParemeter(e);
e.SelectItems.Add(new SelectorItemInfo("F_Jac_Image")); //加上图片字段
}
/// <summary>
/// 单据转换之后事件
/// </summary>
/// <param name="e"></param>
public override void AfterConvert(AfterConvertEventArgs e)
{
var targetExObjs = e.Result.FindByEntityKey("FBillHead"); //目标单据数据包扩展集合
foreach (var tExObj in targetExObjs)
{
var srcObjs = tExObj[BOSConst.ConvSourceExtKey] as List<DynamicObject>; //来源单列表
if (srcObjs != null && srcObjs.Count > 0)
{
//可能存在合并,有多张来源单,这里只取第一张单据图片
var srcImageValue = srcObjs.First()["F_Jac_Image"];
tExObj.DataEntity["F_Jac_Image"] = srcImageValue;
}
}
}
}
}
推荐阅读