示例#1
0
        /// <summary>
        /// 来源单获取日期
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="billData"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        public DynamicObjectCollection GetBillDataEntryDate(Kingdee.BOS.Context ctx,
                                                            DynamicObject billData,
                                                            JNQTYRatePara para)
        {
            var formKey   = billData["FBILLFORMID"].ToString();
            var lotFldKey = billData["FLOTFIELDKEY"].ToString();
            var billId    = billData["FBILLID"].ToString();
            var matFldKey = "FMaterialId";
            var lotid     = billData["flotid"].ToString();
            var matid     = billData["FMaterialId"].ToString();
            QueryBuilderParemeter qbPara = new QueryBuilderParemeter();

            qbPara.FormId = formKey;
            qbPara.FilterClauseWihtKey = string.Format(" fid ={0} And {1} ={2} And {3}.FNumber ='{4}' And FAuxPropId={5} ",
                                                       billId, lotFldKey, lotid, matFldKey, para.MaterialNumber, para.AuxPropId);
            qbPara.SelectItems = SelectorItemInfo.CreateItems("FPRODUCEDATE,FEXPIRYDATE");
            DynamicObjectCollection datas = null;

            try
            {
                datas = Kingdee.BOS.ServiceHelper.QueryServiceHelper.GetDynamicObjectCollection(ctx, qbPara);
            }
            catch (Exception ex)
            {
                return(datas);
            }
            return(datas);
        }
示例#2
0
        /// <summary>
        /// 获取物料对应批次号的生产日期、有限期至
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        public DynamicObjectCollection GetLotExpiryDate(Context ctx, JNQTYRatePara para)
        {
            //批号跟踪里面取
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("select a.FBILLFORMID ,a.FBILLNO,a.FBILLID ,a.FBILLENTRYID ,a.FLOTFIELDKEY,a.flotid,b.FMaterialId ");
            sql.AppendLine("from T_BD_LOTMASTERBILLTRACE a ");
            sql.AppendLine("inner join T_BD_LOTMASTER b on a.flotid=b.flotid ");
            sql.AppendLine("inner join T_BD_Material c on b.FMaterialId=c.FMaterialId ");
            sql.AppendFormat("where a.FSTOCKDIRECT=1 and c.FNumber ='{0}' and b.FNUMBER ='{1}' ", para.MaterialNumber, para.LotNumber);
            if (para.OrgId > 0)
            {
                sql.AppendFormat(" and b.FCreateOrgId={0} ", para.OrgId);
            }
            sql.AppendLine("order by finstockdatetmp desc");
            var traceData = DBUtils.ExecuteDynamicObject(ctx, sql.ToString());
            DynamicObjectCollection date = null;

            if (traceData != null && traceData.Count > 0)
            {
                foreach (var item in traceData)
                {
                    date = GetBillDataEntryDate(ctx, item, para);
                }
            }
            return(date);
        }
示例#3
0
        /// <summary>
        /// 来源单获取单位酶活
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="billData"></param>
        /// <param name="para"></param>
        /// <returns></returns>
        private decimal GetBillDataEntryRate(Kingdee.BOS.Context ctx,
                                             DynamicObject billData,
                                             JNQTYRatePara para)
        {
            var formKey   = billData["FBILLFORMID"].ToString();
            var lotFldKey = billData["FLOTFIELDKEY"].ToString();
            var billId    = billData["FBILLID"].ToString();
            var matFldKey = "FMaterialId";
            var lotid     = billData["flotid"].ToString();
            var matid     = billData["FMaterialId"].ToString();

            QueryBuilderParemeter qbPara = new QueryBuilderParemeter();

            qbPara.FormId = formKey;
            qbPara.FilterClauseWihtKey = string.Format(" fid ={0} And {1} ={2} And {3}.FNumber ='{4}' And FAuxPropId={5} ",
                                                       billId, lotFldKey, lotid, matFldKey, para.MaterialNumber, para.AuxPropId);
            //放到批号主档里过滤
            //if (para.OrgId > 0)
            //{
            //    qbPara.FilterClauseWihtKey +=string.Format ( " And {0}={1} ", GetOrgFldKey( ctx,formKey),para.OrgId );
            //}
            qbPara.SelectItems = SelectorItemInfo.CreateItems("FJNUnitEnzymes");
            try
            {
                DynamicObjectCollection datas = Kingdee.BOS.ServiceHelper.QueryServiceHelper.GetDynamicObjectCollection(ctx, qbPara);
                if (datas != null && datas.Count > 0)
                {
                    return(Convert.ToDecimal(datas[0]["FJNUnitEnzymes"]));
                }
            }
            catch (Exception ex)
            {
                return(0);
            }

            return(0);
        }
