如何指定单据在物料收细明细表中的"收入"与"发出"方向
金蝶云社区-愚公移山
愚公移山
0人赞赏了该文章 985次浏览 未经作者许可,禁止转载编辑于2015年07月22日 17:18:49

本贴是重发贴,昨天回复的方法不能解决原来的问题
公司的项目要求是:将仓库物料先行调拔到生产车间的在制仓库,待生产入库后,再按产品BOM计算出应扣除车间在制仓库原材料库存。本功能已实现,但是在显示在制仓库物料的收发明细表时,原本该为”发出“方向的数据确计入到了”收入“方向,如论如何修改下面源程序的中指定”收入“与”发出方向“的标识都不能指向”发出”,请金碟公司的高手指点一下!

[System.ComponentModel.Description("将加工消耗单数量加入到物料收发明细表")]
public class jgxhdGetData : AbstractStockDetailGetData
{
public override void InitialFullField()
{
base.InitialFullField();
this.FEntryTable = "AJL_PRD_jgxhd_body"; //数据来源表
}
public override void GetFullSql(List lstSql)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine(base.GetInsertSql());
stringBuilder.AppendLine(" SELECT ");
stringBuilder.AppendLine(base.SelListFieldSql());
stringBuilder.AppendLine(" ,0 AS FORDERBY, "); //单据
stringBuilder.AppendLine(" 'O' AS FSTOCKIO, "); //指定为出库标识
stringBuilder.AppendLine(" ISNULL(TSE.FPRICE,0) AS FIOPRICE, "); //材料单价
stringBuilder.AppendLine(" ISNULL(TSE.FAMOUNT,0) AS FIOAMOUNT, "); //总金额(材料成本)
stringBuilder.AppendLine(" TSE.FMATERIALID AS FMATERIALID, "); //物料编号
stringBuilder.AppendLine(" ISNULL(TS.FCURRID,0) AS FCURRID, "); //结算货币
stringBuilder.AppendLine(" ISNULL(TSE.FAUXPROPID,0) AS FAUXPROPID, "); //辅助属性
stringBuilder.AppendLine(string.Format(" {0} AS FDATE, ", this.FFullDate)); //单据日期
stringBuilder.AppendLine(" TS.FCREATEDATE AS FCREATEDATE, "); //单据创建日期
stringBuilder.AppendLine(" ISNULL(TSE.FLOT_TEXT,' ') AS FLOTNO, "); //无用的一个字段
stringBuilder.AppendLine(" TSE.FSTOCKID AS FSTOCKID, "); //仓库
stringBuilder.AppendLine(" TSE.FWORKSHOPID AS FDEPARTMENTID, "); //车间
stringBuilder.AppendLine(" ISNULL(TSE.FSTOCKLOCID,0) AS FSTOCKLOCID, "); //库位
stringBuilder.AppendLine(" TSE.FSTOCKSTATUSID AS FSTOCKSTATUSID, "); //库存状态
stringBuilder.AppendLine(" TSE.FKEEPERTYPEID,TSE.FKEEPERID,TSE.FPRODUCEDATE,TSE.FEXPIRYDATE,ISNULL(TSE.FBOMID,0),");
stringBuilder.AppendLine(string.Format(" '{0}' AS FFORMID, ", "AJL_PRD_JGXHD"));

stringBuilder.AppendLine(string.Format(" '{0}' AS FBILLNAME, ", "加工消耗单")); //数据来源
stringBuilder.AppendLine(" TS.FID AS FBILLID, ");
stringBuilder.AppendLine(" TSE.FSEQ AS FBILLSEQID, ");
stringBuilder.AppendLine(" TS.FBILLNO AS FBILLNO, ");
stringBuilder.AppendLine(" TS.FBILLTYPE AS FBILLTYPE, ");
stringBuilder.AppendLine(" ISNULL(TSE.FMTONO, ' ') AS FMTONO, ");
stringBuilder.AppendLine(" 0 AS FBASEQCQTY, ");
stringBuilder.AppendLine(" 0 AS FBASEQCPRICE, ");
stringBuilder.AppendLine(" 0 AS FSECQCQTY, ");
stringBuilder.AppendLine(" TSE.FACTUALQTY AS FBASEINQTY, "); //主单位消耗数量
stringBuilder.AppendLine(" 0 AS FBASEINPRICE, ");
stringBuilder.AppendLine(" TSE.FACTUALQTY AS FSECINQTY, "); //辅单位消耗数量
stringBuilder.AppendLine(" 0 AS FBASEOUTQTY, ");
stringBuilder.AppendLine(" 0 AS FBASEOUTPRICE, ");
stringBuilder.AppendLine(" 0 AS FSECOUTQTY ");
stringBuilder.AppendLine(" FROM AJL_PRD_jgxhd_head TS "); //委外表头
stringBuilder.AppendLine(" INNER JOIN AJL_PRD_jgxhd_body TSE ON TSE.FID=TS.FID "); //委外表体
base.LinkMaterialTable(stringBuilder);
base.LinkStockTable(stringBuilder);
stringBuilder.AppendLine(" WHERE ");
stringBuilder.AppendLine(this.qzDateFilter);
stringBuilder.AppendLine(string.Format(" AND ({0}) ", this.comFilter));
lstSql.Add(new SqlObject(stringBuilder.ToString(), new List()));
this.GetQcDataSql(lstSql);
}
private void GetQcDataSql(List lstSql) //期初取数
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine(base.GetInsertQcSql());
stringBuilder.AppendLine(" SELECT ");
stringBuilder.AppendLine(base.QCSelListFieldSql());
stringBuilder.AppendLine(string.Format(" ,{0} AS FDATE, ", this.FFullDate));
stringBuilder.AppendLine(" -200 AS FORDERBY, ");
stringBuilder.AppendLine(" 'I' AS FSTOCKIO, ");

