public JsonResult SaveExcelData() { var reader = new System.IO.StreamReader(HttpContext.Request.InputStream); string data = reader.ReadToEnd(); var tempdata = JsonConvert.DeserializeObject <Dictionary <string, string> >(data); var list = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(tempdata["data"]); foreach (var item in list) { T_HSE_HazardSourceIdentity_Temple tmp = new T_HSE_HazardSourceIdentity_Temple(); tmp.ID = FormulaHelper.CreateGuid(); tmp.CreateDate = DateTime.Now; tmp.ModifyDate = DateTime.Now; tmp.CreateUserID = CurrentUserInfo.UserID; tmp.CreateUser = CurrentUserInfo.UserName; tmp.ModifyUserID = CurrentUserInfo.UserID; tmp.ModifyUser = CurrentUserInfo.UserName; tmp.OrgID = CurrentUserInfo.UserOrgID; tmp.CompanyID = CurrentUserInfo.UserCompanyID; tmp.WorkArea = item.GetValue("WorkArea"); tmp.HazardSource = item.GetValue("HazardSource"); tmp.ProbableEvent = item.GetValue("ProbableEvent"); tmp.Probably = Convert.ToInt32(item.GetValue("Probably")); tmp.Seriousness = Convert.ToInt32(item.GetValue("Seriousness")); tmp.RiskDegree = (tmp.Probably * tmp.Seriousness).ToString(); tmp.MajorRisk = item.GetValue("MajorRisk") == "是" ? "1" : "0"; tmp.ControlMeasure = item.GetValue("ControlMeasure"); tmp.Remark = item.GetValue("Remark"); EPCEntites.Set <T_HSE_HazardSourceIdentity_Temple>().Add(tmp); } EPCEntites.SaveChanges(); return(Json("Success")); }
protected override void AfterGetData(Dictionary <string, object> dic, bool isNew, string upperVersionID) { base.AfterGetData(dic, isNew, upperVersionID); string ContractID = dic.GetValue("ContractID"); if (isNew) { ContractID = GetQueryString("ContractID"); } var lastVersionID = dic.GetValue("LastVersionID"); if (string.IsNullOrEmpty(lastVersionID)) { var contract = EPCEntites.Set <S_P_ContractInfo>().Find(ContractID); dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); } else { string LastVersionID = dic.GetValue("LastVersionID"); var change = EPCEntites.Set <S_P_FbContractChange>().Find(LastVersionID); if (change != null) { S_P_ContractInfo contract = new S_P_ContractInfo(); FormulaHelper.UpdateEntity(contract, change.ToDic());//只带合同信息,去掉审批字段数据 dic.SetValue("LastVersionData", JsonHelper.ToJson(contract)); } } }
// protected override void BeforeDelete(string[] Ids) { base.BeforeDelete(Ids); foreach (var Id in Ids) { //如果进度款审核表选择的是必须已通过的计量单则已通过计量单是不会删除的,在这种情况下这判断就显得多余 bool bExist = EPCEntites.Set <S_P_ContractInfo_Fb_BOQPriceCheck>().Any(a => a.BOQCheckIDs.Contains(Id)); if (bExist) { throw new Formula.Exceptions.BusinessValidationException("已经关联了分包合同的进度款审核表,无法删除"); } //流程撤销或者删除的情况下需要处理S_C_BOQ的CheckQuantity else { var boqCheck = EPCEntites.Set <S_P_ContractInfo_Fb_BOQCheck>().Find(Id); var detailList = EPCEntites.Set <S_P_ContractInfo_Fb_BOQCheck_Detail>().Where(a => a.S_P_ContractInfo_Fb_BOQCheckID == Id).ToList(); foreach (S_P_ContractInfo_Fb_BOQCheck_Detail detail in detailList) { //累计部分删除已经确认的数量 S_C_BOQ boq = EPCEntites.Set <S_C_BOQ>().Find(detail.S_C_BOQID); boq.CheckQuantityTotal = (boq.CheckQuantityTotal ?? 0) - detail.ConfirmQuantity; //如果boq没有被任何计量单应用则lock改为false //其中a.ID != detail.ID,排除自己(将要被删除所以不算在内) if (!EPCEntites.Set <S_P_ContractInfo_Fb_BOQCheck_Detail>().Any(a => a.S_C_BOQID == detail.S_C_BOQID && a.ID != detail.ID)) { boq.Locked = false; } } } } }
public JsonResult GetLastDetailInfo(string ID, string VersionID) { var detail = this.GetEntityByID <S_C_BOQ_Version_Detail>(ID); var currDetailVersion = EPCEntites.Set <S_C_BOQ_Version>().Find(detail.VersionID); var result = new Dictionary <string, object>(); if (detail != null && currDetailVersion != null) { var lastVersion = EPCEntites.Set <S_C_BOQ_Version>() .Where(d => d.ContractInfoID == currDetailVersion.ContractInfoID && d.FlowPhase == "End" && d.VersionNumber < currDetailVersion.VersionNumber) .OrderByDescending(c => c.VersionNumber).FirstOrDefault(); if (lastVersion == null) { var boq = this.GetEntityByID <S_C_BOQ>(detail.BOQID); if (boq != null) { result = FormulaHelper.ModelToDic <S_C_BOQ>(boq); } } else { var lastDetail = EPCEntites.Set <S_C_BOQ_Version_Detail>().FirstOrDefault(a => a.BOQID == detail.BOQID && a.VersionID == lastVersion.ID); if (lastDetail != null) { result = FormulaHelper.ModelToDic <S_C_BOQ_Version_Detail>(lastDetail); } } } return(Json(result)); }
private List <S_C_BOQ_Version_Detail> GetSearchList(QueryBuilder qb, string VersionID, string ShowType) { var boqVersionList = EPCEntites.Set <S_C_BOQ_Version_Detail>().Where(a => a.VersionID == VersionID); if (boqVersionList == null) { return(new List <S_C_BOQ_Version_Detail>()); } qb.SortField = "SortIndex"; qb.SortOrder = "asc"; qb.PageSize = 0; if (!String.IsNullOrEmpty(ShowType) && ShowType.ToLower() == "diff") { //只显示差异数据 qb.Add("ModifyState", QueryMethod.NotEqual, "Normal"); boqVersionList = EPCEntites.Set <S_C_BOQ_Version_Detail>().Where(a => a.VersionID == VersionID).Where(qb); } else if (!String.IsNullOrEmpty(ShowType) && ShowType.ToLower() == "new") { //只显示最新版本的数据,不体现差异 qb.Add("ModifyState", QueryMethod.NotEqual, "Remove"); boqVersionList = EPCEntites.Set <S_C_BOQ_Version_Detail>().Where(c => c.VersionID == VersionID).Where(qb); } else { //显示全部数据,体现差异 boqVersionList = EPCEntites.Set <S_C_BOQ_Version_Detail>().Where(c => c.VersionID == VersionID).Where(qb); } return(boqVersionList.ToList()); }
public JsonResult Revert(string latestPlanID) { EPCEntites.Set <S_F_CapitalCompanyPlan>().Delete(a => a.ID == latestPlanID); EPCEntites.Set <S_F_CapitalCompanyPlan_Detail>().Delete(a => a.S_F_BudgetProjectID == latestPlanID); EPCEntites.SaveChanges(); return(Json("")); }
protected override void OnFlowEnd(T_I_ManagerNominate entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { if (entity != null) { entity.Push(); #region 生成项目仓库 var engineeringInfo = EPCEntites.Set <S_I_Engineering>().Find(entity.EngineeringInfoID); if (engineeringInfo == null) { throw new Formula.Exceptions.BusinessValidationException("未能找到指定的工程信息"); } var storage = EPCEntites.Set <S_W_StorageInfo>().FirstOrDefault(a => a.Engineering == engineeringInfo.ID); if (storage == null) { storage = new S_W_StorageInfo { ID = FormulaHelper.CreateGuid(), Name = engineeringInfo.Name, Type = StorageType.Project.ToString(), Engineering = engineeringInfo.ID, EngineeringName = engineeringInfo.Name }; EntityCreateLogic <S_W_StorageInfo>(storage); EPCEntites.Set <S_W_StorageInfo>().Add(storage); } #endregion this.EPCEntites.SaveChanges(); } }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { base.BeforeSaveSubTable(dic, subTableName, detailList, formInfo); if (dic.GetValue("Operation") == "Change" && subTableName == "DeviceList") { foreach (var detail in detailList) { var applyID = dic.GetValue("T_P_InvitationApplyID"); var bomId = detail.GetValue("PBomID"); var applyDetailID = detail.GetValue("ApplyDetailID"); var orlID = detail.GetValue("OrlID"); var quantity = 0.0m; decimal.TryParse(detail.GetValue("InvitationQuantity"), out quantity); var otherQuantity = EPCEntites.Set <T_P_InvitationApply_DeviceList>().Where(a => a.PBomID == bomId && a.T_P_InvitationApplyID != applyID).ToList().Sum(a => a.InvitationQuantity ?? 0); var procurementApplyBomQuantity = EPCEntites.Set <S_P_ProcurementApply_PBom>().Where(a => a.ID == applyDetailID).ToList().Sum(a => a.Quantity); var procurementApplyBomContractQuantity = EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.ApplyDetailID == applyDetailID).ToList().Sum(a => a.ContractQuantity); var procurementApplyBomResultQuantity = EPCEntites.Set <T_P_ComparisonResult_DeviceInfo>().Where(a => a.ApplyDetailID == applyDetailID).ToList().Sum(a => a.InvitationQuantity); var maxQuantity = procurementApplyBomQuantity - procurementApplyBomContractQuantity - procurementApplyBomResultQuantity - otherQuantity; var minQuantity = EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.ApplyDetailID == orlID).ToList().Sum(a => a.ContractQuantity); if (quantity > maxQuantity) { throw new BusinessException("【" + detail.GetValue("PBomName") + "】的数量不能超过" + maxQuantity); } if (quantity < minQuantity) { throw new BusinessException("【" + detail.GetValue("PBomName") + "】的数量不能少于采购合同设备数量" + minQuantity); } } } }
public JsonResult RemovePaymentObj(string PaymentData) { //付款项 付过钱 收过票不能删除 var list = JsonHelper.ToList(PaymentData); foreach (var item in list) { var paymentObject = this.GetEntityByID <S_P_ContractInfo_PaymentObj>(item.GetValue("OrlID")); if (paymentObject != null) { if (paymentObject.SumInvoiceValue > 0) { throw new Formula.Exceptions.BusinessValidationException("付款项【" + paymentObject.Name + "】已经有收票信息,无法进行删除"); } if (paymentObject.SumPaymentValue > 0) { throw new Formula.Exceptions.BusinessValidationException("付款项【" + paymentObject.Name + "】已经有付款信息,无法进行删除"); } EPCEntites.Set <S_P_ContractInfo_PaymentObj>().Remove(paymentObject); } } EPCEntites.SaveChanges(); return(Json("")); }
protected override void OnFlowEnd(S_P_ProcurementApplyChange entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { //撤销 if (entity.Operation == "Cancel") { var bomIds = entity.S_P_ProcurementApplyChange_PBom.GroupBy(a => a.BomID).Select(a => a.Key).ToList(); foreach (var bomId in bomIds) { var pbom = this.EPCEntites.Set <S_P_Bom>().FirstOrDefault(c => c.ID == bomId); pbom.ApplyQuantity = this.EPCEntites.Set <S_P_ProcurementApply_PBom>().Where(a => a.BomID == pbom.ID && a.S_P_ProcurementApplyID != entity.S_P_ProcurementApplyID).ToList().Sum(a => a.Quantity); } EPCEntites.Set <S_P_ProcurementApply>().Delete(a => a.ID == entity.S_P_ProcurementApplyID); } else if (entity.Operation == "Change") { var apply = EPCEntites.Set <S_P_ProcurementApply>().Find(entity.S_P_ProcurementApplyID); //如果第一次进行变更 if (string.IsNullOrEmpty(entity.LastVersionId)) { S_P_ProcurementApplyChange firstChange = new S_P_ProcurementApplyChange(); this.UpdateEntity(firstChange, apply.ToDic()); firstChange.ID = FormulaHelper.CreateGuid(); firstChange.S_P_ProcurementApplyID = apply.ID; firstChange.FlowPhase = "End"; firstChange.Operation = "Initial";//原数据 foreach (var tmp in apply.S_P_ProcurementApply_PBom) { S_P_ProcurementApplyChange_PBom pbom = new S_P_ProcurementApplyChange_PBom(); pbom.ID = FormulaHelper.CreateGuid(); this.UpdateEntity(pbom, tmp.ToDic()); pbom.S_P_ProcurementApplyChangeID = firstChange.ID; pbom.OrlID = tmp.ID; firstChange.S_P_ProcurementApplyChange_PBom.Add(pbom); } entity.LastVersionId = firstChange.ID; EPCEntites.Set <S_P_ProcurementApplyChange>().Add(firstChange); } var operaApplyBoms = entity.S_P_ProcurementApplyChange_PBom.ToList(); var newQuantityApplyBoms = new List <S_P_ProcurementApply_PBom>(); foreach (var op in operaApplyBoms) { var old = EPCEntites.Set <S_P_ProcurementApply_PBom>().SingleOrDefault(a => a.ID == op.OrlID); old.Quantity = op.Quantity;//更新数量 newQuantityApplyBoms.Add(old); } //更新bom var dictAppBoms = newQuantityApplyBoms.GroupBy(a => a.BomID).Select(a => new { BomId = a.Key, SumQuantity = a.Sum(b => b.Quantity) }).ToList(); foreach (var appBom in dictAppBoms) { var pbom = this.EPCEntites.Set <S_P_Bom>().FirstOrDefault(c => c.ID == appBom.BomId); pbom.ApplyQuantity = this.EPCEntites.Set <S_P_ProcurementApply_PBom>().Where(a => a.BomID == pbom.ID && a.S_P_ProcurementApplyID != entity.S_P_ProcurementApplyID).ToList().Sum(a => a.Quantity); pbom.ApplyQuantity += appBom.SumQuantity; } } this.EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(S_P_ContractInfo_Fb_BOQCheck entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); //将之前的所有计量期全部设置为完成 S_P_ContractInfo_Fb_SettlePeriod period = EPCEntites.Set <S_P_ContractInfo_Fb_SettlePeriod>().Find(entity.SettlePeriodID); EPCEntites.Set <S_P_ContractInfo_Fb_SettlePeriod>().Where(a => a.PeriodNum < period.PeriodNum && a.ContractInfoID == period.ContractInfoID).ToList().Update(a => a.Finished = true); }
public JsonResult CheckSpecialDetailTempleCanAdd(string tempTypeValue) { string id = GetQueryString("ID"); int templateType = Convert.ToInt32(tempTypeValue); bool exist = EPCEntites.Set <S_P_ContractInfo_Fb_BOQPayCheck_DetailTemplate>().Any(a => a.PayCheckDetailType == templateType && a.ID != id); return(Json(!exist)); }
public JsonResult SetContractState(string State) { string id = GetQueryString("ID"); if (string.IsNullOrEmpty(id)) { throw new BusinessException("需要选择一条合同数据,请重新确认!"); } S_P_ContractInfo contract = EPCEntites.Set <S_P_ContractInfo>().Find(id); if (contract == null) { throw new BusinessException("未找到合同数据"); } contract.ContractState = State; //终止后释放数量 if (State == "Terminate") { if (contract.S_P_ContractInfo_Content.Any(a => a.ArrivalQuantity > 0)) { throw new Exception("已经有到货记录的设备,不能终止"); } if (contract.S_P_Payment.Count > 0) { throw new Exception("已有付款记录,不能终止"); } if (contract.S_P_Invoice.Count > 0) { throw new Exception("已经有开票记录,不能终止"); } contract.SelectOrder = ""; contract.SelectOrderName = ""; foreach (var content in contract.S_P_ContractInfo_Content) { content.ApplyBomID = ""; content.ApplyDetailID = ""; content.ApplyFormCode = ""; content.ApplyFormID = ""; } var contentBom = contract.S_P_ContractInfo_Content.GroupBy(a => a.PBomID).Select(b => new { BomID = b.Key, Quantity = b.Sum(t => t.ContractQuantity), ContentIDs = b.Select(t => t.ID) }).ToList(); foreach (var tmp in contentBom) { //同一工程下,已签订的不包括本合同的content数量 var newContractQuantity = EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.S_P_ContractInfo.EngineeringInfoID == contract.EngineeringInfoID && a.PBomID == tmp.BomID && a.S_P_ContractInfo.SignDate != null && !tmp.ContentIDs.Contains(a.ID)).ToList().Sum(a => a.ContractQuantity); EPCEntites.Set <S_P_Bom>().Where(a => a.ID == tmp.BomID).Update(a => a.ContractQuantity = newContractQuantity); } } EPCEntites.SaveChanges(); return(Json("")); }
public JsonResult GetFolderTree() { string engineeringInfoID = GetQueryString("EngineeringInfoID"); var engineeringInfo = EPCEntites.Set <S_I_Engineering>().Find(engineeringInfoID); string sql = GetFolderTreeSql(GetQueryString("EngineeringInfoID"), engineeringInfo.Name, "FullID"); var res = this.EPCSQLDB.ExecuteDataTable(sql); return(Json(res)); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { base.BeforeSave(dic, formInfo, isNew); S_I_Engineering engineering = EPCEntites.Set <S_I_Engineering>().Find(dic.GetValue("EngineeringInfoID")); if (engineering.State != ProjectState.Bid.ToString()) { throw new Formula.Exceptions.BusinessValidationException("已经完成立项的项目不能修改投标结果"); } }
public JsonResult GetBOQCheckDetail(string boqCheckIDs) { if (string.IsNullOrEmpty(boqCheckIDs)) { return(Json("")); } string[] idArr = boqCheckIDs.Split(','); var details = (from a in EPCEntites.Set <S_P_ContractInfo_Fb_BOQCheck_Detail>() where idArr.Contains(a.S_P_ContractInfo_Fb_BOQCheckID) join b in EPCEntites.Set <S_C_BOQ>() on a.S_C_BOQID equals b.ID group new { a, b } by new { a.S_C_BOQID, a.Code, a.Name, a.Unit, b.UnitPrice } into c select new { S_C_BOQID = c.Key.S_C_BOQID, //不取a.xx 采用的是当时清单信息 Code = c.Key.Code, Name = c.Key.Name, Unit = c.Key.Unit, ContractInfoQuantity = c.Sum(a => a.a.ContractInfoQuantity), LastPeriodTotal = c.Sum(a => a.a.LastPeriodTotal), DeclareQuantity = c.Sum(a => a.a.DeclareQuantity), ConfirmQuantity = c.Sum(a => a.a.ConfirmQuantity), PeriodTotal = c.Sum(a => a.a.PeriodTotal), //取b.xx 采用的是最新的信息 UnitPrice = c.Key.UnitPrice, //LastPeriodTotalPrice = Convert.ToDecimal(a.LastPeriodTotal) * b.UnitPrice ?? 0, //DeclarePrice = Convert.ToDecimal(a.DeclareQuantity) * b.UnitPrice ?? 0, //ConfirmPrice = Convert.ToDecimal(a.ConfirmQuantity) * b.UnitPrice ?? 0, //PeriodTotalPrice = Convert.ToDecimal(a.PeriodTotal) * b.UnitPrice ?? 0 //处理linq中不识别Convert.ToDecimal 转化为内存数据再进行Convert.ToDecimal转化 }).ToList().Select(a => new { S_C_BOQID = a.S_C_BOQID, //不取a.xx 采用的是当时清单信息 Code = a.Code, Name = a.Name, Unit = a.Unit, Quantity = a.ContractInfoQuantity, LastPeriodTotal = a.LastPeriodTotal, DeclareQuantity = a.DeclareQuantity, ConfirmQuantity = a.ConfirmQuantity, PeriodTotal = a.PeriodTotal, //取b.xx 采用的是最新的信息 UnitPrice = a.UnitPrice, LastPeriodTotalPrice = Convert.ToDecimal(a.LastPeriodTotal) * (a.UnitPrice ?? 0), DeclarePrice = Convert.ToDecimal(a.DeclareQuantity) * (a.UnitPrice ?? 0), ConfirmPrice = Convert.ToDecimal(a.ConfirmQuantity) * (a.UnitPrice ?? 0), PeriodTotalPrice = Convert.ToDecimal(a.PeriodTotal) * (a.UnitPrice ?? 0) }); return(Json(details)); }
public JsonResult GetTreeList(QueryBuilder qb, string VersionID, string ShowType, string showAllPBS) { qb.SortField = "SortIndex"; qb.SortOrder = "asc"; qb.PageSize = 0; var version = EPCEntites.Set<S_C_BOQ_Version>().Find(VersionID); if (version == null) { return Json(""); } var result = GetSearchList(qb, VersionID, ShowType, showAllPBS); return Json(result); }
public override JsonResult Delete() { this.BeforeDelete(Request["ListIDs"].Split(',')); var contractIDs = Request["ListIDs"].Split(','); S_I_Engineering engineering = null; foreach (var contractID in contractIDs) { S_P_ContractInfo contract = this.GetEntityByID <S_P_ContractInfo>(contractID); engineering = contract.S_I_Engineering; var contents = contract.S_P_ContractInfo_Content.ToList(); foreach (var content in contents) { var pBom = EPCEntites.Set <S_P_Bom>().Find(content.PBomID); if (pBom == null) { continue; } //throw new BusinessException("未找到id为【" + content.PBomID + "】的PBom"); //pbom更新以SignDate是否有值为标准,有值说明之前pbom是统计过这个合同额的,因此要扣除 if (contract.SignDate != null) { pBom.ContractQuantity -= content.ContractQuantity; } if (EPCEntites.Set <S_P_ContractInfo_Content>().Count(a => a.PBomID == pBom.ID && a.ID != content.ID) == 0) { pBom.Locked = false; pBom.FactContractDate = null; } } foreach (var content in contract.S_P_ContractInfo_Content.ToList()) { this.EPCEntites.Set <S_P_ContractInfo_Content>().Remove(content); } foreach (var content in contract.S_P_ContractInfo_PaymentObj.ToList()) { this.EPCEntites.Set <S_P_ContractInfo_PaymentObj>().Remove(content); } foreach (var content in contract.S_P_ContractInfo_CBSInfo.ToList()) { this.EPCEntites.Set <S_P_ContractInfo_CBSInfo>().Remove(content); } this.EPCEntites.Set <S_P_ContractInfo>().Remove(contract); this.EPCEntites.Set <S_I_CBS_Contract>().Delete(c => c.RelateID == contract.ID); } this.EPCEntites.SaveChanges(); if (engineering != null) { engineering.SumCBSContractValue(); } return(Json("")); }
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_P_ContractInfo_Fb_BOQPriceCheck entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); foreach (var tmp in entity.S_P_ContractInfo_Fb_BOQPriceCheck_Detail.ToList()) { string boqID = tmp.S_C_BOQID; decimal justCheckPrice = tmp.ConfirmPrice ?? 0; S_C_BOQ boq = EPCEntites.Set <S_C_BOQ>().Find(boqID); //累计已计价部分 boq.CheckPriceTotal = (boq.CheckPriceTotal ?? 0) + justCheckPrice; } }
protected override void OnFlowEnd(T_P_FbContractReview entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); var contract = EPCEntites.Set <S_P_ContractInfo>().Find(entity.ContractID); if (contract == null) { throw new Formula.Exceptions.BusinessValidationException("找不到id为【" + entity.ContractID + "】的分包合同"); } contract.ContractState = "Review"; EPCEntites.SaveChanges(); }
protected override void OnFlowEnd(S_C_BOQ_Version entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { entity.State = "Publish"; var detailList = EPCEntites.Set <S_C_BOQ_Version_Detail>().Where(a => a.VersionID == entity.ID).ToList(); foreach (var item in detailList) { if (item.ModifyState == "Normal") { continue; } var itemDic = FormulaHelper.ModelToDic <S_C_BOQ_Version_Detail>(item); if (item.ModifyState == "Add") { S_C_BOQ boq = new S_C_BOQ(); boq.ID = item.BOQID; boq.Code = item.Code; boq.Name = item.Name; boq.Property = item.Property; boq.Quantity = item.Quantity; boq.Price = item.Price; boq.Remark = item.Remark; boq.Unit = item.Unit; boq.UnitPrice = item.UnitPrice; boq.VersionNo = entity.VersionNumber; boq.ContractInfoID = entity.ContractInfoID; EPCEntites.Set <S_C_BOQ>().Add(boq); } else if (item.ModifyState == "Remove") { EPCEntites.Set <S_C_BOQ>().Delete(a => a.ID == item.BOQID); } else if (item.ModifyState == "Modify") { var boq = EPCEntites.Set <S_C_BOQ>().Find(item.BOQID); if (boq == null) { boq = new S_C_BOQ(); boq.ID = item.BOQID; } boq.VersionNo = entity.VersionNumber; //boq._state FormulaHelper.UpdateEntity <S_C_BOQ>(boq, itemDic, true); } else { throw new Formula.Exceptions.BusinessValidationException(item.ModifyState + "没有if分支处理"); } } EPCEntites.SaveChanges(); }
public JsonResult ImportNodeTemplate() { var engineeringInfoID = GetQueryString("EngineeringInfoID"); if (string.IsNullOrEmpty(engineeringInfoID)) { throw new Formula.Exceptions.BusinessValidationException("engineeringInfoID参数不能为空"); } var nodeIDs = GetQueryString("NodeIDs"); if (string.IsNullOrEmpty(nodeIDs)) { throw new Formula.Exceptions.BusinessValidationException("节点id(NodeIDs)参数不能为空,且格式为id,id,id"); } var nodeIDList = nodeIDs.Split(','); foreach (var nodeID in nodeIDList) { T_HSE_EnvironmentalFactorsIdentification_Detail identity = new T_HSE_EnvironmentalFactorsIdentification_Detail(); var temple = EPCEntites.Set <T_HSE_EnvironmentalFactorsIdentification_Temple>().Find(nodeID); if (temple == null) { throw new Formula.Exceptions.BusinessValidationException("id为" + nodeID + "的T_HSE_EnvironmentalFactorsIdentification_Temple数据不存在"); } identity.WorkArea = temple.WorkArea; identity.TotalValue = temple.TotalValue; identity.Tense = temple.Tense; identity.State = temple.State; identity.RuleValue = temple.RuleValue; identity.Remark = temple.Remark; identity.RateValue = temple.RateValue; identity.OrgID = temple.OrgID; identity.IncidenceValue = temple.IncidenceValue; identity.ImportEnvironmentalFactor = temple.ImportEnvironmentalFactor; identity.ImpactValue = temple.ImpactValue; identity.ID = FormulaHelper.CreateGuid(); identity.EnvironmentalFactor = temple.EnvironmentalFactor; identity.EnvironmentalEffect = temple.EnvironmentalEffect; identity.CreateUserID = CurrentUserInfo.UserID; identity.CreateUser = CurrentUserInfo.UserName; identity.CreateDate = DateTime.Now; identity.ConcernValue = temple.ConcernValue; identity.CompanyID = temple.CompanyID; identity.EngineeringInfoID = engineeringInfoID; EPCEntites.Set <T_HSE_EnvironmentalFactorsIdentification_Detail>().Add(identity); } EPCEntites.SaveChanges(); return(Json("")); }
protected override void OnFlowEnd(T_C_CreditNoteApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { entity.State = "Wait"; var contract = EPCEntites.Set <S_M_ContractInfo>().Find(entity.Contract); if (contract == null) { throw new Formula.Exceptions.BusinessException("没有找到对应的合同信息,开票操作失败"); } entity.Submit(); EPCEntites.SaveChanges(); contract.SummaryInvoiceData(); EPCEntites.SaveChanges(); }
public JsonResult GetConstructionTree(string BiddingOfferID) { var data = this.EPCEntites.Set <S_M_BidOffer_CBS>().Include("S_M_BidOffer_CBS_Detail").Where(d => d.BidOfferID == BiddingOfferID && d.CBSType == "Construction"). OrderBy(d => d.SortIndex).ToList(); var result = new List <Dictionary <string, object> >(); foreach (var item in data) { var dic = FormulaHelper.ModelToDic <S_M_BidOffer_CBS>(item);//Construction 结构cbs dic.SetValue("TypeInfo", "CBS"); result.Add(dic); int subCBSCountofConstructionCBS = EPCEntites.Set <S_M_BidOffer_CBS>().Count(a => a.CBSFullID.Contains(item.CBSID) && a.CBSFullID != item.CBSID); //如果首次添加数据,默认添加pbs节点 if (subCBSCountofConstructionCBS == 0) { S_M_BidOffer bidOffer = EPCEntites.Set <S_M_BidOffer>().Find(BiddingOfferID); if (bidOffer == null) { throw new Formula.Exceptions.BusinessValidationException("没有找到指定的报价,无法载入pbs"); } var pbsList = EPCEntites.Set <S_I_PBS>().Where(a => a.EngineeringInfoID == bidOffer.EngineeringInfoID && a.NodeType == "SubProject").ToList(); foreach (var pbs in pbsList) { var subCBS = item.AddEmptyChild(); subCBS.Name = pbs.Name; subCBS.Code = pbs.Code; var detailDic = FormulaHelper.ModelToDic <S_M_BidOffer_CBS>(subCBS); detailDic.SetValue("TypeInfo", "CBS"); detailDic.SetValue("NodeType", "CBS"); result.Add(detailDic); } EPCEntites.SaveChanges(); } else { foreach (var detail in item.S_M_BidOffer_CBS_Detail.ToList()) { var detailDic = FormulaHelper.ModelToDic <S_M_BidOffer_CBS_Detail>(detail); detailDic.SetValue("TypeInfo", "Detail"); detailDic.SetValue("NodeType", "Detail"); result.Add(detailDic); } } } return(Json(result)); }
protected override void OnFlowEnd(T_M_ContractReview entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing) { base.OnFlowEnd(entity, taskExec, routing); //entity.ContractState = "Review"; T_M_ContractReview contract = EPCEntites.Set <T_M_ContractReview>().Find(entity.ID); contract.Approver = CurrentUserInfo.UserID; contract.ApproverName = CurrentUserInfo.UserName; contract.ApproverDate = DateTime.Now; //if (contract == null) // throw new BusinessException("已无法找到id为【" + entity.Contract + "】的合同信息"); //contract.ContractState = "Review"; //EPCEntites.SaveChanges(); }
protected override void BeforeSaveSubTable(Dictionary <string, string> dic, string subTableName, List <Dictionary <string, string> > detailList, Base.Logic.Domain.S_UI_Form formInfo) { base.BeforeSaveSubTable(dic, subTableName, detailList, formInfo); if (dic.GetValue("Operation") == "Change" && subTableName == "PBom") { var bomIdDicList = detailList.GroupBy(a => a.GetValue("BomID")).Select(a => a.Key); foreach (var bomId in bomIdDicList) { var quantity = 0.0m; foreach (var detail in detailList.Where(a => a.GetValue("BomID") == bomId)) { var tmp = 0.0m; decimal.TryParse(detail.GetValue("Quantity"), out tmp); quantity += tmp; } var bom = EPCEntites.Set <S_P_Bom>().Find(bomId); var applyID = dic.GetValue("S_P_ProcurementApplyID"); var otherQuantity = EPCEntites.Set <S_P_ProcurementApply_PBom>().Where(a => a.BomID == bomId && a.S_P_ProcurementApplyID != applyID).ToList().Sum(a => a.Quantity ?? 0); var maxQuantity = bom.Quantity - otherQuantity; if (quantity > maxQuantity) { throw new BusinessException("设备【" + bom.Name + "】的数量不能超过" + maxQuantity); } } foreach (var detail in detailList) { var detailId = detail.GetValue("ID"); var name = detail.GetValue("Name"); var quantity = 0.0m; decimal.TryParse(detail.GetValue("Quantity"), out quantity); var minQuantity = 0.0m; //minQuantity += EPCEntites.Set<T_P_InvitationApply_DeviceList>().Where(a => a.ApplyDetailID == detailId).ToList().Sum(a => a.InvitationQuantity ?? 0); //minQuantity += EPCEntites.Set<T_P_ComparisonResult_DeviceInfo>().Where(a => a.ApplyDetailID == detailId).ToList().Sum(a => a.InvitationQuantity ?? 0); //minQuantity += EPCEntites.Set<S_P_ContractInfo_Content>().Where(a => a.ApplyDetailID == detailId).ToList().Sum(a => a.ContractQuantity ?? 0); //if (quantity < minQuantity) //{ // throw new BusinessException("明细【" + name + "】的数量不能少于已用于招标、比价、订单的数量之和" + minQuantity); // } minQuantity += EPCEntites.Set <S_P_ContractInfo_Content>().Where(a => a.ApplyBomID == detailId).ToList().Sum(a => a.ContractQuantity ?? 0); if (quantity < minQuantity) { throw new BusinessException("明细【" + name + "】的数量不能少于该申请已签订数量" + minQuantity); } } } }
//获取子表数据 public JsonResult GetBudgetList(string id, string monthColArr) { if (string.IsNullOrEmpty(id)) { return(Json("")); } var sourceDicList = JsonHelper.ToList(monthColArr); //预算明细 var detailList = EPCEntites.Set <S_F_CapitalCompanyPlan_Detail>().Where(a => a.S_F_BudgetProjectID == id).ToList(); //预算明细对应的模板id列表 var templateIDList = detailList.GroupBy(a => a.TemplateID).Select(a => a.First()).Select(a => a.TemplateID); List <Dictionary <string, object> > result = new List <Dictionary <string, object> >(); foreach (var templateID in templateIDList) { Dictionary <string, object> dic = new Dictionary <string, object>(); var sameTemplateIDDetailList = detailList.Where(a => a.TemplateID == templateID); var tmp = sameTemplateIDDetailList.FirstOrDefault(); dic.SetValue("Name", tmp.Name); dic.SetValue("ID", templateID); dic.SetValue("ParentID", tmp.ParentTemplateID); dic.SetValue("FullID", tmp.FullTemplateID); dic.SetValue("SortIndex", tmp.SortIndex); dic.SetValue("CapitalPlanType", tmp.CapitalPlanType); dic.SetValue("AddOrSub", GetAddOrSub(tmp.CapitalPlanType)); dic.SetValue("SourceSQL", tmp.SourceSQL); dic.SetValue("RealSourceSQL", tmp.RealSourceSQL); dic.SetValue("SourceLink", tmp.SourceLink); dic.SetValue("RealSourceLink", tmp.RealSourceLink); dic.SetValue("IsReadOnly", tmp.IsReadOnly); dic.SetValue("HaveSource", !string.IsNullOrEmpty(tmp.SourceSQL)); dic.SetValue("HaveLink", !string.IsNullOrEmpty(tmp.SourceLink)); //月份列 foreach (var sourceDic in sourceDicList) { DateTime budgetDate = Convert.ToDateTime(sourceDic.GetValue("year") + "-" + sourceDic.GetValue("month")); var cell = sameTemplateIDDetailList.SingleOrDefault(a => a.TemplateID == templateID && a.BudgetDate == budgetDate); dic.SetValue(sourceDic.GetValue("colName"), cell != null ? cell.BudgetValue : 0); } result.Add(dic); } return(Json(result.OrderBy(a => a.GetValue("SortIndex")))); }
public JsonResult InvoiceSubmit(string Ids) { var data = Ids.Split(','); foreach (var item in data) { var entity = this.GetEntityByID(item); if (entity == null) { throw new Formula.Exceptions.BusinessException("未能找到ID未【" + entity.ID + "】的开票申请记录,无法进行开票处理"); } entity.Submit(); } EPCEntites.SaveChanges(); return(Json("")); }
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(); }