zhoufan лет назад: 8
Родитель
Сommit
f4e2fef18b

+ 268 - 114
API/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/InfoController.cs

@@ -12,182 +12,319 @@ namespace CallCenterApi.Interface.Controllers
12 12
     public class InfoController : BaseController
13 13
     {
14 14
         private BLL.T_Bus_WorkOrder workOrderBLL = new BLL.T_Bus_WorkOrder();
15
+        private BLL.T_Call_CallRecords callBLL = new BLL.T_Call_CallRecords();
15 16
         private BLL.T_RegionCategory regionCategoryBLL = new BLL.T_RegionCategory();
16 17
         private BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
17 18
         private BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
18 19
         #region 
19 20
         //来源渠道情况
20
-        public ActionResult GetByQD()
21
+        public ActionResult GetSourceInfo()
21 22
         {
22
-            var dt1 = Getslqd24();
23
-            var dt2 = GetArea();
24
-            var dt3 = GetArea24();
25
-
26
-
27
-            return Success("加载成功", new
23
+            var obj = new
28 24
             {
29
-                a = dt1,
30
-                b = dt2,
31
-                c = dt3
32
-            });
25
+                a= GetSourceCount(),
26
+                b= GetAreaCount(),
27
+                c= GetAreaCount24()
28
+            };
29
+
30
+            return Success("加载成功", obj);
33 31
         }
34 32
 
35 33
         //接单部门情况
36
-        public ActionResult GetByDept()
34
+        public ActionResult GetDeptInfo()
37 35
         {
38
-            var dt1 = GetJD();
39
-            var dt2 = Getdpt();
40
-            var dt3 = GetGDCL();
36
+            var obj = new
37
+            {
38
+                a = GetStateCountMonth(),
39
+                b = GetDeptCount(),
40
+                c = GetDealCount24()
41
+            };
41 42
 
43
+            return Success("加载成功", obj);
44
+        }
42 45
 
43
-            return Success("加载成功", new
46
+        //投诉举报情况
47
+        public ActionResult GetTypeInfo()
48
+        {
49
+            var obj = new
44 50
             {
45
-                a = dt1,
46
-                b = dt2,
47
-                c = dt3
48
-            });
51
+                a = GetTypeCountMonth(),
52
+                b = GetTypeCount24(),
53
+                c = GetKeyCount()
54
+            };
55
+
56
+            return Success("加载成功", obj);
49 57
         }
58
+        //话务数量情况
59
+        //中心大数据
60
+        public ActionResult GetCenterInfo()
61
+        {
62
+            var obj = new
63
+            {
64
+                a = GetTypeCount(),
65
+                b = GetTypeCount24(),
66
+                c = GetKeyCount()
67
+            };
50 68
 
51
-        //投诉举报情况
69
+            return Success("加载成功", obj);
70
+        }
71
+        //服务知识
52 72
         #endregion
53 73
 
54 74
         #region 1.来源渠道情况
55 75
         //受理渠道24小时实时统计
56
-        private object Getslqd24()
76
+        private object GetSourceCount()
57 77
         {
58
-            DataTable dt = DbHelperSQL.Query(" select F_Value,(select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_RegDate,getdate())=0 and F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 and T_Bus_WorkOrder.F_InfoSource=T_Sys_DictionaryValue.F_ValueId) F_Count from dbo.T_Sys_DictionaryValue where F_ItemId=6").Tables[0];
78
+            string sql = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_RegDate,getdate())=0 and F_IsDelete=0 "
79
+                + " and isnull(F_InfoConSmallType,0)!=0 and F_InfoSource=F_ValueId) Count from  dbo.T_Sys_DictionaryValue where F_ItemId=6 ";
80
+            DataTable dt = DbHelperSQL.Query(sql).Tables[0];
59 81
 
60 82
             return dt;
61 83
         }
62 84
         //受理区域统计
