地铁二期项目正式开始

T_Report.cs 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Data.SqlClient;
  5. using YTSoft.DBUtility;//Please add references
  6. namespace YTSoft.BaseCallCenter.DAL
  7. {
  8. /// <summary>
  9. /// 数据访问类:T_Report
  10. /// </summary>
  11. public partial class T_Report
  12. {
  13. public T_Report()
  14. { }
  15. #region Method
  16. /// <summary>
  17. ///获取坐席话务报表
  18. /// </summary>
  19. public DataTable GetAgentCallRecordReport(string strWhere)
  20. {
  21. string timeks = strWhere.Split(' ')[0];
  22. string timejs = strWhere.Split(' ')[1];
  23. StringBuilder strSql = new StringBuilder();
  24. strSql.Append(@"select UserCode,UserName,
  25. COUNT(1) as TotalRecord,
  26. (select COUNT(1) from T_Call_CallRecords where CallType=0 and UserId=a.UserId and DATEDIFF(d,IvrStartTime,'" + timeks + "')<=0 and DATEDIFF(d,IvrStartTime,'" + timejs + "')>=0) as InCall,");
  27. strSql.Append(@"
  28. (select COUNT(1) from T_Call_CallRecords where CallType=1 and UserId=a.UserId and DATEDIFF(d,BeginTime,'" + timeks + "')<=0 and DATEDIFF(d,BeginTime,'" + timejs + "')>=0) as OutCall,isnull(Sum(Datediff(s,BeginTime,EndTime)),0) As Second,isnull(avg(Datediff(s,BeginTime,EndTime)),0) As AvgSecond from T_Call_CallRecords as a where a.CallType=0 ");
  29. if (!string.IsNullOrEmpty(strWhere.Trim()))
  30. {
  31. strSql.Append(@"and DATEDIFF(d,IvrStartTime,'" + timeks + "')<=0 and DATEDIFF(d,IvrStartTime,'" + timejs + "')>=0");
  32. }
  33. strSql.Append(@" group by a.UserId,a.UserCode,a.UserName
  34. order by UserCode");
  35. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  36. }
  37. /// <summary>
  38. ///获取坐席业务报表
  39. /// </summary>
  40. public DataTable GetAgentBusinessReport(string strWhere)
  41. {
  42. StringBuilder strSql = new StringBuilder();
  43. strSql.Append(@"SELECT userName,COUNT(1) as TotalCount
  44. FROM T_Bus_WorkOrder where 1=1 ");
  45. if (!string.IsNullOrEmpty(strWhere.Trim()))
  46. {
  47. strSql.Append(strWhere);
  48. }
  49. strSql.Append(@" group by userName");
  50. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  51. }
  52. /// <summary>
  53. ///获取客户满意度
  54. /// </summary>
  55. public DataTable GetCustomerValuationReport(string strWhere)
  56. {
  57. StringBuilder strSql = new StringBuilder();
  58. strSql.Append(@"select UserCode,UserName,sum(case MYD when 1 then 1 else 0 end) as MYCount,sum(case MYD when 2 then 1 else 0 end) as YBCount,sum(case MYD when 3 then 1 else 0 end) as BMYCount from T_Call_CallRecords
  59. where MYD is not null and UserCode is not null ");
  60. if (!string.IsNullOrEmpty(strWhere.Trim()))
  61. {
  62. strSql.Append(strWhere);
  63. }
  64. strSql.Append(@" group by UserCode,UserName");
  65. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  66. }
  67. //GetCallInTypeReport
  68. /// <summary>
  69. ///获取来电方式统计
  70. /// </summary>
  71. public DataTable GetCallInTypeReport(string strWhere)
  72. {
  73. StringBuilder strSql = new StringBuilder();
  74. //select DATEPART(HOUR,BeginTime) as hrhour,COUNT(CallId) as hrCount from T_Call_CallRecords where CallType=0 and DATEDIFF(d,BeginTime,'2013-07-01')<=0 and DATEDIFF(d,BeginTime,'2013-07-18')>=0 group by DATEPART(HOUR,BeginTime)
  75. strSql.Append(@"select DATEPART(HOUR,BeginTime) as hrhour,COUNT(CallId) as hrCount from T_Call_CallRecords where CallType=0 ");
  76. if (!string.IsNullOrEmpty(strWhere.Trim()))
  77. {
  78. strSql.Append(strWhere);
  79. }
  80. strSql.Append(@" group by DATEPART(HOUR,BeginTime)");
  81. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  82. }
  83. /// <summary>
  84. ///获取话务量统计(圆饼形式)
  85. /// </summary>
  86. public DataTable GetCallCountReport(string strWhere)
  87. {
  88. StringBuilder strSql = new StringBuilder();
  89. strSql.Append(@"select COUNT(1) as totalCount,CallType from T_Call_CallRecords where 1=1 ");
  90. if (!string.IsNullOrEmpty(strWhere.Trim()))
  91. {
  92. strSql.Append(strWhere);
  93. }
  94. strSql.Append(@" group by CallType");
  95. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  96. }
  97. /// <summary>
  98. ///获取话务量统计(表格形式)
  99. /// </summary>
  100. public DataTable GetCallCountReport1(string strWhere)
  101. {
  102. StringBuilder strSql = new StringBuilder();
  103. strSql.Append(@"select CallId from T_Call_CallRecords where 1=1 ");
  104. if (!string.IsNullOrEmpty(strWhere.Trim()))
  105. {
  106. strSql.Append(strWhere);
  107. }
  108. strSql.Append(@" group by CallId");
  109. return DbHelperSQL.Query(strSql.ToString()).Tables[0];
  110. }
  111. #endregion Method
  112. }
  113. }