yuqian лет назад: 8
Родитель
Сommit
b12b77b3aa

+ 7 - 0
CallCenterApi/CallCenterApi.BLL/T_Call_PageField.cs

@@ -38,6 +38,13 @@ namespace CallCenterApi.BLL
38 38
         {
39 39
             return dal.Update(model);
40 40
         }
41
+        /// <summary>
42
+        /// 更新多条数据
43
+        /// </summary>
44
+        public bool UpdateByTaskId(long taskId)
45
+        {
46
+            return dal.UpdateByTaskId(taskId);
47
+        }
41 48
 
42 49
         /// <summary>
43 50
         /// 删除一条数据

+ 1 - 0
CallCenterApi/CallCenterApi.BLL/T_Call_TaskTelNum.cs

@@ -388,6 +388,7 @@ namespace CallCenterApi.BLL
388 388
                 for (int n = 0; n < rowsCount; n++)
389 389
                 {
390 390
                     model = new CallCenterApi.Model.T_Call_TaskTelNum();
391
+                    model.F_Id = Convert.ToInt32(dt.Rows[n]["F_Id"]);
391 392
                     model.TaskName = dt.Rows[n]["TaskName"] == DBNull.Value ? "" : dt.Rows[n]["TaskName"].ToString();
392 393
                     model.F_Phone = dt.Rows[n]["F_Phone"] == DBNull.Value ? "" : dt.Rows[n]["F_Phone"].ToString();
393 394
                     model.F_HCState = dt.Rows[n]["F_HCState"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[n]["F_HCState"].ToString());

+ 19 - 0
CallCenterApi/CallCenterApi.DAL/T_Call_PageField.cs

@@ -104,6 +104,25 @@ namespace CallCenterApi.DAL
104 104
             }
105 105
         }
106 106
 
107
+
108
+        /// <summary>
109
+        /// 更新多条数据
110
+        /// </summary>
111
+        public bool UpdateByTaskId(long taskId)
112
+        {
113
+            StringBuilder strSql = new StringBuilder();
114
+            strSql.Append("UPDATE  T_Call_PageField set F_TaskId=@F_TaskId WHERE  F_TaskId=-1");
115
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), new SqlParameter("@F_TaskId", taskId));
116
+            if (rows > 0)
117
+            {
118
+                return true;
119
+            }
120
+            else
121
+            {
122
+                return false;
123
+            }
124
+        }
125
+
107 126
         /// <summary>
108 127
         /// 删除一条数据
109 128
         /// </summary>

+ 1 - 1
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/App_Start/AuthorizeAttribute.cs

@@ -62,7 +62,7 @@ namespace CallCenterApi.Interface
62 62
             //    WriteLog(filterContext);
63 63
             //}
64 64
             //else {
65
-                base.OnAuthorization(filterContext);
65
+            base.OnAuthorization(filterContext);
66 66
             //}
67 67
         }
68 68
         private void WriteLog(AuthorizationContext filterContext)

+ 2 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/Base/BaseController.cs

