public ActionResult GetAreaMapListJson(string id = "") { try { var deptBll = new DepartmentBLL(); var curUser = new OperatorProvider().Current(); var expression = LinqExtensions.True <DistrictEntity>(); expression = expression.And(t => t.OrganizeId == curUser.OrganizeId); var districtdata = bis_districtbll.GetListForCon(expression).Where(t => !string.IsNullOrWhiteSpace(t.LatLng)).ToList(); if (!string.IsNullOrWhiteSpace(id)) { districtdata = districtdata.Where(t => !t.DistrictID.Equals(id)).ToList(); } DataTable dt = new DataTable(); dt.Columns.Add("code"); dt.Columns.Add("status"); dt.Columns.Add("htnum"); dt.Columns.Add("fxnum"); dt.Columns.Add("areacode"); dt.Columns.Add("wxnum"); dt.Columns.Add("content"); List <object> list = new List <object>(); StringBuilder sb = new StringBuilder(); foreach (DistrictEntity area in districtdata) { int val = 0; string htNum = ""; string fxNum = ""; string areaCode = ""; areaCode = area.DistrictCode; string sql = ""; DataTable obj = deptBll.GetDataTable(string.Format("select min(gradeval) from BIS_RISKASSESS t where status=1 and deletemark=0 and t.areacode like '{0}%' {1}", areaCode, sql)); if (obj.Rows.Count > 0) { val = obj.Rows[0][0].ToInt(); } else { val = 0; } //隐患数量 DataTable dtHt = deptBll.GetDataTable(string.Format("select rankname,count(1) num from v_basehiddeninfo t where t.workstream!='整改结束' and t.hidpoint like '{0}%' group by rankname", areaCode)); if (dtHt.Rows.Count > 0) { var rows = dtHt.Select("rankname='一般隐患'"); if (rows.Length > 0) { htNum = rows[0][1].ToString(); } else { htNum = "0"; } rows = dtHt.Select("rankname='重大隐患'"); if (rows.Length > 0) { htNum += "," + rows[0][1].ToString(); } else { htNum += ",0"; } } sb.Clear(); //风险数量 DataTable dtRisk = deptBll.GetDataTable(string.Format(@"select nvl(num,0) from (select 1 gradeval from dual union all select 2 gradeval from dual union all select 3 gradeval from dual union all select 4 gradeval from dual) a left join (select gradeval,count(1) num from BIS_RISKASSESS t where status=1 and deletemark=0 and t.areacode like '{0}%' {1} group by grade,gradeval) b on a.gradeval=b.gradeval order by a.gradeval asc", areaCode, sql)); foreach (DataRow dr in dtRisk.Rows) { sb.AppendFormat("{0},", dr[0].ToString()); } //重大危险源数量 int count = deptBll.GetDataTable(string.Format("select count(1) from HSD_HAZARDSOURCE t where IsDanger=1 and gradeval>0 and deptcode like '{0}%' and t.districtid in(select districtid from bis_district d where d.districtcode like '{1}%')", curUser.OrganizeCode, areaCode)).Rows[0][0].ToInt(); fxNum = sb.ToString().TrimEnd(','); list.Add(new { Code = area.DistrictCode, LatLng = area.LatLng, DistrictName = area.DistrictName, Status = val, htnum = htNum, fxnum = fxNum, wxnum = count, }); } return(Content(list.ToJson())); } catch (Exception ex) { return(Error(ex.Message)); } }