lihai лет назад: 6
Родитель
Сommit
4e20dc47ad

+ 116 - 42
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IndexController.cs

@@ -1,5 +1,6 @@
1 1
 using CallCenter.Utility;
2 2
 using CallCenterApi.Common;
3
+using CallCenterApi.DB;
3 4
 using CallCenterApi.Interface.Controllers.Base;
4 5
 using System;
5 6
 using System.Collections.Generic;
@@ -174,26 +175,65 @@ namespace CallCenterApi.Interface.Controllers
174 175
                     string strDate = date.ToString("yyyy-MM-dd");
175 176
                     string strMonth = date.ToString("yyyy-MM");
176 177
 
177
-                    string uwhere = " 1=1 ";
178
+                    //string uwhere = " 1=1 ";
179
+                    string uwhere = " 1=1  AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";    //and ISNULL(groupcode,'') != ''
178 180
                     if (roleid != 17)
179 181
                     {
180 182
                         uwhere += " and UserCode='" + usercode + "' ";
181 183
                     }
182 184
 
183 185
                     BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
184
-                    var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
185
-                    var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
186
-                    var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
187
-                    var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
188
-
189
-                    int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' and CallState='0' ").Tables[0].Rows.Count;
186
+                    //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
187
+                    //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' and CallState='1' ");
188
+                    //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
189
+                    //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' and CallState='1' ");
190
+                    //int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' and CallState='0' ").Tables[0].Rows.Count;
191
+
192
+                    //2018-05-03 lihai 首页统计问题
193
+                    //var dayinlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
194
+                    //var dayoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(varchar(10),BeginTime, 23)='" + strDate + "' ");
195
+                    //var moninlist = bll.GetModelList(uwhere + " and CallType='0' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
196
+                    //var monoutlist = bll.GetModelList(uwhere + " and CallType='1' and CONVERT(char(7),BeginTime,20)='" + strMonth + "' ");
197
+
198
+                    //int daynocon = bll.GetList("CallType='0' and CallState='0' and datediff(day,BeginTime, '" + strDate + "')=0 ").Tables[0].Rows.Count;
199
+                    ////int daynocon = bll.GetList("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ").Tables[0].Rows.Count;
200
+                    DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,UserCode,ISNULL(TalkLongTime,0) AS TalkLongTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];   //,groupcode
201
+
202
+                    // 今日来电
203
+                    var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
204
+                    var dayinlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'");
205
+                    var dayinlist_totaltimesum = (from DataRow dr in dayinlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
206
+                    //今日去电    
207
+                    var dayoutlist = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'").Count();
208
+                    var dayoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonthdays = '" + strDate + "'");
209
+                    var dayoutlist_totaltimesum = (from DataRow dr in dayoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
210
+                    //本月来电    
211
+                    var moninlist = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'").Count();
212
+                    var moninlist_totaltimesum_0 = dtConnect.Select("CallType='0' and yearmonths = '" + strMonth + "'");
213
+                    var moninlist_totaltimesum = (from DataRow dr in moninlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
214
+                    //本月去电    
215
+                    var monoutlist = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'").Count();
216
+                    var monoutlist_totaltimesum_0 = dtConnect.Select("CallType='1' and yearmonths = '" + strMonth + "'");
217
+                    var monoutlist_totaltimesum = (from DataRow dr in monoutlist_totaltimesum_0 select dr.Field<int>("TalkLongTime")).Sum();
218
+                    //未接来电    
219
+                    var daynocon = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
190 220
 
191 221
                     var obj = new
192 222
                     {
193
-                        dayin = new { count = dayinlist.Count, totaltime =DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
194
-                        dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
195
-                        monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
196
-                        monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()),0) },
223
+                        //dayin = new { count = dayinlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
224
+                        //dayout = new { count = dayoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
225
+                        //monin = new { count = moninlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
226
+                        //monout = new { count = monoutlist.Count, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist.Select(p => p.TalkLongTime).Sum().ToString()), 0) },
227
+                        //daynocon = daynocon
228
+                        // 今日来电
229
+                        dayin = new { count = dayinlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayinlist_totaltimesum.ToString()), 0) },
230
+                        //今日去电    
231
+                        dayout = new { count = dayoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(dayoutlist_totaltimesum.ToString()), 0) },
232
+                        //本月来电    
233
+                        monin = new { count = moninlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(moninlist_totaltimesum.ToString()), 0) },
234
+                        //本月去电    
235
+                        monout = new { count = monoutlist, totaltime = DateTimeConvert.parseTimeSeconds(int.Parse(monoutlist_totaltimesum.ToString()), 0) },
236
+                        //未接来电    
197 237
                         daynocon = daynocon
