|
|
@@ -27,12 +27,12 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
27
|
27
|
}
|
|
28
|
28
|
|
|
29
|
29
|
//获取数据
|
|
30
|
|
- public ActionResult GetDataList(string stime, string endtime)
|
|
|
30
|
+ public ActionResult GetDataList(string stime, string endtime, string dpt)
|
|
31
|
31
|
{
|
|
32
|
32
|
ActionResult res = NoToken("未知错误,请重新登录");
|
|
33
|
33
|
|
|
34
|
34
|
DataTable dtNew = new DataTable();
|
|
35
|
|
- dtNew = GetData(stime, endtime);
|
|
|
35
|
+ dtNew = GetData(stime, endtime, dpt);
|
|
36
|
36
|
#region
|
|
37
|
37
|
//DataTable dtNew = new DataTable();
|
|
38
|
38
|
//#region 编辑表头
|
|
|
@@ -90,13 +90,13 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
90
|
90
|
}
|
|
91
|
91
|
|
|
92
|
92
|
//导出数据
|
|
93
|
|
- public ActionResult ExptList(string stime, string endtime)
|
|
|
93
|
+ public ActionResult ExptList(string stime, string endtime, string dpt)
|
|
94
|
94
|
{
|
|
95
|
95
|
ActionResult res = NoToken("未知错误,请重新登录");
|
|
96
|
96
|
if (Request.IsAuthenticated)
|
|
97
|
97
|
{
|
|
98
|
98
|
NPOIHelper npoi = new NPOIHelper();
|
|
99
|
|
- DataTable dt = GetData(stime, endtime);
|
|
|
99
|
+ DataTable dt = GetData(stime, endtime, dpt);
|
|
100
|
100
|
if (npoi.ExportToExcel("通话时长数据", dt) == "")
|
|
101
|
101
|
{
|
|
102
|
102
|
return Success("导出成功");
|
|
|
@@ -110,7 +110,7 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
110
|
110
|
}
|
|
111
|
111
|
|
|
112
|
112
|
//获取数据源
|
|
113
|
|
- private DataTable GetData(string stime, string endtime)
|
|
|
113
|
+ private DataTable GetData(string stime, string endtime, string dpt)
|
|
114
|
114
|
{
|
|
115
|
115
|
DataTable dtNew = new DataTable();
|
|
116
|
116
|
#region 编辑表头
|
|
|
@@ -135,15 +135,15 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
135
|
135
|
dtNew.Columns.Add(dc9);
|
|
136
|
136
|
#endregion
|
|
137
|
137
|
|
|
138
|
|
- string[] CallInTime = GetCallRecordIn(stime, endtime, "0").TrimStart('[').TrimEnd(']').Split(',');
|
|
139
|
|
- string[] CallInTimes = GetCallRecordTotalTime(stime, endtime, "0").TrimStart('[').TrimEnd(']').Split(',');
|
|
140
|
|
- string[] CallOutTime = GetCallRecordOut(stime, endtime, "1", "").TrimStart('[').TrimEnd(']').Split(',');
|
|
141
|
|
- string[] CallOutTimes = GetCallRecordTotalTime(stime, endtime, "1").TrimStart('[').TrimEnd(']').Split(',');
|
|
142
|
|
- string[] CallOutWTime = GetCallRecordOut(stime, endtime, "1", "0").TrimStart('[').TrimEnd(']').Split(',');
|
|
143
|
|
- string[] CallOutWTimes = GetCallRecordRingTime(stime, endtime).TrimStart('[').TrimEnd(']').Split(',');
|
|
144
|
|
- string[] CallTotalTime = GetCallRecordTotalTime(stime, endtime, "").TrimStart('[').TrimEnd(']').Split(',');
|
|
|
138
|
+ string[] CallInTime = GetCallRecordIn(stime, endtime, "0", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
139
|
+ string[] CallInTimes = GetCallRecordTotalTime(stime, endtime, "0", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
140
|
+ string[] CallOutTime = GetCallRecordOut(stime, endtime, "1", "", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
141
|
+ string[] CallOutTimes = GetCallRecordTotalTime(stime, endtime, "1", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
142
|
+ string[] CallOutWTime = GetCallRecordOut(stime, endtime, "1", "0", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
143
|
+ string[] CallOutWTimes = GetCallRecordRingTime(stime, endtime, dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
144
|
+ string[] CallTotalTime = GetCallRecordTotalTime(stime, endtime, "", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
145
|
145
|
string[] AgentArr = GetAgent().TrimStart('[').TrimEnd(']').Split(',');
|
|
146
|
|
- string[] AverageTime = GetCallAverageTime(stime, endtime).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
146
|
+ string[] AverageTime = GetCallAverageTime(stime, endtime, dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
147
|
147
|
|
|
148
|
148
|
for (int i = 0; i < AgentArr.Length; i++)
|
|
149
|
149
|
{
|
|
|
@@ -173,9 +173,9 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
173
|
173
|
/// <param name="EndTime">结束时间</param>
|
|
174
|
174
|
/// <param name="Tag">1表示呼出,0表示呼入</param>
|
|
175
|
175
|
/// <returns></returns>
|
|
176
|
|
- public string GetCallRecordOut(string BeginTime, string EndTime, string Tag, string state)
|
|
|
176
|
+ public string GetCallRecordOut(string BeginTime, string EndTime, string Tag, string state, string dpt)
|
|
177
|
177
|
{
|
|
178
|
|
- return GetHighChartData(BeginTime, EndTime, Tag, state);
|
|
|
178
|
+ return GetHighChartData(BeginTime, EndTime, Tag, state, dpt);
|
|
179
|
179
|
}
|
|
180
|
180
|
/// <summary>
|
|
181
|
181
|
/// 获取通话总时长
|
|
|
@@ -183,7 +183,7 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
183
|
183
|
/// <param name="BeginTime">开始时间</param>
|
|
184
|
184
|
/// <param name="EndTime">结束时间</param>
|
|
185
|
185
|
/// <returns></returns>
|
|
186
|
|
- public string GetCallRecordTotalTime(string BeginTime, string EndTime, string tag)
|
|
|
186
|
+ public string GetCallRecordTotalTime(string BeginTime, string EndTime, string tag, string dpt)
|
|
187
|
187
|
{
|
|
188
|
188
|
string result = "[";
|
|
189
|
189
|
string sql = "";
|
|
|
@@ -196,6 +196,10 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
196
|
196
|
{
|
|
197
|
197
|
sql += " and DATEDIFF(d,BeginTime,'" + EndTime + "')>=0";
|
|
198
|
198
|
}
|
|
|
199
|
+ if (dpt != null && dpt.Trim() != "")
|
|
|
200
|
+ {
|
|
|
201
|
+ sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
|
|
|
202
|
+ }
|
|
199
|
203
|
if (tag != "")
|
|
200
|
204
|
{
|
|
201
|
205
|
sql += " and CallType=" + tag;
|
|
|
@@ -240,14 +244,14 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
240
|
244
|
/// <param name="BeginTime">开始时间</param>
|
|
241
|
245
|
/// <param name="EndTime">结束时间</param>
|
|
242
|
246
|
/// <returns></returns>
|
|
243
|
|
- public string GetCallAverageTime(string BeginTime, string EndTime)
|
|
|
247
|
+ public string GetCallAverageTime(string BeginTime, string EndTime, string dpt)
|
|
244
|
248
|
{
|
|
245
|
249
|
string result = "[";
|
|
246
|
250
|
|
|
247
|
|
- string[] CallInTime = GetCallRecordIn(BeginTime, EndTime, "0").TrimStart('[').TrimEnd(']').Split(',');
|
|
248
|
|
- string[] CallOutTime = GetCallRecordOut(BeginTime, EndTime, "1", "").TrimStart('[').TrimEnd(']').Split(',');
|
|
|
251
|
+ string[] CallInTime = GetCallRecordIn(BeginTime, EndTime, "0", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
|
252
|
+ string[] CallOutTime = GetCallRecordOut(BeginTime, EndTime, "1", "", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
249
|
253
|
|
|
250
|
|
- string[] CallTotalTime = GetCallRecordTotalTime(BeginTime, EndTime, "").TrimStart('[').TrimEnd(']').Split(',');
|
|
|
254
|
+ string[] CallTotalTime = GetCallRecordTotalTime(BeginTime, EndTime, "", dpt).TrimStart('[').TrimEnd(']').Split(',');
|
|
251
|
255
|
|
|
252
|
256
|
for (int i = 0; i < CallInTime.Length; i++)
|
|
253
|
257
|
{
|
|
|
@@ -274,9 +278,9 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
274
|
278
|
/// <param name="BeginTime">开始时间</param>
|
|
275
|
279
|
/// <param name="EndTime">结束时间</param>
|
|
276
|
280
|
/// <returns></returns>
|
|
277
|
|
- public string GetCallRecordIn(string BeginTime, string EndTime, string Tag)
|
|
|
281
|
+ public string GetCallRecordIn(string BeginTime, string EndTime, string Tag, string dpt)
|
|
278
|
282
|
{
|
|
279
|
|
- return GetHighChartData(BeginTime, EndTime, Tag, "");
|
|
|
283
|
+ return GetHighChartData(BeginTime, EndTime, Tag, "", dpt);
|
|
280
|
284
|
}
|
|
281
|
285
|
/// <summary>
|
|
282
|
286
|
/// 获取呼入呼出数据
|
|
|
@@ -285,7 +289,7 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
285
|
289
|
/// <param name="EndTime">结束时间</param>
|
|
286
|
290
|
/// <param name="Tag">1表示呼出,0表示呼入</param>
|
|
287
|
291
|
/// <returns></returns>
|
|
288
|
|
- private string GetHighChartData(string BeginTime, string EndTime, string Tag, string state)
|
|
|
292
|
+ private string GetHighChartData(string BeginTime, string EndTime, string Tag, string state, string dpt)
|
|
289
|
293
|
{
|
|
290
|
294
|
string result = "[";
|
|
291
|
295
|
string sql = " and CallType=" + Tag; // 呼入
|
|
|
@@ -305,7 +309,10 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
305
|
309
|
{
|
|
306
|
310
|
sql += " and CallState=" + state.Trim();
|
|
307
|
311
|
}
|
|
308
|
|
-
|
|
|
312
|
+ if (dpt != null && dpt.Trim() != "")
|
|
|
313
|
+ {
|
|
|
314
|
+ sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
|
|
|
315
|
+ }
|
|
309
|
316
|
//DataTable dt = DbHelperSQL.Query("SELECT UserId,UserCode,UserName,COUNT(*) AS calloutCount FROM T_Call_CallRecords where 1=1 " + sql + " GROUP BY UserId,UserCode,UserName").Tables[0];
|
|
310
|
317
|
//var recordstr = " select users.F_UserId,users.F_UserCode,users.F_UserName,COUNT(*) AS calloutCount from T_Sys_UserAccount users right join T_Call_CallRecords records on users.F_UserCode = records.UserCode and 1=1 " + sql + " GROUP BY users.F_UserId,users.F_UserCode,users.F_UserName";
|
|
311
|
318
|
//20180509 通话时长统计不对 machenyang
|
|
|
@@ -340,7 +347,7 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
340
|
347
|
/// <param name="BeginTime"></param>
|
|
341
|
348
|
/// <param name="EndTime"></param>
|
|
342
|
349
|
/// <returns></returns>
|
|
343
|
|
- public string GetCallRecordRingTime(string BeginTime, string EndTime)
|
|
|
350
|
+ public string GetCallRecordRingTime(string BeginTime, string EndTime, string dpt)
|
|
344
|
351
|
{
|
|
345
|
352
|
string result = "[";
|
|
346
|
353
|
string sql = "";
|
|
|
@@ -355,6 +362,10 @@ namespace CallCenterApi.Interface.Controllers.report
|
|
355
|
362
|
sql += " and BeginTime<='" + EndTime + "'";
|
|
356
|
363
|
//sql += " and DATEDIFF(d,BeginTime,'" + EndTime + "')>=0";
|
|
357
|
364
|
}
|
|
|
365
|
+ if (dpt != null && dpt.Trim() != "")
|
|
|
366
|
+ {
|
|
|
367
|
+ sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
|
|
|
368
|
+ }
|
|
358
|
369
|
//只统计呼入振铃时长
|
|
359
|
370
|
sql += " and CallType=0 ";
|
|
360
|
371
|
|