需求:物料收发存明细表增加字段
步骤1:
步骤2:
步骤三:
插件代码:
[Description("物料收发明细表:增加字段")]
[Kingdee.BOS.Util.HotUpdate]
public class MaterialRARDetailAddField: StockDetailRpt
{
private string[] TempTableName;
public override void Initialize()
{
base.Initialize();
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
this.IsCreateTempTableByPlugin = true;
}
//重写创建临时表方法
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
//创建临时表用于保存自己的数据
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
TempTableName = dbservice.CreateTemporaryTableName(this.Context, 1);
string strTable = TempTableName[0];
//调用基类方法,获取初步的查询结果
base.BuilderReportSqlAndTempTable(filter, strTable);
//对初步的查询结果处理,然后回填到默认的存放查询结果到临时表
StringBuilder sb = new StringBuilder();
//string strSql1 = @"/*dialect*/select t1.* ,666 as [F_qczl],777 as [F_qcmj] into {0} from {1} t1 ";
string strSql = @" /*dialect*/
select
t1.*,
(CASE
WHEN t1.FBILLNAME='分步式调入单' THEN (select TSKPJC.FNAME from T_STK_STKTRANSFERIN FBSDRD
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON FBSDRD.F_ULRD_BASE1=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='分步式调出单' THEN (select TSKPJC.FNAME from T_STK_STKTRANSFEROUT FBSDCD
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON FBSDCD.FXM=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='盘亏单' THEN (select TSKPJC.FNAME from T_STK_STKCOUNTLOSS a
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON a.F_ULRD_XIANGMU=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='其他出库单' THEN (select TSKPJC.FNAME from T_STK_MISDELIVERY a
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON a.F_ULRD_BASE=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='其他入库单' THEN (select TSKPJC.FNAME from T_STK_MISCELLANEOUS a
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON a.F_ULRD_BASE=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='直接调拨单' THEN (select TSKPJC.FNAME from T_STK_STKTRANSFERIN a
LEFT JOIN T_SAL_KF_PROJECTARCHIVES_L TSKPJC ON a.F_ULRD_XIANGMU=TSKPJC.FID AND TSKPJC.FLocaleID=2052
WHERE FBILLNO=t1.FBILLNO)
else ''
END) AS F_ULRD_Project,
(CASE
WHEN t1.FBILLNAME='分步式调入单' THEN (select TBML.FNAME from T_STK_STKTRANSFERIN FBSDRD
LEFT JOIN T_BD_MATERIAL_L TBML ON FBSDRD.F_ULRD_BASE2=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='分步式调出单' THEN (select TBML.FNAME from T_STK_STKTRANSFEROUT FBSDCD
LEFT JOIN T_BD_MATERIAL_L TBML ON FBSDCD.FLD=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='盘亏单' THEN (select TBML.FNAME from T_STK_STKCOUNTLOSS a
LEFT JOIN T_BD_MATERIAL_L TBML ON a.F_ULRD_LOUDONG=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='其他出库单' THEN (select TBML.FNAME from T_STK_MISDELIVERY a
LEFT JOIN T_BD_MATERIAL_L TBML ON a.F_ULRD_BASE1=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='其他入库单' THEN (select TBML.FNAME from T_STK_MISCELLANEOUS a
LEFT JOIN T_BD_MATERIAL_L TBML ON a.F_ULRD_BASE1=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
WHEN t1.FBILLNAME='直接调拨单' THEN (select TBML.FNAME from T_STK_STKTRANSFERIN a
LEFT JOIN T_BD_MATERIAL_L TBML ON a.F_ULRD_LOUDONG=TBML.FMATERIALID AND TBML.FLOCALEID=2052
WHERE FBILLNO=t1.FBILLNO)
else ''
END) AS F_ULRD_Loudong
into {0}
from {1} t1
";
sb.AppendFormat(strSql, tableName, strTable);
DBUtils.Execute(this.Context, sb.ToString());
}
public override void CloseReport()
{
//删除临时表
if (TempTableName == null || TempTableName.Length == 0)
{
return;
}
IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
dbservice.DeleteTemporaryTableName(this.Context, TempTableName);
base.CloseReport();
}
}
注:以上就是物料收发存汇总表增加字段的操作,代码仅供参考,请读者根据实际业务情况参考。
您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!
请选择打赏金币数 *