示例#4
0
        /// <summary>
        /// 获取物料对应批次号的单位酶活量
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="materialId"></param>
        /// <param name="lotNo"></param>
        /// <returns></returns>
        public decimal MaterialUnitEnzymes(Kingdee.BOS.Context ctx, JNQTYRatePara para)
        {
            //批号跟踪里面取
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("select a.FBILLFORMID ,a.FBILLNO,a.FBILLID ,a.FBILLENTRYID ,a.FLOTFIELDKEY,a.flotid,b.FMaterialId ");
            sql.AppendLine("from T_BD_LOTMASTERBILLTRACE a ");
            sql.AppendLine("inner join T_BD_LOTMASTER b on a.flotid=b.flotid ");
            sql.AppendLine("inner join T_BD_Material c on b.FMaterialId=c.FMaterialId ");
            sql.AppendFormat("where a.FSTOCKDIRECT=1 and c.FNumber ='{0}' and b.FNUMBER ='{1}' ", para.MaterialNumber, para.LotNumber);
            if (para.OrgId > 0)
            {
                sql.AppendFormat(" and b.FCreateOrgId={0} ", para.OrgId);
            }
            sql.AppendLine("order by finstockdatetmp desc");



            var traceData = DBUtils.ExecuteDynamicObject(ctx, sql.ToString());

            if (traceData != null && traceData.Count > 0)
            {
                decimal rate = 0;
                foreach (var item in traceData)
                {
                    rate = GetBillDataEntryRate(ctx, item, para);
                    if (rate > 0)
                    {
                        return(rate);
                    }
                }
            }

            //找不到就到物料的单位换算里面找
            return(GetMatUnitRate(ctx, para.MaterialId));
        }
示例#5
0
        public override void AfterConvert(AfterConvertEventArgs e)
        {
            base.AfterConvert(e);

            if (ConvertFldKey == null || ConvertFldKey.Count == 0)
            {
                return;
            }

            Field lotFld = e.TargetBusinessInfo.GetField(this.LotNoFldKey);
            Field matFld = e.TargetBusinessInfo.GetField(this.MatFldKey);
            Field auxFld = e.TargetBusinessInfo.GetField(this.AuxPropFldKey);
            Field OrgFld = e.TargetBusinessInfo.GetField(this.OrgIdFldKey);//增加组织属性

            if (lotFld == null || matFld == null)
            {
                return;
            }



            ExtendedDataEntity[] HandDatas = e.Result.FindByEntityKey(OrgFld.EntityKey);//获取表单字段
            long OrgVal = 0;

            foreach (ExtendedDataEntity HandData in HandDatas)
            {
                if (OrgFld != null)//取组织值
                {
                    var Org = OrgFld.GetFieldValue(HandData.DataEntity) as DynamicObject;
                    if (Org != null)
                    {
                        OrgVal = Convert.ToInt64(Org["Id"]);
                    }
                }
                ExtendedDataEntity[] dataEntities = e.Result.FindByEntityKey(lotFld.EntityKey);
                foreach (ExtendedDataEntity item in dataEntities)
                {
                    var lotVal = lotFld.GetFieldValue(item.DataEntity);
                    if (lotVal == null || string.IsNullOrEmpty(lotVal.ToString()))
                    {
                        continue;
                    }
                    var matVal = matFld.GetFieldValue(item.DataEntity) as DynamicObject;
                    if (matVal == null)
                    {
                        continue;
                    }


                    JNQTYRatePara para = new JNQTYRatePara();
                    para.MaterialId     = Convert.ToInt64(matVal["Id"]);
                    para.MaterialNumber = Convert.ToString(matVal["Number"]);
                    para.LotNumber      = lotVal.ToString();
                    para.OrgId          = OrgVal;


                    if (auxFld != null)
                    {
                        var aux = auxFld.GetFieldValue(item.DataEntity) as DynamicObject;
                        if (aux != null)
                        {
                            para.AuxPropId = Convert.ToInt64(aux["Id"]);
                        }
                    }



                    decimal rate = YDLCommServiceHelper.MaterialUnitEnzymes(this.Context, para);
                    if (rate == 0)
                    {
                        continue;
                    }

                    foreach (var fld in ConvertFldKey)
                    {
                        Field srcQtyFld  = e.TargetBusinessInfo.GetField(fld.SrcQtyFldKey);
                        Field destQtyFld = e.TargetBusinessInfo.GetField(fld.DestQtyFldKey);
                        Field rateFld    = e.TargetBusinessInfo.GetField(fld.ConverRateFldKey);

                        if (srcQtyFld == null || destQtyFld == null || rateFld == null)
                        {
                            continue;
                        }

                        decimal srcQty = Convert.ToDecimal(srcQtyFld.DynamicProperty.GetValue(item.DataEntity));
                        rateFld.DynamicProperty.SetValue(item.DataEntity, rate);
                        destQtyFld.DynamicProperty.SetValue(item.DataEntity, rate * srcQty);
                    }
                }
            }
        }