UU跑腿标准版

ZuoXiReport.ashx.cs 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using HySoft.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. namespace HySoft.BaseCallCenter.Web.reportmanage.operationdata.controls
  8. {
  9. /// <summary>
  10. /// ZuoXiReport 的摘要说明
  11. /// </summary>
  12. public class ZuoXiReport : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string action = context.Request.QueryString["action"];
  18. switch (action)
  19. {
  20. case "getlist":
  21. context.Response.Write(GetDataList(context));//读取数据
  22. break;
  23. }
  24. }
  25. #region
  26. //岗位 工号 姓名 来话接听数量-lhjtl 受理座席转接量-slzxzjl 接听电话总量-jtdhzl 外呼电话量-whdhl 外呼电话接起量-whdhjql
  27. //签入时长-qrsc 来话接听时长(秒)-ldjtsc 转接电话接听时长(秒)-zjdhjtsc 总接听时长(秒)-zjtsc
  28. //平均来话接听时长(秒 / 次)-pjlhjtsc 平均转接电话接听时长(秒 / 次)-pjzjdhjtsc 平均接听通话时长(秒 / 次)-pjjtthsc
  29. //总呼出通话时长(秒)-zhcthsc 总呼出成功通话时长(秒)-zhccgthsc
  30. //平均呼出通话时长(秒 / 次)-pjhcthsc 平均成功呼出通话时长(秒 / 次)-pjcghcthsc
  31. //来话话后置忙总时长(秒)-lhhhzmzsc 转接电话话后置忙总时长(秒)-zjdhhhzmzsc 话后置忙总时长(秒)-hhzmzsc
  32. //来话话后置忙平均时长(秒 / 次)-lhhhzmpjsc 转接电话话后置忙平均时长(秒 / 次)-zjdhhhzmpjsc
  33. //平均话后置忙时长(秒 / 次)-pjhhzmsc
  34. //来话持线等待总时长(秒)-lhcxddzsc 转接电话持线等待总时长(秒)-zjdhcxddzsc
  35. //持线等待总时长(秒)-cxddzsc 来话持线等待平均时长(秒 / 次)-lhcxddpjsc
  36. //转接电话持线等待平均时长(秒 / 次)-zjdhcxddpjsc 持线等待平均时长(秒 / 次)-cxddpjsc
  37. //未准备好总时长(秒)-wzbhzsc 示闲总时长(秒)-sxzsc 事后处理时长(秒)-shclsc
  38. //来电信息点击量 -ldxxdjl 信息点击总量-xxdjzl
  39. int lhjtl = 0; int slzxzjl = 0; int jtdhzl = 0; int whdhl = 0; int whdhjql = 0;
  40. int qrsc = 0; int ldjtsc = 0; int zjdhjtsc = 0; int zjtsc = 0;
  41. string pjlhjtsc = "0"; string pjzjdhjtsc = "0"; string pjjtthsc = "0";
  42. int zhcthsc = 0; int zhccgthsc = 0;
  43. string pjhcthsc = "0"; string pjcghcthsc = "0";
  44. int lhhhzmzsc = 0; int zjdhhhzmzsc = 0; int hhzmzsc = 0;
  45. int lhhhzmpjsc = 0; int zjdhhhzmpjsc = 0;
  46. string pjhhzmsc = "0";
  47. int lhcxddzsc = 0; int zjdhcxddzsc = 0;
  48. int cxddzsc = 0; string lhcxddpjsc = "0";
  49. int zjdhcxddpjsc = 0; string cxddpjsc = "0";
  50. int wzbhzsc = 0; int sxzsc = 0; int shclsc = 0; int ldxxdjl = 0; int xxdjzl = 0;
  51. #endregion
  52. private string GetDataList(HttpContext context)
  53. {
  54. string res = "";
  55. try
  56. {
  57. string sqlu = "";
  58. string dpt = CommonRequest.GetQueryString("dpt");
  59. string txtStartTime = CommonRequest.GetQueryString("starttime");
  60. string txtEndTime = CommonRequest.GetQueryString("endtime");
  61. string strpageindex = context.Request.Params["page"];
  62. int pageindex = 1;
  63. string strpagesize = context.Request.Params["pagesize"];
  64. int pagesize = 20;
  65. sqlu = " F_SeatFlag=1 and F_DeleteFlag=0";
  66. if (dpt.Trim() != "")
  67. {
  68. sqlu += " and F_DeptId=" + dpt.Trim();
  69. }
  70. string sqltimeCallRecords = "";
  71. string strsqlcall = " 1=1 ";
  72. if (txtStartTime != null && txtStartTime.Trim() != "")
  73. {
  74. sqltimeCallRecords += " and CONVERT(varchar , TimeAlerting, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
  75. strsqlcall += " and CONVERT(varchar , BeginTime, 120)>=CONVERT(varchar , '" + txtStartTime.Trim() + " 00:00:01', 120) ";
  76. }
  77. if (txtEndTime != null && txtEndTime.Trim() != "")
  78. {
  79. sqltimeCallRecords += " and CONVERT(varchar , TimeAlerting, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
  80. strsqlcall += " and CONVERT(varchar , BeginTime, 120)<=CONVERT(varchar , '" + txtEndTime.Trim() + " 23:59:59', 120) ";
  81. }
  82. Model.PageData<object> pageData = new Model.PageData<object>();
  83. var userslist = new BLL.T_Sys_UserAccount().GetModelList(sqlu);
  84. var calllist = new BLL.T_Call_CallRecords().GetModelList(strsqlcall);
  85. var rolelist = new BLL.T_Sys_RoleInfo().GetModelList("");
  86. pageData.Rows = userslist.Select(n =>
  87. {
  88. GetTimes(n.F_WorkNumber, sqltimeCallRecords, strsqlcall);
  89. lhjtl = calllist.Where(c => c.UserCode == n.F_WorkNumber && c.CallType == 0 && c.CallState == 1).ToList().Count();//来话接听数量
  90. whdhl = calllist.Where(c => c.UserCode == n.F_WorkNumber && c.CallType == 1).ToList().Count();//外呼电话量
  91. whdhjql = calllist.Where(c => c.UserCode == n.F_WorkNumber && c.CallType == 1 && c.CallState == 1).ToList().Count();//外呼电话接起量
  92. ldxxdjl = calllist.Where(c => c.UserCode == n.F_WorkNumber && c.F_ZXreasonid > 0).ToList().Count();//来电信息点击量
  93. string rolename = rolelist.Where(r => r.F_RoleId == n.F_RoleId).FirstOrDefault<Model.T_Sys_RoleInfo>().F_RoleName;
  94. return new
  95. {
  96. RoleName = rolename,
  97. UserCode = n.F_WorkNumber,
  98. UserName = n.F_UserName,
  99. LHJTL = lhjtl,
  100. SLZXZJL = slzxzjl,
  101. JTDHZL = jtdhzl,
  102. WHDHL = whdhl,
  103. WHDHJQL = whdhjql,
  104. QRSC = qrsc,
  105. LDJTSC = ldjtsc,
  106. ZJDHJTSC = zjdhjtsc,
  107. ZJTSC = zjtsc,
  108. PJLHJTSC = pjlhjtsc,
  109. PJZJDHJTSC = pjzjdhjtsc,
  110. PJJTTHSC = pjjtthsc,
  111. ZHCTHSC = zhcthsc,
  112. ZHCCGTHSC = zhccgthsc,
  113. PJHCTHSC = pjhcthsc,
  114. PJCGHCTHSC = pjcghcthsc,
  115. LHHHZMZSC = lhhhzmzsc,
  116. ZJDHHHZMZSC = zjdhhhzmzsc,
  117. HHZMZSC = hhzmzsc,
  118. LHHHZMPJSC = lhhhzmpjsc,
  119. ZJDHHHZMPJSC = zjdhhhzmpjsc,
  120. PJHHZMSC = pjhhzmsc,
  121. LHCXDDZSC = lhcxddzsc,
  122. ZJDHCXDDZSC = zjdhcxddzsc,
  123. CXDDZSC = cxddzsc,
  124. LHCXDDPJSC = lhcxddpjsc,
  125. ZJDHCXDDPJSC = zjdhcxddpjsc,
  126. CXDDPJSC = cxddpjsc,
  127. WZBHZSC = wzbhzsc,
  128. SXZSC = sxzsc,
  129. SHCLSC = shclsc,
  130. LDXXDJL = ldxxdjl,
  131. XXDJZL = xxdjzl
  132. };
  133. }).ToList<object>().Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
  134. pageData.Total = userslist.Count;
  135. res = pageData.ToJson();
  136. }
  137. catch (Exception ex)
  138. { }
  139. return res;
  140. }
  141. private void GetTimes(string usercode, string sqltimeCallRecords, string strsqlcall)
  142. {
  143. //岗位 工号 姓名 *来话接听数量-lhjtl 受理座席转接量-slzxzjl 接听电话总量-jtdhzl *外呼电话量-whdhl *外呼电话接起量-whdhjql
  144. //*签入时长-qrsc *来话接听时长(秒)-ldjtsc 转接电话接听时长(秒)-zjdhjtsc 总接听时长(秒)-zjtsc
  145. //*平均来话接听时长(秒 / 次)-pjlhjtsc 平均转接电话接听时长(秒 / 次)-pjzjdhjtsc 平均接听通话时长(秒 / 次)-pjjtthsc
  146. //*总呼出通话时长(秒)-zhcthsc 总呼出成功通话时长(秒)-zhccgthsc
  147. //*平均呼出通话时长(秒 / 次)-pjhcthsc 平均成功呼出通话时长(秒 / 次)-pjcghcthsc
  148. //来话话后置忙总时长(秒)-lhhhzmzsc 转接电话话后置忙总时长(秒)-zjdhhhzmzsc 话后置忙总时长(秒)-hhzmzsc
  149. //来话话后置忙平均时长(秒 / 次)-lhhhzmpjsc 转接电话话后置忙平均时长(秒 / 次)-zjdhhhzmpjsc
  150. //平均话后置忙时长(秒 / 次)-pjhhzmsc
  151. //*来话持线等待总时长(秒)-lhcxddzsc 转接电话持线等待总时长(秒)-zjdhcxddzsc
  152. //持线等待总时长(秒)-cxddzsc *来话持线等待平均时长(秒 / 次)-lhcxddpjsc
  153. //转接电话持线等待平均时长(秒 / 次)-zjdhcxddpjsc 持线等待平均时长(秒 / 次)-cxddpjsc
  154. //未准备好总时长(秒)-wzbhzsc *示闲总时长(秒)-sxzsc 事后处理时长(秒)-shclsc
  155. //*来电信息点击量 -ldxxdjl 信息点击总量-xxdjzl
  156. #region 来话持线等待总时长 来话持线等待平均时长
  157. DataTable dtTrunk = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,SUM(DATEDIFF(Second,timewantagent,timeconnected)) as dd from rep_trunk_call_in where AgentId=" + usercode + " " + sqltimeCallRecords.Replace("TimeAlerting", "TimeCallIn")).Tables[0];
  158. if (dtTrunk.Rows.Count > 0 )
  159. {
  160. int itrunkct = 0;
  161. if (dtTrunk.Rows[0]["ct"].ToString() != "")
  162. {
  163. itrunkct = int.Parse(dtTrunk.Rows[0]["ct"].ToString());
  164. }
  165. if (dtTrunk.Rows[0]["dd"].ToString() != "")
  166. {
  167. lhcxddzsc = int.Parse(dtTrunk.Rows[0]["dd"].ToString());
  168. }
  169. else
  170. {
  171. lhcxddzsc = 0;
  172. }
  173. if (itrunkct != 0)
  174. {
  175. lhcxddpjsc = (lhcxddzsc / itrunkct).ToString();
  176. }
  177. else
  178. {
  179. lhcxddpjsc = "0";
  180. }
  181. }
  182. #endregion
  183. #region 来话接听时长 平均来话接听时长
  184. int iLHjtcs = 0;
  185. DataTable dtCallEvey = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,SUM(TalkLongTime) as sc from T_Call_CallRecords where CallState=1 and CallType=0 and usercode=" + usercode + " " + strsqlcall).Tables[0];
  186. if (dtCallEvey != null && dtCallEvey.Rows.Count > 0)
  187. {
  188. if (dtCallEvey.Rows[0]["ct"].ToString() != "")
  189. {
  190. iLHjtcs = int.Parse(dtCallEvey.Rows[0]["ct"].ToString());//接听次数
  191. }
  192. if (dtCallEvey.Rows[0]["sc"].ToString() != "")
  193. {
  194. ldjtsc = int.Parse(dtCallEvey.Rows[0]["sc"].ToString());//通话秒数
  195. }
  196. else
  197. {
  198. ldjtsc = 0;
  199. }
  200. if (iLHjtcs != 0)
  201. {
  202. pjlhjtsc = (ldjtsc / iLHjtcs).ToString();
  203. }
  204. else
  205. pjlhjtsc = "0";
  206. }
  207. #endregion
  208. #region 总接听时长 平均接听通话时长
  209. int iZjtcs = 0;
  210. DataTable dtCallZEvey = DBUtility.DbHelperSQL.Query("select COUNT(*) as ct,SUM(TalkLongTime) as sc from T_Call_CallRecords where CallState=1 and usercode=" + usercode + " " + strsqlcall).Tables[0];
  211. if (dtCallZEvey != null && dtCallZEvey.Rows.Count > 0)
  212. {
  213. if (dtCallZEvey.Rows[0]["ct"].ToString() != "")
  214. {
  215. iZjtcs = int.Parse(dtCallZEvey.Rows[0]["ct"].ToString());//接听次数
  216. }
  217. if (dtCallZEvey.Rows[0]["sc"].ToString() != "")
  218. {
  219. zjtsc = int.Parse(dtCallZEvey.Rows[0]["sc"].ToString());//通话秒数
  220. }
  221. else
  222. {
  223. zjtsc = 0;
  224. }
  225. if (iZjtcs != 0)
  226. {
  227. pjjtthsc = (ldjtsc / iZjtcs).ToString();
  228. }
  229. else
  230. pjjtthsc = "0";
  231. }
  232. #endregion
  233. #region 总呼出通话时长 平均呼出通话时长
  234. zhcthsc = zjtsc - ldjtsc;
  235. int iHCjtcs = 0;
  236. iHCjtcs=iZjtcs - iLHjtcs;
  237. if (iHCjtcs != 0)
  238. {
  239. pjhcthsc = (zhcthsc / iHCjtcs).ToString();
  240. }
  241. else
  242. pjhcthsc = "0";
  243. #endregion
  244. #region 签入时长 示闲总时长
  245. DataTable dtAgent = DBUtility.DbHelperSQL.Query("select COUNT(*) as dl,SUM(LoginTimes) as dlsc,SUM(reposenum) as zm,SUM(ReposeTimes) as xx from rep_agent_detail where AgentId=" + usercode + " " + sqltimeCallRecords.Replace("TimeAlerting", "TimeLogin")).Tables[0];
  246. if (dtAgent != null && dtAgent.Rows.Count > 0)
  247. {
  248. if (dtAgent.Rows[0]["dlsc"] != null && dtAgent.Rows[0]["dlsc"].ToString() != "")
  249. {
  250. qrsc = int.Parse(dtAgent.Rows[0]["dlsc"].ToString());//签入时长
  251. }
  252. else
  253. {
  254. qrsc = 0;
  255. }
  256. if (dtAgent.Rows[0]["xx"] != null && dtAgent.Rows[0]["xx"].ToString() != "")
  257. {
  258. sxzsc = int.Parse(dtAgent.Rows[0]["xx"].ToString());//示闲总时长
  259. }
  260. else
  261. {
  262. sxzsc = 0;
  263. }
  264. }
  265. else
  266. {
  267. qrsc = 0;
  268. sxzsc = 0;
  269. }
  270. #endregion
  271. }
  272. public bool IsReusable
  273. {
  274. get
  275. {
  276. return false;
  277. }
  278. }
  279. }
  280. }