198 238
                     };
199 239
                     res = Success("成功", obj);
@@ -227,24 +267,48 @@ namespace CallCenterApi.Interface.Controllers
227 267
                         //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
228 268
                         //var list4 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (4,5,6,7,9,12,13) ").Tables[0];
229 269
 
230
-                        string uwhere = " 1=1 ";
270
+                        string uwhere = " 1=1 AND CONVERT(char(7),CreateTime,20) = '" + strMonth + "'";
231 271
                         if (ua.F_RoleId != 17)
232 272
                         {
233 273
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
234 274
                         }
235 275
 
236 276
                         BLL.T_Wo_WorkOrder bll = new BLL.T_Wo_WorkOrder();
237
-                        var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =2 and IsDel=0 ").Tables[0];
238
-                        var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State in (0,1) and IsDel=0 ").Tables[0];
239
-                        var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =2 and IsDel=0 ").Tables[0];
240
-                        var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State in (0,1) and IsDel=0 ").Tables[0];
277
+                        //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =2 and IsDel=0 ").Tables[0];
278
+                        //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State in (0,1) and IsDel=0 ").Tables[0];
279
+                        //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =2 and IsDel=0 ").Tables[0];
280
+                        //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State in (0,1) and IsDel=0 ").Tables[0];
281
+
282
+                        ////日已完成
283
+                        //var list1 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =1 and IsDel=0 ").Tables[0];
284
+                        ////日未完成
285
+                        //var list2 = bll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State=0 and IsDel=0 ").Tables[0];
286
+                        ////月已完成
287
+                        //var list3 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =1 and IsDel=0 ").Tables[0];
288
+                        ////月未完成
289
+                        //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State=0 and IsDel=0 ").Tables[0];
290
+
291
+                        DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),CreateTime, 23) AS yearmonthdays,CONVERT(char(7),CreateTime,20) AS yearmonths,State,IsDel,CreateTime,CreateUser FROM T_Wo_WorkOrder WITH(NOLOCK) where " + uwhere + "").Tables[0];
292
+
293
+                        //日已完成
294
+                        int list1_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and State = 1 and IsDel = 0").Count();
295
+                        //日未完成
296
+                        int list2_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and State=0 and IsDel=0 ").Count();
297
+                        //月已完成
298
+                        var list3_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and State =1 and IsDel=0 ").Count();
299
+                        //月未完成
300
+                        var list4_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and State=0 and IsDel=0").Count();
241 301
 
242 302
                         var obj = new
243 303
                         {
244
-                            daywc = list1.Rows.Count,
245
-                            daywwc = list2.Rows.Count,
246
-                            monwc = list3.Rows.Count,
247
-                            monwwc = list4.Rows.Count
304
+                            //daywc = list1.Rows.Count,
305
+                            //daywwc = list2.Rows.Count,
306
+                            //monwc = list3.Rows.Count,
307
+                            //monwwc = list4.Rows.Count
308
+                            daywc = list1_count,
309
+                            daywwc = list2_count,
310
+                            monwc = list3_count,
311
+                            monwwc = list4_count
248 312
                         };
249 313
                         res = Success("成功", obj);
250 314
                     }
@@ -259,48 +323,47 @@ namespace CallCenterApi.Interface.Controllers
259 323
         /// <returns></returns>
260 324
         public ActionResult GetTelRecordsByHour()