63
-        private object GetArea()
85
+        private object GetAreaCount()
64 86
         {
65
-            DataTable dt = DbHelperSQL.Query(" select F_AreaName,(select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_RegDate,getdate())=0 and F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 and T_Bus_WorkOrder.F_SourceArea=T_Sys_Area.F_AreaId) F_Count from dbo.T_Sys_Area").Tables[0];
87
+            string sql = " select F_AreaName AreaName,(select COUNT(1) from T_Bus_WorkOrder where datediff(day,F_RegDate,getdate())=0 and F_IsDelete=0 "
88
+                + "and isnull(F_InfoConSmallType,0)!=0 and F_SourceArea=F_AreaId) Count from dbo.T_Sys_Area ";
89
+            DataTable dt = DbHelperSQL.Query(sql).Tables[0];
66 90
 
67 91
             return dt;
68 92
         }
69 93
         //受理区域统计(按小时统计)
70
-        private object GetArea24()
94
+        private object GetAreaCount24()
71 95
         {
72
-            DataTable dt = DbHelperSQL.Query(" select datepart(hh,F_RegDate) hor,F_SourceArea, count(1) con from T_Bus_WorkOrder where F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and datediff(day, F_RegDate, getdate()) = 0 group by datepart(hh, F_RegDate), F_SourceArea").Tables[0];
73 96
             var areaList = new BLL.T_Sys_Area().GetModelList(" 1=1 ");
74 97
 
75
-            int[] times = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
76
-            var query3 = times.Select(x => new
98
+            int[] hours = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
99
+
100
+            var obj = new {
101
+                hours = hours,
102
+                cols = areaList.Select(p => p.F_AreaName),
103
+                counts = new List<int[]>()
104
+            };
105
+            foreach (var area in areaList)
77 106
             {
78
-                Time = x,
79
-                Arealist = areaList.Select(z =>
107
+                int[] count = new int[24];
108
+                for (int i = 0; i < hours.Length; i++)
80 109
                 {
81
-                    var con = dt.Select(" hor=" + x.ToString() + " and F_SourceArea='" + z.F_AreaId + "'")[0]["con"].ToString();
82
-                    if (string.IsNullOrEmpty(con))
83
-                    {
84
-                        con = "0";
85
-                    }
86
-                    return new
87
-                    {
88
-                        Area = z.F_AreaName,
89
-                        Count = con,
90
-                        Sort = z.F_Sort
91
-                    };
92
-                }).OrderBy(z => z.Sort)
93
-            });
94
-
95
-            return query3;
110
+                    var list = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 "
111
+                        +" and datediff(day, F_RegDate, getdate()) = 0 and datepart(hh, F_RegDate)=" + hours[i]);
112
+                    count[i] = list.Count;
113
+                }
114
+                obj.counts.Add(count);
115
+            }
116
+
117
+            return obj;
96 118
         }
97 119
 
98 120
         #endregion
99 121
 
100 122
         #region 2.接单部门情况
101 123
         //接单情况汇总(月份)
