Просмотр исходного кода

Merge branch 'master' of http://192.168.1.222:3000/zhengbingbing/NewCallCenter5.1_API

machenyang лет назад: 8
Родитель
Сommit
20afeb8b17

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -155,6 +155,7 @@
155 155
     </Reference>
156 156
   </ItemGroup>
157 157
   <ItemGroup>
158
+    <Content Include="ffmpeg.exe" />
158 159
     <Content Include="Global.asax" />
159 160
     <Content Include="Lib\Senparc.Weixin.dll" />
160 161
     <Content Include="Lib\Senparc.Weixin.MP.dll" />

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/IVRWordsController.cs

@@ -455,6 +455,7 @@ namespace CallCenterApi.Interface.Controllers
455 455
                         //删除本地文件
456 456
                         System.IO.File.Delete(savedir + fullFileName);
457 457
                         System.IO.File.Delete(savedir + temp_filename + ".wav");
458
+                        //System.IO.File.Delete(physicalpath);
458 459
                         var obj = new
459 460
                         {
460 461
                             oldname = fullFileName,

+ 367 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/RecordsController.cs

@@ -0,0 +1,367 @@
1
+using Baidu.Aip.Speech;
2
+using CallCenterApi.DB;
3
+using CallCenterApi.Interface.Controllers.Base;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.Data;
7
+using System.Diagnostics;
8
+using System.IO;
9
+using System.Linq;
10
+using System.Net;
11
+using System.Threading;
12
+using System.Web;
13
+using System.Web.Mvc;
14
+
15
+namespace CallCenterApi.Interface.Controllers
16
+{
17
+    public class RecordsController : BaseController
18
+    {
19
+        // GET: Records
20
+        public ActionResult Index()
21
+        {
22
+            return View();
23
+        }
24
+
25
+        //语音识别
26
+        private Asr _asrClient;//readonly
27
+        //语音合成
28
+        private Tts _ttsClient;//readonly
29
+        //验证身份参数
30
+        string strAK = "PuGGxl9vGrdijDTBYFBhEdVx";
31
+        string strSK = "aGmyOET05Os0atXBxFWXsC9qf1GgXv6R";
32
+        string backdata = "";
33
+
34
+        //public SpeechDemo()
35
+        //{
36
+        //    _asrClient = new Asr(strAK, strSK);
37
+        //    _ttsClient = new Tts("PuGGxl9vGrdijDTBYFBhEdVx", "aGmyOET05Os0atXBxFWXsC9qf1GgXv6R");
38
+        //}
39
+        string scallid = "453";
40
+        string sfilepath = "E:\\callrec\\luyin\\20170508\\1004\\453_1004_173534.mp3";
41
+        public ActionResult GetCallOutprefix(string callid, string filepath)
42
+        {
43
+            ActionResult res = NoToken("未知错误,请重新登录");
44
+            //if (Request.IsAuthenticated)
45
+            //{
46
+            callid = scallid;
47
+            filepath = sfilepath;
48
+            _asrClient = new Asr(strAK, strSK);
49
+            _ttsClient = new Tts("PuGGxl9vGrdijDTBYFBhEdVx", "aGmyOET05Os0atXBxFWXsC9qf1GgXv6R");
50
+            Init();//(callid, filepath);
51
+
52
+
53
+            res = Success("音频文件转换测试", backdata);
54
+            // }
55
+            return res;
56
+        }
57
+
58
+
59
+        public void Init()//(string callid, string filepath)
60
+        {
61
+            //通过读取配置文件,获取数据库
62
+
63
+            string dbpath = Environment.CurrentDirectory + @"\Config.ini";  //指定ini文件的路径
64
+            dbpath = "E:\\项目\\百度语音\\语音\\代码\\ASR_Speech\\ASR_Speech\\bin\\Debug\\Config.ini";
65
+            Common.IniFile ini = new Common.IniFile(dbpath);
66
+            string _dbset = ini.IniReadValue("基础设置SQL", "Catalog");
67
+            string _url = ini.IniReadValue("基础设置", "服务器地址");
68
+            //通过读取数据库,获得URL
69
+            DataTable dt_Recor = DbHelperSQL.Query("select FilePath,CallId from T_Call_CallRecords where IsTranslate is NULL or IsTranslate!=1 ").Tables[0];
70
+            //DataTable dt_Recor = Common.SQLHelper.QueryDataTable(_dbset, "select FilePath,CallId from T_Call_CallRecords where 1=1 ", CommandType.Text, null);
71
+            if (dt_Recor.Rows.Count > 0)
72
+            {
73
+                int i = 0;
74
+                foreach (DataRow dr in dt_Recor.Rows)
75
+                {
76
+                    //录音记录id
77
+                    string callid = dr[1].ToString();
78
+                    //录音记录URL路径
79
+                    string filepath = dr[0].ToString();
80
+                    if (!string.IsNullOrEmpty(filepath))
81
+                    {
82
+                        //通过cmd执行ffmpeg改变音频采样率
83
+                        Process p = new Process();
84
+                        p.StartInfo.FileName = "cmd.exe";
85
+                        p.StartInfo.UseShellExecute = false;
86
+                        p.StartInfo.RedirectStandardOutput = true;
87
+                        p.StartInfo.RedirectStandardInput = true;
88
+                        p.StartInfo.RedirectStandardError = true;
89
+                        p.StartInfo.CreateNoWindow = true;
90
+                        //p.StartInfo.Arguments = "ffmpeg -i "+fileName+ " -ar 16000 "+ namePart + "New.wav";//参数以空格分隔,如果某个参数为空,可以传入””
91
+
92
+                        //p.Start();
93
+                        ////先进入cmd命令
94
+                        ////再打开FFmpeg.exe
95
+                        string ffmpegLocation = System.Threading.Thread.GetDomain().BaseDirectory;// +"bin\\";
96
+                        ////p.StandardInput.WriteLine("exit");
97
+                        //p.StandardInput.WriteLine("cd d/ " + ffmpegLocation + "ffmpeg.exe");
98
+                        //p.StandardInput.WriteLine(ffmpegLocation.TrimEnd('\\'));
99
+
100
+                        //判断是否存在文件夹,不存在则创建
101
+                        string voices_path = ffmpegLocation + "temp_voices";
102
+                        if (!Directory.Exists(voices_path))
103
+                        {
104
+                            Directory.CreateDirectory(voices_path);
105
+                        }
106
+                        //filepath:E:\callrec\luyin\20170506\1200\4_1200_164414.mp3
107
+                        string[] filepaths = filepath.Split(new char[] { '\\' });
108
+                        //res_audiopath:http://192.168.5.7:88/callrec/luyin/20170506/1200/4_1200_164414.mp3
109
+                        string res_audiopath = filepath.Replace(filepath.Substring(0, 2), _url).Replace("mp3", "wav").Replace(@"\", @"/");
110
+                        //voices_path:D:\项目\XFTest_WITHDB\XFTest\bin\Debug
111
+                        //namePart:D:\项目\XFTest_WITHDB\XFTest\bin\Debug\temp_voices\4_1200_164414.wav
112
+                        string namePart = voices_path + @"\" + filepaths.Last().Replace("mp3", "wav");
113
+                        //pcm和WAV格式文件可以解析出来
114
+                        //this.AsrData(p, ffmpegLocation, res_audiopath, callid, namePart);
115
+                        //20171013 用本地文件测试
116
+                        //this.AsrData(p, ffmpegLocation, ffmpegLocation + "0.mp3", callid, namePart);
117
+                        //20171016
118
+                        this.AsrData(p, ffmpegLocation, "http://192.168.5.7:88/CallREC/luyin/20170908/1/427_1_141423.wav", callid, namePart);
119
+                    }
120
+                }
121
+            }
122
+        }
123
+        /// <summary>
124
+        /// 识别本地文件
125
+        /// </summary>
126
+        public void AsrData(Process p, string filelocation, string filepath, string callid, string namepart)
127
+        {
128
+            #region 读取本地文件
129
+            //int audiocounts = SplitAudio(filepath);
130
+
131
+            ////读取结果
132
+            //string rec_result = string.Empty;
133
+
134
+            ////WebClient _wClient = new WebClient();
135
+            ////byte[] p_pcm = _wClient.DownloadData("http://192.168.5.7:88/CallREC/luyin/20170508/1004/453_1004_173534.mp3");
136
+
137
+            ////读取远端文件是否存在
138
+            ////if (!RemoteFileExists("http://192.168.5.7:88/CallREC/luyin/20170908/1/427_1_141423.wav"))
139
+            ////    return;
140
+            ////ffmpeg -i http://192.168.5.7:88/callrec/luyin/20170506/1200/4_1200_164414.mp3 -f wav -ar 16000 -ac 1 -ab 16 D:\项目\XFTest_WITHDB\XFTest\bin\Debug\temp_voices\4_1200_164414.wav
141
+
142
+            //string temp_filename = filepath.Split('\\').Last().Split('.')[0] + "_temp_";
143
+            //Console.Write("\n开始语音听写 ...\n");
144
+            //for (int i = 0; i < audiocounts; i++)
145
+            //{
146
+            //    p.Start();
147
+            //    //先进入cmd命令
148
+            //    //再打开FFmpeg.exe
149
+
150
+            //    //p.StandardInput.WriteLine("exit");
151
+            //    p.StandardInput.WriteLine("cd d/ " + filelocation + "ffmpeg.exe");
152
+            //    p.StandardInput.WriteLine(filelocation.TrimEnd('\\'));
153
+
154
+            //    //p.StandardInput.WriteLine("ffmpeg -i " + temp_filename + i + ".mp3 -f pcm -ar 16000 -ac 1 -ab 16 " + namepart.Replace(@"/", @"\"));
155
+            //    string changefile = "ffmpeg -i " + filelocation + temp_filename + i + ".mp3 -f wav -ar 16000 -ac 1 -ab 16 " + filelocation + temp_filename + i + ".wav";
156
+
157
+            //    p.StandardInput.WriteLine(changefile);
158
+            //    Thread.Sleep(3000);
159
+            //    p.StandardInput.WriteLine("exit");
160
+            //    //Kill 是终止没有图形化界面的进程的唯一方法。
161
+            //    p.Kill();
162
+            //    //此处可以返回一个字符串,此例是返回压缩成功之后的一个文件路径
163
+            //    var data = File.ReadAllBytes(filelocation + temp_filename + i + ".wav");
164
+            //    var result_Json = _asrClient.Recognize(data, "wav", 16000);
165
+            //    if (rec_result != null)
166
+            //    {
167
+            //        int _code = int.Parse(result_Json["err_no"].ToString());
168
+            //        if (_code == 0)
169
+            //        {
170
+            //            string _res = result_Json["result"].ToString();
171
+            //            rec_result += _res.TrimStart('[').TrimEnd(']');
172
+            //        }
173
+            //        else
174
+            //        {
175
+            //            string _msg = result_Json["err_msg"].ToString();
176
+            //            rec_result += _msg;
177
+            //        }
178
+            //    }
179
+            //}
180
+
181
+            //Console.Write("\n语音听写结束\n");
182
+            //Console.Write("=============================================================\n");
183
+            //Console.Write(rec_result);
184
+            //Console.Write("\n=============================================================\n");
185
+            //int exe_res = Common.SQLHelper.Execute("XTZHSW_copy", "update T_Call_CallRecords set OperateObject='1',Remark='" + rec_result + "' where CallId='" + callid + "'", CommandType.Text, null);
186
+            //if (exe_res > 0)
187
+            //{
188
+            //    Console.WriteLine("\n数据库更新成功\n");
189
+            //    //操作完删除转换后的文件
190
+            //    if (File.Exists(filelocation + namepart.Replace(@"/", @"\")))
191
+            //    {
192
+            //        File.Delete(filelocation + namepart.Replace(@"/", @"\"));
193
+            //    }
194
+            //}
195
+            #endregion
196
+
197
+            #region 读取URL中的文件
198
+            //读取结果
199
+            string rec_result = string.Empty;
200
+            //读取远端文件是否存在
201
+            if (!RemoteFileExists(filepath))
202
+                return;
203
+            int audiocounts = SplitAudio(filepath);
204
+            string temp_filename = filepath.Split('/').Last().Split('.')[0] + "_temp_";
205
+            Console.Write("\n开始语音听写 ...\n");
206
+            for (int i = 0; i < audiocounts; i++)
207
+            {
208
+                p.Start();
209
+                //先进入cmd命令
210
+                //再打开FFmpeg.exe
211
+
212
+                //p.StandardInput.WriteLine("exit");
213
+                p.StandardInput.WriteLine("cd d/ " + filelocation + "ffmpeg.exe");
214
+                p.StandardInput.WriteLine(filelocation.TrimEnd('\\'));
215
+
216
+                //p.StandardInput.WriteLine("ffmpeg -i " + temp_filename + i + ".mp3 -f pcm -ar 16000 -ac 1 -ab 16 " + namepart.Replace(@"/", @"\"));
217
+                string changefile = "ffmpeg -i " + filelocation + temp_filename + i + ".wav -acodec pcm_s16le -f s16le -ar 16000 -ac 1 " + filelocation + temp_filename + i + ".pcm";
218
+
219
+                p.StandardInput.WriteLine(changefile);
220
+                Thread.Sleep(3000);
221
+                p.StandardInput.WriteLine("exit");
222
+                //Kill 是终止没有图形化界面的进程的唯一方法。
223
+                //p.Kill();
224
+                //此处可以返回一个字符串,此例是返回压缩成功之后的一个文件路径
225
+                var data = System.IO.File.ReadAllBytes(filelocation + temp_filename + i + ".pcm");
226
+                var result_Json = _asrClient.Recognize(data, "pcm", 16000);
227
+                if (rec_result != null)
228
+                {
229
+                    int _code = int.Parse(result_Json["err_no"].ToString());
230
+                    if (_code == 0)
231
+                    {
232
+                        string _res = result_Json["result"].ToString();
233
+                        rec_result += _res.TrimStart('[').TrimEnd(']');
234
+                    }
235
+                    else
236
+                    {
237
+                        string _msg = result_Json["err_msg"].ToString();
238
+                        rec_result += _msg;
239
+                    }
240
+                }
241
+            }
242
+            backdata = rec_result;
243
+            //Console.Write("\n语音听写结束\n");
244
+            //Console.Write("=============================================================\n");
245
+            //Console.Write(rec_result);
246
+            //Console.Write("\n=============================================================\n");
247
+            int exe_res = DbHelperSQL.ExecuteSql("update T_Call_CallRecords set IsTranslate=1,RecordsContent='" + rec_result + "' where CallId='" + callid + "'");
248
+            if (exe_res > 0)
249
+            {
250
+                //Console.WriteLine("\n数据库更新成功\n");
251
+                //操作完删除转换后的文件
252
+                string x = namepart.Replace(@"/", @"\");
253
+                if (System.IO.File.Exists(filelocation + namepart.Replace(@"/", @"\")))
254
+                {
255
+                    System.IO.File.Delete(filelocation + namepart.Replace(@"/", @"\"));
256
+                }
257
+            }
258
+            #endregion
259
+        }
260
+
261
+        /// <summary>
262
+        /// 分割音频
263
+        /// </summary>
264
+        /// <param name="filepath">音频路径</param>
265
+        private int SplitAudio(string filepath)
266
+        {
267
+            //获取音频时长
268
+            string length = "";
269
+            string[] sumlength;
270
+            int sec = 0;
271
+            DateTime beginTime = DateTime.Parse("00:00:00");
272
+            int index = 1;
273
+            using (Process pro = new Process())
274
+            {
275
+                pro.StartInfo.UseShellExecute = false;
276
+                pro.StartInfo.ErrorDialog = false;
277
+                pro.StartInfo.RedirectStandardError = true;
278
+
279
+                pro.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "bin\\ffmpeg.exe";
280
+                pro.StartInfo.Arguments = " -i " + filepath;
281
+
282
+                pro.Start();
283
+                StreamReader errorreader = pro.StandardError;
284
+                pro.WaitForExit(1000);
285
+
286
+                string result = errorreader.ReadToEnd();
287
+                if (!string.IsNullOrEmpty(result))
288
+                {
289
+                    result = result.Substring(result.IndexOf("Duration: ") + ("Duration: ").Length, ("00:00:00").Length);
290
+                    //result = "00:01:16";
291
+                    length = result;
292
+                    sumlength = length.Split(':');
293
+                    sec += (int.Parse(sumlength[0].ToString()) * 60 * 60 + int.Parse(sumlength[1].ToString()) * 60 + int.Parse(sumlength[2].ToString()));
294
+                }
295
+            }
296
+            //对音频进行分割
297
+            //ffmpeg -ss 00:00:00 -i input.mp4 -c copy -t 60 output.mp4
298
+            if (sec > 30)
299
+            {
300
+                Process p = new Process();
301
+                p.StartInfo.FileName = "cmd.exe";
302
+                p.StartInfo.UseShellExecute = false;
303
+                p.StartInfo.RedirectStandardOutput = true;
304
+                p.StartInfo.RedirectStandardInput = true;
305
+                p.StartInfo.RedirectStandardError = true;
306
+                // p.StartInfo.CreateNoWindow = true;
307
+                p.Start();
308
+                string ffmpegLocation = System.Threading.Thread.GetDomain().BaseDirectory + "bin\\";
309
+                p.StandardInput.WriteLine("exit");
310
+                p.StandardInput.WriteLine("cd d/ " + ffmpegLocation + "ffmpeg.exe");
311
+                p.StandardInput.WriteLine(ffmpegLocation.TrimEnd('\\'));
312
+                string fileName = System.IO.Path.GetFileName(filepath).Split('.')[0];
313
+                index = sec / 28 + 1;
314
+
315
+                for (int i = 0; i < index; i++)
316
+                {
317
+                    string splitstr = "ffmpeg -i " + filepath + " -ss " + beginTime.ToLongTimeString() + " -t 28 -acodec copy " + ffmpegLocation + fileName + "_temp_" + i + "." + System.IO.Path.GetFileName(filepath).Split('.')[1];
318
+                    p.StandardInput.WriteLine(splitstr);
319
+                    beginTime = beginTime.AddSeconds(29);
320
+                    Thread.Sleep(3000);
321
+                }
322
+                p.StandardInput.WriteLine("exit");
323
+                //Kill 是终止没有图形化界面的进程的唯一方法。
324
+                //p.Kill();
325
+            }
326
+            return index;
327
+        }
328
+
329
+        /// <summary>  
330
+        /// 判断远程文件是否存在  
331
+        /// </summary>  
332
+        /// <param name="fileUrl"></param>  
333
+        /// <returns></returns>  
334
+        public static bool RemoteFileExists(string fileUrl)
335
+        {
336
+            HttpWebRequest re = null;
337
+            HttpWebResponse res = null;
338
+            try
339
+            {
340
+                re = (HttpWebRequest)WebRequest.Create(fileUrl);
341
+                res = (HttpWebResponse)re.GetResponse();
342
+                if (res.ContentLength != 0)
343
+                {
344
+                    //MessageBox.Show("文件存在");  
345
+                    return true;
346
+                }
347
+            }
348
+            catch (Exception)
349
+            {
350
+                //MessageBox.Show("无此文件");  
351
+                return false;
352
+            }
353
+            finally
354
+            {
355
+                if (re != null)
356
+                {
357
+                    re.Abort();//销毁关闭连接  
358
+                }
359
+                if (res != null)
360
+                {
361
+                    res.Close();//销毁关闭响应  
362
+                }
363
+            }
364
+            return false;
365
+        }
366
+    }
367
+}

+ 112 - 112
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/callout/CallPlanController.cs

@@ -243,70 +243,70 @@ namespace CallCenterApi.Interface.Controllers.callout
243 243
                 if (taskId > 0)
244 244
                 {
245 245
                     // return Success("添加成功", i);
246
-                        model.TaskID = taskId;
247
-                        DataTable dt = taskTellNumBLL.GetTableDesign();
248
-                        switch (input.ImportType)
249
-                        {
250
-                            case 1: //从文本文件导入
251
-                                var file = Request.Files[0];
252
-                                using (StreamReader sr = new StreamReader(file.InputStream))
253
-                                {
254
-                                    String line;
255
-                                    while ((line = sr.ReadLine()) != null)
256
-                                    {
257
-                                        var row = dt.NewRow();
258
-                                        row["F_TaskId"] = model.TaskID;
259
-                                        row["F_Phone"] = line.ToString();
260
-                                        dt.Rows.Add(row);
261
-                                    }
262
-                                }
263
-                                break;
264
-                            case 2: //从文本框中导入
265
-                                if (string.IsNullOrWhiteSpace(input.PhoneList))
266
-                                    return Error("号码不可以为空");
267
-                                var arr = input.PhoneList.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
268
-                                foreach (var p in arr)
269
-                                {
270
-                                    var row = dt.NewRow();
271
-                                    row["F_TaskId"] = model.TaskID;
272
-                                    row["F_Phone"] = p;
273
-                                    dt.Rows.Add(row);
274
-                                }
275
-                                break;
276
-                            case 3: //从号码段导入
277
-                                if (string.IsNullOrWhiteSpace(input.PhoneStr))
278
-                                    return Error("号码不可以为空");
279
-                                double phoneInt = 0;
280
-                                if (!double.TryParse(input.PhoneStr, out phoneInt))
281
-                                    return Error("请输入正确的手机号码段");
282
-                                phoneInt = phoneInt * 10000;
283
-                                for (int i = 1; i < 10000; i++)
246
+                    model.TaskID = taskId;
247
+                    DataTable dt = taskTellNumBLL.GetTableDesign();
248
+                    switch (input.ImportType)
249
+                    {
250
+                        case 1: //从文本文件导入
251
+                            var file = Request.Files[0];
252
+                            using (StreamReader sr = new StreamReader(file.InputStream))
253
+                            {
254
+                                String line;
255
+                                while ((line = sr.ReadLine()) != null)
284 256
                                 {
285 257
                                     var row = dt.NewRow();
286 258
                                     row["F_TaskId"] = model.TaskID;
287
-                                    row["F_Phone"] = phoneInt + i;
259
+                                    row["F_Phone"] = line.ToString();
288 260
                                     dt.Rows.Add(row);
289 261
                                 }
290
-                                break;
291
-                            case 4: //从Excel中导入
292
-                                NPOIHelper npoi = new NPOIHelper();
293
-                                var dtExcel = npoi.ExcelToTable(input.PhoneStr, 1);
294
-                                break;
295
-                        }
296
-                        if (input.CheckFilter1)
297
-                        {
298
-                            PhoneNumFilter(dt);
299
-                        }
300
-                        if (input.CheckFilter2)
301
-                        {
302
-                            PhoneNumFilterMonth(dt);
303
-                        }
304
-                        taskTellNumBLL.SqlBulkCopy(dt);
262
+                            }
263
+                            break;
264
+                        case 2: //从文本框中导入
265
+                            if (string.IsNullOrWhiteSpace(input.PhoneList))
266
+                                return Error("号码不可以为空");
267
+                            var arr = input.PhoneList.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
268
+                            foreach (var p in arr)
269
+                            {
270
+                                var row = dt.NewRow();
271
+                                row["F_TaskId"] = model.TaskID;
272
+                                row["F_Phone"] = p;
273
+                                dt.Rows.Add(row);
274
+                            }
275
+                            break;
276
+                        case 3: //从号码段导入
277
+                            if (string.IsNullOrWhiteSpace(input.PhoneStr))
278
+                                return Error("号码不可以为空");
279
+                            double phoneInt = 0;
280
+                            if (!double.TryParse(input.PhoneStr, out phoneInt))
281
+                                return Error("请输入正确的手机号码段");
282
+                            phoneInt = phoneInt * 10000;
283
+                            for (int i = 1; i < 10000; i++)
284
+                            {
285
+                                var row = dt.NewRow();
286
+                                row["F_TaskId"] = model.TaskID;
287
+                                row["F_Phone"] = phoneInt + i;
288
+                                dt.Rows.Add(row);
289
+                            }
290
+                            break;
291
+                        case 4: //从Excel中导入
292
+                            NPOIHelper npoi = new NPOIHelper();
293
+                            var dtExcel = npoi.ExcelToTable(input.PhoneStr, 1);
294
+                            break;
295
+                    }
296
+                    if (input.CheckFilter1)
297
+                    {
298
+                        PhoneNumFilter(dt);
299
+                    }
300
+                    if (input.CheckFilter2)
301
+                    {
302
+                        PhoneNumFilterMonth(dt);
303
+                    }
304
+                    taskTellNumBLL.SqlBulkCopy(dt);
305 305
 
306
-                        model.y_HMCount = dt.Rows.Count;
307
-                        if (taskBLL.Update(model))
308
-                            return Success("添加成功");
309
-                        return Error("添加失败");
306
+                    model.y_HMCount = dt.Rows.Count;
307
+                    if (taskBLL.Update(model))
308
+                        return Success("添加成功");
309
+                    return Error("添加失败");
310 310
                 }
311 311
                 return Error("添加失败");
312 312
             }
@@ -376,65 +376,65 @@ namespace CallCenterApi.Interface.Controllers.callout
376 376
         /// <returns></returns>
377 377
         public ActionResult ImportData(ImportDataInput input)
378 378
         {
379
-                DataTable dt = taskTellNumBLL.GetTableDesign();
380
-                switch (input.Type)
381
-                {
382
-                    case 1: //从文本文件导入
383
-                        var file = Request.Files[0];
384
-                        using (StreamReader sr = new StreamReader(file.InputStream))
385
-                        {
386
-                            String line;
387
-                            while ((line = sr.ReadLine()) != null)
388
-                            {
389
-                                var row = dt.NewRow();
390
-                                row["F_TaskId"] = input.TaskId;
391
-                                row["F_Phone"] = line.ToString();
392
-                                dt.Rows.Add(row);
393
-                            }
394
-                        }
395
-                        break;
396
-                    case 2: //从文本框中导入
397
-                        if (string.IsNullOrWhiteSpace(input.PhoneStr))
398
-                            return Error("号码不可以为空");
399
-                        var arr = input.PhoneStr.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
400
-                        foreach (var p in arr)
401
-                        {
402
-                            var row = dt.NewRow();
403
-                            row["F_TaskId"] = input.TaskId;
404
-                            row["F_Phone"] = p;
405
-                            dt.Rows.Add(row);
406
-                        }
407
-                        break;
408
-                    case 3: //从号码段导入
409
-                        if (string.IsNullOrWhiteSpace(input.PhoneStr))
410
-                            return Error("号码不可以为空");
411
-                        double phoneInt = 0;
412
-                        if (!double.TryParse(input.PhoneStr, out phoneInt))
413
-                            return Error("请输入正确的手机号码段");
414
-                        phoneInt = phoneInt * 10000;
415
-                        for (int i = 1; i < 10000; i++)
379
+            DataTable dt = taskTellNumBLL.GetTableDesign();
380
+            switch (input.Type)
381
+            {
382
+                case 1: //从文本文件导入
383
+                    var file = Request.Files[0];
384
+                    using (StreamReader sr = new StreamReader(file.InputStream))
385
+                    {
386
+                        String line;
387
+                        while ((line = sr.ReadLine()) != null)
416 388
                         {
417 389
                             var row = dt.NewRow();
418 390
                             row["F_TaskId"] = input.TaskId;
419
-                            row["F_Phone"] = phoneInt + i;
391
+                            row["F_Phone"] = line.ToString();
420 392
                             dt.Rows.Add(row);
421 393
                         }
422
-                        break;
423
-                    case 4: //从Excel中导入
424
-                        NPOIHelper npoi = new NPOIHelper();
425
-                        var dtExcel = npoi.ExcelToTable(input.PhoneStr, 1);
426
-                        break;
427
-                }
428
-                if (input.CheckFilter1)
429
-                {
430
-                    PhoneNumFilter(dt);
431
-                }
432
-                if (input.CheckFilter2)
433
-                {
434
-                    PhoneNumFilterMonth(dt);
435
-                }
436
-                taskTellNumBLL.SqlBulkCopy(dt);
437
-                return Content("<script type='javascript/text'>alert('啊啊啊');</script>");
394
+                    }
395
+                    break;
396
+                case 2: //从文本框中导入
397
+                    if (string.IsNullOrWhiteSpace(input.PhoneStr))
398
+                        return Error("号码不可以为空");
399
+                    var arr = input.PhoneStr.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
400
+                    foreach (var p in arr)
401
+                    {
402
+                        var row = dt.NewRow();
403
+                        row["F_TaskId"] = input.TaskId;
404
+                        row["F_Phone"] = p;
405
+                        dt.Rows.Add(row);
406
+                    }
407
+                    break;
408
+                case 3: //从号码段导入
409
+                    if (string.IsNullOrWhiteSpace(input.PhoneStr))
410
+                        return Error("号码不可以为空");
411
+                    double phoneInt = 0;
412
+                    if (!double.TryParse(input.PhoneStr, out phoneInt))
413
+                        return Error("请输入正确的手机号码段");
414
+                    phoneInt = phoneInt * 10000;
415
+                    for (int i = 1; i < 10000; i++)
416
+                    {
417
+                        var row = dt.NewRow();
418
+                        row["F_TaskId"] = input.TaskId;
419
+                        row["F_Phone"] = phoneInt + i;
420
+                        dt.Rows.Add(row);
421
+                    }
422
+                    break;
423
+                case 4: //从Excel中导入
424
+                    NPOIHelper npoi = new NPOIHelper();
425
+                    var dtExcel = npoi.ExcelToTable(input.PhoneStr, 1);
426
+                    break;
427
+            }
428
+            if (input.CheckFilter1)
429
+            {
430
+                PhoneNumFilter(dt);
431
+            }
432
+            if (input.CheckFilter2)
433
+            {
434
+                PhoneNumFilterMonth(dt);
435
+            }
436
+            taskTellNumBLL.SqlBulkCopy(dt);
437
+            return Content("<script type='javascript/text'>alert('啊啊啊');</script>");
438 438
 
439 439
         }
440 440
 

+ 7 - 7
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/CustomerController.cs

@@ -169,7 +169,9 @@ namespace CallCenterApi.Interface.Controllers.customer
169 169
             if (userModel == null)
170 170
                 return Error("获取失败,该客户信息不存在");
171 171
             //系统列+自定义列 实体
172
-            var columnList = customerFieldBLL.GetList().Where(x => x.F_IsShowOnList > 0).OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
172
+            var columnList = customerFieldBLL.GetList()
173
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
174
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
173 175
             //系统列+自定义列 字符串
174 176
             var headList = columnList.Select(x => x.F_Name).ToList();
175 177
             //系统列+自定义列 字段名
@@ -180,7 +182,7 @@ namespace CallCenterApi.Interface.Controllers.customer
180 182
             var expand = DbHelperSQL.Query("select  top 1 * from T_Cus_CustomerExpand where F_CustomerId=@F_CustomerId", new SqlParameter("@F_CustomerId", userModel.F_Id)).Tables[0].Rows[0];
181 183
             List<string> strList1 = new List<string>()
182 184
             {
183
-                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_AddAgentName, userModel.F_AddTime.ToString("yyyy-MM-dd HH:mm:ss"), userModel.F_Remark
185
+                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_Remark
184 186
             };
185 187
             List<string> strList2 = new List<string>();
186 188
             foreach (var item in customerColumnArr)
@@ -362,14 +364,12 @@ namespace CallCenterApi.Interface.Controllers.customer
362 364
             return Error("获取参数失败");
363 365
         }
364 366
 
365
-        /// <summary>
366
-        /// 获取自定义字段的字段名和字符串
367
-        /// </summary>
368
-        /// <returns></returns>
369 367
         public ActionResult GetCustomerField()
370 368
         {
371 369
             //系统列+自定义列 实体
372
-            var columnList = customerFieldBLL.GetList().Where(x => x.F_IsShowOnList > 0).OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
370
+            var columnList = customerFieldBLL.GetList()
371
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
372
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
373 373
             //系统列+自定义列 字符串
374 374
             var headList = columnList.Select(x => x.F_Name).ToList();
375 375
             //系统列+自定义列 字段名

+ 137 - 84
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/tel/CallInScreenController.cs

@@ -1,9 +1,11 @@
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;
6 7
 using System.Data;
8
+using System.Data.SqlClient;
7 9
 using System.Linq;
8 10
 using System.Web;
9 11
 using System.Web.Mvc;
@@ -12,6 +14,12 @@ namespace CallCenterApi.Interface.Controllers.tel
12 14
 {
13 15
     public class CallInScreenController : BaseController
14 16
     {
17
+
18
+        private readonly BLL.T_Cus_CustomerBase customerBaseBLL = new BLL.T_Cus_CustomerBase();
19
+        private readonly BLL.T_Cus_CustomerField customerFieldBLL = new BLL.T_Cus_CustomerField();
20
+        private readonly BLL.T_Cus_CustomerExpand customerExpandBLL = new BLL.T_Cus_CustomerExpand();
21
+        private readonly BLL.T_RepositoryInformation knowledgeBLL = new BLL.T_RepositoryInformation();
22
+        private readonly BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
15 23
         /// <summary>
16 24
         /// 添加黑名单
17 25
         /// </summary>
@@ -21,63 +29,63 @@ namespace CallCenterApi.Interface.Controllers.tel
21 29
             ActionResult res = NoToken("未知错误,请重新登录");
22 30
             if (Request.IsAuthenticated)
23 31
             {
24
-                
25
-                    int userId = CurrentUser.UserData.F_UserId;
26
-                    if (userId != 0)
32
+
33
+                int userId = CurrentUser.UserData.F_UserId;
34
+                if (userId != 0)
35
+                {
36
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
37
+                    if (ua != null)
27 38
                     {
28
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
29
-                        if (ua != null)
39
+                        string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
40
+                        string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
41
+                        int n = RequestString.GetInt("num", 0);
42
+                        int type = RequestString.GetInt("type", 0);
43
+                        Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
44
+
45
+                        var date = DateTime.Now;
46
+                        var enddate = date;
47
+                        switch (type)
48
+                        {
49
+                            case 1: enddate = enddate.AddDays(n); break;
50
+                            case 2: enddate = enddate.AddHours(n); break;
51
+                            case 3: enddate = enddate.AddMinutes(n); break;
52
+                            case 4: enddate = DateTime.MaxValue; break;
53
+                        }
54
+                        if (dModel == null)
30 55
                         {
31
-                            string tel = HttpUtility.UrlDecode(RequestString.GetFormString("tel"));
32
-                            string callid = HttpUtility.UrlDecode(RequestString.GetFormString("callid"));
33
-                            int n = RequestString.GetInt("num", 0);
34
-                            int type = RequestString.GetInt("type", 0);
35
-                            Model.T_Call_Blacklist dModel = new BLL.T_Call_Blacklist().GetModelList(" F_TelPhone='" + tel + "' ").FirstOrDefault();
36
-
37
-                            var date = DateTime.Now;
38
-                            var enddate = date;
39
-                            switch (type)
56
+                            dModel = new Model.T_Call_Blacklist();
57
+                            dModel.F_CallId = callid;
58
+                            dModel.F_TelPhone = tel.Trim();
59
+                            dModel.F_SetTime = date;
60
+                            dModel.F_RemoveTime = enddate;
61
+                            dModel.F_InterceptNum = 1;
62
+                            dModel.F_UserId = ua.F_UserId;
63
+                            int b = new BLL.T_Call_Blacklist().Add(dModel);
64
+                            if (b > 0)
40 65
                             {
41
-                                case 1: enddate = enddate.AddDays(n); break;
42
-                                case 2: enddate = enddate.AddHours(n); break;
43
-                                case 3: enddate = enddate.AddMinutes(n); break;
44
-                                case 4: enddate = DateTime.MaxValue; break;
66
+                                res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
45 67
                             }
46
-                            if (dModel == null)
68
+                            else
47 69
                             {
48
-                                dModel = new Model.T_Call_Blacklist();
49
-                                dModel.F_CallId = callid;
50
-                                dModel.F_TelPhone = tel.Trim();
51
-                                dModel.F_SetTime = date;
52
-                                dModel.F_RemoveTime = enddate;
53
-                                dModel.F_InterceptNum = 1;
54
-                                dModel.F_UserId = ua.F_UserId;
55
-                                int b = new BLL.T_Call_Blacklist().Add(dModel);
56
-                                if (b > 0)
57
-                                {
58
-                                    res = Success("添加成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
59
-                                }
60
-                                else
61
-                                {
62
-                                    res = Error("添加失败");
63
-                                }
70
+                                res = Error("添加失败");
71
+                            }
72
+                        }
73
+                        else
74
+                        {
75
+
76
+                            dModel.F_RemoveTime = enddate;
77
+                            if (new BLL.T_Call_Blacklist().Update(dModel))
78
+                            {
79
+                                res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
64 80
                             }
65 81
                             else
66 82
                             {
67
-
68
-                                dModel.F_RemoveTime = enddate;
69
-                                if (new BLL.T_Call_Blacklist().Update(dModel))
70
-                                {
71
-                                    res = Success("修改成功", enddate.ToString("yyyy-MM-dd HH:mm:ss"));
72
-                                }
73
-                                else
74
-                                {
75
-                                    res = Error("修改失败");
76
-                                }
83
+                                res = Error("修改失败");
77 84
                             }
78 85
                         }
79 86
                     }
80
-              
87
+                }
88
+
81 89
             }
82 90
             return res;
83 91
         }
@@ -112,21 +120,66 @@ namespace CallCenterApi.Interface.Controllers.tel
112 120
         /// 根据来电号码获取客户信息
113 121
         /// </summary>
114 122
         /// <returns></returns>
115
-        public ActionResult GetCustomerByTel()
123
+        public ActionResult GetCustomerByTel(string tel)
116 124
         {
117
-            ActionResult res = NoToken("未知错误,请重新登录");
118
-            if (Request.IsAuthenticated)
119
-            {
120
-                DataTable dt = new DataTable();
125
+            //ActionResult res = NoToken("未知错误,请重新登录");
126
+            //if (Request.IsAuthenticated)
127
+            //{
128
+            //    DataTable dt = new DataTable();
121 129
 
122
-                string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
123
-                BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
124
-                dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
130
+            //    string tel = HttpUtility.UrlDecode(RequestString.GetQueryString("tel"));
131
+            //    BLL.T_Cus_CustomerBase bll = new BLL.T_Cus_CustomerBase();
132
+            //    dt = bll.GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
133
+
134
+            //    res = Success("客户信息加载成功", dt);
135
+
136
+            //}
137
+            //return res;
125 138
 
126
-                res = Success("客户信息加载成功", dt);
127 139
 
140
+
141
+            if (string.IsNullOrWhiteSpace(tel))
142
+                return Error("来电号码为空");
143
+
144
+            //系统列+自定义列 实体
145
+            var columnList = customerFieldBLL.GetList()
146
+                .Where(x => (x.F_FieldType == 0 && x.F_IsNecessary > 0) || (x.F_FieldType == 1 && x.F_IsShowOnScrean > 0))
147
+                .OrderBy(x => x.F_FieldType).ThenBy(x => x.F_Sort).ToList();
148
+            //系统列+自定义列 字符串
149
+            var headList = columnList.Select(x => x.F_Name).ToList();
150
+            //系统列+自定义列 字段名
151
+            var nameList = columnList.Select(x => x.F_DBFieldName).ToList();
152
+
153
+            var userModel = customerBaseBLL.GetModelByTel(tel);
154
+            if (userModel == null)
155
+                return Success("获取成功", new
156
+                {
157
+                    namelist = nameList,
158
+                    headlist = headList
159
+                });
160
+
161
+            //自定义列字段名
162
+            var customerColumnArr = columnList.Where(x => x.F_FieldType == 1).Select(x => x.F_DBFieldName).ToList();
163
+            //自定义列值
164
+            var expand = DbHelperSQL.Query("select  top 1 * from T_Cus_CustomerExpand where F_CustomerId=@F_CustomerId", new SqlParameter("@F_CustomerId", userModel.F_Id)).Tables[0].Rows[0];
165
+            List<string> strList1 = new List<string>()
166
+            {
167
+                 userModel.F_Name, userModel.F_PhoneNum1, userModel.F_PhoneNum2, userModel.F_Address, userModel.F_Remark
168
+            };
169
+            List<string> strList2 = new List<string>();
170
+            foreach (var item in customerColumnArr)
171
+            {
172
+                strList2.Add(expand[item].ToString());
128 173
             }
129
-            return res;
174
+            strList1.AddRange(strList2);
175
+
176
+            return Success("获取成功", new
177
+            {
178
+                id = userModel.F_Id,
179
+                namelist = nameList,
180
+                headlist = headList,
181
+                datalist = strList1
182
+            });
130 183
         }
131 184
 
132 185
         /// <summary>
@@ -184,7 +237,7 @@ namespace CallCenterApi.Interface.Controllers.tel
184 237
                 if (tel.Trim().Length == 11 && tel.Substring(0, 1) != "0")
185 238
                 {
186 239
                     BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
187
-                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault(); 
240
+                    Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModelList(" F_MobileNum='" + tel.Substring(0, 7) + "' ").FirstOrDefault();
188 241
 
189 242
                     if (mobileModel != null)
190 243
                     {
@@ -293,17 +346,17 @@ namespace CallCenterApi.Interface.Controllers.tel
293 346
                     }
294 347
                 }
295 348
 
296
-                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 "+ sqlcount);
297
-                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 "+ sqlcount);
298
-                
349
+                int hrcount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=0 " + sqlcount);
350
+                int hccount = new BLL.T_Call_CallRecords().GetRecordCount(" calltype=1 " + sqlcount);
351
+
299 352
                 var obj = new
300 353
                 {
301 354
                     state = "success",
302 355
                     message = "成功",
303 356
                     rows = dt,
304 357
                     total = recordCount,
305
-                    hrcount=hrcount,
306
-                    hccount=hccount,
358
+                    hrcount = hrcount,
359
+                    hccount = hccount,
307 360
                 };
308 361
 
309 362
                 res = Content(obj.ToJson());
@@ -354,34 +407,34 @@ namespace CallCenterApi.Interface.Controllers.tel
354 407
             ActionResult res = NoToken("未知错误,请重新登录");
355 408
             if (Request.IsAuthenticated)
356 409
             {
357
-               
358
-                    int userId = CurrentUser.UserData.F_UserId;
359
-                    if (userId != 0)
410
+
411
+                int userId = CurrentUser.UserData.F_UserId;
412
+                if (userId != 0)
413
+                {
414
+                    Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
415
+                    if (ua != null)
360 416
                     {
361
-                        Model.T_Sys_UserAccount ua = new BLL.T_Sys_UserAccount().GetModel(userId);
362
-                        if (ua != null)
363
-                        {
364
-                            Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
365
-                            model.CallId = RequestString.GetFormString("callid");
366
-                            model.UserId = ua.F_UserId;
367
-                            model.UserCode = ua.F_UserCode;
368
-                            model.UserName = ua.F_UserName;
417
+                        Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
418
+                        model.CallId = RequestString.GetFormString("callid");
419
+                        model.UserId = ua.F_UserId;
420
+                        model.UserCode = ua.F_UserCode;
421
+                        model.UserName = ua.F_UserName;
369 422
                         //model.ExtNumber = ua.F_WorkNumber;
370 423
                         model.ExtNumber = CurrentUser.UserData.F_ExtensionNumber;
371 424
 
372
-                            model.DealType = 5;
373
-                            bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
374
-                            if (bl)
375
-                            {
376
-                                res = Success("更新振铃状态成功");
377
-                            }
378
-                            else
379
-                            {
380
-                                res = Error("更新振铃状态失败");
381
-                            }
425
+                        model.DealType = 5;
426
+                        bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
427
+                        if (bl)
428
+                        {
429
+                            res = Success("更新振铃状态成功");
430
+                        }
431
+                        else
432
+                        {
433
+                            res = Error("更新振铃状态失败");
382 434
                         }
383 435
                     }
384
-            
436
+                }
437
+
385 438
             }
386 439
             return res;
387 440
         }

BIN
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/bin/Interop.Shell32.dll


BIN
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/obj/Debug/Interop.Shell32.dll