@@ -10,7 +10,7 @@ namespace CallCenterApi.Interface.Controllers.Base
10 10
 {
11 11
     public class BaseController : Controller
12 12
     {
13
-        public new FormsPrincipal<Cache.Models.CurrentUserInfo> CurrentUser
13
+        public FormsPrincipal<Cache.Models.CurrentUserInfo> CurrentUser
14 14
         {
15 15
             get
16 16
             {
@@ -45,7 +45,7 @@ namespace CallCenterApi.Interface.Controllers.Base
45 45
         /// <returns></returns>
46 46
         protected virtual ActionResult Success(string message, object data)
47 47
         {
48
-            var jsonMsg = new AjaxResult { state = ResultTypes.success.ToString(), message = message,data=data }.ToJson();
48
+            var jsonMsg = new AjaxResult { state = ResultTypes.success.ToString(), message = message, data = data }.ToJson();
49 49
             FileLog.Info(jsonMsg);
50 50
             return Content(jsonMsg);
51 51
         }

+ 84 - 14
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/callout/CallPlanController.cs

@@ -29,7 +29,7 @@ namespace CallCenterApi.Interface.Controllers.callout
29 29
         private BLL.T_CTI_TaskPhonePart taskPhonePartBLL = new BLL.T_CTI_TaskPhonePart();
30 30
         private BLL.T_Sys_SeatGroup seatGroupBLL = new BLL.T_Sys_SeatGroup();
31 31
         private BLL.T_Sys_SystemConfig systemConfigBLL = new BLL.T_Sys_SystemConfig();
32
-
32
+        private BLL.T_Call_PageField pageFieldBLL = new BLL.T_Call_PageField();
33 33
         #region 外呼任务
34 34
         /// <summary>
35 35
         /// 获取列表
@@ -251,9 +251,12 @@ namespace CallCenterApi.Interface.Controllers.callout
251 251
                 var taskId = taskBLL.Add(model);
252 252
                 if (taskId > 0)
253 253
                 {
254
-                    // return Success("添加成功", i);
255 254
                     try
256 255
                     {
256
+                        pageFieldBLL.UpdateByTaskId(taskId);
257
+
258
+
259
+
257 260
                         model.TaskID = taskId;
258 261
                         DataTable dt = taskTellNumBLL.GetTableDesign();
259 262
                         switch (input.ImportType)
@@ -300,8 +303,24 @@ namespace CallCenterApi.Interface.Controllers.callout
300 303
                                 }
301 304
                                 break;
302 305
                             case 4: //从Excel中导入
306
+                                string[] strArr = input.SelectIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
307
+                                var idArr = strArr.Select(x => Convert.ToInt32(x)).ToArray();
308
+                                var fieldList = pageFieldBLL.DataTableToList(pageFieldBLL.GetList($"F_ID in ({string.Join(",", idArr)})").Tables[0]);
303 309
                                 NPOIHelper npoi = new NPOIHelper();
304
-                                var dtExcel = npoi.ExcelToTable(input.PhoneStr, 1);
310
+                                var dtExcel = npoi.ExcelToTable(input.FilePath, 0);
311
+                                for (int i = 0; i < dtExcel.Rows.Count; i++)
312
+                                {
313
+                                    var row = dt.NewRow();
314
+                                    for (int j = 0; j < dtExcel.Columns.Count; j++)
315
+                                    {
316
+                                        if (fieldList.Count < (j + 1))
317
+                                            break;
318
+                                        row["F_TaskId"] = model.TaskID;
319
+                                        var field = fieldList.SingleOrDefault(x => x.F_Id == idArr[j]);
320
+                                        row[field.F_DBFieldlName] = dtExcel.Rows[i][j];
321
+                                    }
322
+                                    dt.Rows.Add(row);
323
+                                }
305 324
                                 break;
306 325
                         }
307 326
                         if (input.CheckFilter1)
@@ -531,7 +550,7 @@ namespace CallCenterApi.Interface.Controllers.callout
531 550
                 sql += $" and F_YJState={filter.YJState} ";
532 551
             }
533 552
 
534
-            var field = "t.TaskName,F_Phone,F_FPState,F_HCState,F_YJState,F_Username,tn.F_CreateTime";
553
+            var field = "F_Id,t.TaskName,F_Phone,F_FPState,F_HCState,F_YJState,F_Username,tn.F_CreateTime";
535 554
             if (filter.TaskType == 2)
536 555
             {
537 556
                 field += " F_Phone,F_HCState,F_YJState";
@@ -572,12 +591,18 @@ namespace CallCenterApi.Interface.Controllers.callout
572 591
         /// <returns></returns>
573 592
         public ActionResult GetMyPhoneList(FilterCallPhone filter)
574 593
         {
575
-            //if (!Request.IsAuthenticated)
576
-            //    return NoToken("未知错误,请重新登录");
577
-            var model = taskBLL.GetModel(filter.Id);
578
-            if (model == null)
579
-                return Error("外呼任务不存在");
594
+            if (!Request.IsAuthenticated)
595
+                return NoToken("未知错误,请重新登录");
596
+
580 597
             var sql = "";
598
+            if (filter.Id > 0)
599
+            {
600
+                var model = taskBLL.GetModel(filter.Id);
601
+                sql += " and F_TaskId=" + filter.Id;
602
+                if (model == null)
603
+                    return Error("外呼任务不存在");
604
+            }
605
+
581 606
 
582 607
             sql += $" and F_UserId={CurrentUser.UserData.F_UserId} ";
583 608
             if (!string.IsNullOrWhiteSpace(filter.Phone))
@@ -597,7 +622,7 @@ namespace CallCenterApi.Interface.Controllers.callout
597 622
                 sql += $" and F_YJState={filter.YJState} ";
598 623
             }
599 624
 
600
-            var field = "t.TaskName,F_Phone,F_FPState,F_HCState,F_YJState,F_Username,tn.F_CreateTime";
625
+            var field = "F_Id,t.TaskName,F_Phone,F_FPState,F_HCState,F_YJState,F_Username,tn.F_CreateTime";
601 626
             if (filter.TaskType == 2)
602 627
             {
603 628
                 field += " F_Phone,F_HCState,F_YJState";
@@ -608,7 +633,7 @@ namespace CallCenterApi.Interface.Controllers.callout
608 633
                              " T_Call_TaskTelNum tn left join T_CTI_Task t on t.TaskID=tn.F_TaskId ",
609 634
                              " F_Id ",
610 635
                              field,
611
-                             " and F_TaskId=" + filter.Id + sql,
636
+                              sql,
612 637
                              "ORDER BY F_Id desc",
613 638
                              filter.PageSize,
614 639
                              filter.PageIndex,
@@ -619,6 +644,7 @@ namespace CallCenterApi.Interface.Controllers.callout
619 644
             {
620 645
                 rows = modelList.Select(x => new
621 646
                 {
647
+                    id = x.F_Id,
622 648
                     taskname = x.TaskName,
623 649
                     phone = x.F_Phone,
624 650
                     agent = string.IsNullOrWhiteSpace(x.F_UserName) ? "" : x.F_UserName,
@@ -643,6 +669,8 @@ namespace CallCenterApi.Interface.Controllers.callout
643 669
             //    return NoToken("未知错误,请重新登录");
644 670
             if (count <= 0)
645 671
                 return Error("参数错误");
672
+            if (id <= 0)
673
+                return Error("请选择外呼任务");
646 674
             var model = taskBLL.GetModel(id);
647 675
             if (model == null)
648 676
                 return Error("外呼任务不存在");
@@ -650,11 +678,53 @@ namespace CallCenterApi.Interface.Controllers.callout
650 678
             var sum = obj == null ? 0 : Convert.ToInt32(obj);
651 679
             if (sum >= 50)
652 680
                 return Error("请先完成已分配任务");
653
-            if (DbHelperSQL.ExecuteSql($"UPDATE T_Call_TaskTelNum SET F_FPState=1,F_UserId={CurrentUser.UserData.F_UserId} WHERE F_Id in(SELECT TOP({count}) F_Id FROM T_Call_TaskTelNum WHERE F_TaskId={id} and F_FPState=0)") > 0)
654
-                return Success("分配成功");
655
-            return Error("分配失败");
681
+            var res = DbHelperSQL.ExecuteSql($"UPDATE T_Call_TaskTelNum SET F_FPState=1,F_UserId={CurrentUser.UserData.F_UserId},F_Username='{CurrentUser.UserData.F_UserName}' WHERE F_Id in(SELECT TOP({count}) F_Id FROM T_Call_TaskTelNum WHERE F_TaskId={id} and F_FPState=0)");
682
+            if (res > 0)
683
+                return Success($"获取到{res}条可用号码");
684
+            return Error("未获取到可用号码");
685
+        }
686
+        public ActionResult GetMyCallPlan()
687
+        {
688
+            var taskList = taskBLL.DataTableToList(taskBLL.GetList("state=1").Tables[0]);
689
+            return Success("获取成功", taskList.Select(x => new
690
+            {
691
+                id = x.TaskID,
692
+                name = x.TaskName
693
+            }));
656 694
         }
695
+        public ActionResult GetCallNumDetail(int id)
696
+        {
697
+            var taskId = DbHelperSQL.GetSingle($"SELECT F_TaskId FROM T_Call_TaskTelNum WHERE F_ID={id}");
698
+            if (taskId == null || Convert.ToInt32(taskId) <= 0)
699
+                return Error("参数错误");
700
+            var fieldList = pageFieldBLL.DataTableToList(pageFieldBLL.GetList($"F_TaskId={taskId}").Tables[0]);
701
+            StringBuilder sb = new StringBuilder();
702
+            Dictionary<string, string> dicTitle = new Dictionary<string, string>();
703
+            foreach (var item in fieldList)
704
+            {
705
+                sb.Append(item.F_DBFieldlName + ",");
706
+                dicTitle.Add(item.F_DBFieldlName, item.F_Name);
707
+            }
708
+            if (!string.IsNullOrWhiteSpace(sb.ToString()))
709
+            {
710
+                var callNum = DbHelperSQL.Query($"SELECT {sb.ToString().Trim(',')} FROM T_Call_TaskTelNum WHERE F_ID={id}").Tables[0];
711
+                Dictionary<string, string> dic = new Dictionary<string, string>();
712
+                for (int j = 0; j < callNum.Columns.Count; j++)
713
+                {
714
+                    dic.Add(callNum.Columns[j].ColumnName, callNum.Rows[0][j].ToString());
715
+                }
716
+
657 717
 
718
+
719
+                return Success("获取成功", dic.Select(x => new
720
+                {
721
+                    field = x.Key,
722
+                    text = dicTitle[x.Key],
723
+                    value = x.Value
724
+                }));
725
+            }
726
+            return Success("");
727
+        }
658 728
         #endregion
659 729
 
660 730
         #region 导入导出号码

+ 57 - 22
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/callout/ExcelTmpController.cs

@@ -23,11 +23,7 @@ namespace CallCenterApi.Interface.Controllers.callout
23 23
         public ActionResult GetList(FilterExcelTmp filter)
24 24
         {
25 25
             string sql = " and F_DBTableName='T_Call_PageField' ";
26
-
27
-            if (filter.TaskId > 0)
28
-            {
29
-                sql += " and F_AttributeId not in (SELECT [F_FeildId] FROM [T_Call_PageField] where [F_TaskId]=" + filter.TaskId + ") ";
30
-            }
26
+            sql += " and F_AttributeId not in (SELECT [F_FeildId] FROM [T_Call_PageField] where [F_TaskId]=" + filter.TaskId + ") ";
31 27
             if (filter.Type > 0)
32 28
             {
33 29
                 sql += " and F_DBTypeName='" + filter.Type + "' ";
@@ -76,7 +72,7 @@ namespace CallCenterApi.Interface.Controllers.callout
76 72
             }
77 73
             else
78 74
             {
79
-                sql += " and [F_TaskId]=0 ";
75
+                sql += " and [F_TaskId]=-1 ";
80 76
             }
81 77
 
82 78
 
@@ -121,7 +117,7 @@ namespace CallCenterApi.Interface.Controllers.callout
121 117
             }
122 118
             else
123 119
             {
124
-                sql += "  [F_TaskId]=0 ";
120
+                sql += "  [F_TaskId]=-1 ";
125 121
             }
126 122
 
127 123
             var idList = pageFieldBLL.DataTableToListView(pageFieldBLL.GetListView(sql).Tables[0]);
@@ -133,6 +129,31 @@ namespace CallCenterApi.Interface.Controllers.callout
133 129
         }
134 130
 
135 131
         /// <summary>
132
+        /// 获取已选择的自定义字段
133
+        /// </summary>
134
+        /// <param name="filter"></param>
135
+        /// <returns></returns>
136
+        public ActionResult GetSelectedList(FilterExcelTmp filter)
137
+        {
138
+            var sql = "";
139
+            if (filter.TaskId > 0)
140
+            {
141
+                sql += "  [F_TaskId]=" + filter.TaskId + " ";
142
+            }
143
+            else
144
+            {
145
+                sql += "  [F_TaskId]=-1 ";
146
+            }
147
+
148
+            var idList = pageFieldBLL.DataTableToListView(pageFieldBLL.GetListView(sql).Tables[0]);
149
+            return Success("获取成功", idList.Select(x => new
150
+            {
151
+                id = x.F_Id,
152
+                name = x.F_Name
153
+            }));
154
+        }
155
+
156
+        /// <summary>
136 157
         /// 选择自定义字段
137 158
         /// </summary>
138 159
         /// <param name="ids"></param>
@@ -160,28 +181,42 @@ namespace CallCenterApi.Interface.Controllers.callout
160 181
             return Success("添加成功");
161 182
         }
162 183
 
184
+        ///// <summary>
185
+        ///// 去除自定义字段
186
+        ///// </summary>
187
+        ///// <param name="ids"></param>
188
+        ///// <returns></returns>
189
+        //public ActionResult Remove(int[] ids, int taskId)
190
+        //{
191
+        //    pageFieldBLL.DeleteByTaskId(taskId);
192
+        //    var sort = 0;
193
+        //    foreach (var id in ids)
194
+        //    {
195
+        //        var fieldmodel = formEntityAttrBLL.GetModel(id);
196
+        //        if (fieldmodel == null)
197
+        //            continue;
198
+        //        var itemmodel = new T_Call_PageField();
199
+        //        itemmodel.F_Name = fieldmodel.F_Name;
200
+        //        itemmodel.F_DBFieldlName = fieldmodel.F_DBFieldlName;
201
+        //        itemmodel.F_TaskId = taskId;
202
+        //        itemmodel.F_Sort = sort++;
203
+        //        itemmodel.F_FeildId = id;
204
+        //        if (pageFieldBLL.Add(itemmodel) > 0)
205
+        //            continue;
206
+        //    }
207
+        //    return Success("删除成功");
208
+        //}
209
+
163 210
         /// <summary>
164 211
         /// 去除自定义字段
165 212
         /// </summary>
166 213
         /// <param name="ids"></param>
167 214
         /// <returns></returns>
168
-        public ActionResult Remove(int[] ids, int taskId)
215
+        public ActionResult Remove(int[] ids)
169 216
         {
170
-            pageFieldBLL.DeleteByTaskId(taskId);
171
-            var sort = 0;
172
-            foreach (var id in ids)
217
+            if (ids != null && ids.Length > 0)
173 218
             {
174
-                var fieldmodel = formEntityAttrBLL.GetModel(id);
175
-                if (fieldmodel == null)
176
-                    continue;
177
-                var itemmodel = new T_Call_PageField();
178
-                itemmodel.F_Name = fieldmodel.F_Name;
179
-                itemmodel.F_DBFieldlName = fieldmodel.F_DBFieldlName;
180
-                itemmodel.F_TaskId = taskId;
181
-                itemmodel.F_Sort = sort++;
182
-                itemmodel.F_FeildId = id;
183
-                if (pageFieldBLL.Add(itemmodel) > 0)
184
-                    continue;
219
+                pageFieldBLL.DeleteList(string.Join(",", ids));
185 220
             }
186 221
             return Success("删除成功");
187 222
         }

+ 1 - 2
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

@@ -21,7 +21,6 @@ namespace CallCenterApi.Interface
21 21
             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
22 22
 
23 23
         }
24
-
25 24
         protected void Application_AuthenticateRequest(object sender, EventArgs e)
26 25
         {
27 26
             HttpApplication app = (HttpApplication)sender;
@@ -40,7 +39,7 @@ namespace CallCenterApi.Interface
40 39
                 if (ticket != null && string.IsNullOrEmpty(ticket.UserData) == false)
41 40
                     userData = (new JavaScriptSerializer()).Deserialize<Cache.Models.CurrentUserInfo>(ticket.UserData); //还原用户数据
42 41
                 if (ticket != null && userData != null)
43
-                    context.User = new FormsPrincipal<Cache.Models.CurrentUserInfo> (ticket, userData);//重新给context.User赋值。
42
+                    context.User = new FormsPrincipal<Cache.Models.CurrentUserInfo>(ticket, userData);//重新给context.User赋值。
44 43
             }
45 44
             catch { /* 有异常也不要抛出,防止攻击者试探。 */ }
46 45
         }

+ 2 - 0
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Models/Input/CallPlanInput.cs

@@ -91,5 +91,7 @@ namespace CallCenterApi.Interface.Models.Input
91 91
         /// Excel文件路径
92 92
         /// </summary>
93 93
         public string FilePath { get; set; }
94
+        public string SelectIds { get; set; }
95
+
94 96
     }
95 97
 }