261 325
         {
262
-            ActionResult res = NoToken("未知错误,请重新登录");
263 326
             if (Request.IsAuthenticated)
264 327
             {
265 328
 
266 329
                 int userId = CurrentUser.UserData.F_UserId;
267
-                string usercode = CurrentUser.UserData.F_UserCode;
268
-                int roleid = CurrentUser.UserData.F_RoleId;
330
+                Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
269 331
                 if (userId != 0)
270 332
                 {
271 333
                     var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
272 334
                     string strDate = date.ToString("yyyy-MM-dd");
273
-
335
+                    string strMonth = date.ToString("yyyy-MM");
274 336
                     string[] cols = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };
275 337
 
276
-                    string uwhere = " 1=1 ";
277
-                    if (roleid != 17)
338
+                    string uwhere = " 1=1 and CONVERT(char(7),BeginTime,20) = '" + strMonth + "' "; //ISNULL(groupcode,'')!= '' AND 
339
+                    if (userModel.rolecode != "XTGLY")
278 340
                     {
279
-                        uwhere += " and UserCode='" + usercode + "' ";
341
+                        uwhere += " and UserCode='" + userModel.F_UserCode + "' ";
280 342
                     }
281 343
 
282 344
                     BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
345
+                    DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(13),BeginTime, 120) AS yearmonths,CallState,BeginTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
283 346
                     int[] total = new int[24];
284 347
                     int[] count = new int[24];
285 348
                     for (int i = 0; i < cols.Length; i++)
286 349
                     {
287
-                        var list = bll.GetModelList(uwhere + " and CONVERT(varchar(13),BeginTime, 120)='" + (strDate + " " + cols[i]) + "' ");
288
-                        var conlist = list.Where(p => p.CallState == 1);
289
-                        total[i] = list.Count;
350
+                        var list = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "'");
351
+                        var conlist = dtConnect.Select("yearmonths = '" + (strDate + " " + cols[i]) + "' and CallState = 1");
352
+                        total[i] = list.Count();
290 353
                         count[i] = conlist.Count();
291 354
                     }
292 355
 
293 356
                     var obj = new
294 357
                     {
295 358
                         col = cols,
296
-                        total = total,
297
-                        count = count
359
+                        total,
360
+                        count
298 361
                     };
299
-                    res = Success("成功", obj);
362
+                    return Success("成功", obj);
300 363
                 }
301 364
 
302 365
             }
303
-            return res;
366
+            return NoToken("未知错误,请重新登录");
304 367
         }
305 368
 
306 369
         /// <summary>