102
-        private object GetJD()
124
+        private object GetStateCountMonth()
103 125
         {
104
-            DataTable dt = DbHelperSQL.Query(" select datepart(month,F_RegDate) mon,F_InfoConSmallType, count(1) con from T_Bus_WorkOrder where F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and datediff(month,F_RegDate,getdate())<=12 group by datepart(month, F_RegDate), F_InfoConSmallType").Tables[0];
105
-            
106
-            string ids = string.Empty;
107
-            var list = dicValueBLL.GetModelList(" F_ItemId=2 ");
108
-            foreach (var l in list)
126
+            var stateList = dicValueBLL.GetModelList(" F_ItemId = 5 ");
127
+            int[] ints = new int[12];
128
+            string[] months = new string[12];
129
+            for (int i = 12; i > 0; i--)
109 130
             {
110
-                var slist = dicValueBLL.GetModelList(" F_PrentId='" + l.F_ValueId + "' ");
111
-                foreach (var sl in slist)
112
-                {
113
-                    var tlist = dicValueBLL.GetModelList(" F_PrentId='" + sl.F_ValueId + "' ");
114
-                    foreach (var tl in tlist)
115
-                    {
116
-                        if (string.IsNullOrEmpty(ids))
117
-                        {
118
-                            ids = tl.F_ValueId.ToString();
119
-                        }
120
-                        else
121
-                        {
122
-                            ids= ids+"," + tl.F_ValueId.ToString();
123
-                        }
124
-                    }
125
-                }
131
+                var date = DateTime.Now.AddMonths(1 - i);
132
+                string mon = date.ToString("yyyyMM");
133
+                months[12 - i] = mon;
134
+                ints[12 - i] = date.Month;
126 135
             }
127
-            var tsList = dicValueBLL.GetModelList(" F_ValueId in (" + ids + ")");
128
-            int[] months = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
129
-            var query3 = months.Select(x => new
136
+
137
+            var obj = new
138
+            {
139
+                months = months,
140
+                cols = stateList.Select(p => p.F_Value),
141
+                counts = new List<int[]>()
142
+            };
143
+
144
+            foreach (var state in stateList)
130 145
             {
131
-                Month = DateTime.Now.AddMonths(x - 1).ToString("yyyyMM"),
132
-                TSList = tsList.Select(z =>
146
+                int[] count = new int[12];
147
+                for (int i = 0; i < ints.Length; i++)
133 148
                 {
134
-                    var con = dt.Select(" mon=" + DateTime.Now.AddMonths(x - 1).Month + " and F_InfoConSmallType='" + z.F_ValueId + "'")[0]["con"].ToString();
135
-                    if (string.IsNullOrEmpty(con))
136
-                    {
137
-                        con = "0";
138
-                    }
139
-                    return new
140
-                    {
141
-                        tsname = z.F_Value,
142
-                        Count = con
143
-                    };
144
-                }).OrderBy(z => z.tsname)
145
-            });
149
+                    var list = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and "
150
+                        + "datediff(month,F_RegDate,getdate())<=12 and datepart(month, F_RegDate)=" + ints[i]);
151
+                    count[i] = list.Count;
152
+                }
153
+                obj.counts.Add(count);
154
+            }
146 155
 
147
-            return query3;
156
+            return obj;
148 157
         }
149 158
 
150 159
         //各部门受理工单情况
151
-        private object Getdpt()
160
+        private object GetDeptCount()
152 161
         {
153
-            DataTable dt = DbHelperSQL.Query("select F_DeptName,(select COUNT(1) from T_Wo_WorkOrder where  IsDel=0 and datediff(day,createtime,getdate())=0 and ResponDept=F_DeptId) con from T_Sys_Department where F_State=1").Tables[0];
162
+            var list = departmentBLL.GetModelList(" 1=1 ");
163
+            var obj = new
164
+            {
165
+                cols = list.Select(p => p.F_DeptName),
166
+                totals = new List<int[]>(),
167
+                counts = new List<int[]>(),
168
+                percents = new List<string[]>()
169
+            };
154 170
 
155
-            return dt;
171
+            int[] total = new int[list.Count];
172
+            int[] count = new int[list.Count];
173
+            string[] percent = new string[list.Count];
174
+
175
+            for (int i = 0; i < list.Count; i++)
176
+            {
177
+                var tl = workOrderBLL.GetModelList("F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 "
178
+                //+ " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where datediff(day,F_SubmitDate,getdate())=0 "
179
+                + " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where 1=1 "
180
+                + " and F_DeptId=" + list[i].F_DeptId + ")");
181
+                var cl = workOrderBLL.GetModelList("F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 "
182
+                //+ " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where datediff(day,F_SubmitDate,getdate())=0 "
183
+                + " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where 1=1 "
184
+                + " and F_State=1 and F_DeptId=" + list[i].F_DeptId + ")");
185
+
186
+                total[i] = tl.Count;
187
+                count[i] = cl.Count;
188
+                percent[i] = tl.Count > 0 ? ((double)cl.Count / tl.Count).ToString("0.00%") : "-";
189
+            }
190
+
191
+            obj.totals.Add(total);
192
+            obj.counts.Add(count);
193
+            obj.percents.Add(percent);
194
+
195
+            return obj;
156 196
         }
