No Description

TelDeal_Report.aspx.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Text;
  9. using XYFDRQ.DBUtility;
  10. public partial class Report_TelDeal_Report : System.Web.UI.Page
  11. {
  12. XYFDRQ.BLL.T_Report bll_T_Report = new XYFDRQ.BLL.T_Report();
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. if (!this.IsPostBack)
  16. {
  17. txtBeginDate.Value = DateTime.Now.ToString("yyyy-MM-01");//赋初值
  18. txtEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");//赋初值
  19. }
  20. AjaxPro.Utility.RegisterTypeForAjax(typeof(Report_TelDeal_Report));
  21. }
  22. /// <summary>
  23. /// 导出Excel
  24. /// </summary>
  25. /// <param name="sender"></param>
  26. /// <param name="e"></param>
  27. protected void btnExtWord_Click(object sender, EventArgs e)
  28. {
  29. byte[] content = System.Text.Encoding.Default.GetBytes(txtHideItems.Value);//将string转为二进制字节数组
  30. HttpResponse clsreponse = System.Web.HttpContext.Current.Response;
  31. clsreponse.ClearHeaders();
  32. clsreponse.ClearContent();
  33. clsreponse.AddHeader("Content-Disposition", "attachment;filename=TZSJFX" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");//xls
  34. clsreponse.ContentType ="application/msexcel";//设置流的输出格式
  35. clsreponse.OutputStream.Write(content, 0, content.Length);//输出
  36. clsreponse.End();
  37. #region MyRegion
  38. //HttpResponse resp = Page.Response;
  39. //resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
  40. ////下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
  41. ////filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm
  42. //resp.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
  43. ////Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
  44. //resp.ContentType = "application/ms-excel";
  45. ////向http输出流中写入取得的数据信息
  46. //resp.Write(txtHideItems.Value);
  47. ////处理行数据
  48. //resp.End();
  49. #endregion
  50. }
  51. /// <summary>
  52. /// 导出的Excel表
  53. /// </summary>
  54. /// <param name="searchItems"></param>
  55. /// <returns></returns>
  56. [AjaxPro.AjaxMethod()]
  57. public string GetReportTable(AjaxPro.JavaScriptArray searchItems)
  58. {
  59. StringBuilder html = new StringBuilder();
  60. string reportsql = "";
  61. DataTable dt = new DataTable();
  62. string[] _operations = GetSearchItems(searchItems);
  63. html.Append("<h1 style='font-size: 18px;font-weight: bold;color: #333333;text-align:center;width:100%;'><b>来电方式统计表</b></h1>");
  64. //处理方式0:IVR处理1骚扰电话2自助服务3转值班电话4留言5呼损6人工处理
  65. string dealType = "全部";
  66. switch (_operations[2])
  67. {
  68. case "0":
  69. dealType = "IVR处理";
  70. break;
  71. case "1":
  72. dealType = "骚扰电话";
  73. break;
  74. case "2":
  75. dealType = "自助服务";
  76. break;
  77. case "3":
  78. dealType = "转值班电话";
  79. break;
  80. case "4":
  81. dealType = "留言";
  82. break;
  83. case "5":
  84. dealType = "呼损";
  85. break;
  86. case "6":
  87. dealType = "人工处理";
  88. break;
  89. }
  90. html.Append("<div style='width:100%; text-align:right; height:25px;'>处理方式: " + dealType + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
  91. html.Append("<div style='width:100%; text-align:right;height:25px;'>统计截止日期: " + _operations[0] + "—" + _operations[1] + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>");
  92. html.Append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" >");
  93. try
  94. {
  95. //开始时间
  96. if (!string.IsNullOrEmpty(_operations[0]))
  97. {
  98. reportsql += " and DATEDIFF(d,BeginTime,'" + _operations[0] + "')<=0";
  99. }
  100. //结束时间
  101. if (!string.IsNullOrEmpty(_operations[1]))
  102. {
  103. reportsql += " and DATEDIFF(d,BeginTime,'" + _operations[1] + "')>=0";
  104. }
  105. if (!string.IsNullOrEmpty(_operations[2]))
  106. {
  107. if (_operations[2] != "全部")
  108. {
  109. reportsql += " and DealType="+Convert.ToInt32(_operations[2]);
  110. }
  111. }
  112. dt = bll_T_Report.GetCallInTypeReport(reportsql);
  113. //标题第一行
  114. html.Append("<tr style=\"text-align: center;\">");
  115. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;width:150px\">时间</td>");
  116. html.Append("<td class=\"formtabletitle1\"style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 1px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">电话量</td>");
  117. html.Append("</tr>");
  118. //int cateCount = 0;
  119. int allCount = 0;
  120. if (dt != null && dt.Rows.Count > 0)
  121. {
  122. for (int i = 0; i < dt.Rows.Count; i++)
  123. {
  124. html.Append("<tr align=\"center\" valign=\"middle\" onmouseover=\"this.style.backgroundColor='#F6F6F6'\" onmouseout=\"this.style.backgroundColor='#ffffff'\" bgcolor=\"#ffffff\">");
  125. //时间
  126. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["hrhour"].ToString() + "&nbsp;</td>");
  127. //电话量
  128. html.Append("<td class=\"formtable_td\" style=\"vertical-align: middle;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;padding-left: 2px;height: 25px;padding-top: 3px;padding-bottom: 3px;\">" + dt.Rows[i]["hrCount"].ToString() + "&nbsp;</td>");
  129. html.Append("</tr>");
  130. allCount += Convert.ToInt32(dt.Rows[i]["hrCount"]);//合计
  131. }
  132. }
  133. html.Append("<tr style=\"text-align: center;\"><td colspan=\"1\" class=\"formtabletitle3\" style=\"height: 35px;background-color: #D5EDFE;border-left: 1px solid #CCCCCC;border-right: 1px solid #CCCCCC;border-top: 0px solid #CCCCCC;border-bottom: 1px solid #CCCCCC;padding: 3px 10px 3px 2px;text-align:center;\">总计:</td>");
  134. html.Append("<td class=\"formtabletitle2\" style=\"height: 25px;background-color: #D5EDFE;border-left: 0px solid #FFFFFF;border-right: 1px solid #CCCCCC;border-top: 0px solid #FFFFFF;border-bottom: 1px solid #CCCCCC;padding: 3px 3px 3px 3px;text-align:center;\">" + allCount + "&nbsp;</td>");
  135. html.Append("</tr>");
  136. }
  137. catch
  138. { }
  139. finally
  140. {
  141. dt.Clear();
  142. dt.Dispose();
  143. }
  144. html.Append("</table>");
  145. return html.ToString();
  146. }
  147. /// <summary>
  148. /// 报表线状图
  149. /// </summary>
  150. /// <param name="searchItems"></param>
  151. /// <returns></returns>
  152. [AjaxPro.AjaxMethod()]
  153. public string GetReportLines(AjaxPro.JavaScriptArray searchItems)
  154. {
  155. //呼叫类型,0呼入
  156. string[] _operations = GetSearchItems(searchItems);
  157. string startTime = "";
  158. string endTime = "";
  159. int intType = 0;
  160. //开始时间
  161. if (!string.IsNullOrEmpty(_operations[0]))
  162. {
  163. startTime = _operations[0];
  164. }
  165. //结束时间
  166. if (!string.IsNullOrEmpty(_operations[1]))
  167. {
  168. endTime = _operations[1];
  169. }
  170. if (!string.IsNullOrEmpty(_operations[2]))
  171. {
  172. if (_operations[2]!="全部")
  173. {
  174. intType = Convert.ToInt32(_operations[2]);
  175. }
  176. else
  177. {
  178. intType = 7;
  179. }
  180. }
  181. StringBuilder sbStrHR = new StringBuilder();
  182. sbStrHR.Append("select DATEPART(HOUR,BeginTime) as hrhour,COUNT(CallId) as hrCount from T_Call_CallRecords where CallType=0");
  183. if (intType!=7)
  184. {
  185. //为全部
  186. sbStrHR.Append(" and DealType=" + intType);
  187. }
  188. sbStrHR.Append(" and DATEDIFF(d,BeginTime,'" + startTime + "')<=0 and DATEDIFF(d,BeginTime,'"+endTime+"')>=0 group by DATEPART(HOUR,BeginTime)");
  189. DataTable dtHr = DbHelperSQL.Query(sbStrHR.ToString()).Tables[0];
  190. StringBuilder sb = new StringBuilder();//整个的,题头+sb1+sb2+sb3
  191. StringBuilder sb1 = new StringBuilder();//横坐标显示的内容
  192. StringBuilder sb2 = new StringBuilder();//纵坐标显示的值1
  193. sb.Append("<graph xaxisname=\"时\" yaxisname=\"电话量\" hovercapbg=\"DEDEBE\" hovercapborder=\"889E6D\" rotateNames=\"0\" numdivlines=\"4\" divLineColor=\"CCCCCC\" divLineAlpha=\"80\" decimalPrecision=\"0\" showAlternateHGridColor=\"1\" AlternateHGridAlpha=\"30\" AlternateHGridColor=\"CCCCCC\" caption=\"\" subcaption=\"来电方式统计\" outCnvBaseFontSize='13' baseFontSize='13'>");
  194. sb1.Append("<categories font=\"宋体, Arial, Helvetica, sans-serif\" fontSize=\"12\" fontColor=\"000000\" >");
  195. sb2.Append("<dataset seriesname=\"电话量\" color=\"FDC12E\" >");
  196. for (int i = 0; i < 24; i++)
  197. {
  198. sb1.Append("<category name=\"" + i + "\" hoverText=\"" + i + "\" />");
  199. DataRow[] drhr = dtHr.Select("hrhour=" + i);
  200. if (drhr.Length != 0)
  201. {
  202. sb2.Append("<set value=\"" + drhr[0]["hrCount"] + "\" />");
  203. }
  204. else
  205. {
  206. sb2.Append("<set value=\"0\" />");
  207. }
  208. }
  209. sb.Append(sb1.ToString() + "</categories>" + sb2.ToString() + "</dataset></graph>");
  210. StringBuilder sbAll = new StringBuilder();
  211. int StrWidth =700;
  212. int StrHeight = 390;
  213. sbAll.Append("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
  214. sbAll.Append("width=\"" + StrWidth + "\" height=\"" + StrHeight + "\" id=\"FCF_MSLine\">");
  215. sbAll.Append("<param name=\"FlashVars\" value=\"&dataXML=" + System.Web.HttpUtility.UrlEncode(sb.ToString(), System.Text.Encoding.UTF8) + "\" />");
  216. sbAll.Append("<param name=\"movie\" value=\"ChartsFlash/FCF_MSLine.swf?chartWidth=" + StrWidth + "&chartHeight=" + StrHeight + "\" /></object>");
  217. return sbAll.ToString();
  218. }
  219. private string[] GetSearchItems(AjaxPro.JavaScriptArray searchItems)
  220. {
  221. string[] operations = new string[searchItems.Count];
  222. int i = 0;
  223. foreach (Object obj in searchItems)
  224. {
  225. operations[i] = obj.ToString();
  226. i++;
  227. }
  228. return operations;
  229. }
  230. }