地铁二期项目正式开始

ReportOtherController.cs 20KB

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