制造业生产流程智能管控_金蝶企业生产管理系统4折优惠
这个问题刚开始研究,一直以为是一个独立的动态表单的形式,后面经过分析,发现他们都是公用的即时库存单据。这样使得我们想要更改单独的单据库存查询结果成为困难。
添加扩展字段步骤:
1、首先要在即时库存单据添加需要显示的字段
2、调整对应的默认查询规则,使得添加的字段在列表中显示,这个步骤很关键
3、开始添加逻辑。这个需要我们写代码实现,这里我们用的是列表扩展插件的方式,话不多说上点代码:
public class QueryStockServiceEX : AbstractListPlugIn
{
public override void BeforeGetDataForTempTableAccess(BeforeGetDataForTempTableAccessArgs e)
{
if (ColExist(e.TableName,new List() { “FSTOCKORGID_ID”,”FMATERIALID_ID”, “FAvailableQty” }))
{
string sql = string.Format(@”/*dialect*/select FAvailableQty,fstockorgid_id,fstockid_id,fmaterialid_id,fstockunitid_id,
a.flot_id,b.FNUMBER as flot,c.FMASTERID as FMASTERID_id from {0} as a
left join T_BD_LOTMASTER as b on b.FLOTID=a.flot_id
left join T_BD_MATERIAL as c on c.FMATERIALID = a.fmaterialid_id”, e.TableName);
DataSet ds = DBUtils.ExecuteDataSet(this.Context, sql);
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dtrow in ds.Tables[0].Rows)
{
long fstockorgid_id = Convert.ToInt64(dtrow[“fstockorgid_id”]);
long fstockid_id = Convert.ToInt64(dtrow[“fstockid_id”]);
long fmaterialid_id = Convert.ToInt64(dtrow[“fmaterialid_id”]);
long FMASTERID_id = Convert.ToInt64(dtrow[“FMASTERID_id”]);
string flot = Convert.ToString(dtrow[“flot”]);
long fstockunitid_id = Convert.ToInt64(dtrow[“fstockunitid_id”]);
//在插件上面获取物料的预计可发量的方法
ListqueryExpectQtyArgs = new List();
queryExpectQtyArgs.Add(new GetExpectQtyArgs()
{
StockOrgId = fstockorgid_id,
StockId = fstockid_id,
MaterialId = fmaterialid_id,
MaterialMasterId = FMASTERID_id,
LotText = flot,
UnitId = fstockunitid_id
});
///
/// 获取预计量(可发量)
///
///上下文
///查询参数
///预计量(可发量)列表
Listresults = ExpectQtyQueryServiceHelper.GetExpectQty(this.Context, queryExpectQtyArgs);
//返回结果说明
//ExpectBaseUnitQty 预计基本单位量(可发量 = 即时库存 + 预计入 – 预计出)
//ExpectInBaseUnitQty 预计入基本单位数量(待入量)
//ExpectInQty 预计入数量(待入量)
//ExpectOutBaseUnitQty 预计出基本单位数量(待发量)
//ExpectOutQty 预计出数量(待发量)
//ExpectQty 预计量(可发量 = 即时库存 + 预计入 – 预计出)
//LockBaseQty
//LockQty
string sqlText = string.Format(@”MERGE INTO {0} a
USING(SELECT m.FMATERIALID,m.FMASTERID,m.FUSEORGID,ISNULL(m1.FNAME,”) FNAME
FROM T_BD_MATERIAL m
LEFT JOIN T_BD_MATERIAL_L m1 ON m1.FMATERIALID=m.FMATERIALID AND m1.FLOCALEID={1}) AS b
ON b.FMASTERID = a.FMATERIALID_ID AND b.FUSEORGID = a.FSTOCKORGID_ID
WHEN MATCHED THEN UPDATE SET a.FAvailableQty = 1;
“, e.TableName,this.Context.UserLocale.LCID);
DBServiceHelper.Execute(this.Context,sqlText);
}
}
}
}
private bool ColExist(string tableName, Listlist)
{
string sqlText = string.Format(@”/*dialect*/select count(*) countNum from syscolumns where id=OBJECT_ID(‘{0}’) AND name IN(‘{1}’)”,
tableName, string.Join(“‘,'”, list));
int count = DBServiceHelper.ExecuteScalar(this.Context,sqlText,0);
return count == list.Count;
}
现在代码也有了,我们就只需要验证和发布了。
测试,完美解决问题