157 197
 
158 198
         //工单处理时间分布(小时)
159
-        private object GetGDCL()
199
+        private object GetDealCount24()
160 200
         {
161
-            DataTable dt = DbHelperSQL.Query("select datepart(hh,CreateTime) hor,TypeClass, count(1) con from T_Wo_WorkOrder where IsDel = 0 and datediff(day,createtime,getdate())=0 group by datepart(hh, CreateTime), TypeClass").Tables[0];
162
-            //var tsList = dicValueBLL.DataTableToList(dicValueBLL.GetList(" F_DictionaryFlag='TSLX'  and F_State=1  ").Tables[0]);
163
-
164
-            //int[] times = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
165
-            //var query3 = times.Select(x => new
166
-            //{
167
-            //    Time = x,
168
-            //    TSList = tsList.Select(z =>
169
-            //    {
170
-            //        var con = dt.Select(" hor=" + x.ToString() + " and TypeClass='" + z.F_DictionaryValueId + "'")[0]["con"].ToString();
171
-            //        if (string.IsNullOrEmpty(con))
172
-            //        {
173
-            //            con = "0";
174
-            //        }
175
-            //        return new
176
-            //        {
177
-            //            tsname = z.F_Name,
178
-            //            Count = con
179
-            //        };
180
-            //    }).OrderBy(z => z.tsname)
181
-            //});
201
+            int[] hours = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
202
+            int[] acounts = new int[24];
203
+            int[] fcounts = new int[24];
182 204
 
183
-            return dt;
205
+            for (int i = 0; i < hours.Count(); i++)
206
+            {
207
+                var al = workOrderBLL.GetModelList("F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 "
208
+                    + " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where datediff(day,F_SubmitDate,getdate())=0 "
209
+                    + " and datepart(hh, F_SubmitDate)=" + hours[i] + ")");
210
+                var fl = workOrderBLL.GetModelList("F_IsDelete=0 and isnull(F_InfoConSmallType,0)!=0 "
211
+                    + " and F_WorkOrderID in (select F_WorkOrderID from T_Bus_AssignedInfo where datediff(day,F_EndDate,getdate())=0 "
212
+                    + " and F_State=1 and datepart(hh, F_EndDate)=" + hours[i] + ")");
213
+                acounts[i] = al.Count;
214
+                fcounts[i] = fl.Count;
215
+            }
216
+
217
+            var obj = new
218
+            {
219
+                hours = hours,
220
+                acounts = acounts,
221
+                fcounts = fcounts
222
+            };
223
+
224
+            return obj;
184 225
         }
185 226
         #endregion
186 227
 
187 228
         #region 3.投诉举报情况
