Parcourir la Source

首页统计优化

lihai il y a 6 ans
Parent
commit
bd23c08cd7

+ 26 - 15
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IndexController.cs

175
                     string strDate = date.ToString("yyyy-MM-dd");
175
                     string strDate = date.ToString("yyyy-MM-dd");
176
                     string strMonth = date.ToString("yyyy-MM");
176
                     string strMonth = date.ToString("yyyy-MM");
177
 
177
 
178
-                    string uwhere = " 1=1 and ISNULL(groupcode,'') != '' ";
178
+                    string uwhere = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '"+ strMonth + "' ";
179
                     if (roleid != 17)
179
                     if (roleid != 17)
180
                     {
180
                     {
181
                         uwhere += " and UserCode='" + usercode + "' ";
181
                         uwhere += " and UserCode='" + usercode + "' ";
210
                     ////未接来电    
210
                     ////未接来电    
211
                     //int daynocon = bll.GetRecordCount("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ");
211
                     //int daynocon = bll.GetRecordCount("CallType='0' and CONVERT(varchar(100),BeginTime, 23)='" + strDate + "' ");
212
 
212
 
213
-                    DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,TalkLongTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
213
+                    DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,groupcode,UserCode,ISNULL(TalkLongTime,0) AS TalkLongTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
214
 
214
 
215
                     // 今日来电
215
                     // 今日来电
216
                     var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
216
                     var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
286
                         //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
286
                         //var list3 = bll.GetList(" F_USERID='" + userId + "' and CONVERT(char(7),F_CREATEDATE,20)='" + strMonth + "' and F_WORKORDERSTATEID in (0,8) ").Tables[0];
287
                         //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];
287
                         //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];
288
 
288
 
289
-                        string uwhere = " 1=1 ";
289
+                        string uwhere = " 1=1 AND CONVERT(char(7),CreateTime,20) = '" + strMonth + "'";
290
                         if (ua.F_RoleId != 17)
290
                         if (ua.F_RoleId != 17)
291
                         {
291
                         {
292
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
292
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
307
                         ////月未完成
307
                         ////月未完成
308
                         //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State=0 and IsDel=0 ").Tables[0];
308
                         //var list4 = bll.GetList(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State=0 and IsDel=0 ").Tables[0];
309
 
309
 
310
+                        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];
311
+                        
310
                         //日已完成
312
                         //日已完成
311
-                        int list1_count = bll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State =1 and IsDel=0 ");
313
+                        int list1_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and State = 1 and IsDel = 0").Count();
312
                         //日未完成
314
                         //日未完成
313
-                        int list2_count = bll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + strDate + "' and State=0 and IsDel=0 ");
315
+                        int list2_count = dtConnect.Select(" yearmonthdays = '" + strDate + "' and State=0 and IsDel=0 ").Count();
314
                         //月已完成
316
                         //月已完成
315
-                        var list3_count = bll.GetRecordCount(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State =1 and IsDel=0 ");
317
+                        var list3_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and State =1 and IsDel=0 ").Count();
316
                         //月未完成
318
                         //月未完成
317
-                        var list4_count = bll.GetRecordCount(uwhere + " and CONVERT(char(7),CreateTime,20)='" + strMonth + "' and State=0 and IsDel=0 ");
319
+                        var list4_count = dtConnect.Select(" yearmonths = '" + strMonth + "' and State=0 and IsDel=0").Count();
318
 
320
 
319
                         var obj = new
321
                         var obj = new
320
                         {
322
                         {
351
                 {
353
                 {
352
                     var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
354
                     var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
353
                     string strDate = date.ToString("yyyy-MM-dd");
355
                     string strDate = date.ToString("yyyy-MM-dd");
356
+                    string strMonth = date.ToString("yyyy-MM");
354
 
357
 
355
                     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" };
358
                     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" };
356
 
359
 
357
-                    string uwhere = " 1=1 and ISNULL(groupcode,'')!= '' ";
360
+                    string uwhere = " 1=1 and ISNULL(groupcode,'')!= '' AND CONVERT(char(7),BeginTime,20) = '" + strMonth + "' ";
358
                     if (roleid != 17)
361
                     if (roleid != 17)
359
                     {
362
                     {
360
                         uwhere += " and UserCode='" + usercode + "' ";
363
                         uwhere += " and UserCode='" + usercode + "' ";
364
                         uwhere += " and CONVERT(varchar(11),BeginTime, 120) = '" + strDate + "' ";
367
                         uwhere += " and CONVERT(varchar(11),BeginTime, 120) = '" + strDate + "' ";
365
 
368
 
366
                     DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(13),BeginTime, 120) AS yearmonths,CallState,BeginTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
369
                     DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(13),BeginTime, 120) AS yearmonths,CallState,BeginTime FROM T_Call_CallRecords WITH(NOLOCK) where " + uwhere + "").Tables[0];
367
-
370
+                    
368
                     BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
371
                     BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
369
                     int[] total = new int[24];
372
                     int[] total = new int[24];
370
                     int[] count = new int[24];
373
                     int[] count = new int[24];
411
                     {
414
                     {
412
                         var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
415
                         var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
413
                         string strDate = date.ToString("yyyy-MM");
416
                         string strDate = date.ToString("yyyy-MM");
417
+                        //string strMonth = date.ToString("yyyy-MM");
414
 
418
 
415
                         int days = DateTime.DaysInMonth(date.Year, date.Month);
419
                         int days = DateTime.DaysInMonth(date.Year, date.Month);
416
 
420
 
425
                         int[] teltotal = new int[days];
429
                         int[] teltotal = new int[days];
426
                         int[] worktotal = new int[days];
430
                         int[] worktotal = new int[days];
427
 
431
 
428
-                        string uwhere = " 1=1 ";
429
-                        string u1where = " 1=1 and ISNULL(groupcode,'') != '' ";
432
+                        string uwhere = " 1=1  AND CONVERT(char(7),CreateTime,20) = '" + strDate + "' ";
433
+                        string u1where = " 1=1 and ISNULL(groupcode,'') != '' AND CONVERT(char(7),BeginTime,20) = '" + strDate + "' ";
430
                         if (ua.F_RoleId != 17)
434
                         if (ua.F_RoleId != 17)
431
                         {
435
                         {
432
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
436
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
433
                             u1where += " and UserCode='" + ua.F_UserCode + "' ";
437
                             u1where += " and UserCode='" + ua.F_UserCode + "' ";
434
                         }
438
                         }
435
 
439
 
440
+                        DataTable dtConnect = DbHelperSQL.Query("select CONVERT(varchar(10),BeginTime, 23) AS yearmonthdays,CONVERT(char(7),BeginTime,20) AS yearmonths,CallType,BeginTime,groupcode,UserCode FROM T_Call_CallRecords WITH(NOLOCK) where " + u1where + "").Tables[0];
441
+                        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];
442
+
436
                         for (int i = 0; i < cols.Count; i++)
443
                         for (int i = 0; i < cols.Count; i++)
437
                         {
444
                         {
438
                             //var tellist = telbll.GetModelList(" UserId='" + userId + "' and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
445
                             //var tellist = telbll.GetModelList(" UserId='" + userId + "' and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
439
-                            var tellist = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
440
-                            teltotal[i] = tellist.Count;
441
-                            newcount = newcount + tellist.Count;
446
+                            
447
+                            //var tellist = telbll.GetModelList(u1where + " and CONVERT(varchar(10),BeginTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
448
+                            int tellist_Count = dtConnect.Select("yearmonthdays = '" +(strDate + "-" + cols[i]) + "'").Count();
449
+                            teltotal[i] = tellist_Count;
450
+                            newcount = newcount + tellist_Count;
451
+
442
                             //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
452
                             //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
443
                             //var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
453
                             //var worklist = workbll.GetList(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
444
-                            int worklist_count = workbll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
454
+                            //int worklist_count = workbll.GetRecordCount(uwhere + " and CONVERT(varchar(10),CreateTime, 23)='" + (strDate + "-" + cols[i]) + "' ");
455
+                            int worklist_count = dtConnect_Wo.Select("yearmonthdays = '" + (strDate + "-" + cols[i]) + "'").Count();
445
                             //worktotal[i] = worklist.Rows.Count;
456
                             //worktotal[i] = worklist.Rows.Count;
446
                             worktotal[i] = worklist_count;
457
                             worktotal[i] = worklist_count;
447
                         }
458
                         }

BIN
数据库/CallCenter_Anto20191023.rar