| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007 |
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- 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;
- namespace CallCenterApi.Interface.Controllers
- {
- /// <summary>
- /// 大屏公示系统
- /// </summary>
- //[Authority]
- public class InfoController : BaseController
- {
- // GET: Info
- public ActionResult Index()
- {
- return View();
- }
- #region 来源渠道
- /// <summary>
- /// 获取受理区域数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="date"></param>
- /// <returns></returns>
- public ActionResult GetAreaCount24ByDate(string branchcode, DateTime? date,string areaid)
- {
- if (date == null)
- {
- date = DateTime.Now;
- }
- int backtotal = 0;
- //string sqlwhere = " F_IsDelete=0 ";
- string sqlwhere = " F_IsDP=1 ";//大屏展示用到的
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- sqlwhere += " and F_IsSQS='0";
- }
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- backtotal = 1;
-
- sqlwhere += " and F_IsSQ!=1";
-
- }
- int first = 1;
- int[] hours = Enumerable.Range(0, 24).ToArray<int>();
- decimal[,] countstotal=new decimal [10,24];//用于计算累计值//固定了10个市县区
- decimal[] tcountstotal = new decimal[10];
- string[] cols=new string [10];
- string[] colsx = new string[1];//用于县数据相加
- //List<object> items;
- List<List<Dictionary<string, object>>> items = new List<List<Dictionary<string, object>>>();
- //IEnumerable<List<Dictionary<string, object>>> items;
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&areaid=" + areaid + "&signcode=" + signcode ;
- //AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);
- 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)
- {
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["cols"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- a = a.Replace("\"", "");
- cols = a.Split(',');
- }
- else
- {
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["cols"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- a = a.Replace("\"", "");
- colsx = a.Split(',');
- }
- //string x = jo0["data"].ToString();
- for (int i = 0; i < 10;i++)
- {
-
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["counts"][i].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- string[] z = y.Split(',');
- for (int m = 0; m < z.Length; m++)
- {
- if (first == 1)
- {
- countstotal[i, m] = decimal.Parse(z[m]);
- }
- else if (backtotal == 1)
- {
- if (cols[i] == colsx[0])
- {
- countstotal[i, m] += decimal.Parse(z[m]);
- }
- }
- }
-
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["tcounts"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- string[] q = p.Split(',');
- if (backtotal == 1)
- {
- if (cols[i] == colsx[0])
- {
- tcountstotal[i] += decimal.Parse(q[0]);
- }
- }
- else
- {
- tcountstotal[i] += decimal.Parse(q[i]);
- }
- //item计算
- if (backtotal == 1)
- {
- if (cols[i] == colsx[0])
- {
- var rtlist = jo0["data"]["items"][0].ToJson().ToList<Dictionary<string, object>>();
- for (int r = 0; r < rtlist.Count; r++)
- {
- decimal zh = 0;
- if (items.Count > i)
- {
- zh = decimal.Parse(items[i][r]["Count"].ToString());
- }
- rtlist[r]["Count"] = zh + decimal.Parse(rtlist[r]["Count"].ToString());
- }
- //List<Dictionary<string, object>> li = new List<Dictionary<string, object>>();
- //li.AddRange(rtlist );
- items.Add(rtlist);
- }
- }
- else
- {
- var rtlist = jo0["data"]["items"][i].ToJson().ToList<Dictionary<string, object>>();
- items.Add(rtlist);
- }
- }
- first = 0;
-
-
- }
- }
- }
- var data = new
- {
- hours = hours,
- cols ,
- counts=countstotal,
- tcounts = tcountstotal ,
- items
- };
- return Success("成功", data);
- }
- /// <summary>
- /// 获取受理区域数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetAreaCountByDate(string branchcode, DateTime? start, DateTime? end, string areaid)
- {
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- int backtotal = 0;
- string sqlwhere = " F_IsDP=1 ";
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- backtotal = 1;
-
- sqlwhere += " and F_IsSQ!=1";
-
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("F_AreaId");
- dtnew.Columns.Add("AreaName");
- dtnew.Columns.Add("Count");
- int first = 1;
- #endregion
- 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))
- {
- 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") + "&areaid=" + areaid + "&backtotal=" + backtotal + "&isdpjk=1" + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- dtnew.Columns.Add("Item", typeof(object));
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- dtnew.Rows[i]["Item"] = jo0["data"][i]["Item"];
- }
- first = 0;
- }
- else
- {
- for (int m = 0; m < dtnew.Rows.Count; m++)
- {
-
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- if (dtnew.Rows[m][1].ToString() == dt1.Rows[i][1].ToString())
- {
- decimal t = decimal.Parse(dtnew.Rows[i][2].ToString()) + decimal.Parse(dt1.Rows[i][2].ToString());
- dtnew.Rows[i][2] = t;
- //后半部分两个datatable相加
- DataTable dtitem = new DataTable();
- string c = jo0["data"][i]["Item"].ToString();
- DataTable dt = HeadToDataTable(jo0["data"][i]["Item"].ToString(), "Item");
- dtitem = dt;
- DataTable dtold = HeadToDataTable(dtnew.Rows[i]["Item"].ToString(), "Item");
- for (int j = 0; j < dtold.Rows.Count; j++)
- {
- dtitem.Rows[j][1] = decimal.Parse(dtold.Rows[j][1].ToString()) + decimal.Parse(dt.Rows[j][1].ToString());
- }
- dtnew.Rows[i]["Item"] = dtitem;
- }
- }
- }
- }
- }
- }
- }
- return Success("成功", dtnew);
- }
- /// <summary>
- /// 获取来源百分比
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetSourcePercentByDate(string branchcode, DateTime? start, DateTime? end, string areaid)
- {
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
-
- }
- string sqlwhere = " F_IsDP=1 ";
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("Id");
- dtnew.Columns.Add("Source");
- dtnew.Columns.Add("Count");
- dtnew.Columns.Add("Percent");
-
- int first = 1;
- decimal totalcount = 0;//用于计算百分比
- #endregion
- 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))
- {
- 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") + "&areaid=" + areaid + "&isdpjk=1" + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- dtnew.Columns.Add("Item", typeof(object));
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- dtnew.Rows[i]["Item"] = jo0["data"][i]["Item"];
- }
- first = 0;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][2].ToString()) + decimal.Parse(dt1.Rows[i][2].ToString());
- totalcount += t;
- dtnew.Rows[i][2] = t;
- }
- //后半部分两个datatable相加
-
- for (int i = 0; i < dtnew.Rows.Count; i++)
- {
- DataTable dtitem = new DataTable();
- string c = jo0["data"][i]["Item"].ToString();
- DataTable dt = HeadToDataTable(jo0["data"][i]["Item"].ToString(), "Item");
- dtitem = dt;
- DataTable dtold = HeadToDataTable(dtnew.Rows[i]["Item"].ToString(), "Item");
- for (int j = 0; j < dtold.Rows.Count; j++)
- {
- dtitem.Rows[j][1] = decimal.Parse(dtold.Rows[j][1].ToString()) + decimal.Parse(dt.Rows[j][1].ToString());
- }
- dtnew.Rows[i]["Item"] = dtitem;
- }
- }
- //var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
- //result.AddRange(rtlist);
- }
- }
- }
- //计算百分比
- if (totalcount > 0)
- {
- for (int m = 0; m < dtnew.Rows.Count; m++)
- {
- dtnew.Rows[m]["Percent"] = Math.Round(decimal.Parse(dtnew.Rows[m]["Count"].ToString()) / totalcount * 100, 2);
- }
- }
- return Success("成功", dtnew );
- }
-
- /// <summary>
- /// 获取来源数量百分比
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetSourceByDate(string branchcode, DateTime? start, DateTime? end, string areaid)
- {
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- string sqlwhere = " F_IsDP=1 ";
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("Id");
- dtnew.Columns.Add("Source");
- dtnew.Columns.Add("Count");
- //dtnew.Columns.Add("Percent");
- int first = 1;
- decimal totalcount = 0;
- #endregion
- 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))
- {
- 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") + "&areaid=" + areaid + "&isdpjk=1" + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- //dtnew.Columns.Add("Percent", typeof(object));
-
- first = 0;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][2].ToString()) + decimal.Parse(dt1.Rows[i][2].ToString());
- dtnew.Rows[i][2] = t;
- if (dtnew.Rows[i]["Source"].ToString () == "总计")
- {
- totalcount = t;
- }
- }
-
-
- }
- }
- }
- }
- //计算百分比
- //dtnew.Columns.Add("Percent", typeof(object));
- if (totalcount > 0)
- {
- for (int m = 0; m < dtnew.Rows.Count; m++)
- {
- dtnew.Rows[m]["Percent"] = Math.Round(decimal.Parse(dtnew.Rows[m]["Count"].ToString()) / totalcount * 100, 2).ToString ()+"%";
- }
- }
- return Success("成功", dtnew);
- }
- #endregion
- #region 接单部门
- /// <summary>
- /// 接单情况汇总(月份)
- /// </summary>
- /// <param name="branchcode"></param>
- /// <returns></returns>
- public ActionResult GetStateCountMonthByDate(string branchcode, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- decimal[,] countstotal = new decimal[10, 12];//用于计算累计值
- string[] cols = new string[10];
- string[] months = new string[12];
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?signcode=" + signcode + "&areaid=" + areaid;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- if (!string.IsNullOrEmpty(branchcode))
- {
- return Content(ar);//查询单个时直接返回
- }
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["cols"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- a = a.Replace("\"", "");
- cols = a.Split(',');
- string b = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["months"].ToString(), "[\r\n\t ]", "");
- b = b.Replace("[", "");
- b = b.Replace("]", "");
- b = b.Replace("\"", "");
- months = b.Split(',');
- for (int i = 0; i < 10; i++)
- {
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["counts"][i].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- string[] z = y.Split(',');
- for (int m = 0; m < z.Length; m++)
- {
- countstotal[i, m] += decimal.Parse(z[m]);
- }
- }
- }
- }
- }
- var data = new
- {
- months,
- cols,
- counts = countstotal
- };
- return Success("成功", data);
- }
- /// <summary>
- /// 获取承办单位数量(因为是获取部门的所以未调整)
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="deptid"></param>
- /// <returns></returns>
- public ActionResult GetDeptCountByDateNew(string branchcode, DateTime? start, DateTime? end, string areaid, int deptid = 0)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- 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))
- {
- 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") + "&deptid=" + deptid .ToString() + "&areaid=" + areaid + "&signcode=" + signcode;
- AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
- if (ar.state.ToString() == ResultTypes.success.ToString())
- {
- var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
- result.AddRange(rtlist);
- }
- }
- }
- return Success("成功", result);
- }
- /// <summary>
- /// 单位受理处理时间分布
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="date"></param>
- /// <returns></returns>
- public ActionResult GetDealCount24ByDate(string branchcode, DateTime? date, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (date == null)
- {
- date = DateTime.Now;
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- int[] hours = Enumerable.Range(7, 12).ToArray<int>();
- int[] acounts = new int[12];
- int[] fcounts = new int[12];
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode + "&areaid=" + areaid;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- if (!string.IsNullOrEmpty(branchcode))
- {
- return Content(ar);//查询单个时直接返回
- }
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- for (int i = 0; i < 10; i++)
- {
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["acounts"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- string[] q = p.Split(',');
- acounts[i] += int.Parse(q[i]);
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["fcounts"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- string[] b = a.Split(',');
- fcounts[i] += int.Parse(b[i]);
- }
-
- }
- }
- }
- var data = new
- {
- hours,
- acounts,
- fcounts
- };
- return Success("成功", data);
- }
- /// <summary>
- /// 接单情况汇总(月份)
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="month"></param>
- /// <param name="day"></param>
- /// <returns></returns>
- public ActionResult GetStateCountByMonth(string branchcode, string month, string day, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (string.IsNullOrEmpty(month))
- {
- month = DateTime.Now.ToString("yyyy-MM");
- }
- if (string.IsNullOrEmpty(day))
- {
- day = "";
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("State");
- dtnew.Columns.Add("Name");
- dtnew.Columns.Add("Count");
-
- int first = 1;
-
- #endregion
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?month=" + month + "&day=" + day + "&areaid=" + areaid + "&isdpjk=1" + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][2].ToString()) + decimal.Parse(dt1.Rows[i][2].ToString());
- dtnew.Rows[i][2] = t;
- }
-
- }
- }
- }
- }
- return Success("成功", dtnew );
- }
- #endregion
- #region 投诉类型
- /// <summary>
- /// 接单情况汇总(月份)
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetTypeCountMonthByDate(string branchcode, string start, string end, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 变量定义
- DateTime startdate = DateTime.Now.AddMonths(-12);
- DateTime enddate = DateTime.Now;
- if (!string.IsNullOrEmpty(start))
- {
- startdate = DateTime.Parse(start + "-01");
- }
- if (!string.IsNullOrEmpty(end))
- {
- enddate = DateTime.Parse(end + "-01");
- }
- int cnt = (enddate.Year - startdate.Year) * 12 + enddate.Month - startdate.Month + 1;
- string[] months = new string[cnt];
- decimal[,] counts = new decimal[6, cnt];//用于计算累计值//固定了10个市县区
- string[] cols = new string[6];
- #endregion
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?start=" + start + "&end=" + end + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- if (!string.IsNullOrEmpty(branchcode))
- {
- return Content(ar);//查询单个时直接返回
- }
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- for (int i = 0; i < 6; i++)
- {
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["counts"][i].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- string[] z = y.Split(',');
- for (int m = 0; m < z.Length; m++)
- {
- counts[i, m] += decimal.Parse(z[m]);
- }
-
- }
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["cols"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- a = a.Replace("\"", "");
- cols = a.Split(',');
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["months"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- p = p.Replace("\"", "");
- months = p.Split(',');
- }
- }
- }
- var data = new
- {
- months,
- cols,
- counts
- };
- return Success("成功", data);
- }
- /// <summary>
- /// 获取关键词数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <param name="keyid"></param>
- /// <returns></returns>
- public ActionResult GetKeyCountByDateNew(string branchcode, DateTime? start, DateTime? end, string areaid, int keyid = 0)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("关键字");
- dtnew.Columns.Add("咨询");
- dtnew.Columns.Add("求助");
- dtnew.Columns.Add("投诉");
- dtnew.Columns.Add("建议");
- dtnew.Columns.Add("表扬");
- dtnew.Columns.Add("其他");
- dtnew.Columns.Add("合计");
- //dtnew.Columns.Add("排名");
- int first = 1;
-
- #endregion
- 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))
- {
- 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") + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- for (int m = 0; m < dtnew.Rows.Count; m++)
- {
- if (dtnew.Rows[m][0].ToString() == dt1.Rows[i][0].ToString())
- {
- for (int j = 1; j < 8; j++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][j].ToString()) + decimal.Parse(dt1.Rows[i][j].ToString());
- dtnew.Rows[i][j] = t;
- }
- }
- }
- }
-
- }
- }
- }
- }
- //dtnew.Columns.Add("排名");
- dtnew.DefaultView.Sort = "合计 DESC";
- DataTable dtTemp = dtnew.DefaultView.ToTable();
- #region 增加排名
- if (dtTemp != null)
- {
- //DataColumn autoColumn = new DataColumn("排名", System.Type.GetType("System.Int32"));
- //dtTemp.Columns.Add(autoColumn);
- //dtTemp.Columns["排名"].SetOrdinal(0);
- for (int i = 0; i < dtTemp.Rows.Count; i++)
- {
- dtTemp.Rows[i]["排名"] = i + 1;
- }
- }
- #endregion
- return Success("成功", dtTemp);
- }
- /// <summary>
- /// 获取类型数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetTypeCountByDate(string branchcode, DateTime? start, DateTime? end, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("TypeName");
- dtnew.Columns.Add("Count");
-
- int first = 1;
- #endregion
- 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))
- {
- 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") + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][1].ToString()) + decimal.Parse(dt1.Rows[i][1].ToString());
-
- dtnew.Rows[i][1] = t;
- }
-
- }
- //var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
- //result.AddRange(rtlist);
- }
- }
- }
- return Success("成功", dtnew );
- }
- #endregion
- #region 话务数量
- /// <summary>
- /// 坐席闲忙比例
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="start"></param>
- /// <param name="end"></param>
- /// <returns></returns>
- public ActionResult GetUserStateCount24ByDate(string branchcode, DateTime? start, DateTime? end, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (start == null && end == null)
- {
- start = DateTime.Now;
- end = DateTime.Now;
- }
- else
- {
- if (start == null) { start = DateTime.Now; }
- if (end == null) { end = DateTime.Now; }
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- int[] hours = Enumerable.Range(0, 24).ToArray<int>();
- double[] kxpercents = new double[24];
- double[] thpercents = new double[24];
- double[] zmpercents = new double[24];
- string[] kxcon = new string[24];
- string[] thcon = new string[24];
- string[] xxcon = new string[24];
- int[] con = new int[24];
- ArrayList result = new ArrayList();
- var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
- string controllername = RouteData.Values["controller"].ToString();
- string actionname = "GetUserStateNum24ByDate";// 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") + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- //if (!string.IsNullOrEmpty(branchcode))
- //{
- // return Content(ar);//查询单个时直接返回
- //}
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["kxcon"].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- y = y.Replace("\"", "");
- string[] z = y.Split(',');
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["thcon"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- p = p.Replace("\"", "");
- string[] q = p.Split(',');
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["xxcon"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- a = a.Replace("\"", "");
- string[] b = a.Split(',');
- string m = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["con"].ToString(), "[\r\n\t ]", "");
- m = m.Replace("[", "");
- m = m.Replace("]", "");
- m = m.Replace("\"", "");
- string[] n = m.Split(',');
- for (int i = 0; i < hours.Length; i++)
- {
- if (kxcon[i] == null)
- {
- kxcon[i] = "0";
- }
- if (thcon[i] == null)
- {
- thcon[i] = "0";
- }
- if (xxcon[i] == null)
- {
- xxcon[i] = "0";
- }
- kxcon[i] = (int.Parse(kxcon[i]) +int.Parse(z[i])).ToString ();
- thcon[i] = (int.Parse(thcon[i])+int.Parse(q[i])).ToString();
- xxcon[i] = (int.Parse(xxcon[i]) + int.Parse(b[i])).ToString();
- con[i] += int.Parse(n[i]);
- }
- }
- }
- }
- for (int i = 0; i < hours.Length; i++)
- {
- if (con[i] == 0)
- {
- kxpercents[i] = 0;
- thpercents[i] = 0;
- zmpercents[i] = 0;
- }
- else
- {
- kxpercents[i] = Math.Round((double.Parse(kxcon[i]) * 100 / con[i]), 2);
- thpercents[i] = Math.Round((double.Parse(thcon[i]) * 100 / con[i]), 2);
- zmpercents[i] = Math.Round((double.Parse(xxcon[i]) * 100 / con[i]), 2);
- }
- }
- var data = new
- {
- hours,
- kxpercents ,
- thpercents,
- zmpercents
- };
- return Success("加载成功", data);
- }
- /// <summary>
- /// 话务量实时数据统计
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="date"></param>
- /// <returns></returns>
- public ActionResult GetTelCount24ByDate(string branchcode, DateTime? date, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (date == null)
- {
- date = DateTime.Now;
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- int[] hours = Enumerable.Range(0, 24).ToArray<int>();
- int[] rcounts = new int[24];//来电数量
- int[] ccounts = new int[24];//接通数量
- int[] lcounts = new int[24];//留言数量
- int[] gcounts = new int[24];//放弃数量
- int[] scounts = new int[24];//骚扰数量
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode + "&areaid=" + areaid;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- if (!string.IsNullOrEmpty(branchcode))
- {
- return Content(ar);//查询单个时直接返回
- }
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- //string x = jo0["data"].ToString();
-
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["rcounts"].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- string[] z = y.Split(',');
-
-
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["ccounts"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- string[] q = p.Split(',');
- string a = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["gcounts"].ToString(), "[\r\n\t ]", "");
- a = a.Replace("[", "");
- a = a.Replace("]", "");
- string[] b = a.Split(',');
- string m = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["scounts"].ToString(), "[\r\n\t ]", "");
- m = m.Replace("[", "");
- m = m.Replace("]", "");
- string[] n = m.Split(',');
- for (int i = 0; i < 24; i++)
- {
- rcounts[i] += int.Parse (z[i]);
- ccounts[i] += int.Parse(q[i]);
- gcounts[i] += int.Parse(b[i]);
- scounts[i] += int.Parse(n[i]);
- }
-
- }
- }
- }
- var data = new
- {
- hours,
- rcounts ,
- ccounts ,
- //lcounts = lcounts,
- gcounts,
- scounts
- };
- return Success("加载成功", data);
- }
- /// <summary>
- /// 获取通话数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="date"></param>
- /// <returns></returns>
- public ActionResult GetTelCountByDate(string branchcode, DateTime? date, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (date == null)
- {
- date = DateTime.Now;
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- decimal hwcon=0;
- decimal lhcon = 0;
- decimal jtcon = 0;
- double pjthtimes = 0;
- double jtl = 0;
- double thtimes=0;
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- if (!string.IsNullOrEmpty(branchcode))
- {
- return Content(ar);//查询单个时直接返回
- }
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- hwcon+=decimal .Parse (jo0["data"]["hwcon"].ToString());
- lhcon += decimal.Parse(jo0["data"]["lhcon"].ToString());
- jtcon += decimal.Parse(jo0["data"]["jtcon"].ToString());
- //pjthtimes += decimal.Parse(jo0["data"]["pjthtimes"].ToString());
- thtimes += double.Parse(jo0["data"]["pjthtimes"].ToString());
- //jtl += decimal.Parse(jo0["data"]["jtl"].ToString());
- if (hwcon >0)
- {
- jtl = Math.Round((double.Parse(jtcon.ToString ()) * 100 / double.Parse(hwcon.ToString ())), 2);
- }
- if (jtcon >0)
- {
- pjthtimes = Math.Round(thtimes / double.Parse(jtcon.ToString ()));
- }
- }
- }
- }
- var data = new
- {
- hwcon = hwcon,
- lhcon = lhcon,
- jtcon = jtcon,
- pjthtimes = pjthtimes,
- jtl = jtl
- };
- return Success("加载成功", data);
- }
- #endregion
- #region 中心大数据
- /// <summary>
- /// 工单类型各数量
- /// </summary>
- /// <param name="branchcode"></param>
- /// <returns></returns>
- public ActionResult GetTypeCountNew(string branchcode, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- #region 定义新表
- DataTable dtnew = new DataTable();
- dtnew.Columns.Add("TypeName");
- dtnew.Columns.Add("DayCount");
- dtnew.Columns.Add("MonthCount");
- dtnew.Columns.Add("TotalCount");
- dtnew.Columns.Add("Percent");
- int first = 1;
- Int64 totalcount = 0;
- #endregion
- 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))
- {
- if (!string.IsNullOrEmpty(l.F_AreaId))
- {
- areaid = l.F_AreaId;
- }
- string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
- string strparams = "?signcode=" + signcode + "&areaid=" + areaid;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- 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;
- }
- else
- {
- //前部分相加
- DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- for (int j = 1; j < 4; j++)
- {
- decimal t = decimal.Parse(dtnew.Rows[i][j].ToString()) + decimal.Parse(dt1.Rows[i][j].ToString());
- dtnew.Rows[i][j] = t;
-
- }
- totalcount += Int64.Parse(dtnew.Rows[i]["TotalCount"].ToString());
- }
- }
- //var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
- //result.AddRange(rtlist);
- }
- }
- }
- #region 计算比例
- if (totalcount > 0)
- {
- for (int j = 0; j < dtnew.Rows.Count; j++)
- {
- dtnew.Rows[j]["Percent"] = Math.Round(decimal.Parse(dtnew.Rows[j]["TotalCount"].ToString()) / totalcount * 100, 2);
- }
- }
- #endregion
- return Success("成功", dtnew);
- }
- /// <summary>
- /// 接通率统计
- /// </summary>
- /// <param name="branchcode"></param>
- /// <param name="date"></param>
- /// <returns></returns>
- public ActionResult GetTelRate24ByDate(string branchcode, DateTime? date, string areaid)
- {
- if (branchcode == "sqs12345")
- {
- branchcode = "";
- }
- if (date == null)
- {
- date = DateTime.Now;
- }
- string sqlwhere = " F_IsDP=1 ";
- if (!string.IsNullOrEmpty(branchcode))
- {
- sqlwhere += " and F_Code='" + branchcode + "'";
- }
- else
- {
- sqlwhere += " and F_IsSQ!=1";
- }
- int[] hours = Enumerable.Range(0, 24).ToArray<int>();
- int[] jt = new int[24];
- int[] zs = new int[24];
- double[] rates = new double[24];
-
- ArrayList result = new ArrayList();
- var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
- string controllername = RouteData.Values["controller"].ToString();
- string actionname = "GetTelNum24ByDate";// 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 = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&areaid=" + areaid + "&signcode=" + signcode;
- string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
- //if (!string.IsNullOrEmpty(branchcode))
- //{
- // return Content(ar);//查询单个时直接返回
- //}
- JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
- if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
- {
- //string x = jo0["data"].ToString();
-
- string y = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["jt"].ToString(), "[\r\n\t ]", "");
- y = y.Replace("[", "");
- y = y.Replace("]", "");
- string[] z = y.Split(',');
- string p = System.Text.RegularExpressions.Regex.Replace(jo0["data"]["zs"].ToString(), "[\r\n\t ]", "");
- p = p.Replace("[", "");
- p = p.Replace("]", "");
- string[] q = p.Split(',');
- for (int i = 0; i < 24; i++)
- {
- jt[i] += int.Parse(z[i]);
- zs[i] += int.Parse(q[i]);
- }
-
- }
- }
- }
- for (int j = 0; j < 24; j++)
- {
- rates[j] = zs[j] > 0 ? Math.Round(((double)jt[j] * 100 / zs[j]), 2) : 0;
- }
- var data = new
- {
- hours ,
- rates
- };
- return Success("成功", data);
- }
- #endregion
- #region 数据处理
- /// <summary>
- /// Json 字符串 转换为 DataTable数据集合
- /// </summary>
- /// <param name="json"></param>
- /// <returns></returns>
- public static DataTable ToDataTable(string json,string dicstr)//Item
- {
- DataTable dataTable = new DataTable(); //实例化
- DataTable result;
- try
- {
- JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
- javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
- ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(json);
- if (arrayList.Count > 0)
- {
- foreach (Dictionary<string, object> dictionary in arrayList)
- {
- if (dictionary.Keys.Count<string>() == 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());
- else
- {
- ArrayList list = dictionary[current] as ArrayList;
- foreach (Dictionary<string, object> dic in list)
- {
- foreach (string key in dic.Keys)
- {
- dataTable.Columns.Add(key, dic[key].GetType());
- }
- break;
- }
- }
- }
- }
- //Rows
- //string root = "";
-
- List<string> cname = new List<string>();
- foreach (string current in dictionary.Keys)
- {
-
- if (current != dicstr)
- {
- //root = current;
- //dataRow[root] = dictionary[root];
-
- cname.Add(current);
- }
- else
- {
- ArrayList list = dictionary[current] as ArrayList;
- foreach (Dictionary<string, object> dic in list)
- {
- DataRow dataRow = dataTable.NewRow();
- foreach (var li in cname )
- {
- if (dictionary[li] == null)
- {
- dataRow[li] = -1;
- }
- else
- {
- dataRow[li] = dictionary[li];
- }
-
- }
- //dataRow[root] = dictionary[root];
- foreach (string key in dic.Keys)
- {
- dataRow[key] = dic[key];
- }
- dataTable.Rows.Add(dataRow);
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- result = dataTable;
- return result;
- }
- 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<ArrayList>(json);
- if (arrayList.Count > 0)
- {
- foreach (Dictionary<string, object> dictionary in arrayList)
- {
- if (dictionary.Keys.Count<string>() == 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());
- //else
- //{
- // ArrayList list = dictionary[current] as ArrayList;
- // foreach (Dictionary<string, object> dic in list)
- // {
- // foreach (string key in dic.Keys)
- // {
- // dataTable.Columns.Add(key, dic[key].GetType());
- // }
- // break;
- // }
- //}
- }
- }
- //Rows
- //string root = "";
- List<string> cname = new List<string>();
- 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];
- }
- }
- //dataRow[root] = dictionary[root];
-
- //else
- //{
- // ArrayList list = dictionary[current] as ArrayList;
- // foreach (Dictionary<string, object> dic in list)
- // {
- // DataRow dataRow = dataTable.NewRow();
- // foreach (var li in cname)
- // {
- // dataRow[li] = dictionary[li];
- // }
- // //dataRow[root] = dictionary[root];
- // foreach (string key in dic.Keys)
- // {
- // dataRow[key] = dic[key];
- // }
- // dataTable.Rows.Add(dataRow);
- // }
- //}
- }
- dataTable.Rows.Add(dataRow);
- }
- }
- }
- catch
- {
- }
- result = dataTable;
- return result;
- }
- public static DataTable ItemToDataTable(string json, string dicstr)//Item
- {
- DataTable dataTable = new DataTable(); //实例化
- DataTable result;
- try
- {
- JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
- javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
- ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(json);
- if (arrayList.Count > 0)
- {
- foreach (Dictionary<string, object> dictionary in arrayList)
- {
- if (dictionary.Keys.Count<string>() == 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());
- else
- {
- ArrayList list = dictionary[current] as ArrayList;
- foreach (Dictionary<string, object> dic in list)
- {
- foreach (string key in dic.Keys)
- {
- dataTable.Columns.Add(key, dic[key].GetType());
- }
- break;
- }
- }
- }
- }
- //Rows
- //string root = "";
- List<string> cname = new List<string>();
- foreach (string current in dictionary.Keys)
- {
- if (current != dicstr)
- {
- //root = current;
- //dataRow[root] = dictionary[root];
- //cname.Add(current);
- }
- else
- {
- ArrayList list = dictionary[current] as ArrayList;
- foreach (Dictionary<string, object> dic in list)
- {
- DataRow dataRow = dataTable.NewRow();
- //foreach (var li in cname)
- //{
- //dataRow[li] = dictionary[li];
- //}
- //dataRow[root] = dictionary[root];
- foreach (string key in dic.Keys)
- {
- dataRow[key] = dic[key];
- }
- dataTable.Rows.Add(dataRow);
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- result = dataTable;
- return result;
- }
- #endregion
- }
- }
|