UU跑腿标准版

ZuoXiTongHua.ashx.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.SessionState;
  6. using System.Text;
  7. using System.Data;
  8. namespace HySoft.BaseCallCenter.Web.reportmanage.operationdata.controls
  9. {
  10. /// <summary>
  11. /// ZuoXiTongHua 的摘要说明
  12. /// </summary>
  13. public class ZuoXiTongHua : IHttpHandler
  14. {
  15. public void ProcessRequest(HttpContext context)
  16. {
  17. context.Response.ContentType = "text/plain";
  18. string action = context.Request.QueryString["action"];
  19. switch (action)
  20. {
  21. case "getlist":
  22. context.Response.Write(GetDataListHtml(context));//读取数据
  23. break;
  24. }
  25. }
  26. public string GetDataListHtml(HttpContext context)
  27. {
  28. StringBuilder htmlReport = new StringBuilder();//存储生成的HTML
  29. htmlReport.Append("<table cellspacing='0' cellpadding='0' border='1' width='100%'><tr height='35'>");
  30. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>坐席人员</td>");
  31. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>通话总时长(小时)</td>");
  32. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼出通话总时长(小时)</td>");
  33. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼出通话占比</td>");
  34. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼入通话总时长</td>");
  35. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>呼入通话占比</td>");
  36. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均日呼入通话时长(小时)</td>");
  37. htmlReport.Append("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>平均日呼出通话时长(小时)</td>");
  38. htmlReport.Append("</tr>");
  39. try
  40. {
  41. string txtStartTime = context.Request.QueryString["txtStartTime"];
  42. string txtEndTime = context.Request.QueryString["txtEndTime"];
  43. string sqltimeCallRecords = "";
  44. if (txtStartTime != null && txtStartTime.Trim() != "")
  45. {
  46. sqltimeCallRecords += " and CONVERT(varchar , TalkStartTime, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
  47. }
  48. if (txtEndTime != null && txtEndTime.Trim() != "")
  49. {
  50. sqltimeCallRecords += " and CONVERT(varchar , TalkStartTime, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
  51. }
  52. double zong1 = 0;
  53. double zong2 = 0;
  54. double zong3 = 0;
  55. double zong4 = 0;
  56. double zong5 = 0;
  57. double zong6 = 0;
  58. double day = 0;
  59. Double sumshuchu = 0;
  60. Double sumshuru = 0;
  61. if (txtStartTime != null && txtEndTime != null && txtEndTime.Trim() != "" && txtStartTime.Trim() != "")
  62. {
  63. TimeSpan time = Convert.ToDateTime(txtEndTime) - Convert.ToDateTime(txtStartTime);
  64. day = time.Days+1;
  65. }
  66. DataTable dt = new DataTable();
  67. string sql = "SELECT *,(SELECT sum(TalkLongTime) FROM T_Call_CallRecords where UserId=T_Sys_UserAccount.F_Userid " + sqltimeCallRecords + ") as counts from T_Sys_UserAccount where F_RoleId in(1,28,29) order by counts desc ";
  68. dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  69. for (int i = 0; i < dt.Rows.Count; i++)
  70. {
  71. sql = "SELECT (SELECT sum(TalkLongTime) FROM T_Call_CallRecords where UserId=" + dt.Rows[i]["F_UserId"].ToString() + "" + sqltimeCallRecords + ") as sums,";
  72. sql += "(SELECT sum(TalkLongTime) FROM T_Call_CallRecords where UserId=" + dt.Rows[i]["F_UserId"].ToString() + " and CallType=0" + sqltimeCallRecords + ") as sumshuru,";
  73. sql += "(SELECT sum(TalkLongTime) FROM T_Call_CallRecords where UserId=" + dt.Rows[i]["F_UserId"].ToString() + " and CallType=1" + sqltimeCallRecords + ") as sumshuchu";
  74. DataTable dt1 = new DataTable();
  75. dt1 = DBUtility.DbHelperSQL.Query(sql).Tables[0];
  76. if (dt1.Rows[0]["sums"] == null || dt1.Rows[0]["sums"].ToString() == "" || dt1.Rows[0]["sums"].ToString() == "0")
  77. {
  78. continue;
  79. }
  80. htmlReport.AppendFormat("<tr><td align='center'style='border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", dt.Rows[i]["F_UserName"].ToString());
  81. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["sums"]) / 3600).ToString("f2"));
  82. Double sums = 0;
  83. if (dt1.Rows[0]["sums"] != null && dt1.Rows[0]["sums"].ToString() != "")
  84. {
  85. zong1 += Convert.ToInt32(dt1.Rows[0]["sums"]);
  86. sums = Convert.ToInt32(dt1.Rows[0]["sums"]);
  87. }
  88. if (dt1.Rows[0]["sumshuchu"] == null || dt1.Rows[0]["sumshuchu"].ToString() == "")
  89. {
  90. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0</td>");
  91. }
  92. else
  93. {
  94. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["sumshuchu"]) / 3600).ToString("f2"));
  95. }
  96. sumshuchu = 0;
  97. if (dt1.Rows[0]["sumshuchu"] != null && dt1.Rows[0]["sumshuchu"].ToString() != "")
  98. {
  99. zong2 += Convert.ToInt32(dt1.Rows[0]["sumshuchu"]);
  100. sumshuchu = Convert.ToInt32(dt1.Rows[0]["sumshuchu"]);
  101. }
  102. if (sums == 0)
  103. {
  104. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", "0.00" + "%");
  105. }
  106. else
  107. {
  108. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (sumshuchu / sums * 100).ToString("f2") + "%");
  109. }
  110. if (dt1.Rows[0]["sumshuru"] == null || dt1.Rows[0]["sumshuru"].ToString() == "")
  111. {
  112. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>0</td>");
  113. }
  114. else
  115. {
  116. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (Convert.ToDouble(dt1.Rows[0]["sumshuru"]) / 3600).ToString("f2"));
  117. }
  118. sumshuru = 0;
  119. if (dt1.Rows[0]["sumshuru"] != null && dt1.Rows[0]["sumshuru"].ToString() != "")
  120. {
  121. zong3 += Convert.ToInt32(dt1.Rows[0]["sumshuru"]);
  122. sumshuru = Convert.ToInt32(dt1.Rows[0]["sumshuru"]);
  123. }
  124. if (sums == 0)
  125. {
  126. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", "0.00" + "%");
  127. }
  128. else
  129. {
  130. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (sumshuru / sums * 100).ToString("f2") + "%");
  131. }
  132. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (sumshuru / day/3600).ToString("f2"));
  133. htmlReport.AppendFormat("<td align='center' style=' border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px; height: 18px; padding-top: 3px; padding-bottom: 3px;'>{0}</td>", (sumshuchu / day/3600).ToString("f2"));
  134. htmlReport.Append("</tr>");
  135. }
  136. htmlReport.Append("<tr height='35'>");
  137. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", "总计");
  138. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zong1 / 3600).ToString("f2"));
  139. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zong2 / 3600).ToString("f2"));
  140. if (zong1 == 0 || zong2 == 0)
  141. {
  142. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>0.00%</td>");
  143. }
  144. else
  145. {
  146. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble(zong2 / zong1) * 100).ToString("f2") + "%");
  147. }
  148. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zong3 / 3600).ToString("f2"));
  149. if (zong1 == 0 || zong3 == 0)
  150. {
  151. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>0.00%</td>");
  152. }
  153. else
  154. {
  155. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (Convert.ToDouble(zong3 / zong1) * 100).ToString("f2") + "%");
  156. }
  157. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zong3 / day/3600).ToString("f2"));
  158. htmlReport.AppendFormat("<td style='height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; padding: 3px 3px 3px 3px; text-align: center;'>{0}</td>", (zong2/day/3600).ToString("f2"));
  159. htmlReport.Append("</tr>");
  160. htmlReport.Append("</table>");
  161. }
  162. catch { }
  163. return htmlReport.ToString();
  164. }
  165. public bool IsReusable
  166. {
  167. get
  168. {
  169. return false;
  170. }
  171. }
  172. }
  173. }