/// <summary> /// 展示Excel 数据 /// </summary> /// <param name="fileName"></param> /// <returns></returns> public JsonResult PresentExcelData(string fileName) { var ajaxData = new AjaxDataResult() { code = 1, msg = "未获取到数据!" }; try { //获取分页数据 var list = GetExcelData(fileName); if (list != null) { ajaxData.code = 0; ajaxData.msg = "获取数据成功!"; ajaxData.data = list; ajaxData.count = list.Count; } } catch (Exception ex) { ajaxData.msg = ex.Message; } return(Json(ajaxData, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存方法 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonResult Save(PlanBatchInfo model) { var ajaxData = new AjaxDataResult() { code = 0, msg = "保存失败!" }; try { if (model != null) { db.PlanBatchInfos.Add(model); var result = db.SaveChanges() > 0; if (result) { ajaxData.code = 1; ajaxData.msg = "保存成功!"; } } } catch (Exception ex) { ajaxData.msg = ex.Message; } return(Json(ajaxData, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 批量导入Excel数据 /// </summary> /// <param name="planBatchStr"></param> /// <returns></returns> public JsonResult SaveExcelData(string planBatchStr) { var ajaxModel = new AjaxDataResult() { code = 1, msg = "保存成功!" }; try { var list = new List <PlanBatchInfo>(); if (!string.IsNullOrEmpty(planBatchStr)) { list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PlanBatchInfo> >(planBatchStr); } foreach (var model in list) { db.PlanBatchInfos.Add(model); } db.SaveChanges(); } catch (Exception ex) { ajaxModel.code = 0; ajaxModel.msg = "保存失败!"; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取页面分页数据 /// </summary> /// <returns></returns> public JsonResult GetPageData() { var ajaxModel = new AjaxDataResult() { code = 1, msg = "未获取到数据!" }; var queryModel = new PlanBatchQueryModel { page = !string.IsNullOrEmpty(Request["page"]) ? Convert.ToInt32(Request["page"]) : 1, limit = !string.IsNullOrEmpty(Request["limit"]) ? Convert.ToInt32(Request["limit"]) : 10, PlanBatch = Request["PlanBatch"], PlanName = Request["PlanName"], CityPlace = Request["CityPlace"], BidMode = Request["BidMode"], BuildWay = Request["BuildWay"], BidYear = Request["BidYear"] }; if (!string.IsNullOrEmpty(Request["PlanStartDt"])) { queryModel.PlanStartDt = Convert.ToDateTime(Request["PlanStartDt"]); } if (!string.IsNullOrEmpty(Request["PlanEndDt"])) { queryModel.PlanEndDt = Convert.ToDateTime(Request["PlanEndDt"]); } var list = db.PlanBatchInfos.Where(m => (string.IsNullOrEmpty(queryModel.PlanBatch) || (!string.IsNullOrEmpty(queryModel.PlanBatch) && m.PlanBatch.Contains(queryModel.PlanBatch))) && (string.IsNullOrEmpty(queryModel.PlanName) || (!string.IsNullOrEmpty(queryModel.PlanName) && m.PlanName.Contains(queryModel.PlanName))) && (string.IsNullOrEmpty(queryModel.CityPlace) || (!string.IsNullOrEmpty(queryModel.PlanBatch) && m.CityPlace.Contains(queryModel.CityPlace))) && (string.IsNullOrEmpty(queryModel.BidMode) || (!string.IsNullOrEmpty(queryModel.PlanBatch) && m.BidMode.Contains(queryModel.BidMode))) && (string.IsNullOrEmpty(queryModel.BuildWay) || (!string.IsNullOrEmpty(queryModel.BuildWay) && m.BuyWay.Contains(queryModel.BuildWay))) && (string.IsNullOrEmpty(queryModel.BidYear) || (!string.IsNullOrEmpty(queryModel.BidYear) && m.BidYear.Contains(queryModel.BidYear))) ).ToList(); if (queryModel.PlanStartDt.HasValue) { list = list.Where(m => m.PlanStartDt.Value >= queryModel.PlanStartDt).ToList(); } if (queryModel.PlanEndDt.HasValue) { list = list.Where(m => m.PlanEndDt.Value < queryModel.PlanEndDt).ToList(); } ajaxModel.count = list.Count; list = list.OrderBy(m => m.Phid).Skip(queryModel.page - 1).Take(queryModel.limit).ToList(); if (list.Any()) { ajaxModel.code = 0; ajaxModel.msg = "获取数据成功!"; ajaxModel.data = list; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 发布消息。 /// </summary> /// <param name="message">消息。</param> /// <returns>操作的结果。</returns> public ActionResult Publish(string message) { AjaxDataResult <string> ajaxDataResult = AjaxDataResult <string> .GetDataResult(); try { _capBus.Publish(AppDataInit.MQRouteKey, message); ajaxDataResult.Msg = "OK"; ajaxDataResult.Ok = true; ajaxDataResult.Msg = message; } catch (Exception ex) { logger.Error(ex); ajaxDataResult.Msg = ex.Message; } return(Json(ajaxDataResult)); }
/// <summary> /// 批量删除 /// </summary> /// <param name="Ids"></param> /// <returns></returns> public JsonResult BatchDelete(string Ids) { var ajaxModel = new AjaxDataResult() { code = 0, msg = "删除失败!" }; try { if (!string.IsNullOrEmpty(Ids)) { var IdList = Ids.Split(',').Select(m => Convert.ToInt64(m)).ToList(); if (IdList.Any()) { foreach (var id in IdList) { var planProjectInfo = db.ProjectPlanInfos.Find(id); if (planProjectInfo != null) { db.ProjectPlanInfos.Remove(planProjectInfo); } } db.SaveChanges(); ajaxModel.msg = "删除成功!"; ajaxModel.code = 1; } } } catch (Exception ex) { ajaxModel.msg = ex.Message; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 分页数据 /// </summary> /// <returns></returns> public JsonResult GetPageData() { var levelList = new List <string>() { "35", "110", "220", "500", "当月汇总", "当月规模占年度比例", "1-当月规模累计", "1-当月规模占年度比例" }; var ajaxModel = new AjaxDataResult() { code = 1, msg = "未获取到数据!" }; var queryModel = new WorkProjectScaleQueryModel(); queryModel.page = !string.IsNullOrEmpty(Request["page"]) ? Convert.ToInt32(Request["page"]) : 1; queryModel.limit = !string.IsNullOrEmpty(Request["limit"]) ? Convert.ToInt32(Request["limit"]) : 10; if (!string.IsNullOrEmpty(Request["Month"])) { queryModel.Month = Convert.ToDateTime(Request["Month"]).ToString("yyyy-MM"); } var list = db.WorkProjectScaleInfos.Where(m => (string.IsNullOrEmpty(queryModel.Month)) || (queryModel.Month != string.Empty && m.Month.Contains(queryModel.Month))); if (list.Any()) { var groupData = list.GroupBy(m => new { m.Year, m.Month, m.VolLevel }) .Select(m => new WorkProjectScaleDto() { Year = m.Key.Year, Month = m.Key.Month, VolLevel = m.Key.VolLevel, PNumber = m.Sum(n => n.PNumber), TableNum = m.Sum(n => n.TableNum), CircuitNum = m.Sum(n => n.CircuitNum), Length = m.Sum(n => n.Length), Volume = m.Sum(n => n.Volume), AvgRate = 0 }).ToList(); var monthList = groupData.Select(m => m.Year + m.Month).Distinct().ToList(); foreach (var month in monthList) { var firstData = groupData.FirstOrDefault(m => (m.Year + m.Month) == month); var notContainsData = levelList.Where(m => !groupData.Where(t => t.TJDate == month).Select(n => n.VolLevel).Contains(m)).ToList(); foreach (var item in notContainsData) { groupData.Add(new WorkProjectScaleDto() { Year = firstData.Year, Month = firstData.Month, VolLevel = item, PNumber = 0, TableNum = 0, CircuitNum = 0, Length = 0, Volume = 0, AvgRate = 0 }); } } var currentYearList = list.Select(m => m.Year).Distinct().ToList(); foreach (var year in currentYearList) { // 当年数据 var currentYearData = groupData.Where(m => m.Year == year).ToList(); var totalPNumber = currentYearData.Sum(m => m.PNumber); var totalTableNum = currentYearData.Sum(m => m.TableNum); var totalCircuitNum = currentYearData.Sum(m => m.CircuitNum); var totalLength = currentYearData.Sum(m => m.Length); var totalVolume = currentYearData.Sum(m => m.Volume); var currentMonthList = list.Where(m => m.Year == year).Select(m => m.Month).Distinct().ToList(); foreach (var month in currentMonthList) { // 1月至当月的数据 var currentMonthData = currentYearData.Where(m => Convert.ToInt32(m.Month) <= Convert.ToInt32(month)).ToList(); // 1至当月累计数据 var totalMonthPNumber = currentMonthData.Sum(m => m.PNumber); var totalMonthTableNum = currentMonthData.Sum(m => m.TableNum); var totalMonthCircuitNum = currentMonthData.Sum(m => m.CircuitNum); var totalMonthLength = currentMonthData.Sum(m => m.Length); var totalMonthVolume = currentMonthData.Sum(m => m.Volume); // 当前维度数据 var currentData = currentMonthData.Where(m => m.TJDate == year + month).ToList(); // 当月累计数据 var currentPNumber = currentData.Sum(m => m.PNumber); var currentTableNum = currentData.Sum(m => m.TableNum); var currentCircuitNum = currentData.Sum(m => m.CircuitNum); var currentLength = currentData.Sum(m => m.Length); var currentVolume = currentData.Sum(m => m.Volume); // 月度汇总 var tempData1 = currentData.FirstOrDefault(m => m.VolLevel == "当月汇总"); tempData1.PNumber = currentPNumber; tempData1.TableNum = currentTableNum; tempData1.CircuitNum = currentCircuitNum; tempData1.Length = currentLength; tempData1.Volume = currentVolume; // 当月规模占年度比例 var tempData2 = currentData.FirstOrDefault(m => m.VolLevel == "当月规模占年度比例"); tempData2.Length = Math.Round(currentLength / totalLength * 100, 2); tempData2.Volume = Math.Round(currentVolume / totalVolume * 100, 2); tempData2.AvgRate = Math.Round((tempData2.Length + Convert.ToDouble(tempData2.Volume)) / 2, 2); // 1-当月规模累计 var tempData3 = currentData.FirstOrDefault(m => m.VolLevel == "1-当月规模累计"); tempData3.PNumber = totalMonthPNumber; tempData3.TableNum = totalMonthTableNum; tempData3.CircuitNum = totalMonthCircuitNum; tempData3.Length = totalMonthLength; tempData3.Volume = totalMonthVolume; // 1 - 当月规模占年度比例 var tempData4 = currentData.FirstOrDefault(m => m.VolLevel == "1-当月规模占年度比例"); tempData4.Length = Math.Round(totalMonthLength / totalLength * 100, 2); tempData4.Volume = Math.Round(totalMonthVolume / totalVolume * 100, 2); tempData4.AvgRate = Math.Round((tempData4.Length + Convert.ToDouble(tempData4.Volume)) / 2, 2); } } ajaxModel.count = groupData.Count; groupData = groupData.OrderBy(m => m.Year).ThenBy(m => m.Month).ThenBy(m => m.Sort).Skip(queryModel.page - 1).Take(queryModel.limit).ToList(); if (groupData.Count > 0) { ajaxModel.code = 0; ajaxModel.data = groupData; ajaxModel.msg = "获取数据成功!"; } } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取分页数据 /// </summary> /// <returns></returns> public JsonResult GetPageData() { var ajaxModel = new AjaxDataResult() { code = 1, msg = "未获取到数据!" }; var queryModel = new ProjectPlanQueryModel(); // 分页数据 queryModel.page = !string.IsNullOrEmpty(Request["page"]) ? Convert.ToInt32(Request["page"]) : 1; queryModel.limit = !string.IsNullOrEmpty(Request["limit"]) ? Convert.ToInt32(Request["limit"]) : 10; queryModel.ProjectName = Request["ProjectName"]; queryModel.CLevel = Request["CLevel"]; if (!string.IsNullOrEmpty(Request["Build_bdt"])) { queryModel.Build_bdt = Convert.ToDateTime(Request["Build_bdt"]).ToString("yyyy-MM"); } if (!string.IsNullOrEmpty(Request["Build_tdt"])) { queryModel.Build_tdt = Convert.ToDateTime(Request["Build_tdt"]).ToString("yyyy-MM"); } queryModel.Catagory = Request["Catagory"]; queryModel.PType = Request["PType"]; queryModel.Nature = Request["Nature"]; queryModel.IsBeginOrWork = Request["IsBeginOrWork"]; var list = db.ProjectPlanInfos.Where(m => (string.IsNullOrEmpty(queryModel.ProjectName) || (!string.IsNullOrEmpty(queryModel.ProjectName) && m.ProjectName.Contains(queryModel.ProjectName))) && (string.IsNullOrEmpty(queryModel.CLevel) || (!string.IsNullOrEmpty(queryModel.CLevel) && m.CLevel.Contains(queryModel.CLevel))) && (string.IsNullOrEmpty(queryModel.Catagory) || (!string.IsNullOrEmpty(queryModel.Catagory) && m.Catagory.Contains(queryModel.Catagory))) && (string.IsNullOrEmpty(queryModel.PType) || (!string.IsNullOrEmpty(queryModel.PType) && m.PType.Contains(queryModel.PType))) && (string.IsNullOrEmpty(queryModel.Nature) || (!string.IsNullOrEmpty(queryModel.Nature) && m.Nature.Contains(queryModel.Nature))) ).ToList(); if (!string.IsNullOrEmpty(queryModel.Build_bdt)) { list = list.Where(m => m.Build_bdt.HasValue && m.Build_bdt.Value.ToString("yyyy-MM").Contains(queryModel.Build_bdt)).ToList(); } if (!string.IsNullOrEmpty(queryModel.Build_tdt)) { list = list.Where(m => m.Build_tdt.HasValue && m.Build_tdt.Value.ToString("yyyy-MM").Contains(queryModel.Build_tdt)).ToList(); } if (queryModel.IsBeginOrWork == "开工") { list = list.Where(m => m.IsBegin == "是" && m.IsWork != "是").ToList(); } if (queryModel.IsBeginOrWork == "投产") { list = list.Where(m => m.IsWork == "是").ToList(); } ajaxModel.count = list.Count; list = list.OrderBy(m => m.Phid).Skip(queryModel.page - 1).Take(queryModel.limit).ToList(); if (list.Any()) { ajaxModel.code = 0; ajaxModel.msg = "获取数据成功!"; ajaxModel.data = list; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 批量保存 /// </summary> /// <param name="planBatchStr"></param> /// <returns></returns> public JsonResult BatchSave(string planBatchStr) { var ajaxModel = new AjaxDataResult() { code = 0, msg = "保存失败!" }; try { var list = new List <ProjectPlanInfo>(); if (!string.IsNullOrEmpty(planBatchStr)) { list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ProjectPlanInfo> >(planBatchStr); if (list.Any()) { foreach (var projectPlanInfo in list) { var projectPlanModel = db.ProjectPlanInfos.FirstOrDefault(m => m.Phid == projectPlanInfo.Phid); if (projectPlanModel != null) { projectPlanModel.LineId = projectPlanInfo.LineId; projectPlanModel.ProjectNo = projectPlanInfo.ProjectNo; projectPlanModel.Province = projectPlanInfo.Province; projectPlanModel.Company = projectPlanInfo.Company; projectPlanModel.CLevel = projectPlanInfo.CLevel; projectPlanModel.ProjectName = projectPlanInfo.ProjectName; projectPlanModel.Catagory = projectPlanInfo.Catagory; projectPlanModel.PType = projectPlanInfo.PType; projectPlanModel.Nature = projectPlanInfo.Nature; projectPlanModel.IsBegin = projectPlanInfo.IsBegin; projectPlanModel.IsWork = projectPlanInfo.IsWork; projectPlanModel.Vlength = projectPlanInfo.Vlength; projectPlanModel.Volume = projectPlanInfo.Volume; projectPlanModel.CycleNum = projectPlanInfo.CycleNum; projectPlanModel.GroupNum = projectPlanInfo.GroupNum; projectPlanModel.Address = projectPlanInfo.Address; projectPlanModel.Pre_fno = projectPlanInfo.Pre_fno; projectPlanModel.Pre_bdt = projectPlanInfo.Pre_bdt; projectPlanModel.Pre_yno = projectPlanInfo.Pre_yno; projectPlanModel.Pre_sno = projectPlanInfo.Pre_sno; projectPlanModel.Pre_isable = projectPlanInfo.Pre_isable; projectPlanModel.Pre_hno = projectPlanInfo.Pre_hno; projectPlanModel.Pre_hdt = projectPlanInfo.Pre_hdt; projectPlanModel.Pre_pdt = projectPlanInfo.Pre_pdt; projectPlanModel.Pre_sdt = projectPlanInfo.Pre_sdt; projectPlanModel.Start_zdt = projectPlanInfo.Start_zdt; projectPlanModel.Start_kdt = projectPlanInfo.Start_kdt; projectPlanModel.Start_sdt = projectPlanInfo.Start_sdt; projectPlanModel.Start_fdt = projectPlanInfo.Start_fdt; projectPlanModel.Start_ydt = projectPlanInfo.Start_ydt; projectPlanModel.Start_wdt = projectPlanInfo.Start_wdt; projectPlanModel.Start_bdt = projectPlanInfo.Start_bdt; projectPlanModel.Start_jdt = projectPlanInfo.Start_jdt; projectPlanModel.Start_gdt = projectPlanInfo.Start_gdt; projectPlanModel.Start_xdt = projectPlanInfo.Start_xdt; projectPlanModel.Start_ldt = projectPlanInfo.Start_ldt; projectPlanModel.Start_pdt = projectPlanInfo.Start_pdt; projectPlanModel.Start_cdt = projectPlanInfo.Start_cdt; projectPlanModel.Start_hdt = projectPlanInfo.Start_hdt; projectPlanModel.Start_ddt = projectPlanInfo.Start_ddt; projectPlanModel.Start_rdt = projectPlanInfo.Start_rdt; projectPlanModel.Build_bdt = projectPlanInfo.Build_bdt; projectPlanModel.Build_sdt = projectPlanInfo.Build_sdt; projectPlanModel.Build_xdt = projectPlanInfo.Build_xdt; projectPlanModel.Build_ydt = projectPlanInfo.Build_ydt; projectPlanModel.Build_hdt = projectPlanInfo.Build_hdt; projectPlanModel.Build_cdt = projectPlanInfo.Build_cdt; projectPlanModel.Build_tdt = projectPlanInfo.Build_tdt; projectPlanModel.Finish_jdt = projectPlanInfo.Finish_jdt; projectPlanModel.Finish_fdt = projectPlanInfo.Finish_fdt; projectPlanModel.Finish_zdt = projectPlanInfo.Finish_zdt; projectPlanModel.DynamicNum = projectPlanInfo.DynamicNum; projectPlanModel.DemandNum = projectPlanInfo.DemandNum; projectPlanModel.TotalNum = projectPlanInfo.TotalNum; projectPlanModel.PlanNum = projectPlanInfo.PlanNum; projectPlanModel.Progress = projectPlanInfo.Progress; projectPlanModel.Remark = projectPlanInfo.Remark; projectPlanModel.Important_high = projectPlanInfo.Important_high; projectPlanModel.Important_assort = projectPlanInfo.Important_assort; projectPlanModel.Important_strong = projectPlanInfo.Important_strong; projectPlanModel.Important_iron = projectPlanInfo.Important_iron; projectPlanModel.Important_rail = projectPlanInfo.Important_rail; projectPlanModel.Important_wind = projectPlanInfo.Important_wind; projectPlanModel.Important_light = projectPlanInfo.Important_light; projectPlanModel.Important_give = projectPlanInfo.Important_give; projectPlanModel.Important_farmer = projectPlanInfo.Important_farmer; projectPlanModel.Important_summary = projectPlanInfo.Important_summary; projectPlanModel.Months = projectPlanInfo.Months; projectPlanModel.WorkReady = projectPlanInfo.WorkReady; projectPlanModel.WorkSet = projectPlanInfo.WorkSet; projectPlanModel.WorkStart = projectPlanInfo.WorkStart; projectPlanModel.WorkBid = projectPlanInfo.WorkBid; projectPlanModel.WorkCheck = projectPlanInfo.WorkCheck; // 已开工项目 if (projectPlanInfo.IsBegin == "是" && projectPlanInfo.IsWork != "是") { var beginProjectInfo = db.BeginProjectScaleInfos.FirstOrDefault(m => m.PPhid == projectPlanModel.Phid); if (beginProjectInfo != null) { beginProjectInfo.Year = projectPlanInfo.Build_bdt.Value.ToString("yyyy"); beginProjectInfo.Month = projectPlanInfo.Build_bdt.Value.ToString("MM"); beginProjectInfo.VolLevel = projectPlanInfo.CLevel; beginProjectInfo.PNumber = 1; beginProjectInfo.CircuitNum = Convert.ToInt32(projectPlanInfo.CycleNum ?? "0"); beginProjectInfo.TableNum = Convert.ToInt32(projectPlanInfo.GroupNum ?? "0"); beginProjectInfo.Length = Convert.ToDouble(projectPlanInfo.Vlength ?? "0"); beginProjectInfo.Volume = Convert.ToDecimal(projectPlanInfo.Volume ?? "0"); } } // 已投产项目 if (projectPlanInfo.IsWork == "是") { var workProjectInfo = db.WorkProjectScaleInfos.FirstOrDefault(m => m.PPhid == projectPlanInfo.Phid); if (workProjectInfo != null) { workProjectInfo.Year = projectPlanInfo.Build_tdt.Value.ToString("yyyy"); workProjectInfo.Month = projectPlanInfo.Build_tdt.Value.ToString("MM"); workProjectInfo.VolLevel = projectPlanInfo.CLevel; workProjectInfo.PNumber = 1; workProjectInfo.CircuitNum = Convert.ToInt32(projectPlanInfo.CycleNum ?? "0"); workProjectInfo.TableNum = Convert.ToInt32(projectPlanInfo.GroupNum ?? "0"); workProjectInfo.Length = Convert.ToDouble(projectPlanInfo.Vlength ?? "0"); workProjectInfo.Volume = Convert.ToDecimal(projectPlanInfo.Volume ?? "0"); } } db.SaveChanges(); } else { db.ProjectPlanInfos.Add(projectPlanInfo); db.SaveChanges(); // 已开工项目 if (projectPlanInfo.IsBegin == "是" && projectPlanInfo.IsWork != "是") { var beginProjectInfo = new BeginProjectScaleInfo(); beginProjectInfo.PPhid = projectPlanInfo.Phid; beginProjectInfo.Year = projectPlanInfo.Build_bdt.Value.ToString("yyyy"); beginProjectInfo.Month = projectPlanInfo.Build_bdt.Value.ToString("MM"); beginProjectInfo.VolLevel = projectPlanInfo.CLevel; beginProjectInfo.PNumber = 1; beginProjectInfo.CircuitNum = Convert.ToInt32(projectPlanInfo.CycleNum ?? "0"); beginProjectInfo.TableNum = Convert.ToInt32(projectPlanInfo.GroupNum ?? "0"); beginProjectInfo.Length = Convert.ToDouble(projectPlanInfo.Vlength ?? "0"); beginProjectInfo.Volume = Convert.ToDecimal(projectPlanInfo.Volume ?? "0"); db.BeginProjectScaleInfos.Add(beginProjectInfo); } // 已投产项目 if (projectPlanInfo.IsWork == "是") { var workProjectInfo = new WorkProjectScaleInfo(); workProjectInfo.PPhid = projectPlanInfo.Phid; workProjectInfo.Year = projectPlanInfo.Build_tdt.Value.ToString("yyyy"); workProjectInfo.Month = projectPlanInfo.Build_tdt.Value.ToString("MM"); workProjectInfo.VolLevel = projectPlanInfo.CLevel; workProjectInfo.PNumber = 1; workProjectInfo.CircuitNum = Convert.ToInt32(projectPlanInfo.CycleNum ?? "0"); workProjectInfo.TableNum = Convert.ToInt32(projectPlanInfo.GroupNum ?? "0"); workProjectInfo.Length = Convert.ToDouble(projectPlanInfo.Vlength ?? "0"); workProjectInfo.Volume = Convert.ToDecimal(projectPlanInfo.Volume ?? "0"); db.WorkProjectScaleInfos.Add(workProjectInfo); } db.SaveChanges(); } } ajaxModel.code = 1; ajaxModel.msg = "保存成功!"; } } } catch (Exception ex) { ajaxModel.msg = ex.Message; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 批量保存 /// </summary> /// <param name="planBatchStr"></param> /// <returns></returns> public JsonResult BatchSave(string planBatchStr) { var ajaxModel = new AjaxDataResult() { code = 0, msg = "保存失败!" }; try { var list = new List <PlanBatchInfo>(); if (!string.IsNullOrEmpty(planBatchStr)) { list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <PlanBatchInfo> >(planBatchStr); if (list.Any()) { foreach (var planBatchInfo in list) { var planBatchModel = db.PlanBatchInfos.FirstOrDefault(m => m.Phid == planBatchInfo.Phid); if (planBatchModel != null) { planBatchModel.PlanBatch = planBatchInfo.PlanBatch; planBatchModel.PlanName = planBatchInfo.PlanName; planBatchModel.CityPlace = planBatchInfo.CityPlace; planBatchModel.BidMode = planBatchInfo.BidMode; planBatchModel.BuyWay = planBatchInfo.BuyWay; planBatchModel.BidYear = planBatchInfo.BidYear; planBatchModel.BidFlag = planBatchInfo.BidFlag; planBatchModel.PlanCheckDt = planBatchInfo.PlanCheckDt; planBatchModel.PlanEndDt = planBatchInfo.PlanEndDt; planBatchModel.Status = planBatchInfo.Status; planBatchModel.PlanStartDt = planBatchInfo.PlanStartDt; planBatchModel.CityStartDt = planBatchInfo.CityStartDt; planBatchModel.Period = planBatchInfo.Period; } else { db.PlanBatchInfos.Add(planBatchInfo); } } var result = db.SaveChanges() > 0; if (result) { ajaxModel.code = 1; ajaxModel.msg = "保存成功!"; } } } } catch (Exception ex) { ajaxModel.msg = ex.Message; } return(Json(ajaxModel, JsonRequestBehavior.AllowGet)); }