public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { string tmplCode = Request["TmplCode"]; var formInfo = baseEntities.Set <S_UI_Form>().Where(c => c.Code == tmplCode).OrderByDescending(c => c.ID).FirstOrDefault(); //获取最新一个版本即可 var entity = this.GetEntityByID <T>(taskExec.S_WF_InsFlow.FormInstanceID); bool flag = false; Workflow.Logic.BusinessFacade.FlowFO flowFO = new Workflow.Logic.BusinessFacade.FlowFO(); flag = flowFO.ExecTask(taskExec.ID, routing.ID, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment, Request["RoutingID"]); //流程表单定义的流程逻辑 ExecFlowLogic(routing.Code, taskExec.S_WF_InsFlow.FormInstanceID, ""); SetFormFlowInfo(taskExec.S_WF_InsFlow); if (flag) { if (entity == null) { throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑"); } OnFlowEnd(entity, taskExec, routing); } this.BusinessEntities.SaveChanges(); if (routing != null) { routing.ExeLogic(); this.entities.SaveChanges(); } return(flag); }
public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { var auditStateArray = Enum.GetNames(typeof(Project.Logic.AuditState)); var str = ""; for (int i = 0; i < auditStateArray.Length; i++) { if ((i + 1) % 5 != 0) { str += auditStateArray[i] + "、"; } else { str += "<br/>" + auditStateArray[i] + "、"; } } var workFlowEntities = FormulaHelper.GetEntities <WorkflowEntities>(); var nextStep = workFlowEntities.Set <S_WF_InsDefStep>().SingleOrDefault(c => c.ID == routing.EndID); if (!string.IsNullOrEmpty(nextStep.Code) && !auditStateArray.Contains(nextStep.Code)) { throw new Formula.Exceptions.BusinessException("校审环节【" + nextStep.Code + "】不符合要求,流程未能启动<br/>" + "环节编号只能是:" + str.TrimEnd('、')); } return(base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment)); }
public virtual bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { FlowFO flowFO = new FlowFO(); //流程表单定义的流程逻辑 ExecFlowLogic(routing.Code, taskExec.S_WF_InsFlow.FormInstanceID); return(flowFO.ExecTask(taskExec.ID, routing.ID, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment, Request["RoutingID"])); }
public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { var entity = this.BusinessEntities.Set <S_I_IdentifyApply>().SingleOrDefault(c => c.ID == taskExec.S_WF_InsFlow.FormInstanceID); if (entity != null) { var state = IdentifyState.InFlow.ToString(); var infoIDs = entity.S_I_IdentifyApply_DetailInfo.Select(a => a.IdentifyInfoID).ToArray(); this.BusinessEntities.Set <S_I_IdentifyInfo>().Where(a => infoIDs.Contains(a.ID)).Update(a => a.State = state); this.BusinessEntities.SaveChanges(); } return(base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment)); }
public string NewRule(string defineID, string beginActivityID, string endAcitivityID, string name) { string result = ""; string guid = FormulaHelper.CreateGuid(); try { var flowDef = entities.Set <S_WF_InsDefFlow>().Where(c => c.ID == defineID).SingleOrDefault(); if (flowDef == null) { throw new Exception("指定的工作流定义未找到"); } var startStep = entities.Set <S_WF_InsDefStep>().Where(c => c.ID == beginActivityID).SingleOrDefault(); var endStep = entities.Set <S_WF_InsDefStep>().Where(c => c.ID == endAcitivityID).SingleOrDefault(); var routing = new S_WF_InsDefRouting(); routing.ID = guid; routing.InsDefStepID = startStep.ID; routing.EndID = endStep.ID; routing.InsDefFlowID = defineID; routing.SortIndex = startStep.S_WF_InsDefRouting.Count; routing.Type = RoutingType.Normal.ToString(); routing.Name = "送" + endStep.Name; routing.AllowDoBack = "1"; //默认允许打回 2014-12-1 routing.SaveForm = "1"; //默认自动保存表单 2014-12-1 routing.MustInputComment = "1"; //默认弹出意见框 2014-12-1 routing.AllowWithdraw = "1"; //默认允许撤销 2014-12-1 entities.Set <S_WF_InsDefRouting>().Add(routing); if (routing.Name == "送结束") { routing.Name = "结束"; routing.SelectMode = ""; } entities.SaveChanges(); result = guid; } catch (Exception exp) { LogWriter.Error(exp); result = "Error"; } return(result); }
public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { if (routing.Code == "End") { var formInstanceID = taskExec.S_WF_InsFlow.FormInstanceID; var financeElectronicDocumentDownloadEntity = this.BusinessEntities.Set<T_FDM_FinanceElectronicDocumentDownload>().Find(formInstanceID); if (financeElectronicDocumentDownloadEntity == null) throw new BusinessException("获取当前下载申请单失败,请联系管理员!"); var deitals = financeElectronicDocumentDownloadEntity.T_FDM_FinanceElectronicDocumentDownload_Detail.ToList(); if (deitals != null && deitals.Count > 0) { var fedIds = deitals.Select(c => c.FinanceElectronicDocumentInfoID).ToArray(); var financeElectronicDocumentEntiys = this.BusinessEntities.Set<T_FDM_FinanceElectronicDocumentUpload>() .Where(c => fedIds.Contains(c.ID)).ToList(); financeElectronicDocumentEntiys.Update(c => c.DownLoadCount = c.DownLoadCount + 1); this.BusinessEntities.SaveChanges(); } } return base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment); }
public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { var rtn = base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment); var dt = this.MarketSQLDB.ExecuteDataTable("SELECT * FROM T_C_ContractReview WHERE ID='" + taskExec.S_WF_InsFlow.FormInstanceID + "'"); if (dt.Rows.Count > 0) { var dic = Formula.FormulaHelper.DataRowToDic(dt.Rows[0]); if (!String.IsNullOrEmpty(dic.GetValue("ContractID"))) { this.MarketSQLDB.ExecuteNonQuery("Update S_C_ManageContract set FlowPhase='" + dic.GetValue("FlowPhase") + "' where ID='" + dic.GetValue("ContractID") + "'"); if (rtn) { this.MarketSQLDB.ExecuteNonQuery(String.Format("Update S_C_ManageContract set ContractState='{0}' where ID='{1}'", "WaitSign", dic.GetValue("ContractID"))); } } } return(rtn); }
public override bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { var result = base.ExecTaskExec(taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment); var entity = this.GetEntityByID(taskExec.S_WF_InsFlow.FormInstanceID); if (entity == null) { throw new Formula.Exceptions.BusinessException("实体ID为空,未能找到相关实体对象,无法执行逻辑"); } if (result) { this.OnFlowEnd(entity, taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment); } else { this.OnExecute(entity, taskExec, routing, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment); } return(result); }
protected override void OnFlowEnd(S_EP_ProductionProgressConfirmAdjustInfo data, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (data != null) { data.Push(); } }
protected override void OnFlowEnd(T_BM_RepaymentForm entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); entity.Push(); this.BusinessEntities.SaveChanges(); }
protected override void OnFlowEnd(S_EP_ProductionBatchSettleApply data, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (data != null) { data.Push(); } }
protected override void OnFlowEnd(S_EP_SubContractSettlement data, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (data != null) { data.Push(); } }
protected virtual void OnFlowEnd(T entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { }
protected virtual void OnFlowEnd(T entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { }
protected override void OnFlowEnd(S_EP_ReimbursementApply entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); entity.Push(); this.BusinessEntities.SaveChanges(); }
public virtual bool ExecTaskExec(S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing, string nextExecUserIDs, string nextExecUserNames, string nextExecUserIDsGroup, string nextExecRoleIDs, string nextExecOrgIDs, string execComment) { FlowFO flowFO = new FlowFO(); return(flowFO.ExecTask(taskExec.ID, routing.ID, nextExecUserIDs, nextExecUserNames, nextExecUserIDsGroup, nextExecRoleIDs, nextExecOrgIDs, execComment, Request["RoutingID"]));//Request["RoutingID"] 当分支路由时,其值为逗号隔开的全部分支ID }
protected override void OnFlowEnd(S_P_ProcurementContractChange entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var contract = entity.Push(); this.EPCEntites.SaveChanges(); AfterSave(contract.ToDic()); }
protected override void OnFlowEnd(T_M_ContractInfo entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var project = EPCEntites.Set <T_I_EngineeringBuild>().FirstOrDefault(c => c.ID == entity.ProjectInfo); if (project != null) { project.Programme = entity.Programme; project.ConstructionFeatures = entity.ConstructionFeatures; project.ConstructionSite = entity.ConstructionSite; } EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(S_EP_IncomeInvoiceConfirmRevert data, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (data != null) { data.Push(); } }
protected override void OnFlowEnd(T_M_ContractInfoChange entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); var contract = EPCEntites.Set <T_M_ContractInfo>().Find(entity.ContractInfoID); var scontract = EPCEntites.Set <S_M_ContractInfo>().FirstOrDefault(c => c.TContractInfoID == contract.ID); if (entity != null && contract != null) { var ps = typeof(T_M_ContractInfo).GetProperties(); foreach (PropertyInfo item in ps) { string name = item.Name; string type = item.PropertyType.Name; object value = item.GetValue(entity, null); if (type != "ICollection`1" && name != "ContractInfoID" && name != "VersionNumber" && name != "ID" & value != null) { item.SetValue(contract, value, null); } } } if (entity != null && scontract != null) { var ps = typeof(S_M_ContractInfo).GetProperties(); foreach (PropertyInfo item in ps) { string name = item.Name; string type = item.PropertyType.Name; object value = item.GetValue(entity, null); if (type != "ICollection`1" && name != "ContractInfoID" && name != "VersionNumber" && name != "ID" & value != null) { item.SetValue(scontract, value, null); } } } var project = EPCEntites.Set <T_I_EngineeringBuild>().FirstOrDefault(c => c.ID == entity.ProjectInfo); if (project != null) { project.Programme = entity.Programme; project.ConstructionFeatures = entity.ConstructionFeatures; project.ConstructionSite = entity.ConstructionSite; } this.EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(T_W_WarehouseScrap entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var equipmentDetail = entity.T_W_WarehouseScrap_EquipmentDetail.ToList(); var equipmentAccount = this.EPCEntites.Set <S_W_EquipmentAccount>().Where(a => a.StorageInfoID == entity.StorageInfo && a.Account > 0 && a.LeftCount > 0).ToList(); var storageAccounts = this.EPCEntites.Set <S_W_EquipmentAccount>().Where(a => a.StorageInfoID == entity.StorageInfo).ToList(); var latestEquipments = this.EPCEntites.Set <S_W_LatestEquipment>().Where(a => a.StorageInfoID == entity.StorageInfo).ToList(); foreach (var equipment in equipmentDetail) { var accounts = equipmentAccount.Where(a => a.ExpirationDate == equipment.ExpirationDate && a.Code == equipment.Code && a.Name == equipment.Name && a.Supplier == equipment.Supplier).ToList(); if (accounts.Count <= 0) { continue; } var accountSum = equipmentAccount.Sum(a => a.LeftCount); if (Math.Abs(accountSum == null ? 0 : (decimal)accountSum) < Math.Abs(equipment.Count == null ? 0 : (decimal)equipment.Count)) { continue; } var leftCount = equipment.Count; while (leftCount > 0) { var detailSql = string.Format("select Top 1 * from T_W_WarehouseScrap_EquipmentDetail where ID = '{0}'", equipment.ID); //直接把查询的数据转成 S_W_EquipmentAccount var detail = this.EPCSQLDB.ExecuteObject <S_W_EquipmentAccount>(detailSql); detail.ID = FormulaHelper.CreateGuid(); detail.FillDate = entity.FillDate; detail.FillUser = entity.FillUser; detail.FillUserName = entity.FillUserName; detail.StorageInfoID = entity.StorageInfo; detail.Type = EquipmentAccountType.Scrap.ToString(); detail.FormID = entity.ID; detail.Specification = accounts[0].Specification; detail.Branding = accounts[0].Branding; detail.Material = accounts[0].Material; detail.MaterialSub = accounts[0].MaterialSub; detail.Supplier = accounts[0].Supplier; detail.SupplierName = accounts[0].SupplierName; detail.ExpirationDate = accounts[0].ExpirationDate; detail.RootID = accounts[0].RootID; detail.PBomID = accounts[0].PBomID; detail.ExchangeRate = accounts[0].ExchangeRate; detail.RMBTaxRate = accounts[0].RMBTaxRate; if (leftCount >= accounts[0].LeftCount) { detail.Account = -accounts[0].LeftCount; detail.LeftCount = detail.Account; leftCount -= accounts[0].LeftCount; detail.UnitPrice = accounts[0].UnitPrice; detail.TotalPrice = Math.Abs((decimal)(detail.UnitPrice * detail.Account)); detail.RMBTotalPrice = detail.TotalPrice * detail.ExchangeRate; detail.RMBTaxPrice = Math.Abs((decimal)(accounts[0].RMBTaxPrice / accounts[0].Account * detail.Account)); detail.RMBTaxOutPrice = detail.RMBTotalPrice - detail.RMBTaxPrice; accounts[0].LeftCount = 0; accounts.RemoveAt(0); } else { accounts[0].LeftCount = accounts[0].LeftCount - leftCount; detail.Account = -leftCount; detail.LeftCount = detail.Account; leftCount = 0; detail.UnitPrice = accounts[0].UnitPrice; detail.TotalPrice = Math.Abs((decimal)(detail.UnitPrice * detail.Account)); detail.RMBTotalPrice = detail.TotalPrice * detail.ExchangeRate; detail.RMBTaxPrice = Math.Abs((decimal)(accounts[0].RMBTaxPrice / accounts[0].Account * detail.Account)); detail.RMBTaxOutPrice = detail.RMBTotalPrice - detail.RMBTaxPrice; } this.EPCEntites.Set <S_W_EquipmentAccount>().Add(detail); storageAccounts.Add(detail); var latest = latestEquipments.FirstOrDefault(a => a.Supplier == detail.Supplier && a.Code == detail.Code && a.Name == detail.Name && a.ExpirationDate == detail.ExpirationDate && a.PBomID == detail.PBomID); if (latest != null) { var list = storageAccounts.Where(a => a.Supplier == latest.Supplier && a.Code == latest.Code && a.Name == latest.Name && a.ExpirationDate == latest.ExpirationDate && a.PBomID == latest.PBomID).ToList(); decimal count = 0, total = 0, totalRMB = 0, tax = 0, taxOut = 0; foreach (var item in list) { count += (decimal)item.Account; total += (decimal)item.Account * (decimal)item.UnitPrice; totalRMB += (decimal)item.Account * (decimal)item.UnitPrice * (decimal)item.ExchangeRate; tax += (decimal)(item.Account > 0 ? item.RMBTaxPrice : (0 - item.RMBTaxPrice)); taxOut += (decimal)(item.Account > 0 ? item.RMBTaxOutPrice : (0 - item.RMBTaxOutPrice)); } var type = EquipmentAccountType.Scrap.ToString(); var scrapCount = Math.Abs((decimal)list.Where(a => a.Type == type).Sum(a => a.Account)); latest.Account = count; latest.TotalPrice = Math.Round(total, 2); latest.RMBTotalPrice = Math.Round(totalRMB, 2); latest.RMBTaxPrice = Math.Round(tax, 2); latest.RMBTaxOutPrice = Math.Round(taxOut, 2); latest.UnitPrice = latest.Account == 0 ? latest.UnitPrice : Math.Round((decimal)(latest.TotalPrice / latest.Account), 2); latest.ScrapCount = scrapCount; } } } this.EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(T_W_WarehouseEntry entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var equipmentDetail = entity.T_W_WarehouseEntry_EquipmentDetail.ToList(); var storageAccounts = this.EPCEntites.Set <S_W_EquipmentAccount>().Where(a => a.StorageInfoID == entity.StorageInfo).ToList(); var latestEquipments = this.EPCEntites.Set <S_W_LatestEquipment>().Where(a => a.StorageInfoID == entity.StorageInfo).ToList(); if (entity.Type != EntryType.Allot.ToString()) { #region 采购 var detailSql = string.Format("select * from T_W_WarehouseEntry_EquipmentDetail where T_W_WarehouseEntryID = '{0}'", entity.ID); //直接把查询的数据转成 List<S_W_EquipmentAccount> var details = this.EPCSQLDB.ExecuteList <S_W_EquipmentAccount>(detailSql); foreach (var detail in details) { detail.FillDate = entity.FillDate; detail.FillUser = entity.FillUser; detail.FillUserName = entity.FillUserName; detail.StorageInfoID = entity.StorageInfo; detail.Type = EquipmentAccountType.Entry.ToString(); detail.FormID = entity.ID; detail.RootID = detail.ID; detail.ExchangeRate = entity.ExchangeRate; detail.PBomID = string.IsNullOrEmpty(detail.PBomID) ? "" : detail.PBomID; var equipment = equipmentDetail.FirstOrDefault(a => a.ID == detail.ID); if (equipment != null) { detail.Account = equipment.Count; detail.LeftCount = equipment.Count; //修改合同设备清单的到货数 var content = this.EPCEntites.Set <S_P_ContractInfo_Content>().FirstOrDefault(a => a.ID == equipment.ContentID); if (content != null) { content.YetCount = this.EPCEntites.Set <T_W_WarehouseEntry_EquipmentDetail>(). Where(a => a.ContentID == content.ID).ToList().Sum(a => a.Count); } var pbom = this.EPCEntites.Set <S_P_Bom>().FirstOrDefault(a => a.ID == equipment.PBomID); if (pbom != null) { if (string.IsNullOrEmpty(detail.Specification)) { detail.Specification = pbom.Specification; } if (string.IsNullOrEmpty(detail.Branding)) { detail.Branding = pbom.Branding; } if (string.IsNullOrEmpty(detail.Material)) { detail.Material = pbom.Material; } if (string.IsNullOrEmpty(detail.MaterialSub)) { detail.MaterialSub = pbom.MaterialSub; } } } this.EPCEntites.Set <S_W_EquipmentAccount>().Add(detail); storageAccounts.Add(detail); var latest = latestEquipments.FirstOrDefault(a => a.Supplier == detail.Supplier && a.Code == detail.Code && a.Name == detail.Name && a.ExpirationDate == detail.ExpirationDate && a.PBomID == detail.PBomID); if (latest == null) { latest = new S_W_LatestEquipment { ID = FormulaHelper.CreateGuid(), StorageInfoID = detail.StorageInfoID, Code = detail.Code, Name = detail.Name, Model = detail.Model, Specification = detail.Specification, Branding = detail.Branding, Material = detail.Material, MaterialSub = detail.MaterialSub, Supplier = detail.Supplier, SupplierName = detail.SupplierName, Unit = detail.Unit, ExpirationDate = detail.ExpirationDate, PBomID = detail.PBomID }; this.EPCEntites.Set <S_W_LatestEquipment>().Add(latest); } var list = storageAccounts.Where(a => a.Supplier == latest.Supplier && a.Code == latest.Code && a.Name == latest.Name && a.ExpirationDate == latest.ExpirationDate && a.PBomID == latest.PBomID).ToList(); decimal count = 0, total = 0, totalRMB = 0, tax = 0, taxOut = 0; foreach (var item in list) { count += (decimal)item.Account; total += (decimal)item.Account * (decimal)item.UnitPrice; totalRMB += (decimal)item.Account * (decimal)item.UnitPrice * (decimal)item.ExchangeRate; tax += (decimal)(item.Account > 0 ? item.RMBTaxPrice : (0 - item.RMBTaxPrice)); taxOut += (decimal)(item.Account > 0 ? item.RMBTaxOutPrice : (0 - item.RMBTaxOutPrice)); } latest.Account = count; latest.TotalPrice = Math.Round(total, 2); latest.RMBTotalPrice = Math.Round(totalRMB, 2); latest.RMBTaxPrice = Math.Round(tax, 2); latest.RMBTaxOutPrice = Math.Round(taxOut, 2); latest.UnitPrice = latest.Account == 0 ? latest.UnitPrice : Math.Round((decimal)(latest.TotalPrice / latest.Account), 2); } #endregion } else { #region 调拨 var allotID = entity.RelateForm; var equipmentAccounts = this.EPCEntites.Set <S_W_EquipmentAccount>().Where(a => a.FormID == allotID).ToList(); foreach (var equipmentAccount in equipmentAccounts) { var newAccount = equipmentAccount.Clone <S_W_EquipmentAccount>(); newAccount.ID = FormulaHelper.CreateGuid(); newAccount.FillDate = entity.FillDate; newAccount.FillUser = entity.FillUser; newAccount.FillUserName = entity.FillUserName; newAccount.RootID = equipmentAccount.RootID; newAccount.StorageInfoID = entity.StorageInfo; newAccount.Account = -newAccount.Account; newAccount.LeftCount = newAccount.Account; newAccount.Type = EquipmentAccountType.Entry.ToString(); newAccount.FormID = entity.ID; this.EPCEntites.Set <S_W_EquipmentAccount>().Add(newAccount); storageAccounts.Add(newAccount); var latest = latestEquipments.FirstOrDefault(a => a.Supplier == newAccount.Supplier && a.Code == newAccount.Code && a.Name == newAccount.Name && a.ExpirationDate == newAccount.ExpirationDate && a.PBomID == newAccount.PBomID); if (latest == null) { latest = new S_W_LatestEquipment { ID = FormulaHelper.CreateGuid(), StorageInfoID = newAccount.StorageInfoID, Code = newAccount.Code, Name = newAccount.Name, Model = newAccount.Model, Specification = newAccount.Specification, Branding = newAccount.Branding, Material = newAccount.Material, MaterialSub = newAccount.MaterialSub, Supplier = newAccount.Supplier, SupplierName = newAccount.SupplierName, Unit = newAccount.Unit, ExpirationDate = newAccount.ExpirationDate, PBomID = newAccount.PBomID }; this.EPCEntites.Set <S_W_LatestEquipment>().Add(latest); } var list = storageAccounts.Where(a => a.Supplier == latest.Supplier && a.Code == latest.Code && a.Name == latest.Name && a.ExpirationDate == latest.ExpirationDate && a.PBomID == latest.PBomID).ToList(); decimal count = 0, total = 0, totalRMB = 0, tax = 0, taxOut = 0; foreach (var item in list) { count += (decimal)item.Account; total += (decimal)item.Account * (decimal)item.UnitPrice; totalRMB += (decimal)item.Account * (decimal)item.UnitPrice * (decimal)item.ExchangeRate; tax += (decimal)(item.Account > 0 ? item.RMBTaxPrice : (0 - item.RMBTaxPrice)); taxOut += (decimal)(item.Account > 0 ? item.RMBTaxOutPrice : (0 - item.RMBTaxOutPrice)); } latest.Account = count; latest.TotalPrice = Math.Round(total, 2); latest.RMBTotalPrice = Math.Round(totalRMB, 2); latest.RMBTaxPrice = Math.Round(tax, 2); latest.RMBTaxOutPrice = Math.Round(taxOut, 2); latest.UnitPrice = latest.Account == 0 ? latest.UnitPrice : Math.Round((decimal)(latest.TotalPrice / latest.Account), 2); } #endregion } //回写Bom的物资编码 foreach (var content in entity.T_W_WarehouseEntry_EquipmentDetail) { var bom = this.GetEntityByID <S_P_Bom>(content.PBomID); if (bom != null) { if (!string.IsNullOrEmpty(content.Code) && content.Code != bom.Number) { bom.Number = content.Code; } } } this.EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(S_I_DestroyApply entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var state = IdentifyState.Finish.ToString(); var infoIDs = entity.S_I_DestroyApply_DetailInfo.Select(a => a.IdentifyInfoID).ToArray(); var IdentifyApplyDetailInfoIDs = entity.S_I_DestroyApply_DetailInfo.Select(a => a.IdentifyApplyDetailInfoID).ToArray(); this.BusinessEntities.Set <S_I_IdentifyApply_DetailInfo>().Where(a => IdentifyApplyDetailInfoIDs.Contains(a.ID)).Update(a => a.HandleResult = state); var apply = this.BusinessEntities.Set <S_I_IdentifyApply>().FirstOrDefault(a => a.ID == entity.IdentifyApplyID); if (apply != null) { if (apply.S_I_IdentifyApply_DetailInfo.Count(a => !IdentifyApplyDetailInfoIDs.Contains(a.ID) && a.HandleResult != state) == 0) { apply.HandleState = HandleState.Finish.ToString(); } else { apply.HandleState = HandleState.Part.ToString(); } } var updateDic = new Dictionary <S_DOC_Space, StringBuilder>(); var infos = this.BusinessEntities.Set <S_I_IdentifyInfo>().Where(a => infoIDs.Contains(a.ID)).ToList(); foreach (var info in infos) { info.State = state; var space = DocConfigHelper.CreateConfigSpaceByID(info.SpaceID); var nodeInfo = new S_NodeInfo(info.NodeID, space); if (!updateDic.ContainsKey(space)) { updateDic.Add(space, new StringBuilder()); } updateDic[space].AppendLine(string.Format(@" update S_NodeInfo set [State] = '{0}' where FullPathID like '{1}%' update S_FileInfo set [State] = '{0}' where FullNodeID like '{1}%'", DocState.Invalid.ToString(), nodeInfo.FullPathID)); } foreach (var item in updateDic.Keys) { var instanceDB = SQLHelper.CreateSqlHelper(item.SpaceKey, item.ConnectString); instanceDB.ExecuteNonQuery(updateDic[item].ToString()); } //添加销毁记录 var IdentifyApplyDetails = this.BusinessEntities.Set <S_I_IdentifyApply_DetailInfo>().Where(a => IdentifyApplyDetailInfoIDs.Contains(a.ID)).Select(a => a).ToList(); foreach (var IdentifyApplyDetail in IdentifyApplyDetails) { var identifyInfo = this.BusinessEntities.Set <S_I_IdentifyInfo>().FirstOrDefault(b => b.ID.Equals(IdentifyApplyDetail.IdentifyInfoID)); S_NodeInfo node = new S_NodeInfo(identifyInfo.NodeID, FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(b => b.ID.Equals(identifyInfo.SpaceID))); InventoryFO.CreateNewInventoryLedger(node, "", InventoryType.Destroy); } }
protected override void OnFlowEnd(S_EP_SupplierContractConfirm data, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { CheckSubContractConfirmMethod(); if (data != null) { data.Push(); } }
protected override void OnFlowEnd(S_SU_DocumentRelieveSeal entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var detailIst = entity.S_SU_DocumentRelieveSeal_DetailList.ToList(); var spaceList = new List <S_DOC_Space>(); var spaceIDs = detailIst.Where(a => !string.IsNullOrEmpty(a.SpaceID)).Select(a => a.SpaceID).ToList(); foreach (var spaceID in spaceIDs) { var nodeIds = detailIst.Where(a => a.SpaceID == spaceID && !string.IsNullOrEmpty(a.RelateID)).Select(a => a.RelateID); StringBuilder sb = new StringBuilder(); var space = spaceList.FirstOrDefault(a => a.ID == spaceID); if (space == null) { space = DocConfigHelper.CreateConfigSpaceByID(spaceID); spaceList.Add(space); } var db = SQLHelper.CreateSqlHelper(space.SpaceKey, space.ConnectString); foreach (var nodeid in nodeIds) { sb.AppendLine("update S_NodeInfo set State = '" + DocState.Normal.ToString() + "',RackNumber='" + entity.RelieveSealRackNumber + "',RackNumberName='" + entity.RelieveSealRackNumberName + "',StorageRoom='" + entity.RelieveSealStorageRoom + "',StorageRoomName='" + entity.RelieveSealStorageRoomName + "' where FullPathID like '%" + nodeid + "%'"); sb.AppendLine("update S_FileInfo set State = '" + DocState.Normal.ToString() + "' where FullNodeID like '%" + nodeid + "%'"); } if (sb.Length > 0) { db.ExecuteNonQuery(sb.ToString()); } } foreach (var detail in detailIst) { if (detail.RelateType.Equals("Node")) { S_NodeInfo node = new S_NodeInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID))); InventoryFO.CreateNewInventoryLedger(node, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal); } else { S_FileInfo file = new S_FileInfo(detail.RelateID, Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(detail.SpaceID))); InventoryFO.CreateNewInventoryLedger(file, "\"库房\"修改为:\"" + entity.RelieveSealStorageRoomName + "\";\"货架号\"修改为:\"" + entity.RelieveSealRackNumberName + "\"", InventoryType.RelieveSeal); } } }
protected override void OnFlowEnd(T_E_BomFetchPlan entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (entity != null) { foreach (var item in entity.T_E_BomFetchPlan_BomDetail.ToList()) { var pbom = this.EPCEntites.Set <S_P_Bom>().FirstOrDefault(c => c.ID == item.BomID); if (pbom == null) { continue; } pbom.PlanFetchDate = item.PlanFetchDate; pbom.PlanPacthID = entity.ID; } this.EPCEntites.SaveChanges(); } }
protected override void OnFlowEnd(S_C_RectifySheet entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { foreach (var item in entity.S_C_RectifySheet_RectifyProblems.ToList()) { if (item.RectifyState == "Closed") { item.CloseDate = System.DateTime.Now.Date; } } this.EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(T_BM_NoPaymentConfirmation entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); if (entity == null) { throw new Formula.Exceptions.BusinessException("获取当前未还款确认失败,请联系管理员!"); } entity.Push(); this.BusinessEntities.SaveChanges(); }
protected override void OnFlowEnd(S_E_MajorPutInfo entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { if (entity != null) { entity.Push(); this.EPCEntites.SaveChanges(); } }
protected override void OnFlowEnd(T_EXE_TaskWorkPublish entity, S_WF_InsTaskExec taskExec, S_WF_InsDefRouting routing) { var baseconfig = FormulaHelper.GetEntities <BaseConfigEntities>(); var taskWorks = entity.T_EXE_TaskWorkPublish_TaskWork; var RoleNames = baseconfig.Set <S_D_RoleDefine>().ToList(); foreach (var taskWork in taskWorks) { var cbs = this.BusinessEntities.Set <S_C_CBS>().FirstOrDefault(a => a.ProjectInfoID == entity.ProjectInfoID && a.Code == taskWork.Major); var budget = this.BusinessEntities.Set <S_C_CBS_Budget>().FirstOrDefault(a => a.ID == taskWork.TaskWorkID); if (budget == null) { budget = new S_C_CBS_Budget(); budget.ID = taskWork.TaskWorkID; budget.Name = taskWork.Name; budget.Code = taskWork.Code; cbs.AddBudget(budget); } budget.Quantity = taskWork.Workload; if (budget.Quantity.HasValue && budget.UnitPrice.HasValue) { budget.TotalValue = budget.Quantity.Value * budget.UnitPrice.Value; } if (!string.IsNullOrEmpty(taskWork.RoleRate)) { var roles = JsonHelper.ToList(taskWork.RoleRate); foreach (var role in roles) { var roleRateID = role.GetValue("ID"); var subBudget = this.BusinessEntities.Set <S_C_CBS_Budget>().FirstOrDefault(a => a.ID == roleRateID); if (subBudget == null) { subBudget = new S_C_CBS_Budget(); subBudget.ID = roleRateID; subBudget.Code = role.GetValue("Role"); subBudget.Name = RoleNames.FirstOrDefault(a => a.RoleCode == subBudget.Code).RoleName; budget.AddChild(subBudget); } subBudget.Quantity = string.IsNullOrEmpty(role.GetValue("Workload")) ? 0m : Convert.ToDecimal(role.GetValue("Workload")); if (subBudget.Quantity.HasValue && subBudget.UnitPrice.HasValue) { subBudget.TotalValue = subBudget.Quantity.Value * subBudget.UnitPrice.Value; } } } var task = this.BusinessEntities.Set <S_W_TaskWork>().FirstOrDefault(a => a.ID == taskWork.TaskWorkID); if (task != null) { task.State = TaskWorkState.Execute.ToString(); if (taskWork.IsChanged == "true") { task.Workload = taskWork.Workload; task.PlanEndDate = taskWork.PlanEndDate; if (!string.IsNullOrEmpty(taskWork.RoleRate)) { var role = JsonHelper.ToList(taskWork.RoleRate); foreach (var r in role) { var roleRate = this.GetEntityByID <S_W_TaskWork_RoleRate>(r.GetValue("ID")); roleRate.Workload = string.IsNullOrEmpty(r.GetValue("Workload")) ? 0m : Convert.ToDecimal(r.GetValue("Workload")); roleRate.Rate = string.IsNullOrEmpty(r.GetValue("Rate")) ? 0m : Convert.ToDecimal(r.GetValue("Rate")); } } } task.Publish(); } this.BusinessEntities.SaveChanges(); cbs.Ansestors.FirstOrDefault(a => a.NodeType == CBSNodeType.Root.ToString()).SummaryBudget(); } this.BusinessEntities.SaveChanges(); }