private string getLineId(IRptParams filter)
        {
            DynamicObjectCollection collection = filter.FilterParameter.CustomFilter["FLINEID"] as DynamicObjectCollection;

            if (collection == null || collection.Count <= 0)
            {
                return("");
            }

            List <long> cusIds = collection.Select(o => Convert.ToInt64(o["FLINEID_Id"])).ToList();

            return(string.Format("({0})", string.Join(",", cusIds)));
        }
Esempio n. 2
0
        private IEnumerable <DynamicObject> GetDynamicObjects(Context ctx, FormOperation oper = null)
        {
            string sql = GetSql(ctx);
            List <DynamicObject> objs = null;

            if (!string.IsNullOrEmpty(sql))
            {
                DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, sql);

                if (coll != null && coll.Count > 0)
                {
                    objs = coll.Select(o => (DynamicObject)o).ToList();

                    if (oper != null)
                    {
                        if (oper.Operation.ToUpper().CompareTo(SynOperationType.DELETE.ToString()) == 0)
                        {
                            objs.ForEach(o => o["FForbidStatus"] = "C");
                        }
                    }
                }
            }
            return(objs);
        }
Esempio n. 3
0
        public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e)
        {
            base.AfterConvert(e);
            //获取头数据
            var headEntity = e.Result.FindByEntityKey("FBillHead");

            //获取元数据 用于获取源单需要转化的动态集合
            object[]     pkids    = sourceDataCollection.Select(p => p["FID"]).Distinct().ToArray();
            FormMetadata metadata = MetaDataServiceHelper.Load(this.Context, "PAEZ_ICMO") as FormMetadata;

            DynamicObject[] objs = BusinessDataServiceHelper.Load(this.Context, pkids, metadata.BusinessInfo.GetDynamicObjectType());


            Entity FEntityWorkSeq = e.TargetBusinessInfo.GetEntity("FEntity");
            Entity FentityICMO    = e.TargetBusinessInfo.GetEntity("FEntityICMOIN");
            DynamicObjectCollection sourceProdPlanCollection = null;
            DynamicObjectCollection sourceICMOCollection     = null;

            foreach (var extendDataEntity in headEntity)
            {
                DynamicObjectCollection objectProdPlanCollect      = extendDataEntity["FEntity"] as DynamicObjectCollection;
                DynamicObjectCollection objectMetailICOMCollection = extendDataEntity["PAEZ_SHWorkMaterialIN"] as DynamicObjectCollection;

                for (int i = objectProdPlanCollect.Count - 1; i >= 0; i--)
                {
                    objectProdPlanCollect.RemoveAt(i);
                }

                DynamicObjectCollection objectICMO = null;
                foreach (var sourceItem in objs)
                {
                    sourceProdPlanCollection = sourceItem["PAEZ_ICMO_Entry_ProProcedure"] as DynamicObjectCollection;
                    sourceICMOCollection     = sourceItem["PAEZ_ICMO_Entry_ICItem"] as DynamicObjectCollection;
                }

                foreach (var sourceItem in sourceProdPlanCollection)
                {
                    DynamicObject objectProdPlan = new DynamicObject(FEntityWorkSeq.DynamicObjectType);
                    objectProdPlan["seq"] = sourceItem["seq"];
                    objectProdPlan["F_PAEZ_ProduceID_Id"] = sourceItem["F_PAEZ_ProduceID_Id"];
                    objectProdPlan["F_PAEZ_ProduceID"]    = sourceItem["F_PAEZ_ProduceID"];
                    objectProdPlan["F_PAEZ_Times"]        = sourceItem["F_PAEZ_Times"];
                    objectProdPlan["F_PAEZ_Equipment_Id"] = sourceItem["F_PAEZ_MachineID_Id"];
                    objectProdPlan["F_PAEZ_Equipment"]    = sourceItem["F_PAEZ_MachineID"];
                    objectProdPlan["F_PAEZ_Rolling"]      = sourceItem["F_PAEZ_Rolling"];
                    objectProdPlan["F_PAEZ_Notes"]        = sourceItem["F_PAEZ_Notes"];
                    objectProdPlanCollect.Add(objectProdPlan);
                }

                foreach (var sourceItem in sourceICMOCollection)
                {
                    DynamicObject sourceICMO = new DynamicObject(FentityICMO.DynamicObjectType);
                    sourceICMO["Seq"]                = sourceItem["seq"];
                    sourceICMO["F_PAEZ_Material"]    = sourceItem["F_PAEZ_ICItemID"];                   //原料代码
                    sourceICMO["F_PAEZ_Material_Id"] = sourceItem["F_PAEZ_ICItemID_Id"];                //ID
                    //        sourceICMO["F_PAEZ_BaseProperty"] = sourceItem["F_PAEZ_ICItemName"];                //原料名称
                    //       sourceICMO["F_PAEZ_BaseProperty2_Id"] = sourceItem["F_PAEZ_ICItemMaterial"];           //材质
                    sourceICMO["F_PAEZ_IcItemLevel"]       = sourceItem["F_PAEZ_IcItemLevel"];        //等级
                    sourceICMO["F_PAEZ_Model"]             = sourceItem["F_PAEZ_ICItemModel"];        //规格
                    sourceICMO["F_PAEZ_LotMa"]             = sourceItem["F_PAEZ_Lot"];                //批号
                    sourceICMO["F_PAEZ_ReelItemIN"]        = sourceItem["F_PAEZ_ICItemReelNO"];       //卷号
                    sourceICMO["F_PAEZ_MaWeight"]          = sourceItem["F_PAEZ_ICItemWeight"];       //重量
                    sourceICMO["F_PAEZ_UnitIDMAWeight"]    = sourceItem["F_PAEZ_ICItemWeightUNITID"]; //重量单位
                    sourceICMO["F_PAEZ_QtyMa"]             = sourceItem["F_PAEZ_IcItemQty"];          //数量
                    sourceICMO["F_PAEZ_UnitID1"]           = sourceItem["F_PAEZ_ICItemQtyUnitID"];    //数量单位
                    sourceICMO["F_PAEZ_MaWidth"]           = sourceItem["F_PAEZ_ICItemWidth"];        //宽度
                    sourceICMO["F_PAEZ_MaThickness"]       = sourceItem["F_PAEZ_ICItemThickness"];    //厚度
                    sourceICMO["F_PAEZ_MaLength"]          = sourceItem["F_PAEZ_ICItemLength"];       //长度
                    sourceICMO["F_PAEZ_MaWidthRE"]         = sourceItem["F_PAEZ_ICItemRefWidth"];     //参宽
                    sourceICMO["F_PAEZ_MaThicknessRE"]     = sourceItem["F_PAEZ_ICItemRefThickness"]; //參厚
                    sourceICMO["F_PAEZ_CCONTENTSItemIN"]   = sourceItem["F_PAEZ_ICItemCContents"];    //碳含量
                    sourceICMO["F_PAEZ_CRCONTENTSItemIN"]  = sourceItem["F_PAEZ_ICItemCRContents"];   //铬含量
                    sourceICMO["F_PAEZ_PRODUCTEDGEItemIN"] = sourceItem["F_PAEZ_ICItemEdge"];         //边部状况
                    //   sourceICMO["F_PAEZ_StockLot"] = sourceItem["F_PAEZ_LotStock"];                      //库存批次

                    objectMetailICOMCollection.Add(sourceICMO);
                }
            }
        }
        public override void DoExecute(Kingdee.BOS.Core.DynamicForm.IDynamicFormView targetView)
        {
            DynamicObjectCollection dataEntrys = targetView.Model.DataObject["PUR_ReceiveEntry"] as DynamicObjectCollection;

            if (dataEntrys == null || dataEntrys.Count == 0)
            {
                return;
            }
            List <long> poEntryIds = dataEntrys.Select(s => Convert.ToInt64(s["POORDERENTRYID"])).ToList();
            //内蒙出库的数量批号
            List <DynamicObject> outStockData = base.GetOutStockData(poEntryIds);

            //倒序搜索
            for (int row = dataEntrys.Count - 1; row >= 0; row--)
            {
                long poEntryId = Convert.ToInt64(dataEntrys[row]["POORDERENTRYID"]);
                List <DynamicObject> srcOutData = outStockData.Where(w => Convert.ToInt64(w["FENTRYID"]) == poEntryId).ToList();
                if (srcOutData == null || srcOutData.Count == 0)
                {
                    continue;
                }
                //给默认携带行赋值
                targetView.Model.SetValue("FActReceiveQty", srcOutData[0]["FREALQTY"], row);
                targetView.Model.SetValue("FUNITID", srcOutData[0]["FUNITID"], row);
                targetView.Model.SetValue("FLot", srcOutData[0]["FLOT_TEXT"], row);
                targetView.Model.SetValue("FJNUnitEnzymes", srcOutData[0]["FJNUnitEnzymes"], row);
                targetView.Model.SetValue("FExtAuxUnitQty", srcOutData[0]["FAuxUnitQty"], row);
                targetView.InvokeFieldUpdateService("FActReceiveQty", row);
                targetView.InvokeFieldUpdateService("FLot", row);
                //出库数据排除第一行,按照序号倒排
                srcOutData.RemoveAt(0);
                if (srcOutData == null || srcOutData.Count == 0)
                {
                    continue;
                }
                srcOutData = srcOutData.OrderByDescending(o => o["FID"]).ThenByDescending(o => o["FSEQ"]).ToList();
                for (int i = 0; i < srcOutData.Count; i++)
                {
                    targetView.Model.CopyEntryRowFollowCurrent("FDetailEntity", row, row, true);
                    targetView.Model.SetValue("FActReceiveQty", srcOutData[i]["FREALQTY"], row + 1);
                    targetView.Model.SetValue("FUNITID", srcOutData[i]["FUNITID"], row + 1);
                    targetView.Model.SetValue("FLot", srcOutData[i]["FLOT_TEXT"], row + 1);
                    targetView.Model.SetValue("FJNUnitEnzymes", srcOutData[i]["FJNUnitEnzymes"], row + 1);
                    targetView.Model.SetValue("FExtAuxUnitQty", srcOutData[i]["FAuxUnitQty"], row + 1);
                    //其他字段赋值
                    targetView.Model.SetValue("FSrcFormId", targetView.Model.GetValue("FSrcFormId", row), row + 1);
                    targetView.Model.SetValue("FSRCBillNo", targetView.Model.GetValue("FSRCBillNo", row), row + 1);
                    targetView.Model.SetValue("FOrderBillNo", targetView.Model.GetValue("FOrderBillNo", row), row + 1);
                    targetView.Model.SetValue("FSrcId", targetView.Model.GetValue("FSrcId", row), row + 1);
                    targetView.Model.SetValue("FSrcEntryId", targetView.Model.GetValue("FSrcEntryId", row), row + 1);
                    targetView.Model.SetValue("FPOORDERENTRYID", targetView.Model.GetValue("FPOORDERENTRYID", row), row + 1);
                    targetView.Model.SetValue("FBFLowId", targetView.Model.GetValue("FBFLowId", row), row + 1);
                    targetView.InvokeFieldUpdateService("FActReceiveQty", row + 1);
                    targetView.InvokeFieldUpdateService("FLot", row + 1);
                    //保质期为空,默认当前日期
                    if (targetView.Model.GetValue("FProduceDate", row + 1) == null)
                    {
                        targetView.Model.SetValue("FProduceDate", DateTime.Now.Date, row + 1);
                        targetView.InvokeFieldUpdateService("FProduceDate", row + 1);
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 入库日期校验
        /// </summary>
        /// <param name="date"></param>
        /// <param name="linkData"></param>
        private string dateValitor(DateTime date, DynamicObjectCollection linkData)
        {
            string billNo = "";
            string sql    = string.Format("select FDATE,FBILLNO from T_PUR_Receive where FID in ({0})", string.Join(",", linkData.Select(s => Convert.ToInt32(s["SBillId"]))));
            DynamicObjectCollection reData = DBUtils.ExecuteDynamicObject(this.Context, sql);

            if (reData.Any(a => date < Convert.ToDateTime(a["FDATE"])))
            {
                billNo = Convert.ToString(reData.FirstOrDefault(f => date < Convert.ToDateTime(f["FDATE"]))["FBILLNO"]);
            }
            //foreach (DynamicObject item in linkData)
            //{
            //    int receiveId = Convert.ToInt32(item["SBillId"]);
            //    if (item["sTableName"].ToString() != "T_PUR_ReceiveEntry") continue;//跳过非收料单下推
            //    string sql = string.Format("select FDATE,FBILLNO from T_PUR_Receive where FID={0}", receiveId);
            //    DynamicObjectCollection reData = DBUtils.ExecuteDynamicObject(this.Context, sql);
            //    if (reData == null || reData.Count == 0) continue;
            //    DateTime receiveDate = Convert.ToDateTime(reData[0]["FDATE"]);
            //    if (date < receiveDate)
            //    {
            //        billNo = reData[0]["FBILLNO"].ToString();
            //        break;
            //    }
            //}
            return(billNo);
        }
        /// <summary>
        /// 校验逻辑实现
        /// </summary>
        /// <param name="dataEntities"></param>
        /// <param name="validateContext"></param>
        /// <param name="ctx"></param>
        public override void Validate(Kingdee.BOS.Core.ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Kingdee.BOS.Context ctx)
        {
            if (dataEntities == null)
            {
                return;
            }

            var enProp = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryName;

            this.EntityKey = enProp;
            var orgFldKey = validateContext.BusinessInfo.MainOrgField.Key;

            foreach (var dataEntity in dataEntities)
            {
                string billType = dataEntity["FBillTypeID_Id"].ToString();
                if (!(billType == "005056c00008baa211e3097d9bc0332e" || billType == "005056945db184ed11e3af2dcda7ee49"))
                {
                    continue;                                                                                                     //产品检验单\自制工序检验单
                }
                DynamicObjectCollection rows = dataEntity[enProp] as DynamicObjectCollection;
                if (rows == null || rows.Count <= 0)
                {
                    continue;
                }

                //取酶活量大于零的
                var checkRows = rows.Where(f => Convert.ToDecimal(f["FJNUnitEnzymes"]) > 0).ToList();
                if (checkRows == null || checkRows.Count() <= 0)
                {
                    continue;
                }

                //先查本单的数据
                var grp1 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p["MaterialId_Id"].ToString()),
                    AuxId = long.Parse(p["AuxPropId_Id"].ToString()),
                    LotNumber = Convert.ToString(p["Lot_Text"]),
                    UnitEnzymes = Convert.ToDecimal(p["FJNUnitEnzymes"])
                }).Distinct().ToList();

                var grp2 = (from p in checkRows
                            select new
                {
                    OrgID = long.Parse(dataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"].ToString()),
                    MatId = long.Parse(p["MaterialId_Id"].ToString()),
                    AuxId = long.Parse(p["AuxPropId_Id"].ToString()),
                    LotNumber = Convert.ToString(p["Lot_Text"])
                }).Distinct().ToList();

                if (grp1.Count != grp2.Count)
                {
                    validateContext.AddError(dataEntity.DataEntity,
                                             new ValidationErrorInfo("FBillNo",
                                                                     Convert.ToString(((DynamicObject)(dataEntity.DataEntity))["Id"]),
                                                                     dataEntity.DataEntityIndex,
                                                                     dataEntity.RowIndex,
                                                                     "JN-InStockCheck-002",
                                                                     string.Format("保存失败:启用双计量单位的物料,公司+物料+辅助属性+批号所对应的单位酶活量有多个!", dataEntity.BillNo),
                                                                     "金蝶提示", ErrorLevel.Warning));
                    continue;
                }

                //查数据库后台的数据
                foreach (var item in checkRows)
                {
                    var matVal = item["MaterialId"] as DynamicObject;
                    if (matVal == null)
                    {
                        continue;
                    }
                    CheckPara para = new CheckPara();
                    para.lotNumber = item["Lot_Text"].ToString();
                    if (para.lotNumber.Length == 0)
                    {
                        continue;
                    }
                    DynamicObjectCollection linkData = item["FEntity_Link"] as DynamicObjectCollection;
                    para.tableName     = linkData[0]["sTableName"].ToString();
                    para.linkId        = string.Join(",", linkData.Select(s => Convert.ToInt32(s["SBillId"])));
                    para.currEnFldName = validateContext.BusinessInfo.GetField(matFldKey).Entity.EntryPkFieldName;
                    para.orgId         = Convert.ToInt64(dataEntity.DataEntity[validateContext.BusinessInfo.MainOrgField.PropertyName + "_Id"]);
                    para.matId         = Convert.ToInt64(matVal["Id"]);
                    var aux = item["AuxPropId"] as DynamicObject;
                    if (aux != null)
                    {
                        para.auxPropId = Convert.ToInt64(aux["Id"]);
                    }

                    para.unitEnzymes    = Convert.ToDecimal(item["FJNUnitEnzymes"]);
                    para.currentEntryId = Convert.ToInt64(item["Id"]);
                    para.currFormKey    = validateContext.BusinessInfo.GetForm().Id;
                    para.ctx            = ctx;

                    string errInfor = "";
                    if (CheckExists(para, out errInfor))
                    {
                        validateContext.AddError(dataEntity.DataEntity,
                                                 new ValidationErrorInfo("FBillNo",
                                                                         Convert.ToString(dataEntity.DataEntity["Id"]),
                                                                         dataEntity.DataEntityIndex,
                                                                         dataEntity.RowIndex,
                                                                         "JN-InStockCheck-002",
                                                                         string.Format("保存失败:第{1}行物料,启用双计量单位,公司+物料+辅助属性+批号所对应的单位酶活量有多个({0})!", errInfor, rows.IndexOf(item) + 1),
                                                                         "金蝶提示", ErrorLevel.Warning));
                        continue;
                    }
                }
            }
        }