县级监管平台

CountyBusinessController.cs 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. 
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using System.Web.Script.Serialization;
  10. using CallCenterApi.Common;
  11. using CallCenterApi.DB;
  12. using CallCenterApi.Interface.Controllers.Base;
  13. using Newtonsoft.Json;
  14. using Newtonsoft.Json.Linq;
  15. namespace CallCenterApi.Interface.Controllers.County
  16. {
  17. //[Authority]
  18. public class CountyBusinessController : BaseController
  19. {
  20. // GET: CountyBusiness
  21. /// <summary>
  22. /// 获取工单列表
  23. /// </summary>
  24. /// <param name="phone"></param>
  25. /// <param name="usercode"></param>
  26. /// <returns></returns>
  27. public ActionResult GetAreaOrderList(string branchcode)
  28. {
  29. string sqlwhere = " F_IsDelete=0 ";
  30. if (!string.IsNullOrEmpty(branchcode))
  31. {
  32. sqlwhere += " and F_Code='" + branchcode + "'";
  33. }
  34. else
  35. {
  36. return Error("请选择区县");
  37. }
  38. //ArrayList result = new ArrayList();
  39. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  40. if (list.Count == 0)
  41. {
  42. return Error("查询失败");
  43. }
  44. string strstate = HttpUtility.UrlDecode(RequestString.GetQueryString("state"));
  45. string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
  46. string strtel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
  47. string strkey = HttpUtility.UrlDecode(RequestString.GetQueryString("key"));
  48. string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
  49. string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
  50. string strworkid = HttpUtility.UrlDecode(RequestString.GetQueryString("workid"));
  51. int dealtype = RequestString.GetInt("dealtype", -1);
  52. #region 新增筛选项
  53. string strusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("usercode"));
  54. string strddusercode = HttpUtility.UrlDecode(RequestString.GetQueryString("ddusercode"));//调度员
  55. int source = RequestString.GetInt("source", 0);
  56. int keyid = RequestString.GetInt("keyid", 0);
  57. int type = RequestString.GetInt("type", 0);
  58. int bigtype = RequestString.GetInt("bigtype", 0);
  59. int smalltype = RequestString.GetInt("smalltype", 0);
  60. int sourcearea = RequestString.GetInt("sourcearea", 0);
  61. int deptid = RequestString.GetInt("deptid", 0);
  62. int issend = RequestString.GetInt("issend", -1);
  63. int deptlevel = RequestString.GetInt("deptlevel", 0);
  64. #endregion
  65. string strpageindex = RequestString.GetQueryString("page");
  66. int pageindex = 1;
  67. string strpagesize = RequestString.GetQueryString("pagesize");
  68. int pagesize = 10;
  69. if (!string.IsNullOrEmpty(strpageindex) && strpageindex.Trim() != "")
  70. {
  71. pageindex = Convert.ToInt32(strpageindex);
  72. }
  73. if (!string.IsNullOrEmpty(strpagesize) && strpagesize.Trim() != "")
  74. {
  75. pagesize = Convert.ToInt32(strpagesize);
  76. }
  77. string controllername = RouteData.Values["controller"].ToString();
  78. string actionname = RouteData.Values["action"].ToString();
  79. if (!string.IsNullOrEmpty(list[0].F_Url))
  80. {
  81. string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign);
  82. string strparams = "?state=" + strstate + "&name=" + strname + "&tel=" + strtel + "&key=" + strkey
  83. + "&usercode="+ strusercode+ "&ddusercode="+ strddusercode+ "&source="+ source+ "&keyid="+ keyid
  84. + "&type="+ type+ "&bigtype="+ bigtype+ "&smalltype="+ smalltype+ "&sourcearea="+ sourcearea
  85. + "&deptid="+ deptid+ "&issend="+ issend+ "&deptlevel="+ deptlevel+ "&workid="+ strworkid
  86. + "&starttime=" + strstarttime + "&endtime=" + strendtime + "&page=" + pageindex + "&pagesize=" + pagesize + "&signcode=" + signcode;
  87. string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams);
  88. return Content(result);
  89. }
  90. else
  91. {
  92. var obj = new
  93. {
  94. state = "success",
  95. message = "成功",
  96. rows = new DataTable(),
  97. total = 0
  98. };
  99. return Content(obj.ToJson());
  100. }
  101. }
  102. /// <summary>
  103. /// 获取工单列表
  104. /// </summary>
  105. /// <param name="phone"></param>
  106. /// <param name="usercode"></param>
  107. /// <returns></returns>
  108. public ActionResult GetAreaWorkOrder(string branchcode, string workorderid)
  109. {
  110. string sqlwhere = " F_IsDelete=0 ";
  111. if (!string.IsNullOrEmpty(branchcode))
  112. {
  113. sqlwhere += " and F_Code='" + branchcode + "'";
  114. }
  115. else
  116. {
  117. return Error("请选择区县");
  118. }
  119. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  120. if (list.Count == 0)
  121. {
  122. return Error("查询失败");
  123. }
  124. if (string.IsNullOrEmpty(workorderid))
  125. {
  126. return Error("查询失败");
  127. }
  128. string controllername = RouteData.Values["controller"].ToString();
  129. string actionname = RouteData.Values["action"].ToString();
  130. if (!string.IsNullOrEmpty(list[0].F_Url))
  131. {
  132. string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign);
  133. string strparams = "?workorderid=" + workorderid + "&signcode=" + signcode;
  134. string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams);
  135. return Content(result);
  136. }
  137. else
  138. {
  139. return Error("查询失败");
  140. }
  141. }
  142. /// <summary>
  143. /// 绩效考核
  144. /// </summary>
  145. /// <param name="start"></param>
  146. /// <param name="end"></param>
  147. /// <returns></returns>
  148. public ActionResult GetAreaAssessment(string branchcode,DateTime? start, DateTime? end, int isdc = 0)
  149. {
  150. if (start == null)
  151. {
  152. start = DateTime.Now;
  153. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  154. }
  155. if (end == null)
  156. {
  157. end = DateTime.Now;
  158. }
  159. string sqlwhere = " F_IsDelete=0 ";
  160. if (!string.IsNullOrEmpty(branchcode))
  161. {
  162. sqlwhere += " and F_Code='" + branchcode + "'";
  163. }
  164. ArrayList result = new ArrayList();
  165. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  166. string controllername = RouteData.Values["controller"].ToString();
  167. string actionname = RouteData.Values["action"].ToString();
  168. foreach (var l in list)
  169. {
  170. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  171. {
  172. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  173. string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode;
  174. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  175. if (ar.state.ToString() == ResultTypes.success.ToString())
  176. {
  177. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  178. result.AddRange(rtlist);
  179. }
  180. }
  181. }
  182. if (isdc > 0)
  183. {
  184. string[] cols = new string[] { "区县名称", "受理量", "交办量", "已办量", "重办量", "及时量", "超时量", "延时量", "回访量", "市民满意", "市民不满意" };
  185. NPOIHelper npoi = new NPOIHelper();
  186. if (npoi.ExportToExcel("绩效考核报表", result, cols) == "")
  187. {
  188. return Success("导出成功");
  189. }
  190. else
  191. {
  192. return Error("导出失败");
  193. }
  194. }
  195. return Success("成功", result);
  196. }
  197. //2019-8-21
  198. /// <summary>
  199. /// 绩效考核--添加获取市县总和
  200. /// </summary>
  201. /// <param name="start"></param>
  202. /// <param name="end"></param>
  203. /// <returns></returns>
  204. public ActionResult GetAreaAssessmentNew(string branchcode, DateTime? start, DateTime? end, int isdc = 0)
  205. {
  206. start = DateTime.Now.AddDays(-100);
  207. #region 定义新表
  208. DataTable dtnew = new DataTable();
  209. dtnew.Columns.Add("areaname");
  210. dtnew.Columns.Add("acceptcount");
  211. dtnew.Columns.Add("assigncount");
  212. dtnew.Columns.Add("dealcount");
  213. dtnew.Columns.Add("reloadcount");
  214. dtnew.Columns.Add("timelycount");
  215. dtnew.Columns.Add("timeoutcount");
  216. dtnew.Columns.Add("delaycount");
  217. dtnew.Columns.Add("visitcount");
  218. dtnew.Columns.Add("satisfiedcount");
  219. dtnew.Columns.Add("notsatisfiedcount");
  220. int first = 1;
  221. //Int64 totalcount = 0;
  222. #endregion
  223. if (start == null)
  224. {
  225. start = DateTime.Now;
  226. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  227. }
  228. if (end == null)
  229. {
  230. end = DateTime.Now;
  231. }
  232. string sqlwhere = " F_IsDelete=0 ";
  233. if (!string.IsNullOrEmpty(branchcode))
  234. {
  235. sqlwhere += " and F_Code='" + branchcode + "'";
  236. }
  237. //string areaid = "";
  238. ArrayList result = new ArrayList();
  239. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  240. string controllername = RouteData.Values["controller"].ToString();
  241. string actionname = "GetAreaAssessment";//RouteData.Values["action"].ToString();
  242. foreach (var l in list)
  243. {
  244. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  245. {
  246. //if (!string.IsNullOrEmpty(l.F_AreaId))
  247. //{
  248. // areaid = l.F_AreaId;
  249. //}
  250. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  251. string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode;
  252. string ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams);//.ToObject<AjaxResult>();
  253. //if (!string.IsNullOrEmpty(branchcode))
  254. //{
  255. // return Content(ar);//查询单个时直接返回
  256. //}
  257. JObject jo0 = (JObject)JsonConvert.DeserializeObject(ar);
  258. if (jo0 != null && jo0["state"].ToString() == ResultTypes.success.ToString())
  259. {
  260. if (first == 1)
  261. {
  262. DataTable dt = HeadToDataTable(jo0["data"].ToString(), "Item");
  263. dtnew = dt;
  264. first = 0;
  265. if (!string.IsNullOrEmpty(branchcode))
  266. {
  267. break;
  268. }
  269. }
  270. else
  271. {
  272. int isbh = 0;
  273. //前部分相加
  274. DataTable dt1 = HeadToDataTable(jo0["data"].ToString(), "Item");
  275. for (int m = 0; m < dt1 .Rows .Count ; m++)
  276. {
  277. for (int i = 0; i < dtnew.Rows.Count; i++)
  278. {
  279. if (dtnew.Rows[i]["areaname"].ToString() == dt1.Rows[m]["areaname"].ToString())
  280. {
  281. for (int j = 1; j < 11; j++)
  282. {
  283. string cols = dtnew.Columns[j].ColumnName;
  284. decimal t = decimal.Parse(dtnew.Rows[i][cols].ToString()) + decimal.Parse(dt1.Rows[m][cols].ToString());
  285. dtnew.Rows[i][cols] = t;
  286. isbh = 1;
  287. }
  288. //totalcount += Int64.Parse(dtnew.Rows[i]["TotalCount"].ToString());
  289. }
  290. }
  291. if (isbh == 0)
  292. {
  293. DataRow dr = dt1.Rows[m];
  294. dtnew.ImportRow(dr);
  295. }
  296. }
  297. }
  298. //var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  299. //result.AddRange(rtlist);
  300. }
  301. }
  302. }
  303. if (isdc > 0)
  304. {
  305. string[] cols = new string[] { "区县名称", "受理量", "交办量", "已办量", "重办量", "及时量", "超时量", "延时量", "回访量", "市民满意", "市民不满意" };
  306. NPOIHelper npoi = new NPOIHelper();
  307. if (npoi.ExportToExcel("绩效考核报表", dtnew, cols) == "")
  308. {
  309. return Success("导出成功");
  310. }
  311. else
  312. {
  313. return Error("导出失败");
  314. }
  315. }
  316. return Success("成功", dtnew);
  317. }
  318. public static DataTable HeadToDataTable(string json, string dicstr)//Item
  319. {
  320. DataTable dataTable = new DataTable(); //实例化
  321. DataTable result;
  322. try
  323. {
  324. JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
  325. javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值
  326. ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(json);
  327. if (arrayList.Count > 0)
  328. {
  329. foreach (Dictionary<string, object> dictionary in arrayList)
  330. {
  331. if (dictionary.Keys.Count<string>() == 0)
  332. {
  333. result = dataTable;
  334. return result;
  335. }
  336. //Columns
  337. if (dataTable.Columns.Count == 0)
  338. {
  339. foreach (string current in dictionary.Keys)
  340. {
  341. if (current != dicstr)
  342. dataTable.Columns.Add(current, dictionary[current].GetType());
  343. }
  344. }
  345. //Rows
  346. //string root = "";
  347. List<string> cname = new List<string>();
  348. DataRow dataRow = dataTable.NewRow();
  349. foreach (string current in dictionary.Keys)
  350. {
  351. if (current != dicstr)
  352. {
  353. //root = current;
  354. //dataRow[root] = dictionary[root];
  355. cname.Add(current);
  356. }
  357. foreach (var li in cname)
  358. {
  359. if (dictionary[li] == null)
  360. {
  361. dataRow[li] = -1;
  362. }
  363. else
  364. {
  365. dataRow[li] = dictionary[li];
  366. }
  367. }
  368. }
  369. dataTable.Rows.Add(dataRow);
  370. }
  371. }
  372. }
  373. catch
  374. {
  375. }
  376. result = dataTable;
  377. return result;
  378. }
  379. /// <summary>
  380. /// 县区受理
  381. /// </summary>
  382. /// <param name="start"></param>
  383. /// <param name="end"></param>
  384. /// <returns></returns>
  385. public ActionResult GetAreaAccept(string branchcode, DateTime? date, int isdc = 0)
  386. {
  387. if (date == null)
  388. {
  389. date = DateTime.Now;
  390. }
  391. string sqlwhere = " F_IsDelete=0 ";
  392. if (!string.IsNullOrEmpty(branchcode))
  393. {
  394. sqlwhere += " and F_Code='" + branchcode + "'";
  395. }
  396. ArrayList result = new ArrayList();
  397. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  398. string controllername = RouteData.Values["controller"].ToString();
  399. string actionname = RouteData.Values["action"].ToString();
  400. foreach (var l in list)
  401. {
  402. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  403. {
  404. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  405. string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode;
  406. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  407. if (ar.state.ToString() == ResultTypes.success.ToString())
  408. {
  409. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  410. result.AddRange(rtlist);
  411. }
  412. }
  413. }
  414. if (isdc > 0)
  415. {
  416. string[] cols = new string[] { "区县名称", "受理量", "同比", "环比" };
  417. NPOIHelper npoi = new NPOIHelper();
  418. if (npoi.ExportToExcel("县区受理报表", result, cols) == "")
  419. {
  420. return Success("导出成功");
  421. }
  422. else
  423. {
  424. return Error("导出失败");
  425. }
  426. }
  427. return Success("成功", result);
  428. }
  429. /// <summary>
  430. /// 县区办理
  431. /// </summary>
  432. /// <param name="start"></param>
  433. /// <param name="end"></param>
  434. /// <returns></returns>
  435. public ActionResult GetAreaDeal(string branchcode, DateTime? date, int isdc = 0)
  436. {
  437. if (date == null)
  438. {
  439. date = DateTime.Now;
  440. }
  441. string sqlwhere = " F_IsDelete=0 ";
  442. if (!string.IsNullOrEmpty(branchcode))
  443. {
  444. sqlwhere += " and F_Code='" + branchcode + "'";
  445. }
  446. ArrayList result = new ArrayList();
  447. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  448. string controllername = RouteData.Values["controller"].ToString();
  449. string actionname = RouteData.Values["action"].ToString();
  450. foreach (var l in list)
  451. {
  452. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  453. {
  454. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  455. string strparams = "?date=" + date.Value.ToString("yyyy-MM-dd") + "&signcode=" + signcode;
  456. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  457. if (ar.state.ToString() == ResultTypes.success.ToString())
  458. {
  459. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  460. result.AddRange(rtlist);
  461. }
  462. }
  463. }
  464. if (isdc > 0)
  465. {
  466. string[] cols = new string[] { "区县名称", "办理量", "同比", "环比" };
  467. NPOIHelper npoi = new NPOIHelper();
  468. if (npoi.ExportToExcel("县区办理报表", result, cols) == "")
  469. {
  470. return Success("导出成功");
  471. }
  472. else
  473. {
  474. return Error("导出失败");
  475. }
  476. }
  477. return Success("成功", result);
  478. }
  479. /// <summary>
  480. /// 县区各类型统计
  481. /// </summary>
  482. /// <param name="start"></param>
  483. /// <param name="end"></param>
  484. /// <returns></returns>
  485. public ActionResult GetAreaCount(string branchcode, DateTime? start, DateTime? end, int type, int isdc = 0)
  486. {
  487. if (start == null)
  488. {
  489. start = DateTime.Now;
  490. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  491. }
  492. if (end == null)
  493. {
  494. end = DateTime.Now;
  495. }
  496. string sqlwhere = " F_IsDelete=0 ";
  497. if (!string.IsNullOrEmpty(branchcode))
  498. {
  499. sqlwhere += " and F_Code='" + branchcode + "'";
  500. }
  501. ArrayList result = new ArrayList();
  502. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  503. string controllername = RouteData.Values["controller"].ToString();
  504. string actionname = RouteData.Values["action"].ToString();
  505. foreach (var l in list)
  506. {
  507. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  508. {
  509. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  510. string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&type=" + type + "&signcode=" + signcode;
  511. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  512. if (ar.state.ToString() == ResultTypes.success.ToString())
  513. {
  514. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  515. result.AddRange(rtlist);
  516. }
  517. }
  518. }
  519. if (isdc > 0)
  520. {
  521. string[] cols = new string[] { "区县名称", "类型", "数量" };
  522. NPOIHelper npoi = new NPOIHelper();
  523. if (npoi.ExportToExcel("统计报表", result, cols) == "")
  524. {
  525. return Success("导出成功");
  526. }
  527. else
  528. {
  529. return Error("导出失败");
  530. }
  531. }
  532. return Success("成功", result);
  533. }
  534. /// <summary>
  535. /// 县区来源统计
  536. /// </summary>
  537. /// <param name="start"></param>
  538. /// <param name="end"></param>
  539. /// <returns></returns>
  540. public ActionResult GetAreaSourceCount(string branchcode, DateTime? start, DateTime? end, int isdc = 0)
  541. {
  542. if (start == null)
  543. {
  544. start = DateTime.Now;
  545. start = new DateTime(start.Value.Year, start.Value.Month, 1);
  546. }
  547. if (end == null)
  548. {
  549. end = DateTime.Now;
  550. }
  551. string sqlwhere = " F_IsDelete=0 ";
  552. if (!string.IsNullOrEmpty(branchcode))
  553. {
  554. sqlwhere += " and F_Code='" + branchcode + "'";
  555. }
  556. ArrayList result = new ArrayList();
  557. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  558. string controllername = RouteData.Values["controller"].ToString();
  559. string actionname = "GetAreaCount";// RouteData.Values["action"].ToString();
  560. foreach (var l in list)
  561. {
  562. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  563. {
  564. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  565. string strparams = "?start=" + start.Value.ToString("yyyy-MM-dd") + "&end=" + end.Value.ToString("yyyy-MM-dd") + "&type=1&signcode=" + signcode;
  566. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  567. if (ar.state.ToString() == ResultTypes.success.ToString())
  568. {
  569. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  570. result.AddRange(rtlist);
  571. }
  572. }
  573. }
  574. ArrayList areas = new ArrayList();
  575. string[] sources = new string[] { "电话", "12345信箱", "微博", "网站", "微信", "手机APP", "政务服务网" };
  576. DataTable dt = new DataTable();
  577. dt.Columns.Add("县区/渠道");
  578. foreach (var source in sources)
  579. {
  580. dt.Columns.Add(source,typeof(int));
  581. }
  582. dt.Columns.Add("合计", typeof(int));
  583. DataRow dr = dt.NewRow();
  584. int i = 0;
  585. int sum = 0;
  586. foreach (Dictionary<string, object> l in result)
  587. {
  588. string area= l["areaname"].ToString();
  589. string source = l["source"].ToString();
  590. if (!areas.Contains(area))
  591. {
  592. areas.Add(area);
  593. if (i != 0)
  594. {
  595. dr["合计"] = sum;
  596. dt.Rows.Add(dr);
  597. sum = 0;
  598. dr = dt.NewRow();
  599. }
  600. dr["县区/渠道"] = area;
  601. i++;
  602. }
  603. if (sources.Contains(source))
  604. {
  605. dr[source] = l["count"].ToString();
  606. sum += Int32.Parse(l["count"].ToString());
  607. }
  608. }
  609. dr["合计"] = sum;
  610. dt.Rows.Add(dr);
  611. dr = dt.NewRow();
  612. dr["县区/渠道"] = "合计";
  613. dr["电话"] = dt.Compute("sum([电话])", "true").ToString();
  614. dr["12345信箱"] = dt.Compute("sum([12345信箱])", "true").ToString();
  615. dr["微博"] = dt.Compute("sum([微博])", "true").ToString();
  616. dr["网站"] = dt.Compute("sum([网站])", "true").ToString();
  617. dr["微信"] = dt.Compute("sum([微信])", "true").ToString();
  618. dr["手机APP"] = dt.Compute("sum([手机APP])", "true").ToString();
  619. dr["政务服务网"] = dt.Compute("sum([政务服务网])", "true").ToString();
  620. dr["合计"] = dt.Compute("sum([合计])", "true").ToString();
  621. dt.Rows.Add(dr);
  622. if (isdc > 0)
  623. {
  624. NPOIHelper npoi = new NPOIHelper();
  625. if (npoi.ExportToExcel("来源统计报表", dt) == "")
  626. {
  627. return Success("导出成功");
  628. }
  629. else
  630. {
  631. return Error("导出失败");
  632. }
  633. }
  634. return Success("成功", dt);
  635. }
  636. /// <summary>
  637. /// 办理率统计
  638. /// </summary>
  639. /// <param name="branchcode"></param>
  640. /// <param name="month"></param>
  641. /// <param name="isdc"></param>
  642. /// <returns></returns>
  643. public ActionResult GetAreaEndRate(string branchcode, string month, int isdc = 0)
  644. {
  645. string sqlwhere = " F_IsDelete=0 ";
  646. if (!string.IsNullOrEmpty(branchcode))
  647. {
  648. sqlwhere += " and F_Code='" + branchcode + "'";
  649. }
  650. ArrayList result = new ArrayList();
  651. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  652. string controllername = RouteData.Values["controller"].ToString();
  653. string actionname = RouteData.Values["action"].ToString();
  654. foreach (var l in list)
  655. {
  656. if (!string.IsNullOrEmpty(l.F_Sign) && !string.IsNullOrEmpty(l.F_Url))
  657. {
  658. string signcode = CommonHelper.getsigncode(controllername, actionname, l.F_Sign);
  659. string strparams = "?month=" + month + "&signcode=" + signcode;
  660. AjaxResult ar = HttpMethods.HttpGet(l.F_Url + "/" + controllername + "/" + actionname + strparams).ToObject<AjaxResult>();
  661. if (ar.state.ToString() == ResultTypes.success.ToString())
  662. {
  663. var rtlist = ar.data.ToJson().ToList<Dictionary<string, object>>();
  664. result.AddRange(rtlist);
  665. }
  666. }
  667. }
  668. if (isdc > 0)
  669. {
  670. string[] cols = new string[] { "区县名称", "受理量", "办理量", "结案量", "结案率" };
  671. NPOIHelper npoi = new NPOIHelper();
  672. if (npoi.ExportToExcel("县区结案率报表", result, cols) == "")
  673. {
  674. return Success("导出成功");
  675. }
  676. else
  677. {
  678. return Error("导出失败");
  679. }
  680. }
  681. return Success("成功", result);
  682. }
  683. /// <summary>
  684. /// 获取简报月
  685. /// </summary>
  686. /// <param name="branchcode"></param>
  687. /// <param name="month"></param>
  688. /// <param name="isdc"></param>
  689. /// <returns></returns>
  690. public ActionResult GetSimpleReport(string branchcode, string month, int isdc = 0)
  691. {
  692. string sqlwhere = " F_IsDelete=0 ";
  693. if (!string.IsNullOrEmpty(branchcode))
  694. {
  695. sqlwhere += " and F_Code='" + branchcode + "'";
  696. }
  697. else
  698. {
  699. return Error("请选择区县");
  700. }
  701. //ArrayList result = new ArrayList();
  702. var list = new BLL.T_Branch_List().GetModelList(sqlwhere);
  703. if (list.Count == 0)
  704. {
  705. return Error("查询失败");
  706. }
  707. string controllername = RouteData.Values["controller"].ToString();
  708. string actionname = RouteData.Values["action"].ToString();
  709. if (!string.IsNullOrEmpty(list[0].F_Url))
  710. {
  711. string signcode = CommonHelper.getsigncode(controllername, actionname, list[0].F_Sign);
  712. string strparams = "?month=" + month + "&signcode=" + signcode;
  713. string result = HttpMethods.HttpGet(list[0].F_Url + "/" + controllername + "/" + actionname + strparams);
  714. if (isdc > 0)
  715. {
  716. AjaxResult ar = result.ToObject<AjaxResult>();
  717. NPOIHelper npoi = new NPOIHelper();
  718. if (npoi.SimpleExportToExcel(ar.data.ToJson().ToObject<DataSet>()) == "")
  719. {
  720. return Success("导出成功");
  721. }
  722. else
  723. {
  724. return Error("导出失败");
  725. }
  726. }
  727. return Content(result);
  728. }
  729. else
  730. {
  731. var obj = new
  732. {
  733. state = "error",
  734. message = "查询失败"
  735. };
  736. return Content(obj.ToJson());
  737. }
  738. }
  739. }
  740. }