/*
1、在物料收发汇总表过滤界面的期初参考价来源中添加枚举值;
2、开发服务端插件,参考如下示例代码。注册插件后,需要停用原有插件。
*/
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.K3.SCM.App.Stock.Report;
using System;
using System.Collections.Generic;
using System.Data;
namespace CustomerPluginService
{
public class StockSummaryRptTestRpt : StockSummaryRpt
{
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
{
base.BuilderReportSqlAndTempTable(filter, tableName);
var dyFilter = filter.FilterParameter.CustomFilter;
this.qcSrcPrice = (StockRptEnums.Enu_QcSrcPrice)Convert.ToInt32(dyFilter["QCPriceSource"]);
this.ioSrcPrice = (StockRptEnums.Enu_IoSrcPrice)Convert.ToInt32(dyFilter["IOPriceSource"]);
//如果选择了自定义期初参考价来源
if (Convert.ToInt32(dyFilter["QCPriceSource"]) == 6)
{
IDBService service = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
string tmpDataTbl = service.CreateTemporaryTableName(this.Context);
//获取新的期初参考价,并存到临时表tmpDataTbl
/*
* 获取期初参考价逻辑
*/
//如果收入发出成本价选择了期初参考价,则收入发出成本价金额也要做更新
string updateIOPriceAmountSql = "";
if (((StockRptEnums.Enu_IoSrcPrice)Convert.ToInt32(dyFilter["IOPriceSource"])) == StockRptEnums.Enu_IoSrcPrice.KdQcPrice)
{
updateIOPriceAmountSql = ",T0.FBASEINPRICE=T1.FBASEINPRICE,T0.FINAMOUNT=T0.FBASEINQTY*T1.FBASEINPRICE,发出成本....";
}
//查询数据并插入新表返回平台
//结存金额=期初金额+收入金额-发出金额
//结存参考价=结存金额/结存数量
string sqlText = string.Format(@"MERGE INTO {0} T0 USING {1} T1
ON (两个表关联字段 )
WHEN MATCHED THEN UPDATE
SET T0.FBASEQCPRICE = T1.FBASEQCPRICE,
T0.FSTOCKQCPRICE = T1.FSTOCKQCPRICE,
T0.FQCAMOUNT=T0.FBASEQCQTY*T1.FBASEQCPRICE......{2}"
, tableName, tmpDataTbl,updateIOPriceAmountSql);
DBUtils.Execute(this.Context, sqlText);
}
}
}
}
推荐阅读