public ActionResult GetMapData(int qKyUnit, int qCreator, string qKyDate1, string qKyDate2, int userId, int unitId, int dataType) { string rsljson = ""; DateTime beginDate = Md5Helper.GMT2Local(qKyDate1); DateTime endDate = Md5Helper.GMT2Local(qKyDate2); var records = db.view_report.Where(p => p.ky_date >= beginDate && p.ky_date <= endDate && p.record_state != 1000); // if (dataType == Global.SELF_DATA) { records = records.Where(p => p.creater_id.Value == userId); } else if (qCreator != 0) { records = records.Where(p => p.creater_id == qCreator); } if (dataType == Global.UNIT_DATA) { records = records.Where(p => p.ky_unit == unitId); } else if (qKyUnit != 0) { records = records.Where(p => p.ky_unit == qKyUnit); } var rslList = records.GroupBy(p => p.xz).ToList(); //rsljson = JsonConvert.SerializeObject(); return(Content(rsljson)); }
public ActionResult Grid1_Query(int userId, int unitId, int dataType, JArray Grid1_fields, string qKyUnit, string qCreator, string qKyState, string qKyDate1, string qKyDate2, string qTitle, string qTitle2) { gbQC.qKyUnit = Int32.Parse(qKyUnit); gbQC.qCreator = Int32.Parse(qCreator); gbQC.qKyState = Int32.Parse(qKyState); gbQC.qKyDate1 = Md5Helper.GMT2Local(qKyDate1); gbQC.qKyDate2 = Md5Helper.GMT2Local(qKyDate2); gbQC.qTitle = qTitle; gbQC.qTitle2 = qTitle2; gbQC.userId = userId; gbQC.unitId = unitId; gbQC.dataType = dataType; var grid1 = UIHelper.Grid("Grid1"); int count = 0; var dataSource = QueryRecord(gbQC, 0, 10, ref count); ViewBag.Grid1RecordCount = count; grid1.RecordCount(count); grid1.DataSource(dataSource, Grid1_fields); return(UIHelper.Result()); }
public ActionResult GetReportData(int type, int qKyUnit, int qCreator, string qKyDate1, string qKyDate2, int userId, int unitId, int dataType) { List <string> names = new List <string>(); List <ChartSeriesModel> seriesList = new List <ChartSeriesModel>(); List <int> nums = new List <int>(); List <DataZoomModel> dzList = new List <DataZoomModel>(); ChartSeriesModel csm = new ChartSeriesModel(); string rsljson = ""; DateTime beginDate = Md5Helper.GMT2Local(qKyDate1); DateTime endDate = Md5Helper.GMT2Local(qKyDate2); var records = db.view_report.Where(p => p.ky_date >= beginDate && p.ky_date <= endDate && p.record_state != 1000); // if (dataType == Global.SELF_DATA) { records = records.Where(p => p.creater_id.Value == userId); } else if (qCreator != 0) { records = records.Where(p => p.creater_id == qCreator); } if (dataType == Global.UNIT_DATA) { records = records.Where(p => p.ky_unit == unitId); } else if (qKyUnit != 0) { records = records.Where(p => p.ky_unit == qKyUnit); } switch (type) { case 1: var rslList = records.GroupBy(p => p.xz).ToList(); csm.name = "案件性质"; csm.type = "bar"; foreach (var rsl in rslList) { names.Add(rsl.Key); nums.Add(rsl.Count()); } csm.data = nums; seriesList.Add(csm); var option = new { title = new { text = "案件性质汇总统计" }, tooltip = new { }, xAxis = new { axisLabel = new { interval = "0", rotate = "30" }, data = names }, yAxis = new { }, series = seriesList }; rsljson = JsonConvert.SerializeObject(option); break; case 2: var rslList2 = records.GroupBy(p => p.bg_unit_name).ToList(); csm.name = "接警单位"; csm.type = "bar"; foreach (var rsl in rslList2) { names.Add(rsl.Key); nums.Add(rsl.Count()); } csm.data = nums; seriesList.Add(csm); var option2 = new { title = new { text = "接警单位汇总统计" }, tooltip = new { }, xAxis = new { axisLabel = new { interval = "0", rotate = "30" }, data = names }, yAxis = new { }, series = seriesList }; rsljson = JsonConvert.SerializeObject(option2); break; case 3: var rslList3 = records.GroupBy(p => p.jjr_name).ToList(); csm.name = "接警人"; csm.type = "bar"; foreach (var rsl in rslList3) { names.Add(rsl.Key); nums.Add(rsl.Count()); } csm.data = nums; seriesList.Add(csm); var option3 = new { title = new { text = "接警人汇总统计" }, tooltip = new { }, xAxis = new { axisLabel = new { interval = "0", rotate = "45" }, data = names }, yAxis = new { }, series = seriesList }; rsljson = JsonConvert.SerializeObject(option3); break; case 4: var rslList4 = records.OrderBy(p => p.ky_date).GroupBy(p => p.ky_date).ToList(); csm.name = "接警日期"; csm.type = "line"; foreach (var rsl in rslList4) { names.Add(rsl.Key.Value.ToString("yyyy-MM-dd")); nums.Add(rsl.Count()); } csm.data = nums; seriesList.Add(csm); DataZoomModel dz = new DataZoomModel() { end = 100 }; dzList.Add(dz); DataZoomModel dz1 = new DataZoomModel() { type = "inside" }; dzList.Add(dz1); var option4 = new { title = new { text = "日均案件统计" }, tooltip = new { }, xAxis = new { data = names }, dataZoom = dzList, yAxis = new { }, series = seriesList }; rsljson = JsonConvert.SerializeObject(option4); break; case 5: var rslList5 = records.Select(n => new { record_id = n.record_id, ky_month = n.ky_date.Value.Year + "-" + n.ky_date.Value.Month }) .GroupBy(p => p.ky_month).ToList(); csm.name = "接警月"; csm.type = "line"; foreach (var rsl in rslList5) { names.Add(rsl.Key); nums.Add(rsl.Count()); } csm.data = nums; seriesList.Add(csm); DataZoomModel dz2 = new DataZoomModel() { end = 100 }; dzList.Add(dz2); DataZoomModel dz3 = new DataZoomModel() { type = "inside" }; dzList.Add(dz3); var option5 = new { title = new { text = "月均案件统计" }, tooltip = new { }, xAxis = new { data = names }, yAxis = new { }, dataZoom = dzList, series = seriesList }; rsljson = JsonConvert.SerializeObject(option5); break; } return(Content(rsljson)); }