地铁二期项目正式开始

ReportOtherController.cs 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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 = "100.00%";
  138. string data2 = "-";
  139. string data3 = "-";
  140. int tempTotal = 0;
  141. int tempint = 0;
  142. int tempTotal1 = 0;
  143. int tempint1 = 0;
  144. int tempTotal2 = 0;
  145. int tempint2 = 0;
  146. foreach (DataRow thisRow in datas.Rows)
  147. {
  148. //if (thisRow["F_HOUSING"].ToMyString() == "咨询")
  149. //{
  150. // if (thisRow["CallState"].ToInt32() == 1)
  151. // {
  152. // tempint = thisRow["num"].ToInt32();
  153. // }
  154. // tempTotal += thisRow["num"].ToInt32();
  155. //}
  156. if (thisRow["F_HOUSING"].ToMyString() == "建议")
  157. {
  158. if (thisRow["CallState"].ToInt32() == 1)
  159. {
  160. tempint1 = thisRow["num"].ToInt32();
  161. }
  162. tempTotal1 += thisRow["num"].ToInt32();
  163. }
  164. if (thisRow["F_HOUSING"].ToMyString() == "投诉")
  165. {
  166. if (thisRow["CallState"].ToInt32() == 1)
  167. {
  168. tempint2 = thisRow["num"].ToInt32();
  169. }
  170. tempTotal2 += thisRow["num"].ToInt32();
  171. }
  172. }
  173. //if (tempTotal != 0)
  174. //{
  175. // data1 = (tempint / (double)tempTotal).ToString("0.00%");
  176. //}
  177. if (tempTotal1 != 0)
  178. {
  179. data2 = (tempint1 / (double)tempTotal1).ToString("0.00%");
  180. }
  181. if (tempTotal2 != 0)
  182. {
  183. data3 = (tempint2 / (double)tempTotal2).ToString("0.00%");
  184. }
  185. dataRow = newTable.NewRow();
  186. dataRow["指标名称"] = "咨询首呼解决率";
  187. dataRow["指标值"] = data1;
  188. newTable.Rows.Add(dataRow);
  189. dataRow = newTable.NewRow();
  190. dataRow["指标名称"] = "建议首呼解决率";
  191. dataRow["指标值"] = data2;
  192. newTable.Rows.Add(dataRow);
  193. dataRow = newTable.NewRow();
  194. dataRow["指标名称"] = "投诉首呼解决率";
  195. dataRow["指标值"] = data3;
  196. newTable.Rows.Add(dataRow);
  197. }
  198. #endregion
  199. #region 按时办结率
  200. datas = busReport.GetOtherData4(startDate, endDate);
  201. if (datas != null && datas.Rows.Count > 0)
  202. {
  203. string data1 = "-";
  204. string data2 = "-";
  205. string data3 = "-";
  206. int tempTotal = 0;
  207. int tempint = 0;
  208. int tempTotal1 = 0;
  209. int tempint1 = 0;
  210. int tempTotal2 = 0;
  211. int tempint2 = 0;
  212. foreach (DataRow thisRow in datas.Rows)
  213. {
  214. if (thisRow["CallState"].ToInt32() == 0)
  215. {
  216. OvertimeCount += thisRow["num"].ToInt32();
  217. }
  218. if (thisRow["F_HOUSING"].ToMyString() == "咨询")
  219. {
  220. if (thisRow["CallState"].ToInt32() == 1)
  221. {
  222. tempint = thisRow["num"].ToInt32();
  223. }
  224. tempTotal += thisRow["num"].ToInt32();
  225. }
  226. if (thisRow["F_HOUSING"].ToMyString() == "建议")
  227. {
  228. if (thisRow["CallState"].ToInt32() == 1)
  229. {
  230. tempint1 = thisRow["num"].ToInt32();
  231. }
  232. tempTotal1 += thisRow["num"].ToInt32();
  233. }
  234. if (thisRow["F_HOUSING"].ToMyString() == "投诉")
  235. {
  236. if (thisRow["CallState"].ToInt32() == 1)
  237. {
  238. tempint2 = thisRow["num"].ToInt32();
  239. }
  240. tempTotal2 += thisRow["num"].ToInt32();
  241. }
  242. }
  243. if (tempTotal != 0)
  244. {
  245. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  246. }
  247. if (tempTotal1 != 0)
  248. {
  249. data2 = (tempint1 / (double)tempTotal1).ToString("0.00%");
  250. }
  251. if (tempTotal2 != 0)
  252. {
  253. data3 = (tempint2 / (double)tempTotal2).ToString("0.00%");
  254. }
  255. dataRow = newTable.NewRow();
  256. dataRow["指标名称"] = "咨询按时办结率";
  257. dataRow["指标值"] = data1;
  258. newTable.Rows.Add(dataRow);
  259. dataRow = newTable.NewRow();
  260. dataRow["指标名称"] = "建议按时办结率";
  261. dataRow["指标值"] = data2;
  262. newTable.Rows.Add(dataRow);
  263. dataRow = newTable.NewRow();
  264. dataRow["指标名称"] = "投诉按时办结率";
  265. dataRow["指标值"] = data3;
  266. newTable.Rows.Add(dataRow);
  267. }
  268. #endregion
  269. #region 按时答复率
  270. datas = busReport.GetOtherData5(startDate, endDate);
  271. if (datas != null && datas.Rows.Count > 0)
  272. {
  273. string data1 = "-";
  274. int tempTotal = 0;
  275. int tempint = 0;
  276. foreach (DataRow thisRow in datas.Rows)
  277. {
  278. if (thisRow["CallState"].ToInt32() == 1)
  279. {
  280. tempint = thisRow["num"].ToInt32();
  281. }
  282. tempTotal += thisRow["num"].ToInt32();
  283. }
  284. if (tempTotal != 0)
  285. {
  286. data1 = (tempint / (double)tempTotal).ToString("0.00%");
  287. }
  288. dataRow = newTable.NewRow();
  289. dataRow["指标名称"] = "按时答复率";
  290. dataRow["指标值"] = data1;
  291. newTable.Rows.Add(dataRow);
  292. }
  293. #endregion
  294. #region 超时工单数
  295. dataRow = newTable.NewRow();
  296. dataRow["指标名称"] = "超时工单数";
  297. dataRow["指标值"] = OvertimeCount;
  298. newTable.Rows.Add(dataRow);
  299. #endregion
  300. #region 定责指标
  301. datas = busReport.GetOtherData6(startDate, endDate);
  302. if (true)
  303. {
  304. string data1 = "-";
  305. string data2 = "-";
  306. string data3 = "-";
  307. string data4 = "-";
  308. int tempTotal1 = 0;
  309. int tempint1 = 0;
  310. int tempTotal2 = 0;
  311. int tempint2 = 0;
  312. int tempTotal3 = 0;
  313. int tempint3 = 0;
  314. int tempTotal4 = 0;
  315. int tempint4 = 0;
  316. if (datas != null && datas.Rows.Count > 0)
  317. {
  318. foreach (DataRow thisRow in datas.Rows)
  319. {
  320. // 根据事件概况,初步定性为无效投诉
  321. // 根据事件概况,初步定性为有效无责投诉
  322. // 根据事件概况,初步定性为一级有责投诉
  323. // 根据事件概况,初步定性为二级有责投诉
  324. // 根据事件概况,初步定性为三级有责投诉
  325. if (thisRow["F_SERVICENATURE"].ToMyString().Contains("无效投诉"))
  326. {
  327. tempint1 += thisRow["num"].ToInt32();
  328. tempTotal1 += thisRow["num"].ToInt32();
  329. }
  330. else if (thisRow["F_SERVICENATURE"].ToMyString().Contains("责投诉"))
  331. {
  332. tempint2 += thisRow["num"].ToInt32();
  333. tempTotal1 += thisRow["num"].ToInt32();
  334. }
  335. if (thisRow["F_SERVICENATURE"].ToMyString().Contains("有责投诉"))
  336. {
  337. tempint3 += thisRow["num"].ToInt32();
  338. }
  339. else if (thisRow["F_SERVICENATURE"].ToMyString().Contains("有效无责投诉"))
  340. {
  341. tempint4 += thisRow["num"].ToInt32();
  342. }
  343. }
  344. }
  345. if (tempTotal1 != 0)
  346. {
  347. data1 = (tempint1 / (double)tempTotal1).ToString("0.00%");
  348. data2 = (tempint2 / (double)tempTotal1).ToString("0.00%");
  349. data3 = (tempint3 / (double)tempTotal1).ToString("0.00%");
  350. data4 = (tempint4 / (double)tempTotal1).ToString("0.00%");
  351. }
  352. #region 指标赋值
  353. dataRow = newTable.NewRow();
  354. dataRow["指标名称"] = "无效投诉数量";
  355. dataRow["指标值"] = tempint1;
  356. newTable.Rows.Add(dataRow);
  357. dataRow = newTable.NewRow();
  358. dataRow["指标名称"] = "无效投诉占比";
  359. dataRow["指标值"] = data1;
  360. newTable.Rows.Add(dataRow);
  361. dataRow = newTable.NewRow();
  362. dataRow["指标名称"] = "有效投诉数量";
  363. dataRow["指标值"] = tempint2;
  364. newTable.Rows.Add(dataRow);
  365. dataRow = newTable.NewRow();
  366. dataRow["指标名称"] = "有效投诉占比";
  367. dataRow["指标值"] = data2;
  368. newTable.Rows.Add(dataRow);
  369. dataRow = newTable.NewRow();
  370. dataRow["指标名称"] = "有责投诉数量";
  371. dataRow["指标值"] = tempint3;
  372. newTable.Rows.Add(dataRow);
  373. dataRow = newTable.NewRow();
  374. dataRow["指标名称"] = "有责投诉占比";
  375. dataRow["指标值"] = data3;
  376. newTable.Rows.Add(dataRow);
  377. dataRow = newTable.NewRow();
  378. dataRow["指标名称"] = "有效无责数量";
  379. dataRow["指标值"] = tempint4;
  380. newTable.Rows.Add(dataRow);
  381. dataRow = newTable.NewRow();
  382. dataRow["指标名称"] = "有效无责占比";
  383. dataRow["指标值"] = data4;
  384. newTable.Rows.Add(dataRow);
  385. #endregion
  386. }
  387. #endregion
  388. dataModel.code = 0;
  389. dataModel.data = newTable;
  390. }
  391. catch (Exception ex)
  392. {
  393. dataModel.code = 200;
  394. dataModel.msg = ex.Message;
  395. }
  396. return JsonConvert.SerializeObject(dataModel);
  397. }
  398. #endregion
  399. #region 定责指标
  400. public ActionResult GetDZView()
  401. {
  402. WorkOrderMyModel model = new WorkOrderMyModel();
  403. return View(model);
  404. }
  405. /// <summary>
  406. /// 获取工单信息
  407. /// </summary>
  408. /// <param name="page">当前页码</param>
  409. /// <param name="limit">每页数据量</param>
  410. /// <param name="sqlWhere">查询条件</param>
  411. /// <returns></returns>
  412. [ActionName("GetDZData")]
  413. [HttpGet]
  414. public string GetDZData(DateTime? NowDateTime, string dateParty)
  415. {
  416. //数据结果集
  417. ResponseData dataModel = new ResponseData();
  418. try
  419. {
  420. string startDate = "";
  421. string endDate = "";
  422. if (!string.IsNullOrEmpty(dateParty))
  423. {
  424. startDate = dateParty.Substring(0, 10);
  425. endDate = dateParty.Substring(12);
  426. }
  427. else
  428. {
  429. startDate = endDate = DateTime.Now.ToString("yyyy-MM-dd");
  430. }
  431. DataTable newTable = new DataTable();
  432. newTable.Columns.Add("一级分类");
  433. newTable.Columns.Add("一级数量");
  434. newTable.Columns.Add("一级占比");
  435. newTable.Columns.Add("二级分类");
  436. newTable.Columns.Add("二级数量");
  437. newTable.Columns.Add("二级占比");
  438. newTable.Columns.Add("三级分类");
  439. newTable.Columns.Add("三级数量");
  440. newTable.Columns.Add("三级占比");
  441. DataRow dataRow;
  442. #region 统计
  443. DataTable datas7 = busReport.GetOtherData7(startDate, endDate);
  444. DataTable datas8 = busReport.GetOtherData8(startDate, endDate);
  445. DataTable datas9 = busReport.GetOtherData9(startDate, endDate);
  446. int totle7 = 0;
  447. int totle8 = 0;
  448. int totle9 = 0;
  449. #region 计算总数 百分比
  450. if (datas7 != null && datas7.Rows.Count > 0)
  451. {
  452. foreach (DataRow dr in datas7.Rows)
  453. {
  454. totle7 += dr["num"].ToInt32();
  455. }
  456. }
  457. if (datas8 != null && datas8.Rows.Count > 0)
  458. {
  459. foreach (DataRow dr in datas8.Rows)
  460. {
  461. totle8 += dr["num"].ToInt32();
  462. }
  463. }
  464. if (datas9 != null && datas9.Rows.Count > 0)
  465. {
  466. foreach (DataRow dr in datas9.Rows)
  467. {
  468. totle9 += dr["num"].ToInt32();
  469. }
  470. }
  471. #endregion
  472. for (int i = 0; i < 10; i++)
  473. {
  474. dataRow = newTable.NewRow();
  475. #region 一级分类
  476. if (totle7 > 0&&datas7.Rows.Count>i)
  477. {
  478. dataRow["一级分类"] = datas7.Rows[i]["name"];
  479. int tempn = datas7.Rows[i]["num"].ToInt32();
  480. dataRow["一级数量"] = tempn;
  481. dataRow["一级占比"] = (tempn/ (double)totle7).ToString("0.00%");
  482. }
  483. else
  484. {
  485. dataRow["一级分类"] = "-";
  486. dataRow["一级数量"] = "-";
  487. dataRow["一级占比"] = "-";
  488. }
  489. #endregion
  490. #region 二级分类
  491. if (totle8 > 0 && datas8.Rows.Count > i)
  492. {
  493. dataRow["二级分类"] = datas8.Rows[i]["name"];
  494. int tempn = datas8.Rows[i]["num"].ToInt32();
  495. dataRow["二级数量"] = tempn;
  496. dataRow["二级占比"] = (tempn / (double)totle8).ToString("0.00%");
  497. }
  498. else
  499. {
  500. dataRow["二级分类"] = "-";
  501. dataRow["二级数量"] = "-";
  502. dataRow["二级占比"] = "-";
  503. }
  504. #endregion
  505. #region 三级分类
  506. if (totle9 > 0 && datas9.Rows.Count > i)
  507. {
  508. dataRow["三级分类"] = datas9.Rows[i]["name"];
  509. int tempn = datas9.Rows[i]["num"].ToInt32();
  510. dataRow["三级数量"] = tempn;
  511. dataRow["三级占比"] = (tempn / (double)totle9).ToString("0.00%");
  512. }
  513. else
  514. {
  515. dataRow["三级分类"] = "-";
  516. dataRow["三级数量"] = "-";
  517. dataRow["三级占比"] = "-";
  518. }
  519. #endregion
  520. newTable.Rows.Add(dataRow);
  521. }
  522. #endregion
  523. dataModel.code = 0;
  524. dataModel.data = newTable;
  525. }
  526. catch (Exception ex)
  527. {
  528. dataModel.code = 200;
  529. dataModel.msg = ex.Message;
  530. }
  531. return JsonConvert.SerializeObject(dataModel);
  532. }
  533. #endregion
  534. }
  535. }