地铁二期项目正式开始

ReportOtherController.cs 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Web;
  9. using System.Web.Mvc;
  10. using System.Web.Script.Serialization;
  11. using YTSoft.BaseCallCenter.Model;
  12. using YTSoft.BaseCallCenter.MVCWeb.Commons;
  13. using YTSoft.BaseCallCenter.MVCWeb.Models;
  14. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  15. {
  16. public class ReportOtherController : BaseController
  17. {
  18. BLL.ReportBLL busReport = new BLL.ReportBLL();
  19. #region 其他指标
  20. public ActionResult GetindexView()
  21. {
  22. WorkOrderMyModel model = new WorkOrderMyModel();
  23. return View(model);
  24. }
  25. /// <summary>
  26. /// 获取工单信息
  27. /// </summary>
  28. /// <param name="page">当前页码</param>
  29. /// <param name="limit">每页数据量</param>
  30. /// <param name="sqlWhere">查询条件</param>
  31. /// <returns></returns>
  32. [ActionName("GetindexData")]
  33. [HttpGet]
  34. public string GetindexData(DateTime? NowDateTime, string dateParty)
  35. {
  36. //数据结果集
  37. ResponseData dataModel = new ResponseData();
  38. try
  39. {
  40. string startDate = "";
  41. string endDate = "";
  42. if (!string.IsNullOrEmpty(dateParty))
  43. {
  44. startDate = dateParty.Substring(0, 10);
  45. endDate = dateParty.Substring(12);
  46. }
  47. else
  48. {
  49. startDate = endDate = DateTime.Now.ToString("yyyy-MM-dd");
  50. }
  51. DataTable datas = null;
  52. DataTable newTable = new DataTable();
  53. //newTable.Columns.Add("ID");
  54. newTable.Columns.Add("指标名称");
  55. newTable.Columns.Add("指标值");
  56. DataRow dataRow;
  57. int OvertimeCount = 0;
  58. #region 接通率
  59. datas = busReport.GetOtherData1(startDate, endDate);
  60. if (datas != null && datas.Rows.Count > 0)
  61. {
  62. string data1 = "-";
  63. int tempTotal = 0;
  64. int tempint = 0;
  65. foreach (DataRow thisRow in datas.Rows)
  66. {
  67. if (thisRow["CallState"].ToInt32() == 1)
  68. {
  69. tempint = thisRow["num"].ToInt32();
  70. }
  71. tempTotal += thisRow["num"].ToInt32();
  72. }
  73. if (tempTotal != 0)
  74. {
  75. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  76. }
  77. dataRow = newTable.NewRow();
  78. dataRow["指标名称"] = "接通率";
  79. dataRow["指标值"] = data1;
  80. newTable.Rows.Add(dataRow);
  81. }
  82. #endregion
  83. #region 流失率
  84. datas = busReport.GetOtherData2(startDate, endDate);
  85. if (datas != null && datas.Rows.Count > 0)
  86. {
  87. string data1 = "-";
  88. int tempTotal = 0;
  89. int tempint = 0;
  90. foreach (DataRow thisRow in datas.Rows)
  91. {
  92. if (thisRow["CallState"].ToInt32() == 0)
  93. {
  94. tempint = thisRow["num"].ToInt32();
  95. }
  96. tempTotal += thisRow["num"].ToInt32();
  97. }
  98. if (tempTotal != 0)
  99. {
  100. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  101. }
  102. dataRow = newTable.NewRow();
  103. dataRow["指标名称"] = "流失率";
  104. dataRow["指标值"] = data1;
  105. newTable.Rows.Add(dataRow);
  106. }
  107. #endregion
  108. #region 按时转出率
  109. datas = busReport.GetOtherData3(startDate, endDate);
  110. if (datas != null && datas.Rows.Count > 0)
  111. {
  112. string data1 = "-";
  113. int tempTotal = 0;
  114. int tempint = 0;
  115. foreach (DataRow thisRow in datas.Rows)
  116. {
  117. if (thisRow["CallState"].ToInt32() == 1)
  118. {
  119. tempint = thisRow["num"].ToInt32();
  120. }
  121. tempTotal += thisRow["num"].ToInt32();
  122. }
  123. if (tempTotal != 0)
  124. {
  125. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  126. }
  127. dataRow = newTable.NewRow();
  128. dataRow["指标名称"] = "按时转出率";
  129. dataRow["指标值"] = data1;
  130. newTable.Rows.Add(dataRow);
  131. }
  132. #endregion
  133. #region 首呼解决率
  134. datas = busReport.GetOtherData10(startDate, endDate);
  135. if (datas != null && datas.Rows.Count > 0)
  136. {
  137. string data1 = "-";
  138. int tempTotal = 0;
  139. int tempint = 0;
  140. foreach (DataRow thisRow in datas.Rows)
  141. {
  142. if (thisRow["CallState"].ToInt32() == 1)
  143. {
  144. tempint = thisRow["num"].ToInt32();
  145. }
  146. tempTotal += thisRow["num"].ToInt32();
  147. }
  148. if (tempTotal != 0)
  149. {
  150. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  151. }
  152. dataRow = newTable.NewRow();
  153. dataRow["指标名称"] = "首呼解决率";
  154. dataRow["指标值"] = data1;
  155. newTable.Rows.Add(dataRow);
  156. }
  157. #endregion
  158. #region 按时办结率
  159. datas = busReport.GetOtherData4(startDate, endDate);
  160. if (datas != null && datas.Rows.Count > 0)
  161. {
  162. string data1 = "-";
  163. string data2 = "-";
  164. string data3 = "-";
  165. int tempTotal = 0;
  166. int tempint = 0;
  167. int tempTotal1 = 0;
  168. int tempint1 = 0;
  169. int tempTotal2 = 0;
  170. int tempint2 = 0;
  171. foreach (DataRow thisRow in datas.Rows)
  172. {
  173. if (thisRow["CallState"].ToInt32() == 0)
  174. {
  175. OvertimeCount += thisRow["num"].ToInt32();
  176. }
  177. if (thisRow["F_HOUSING"].ToMyString() == "咨询")
  178. {
  179. if (thisRow["CallState"].ToInt32() == 1)
  180. {
  181. tempint = thisRow["num"].ToInt32();
  182. }
  183. tempTotal += thisRow["num"].ToInt32();
  184. }
  185. else if (thisRow["F_HOUSING"].ToMyString() == "建议")
  186. {
  187. if (thisRow["CallState"].ToInt32() == 1)
  188. {
  189. tempint1 = thisRow["num"].ToInt32();
  190. }
  191. tempTotal1 += thisRow["num"].ToInt32();
  192. }
  193. else if (thisRow["F_HOUSING"].ToMyString() == "投诉")
  194. {
  195. if (thisRow["CallState"].ToInt32() == 1)
  196. {
  197. tempint2 = thisRow["num"].ToInt32();
  198. }
  199. tempTotal2 += thisRow["num"].ToInt32();
  200. }
  201. }
  202. if (tempTotal != 0)
  203. {
  204. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  205. }
  206. if (tempTotal1 != 0)
  207. {
  208. data2 = (tempint1 / (double)tempTotal1).ToString("0.00%");
  209. }
  210. if (tempTotal2 != 0)
  211. {
  212. data3 = (tempint2 / (double)tempTotal2).ToString("0.00%");
  213. }
  214. dataRow = newTable.NewRow();
  215. dataRow["指标名称"] = "咨询按时办结率";
  216. dataRow["指标值"] = data1;
  217. newTable.Rows.Add(dataRow);
  218. dataRow = newTable.NewRow();
  219. dataRow["指标名称"] = "建议按时办结率";
  220. dataRow["指标值"] = data2;
  221. newTable.Rows.Add(dataRow);
  222. dataRow = newTable.NewRow();
  223. dataRow["指标名称"] = "投诉按时办结率";
  224. dataRow["指标值"] = data3;
  225. newTable.Rows.Add(dataRow);
  226. }
  227. #endregion
  228. #region 按时答复率
  229. datas = busReport.GetOtherData5(startDate, endDate);
  230. if (datas != null && datas.Rows.Count > 0)
  231. {
  232. string data1 = "-";
  233. int tempTotal = 0;
  234. int tempint = 0;
  235. foreach (DataRow thisRow in datas.Rows)
  236. {
  237. if (thisRow["CallState"].ToInt32() == 1)
  238. {
  239. tempint = thisRow["num"].ToInt32();
  240. }
  241. tempTotal += thisRow["num"].ToInt32();
  242. }
  243. if (tempTotal != 0)
  244. {
  245. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  246. }
  247. dataRow = newTable.NewRow();
  248. dataRow["指标名称"] = "按时答复率";
  249. dataRow["指标值"] = data1;
  250. newTable.Rows.Add(dataRow);
  251. }
  252. #endregion
  253. #region 超时工单数
  254. dataRow = newTable.NewRow();
  255. dataRow["指标名称"] = "超时工单数";
  256. dataRow["指标值"] = OvertimeCount;
  257. newTable.Rows.Add(dataRow);
  258. #endregion
  259. #region 定责指标
  260. datas = busReport.GetOtherData6(startDate, endDate);
  261. if (true)
  262. {
  263. string data1 = "-";
  264. string data2 = "-";
  265. string data3 = "-";
  266. string data4 = "-";
  267. int tempTotal1 = 0;
  268. int tempint1 = 0;
  269. int tempTotal2 = 0;
  270. int tempint2 = 0;
  271. int tempTotal3 = 0;
  272. int tempint3 = 0;
  273. int tempTotal4 = 0;
  274. int tempint4 = 0;
  275. if (datas != null && datas.Rows.Count > 0)
  276. {
  277. foreach (DataRow thisRow in datas.Rows)
  278. {
  279. // 根据事件概况,初步定性为无效投诉
  280. // 根据事件概况,初步定性为有效无责投诉
  281. // 根据事件概况,初步定性为一级有责投诉
  282. // 根据事件概况,初步定性为二级有责投诉
  283. // 根据事件概况,初步定性为三级有责投诉
  284. if (thisRow["DealResult"].ToMyString().Contains("无效投诉"))
  285. {
  286. tempint1 += thisRow["num"].ToInt32();
  287. tempTotal1 += thisRow["num"].ToInt32();
  288. }
  289. else if (thisRow["DealResult"].ToMyString().Contains("责投诉"))
  290. {
  291. tempint2 += thisRow["num"].ToInt32();
  292. tempTotal1 += thisRow["num"].ToInt32();
  293. }
  294. if (thisRow["DealResult"].ToMyString().Contains("有责投诉"))
  295. {
  296. tempint3 += thisRow["num"].ToInt32();
  297. }
  298. else if (thisRow["DealResult"].ToMyString().Contains("有效无责投诉"))
  299. {
  300. tempint4 += thisRow["num"].ToInt32();
  301. }
  302. }
  303. }
  304. if (tempTotal1 != 0)
  305. {
  306. data1 = (tempint1 / (double)tempTotal1).ToString("0.00%");
  307. data2 = (tempint2 / (double)tempTotal1).ToString("0.00%");
  308. data3 = (tempint3 / (double)tempTotal1).ToString("0.00%");
  309. data4 = (tempint4 / (double)tempTotal1).ToString("0.00%");
  310. }
  311. #region 指标赋值
  312. dataRow = newTable.NewRow();
  313. dataRow["指标名称"] = "无效投诉数量";
  314. dataRow["指标值"] = tempint1;
  315. newTable.Rows.Add(dataRow);
  316. dataRow = newTable.NewRow();
  317. dataRow["指标名称"] = "无效投诉占比";
  318. dataRow["指标值"] = data1;
  319. newTable.Rows.Add(dataRow);
  320. dataRow = newTable.NewRow();
  321. dataRow["指标名称"] = "有效投诉数量";
  322. dataRow["指标值"] = tempint2;
  323. newTable.Rows.Add(dataRow);
  324. dataRow = newTable.NewRow();
  325. dataRow["指标名称"] = "有效投诉占比";
  326. dataRow["指标值"] = data2;
  327. newTable.Rows.Add(dataRow);
  328. dataRow = newTable.NewRow();
  329. dataRow["指标名称"] = "有责投诉数量";
  330. dataRow["指标值"] = tempint3;
  331. newTable.Rows.Add(dataRow);
  332. dataRow = newTable.NewRow();
  333. dataRow["指标名称"] = "有责投诉占比";
  334. dataRow["指标值"] = data3;
  335. newTable.Rows.Add(dataRow);
  336. dataRow = newTable.NewRow();
  337. dataRow["指标名称"] = "有效无责数量";
  338. dataRow["指标值"] = tempint4;
  339. newTable.Rows.Add(dataRow);
  340. dataRow = newTable.NewRow();
  341. dataRow["指标名称"] = "有效无责占比";
  342. dataRow["指标值"] = data4;
  343. newTable.Rows.Add(dataRow);
  344. #endregion
  345. }
  346. #endregion
  347. dataModel.code = 0;
  348. dataModel.data = newTable;
  349. }
  350. catch (Exception ex)
  351. {
  352. dataModel.code = 200;
  353. dataModel.msg = ex.Message;
  354. }
  355. return JsonConvert.SerializeObject(dataModel);
  356. }
  357. #endregion
  358. #region 定责指标
  359. public ActionResult GetDZView()
  360. {
  361. WorkOrderMyModel model = new WorkOrderMyModel();
  362. return View(model);
  363. }
  364. /// <summary>
  365. /// 获取工单信息
  366. /// </summary>
  367. /// <param name="page">当前页码</param>
  368. /// <param name="limit">每页数据量</param>
  369. /// <param name="sqlWhere">查询条件</param>
  370. /// <returns></returns>
  371. [ActionName("GetDZData")]
  372. [HttpGet]
  373. public string GetDZData(DateTime? NowDateTime, string dateParty)
  374. {
  375. //数据结果集
  376. ResponseData dataModel = new ResponseData();
  377. try
  378. {
  379. string startDate = "";
  380. string endDate = "";
  381. if (!string.IsNullOrEmpty(dateParty))
  382. {
  383. startDate = dateParty.Substring(0, 10);
  384. endDate = dateParty.Substring(12);
  385. }
  386. else
  387. {
  388. startDate = endDate = DateTime.Now.ToString("yyyy-MM-dd");
  389. }
  390. DataTable newTable = new DataTable();
  391. newTable.Columns.Add("一级分类");
  392. newTable.Columns.Add("一级数量");
  393. newTable.Columns.Add("一级占比");
  394. newTable.Columns.Add("二级分类");
  395. newTable.Columns.Add("二级数量");
  396. newTable.Columns.Add("二级占比");
  397. newTable.Columns.Add("三级分类");
  398. newTable.Columns.Add("三级数量");
  399. newTable.Columns.Add("三级占比");
  400. DataRow dataRow;
  401. #region 统计
  402. DataTable datas7 = busReport.GetOtherData7(startDate, endDate);
  403. DataTable datas8 = busReport.GetOtherData8(startDate, endDate);
  404. DataTable datas9 = busReport.GetOtherData9(startDate, endDate);
  405. int totle7 = 0;
  406. int totle8 = 0;
  407. int totle9 = 0;
  408. #region 计算总数 百分比
  409. if (datas7 != null && datas7.Rows.Count > 0)
  410. {
  411. foreach (DataRow dr in datas7.Rows)
  412. {
  413. totle7 += dr["num"].ToInt32();
  414. }
  415. }
  416. if (datas8 != null && datas8.Rows.Count > 0)
  417. {
  418. foreach (DataRow dr in datas8.Rows)
  419. {
  420. totle8 += dr["num"].ToInt32();
  421. }
  422. }
  423. if (datas9 != null && datas9.Rows.Count > 0)
  424. {
  425. foreach (DataRow dr in datas9.Rows)
  426. {
  427. totle9 += dr["num"].ToInt32();
  428. }
  429. }
  430. #endregion
  431. for (int i = 0; i < 10; i++)
  432. {
  433. dataRow = newTable.NewRow();
  434. #region 一级分类
  435. if (totle7 > 0&&datas7.Rows.Count>i)
  436. {
  437. dataRow["一级分类"] = datas7.Rows[i]["name"];
  438. int tempn = datas7.Rows[i]["num"].ToInt32();
  439. dataRow["一级数量"] = tempn;
  440. dataRow["一级占比"] = (tempn/ (double)totle7).ToString("0.00%");
  441. }
  442. else
  443. {
  444. dataRow["一级分类"] = "-";
  445. dataRow["一级数量"] = "-";
  446. dataRow["一级占比"] = "-";
  447. }
  448. #endregion
  449. #region 二级分类
  450. if (totle8 > 0 && datas8.Rows.Count > i)
  451. {
  452. dataRow["二级分类"] = datas8.Rows[i]["name"];
  453. int tempn = datas8.Rows[i]["num"].ToInt32();
  454. dataRow["二级数量"] = tempn;
  455. dataRow["二级占比"] = (tempn / (double)totle8).ToString("0.00%");
  456. }
  457. else
  458. {
  459. dataRow["二级分类"] = "-";
  460. dataRow["二级数量"] = "-";
  461. dataRow["二级占比"] = "-";
  462. }
  463. #endregion
  464. #region 三级分类
  465. if (totle9 > 0 && datas9.Rows.Count > i)
  466. {
  467. dataRow["三级分类"] = datas9.Rows[i]["name"];
  468. int tempn = datas9.Rows[i]["num"].ToInt32();
  469. dataRow["三级数量"] = tempn;
  470. dataRow["三级占比"] = (tempn / (double)totle9).ToString("0.00%");
  471. }
  472. else
  473. {
  474. dataRow["三级分类"] = "-";
  475. dataRow["三级数量"] = "-";
  476. dataRow["三级占比"] = "-";
  477. }
  478. #endregion
  479. newTable.Rows.Add(dataRow);
  480. }
  481. #endregion
  482. dataModel.code = 0;
  483. dataModel.data = newTable;
  484. }
  485. catch (Exception ex)
  486. {
  487. dataModel.code = 200;
  488. dataModel.msg = ex.Message;
  489. }
  490. return JsonConvert.SerializeObject(dataModel);
  491. }
  492. #endregion
  493. }
  494. }