188
-        //投诉/举报汇总
189
-        //举报单位/个人统计
229
+        //投诉类型统计(月份)
230
+        private object GetTypeCountMonth()
231
+        {
232
+            int[] ints = new int[12];
233
+            string[] months = new string[12];
234
+            for (int i = 12; i > 0; i--)
235
+            {
236
+                var date = DateTime.Now.AddMonths(1 - i);
237
+                string mon = date.ToString("yyyyMM");
238
+                months[12 - i] = mon;
239
+                ints[12 - i] = date.Month;
240
+            }
241
+
242
+            var typelist = dicValueBLL.GetModelList(" F_ItemId=2 ");
243
+            var obj = new
244
+            {
245
+                months= months,
246
+                cols = typelist.Select(p => p.F_Value),
247
+                counts = new List<int[]>(),
248
+            };
249
+
250
+            foreach (var l in typelist)
251
+            {
252
+                int[] count = new int[12];
253
+                for (int i = 0; i < ints.Length; i++)
254
+                {
255
+                    var list = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and F_InfoType="+l.F_ValueId
256
+                        + " and datediff(month,F_RegDate,getdate())<=12 and datepart(month, F_RegDate)=" + ints[i]);
257
+                    count[i] = list.Count;
258
+                }
259
+                obj.counts.Add(count);
260
+            }
261
+
262
+            return obj;
263
+        }
264
+        //工单处理时间分布(小时)
265
+        private object GetTypeCount24()
266
+        {
267
+            int[] hours = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 };
268
+            var typelist = dicValueBLL.GetModelList(" F_ItemId=2 ");
269
+            var obj = new
270
+            {
271
+                hours = hours,
272
+                cols = typelist.Select(p => p.F_Value),
273
+                counts = new List<int[]>()
274
+            };
275
+
276
+            foreach (var l in typelist)
277
+            {
278
+                int[] count = new int[24];
279
+                for (int i = 0; i < hours.Length; i++)
280
+                {
281
+                    var list = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and F_InfoType=" + l.F_ValueId
282
+                        + " and datediff(day,F_RegDate,getdate())=0 and datepart(hh, F_RegDate)=" + hours[i]);
283
+                    count[i] = list.Count;
284
+                }
285
+                obj.counts.Add(count);
286
+            }
287
+
288
+            return obj;
289
+        }
190 290
         //投诉关键字统计
291
+        private object GetKeyCount()
292
+        {
293
+            string ids = string.Empty;
294
+            var list = dicValueBLL.GetModelList(" F_PrentId=6 ");
295
+            foreach (var l in list)
296
+            {
297
+                var slist = dicValueBLL.GetModelList(" F_PrentId= " + l.F_ValueId);
298
+                foreach (var sl in slist)
299
+                {
300
+                    if (string.IsNullOrEmpty(ids))
301
+                    {
302
+                        ids = sl.F_ValueId.ToString();
303
+                    }
304
+                    else
305
+                    {
306
+                        ids= ids+","+ sl.F_ValueId.ToString();
307
+                    }
308
+                }
309
+            }
310
+
311
+            var typelist = dicValueBLL.GetModelList(" F_ValueId in (" + ids + ") ");
312
+
313
+            int[] counts = new int[typelist.Count];
314
+
315
+            for (int i = 0; i < typelist.Count; i++)
316
+            {
317
+                var slist = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and F_InfoConSmallType=" + typelist[i].F_ValueId);
318
+                counts[i] = slist.Count;
319
+            }
320
+            var obj = new
321
+            {
322
+                cols = typelist.Select(p => p.F_Value),
323
+                counts = counts
324
+            };
325
+            return obj;
326
+        }
327
+        //举报单位/个人统计
191 328
         //投诉单位统计
192 329
         //举报关键字统计
193 330
         #endregion
@@ -201,6 +338,23 @@ namespace CallCenterApi.Interface.Controllers
201 338
 
202 339
         #region 5.中心大数据
203 340
         //工单类型各数量
341
+        private object GetTypeCount()
342
+        {
343
+            var typelist = dicValueBLL.GetModelList(" F_ItemId=2 ");
344
+            int[] counts = new int[typelist.Count];
345
+
346
+            for (int i = 0; i < typelist.Count; i++)
347
+            {
348
+                var list = workOrderBLL.GetModelList("F_IsDelete = 0 and isnull(F_InfoConSmallType,0)!=0 and F_InfoType=" + typelist[i].F_ValueId);
349
+                counts[i] = list.Count;
350
+            }
351
+            var obj = new
352
+            {
353
+                cols = typelist.Select(p => p.F_Value),
354
+                counts = counts
355
+            };
356
+            return obj;
357
+        }
204 358
         //接通率统计源
205 359
         //投诉举报关键话题排名
206 360
         //通话数量统计