stringBuilder.AppendLine(" TSE.FMATERIALID AS FMATERIALID, ");
stringBuilder.AppendLine(" ISNULL(TSE.FAUXPROPID,0) AS FAUXPROPID, ");
stringBuilder.AppendLine(" ISNULL(TSE.FLOT_TEXT,' ') AS FLOTNO, ");
stringBuilder.AppendLine(" ISNULL(TSE.FMTONO, ' ') AS FMTONO, ");
stringBuilder.AppendLine(" TSE.FSTOCKID AS FSTOCKID, ");
stringBuilder.AppendLine(" ISNULL(TSE.FSTOCKLOCID,0) AS FSTOCKLOCID, ");
stringBuilder.AppendLine(" TSE.FSTOCKSTATUSID AS FSTOCKSTATUSID, ");
stringBuilder.AppendLine(" TSE.FKEEPERTYPEID,TSE.FKEEPERID,TSE.FPRODUCEDATE,TSE.FEXPIRYDATE,ISNULL(TSE.FBOMID,0),");
stringBuilder.AppendLine(" SUM(TSE.FACTUALQTY) AS FBASEQCQTY, ");
stringBuilder.AppendLine(" SUM(TSE.FACTUALQTY) AS FSECQCQTY ");
stringBuilder.AppendLine(" FROM AJL_PRD_jgxhd_head TS ");
stringBuilder.AppendLine(" INNER JOIN AJL_PRD_jgxhd_body TSE ON TSE.FID=TS.FID ");
base.LinkMaterialTable(stringBuilder);
base.LinkStockTable(stringBuilder);
stringBuilder.AppendLine(" WHERE ");
stringBuilder.AppendLine(this.qcDateFilter);
stringBuilder.AppendLine(string.Format(" AND ({0}) ", this.comFilter));
stringBuilder.AppendLine(base.GetGroupbyQcSql());
lstSql.Add(new SqlObject(stringBuilder.ToString(), new List()));
}
}