private void FillReferDetail(ExtendedDataEntity[] entityDataes, DynamicObject billTypePara) { FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true); EntryEntity entryEntity = metadata.BusinessInfo.GetEntryEntity("FReferDetail"); List <long> srcEntryIds = (from s in entityDataes from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>(); string businessType = billTypePara.GetDynamicObjectItemValue <string>("FInspectType", null); DynamicObjectCollection col = this.GetSrcInfo(base.Context, srcEntryIds, businessType); if (!col.IsEmpty <DynamicObject>()) { foreach (ExtendedDataEntity entity2 in entityDataes) { DynamicObject dataEntity = entity2.DataEntity; DynamicObjectCollection objects2 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("ReferDetail", null); objects2.Clear(); DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicObjectItemValue <DynamicObjectCollection>("FEntity_Link", null); int num = 1; foreach (DynamicObject obj2 in objects3) { InspectBillView.FEntity_Link link = obj2; foreach (DynamicObject obj3 in (from w in col where w.GetDynamicObjectItemValue <string>("FTEID", null) == link.SId select w).ToList <DynamicObject>()) { InspectBillView.ReferDetail detail = new Kingdee.K3.MFG.Common.BusinessEntity.QM.InspectBillView.ReferDetail(new DynamicObject(entryEntity.DynamicObjectType)) { Seq = num++, SrcBillType = obj3.GetDynamicObjectItemValue <string>("FSRCBILLTYPE", null), SrcBillNo = obj3.GetDynamicObjectItemValue <string>("FSRCBILLNO", null), SrcInterId = Convert.ToInt64(link.SBillId), SrcEntryId = Convert.ToInt64(link.SId), SrcEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FSRCENTRYSEQ", 0), OrderType_Id = obj3.GetDynamicObjectItemValue <string>("FORDERBILLTYPE", null), OrderBillNo = obj3.GetDynamicObjectItemValue <string>("FORDERBILLNO", null), OrderId = obj3.GetDynamicObjectItemValue <long>("FORDERID", 0L), OrderEntryId = obj3.GetDynamicObjectItemValue <long>("FORDERENTRYID", 0L), OrderEntrySeq = (long)obj3.GetDynamicObjectItemValue <int>("FORDERENTRYSEQ", 0) }; objects2.Add((DynamicObject)detail); } } } } }
/// <summary> /// 单据转换后事件 /// </summary> /// <param name="e"></param> public override void AfterConvert(Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args.AfterConvertEventArgs e) { base.AfterConvert(e); ExtendedDataEntity[] assemblies = e.Result.FindByEntityKey("FBillHead");//下游单据 foreach (ExtendedDataEntity extendedDataEntity in assemblies) { DynamicObject parents = extendedDataEntity.DataEntity as DynamicObject; DynamicObjectCollection Entry = parents["Entity"] as DynamicObjectCollection;//主表体 if (Entry == null || Entry.Count == 0) { continue; } foreach (DynamicObject item in Entry) { long qcschemeId = Convert.ToInt64(item["QCSchemeId_Id"]); //质检方案Id string sql = string.Format(@"select A.FINSPECTITEMID,B.FSAMPLESCHEMEID,B.FANALYSISMETHOD,B.FDEFECTLEVEL,B.FDESTRUCTINSPECT, B.FKEYINSPECT,B.FQUALITYSTDID,B.FINSPECTMETHODID,B.FINSPECTINSTRUMENTID,B.FINSPECTBASISID,B.FUNITID from T_QM_QCSCHEMEENTRY A inner join T_QM_INSPECTITEM B on A.FINSPECTITEMID=B.FID where A.FID={0}", qcschemeId); DynamicObjectCollection inspectItem = DBUtils.ExecuteDynamicObject(this.Context, sql, null, null, System.Data.CommandType.Text, null); //检验项目 if (inspectItem == null || inspectItem.Count == 0) { continue; } DynamicObjectCollection inspectEntry = item["ItemDetail"] as DynamicObjectCollection;//检验项目子单据体 foreach (DynamicObject inspect in inspectItem) { DynamicObject newData = inspectEntry.DynamicCollectionItemPropertyType.CreateInstance() as DynamicObject;//新建子单据体分录 newData["InspectItemId_Id"] = inspect["FINSPECTITEMID"]; newData["SampleSchemeId_Id"] = inspect["FSAMPLESCHEMEID"]; newData["AnalysisMethod"] = inspect["FANALYSISMETHOD"]; newData["DefectLevel1"] = inspect["FDEFECTLEVEL"]; newData["DestructInspect"] = Convert.ToInt32(inspect["FDESTRUCTINSPECT"]) == 0 ? false : true; newData["KeyInspect"] = Convert.ToInt32(inspect["FKEYINSPECT"]) == 0 ? false : true; newData["QualityStdId_Id"] = inspect["FQUALITYSTDID"]; newData["InspectMethodId_Id"] = inspect["FINSPECTMETHODID"]; newData["InspectInstrumentId_Id"] = inspect["FINSPECTINSTRUMENTID"]; newData["InspectBasisId_Id"] = inspect["FINSPECTBASISID"]; newData["UnitId_Id"] = inspect["FUNITID"]; inspectEntry.Add(newData); } } Kingdee.BOS.Contracts.ServiceFactory.GetService <IDBService>(this.Context).LoadReferenceObject(this.Context, new DynamicObject[] { parents }, e.TargetBusinessInfo.GetDynamicObjectType(), false);//重新加载一次信息,刷新出基础资料(当基础资料只有ID有值时) } }
private void RefreshErrEntity(StockOrgOperateResult opResult, ErrType errType) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FEntityErrInfo"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((errType == ErrType.Minus) || (errType == ErrType.None)) || ((errType == ErrType.UnAuditStkCountBill) || (errType == ErrType.StkDraftBill))) { this.View.UpdateView("FEntityErrInfo"); } else if (((opResult == null) || (opResult.ErrInfo == null)) || (opResult.ErrInfo.Count < 1)) { this.View.UpdateView("FEntityErrInfo"); } else { IEnumerable <OperateErrorInfo> enumerable; if (errType == ErrType.UnAuditBill) { enumerable = from p in opResult.ErrInfo where p.ErrType == Convert.ToInt32(ErrType.UnAuditBill) select p; } else { enumerable = from p in opResult.ErrInfo where p.ErrType < Convert.ToInt32(ErrType.OrgStatusErr) select p; } foreach (OperateErrorInfo info in enumerable) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["ErrType"] = info.ErrType, ["ErrObjType"] = info.ErrObjType, ["ErrObjKeyField"] = info.ErrObjKeyField, ["ErrObjKeyID"] = info.ErrObjKeyID, ["ErrMsg"] = info.ErrMsg }; entityDataObject.Add(item); } this.View.UpdateView("FEntityErrInfo"); } }
/// <summary> /// 获取表单数据 /// </summary> /// <returns></returns> public DynamicObjectCollection DB_GetFormDatas() { string[] tb = FormIdToTbNameMap[this.View.GetFormId()]; bool hasEntry = tb[1] == "" ? false : true; DynamicObjectCollection datas; if (hasEntry) { datas = this.View.Model.DataObject["FEntity"] as DynamicObjectCollection; } else { BusinessInfo info = this.View.Model.BillBusinessInfo; datas = new DynamicObjectCollection(this.View.Model.DataObject.DynamicObjectType); datas.Add(this.View.Model.DataObject); } return(datas); }
private void RefreshMinusEntry(StockOrgOperateResult opResult, ErrType errType) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FMinusEntry"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((opResult != null) && (opResult.MinusErrObject != null)) && (((DynamicObjectCollection)opResult.MinusErrObject["Entry"]).Count > 0)) { foreach (DynamicObject obj2 in (DynamicObjectCollection)opResult.MinusErrObject["Entry"]) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["ErrMessage"] = obj2["ErrMessage"], ["MaterialNumber"] = obj2["MaterialNumber"], ["MaterialName"] = obj2["MaterialName"], ["Specification"] = obj2["Specification"], ["StockName"] = obj2["StockName"], ["StockLocName"] = obj2["StockLocName"], ["UnitName"] = obj2["UnitName"], ["Qty"] = obj2["Qty"], ["SecUnitName"] = obj2["SecUnitName"], ["SecQty"] = obj2["SecQty"], ["LotText"] = obj2["LotText"], ["AuxPropName"] = obj2["AuxPropName"], ["BOMNumber"] = obj2["BOMNumber"], ["MtoNo"] = obj2["MtoNo"], ["ProjectNo"] = obj2["ProjectNo"], ["ProduceDate"] = obj2["ProduceDate"], ["ExpiryDate"] = obj2["ExpiryDate"], ["StockStatusName"] = obj2["StockStatusName"], ["OwnerTypeName"] = obj2["OwnerTypeName"], ["OwnerName"] = obj2["OwnerName"], ["KeeperTypeName"] = obj2["KeeperTypeName"], ["KeeperName"] = obj2["KeeperName"] }; entityDataObject.Add(item); } } this.View.UpdateView("FMinusEntry"); }
private DynamicObject CreateLogDy(Context ctx, BeginOperationTransactionArgs e) { DynamicObject obj2 = null; if (e.DataEntitys.Count <DynamicObject>() <= 0) { return(obj2); } FormMetadata metadata = ServiceHelper.GetService <IMetaDataService>().Load(ctx, "BM_BUDGETCTRLLOG", true) as FormMetadata; BusinessInfo businessInfo = metadata.BusinessInfo; DynamicObject obj3 = (DynamicObject)metadata.BusinessInfo.GetDynamicObjectType().CreateInstance(); obj3["BillFormID_Id"] = " "; obj3["FBillNo"] = " "; obj3["OperationId"] = 3; obj3["OperationNumber"] = "Delete"; obj3["FCreateDate"] = DateTime.Now; obj3["FCreatorId_Id"] = ctx.UserId; obj3["Description"] = ResManager.LoadKDString("预算控制规则-删除", "0032056000021791", SubSystemType.FIN, new object[0]); int num = 1; string str = ResManager.LoadKDString("预算控制规则删除", "0032056000021794", SubSystemType.FIN, new object[0]); string format = ResManager.LoadKDString("预算控制规则:{0}[{1}]删除", "0032056000021795", SubSystemType.FIN, new object[0]); foreach (DynamicObject obj4 in e.DataEntitys) { DynamicObjectCollection objects = obj3["LOGENTITY"] as DynamicObjectCollection; DynamicObject item = objects.DynamicCollectionItemPropertyType.CreateInstance() as DynamicObject; item["SEQ"] = num++; int num2 = obj4.GetDynamicObjectItemValue <int>("Id", 0); string name = this.GetName(obj4.GetDynamicObjectItemValue <LocaleValue>("name", null)); item["RuleID"] = num2; item["RuleName"] = name; item["LogTime"] = DateTime.Now; item["Descriptions"] = str; item["Detailed"] = string.Format(format, name, num2); item["Level"] = 0; item["LogType"] = 100.ToString(); objects.Add(item); } return(obj3); }
private void RefreshStkCntBillAuditEntry(StockOrgOperateResult opResult, ErrType errtype) { Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FStkCountBillAuditEntry"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if (((opResult != null) && (opResult.StkCountBillAuditErrInfo != null)) && (opResult.StkCountBillAuditErrInfo.Count > 0)) { foreach (OperateErrorInfo info in opResult.StkCountBillAuditErrInfo) { DynamicObject item = new DynamicObject(dynamicObjectType) { ["CtbaErrType"] = info.ErrType, ["CtbaErrObjType"] = info.ErrObjType, ["CtbaErrObjKeyField"] = info.ErrObjKeyField, ["CtbaErrObjKeyID"] = info.ErrObjKeyID, ["CtbaErrMsg"] = info.ErrMsg }; entityDataObject.Add(item); } } this.View.UpdateView("FStkCountBillAuditEntry"); }
/// <summary> /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件 /// </summary> /// <param name="e"></param> public override void OnAfterCreateLink(CreateLinkEventArgs e) { // 预先获取一些必要的元数据,后续代码要用到: // 源单第二单据体,执行部门 Entity srcSecondEntity = e.SourceBusinessInfo.GetEntity("F_PEJK_ExecuteDept"); // 目标单第一单据体,产品明细 //Entity mainEntity = e.TargetBusinessInfo.GetEntity("FEntity"); // 目标单第二单据体,执行部门 Entity secondEntity = e.TargetBusinessInfo.GetEntity("F_PEJK_OppExecuteDept"); // 目标单关联子单据体 //Entity linkEntity = null; //Form form = e.TargetBusinessInfo.GetForm(); //if (form.LinkSet != null // && form.LinkSet.LinkEntitys != null // && form.LinkSet.LinkEntitys.Count != 0) //{ // linkEntity = e.TargetBusinessInfo.GetEntity( // form.LinkSet.LinkEntitys[0].Key); //} //if (linkEntity == null) //{ // return; //} // 获取生成的全部下游单据 ExtendedDataEntity[] billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); // 对下游单据,逐张单据进行处理 //foreach (var item in billDataEntitys) //{ // DynamicObject dataObject = item.DataEntity; // // 定义一个集合,用于收集本单对应的源单内码 // HashSet<long> srcBillIds = new HashSet<long>(); // //开始到主单据体中,读取关联的源单内码 // DynamicObjectCollection mainEntryRows = // mainEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; // foreach (var mainEntityRow in mainEntryRows) // { // DynamicObjectCollection linkRows = // linkEntity.DynamicProperty.GetValue(mainEntityRow) as DynamicObjectCollection; // foreach (var linkRow in linkRows) // { // long srcBillId = Convert.ToInt64(linkRow["SBillId"]); // if (srcBillId != 0 // && srcBillIds.Contains(srcBillId) == false) // { // srcBillIds.Add(srcBillId); // } // } // } //DynamicObject linkRows = // linkEntity.DynamicProperty.GetValue(dataObject) as DynamicObject; // long srcBillId = Convert.ToInt64(linkRows["SBillId"]); // if (srcBillId != 0 // && srcBillIds.Contains(srcBillId) == false) // { // srcBillIds.Add(srcBillId); // } //定义一个集合,用于收集本单对应的源单内码 HashSet <long> srcBillIds = new HashSet <long>(); foreach (var item in billDataEntitys) { DynamicObject dataObject = item.DataEntity; if (Convert.ToString(dataObject["FSourceBillNo"]) != null && Convert.ToString(dataObject["FSourceBillNo"]) != " ") { string strSql = string.Format(@"/*dialect*/select FID from T_CRM_Clue where FBILLNO = '{0}'", Convert.ToString(dataObject["FSourceBillNo"])); long srcBillId = DBUtils.ExecuteScalar <long>(this.Context, strSql, 0, null); if (srcBillId != 0 && srcBillIds.Contains(srcBillId) == false) { srcBillIds.Add(srcBillId); } if (srcBillIds.Count == 0) { continue; } // 开始加载源单第二单据体上的字段 // 确定需要加载的源单字段(仅加载需要携带的字段) List <SelectorItemInfo> selector = new List <SelectorItemInfo>(); selector.Add(new SelectorItemInfo("F_PEJK_ExecuteDeptId")); // TODO: 继续添加其他需要携带的字段,示例代码略 // 设置过滤条件 string filter = string.Format(" {0} IN ({1}) ", e.SourceBusinessInfo.GetForm().PkFieldName, string.Join(",", srcBillIds)); OQLFilter filterObj = OQLFilter.CreateHeadEntityFilter(filter); // 读取源单 IViewService viewService = ServiceHelper.GetService <IViewService>(); var srcBillObjs = viewService.Load(this.Context, e.SourceBusinessInfo.GetForm().Id, selector, filterObj); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection secondEntryRows = secondEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; secondEntryRows.Clear(); // 删除空行 foreach (var srcBillObj in srcBillObjs) { DynamicObjectCollection srcEntryRows = srcSecondEntity.DynamicProperty.GetValue(srcBillObj) as DynamicObjectCollection; foreach (var srcEntryRow in srcEntryRows) { // 目标单添加新行,并接受源单字段值 DynamicObject newRow = new DynamicObject(secondEntity.DynamicObjectType); secondEntryRows.Add(newRow); // 填写字段值 newRow["F_PEJK_ExecuteDeptId"] = srcEntryRow["F_PEJK_ExecuteDeptId"]; // TODO: 逐个填写其他字段值,示例代码略 } } } //string strSql = string.Format(@"/*dialect*/select fsbillid from T_CRM_Opportunity_LK where fid = {0}", Convert.ToInt64(dataObject["id"])); } }
public override void AfterCreateModelData(EventArgs e) { List <Bem_QanoArgs> resultList = null; BizQanoService service = BizQanoService.GetInstance(); int seq = 0;//父单据体行 Entity entity = this.View.BusinessInfo.GetEntity("FEntity"); DynamicObjectCollection objs = this.View.Model.GetEntityDataObject(entity); //this.Model.ClearNoDataRow(); objs.Clear(); resultList = service.GetBillMaterialList(this.Context, ids, entryIds, PformId); if (resultList.Count > 0) { foreach (Bem_QanoArgs one in resultList) { DynamicObject obj = new DynamicObject(entity.DynamicObjectType); objs.Add(obj); //this.Model.CreateNewEntryRow(entity,seq); //obj["F_QANo"] = one.qano; //obj["F_RealLength"] = one.RealLength; //obj["F_RealWidth"] = one.RealWidth; //obj["F_RealThinkness"] = one.RealThinkness; //obj["F_Length"] = one.Length; //obj["F_Width"] = one.Width; //obj["F_Thinkness"] = one.Thinkness; //obj["F_Specification"] = one.Specification; //obj["F_CContent"] = one.CContent; //obj["F_CrContent"] = one.CrContent; //obj["F_ElementRemark"] = one.ElementRemark; //obj["F_PerRemark"] = one.PerRemark; //obj["F_SurfaceRemark"] = one.SurfaceRemark; //obj["F_OtherRemaek"] = one.OtherRemaek; //obj["F_WeightMethod_Id"] = one.weightMethod; //obj["F_QualityLevel_Id"] = one.qualityLevel; //obj["F_EdgeState_Id"] = one.edgeState; ////obj["F_Surface"] = one.surface; ////obj["F_MQuailty_Id"] = one.mQuailty; ////obj["F_Category_Id"] = one.category; //obj["F_Standard_Id"] = one.standard; //obj["F_Origin_Id"] = one.origin; //obj["F_PCategory_Id"] = one.pCategory; //obj["FMATERIALID_Id"] = one.masterId; //obj["F_BEM_billseq"] = one.seq; //obj["FLOT_Id"] = one.FLotNo; //obj["F_BEM_billentryid"] = one.entryid; //obj["F_BEM_billno"] = one.FBILLNO; this.View.Model.SetValue("F_QANo", one.qano, seq); this.View.Model.SetValue("F_RealLength", one.RealLength, seq); this.View.Model.SetValue("F_RealWidth", one.RealWidth, seq); this.View.Model.SetValue("F_RealThinkness", one.RealThinkness, seq); this.View.Model.SetValue("F_Length", one.Length, seq); this.View.Model.SetValue("F_Width", one.Width, seq); this.View.Model.SetValue("F_Thinkness", one.Thinkness, seq); this.View.Model.SetValue("F_Specification", one.Specification, seq); this.View.Model.SetValue("F_CContent", one.CContent, seq); this.View.Model.SetValue("F_CrContent", one.CrContent, seq); this.View.Model.SetValue("F_ElementRemark", one.ElementRemark, seq); this.View.Model.SetValue("F_PerRemark", one.PerRemark, seq); this.View.Model.SetValue("F_SurfaceRemark", one.SurfaceRemark, seq); this.View.Model.SetValue("F_OtherRemaek", one.OtherRemaek, seq); this.View.Model.SetValue("F_WeightMethod", one.weightMethod, seq); this.View.Model.SetValue("F_QualityLevel", one.qualityLevel, seq); this.View.Model.SetValue("F_EdgeState", one.edgeState, seq); this.View.Model.SetValue("F_Surface", one.surface, seq); this.View.Model.SetValue("F_MQuailty", one.mQuailty, seq); this.View.Model.SetValue("F_Category", one.category, seq); this.View.Model.SetValue("F_Standard", one.standard, seq); this.View.Model.SetValue("F_Origin", one.origin, seq); this.View.Model.SetValue("F_PCategory", one.pCategory, seq); this.View.Model.SetValue("FMATERIALID", one.masterId, seq); this.View.Model.SetValue("F_BEM_billseq", one.seq, seq); this.View.Model.SetValue("FLOT", one.FLotNo, seq); this.View.Model.SetValue("F_BEM_billentryid", one.entryid, seq); this.View.Model.SetValue("F_BEM_billno", one.FBILLNO, seq); this.View.Model.SetEntryCurrentRowIndex("FEntity", seq); obj["Seq"] = ++seq; } this.View.UpdateView("FEntity"); } }
//创建销售预测变更单 private void CreateForecastChangeBill() { //分组集合 List <string> lstGroups = new List <string>(); string sGroup = string.Empty; foreach (DynamicObject lstEntry in lstEntrys) { sGroup = Convert.ToString(lstEntry["FSaleOrgId_ID"]) + "+" + Convert.ToString(lstEntry["FSaleDeptId_ID"]) + "+" + Convert.ToString(lstEntry["FSaleGroupId_ID"]) + "+" + Convert.ToString(lstEntry["FSalerId_ID"]); if (!lstGroups.Contains(sGroup)) { lstGroups.Add(sGroup); } } //插入数据 //销售预测变更单的信息 BusinessInfo businessInfo = ((FormMetadata)MetaDataServiceHelper.Load(this.Context, "JN_YDL_SAL_ForecastChange", true)).BusinessInfo; DynamicObject billHead = null; DynamicObjectCollection billEntrys = null; List <DynamicObject> lstBills = new List <DynamicObject>(); List <DynamicObject> lstSelectEntrys; long lSaleOrgId = 0; long lSaleDeptId = 0; long lSaleGroupId = 0; long lSalerId = 0; foreach (string lstGroup in lstGroups) { //单据头 billHead = businessInfo.GetDynamicObjectType().CreateInstance() as DynamicObject; //单据体 billEntrys = billHead["FEntity"] as DynamicObjectCollection; if (billHead == null || billEntrys == null) { continue; } string[] sGroupSplit = lstGroup.Split('+'); if (sGroupSplit == null || sGroupSplit.Count() != 4) { continue; } lSaleOrgId = Convert.ToInt64(sGroupSplit[0]); lSaleDeptId = Convert.ToInt64(sGroupSplit[1]); lSaleGroupId = Convert.ToInt64(sGroupSplit[2]); lSalerId = Convert.ToInt64(sGroupSplit[3]); billHead["FBillTypeID_Id"] = "58b2a721c7f776"; billHead["FJNSaleOrgId_Id"] = lSaleOrgId; billHead["FJNSaleDeptId_Id"] = lSaleDeptId; billHead["FJNSaleGroupId_Id"] = lSaleGroupId; billHead["FJNSalerId_Id"] = lSalerId; billHead["FDocumentStatus"] = "A"; billHead["FJNDate"] = DateTime.Now; billHead["FDirection"] = sAdjustType == "A" ? "B" : "A"; billHead["FCreateDate"] = DateTime.Now; billHead["FCreatorId_Id"] = this.Context.UserId; lstSelectEntrys = lstEntrys.Where(p => Convert.ToInt64(p["FSaleOrgId_Id"]) == lSaleOrgId && Convert.ToInt64(p["FSaleDeptId_Id"]) == lSaleDeptId && Convert.ToInt64(p["FSaleGroupId_Id"]) == lSaleGroupId && Convert.ToInt64(p["FSalerId_Id"]) == lSalerId).ToList(); if (lstSelectEntrys == null || lstSelectEntrys.Count() <= 0) { continue; } int seq = 1; foreach (DynamicObject entry in lstSelectEntrys) { DynamicObject billEntry = new DynamicObject(billEntrys.DynamicCollectionItemPropertyType); billEntry["Seq"] = seq; billEntry["FJNMaterialId_Id"] = entry["FMaterialId_Id"]; billEntry["FJNAUXPROP_Id"] = entry["FAuxPropId_Id"]; billEntry["FJNForecastQty"] = entry["FAdjustQty"]; billEntry["FJNUnitID_Id"] = entry["FUnitID_Id"]; billEntry["FJNBaseUnitID_Id"] = entry["FUnitID_Id"]; billEntry["FJNBaseUnitQty"] = entry["FAdjustQty"]; billEntry["FJNStockOrg_Id"] = this.Context.CurrentOrganizationInfo.ID; billEntry["FJNSettleOrg_Id"] = this.Context.CurrentOrganizationInfo.ID; billEntry["FJNSupplyOrg_Id"] = this.Context.CurrentOrganizationInfo.ID; DynamicObject material = entry["FMaterialId"] as DynamicObject; if (material != null) { string Materialname = material["Name"].ToString(); string sql = ""; if (Materialname.IndexOf("(内蒙)") > 0 || Materialname.IndexOf("(内蒙)") > 0 || Materialname.IndexOf("(内蒙)") > 0) { billEntry["FJNSupplyOrg_Id"] = 100063; sql = string.Format(@"select t2.FWORKSHOPID as FWORKSHOPID from T_BD_MATERIAL t1 join T_BD_MATERIALPRODUCE t2 on t1.FMATERIALID=t2.FMATERIALID where t1.FMASTERID in( select FMASTERID from T_BD_MATERIAL where FMATERIALID={0}) and t1.FUSEORGID={1}", Convert.ToInt32(entry["FMaterialId_Id"]), 100063); } else { billEntry["FJNSupplyOrg_Id"] = 100062; sql = string.Format(@"select t2.FWORKSHOPID as FWORKSHOPID from T_BD_MATERIAL t1 join T_BD_MATERIALPRODUCE t2 on t1.FMATERIALID=t2.FMATERIALID where t1.FMASTERID in( select FMASTERID from T_BD_MATERIAL where FMATERIALID={0}) and t1.FUSEORGID={1}", Convert.ToInt32(entry["FMaterialId_Id"]), 100062); } DynamicObjectCollection FWORKSHOPID = DBServiceHelper.ExecuteDynamicObject(this.Context, sql); if (FWORKSHOPID.Count > 0) { int WORKSHOP = Convert.ToInt32(FWORKSHOPID[0]["FWORKSHOPID"]); billEntry["F_VTR_PrdDeptId_Id"] = WORKSHOP; } /* else * { * billEntry["F_VTR_PrdDeptId"] = 0; * }*/ } billEntrys.Add(billEntry); seq++; } lstBills.Add(billHead); } if (lstBills.Count <= 0) { return; } //生成编码 MakeBillNo(lstBills); Kingdee.BOS.ServiceHelper.DBServiceHelper.LoadReferenceObject(this.Context, lstBills.ToArray(), businessInfo.GetDynamicObjectType(), false); DynamicObject[] billDatas = BusinessDataServiceHelper.Save(this.Context, lstBills.ToArray()); if (billDatas == null || billDatas.Count() <= 0) { //K3DisplayerModel model = K3DisplayerModel.Create(this.Context, "调整失败,未成功创建销售预测变更单"); //// 创建一个交互提示错误对象,并设置错误来源,相互隔离 //KDInteractionException ie = new KDInteractionException("错误提示"); //ie.InteractionContext.InteractionFormId = FormIdConst.BOS_K3Displayer; // 提示信息显示界面 //ie.InteractionContext.K3DisplayerModel = model; // 提示内容 //ie.InteractionContext.IsInteractive = true; // 是否需要交互 //throw ie; // 抛出错误,终止流程 this.OperationResult.OperateResult[0].SuccessStatus = false; this.OperationResult.OperateResult[0].Message = "创建销售预测变更单失败"; } else { OperateResult result; foreach (var item in billDatas) { result = new OperateResult { SuccessStatus = true, Message = "创建销售预测变更单成功", MessageType = MessageType.Normal, Name = "生成销售预测变更单:" + Convert.ToString(item["FBillNo"]) + "成功", PKValue = item }; this.OperationResult.OperateResult.Add(result); } } this.OperationResult.IsShowMessage = true; }
/// <summary> /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件 /// </summary> /// <param name="e"></param> public override void OnAfterCreateLink(CreateLinkEventArgs e) { // 预先获取一些必要的元数据,后续代码要用到: // 源单第二单据体 Entity srcSecondEntity = e.SourceBusinessInfo.GetEntity("F_PAEZ_OtherEntity"); // 目标单第一单据体 Entity destMainEntity = e.TargetBusinessInfo.GetEntity("FEntity"); // 目标单第二单据体 Entity destSecondEntity = e.TargetBusinessInfo.GetEntity("F_PAEZ_OtherEntity"); // 目标单关联子单据体 Entity linkEntity = null; Form form = e.TargetBusinessInfo.GetForm(); if (form.LinkSet != null && form.LinkSet.LinkEntitys != null && form.LinkSet.LinkEntitys.Count != 0) { linkEntity = e.TargetBusinessInfo.GetEntity( form.LinkSet.LinkEntitys[0].Key); } if (linkEntity == null) { return; } // 获取生成的全部下游单据 ExtendedDataEntity[] billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); // 对下游单据,逐张单据进行处理 foreach (var item in billDataEntitys) { DynamicObject destBillObject = item.DataEntity; // 定义一个集合,用于收集本单对应的源单内码 HashSet <long> srcBillIds = new HashSet <long>(); // 开始到主单据体中,读取关联的源单内码 DynamicObjectCollection destMainEntryRows = destMainEntity.DynamicProperty.GetValue(destBillObject) as DynamicObjectCollection; foreach (var mainEntityRow in destMainEntryRows) { DynamicObjectCollection linkRows = linkEntity.DynamicProperty.GetValue(mainEntityRow) as DynamicObjectCollection; foreach (var linkRow in linkRows) { long srcBillId = Convert.ToInt64(linkRow["SBillId"]); if (srcBillId != 0 && srcBillIds.Contains(srcBillId) == false) { srcBillIds.Add(srcBillId); } } } if (srcBillIds.Count == 0) { continue; } // 开始加载源单第二单据体上的字段 // 确定需要加载的源单字段(仅加载需要携带的字段) List <SelectorItemInfo> selector = new List <SelectorItemInfo>(); selector.Add(new SelectorItemInfo("F_PAEZ_Desc")); // TODO: 继续添加其他需要携带的字段,示例代码略 // 设置过滤条件 string filter = string.Format(" {0} IN ({1}) ", e.SourceBusinessInfo.GetForm().PkFieldName, string.Join(",", srcBillIds)); OQLFilter filterObj = OQLFilter.CreateHeadEntityFilter(filter); // 读取源单 IViewService viewService = ServiceHelper.GetService <IViewService>(); var srcBillObjs = viewService.Load(this.Context, e.SourceBusinessInfo.GetForm().Id, selector, filterObj); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection destSecondEntryRows = destSecondEntity.DynamicProperty.GetValue(destBillObject) as DynamicObjectCollection; destSecondEntryRows.Clear(); // 删除空行 foreach (var srcBillObj in srcBillObjs) { DynamicObjectCollection srcEntryRows = srcSecondEntity.DynamicProperty.GetValue(srcBillObj) as DynamicObjectCollection; foreach (var srcEntryRow in srcEntryRows) { // 目标单添加新行,并接受源单字段值 DynamicObject newRow = new DynamicObject(destSecondEntity.DynamicObjectType); destSecondEntryRows.Add(newRow); // 填写字段值 newRow["F_PAEZ_Desc"] = srcEntryRow["F_PAEZ_Desc"]; // TODO: 逐个填写其他字段值,示例代码略 } } } }
public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e) { base.BeforeExecuteOperationTransaction(e); HashSet <string> poBillNos = new HashSet <string>(); Entity entity = this.BusinessInfo.GetEntity("FInStockEntry"); Entity linkEntry = this.BusinessInfo.GetEntity("FInStockEntry_Link"); Field fldSrcFormId = this.BusinessInfo.GetField("FSRCBILLTYPEID"); Field fldSrcBillNo = this.BusinessInfo.GetField("FSrcBillNo"); // 对单据体进行循环,取关联的源单编号 foreach (var billObj in e.SelectedRows) { DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity) as DynamicObjectCollection; foreach (var entryRow in entryRows) { string srcFormId = fldSrcFormId.DynamicProperty.GetValue <string>(entryRow); string srcSrcBillNo = fldSrcBillNo.DynamicProperty.GetValue <string>(entryRow); if (string.IsNullOrWhiteSpace(srcFormId) || !srcFormId.EqualsIgnoreCase(POFormId)) {// 源单不是采购订单,略过 continue; } // 源单编号已经登记,不再重复记录,略过 if (poBillNos.Contains(srcSrcBillNo)) { continue; } // Link已经记录了源单信息,略过 DynamicObjectCollection linkRows = linkEntry.DynamicProperty.GetValue(entryRow) as DynamicObjectCollection; if (linkRows.Count > 0) { continue; } poBillNos.Add(srcSrcBillNo); } } if (poBillNos.Count == 0) { return; } DynamicObject[] poObjs = this.LoadPurchaseOrder(poBillNos); if (poObjs == null || poObjs.Length == 0) { return; } Dictionary <string, Dictionary <string, DynamicObject> > dctAllBills = this.BuildDictionary(poObjs); string srcTableNumber = this.GetPOEntryTableNumber(); List <DynamicObject> allNewLinkRows = new List <DynamicObject>(); // 循环单据体,为单据体,建立起源单关联信息: foreach (var billObj in e.SelectedRows) { DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity) as DynamicObjectCollection; foreach (var entryRow in entryRows) { string srcFormId = fldSrcFormId.DynamicProperty.GetValue <string>(entryRow); string srcSrcBillNo = fldSrcBillNo.DynamicProperty.GetValue <string>(entryRow); if (string.IsNullOrWhiteSpace(srcFormId) || !srcFormId.EqualsIgnoreCase(POFormId)) {// 源单不是采购订单,略过 continue; } Dictionary <string, DynamicObject> dctOneBill = null; if (dctAllBills.TryGetValue(srcSrcBillNo, out dctOneBill) == false) { continue; } DynamicObject materialObj = entryRow["MaterialId"] as DynamicObject; if (materialObj == null) { continue; } string materialNumber = Convert.ToString(materialObj["number"]); DynamicObject srcRow = null; if (dctOneBill.TryGetValue(materialNumber, out srcRow) == false) { continue; } // Link已经记录了源单信息,略过 DynamicObjectCollection linkRows = linkEntry.DynamicProperty.GetValue(entryRow) as DynamicObjectCollection; if (linkRows.Count > 0) { continue; } DynamicObject linkRow = new DynamicObject(linkEntry.DynamicObjectType); linkRow["STableName"] = srcTableNumber; this.FillLinkRow(srcRow, entryRow, linkRow); linkRows.Add(linkRow); allNewLinkRows.Add(linkRow); } } // 为新建的源单关联信息,设置内码 IDBService dbService = ServiceHelper.GetService <IDBService>(); dbService.AutoSetPrimaryKey(this.Context, allNewLinkRows.ToArray(), linkEntry.DynamicObjectType); }
private void SplitData(AfterConvertEventArgs e) { ExtendedDataEntity[] source = e.Result.FindByEntityKey("FEntity"); string billTypeId = (source.FirstOrDefault <ExtendedDataEntity>().DataEntity.Parent as DynamicObject).GetDynamicObjectItemValue <string>("FBillTypeID_Id", null); DynamicObject dynamicObject = Kingdee.K3.MFG.App.AppServiceContext.BusinessDataService.LoadBillTypePara(base.Context, "InspectBillTPS", billTypeId, true); string str2 = dynamicObject.GetDynamicObjectItemValue <string>("SPLITBY", null); if ((!dynamicObject.IsNullOrEmpty() && !str2.EqualsIgnoreCase("A")) && !str2.IsNullOrEmptyOrWhiteSpace()) { List <long> materialIds = (from s in source select s.DataEntity.GetDynamicValue <long>("MaterialId_Id", 0L)).ToList <long>(); Dictionary <long, Tuple <long, long> > inspectorInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectService>().GetInspectorInfo(base.Context, materialIds); if (!inspectorInfo.IsEmpty <KeyValuePair <long, Tuple <long, long> > >()) { ExtendedDataEntity[] entityArray2 = e.Result.FindByEntityKey("FBillHead"); List <ExtendedDataEntity> list2 = new List <ExtendedDataEntity>(); foreach (ExtendedDataEntity entity in entityArray2) { Dictionary <long, ExtendedDataEntity> dictionary2 = new Dictionary <long, ExtendedDataEntity>(); foreach (DynamicObject obj3 in entity.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null)) { Tuple <long, long> tuple; long key = obj3.GetDynamicValue <long>("MaterialId_Id", 0L); if (inspectorInfo.TryGetValue(key, out tuple)) { long num2 = str2.EqualsIgnoreCase("B") ? tuple.Item1 : tuple.Item2; if (dictionary2.Keys.Contains <long>(num2)) { dictionary2[num2].DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null).Add(obj3); } else { ExtendedDataEntity entity2 = (ExtendedDataEntity)entity.Clone(); DynamicObjectCollection objects3 = entity2.DataEntity.GetDynamicValue <DynamicObjectCollection>("Entity", null); objects3.Clear(); objects3.Add(obj3); if (str2.EqualsIgnoreCase("B")) { entity2.DataEntity.SetDynamicObjectItemValue("InspectGroupId_Id", tuple.Item1); } else if (str2.EqualsIgnoreCase("C")) { entity2.DataEntity.SetDynamicObjectItemValue("InspectorId_Id", tuple.Item2); } dictionary2.Add(num2, entity2); } } } list2.AddRange(dictionary2.Values); dictionary2.Clear(); } DynamicObject[] col = (from s in list2 select s.DataEntity).ToArray <DynamicObject>(); if (!col.IsEmpty <DynamicObject>()) { Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, col, col.FirstOrDefault <DynamicObject>().DynamicObjectType, true); for (int i = 0; i < entityArray2.Length; i++) { e.Result.RemoveExtendedDataEntity("FBillHead", 0);//原来e.Result.RemoveExtendedDataEntity("FBillHead",i) } e.Result.AddExtendedDataEntities("FBillHead", list2.ToArray()); } } } }
/// <summary> /// 主单据体的字段携带完毕,与源单的关联关系创建好之后,触发此事件 /// </summary> /// <param name="e"></param> //public override void OnAfterCreateLink(CreateLinkEventArgs e) //{ // base.OnAfterCreateLink(e); // //源单 销售订单明细 // Entity srcFirstEntity = e.SourceBusinessInfo.GetEntity("FSaleOrderEntry"); // //目标单 直接调拨单明细 // Entity mainEntity = e.TargetBusinessInfo.GetEntity("FBillEntry"); // // 目标单关联子单据体 // Entity linkEntity = null; // Form form = e.TargetBusinessInfo.GetForm(); // if (form.LinkSet != null // && form.LinkSet.LinkEntitys != null // && form.LinkSet.LinkEntitys.Count != 0) // { // linkEntity = e.TargetBusinessInfo.GetEntity( // form.LinkSet.LinkEntitys[0].Key); // } // if (linkEntity == null) // { // return; // } // // 获取生成的全部下游单据 // ExtendedDataEntity[] billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); // // 对下游单据,逐张单据进行处理 // foreach (var item in billDataEntitys) // { // DynamicObjectCollection directEntry = item["TransferDirectEntry"] as DynamicObjectCollection; // //合并之后的分录 为了不遍历每次增加 // DynamicObject entryEnd = directEntry[0] as DynamicObject; // //获取目标单组织 sql中使用 // DynamicObject org = item["StockOrgId"] as DynamicObject; // long orgId=Convert.ToInt64(org["Id"]); // decimal slamount = 0;//塑料箱总数 // decimal pmamount = 0;//泡沫箱总数 // for (int i=0;i< directEntry.Count; i++) // { // //目标单分录 // DynamicObject entry= directEntry[i] as DynamicObject; // //目标单物料 // DynamicObject material = entry["MaterialId"] as DynamicObject; // //目标单调拨数量 // decimal qty= Convert.ToDecimal(entry["QTY"]); // //物料获取装箱数 // decimal packQty= Convert.ToDecimal(material["FPACKQTY"]); // //物料获取箱套类型 // DynamicObjectCollection materialBase = material["MaterialBase"] as DynamicObjectCollection; // foreach (DynamicObject colourAll in materialBase) // { // string colour = Convert.ToString(colourAll["FBOXCOLOUR"]); // if (colour.Equals("1"))//塑料箱 // { // decimal slxAmount = Math.Ceiling(qty / packQty); // slamount = slamount + slxAmount; // } // if (colour.Equals("2"))//泡沫箱 // { // decimal pmxAmount = Math.Ceiling(qty / packQty); // pmamount = pmamount + pmxAmount; // } // } // } // //新增分录 判断两种箱套数量是否为空 // if (slamount != 0) // { // // 目标单添加新行,并接受源单字段值 // DynamicObject newRow = new DynamicObject(mainEntity.DynamicObjectType); // directEntry.Add(newRow); // //根据组织查询对应 箱套 // string sql = string.Format(@"select fmaterialid from t_bd_material where fnumber='07040000' and fuseorgid={0}", orgId); // long result = DBUtils.ExecuteScalar<long>(base.Context, sql, -1, null); // //调入货主类型 string // string ownerType = Convert.ToString(item["OwnerTypeIdHead"]); // //调出货主类型 string // string ownerOutType = Convert.ToString(item["OwnerTypeOutIdHead"]); // //调入货主 DynamicObject // DynamicObject owner = item["OwnerIdHead"] as DynamicObject; // //调出货主 DynamicObject // DynamicObject ownerOut = item["OwnerOutIdHead"] as DynamicObject; // //调入保管者类型 // string keeperType = item["OwnerTypeIdHead"] as string; // //调出保管者类型 // string keeperOutType = entryEnd["KeeperTypeId"] as string; // //调入保管者 // DynamicObject keeper = entryEnd["KeeperId"] as DynamicObject; // //调出保管者 // DynamicObject keeperOut = entryEnd["KeeperOutId"] as DynamicObject; // //调拨数量基本单位 BaseQty // decimal baseQty = Convert.ToDecimal( entryEnd["BaseQty"]); // //组织基础资料对象 // if (result !=0 && result != -1) // { // IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();//元数据服务 // IViewService view = ServiceHelper.GetService<IViewService>();//界面服务 // FormMetadata Meta = metaService.Load(base.Context, "BD_MATERIAL") as FormMetadata;//获取基础资料元数据 // DynamicObject BasicObject = view.LoadSingle(base.Context, result, Meta.BusinessInfo.GetDynamicObjectType()); // //物料ID // long materialId = Convert.ToInt64(BasicObject["Id"]); // // 填写字段值 // DynamicObjectCollection materialStock = BasicObject["MaterialStock"] as DynamicObjectCollection; // DynamicObjectCollection materialBase = BasicObject["MaterialBase"] as DynamicObjectCollection; // //基本单位 // foreach(DynamicObject base2 in materialBase) // { // DynamicObject baseUnit = base2["BaseUnitId"] as DynamicObject; // newRow["BaseUnitId"] =baseUnit; // } // //单位 物料 // foreach (DynamicObject base1 in materialStock) // { // DynamicObject unit = base1["StoreUnitID"] as DynamicObject; // long unitId = Convert.ToInt64(unit["Id"]); // newRow["MaterialId"] = BasicObject; // newRow["MaterialId_Id"] = materialId; // newRow["QTY"] = slamount; // newRow["UnitId"] = unit; // newRow["UnitId_Id"] = unitId; // newRow["Seq"] = directEntry.Count; // //调入货主 // newRow["OwnerId"] = owner; // //调入货主类型 // newRow["OwnerTypeId"] = ownerType; // //调处货主 // newRow["FOwnerOutId"] = ownerOut; // //调出货主类型 // newRow["OwnerTypeOutId"] = ownerOutType; // //调入保管者类型 // newRow["KeeperTypeId"] = keeperOutType; // //调出保管者类型 // newRow["KeeperTypeOutId"] = keeperOutType; // //调入保管者 // newRow["KeeperId"] = owner; // //调出保管者 // newRow["KeeperOutId"] = ownerOut; // //调出数量(基本单位) // newRow["BaseQty"] = baseQty; // } // } // } // if(pmamount != 0) // { // // 目标单添加新行 // DynamicObject newRow = new DynamicObject(entryEnd.DynamicObjectType); // directEntry.Add(newRow); // //根据组织查询对应 箱套 // string sql = string.Format(@"select fmaterialid from t_bd_material where fnumber='07040004' and fuseorgid={0}", orgId); // long result = DBUtils.ExecuteScalar<long>(base.Context, sql, -1, null); // //组织基础资料对象 // if (result != 0 && result != -1) // { // IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();//元数据服务 // IViewService view = ServiceHelper.GetService<IViewService>();//界面服务 // FormMetadata Meta = metaService.Load(base.Context, "BD_MATERIAL") as FormMetadata;//获取基础资料元数据 // DynamicObject BasicObject = view.LoadSingle(base.Context, result, Meta.BusinessInfo.GetDynamicObjectType()); // //物料ID // long materialId = Convert.ToInt64(BasicObject["Id"]); // // 填写字段值 // DynamicObjectCollection materialStock = BasicObject["MaterialStock"] as DynamicObjectCollection; // foreach(DynamicObject base1 in materialStock) // { // DynamicObject unit = base1["StoreUnitID"] as DynamicObject; // long unitId = Convert.ToInt64(unit["Id"]); // newRow["MaterialId"] = BasicObject; // newRow["MaterialId_Id"] = materialId; // newRow["QTY"] = pmamount; // newRow["UnitId"] = unit; // newRow["UnitId_Id"] = unitId; // newRow["Seq"] = directEntry.Count; // } // } // } // // TODO: 逐个填写其他字段值,示例代码略 // } //} public override void AfterConvert(AfterConvertEventArgs e) { base.AfterConvert(e); // 获取生成的全部下游单据 ExtendedDataEntity[] billDataEntitys = e.Result.FindByEntityKey("FBillHead"); Entity mainEntity = e.TargetBusinessInfo.GetEntity("FBillEntry"); Entity srcFirstEntity = e.SourceBusinessInfo.GetEntity("FSaleOrderEntry"); // 对下游单据,逐张单据进行处理 foreach (var item in billDataEntitys) { DynamicObjectCollection directEntry = item["TransferDirectEntry"] as DynamicObjectCollection; //合并之后的分录 为了不遍历每次增加 DynamicObject entryEnd = directEntry[0] as DynamicObject; //获取目标单组织 sql中使用 DynamicObject org = item["StockOrgId"] as DynamicObject; long orgId = Convert.ToInt64(org["Id"]); decimal slamount = 0; //塑料箱总数 decimal pmamount = 0; //泡沫箱总数 for (int i = 0; i < directEntry.Count; i++) { //目标单分录 DynamicObject entry = directEntry[i] as DynamicObject; //目标单物料 DynamicObject material = entry["MaterialId"] as DynamicObject; //目标单调拨数量 decimal qty = Convert.ToDecimal(entry["QTY"]); //物料获取装箱数 decimal packQty = Convert.ToDecimal(material["FPACKQTY"]); //物料获取箱套类型 DynamicObjectCollection materialBase = material["MaterialBase"] as DynamicObjectCollection; foreach (DynamicObject colourAll in materialBase) { string colour = Convert.ToString(colourAll["FBOXCOLOUR"]); if (colour.Equals("1"))//塑料箱 { decimal slxAmount = Math.Ceiling(qty / packQty); slamount = slamount + slxAmount; } if (colour.Equals("2"))//泡沫箱 { decimal pmxAmount = Math.Ceiling(qty / packQty); pmamount = pmamount + pmxAmount; } } } //新增分录 判断两种箱套数量是否为空 if (slamount != 0) { // 目标单添加新行,并接受源单字段值 DynamicObject newRow = new DynamicObject(mainEntity.DynamicObjectType); directEntry.Add(newRow); //根据组织查询对应 箱套 string sql = string.Format(@"select fmaterialid from t_bd_material where fnumber='07040000' and fuseorgid={0}", orgId); long result = DBUtils.ExecuteScalar <long>(base.Context, sql, -1, null); //调入货主类型 string string ownerType = Convert.ToString(item["OwnerTypeIdHead"]); //调出货主类型 string string ownerOutType = Convert.ToString(item["OwnerTypeOutIdHead"]); //调入货主 DynamicObject DynamicObject owner = entryEnd["OwnerId"] as DynamicObject; //调出货主 DynamicObject DynamicObject ownerOut = entryEnd["FOwnerOutId"] as DynamicObject; //调入保管者 DynamicObject keeper = entryEnd["KeeperId"] as DynamicObject; //调出保管者 DynamicObject keeperOut = entryEnd["KeeperOutId"] as DynamicObject; //调入保管者类型 string keeperType = entryEnd["OwnerTypeId"] as string; //调出保管者类型 string keeperOutType = entryEnd["KeeperTypeId"] as string; ////调拨数量基本单位 BaseQty //decimal baseQty = Convert.ToDecimal(entryEnd["BaseQty"]); //组织基础资料对象 if (result != 0 && result != -1) { IMetaDataService metaService = ServiceHelper.GetService <IMetaDataService>(); //元数据服务 IViewService view = ServiceHelper.GetService <IViewService>(); //界面服务 FormMetadata Meta = metaService.Load(base.Context, "BD_MATERIAL") as FormMetadata; //获取基础资料元数据 DynamicObject BasicObject = view.LoadSingle(base.Context, result, Meta.BusinessInfo.GetDynamicObjectType()); //物料ID long materialId = Convert.ToInt64(BasicObject["Id"]); // 填写字段值 DynamicObjectCollection materialStock = BasicObject["MaterialStock"] as DynamicObjectCollection; DynamicObjectCollection materialBase = BasicObject["MaterialBase"] as DynamicObjectCollection; ////基本单位 //foreach (DynamicObject base2 in materialBase) //{ // DynamicObject baseUnit = base2["BaseUnitId"] as DynamicObject; // newRow["BaseUnitId"] = baseUnit; //} //单位 物料 foreach (DynamicObject base1 in materialStock) { DynamicObject unit = base1["StoreUnitID"] as DynamicObject; long unitId = Convert.ToInt64(unit["Id"]); newRow["MaterialId"] = BasicObject; newRow["MaterialId_Id"] = materialId; newRow["QTY"] = slamount; newRow["UnitId"] = unit; newRow["UnitId_Id"] = unitId; newRow["Seq"] = directEntry.Count; newRow["DestMaterialId"] = BasicObject; newRow["BaseUnitId"] = unit; newRow["BaseUnitId_Id"] = unitId; //BaseUnitId //调入货主 newRow["OwnerId"] = owner; //调入货主类型 newRow["OwnerTypeId"] = ownerType; //调处货主 newRow["FOwnerOutId"] = ownerOut; //调出货主类型 newRow["OwnerTypeOutId"] = ownerOutType; //调入保管者类型 newRow["KeeperTypeId"] = keeperOutType; //调出保管者类型 newRow["KeeperTypeOutId"] = keeperOutType; //调入保管者 newRow["KeeperId"] = owner; //调出保管者 newRow["KeeperOutId"] = ownerOut; //调出数量(基本单位) newRow["BaseQty"] = slamount; } } } if (pmamount != 0) { // 目标单添加新行 DynamicObject newRow = new DynamicObject(entryEnd.DynamicObjectType); directEntry.Add(newRow); //根据组织查询对应 箱套 string sql = string.Format(@"select fmaterialid from t_bd_material where fnumber='07040004' and fuseorgid={0}", orgId); long result = DBUtils.ExecuteScalar <long>(base.Context, sql, -1, null); //组织基础资料对象 if (result != 0 && result != -1) { IMetaDataService metaService = ServiceHelper.GetService <IMetaDataService>(); //元数据服务 IViewService view = ServiceHelper.GetService <IViewService>(); //界面服务 FormMetadata Meta = metaService.Load(base.Context, "BD_MATERIAL") as FormMetadata; //获取基础资料元数据 DynamicObject BasicObject = view.LoadSingle(base.Context, result, Meta.BusinessInfo.GetDynamicObjectType()); //物料ID long materialId = Convert.ToInt64(BasicObject["Id"]); // 填写字段值 DynamicObjectCollection materialStock = BasicObject["MaterialStock"] as DynamicObjectCollection; foreach (DynamicObject base1 in materialStock) { DynamicObject unit = base1["StoreUnitID"] as DynamicObject; long unitId = Convert.ToInt64(unit["Id"]); newRow["MaterialId"] = BasicObject; newRow["MaterialId_Id"] = materialId; newRow["QTY"] = pmamount; newRow["UnitId"] = unit; newRow["UnitId_Id"] = unitId; newRow["Seq"] = directEntry.Count; newRow["DestMaterialId"] = BasicObject; //调出数量(基本单位) newRow["BaseQty"] = pmamount; } } } } }
public override void OnAfterCreateLink(CreateLinkEventArgs e) { base.OnAfterCreateLink(e); //源单 Entity srcFEntity = e.SourceBusinessInfo.GetEntity("FEntity"); Entity srcFEntityBPR = e.SourceBusinessInfo.GetEntity("FEntityBPR"); Entity srcFEntityM = e.SourceBusinessInfo.GetEntity("FEntityM"); //Entity srcFEntityHD = e.SourceBusinessInfo.GetEntity("FEntityHD"); //目标单 Entity tgtFEntity = e.TargetBusinessInfo.GetEntity("FEntity"); Entity tgtFEntityBPR = e.TargetBusinessInfo.GetEntity("FEntityBPR"); Entity tgtFEntityM = e.TargetBusinessInfo.GetEntity("FEntityM"); //Entity tgtFEntityHD = e.TargetBusinessInfo.GetEntity("FEntityHD"); var billDataEntitys = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"); foreach (var item in billDataEntitys) { DynamicObject dataObject = item.DataEntity; string sql = string.Format("select * from ora_CRM_Contract where FBillNo='{0}'", dataObject["FNicheID"].ToString()); var pkIDs = CZDB_GetData(sql); if (pkIDs.Count <= 0) { continue; } string FID = pkIDs[0]["FID"].ToString(); //加载源单数据 IViewService viewService = ServiceHelper.GetService <IViewService>(); sql = string.Format("select FEntryID from ora_CRM_ContractEntry where FID='{0}'", FID); var srcFEntityEIDs = CZDB_GetData(sql); if (srcFEntityEIDs.Count > 0) { object[] objs = new object[srcFEntityEIDs.Count]; for (int i = 0; i < srcFEntityEIDs.Count; i++) { objs[i] = srcFEntityEIDs[i]["FEntryID"].ToString(); } var srcFEntityBillObjs = viewService.Load(this.Context, objs, srcFEntity.DynamicObjectType); // 开始把源单单据体数据,填写到目标单上 DynamicObjectCollection tgtFEntityRows = tgtFEntity.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; tgtFEntityRows.Clear(); foreach (var srcRow in srcFEntityBillObjs) { DynamicObject newRow = new DynamicObject(tgtFEntity.DynamicObjectType); tgtFEntityRows.Add(newRow); newRow["FMtlGroup"] = srcRow["FMtlGroup"]; newRow["FDescribe"] = srcRow["FDescribe"]; newRow["FQty"] = srcRow["FQty"]; newRow["FModel"] = srcRow["FModel"]; newRow["FIsStandard"] = srcRow["FIsStandard"]; newRow["FBPRndID"] = srcRow["FBPRndID"]; newRow["FBRndNo"] = srcRow["FBRndNo"]; newRow["FGUID"] = srcRow["FGUID"]; newRow["FIS2W"] = srcRow["FIS2W"]; } } /* * sql = string.Format("select FBEntryID from ora_CRM_ContractBPR where FID='{0}'", FID); * var srcFEntityBPREIDs = CZDB_GetData(sql); * if (srcFEntityBPREIDs.Count > 0) * { * object[] objs = new object[srcFEntityBPREIDs.Count]; * for (int i = 0; i < srcFEntityBPREIDs.Count; i++) * { * objs[i] = srcFEntityBPREIDs[i]["FBEntryID"].ToString(); * } * var srcFEntityBPRBillObjs = viewService.Load(this.Context, objs, srcFEntityBPR.DynamicObjectType); * DynamicObjectCollection tgtFEntityBPRRows = tgtFEntityBPR.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; * tgtFEntityBPRRows.Clear(); * foreach (var srcRow in srcFEntityBPRBillObjs) * { * DynamicObject newRow = new DynamicObject(tgtFEntityBPR.DynamicObjectType); * tgtFEntityBPRRows.Add(newRow); * //newRow["BSEQ"] = srcRow["BSEQ"]; * newRow["FBGUID"] = srcRow["FBGUID"]; * newRow["FBSrcEID"] = srcRow["FBSrcEID"]; * newRow["FBSrcSEQ"] = srcRow["FBSrcSEQ"]; * newRow["FBPRndSEQ"] = srcRow["FBPRndSEQ"]; * newRow["FBMtlGroup"] = srcRow["FBMtlGroup"]; * newRow["FBMtlItem"] = srcRow["FBMtlItem"]; * newRow["FMaterialID"] = srcRow["FMaterialID"]; * newRow["FBDescribe"] = srcRow["FBDescribe"]; * newRow["FBQty"] = srcRow["FBQty"]; * newRow["FBModel"] = srcRow["FBModel"]; * newRow["FBIsStandard"] = srcRow["FBIsStandard"]; * newRow["FBasePrice"] = srcRow["FBasePrice"]; * newRow["FBPAmt"] = srcRow["FBPAmt"]; * newRow["FBPAmtGroup"] = srcRow["FBPAmtGroup"]; * newRow["FBRptPrice"] = srcRow["FBRptPrice"]; * newRow["FBAbaComm"] = srcRow["FBAbaComm"]; * newRow["FBDownPoints"] = srcRow["FBDownPoints"]; * newRow["FBWorkDay"] = srcRow["FBWorkDay"]; * newRow["FBCostAdj"] = srcRow["FBCostAdj"]; * newRow["FBCAReason"] = srcRow["FBCAReason"]; * newRow["FBDelivery"] = srcRow["FBDelivery"]; * newRow["FBPAmtLc"] = srcRow["FBPAmtLc"]; * newRow["FBRptPrcLc"] = srcRow["FBRptPrcLc"]; * newRow["FBIS2W"] = srcRow["FBIS2W"]; * newRow["FBUnitID"] = srcRow["FBUnitID"]; * newRow["FBTaxRateID"] = srcRow["FBTaxRateID"]; * newRow["FBTaxRate"] = srcRow["FBTaxRate"]; * newRow["FBBomVsn"] = srcRow["FBBomVsn"]; * newRow["FBTaxPrice"] = srcRow["FBTaxPrice"]; * newRow["FBNTPrice"] = srcRow["FBNTPrice"]; * newRow["FBTaxAmt"] = srcRow["FBTaxAmt"]; * newRow["FBNTAmt"] = srcRow["FBNTAmt"]; * * newRow["FBRangeAmtOne"] = srcRow["FBRangeAmtOne"]; * newRow["FBRangeAmtGP"] = srcRow["FBRangeAmtGP"]; * newRow["FBRangeAmtReason"] = srcRow["FBRangeAmtReason"]; * newRow["FProdFactory"] = srcRow["FProdFactory"]; * //newRow["FBLkQty"] = srcRow["FBLkQty"]; * } * } */ sql = string.Format("select FEntryIDM from ora_CRM_ContractMtl where FID='{0}'", FID); var srcFEntityMEIDs = CZDB_GetData(sql); if (srcFEntityMEIDs.Count > 0) { object[] objs = new object[srcFEntityMEIDs.Count]; for (int i = 0; i < srcFEntityMEIDs.Count; i++) { objs[i] = srcFEntityMEIDs[i]["FEntryIDM"].ToString(); } var srcFEntityMBillObjs = viewService.Load(this.Context, objs, srcFEntityM.DynamicObjectType); DynamicObjectCollection tgtFEntityMRows = tgtFEntityM.DynamicProperty.GetValue(dataObject) as DynamicObjectCollection; tgtFEntityMRows.Clear(); foreach (var srcRow in srcFEntityMBillObjs) { DynamicObject newRow = new DynamicObject(tgtFEntityM.DynamicObjectType); tgtFEntityMRows.Add(newRow); newRow["FMGUID"] = srcRow["FMGUID"]; newRow["FMSrcEID"] = srcRow["FMSrcEID"]; newRow["FMSrcSEQ"] = srcRow["FMSrcSEQ"]; newRow["FMMtlGroup"] = srcRow["FMMtlGroup"]; newRow["FMMtlItem"] = srcRow["FMMtlItem"]; newRow["FMClass"] = srcRow["FMClass"]; newRow["FMMtl"] = srcRow["FMMtl"]; newRow["FMModel"] = srcRow["FMModel"]; newRow["FMQty"] = srcRow["FMQty"]; newRow["FMUnit"] = srcRow["FMUnit"]; newRow["FMPrice"] = srcRow["FMPrice"]; newRow["FMAmt"] = srcRow["FMAmt"]; newRow["FMGpAmtB"] = srcRow["FMGpAmtB"]; newRow["FMCostRate"] = srcRow["FMCostRate"]; newRow["FMCost"] = srcRow["FMCost"]; newRow["FMGPRate"] = srcRow["FMGPRate"]; newRow["FMGP"] = srcRow["FMGP"]; newRow["FMGpAmt"] = srcRow["FMGpAmt"]; newRow["FMGpAmtLc"] = srcRow["FMGpAmtLc"]; newRow["FMIS2W"] = srcRow["FMIS2W"]; } } } }
private void BuildSerial(ExtendedDataEntity[] entryDataes) { List <long> col = (from s in entryDataes from ss in s.DataEntity["FEntity_Link"] as DynamicObjectCollection select ss.GetDynamicObjectItemValue <long>("SId", 0L)).Distinct <long>().ToList <long>(); if (!col.IsEmpty <long>()) { IEnumerable <DynamicObject> purSNInfo = Kingdee.K3.MFG.App.AppServiceContext.GetService <IInspectSrcService>().GetPurSNInfo(base.Context, col); if (purSNInfo.IsEmpty <DynamicObject>()) { foreach (ExtendedDataEntity entity in entryDataes) { entity.DataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0); entity.DataEntity.SetDynamicObjectItemValue("SNUnitID", null); } } else { Dictionary <long, IGrouping <long, DynamicObject> > dictionary = (from g in purSNInfo where g.GetDynamicValue <long>("FIBENTRYID", 0L) <= 0L group g by g.GetDynamicValue <long>("FENTRYID", 0L)).ToDictionary <IGrouping <long, DynamicObject>, long>(d => d.Key); FormMetadata metadata = (FormMetadata)Kingdee.K3.MFG.App.AppServiceContext.MetadataService.Load(base.Context, "QM_InspectBill", true); Entity entity2 = metadata.BusinessInfo.GetEntity("FEntity"); foreach (ExtendedDataEntity entity3 in entryDataes) { DynamicObject dataEntity = entity3.DataEntity; DynamicObjectCollection objects = dataEntity.GetDynamicValue <DynamicObjectCollection>("FEntity_Link", null); dataEntity.GetDynamicValue <long>("SrcEntryId", 0L); DynamicObjectCollection source = dataEntity.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null); DynamicObject obj3 = source.First <DynamicObject>() as DynamicObject; List <DynamicObject> list2 = new List <DynamicObject>(); foreach (DynamicObject obj4 in objects) { long key = obj4.GetDynamicValue <long>("SId", 0L); IGrouping <long, DynamicObject> grouping = null; if (dictionary.TryGetValue(key, out grouping)) { foreach (DynamicObject obj5 in grouping) { list2.Add(obj5); } } } if (list2.All <DynamicObject>(a => a.GetDynamicValue <long>("FSERIALID", 0L) <= 0L)) { dataEntity.SetDynamicObjectItemValue("SNUnitID_Id", 0); dataEntity.SetDynamicObjectItemValue("SNUnitID", null); } else { source.Clear(); List <DynamicObject> list3 = (from s in list2 orderby s.GetDynamicValue <string>("FSERIALNO", null) select s).ToList <DynamicObject>(); List <DynamicObject> list4 = (from s in list3 where !s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace() select s).ToList <DynamicObject>(); List <DynamicObject> collection = (from s in list3 where s.GetDynamicValue <string>("FSERIALNO", null).IsNullOrEmptyOrWhiteSpace() select s).ToList <DynamicObject>(); list4.AddRange(collection); int num2 = 1; DynamicObject baseUnitInfo = dataEntity.GetDynamicValue <DynamicObject>("BaseUnitId", null); DynamicObject unitInfo = dataEntity.GetDynamicValue <DynamicObject>("SNUnitID", null); foreach (DynamicObject obj8 in list4) { DynamicObject dynamicObject = obj3 as DynamicObject; dynamicObject.SetDynamicObjectItemValue("PolicyQty", 1); decimal num3 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, dynamicObject.GetDynamicValue <long>("PolicyMaterialId_Id", 0L), unitInfo, baseUnitInfo, 1M); dynamicObject.SetDynamicObjectItemValue("BasePolicyQty", num3); dynamicObject.SetDynamicObjectItemValue("Seq", num2++); if (obj8.GetDynamicValue <int>("FSERIALID", 0) != 0) { dynamicObject.SetDynamicObjectItemValue("SerialId_Id", obj8.GetDynamicValue <int>("FSERIALID", 0)); } source.Add(dynamicObject); } } } Kingdee.K3.MFG.App.AppServiceContext.DBService.LoadReferenceObject(base.Context, (from s in entryDataes select s.DataEntity).ToArray <DynamicObject>(), entity2.DynamicObjectType, true); foreach (ExtendedDataEntity entity4 in entryDataes) { DynamicObject obj10 = entity4.DataEntity; DynamicObject obj11 = obj10.GetDynamicValue <DynamicObject>("BaseUnitId", null); DynamicObject obj12 = obj10.GetDynamicValue <DynamicObject>("SNUnitID", null); if (!obj12.IsNullOrEmpty()) { DynamicObjectCollection objects3 = obj10.GetDynamicValue <DynamicObjectCollection>("PolicyDetail", null); decimal num4 = MFGQtyConvertUtil.getToBasePrecisionQty(base.Context, objects3.FirstOrDefault <DynamicObject>().GetDynamicValue <long>("PolicyMaterialId_Id", 0L), obj12, obj11, 1M); foreach (DynamicObject obj13 in objects3) { obj13.SetDynamicObjectItemValue("BasePolicyQty", num4); } } } } } }
public override void CreateNewData(BizDataEventArgs e) { DynamicObjectType dynamicObjectType = this.Model.BillBusinessInfo.GetDynamicObjectType(); Entity entity = this.View.BusinessInfo.Entrys[1]; DynamicObjectType dt = entity.DynamicObjectType; DynamicObject dataEntity = new DynamicObject(dynamicObjectType) { ["CloseDate"] = DateTime.Now.Date }; DynamicObjectCollection objects = entity.DynamicProperty.GetValue <DynamicObjectCollection>(dataEntity); BusinessObject bizObject = new BusinessObject { Id = "STK_Account", PermissionControl = 1, SubSystemId = "STK" }; List <long> valList = PermissionServiceHelper.GetPermissionOrg(base.Context, bizObject, this.isOpenAccount ? "4cc4dea42de6441ebeb21c509358d73d" : "1046d14017fd45dbaff9b1fe4affe0c6"); if ((valList == null) || (valList.Count < 1)) { e.BizDataObject = dataEntity; } else { Dictionary <string, object> batchStockDate = StockServiceHelper.GetBatchStockDate(base.Context, valList); if ((batchStockDate == null) || (batchStockDate.Keys.Count < 1)) { e.BizDataObject = dataEntity; } else { valList.Clear(); foreach (string str in batchStockDate.Keys) { valList.Add(Convert.ToInt64(str)); } List <SelectorItemInfo> list2 = new List <SelectorItemInfo> { new SelectorItemInfo("FORGID"), new SelectorItemInfo("FName"), new SelectorItemInfo("FNumber"), new SelectorItemInfo("FDescription") }; string str2 = this.GetInFilter(" FORGID", valList) + $" AND FDOCUMENTSTATUS = 'C' AND FFORBIDSTATUS = 'A' AND (FORGFUNCTIONS like'%103%') AND EXISTS(SELECT 1 FROM T_BAS_SYSTEMPROFILE BSP WHERE BSP.FCATEGORY = 'STK' AND BSP.FORGID = FORGID AND BSP.FACCOUNTBOOKID = 0 AND BSP.FKEY = 'IsInvEndInitial' AND BSP.FVALUE = '1') {(this.isOpenAccount ? "AND EXISTS(SELECT 1 FROM T_STK_CLOSEPROFILE SCP WHERE SCP.FCATEGORY = 'STK' AND SCP.FORGID = FORGID )" : "")} "; QueryBuilderParemeter para = new QueryBuilderParemeter { FormId = "ORG_Organizations", SelectItems = list2, FilterClauseWihtKey = str2, OrderByClauseWihtKey = "", IsolationOrgList = null, RequiresDataPermission = true }; DynamicObjectCollection source = QueryServiceHelper.GetDynamicObjectCollection(base.Context, para, null); DataTable stockOrgAcctLastCloseDate = CommonServiceHelper.GetStockOrgAcctLastCloseDate(base.Context, ""); Dictionary <long, DateTime> dictionary2 = new Dictionary <long, DateTime>(); foreach (DataRow row in stockOrgAcctLastCloseDate.Rows) { if (!(row["FCLOSEDATE"] is DBNull) && !string.IsNullOrWhiteSpace(row["FCLOSEDATE"].ToString())) { dictionary2[Convert.ToInt64(row["FORGID"])] = Convert.ToDateTime(row["FCLOSEDATE"]); } } int num = 0; if ((source != null) && (source.Count <DynamicObject>() > 0)) { foreach (DynamicObject obj4 in source) { long key = Convert.ToInt64(obj4["FORGID"]); DynamicObject item = new DynamicObject(dt) { ["Check"] = true, ["StockOrgNo"] = obj4["FNumber"].ToString(), ["StockOrgName"] = ((obj4["FName"] == null) || string.IsNullOrEmpty(obj4["FName"].ToString())) ? "" : obj4["FName"].ToString(), ["StockOrgDesc"] = ((obj4["FDescription"] == null) || string.IsNullOrEmpty(obj4["FDescription"].ToString())) ? "" : obj4["FDescription"].ToString(), ["StockOrgID"] = obj4["FORGID"].ToString(), ["Result"] = "", ["RetFlag"] = false, ["Seq"] = num++ }; if (dictionary2.ContainsKey(key)) { item["LastCloseDate"] = dictionary2[key]; } objects.Add(item); } } e.BizDataObject = dataEntity; } } }
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); } } }
private void ShowErrTypeInfo() { long curStockOrgId; Entity entryEntity = this.View.BusinessInfo.GetEntryEntity("FEntityErrType"); DynamicObjectType dynamicObjectType = entryEntity.DynamicObjectType; DynamicObjectCollection entityDataObject = this.Model.GetEntityDataObject(entryEntity); entityDataObject.Clear(); if ((this.opResults == null) || (this.opResults.Count < 1)) { this.ClearEntity("FEntityErrInfo"); this.ShowHideErrTabDetail(null, ErrType.None); this.View.UpdateView("FEntityErrType"); this.ShowErrGrid(true); } else { int entryCurrentRowIndex = this.Model.GetEntryCurrentRowIndex("FEntityAction"); curStockOrgId = Convert.ToInt64(this.Model.GetValue("FStockOrgID", entryCurrentRowIndex)); StockOrgOperateResult result = this.opResults.SingleOrDefault <StockOrgOperateResult>(p => p.StockOrgID == curStockOrgId); if ((result == null) || result.OperateSuccess) { this.ClearEntity("FEntityErrInfo"); this.ShowHideErrTabDetail(null, ErrType.None); this.View.UpdateView("FEntityErrType"); this.ShowErrGrid(true); } else { DynamicObject obj2; if ((result.ErrInfo != null) && result.ErrInfo.Exists(p => p.ErrType < Convert.ToInt32(ErrType.UnAuditBill))) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.OrgStatusErr, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织状态不符合{0}操作条件", "004023030002140", SubSystemType.SCM, new object[0]), this.isOpenAccount ? ResManager.LoadKDString("反关账", "004023030000238", SubSystemType.SCM, new object[0]) : ResManager.LoadKDString("关账", "004023030000241", SubSystemType.SCM, new object[0])) }; entityDataObject.Add(obj2); } if ((result.ErrInfo != null) && result.ErrInfo.Exists(p => p.ErrType == Convert.ToInt32(ErrType.UnAuditBill))) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.UnAuditBill, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织存在未审核的库存单据", "004023030002143", SubSystemType.SCM, new object[0]), new object[0]) }; entityDataObject.Add(obj2); } if ((result.StkBillDraftErrInfo != null) && (result.StkBillDraftErrInfo.Count > 0)) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.StkDraftBill, ["ErrTypeName"] = ResManager.LoadKDString("当前组织存在暂存的库存单据", "004023000022222", SubSystemType.SCM, new object[0]) }; entityDataObject.Add(obj2); } if ((result.StkCountBillAuditErrInfo != null) && (result.StkCountBillAuditErrInfo.Count > 0)) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.UnAuditStkCountBill, ["ErrTypeName"] = ResManager.LoadKDString("当前组织存在未审核的盘点单据", "004023000018755", SubSystemType.SCM, new object[0]) }; entityDataObject.Add(obj2); } if (result.MinusErrObject != null) { obj2 = new DynamicObject(dynamicObjectType) { ["ErrorType"] = ErrType.Minus, ["ErrTypeName"] = string.Format(ResManager.LoadKDString("当前组织存在异常库存数据", "004023030002146", SubSystemType.SCM, new object[0]), new object[0]) }; entityDataObject.Add(obj2); } this.View.UpdateView("FEntityErrType"); this.View.SetEntityFocusRow("FEntityErrType", 0); this.ShowErrInfo(); } } }