using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Script.Serialization; using CallCenterApi.Common; using CallCenterApi.DB; using CallCenterApi.Interface.Controllers.Base; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace CallCenterApi.Interface.Controllers.County { //[Authority] public class CountyBusinessController : BaseController { // GET: CountyBusiness /// /// 获取工单列表 /// /// /// /// public ActionResult GetAreaOrderList(string branchcode) { string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } else { return Error("请选择区县"); } //ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); if (list.Count == 0) { return Error("查询失败"); } string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state")); string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name")); string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel")); string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key")); string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime")); string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime")); string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid")); int dealtype = RequestString.GetInt("dealtype", -1); #region 新增筛选项 string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode")); string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员 int source = RequestString.GetInt("source", 0); int keyid = RequestString.GetInt("keyid", 0); int type = RequestString.GetInt("type", 0); int bigtype = RequestString.GetInt("bigtype", 0); int smalltype = RequestString.GetInt("smalltype", 0); int sourcearea = RequestString.GetInt("sourcearea", 0); int deptid = RequestString.GetInt("deptid", 0); int issend = RequestString.GetInt("issend", -1); int deptlevel = RequestString.GetInt("deptlevel", 0); #endregion string strpageindex = RequestString.GetQueryString("page"); int pageindex = 1; string strpagesize = RequestString.GetQueryString("pagesize"); int pagesize = 10; if (!string.IsNullOrEmpty(strpageindex) && strpageindex.Trim() != "") { pageindex = Convert.ToInt32(strpageindex); } if (!string.IsNullOrEmpty(strpagesize) && strpagesize.Trim() != "") { pagesize = Convert.ToInt32(strpagesize); } string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); if (!string.IsNullOrEmpty(list[0].F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign); string strparams = "?state=" + strstate + "&name=" + strname + "&tel=" + strtel + "&key=" + strkey + "&usercode="+ strusercode+ "&ddusercode="+ strddusercode+ "&source="+ source+ "&keyid="+ keyid + "&type="+ type+ "&bigtype="+ bigtype+ "&smalltype="+ smalltype+ "&sourcearea="+ sourcearea + "&deptid="+ deptid+ "&issend="+ issend+ "&deptlevel="+ deptlevel+ "&workid="+ strworkid + "&starttime=" + strstarttime + "&endtime=" + strendtime + "&page=" + pageindex + "&pagesize=" + pagesize + "&signcode=" + signcode; string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams); return Content(result); } else { var obj = new { state = "success", message = "成功", rows = new DataTable(), total = 0 }; return Content(obj.ToJson()); } } /// /// 获取工单列表 /// /// /// /// public ActionResult GetAreaWorkOrder(string branchcode, string workorderid) { string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } else { return Error("请选择区县"); } var list = new BLL.T_Branch_List().GetModelList(sqlwhere); if (list.Count == 0) { return Error("查询失败"); } if (string.IsNullOrEmpty(workorderid)) { return Error("查询失败"); } string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); if (!string.IsNullOrEmpty(list[0].F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign); string strparams = "?workorderid=" + workorderid + "&signcode=" + signcode; string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams); return Content(result); } else { return Error("查询失败"); } } /// /// 绩效考核 /// /// /// /// public ActionResult GetAreaAssessment(string branchcode,DateTime? start, DateTime? end, int isdc = 0) { if (start == null) { start = DateTime.Now; start = new DateTime(start.Value.Year, start.Value.Month, 1); } if (end == null) { end = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "受理量", "交办量", "已办量", "重办量", "及时量", "超时量", "延时量", "回访量", "市民满意", "市民不满意" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("绩效考核报表", result, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", result); } //2019-8-21 /// /// 绩效考核--添加获取市县总和 /// /// /// /// public ActionResult GetAreaAssessmentNew(string branchcode, DateTime? start, DateTime? end, int isdc = 0) { start = DateTime.Now.AddDays(-100); #region 定义新表 DataTable dtnew = new DataTable(); dtnew.Columns.Add("areaname"); dtnew.Columns.Add("acceptcount"); dtnew.Columns.Add("assigncount"); dtnew.Columns.Add("dealcount"); dtnew.Columns.Add("reloadcount"); dtnew.Columns.Add("timelycount"); dtnew.Columns.Add("timeoutcount"); dtnew.Columns.Add("delaycount"); dtnew.Columns.Add("visitcount"); dtnew.Columns.Add("satisfiedcount"); dtnew.Columns.Add("notsatisfiedcount"); int first = 1; //Int64 totalcount = 0; #endregion if (start == null) { start = DateTime.Now; start = new DateTime(start.Value.Year, start.Value.Month, 1); } if (end == null) { end = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } //string areaid = ""; ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = "GetAreaAssessment";//RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { //if (!string.IsNullOrEmpty(l.F_AreaId)) //{ // areaid = l.F_AreaId; //} string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode; string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject(); //if (!string.IsNullOrEmpty(branchcode)) //{ // return Content(ar);//查询单个时直接返回 //} JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar); if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString()) { if (first == 1) { DataTable dt = HeadToDataTable(jo0["data"].ToString(), "Item"); dtnew = dt; first = 0; if (!string.IsNullOrEmpty(branchcode)) { break; } } else { int isbh = 0; //前部分相加 DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item"); for (int m = 0; m < dt1 .Rows .Count ; m++) { for (int i = 0; i < dtnew.Rows.Count; i++) { if (dtnew.Rows[i]["areaname"].ToString() == dt1.Rows[m]["areaname"].ToString()) { for (int j = 1; j < 11; j++) { string cols = dtnew.Columns[j].ColumnName; decimal t = decimal.Parse(dtnew.Rows[i][cols].ToString()) + decimal.Parse(dt1.Rows[m][cols].ToString()); dtnew.Rows[i][cols] = t; isbh = 1; } //totalcount += Int64.Parse(dtnew.Rows[i]["TotalCount"].ToString()); } } if (isbh == 0) { DataRow dr = dt1.Rows[m]; dtnew.ImportRow(dr); } } } //var rtlist = ar.data.ToJson().ToList>(); //result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "受理量", "交办量", "已办量", "重办量", "及时量", "超时量", "延时量", "回访量", "市民满意", "市民不满意" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("绩效考核报表", dtnew, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", dtnew); } public static DataTable HeadToDataTable(string json, string dicstr)//Item { DataTable dataTable = new DataTable(); //实例化 DataTable result; try { JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值 ArrayList arrayList = javaScriptSerializer.Deserialize(json); if (arrayList.Count > 0) { foreach (Dictionary dictionary in arrayList) { if (dictionary.Keys.Count() == 0) { result = dataTable; return result; } //Columns if (dataTable.Columns.Count == 0) { foreach (string current in dictionary.Keys) { if (current != dicstr) dataTable.Columns.Add(current, dictionary[current].GetType()); } } //Rows //string root = ""; List cname = new List(); DataRow dataRow = dataTable.NewRow(); foreach (string current in dictionary.Keys) { if (current != dicstr) { //root = current; //dataRow[root] = dictionary[root]; cname.Add(current); } foreach (var li in cname) { if (dictionary[li] == null) { dataRow[li] = -1; } else { dataRow[li] = dictionary[li]; } } } dataTable.Rows.Add(dataRow); } } } catch { } result = dataTable; return result; } /// /// 县区受理 /// /// /// /// public ActionResult GetAreaAccept(string branchcode, DateTime? date, int isdc = 0) { if (date == null) { date = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "受理量", "同比", "环比" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("县区受理报表", result, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", result); } /// /// 县区办理 /// /// /// /// public ActionResult GetAreaDeal(string branchcode, DateTime? date, int isdc = 0) { if (date == null) { date = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "办理量", "同比", "环比" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("县区办理报表", result, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", result); } /// /// 县区各类型统计 /// /// /// /// public ActionResult GetAreaCount(string branchcode, DateTime? start, DateTime? end, int type, int isdc = 0) { if (start == null) { start = DateTime.Now; start = new DateTime(start.Value.Year, start.Value.Month, 1); } if (end == null) { end = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&type=" + type + "&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "类型", "数量" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("统计报表", result, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", result); } /// /// 县区来源统计 /// /// /// /// public ActionResult GetAreaSourceCount(string branchcode, DateTime? start, DateTime? end, int isdc = 0) { if (start == null) { start = DateTime.Now; start = new DateTime(start.Value.Year, start.Value.Month, 1); } if (end == null) { end = DateTime.Now; } string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = "GetAreaCount";// RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&type=1&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } ArrayList areas = new ArrayList(); string[] sources = new string[] { "电话", "12345信箱", "微博", "网站", "微信", "手机APP", "政务服务网" }; DataTable dt = new DataTable(); dt.Columns.Add("县区/渠道"); foreach (var source in sources) { dt.Columns.Add(source,typeof(int)); } dt.Columns.Add("合计", typeof(int)); DataRow dr = dt.NewRow(); int i = 0; int sum = 0; foreach (Dictionary l in result) { string area= l["areaname"].ToString(); string source = l["source"].ToString(); if (!areas.Contains(area)) { areas.Add(area); if (i != 0) { dr["合计"] = sum; dt.Rows.Add(dr); sum = 0; dr = dt.NewRow(); } dr["县区/渠道"] = area; i++; } if (sources.Contains(source)) { dr[source] = l["count"].ToString(); sum += Int32.Parse(l["count"].ToString()); } } dr["合计"] = sum; dt.Rows.Add(dr); dr = dt.NewRow(); dr["县区/渠道"] = "合计"; dr["电话"] = dt.Compute("sum([电话])", "true").ToString(); dr["12345信箱"] = dt.Compute("sum([12345信箱])", "true").ToString(); dr["微博"] = dt.Compute("sum([微博])", "true").ToString(); dr["网站"] = dt.Compute("sum([网站])", "true").ToString(); dr["微信"] = dt.Compute("sum([微信])", "true").ToString(); dr["手机APP"] = dt.Compute("sum([手机APP])", "true").ToString(); dr["政务服务网"] = dt.Compute("sum([政务服务网])", "true").ToString(); dr["合计"] = dt.Compute("sum([合计])", "true").ToString(); dt.Rows.Add(dr); if (isdc > 0) { NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("来源统计报表", dt) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", dt); } /// /// 办理率统计 /// /// /// /// /// public ActionResult GetAreaEndRate(string branchcode, string month, int isdc = 0) { string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); foreach (var l in list) { if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign); string strparams = "?month=" + month + "&signcode=" + signcode; AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject(); if (ar.state.ToString() == ResultTypes.success.ToString()) { var rtlist = ar.data.ToJson().ToList>(); result.AddRange(rtlist); } } } if (isdc > 0) { string[] cols = new string[] { "区县名称", "受理量", "办理量", "结案量", "结案率" }; NPOIHelper npoi = new NPOIHelper(); if (npoi.ExportToExcel("县区结案率报表", result, cols) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Success("成功", result); } /// /// 获取简报月 /// /// /// /// /// public ActionResult GetSimpleReport(string branchcode, string month, int isdc = 0) { string sqlwhere = " F_IsDelete=0 "; if (!string.IsNullOrEmpty(branchcode)) { sqlwhere += " and F_Code='" + branchcode + "'"; } else { return Error("请选择区县"); } //ArrayList result = new ArrayList(); var list = new BLL.T_Branch_List().GetModelList(sqlwhere); if (list.Count == 0) { return Error("查询失败"); } string controllername = RouteData.Values["controller"].ToString(); string actionname = RouteData.Values["action"].ToString(); if (!string.IsNullOrEmpty(list[0].F_Url)) { string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign); string strparams = "?month=" + month + "&signcode=" + signcode; string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams); if (isdc > 0) { AjaxResult ar = result.ToObject(); NPOIHelper npoi = new NPOIHelper(); if (npoi.SimpleExportToExcel(ar.data.ToJson().ToObject()) == "") { return Success("导出成功"); } else { return Error("导出失败"); } } return Content(result); } else { var obj = new { state = "error", message = "查询失败" }; return Content(obj.ToJson()); } } } }