Przeglądaj źródła

首页统计优化

lihai 6 lat temu
rodzic
commit
bd23c08cd7

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

@@ -175,7 +175,7 @@ namespace CallCenterApi.Interface.Controllers
175 175
                     string strDate = date.ToString("yyyy-MM-dd");
176 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 179
                     if (roleid != 17)
180 180
                     {
181 181
                         uwhere += " and UserCode='" + usercode + "' ";
@@ -210,7 +210,7 @@ namespace CallCenterApi.Interface.Controllers
210 210
                     ////未接来电    
211 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 216
                     var dayinlist = dtConnect.Select("CallType='0' and yearmonthdays = '" + strDate + "'").Count();
@@ -286,7 +286,7 @@ namespace CallCenterApi.Interface.Controllers
286 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 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 290
                         if (ua.F_RoleId != 17)
291 291
                         {
292 292
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
@@ -307,14 +307,16 @@ namespace CallCenterApi.Interface.Controllers
307 307
                         ////月未完成
308 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 321
                         var obj = new
320 322
                         {
@@ -351,10 +353,11 @@ namespace CallCenterApi.Interface.Controllers
351 353
                 {
352 354
                     var date = DateTime.Now;//DateTime.Parse("2014-05-05"); //
353 355
                     string strDate = date.ToString("yyyy-MM-dd");
356
+                    string strMonth = date.ToString("yyyy-MM");
354 357
 
355 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 361
                     if (roleid != 17)
359 362
                     {
360 363
                         uwhere += " and UserCode='" + usercode + "' ";
@@ -364,7 +367,7 @@ namespace CallCenterApi.Interface.Controllers
364 367
                         uwhere += " and CONVERT(varchar(11),BeginTime, 120) = '" + strDate + "' ";
365 368
 
366 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 371
                     BLL.T_Call_CallRecords bll = new BLL.T_Call_CallRecords();
369 372
                     int[] total = new int[24];
370 373
                     int[] count = new int[24];
@@ -411,6 +414,7 @@ namespace CallCenterApi.Interface.Controllers
411 414
                     {
412 415
                         var date = DateTime.Now;//DateTime.Parse("2015-04-05"); //
413 416
                         string strDate = date.ToString("yyyy-MM");
417
+                        //string strMonth = date.ToString("yyyy-MM");
414 418
 
415 419
                         int days = DateTime.DaysInMonth(date.Year, date.Month);
416 420
 
@@ -425,23 +429,30 @@ namespace CallCenterApi.Interface.Controllers
425 429
                         int[] teltotal = new int[days];
426 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 434
                         if (ua.F_RoleId != 17)
431 435
                         {
432 436
                             uwhere += " and CreateUser='" + ua.F_UserCode + "' ";
433 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 443
                         for (int i = 0; i < cols.Count; i++)
437 444
                         {
438 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 452
                             //var worklist = workbll.GetList(" F_USERID='" + userId + "' and CONVERT(varchar(10),F_CREATEDATE, 23)='" + (strDate + "-" + cols[i]) + "' ").Tables[0];
443 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 456
                             //worktotal[i] = worklist.Rows.Count;
446 457
                             worktotal[i] = worklist_count;
447 458
                         }

BIN
数据库/CallCenter_Anto20191023.rar