@@ -321,6 +384,7 @@ namespace CallCenterApi.Interface.Controllers
321 384
                     {
322 385
                         var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
323 386
                         string strDate = date.ToString("yyyy-MM");
387
+                        //string strMonth = date.ToString("yyyy-MM");
324 388
 
325 389
                         int days = DateTime.DaysInMonth(date.Year, date.Month);
326 390
 
@@ -335,23 +399,32 @@ namespace CallCenterApi.Interface.Controllers
335 399
                         int[] teltotal = new int[days];
336 400
                         int[] worktotal = new int[days];
337 401
 
338
-                        string uwhere = " 1=1 ";
339
-                        string u1where = " 1=1 ";
402
+                        string uwhere = " 1=1  AND CONVERT(char(7),CreateTime,20) = '" + strDate + "' ";
403
+                        string u1where = " 1=1 and CONVERT(char(7),BeginTime,20) = '" + strDate + "' "; //ISNULL(groupcode,'') != '' AND 
340 404
                         if (ua.F_RoleId != 17)
341 405
                         {
342 406
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
343 407
                             u1where += " and UserCode='" + ua.F_UserCode + "' ";
344 408
                         }
345 409
 
410
+                        DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,UserCode FROM T_Call_CallRecords WITH(NOLOCK) where " + u1where + "").Tables[0]; //,groupcode
411
+                        DataTable dtConnect_Wo = DbHelperSQL.Query("select CONVERT(varchar(10),CreateTime, 23) AS yearmonthdays,CONVERT(char(7),CreateTime,20) AS yearmonths,State,IsDel,CreateTime,CreateUser FROM T_Wo_WorkOrder WITH(NOLOCK) where " + uwhere + "").Tables[0];
412
+
346 413
                         for (int i = 0; i < cols.Count; i++)
347 414
                         {
348 415
                             //var tellist = telbll.GetModelList(" UserId='" + userId + "' and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
349
-                            var tellist = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
350
-                            teltotal[i] = tellist.Count;
351
-                            newcount = newcount + tellist.Count;
416
+
417
+                            //var tellist = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
418
+                            int tellist_Count = dtConnect.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
419
+                            teltotal[i] = tellist_Count;
420
+                            newcount = newcount + tellist_Count;
421
+
352 422
                             //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
353
-                            var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
354
-                            worktotal[i] = worklist.Rows.Count;
423
+                            //var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
424
+                            //int worklist_count = workbll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
425
+                            int worklist_count = dtConnect_Wo.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
426
+                            //worktotal[i] = worklist.Rows.Count;
427
+                            worktotal[i] = worklist_count;
355 428
                         }
356 429
 
357 430
                         var olddate = date.AddYears(-1);
@@ -359,7 +432,8 @@ namespace CallCenterApi.Interface.Controllers
359 432
                         string strold2 = olddate.ToString("yyyy-MM-dd");
360 433
 
361 434
                         string bl = string.Empty;
362
-                        var oldcount = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ").Count;
435
+                        //var oldcount = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ").Count;
436
+                        var oldcount = telbll.GetRecordCount(u1where + " and CONVERT(varchar(10),BeginTime, 23)>='" + strold1 + "' and CONVERT(varchar(10),BeginTime, 23)<='" + strold2 + "' ");
363 437
 
364 438
                         if (oldcount == newcount)
365 439
                         {

+ 64 - 28
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/TotalCallController.cs

@@ -13,6 +13,7 @@ namespace CallCenterApi.Interface.Controllers.report
13 13
     //[Authority]
14 14
     public class TotalCallController : BaseController
15 15
     {
16
+        BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
16 17
         //总呼叫量统计
17 18
 
18 19
         //获取表头
@@ -28,7 +29,7 @@ namespace CallCenterApi.Interface.Controllers.report
28 29
         }
29 30
 
30 31
         //获取数据
31
-        public ActionResult GetDataList(string years)
32
+        public ActionResult GetDataList(string years, string dpt)
32 33
         {
33 34
             ActionResult res = NoToken("未知错误,请重新登录");
34 35
             if (Request.IsAuthenticated)
@@ -45,7 +46,13 @@ namespace CallCenterApi.Interface.Controllers.report
45 46
                 dtNew.Columns.Add(dc3);
46 47
                 dtNew.Columns.Add(dc4);
47 48
                 #endregion
48
-                DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
49
+                var sql = "";
50
+                if (dpt != null && dpt.Trim() != "")
51
+                {
52
+                    sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
53
+                }
54
+                //DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
55
+                var list = bll.DataTableToList(bll.GetList($" 1=1 {sql} ").Tables[0]);
49 56
                 DateTime dtNow;
50 57
                 int Count = 0;
51 58
                 int DayCount = 0;
@@ -65,20 +72,26 @@ namespace CallCenterApi.Interface.Controllers.report
65 72
 
66 73
                     DateTime beginTime = Convert.ToDateTime(dtNow.Year + "-" + i + "-01 00:00:00");
67 74
                     int days = DateTime.DaysInMonth(dtNow.Year, beginTime.Month);
68
-                    DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
69
-                    if (dtRow.Length > 0)
75
+                    //DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
76
+                    var listByTime = list.Where(x => x.BeginTime >= Convert.ToDateTime(beginTime.ToString()) && x.BeginTime < beginTime.AddDays(days).AddSeconds(-1));
77
+
78
+                    //if (dtRow.Length > 0)
79
+                    if (listByTime.Count() > 0)
70 80
                     {
71
-                        Count += dtRow.Length;
81
+                        //Count += dtRow.Length;
82
+                        Count += listByTime.Count();
72 83
                         for (int j = 1; j <= days; j++)
73 84
                         {
74 85
                             DataRow dr1 = dtNew.NewRow();
75
-                            if (dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length > 0)
86
+                            //if (dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length > 0)
87
+                            if (listByTime.Where(x => x.BeginTime >= beginTime.AddDays(j - 1) && x.BeginTime < beginTime.AddDays(j).AddSeconds(-1)).Count() > 0)
76 88
                             {
77 89
                                 DayCount += 1;
78 90
 
79 91
                                 dr1["月份"] = beginTime.Month + "月";
80 92
                                 dr1["日期"] = beginTime.AddDays(j - 1).ToShortDateString();
81
-                                dr1["总数"] = dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length;
93
+                                // dr1["总数"] = dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length;
94
+                                dr1["总数"] = listByTime.Where(x => x.BeginTime >= beginTime.AddDays(j - 1) && x.BeginTime < beginTime.AddDays(j).AddSeconds(-1)).Count();
82 95
                                 dr1["Count"] = "1";
83 96
                                 dtNew.Rows.Add(dr1);
84 97
                             }
@@ -88,7 +101,8 @@ namespace CallCenterApi.Interface.Controllers.report
88 101
                         {
89 102
                             drNew["月份"] = beginTime.Month + "月";
90 103
                             drNew["日期"] = "总计";
91
-                            drNew["总数"] = dtRow.Length;
104
+                            //drNew["总数"] = dtRow.Length;
105
+                            drNew["总数"] = listByTime.Count();
92 106
                             drNew["Count"] = DayCount.ToString();
93 107
                             dtNew.Rows.Add(drNew);
94 108
                         }
@@ -111,10 +125,11 @@ namespace CallCenterApi.Interface.Controllers.report
111 125
             return res;
112 126
         }
113 127
 
114
-        private DataTable GetData(string years)
128
+        private DataTable GetData(string years, string dpt)
115 129
         {
116 130
             DataTable dtNew = new DataTable();
117
-            try {
131
+            try
132
+            {
118 133
                 #region
119 134
                 DataColumn dc1 = new DataColumn("月份", Type.GetType("System.String"));
120 135
                 DataColumn dc2 = new DataColumn("日期", Type.GetType("System.String"));
@@ -124,7 +139,13 @@ namespace CallCenterApi.Interface.Controllers.report
124 139
                 dtNew.Columns.Add(dc2);
125 140
                 dtNew.Columns.Add(dc3);
126 141
                 #endregion
127
-                DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
142
+                var sql = "";
143
+                if (dpt != null && dpt.Trim() != "")
144
+                {
145
+                    sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
146
+                }
147
+                //DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
148
+                var list = bll.DataTableToList(bll.GetList($" 1=1 {sql} ").Tables[0]);
128 149
                 DateTime dtNow;
129 150
                 int Count = 0;
130 151
                 int DayCount = 0;
@@ -144,21 +165,26 @@ namespace CallCenterApi.Interface.Controllers.report
144 165
 
145 166
                     DateTime beginTime = Convert.ToDateTime(dtNow.Year + "-" + i + "-01 00:00:00");
146 167
                     int days = DateTime.DaysInMonth(dtNow.Year, beginTime.Month);
147
-                    DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
148
-                    if (dtRow.Length > 0)
168
+                    //DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
169
+                    var listByTime = list.Where(x => x.BeginTime >= Convert.ToDateTime(beginTime.ToString()) && x.BeginTime < beginTime.AddDays(days).AddSeconds(-1));
170
+                    //if (dtRow.Length > 0)
171
+                    if (listByTime.Count() > 0)
149 172
                     {
150
-                        Count += dtRow.Length;
173
+                        //Count += dtRow.Length;
174
+                        Count += listByTime.Count();
151 175
                         for (int j = 1; j <= days; j++)
152 176
                         {
153 177
                             DataRow dr1 = dtNew.NewRow();
154
-                            if (dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length > 0)
178
+                            //if (dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length > 0)
179
+                            if (listByTime.Where(x => x.BeginTime >= beginTime.AddDays(j - 1) && x.BeginTime < beginTime.AddDays(j).AddSeconds(-1)).Count() > 0)
155 180
                             {
156 181
                                 DayCount += 1;
157 182
 
158 183
                                 dr1["月份"] = beginTime.Month + "月";
159 184
                                 dr1["日期"] = beginTime.AddDays(j - 1).ToShortDateString();
160
-                                dr1["总数"] = dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length;
161
-                               
185
+                                //dr1["总数"] = dtRow.CopyToDataTable().Select("begintime >='" + beginTime.AddDays(j - 1) + "' and  beginTime<'" + beginTime.AddDays(j).AddSeconds(-1) + "'").Length;
186
+                                dr1["总数"] = listByTime.Where(x => x.BeginTime >= beginTime.AddDays(j - 1) && x.BeginTime < beginTime.AddDays(j).AddSeconds(-1)).Count();
187
+
162 188
                                 dtNew.Rows.Add(dr1);
163 189
                             }
164 190
                         }
@@ -167,7 +193,8 @@ namespace CallCenterApi.Interface.Controllers.report
167 193
                         {
168 194
                             drNew["月份"] = beginTime.Month + "月";
169 195
                             drNew["日期"] = "总计";
170
-                            drNew["总数"] = dtRow.Length;
196
+                            //drNew["总数"] = dtRow.Length;
197
+                            drNew["总数"] = listByTime.Count();
171 198
                             dtNew.Rows.Add(drNew);
172 199
                         }
173 200
                         DayCount = 0;
@@ -188,13 +215,13 @@ namespace CallCenterApi.Interface.Controllers.report
188 215
             return dtNew;
189 216
         }
190 217
 
191
-        public ActionResult ExptList(string years)
218
+        public ActionResult ExptList(string years, string dpt)
192 219
         {
193 220
             ActionResult res = NoToken("未知错误,请重新登录");
194 221
             if (Request.IsAuthenticated)
195 222
             {
196 223
                 NPOIHelper npoi = new NPOIHelper();
197
-                DataTable dt = GetData(years);
224
+                DataTable dt = GetData(years, dpt);
198 225
                 if (npoi.ExportToExcel("总呼叫量数据", dt) == "")
199 226
                 {
200 227
                     return Success("导出成功");
@@ -208,14 +235,19 @@ namespace CallCenterApi.Interface.Controllers.report
208 235
         }
209 236
 
210 237
         //获取图形数据
211
-        public ActionResult GetChartData(string years)
238
+        public ActionResult GetChartData(string years, string dpt)
212 239
         {
213 240
             ActionResult res = NoToken("未知错误,请重新登录");
214 241
             if (Request.IsAuthenticated)
215 242
             {
216
-                string[] arr=new string[12];
217
-                
218
-                DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
243
+                string[] arr = new string[12];
244
+                var sql = "";   // and ISNULL(groupcode,'') != '' 
245
+                if (dpt != null && dpt.Trim() != "")
246
+                {
247
+                    sql += $" AND UserCode IN (SELECT F_UserCode FROM dbo.T_Sys_UserAccount WHERE F_DeptId = {dpt} AND f_seatFlag=1 and F_WorkNumber!='') ";
248
+                }
249
+                //DataTable dt = new BLL.T_Call_CallRecords().GetList("1=1").Tables[0];
250
+                var list = bll.DataTableToList(bll.GetList($" 1=1 {sql} ").Tables[0]);
219 251
                 DateTime dtNow;
220 252
 
221 253
                 if (string.IsNullOrEmpty(years))
@@ -230,14 +262,18 @@ namespace CallCenterApi.Interface.Controllers.report
230 262
                 {
231 263
                     DateTime beginTime = Convert.ToDateTime(dtNow.Year + "-" + i + "-01 00:00:00");
232 264
                     int days = DateTime.DaysInMonth(dtNow.Year, beginTime.Month);
233
-                    DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
234
-                    if (dtRow.Length > 0)
265
+                    //DataRow[] dtRow = dt.Select("begintime >='" + beginTime.ToString() + "' and  beginTime<'" + beginTime.AddDays(days).AddSeconds(-1) + "'");
266
+                    var listByTime = list.Where(x => x.BeginTime >= Convert.ToDateTime(beginTime.ToString()) && x.BeginTime < beginTime.AddDays(days).AddSeconds(-1));
267
+
268
+                    //if (dtRow.Length > 0)
269
+                    if (listByTime.Count() > 0)
235 270
                     {
236
-                        arr[i-1] = dtRow.Length.ToString();
271
+                        //arr[i-1] = dtRow.Length.ToString();
272
+                        arr[i - 1] = listByTime.Count().ToString();
237 273
                     }
238 274
                     else
239 275
                     {
240
-                        arr[i-1] = "0";
276
+                        arr[i - 1] = "0";
241 277
                     }
242 278
                 }
243 279