|
|
@@ -9,6 +9,7 @@ using System.Data;
|
|
9
|
9
|
using CallCenter.Utility;
|
|
10
|
10
|
using CallCenterApi.Common;
|
|
11
|
11
|
using CallCenterApi.DB;
|
|
|
12
|
+using System.IO;
|
|
12
|
13
|
|
|
13
|
14
|
namespace CallCenterApi.Interface.Controllers.customer
|
|
14
|
15
|
{
|
|
|
@@ -19,7 +20,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
19
|
20
|
/// 获取客户列表
|
|
20
|
21
|
/// </summary>
|
|
21
|
22
|
/// <returns></returns>
|
|
22
|
|
- public ActionResult GetList()
|
|
|
23
|
+ public ActionResult GetList(int isdc=0)
|
|
23
|
24
|
{
|
|
24
|
25
|
string sql = " and F_DeleteFlag=0";
|
|
25
|
26
|
DataTable dt = new DataTable();
|
|
|
@@ -60,11 +61,27 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
60
|
61
|
{
|
|
61
|
62
|
pagesize = Convert.ToInt32(strpagesize);
|
|
62
|
63
|
}
|
|
|
64
|
+ if (isdc>0)
|
|
|
65
|
+ {
|
|
|
66
|
+ var dtdc = DbHelperSQL.Query(" F_CustomerName 联系人姓名,F_Mobile 联系人电话,F_Email 邮箱,F_Address 地址,(select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 and F_CusPhone=a.F_Mobile) as 工单数量 (select count(1) from dbo.T_Call_CallRecords where CallType=0 and CallNumber=a.F_Mobile ) as 来电数量"
|
|
|
67
|
+ + " from T_Cus_CustomerBase a WITH(NOLOCK) where 1=1 " + sql ).Tables[0];
|
|
|
68
|
+ var msg = new NPOIHelper().ExportToExcel("市民资料", dtdc);
|
|
|
69
|
+ if (msg == "")
|
|
|
70
|
+ {
|
|
|
71
|
+ return Success("导出成功");
|
|
|
72
|
+ }
|
|
|
73
|
+ else
|
|
|
74
|
+ {
|
|
|
75
|
+ return Error("导出失败");
|
|
|
76
|
+ }
|
|
|
77
|
+ }
|
|
|
78
|
+
|
|
|
79
|
+ string cols = "*,(select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 and F_CusPhone=a.F_Mobile) as gdCount, (select count(1) from dbo.T_Call_CallRecords where CallType=0 and CallNumber=a.F_Mobile ) as ldCount ";
|
|
63
|
80
|
int recordCount = 0;
|
|
64
|
81
|
dt = BLL.PagerBLL.GetListPager(
|
|
65
|
|
- "T_Cus_CustomerBase",
|
|
|
82
|
+ "T_Cus_CustomerBase a WITH(NOLOCK) ",
|
|
66
|
83
|
"F_CustomerId",
|
|
67
|
|
- "*",
|
|
|
84
|
+ cols,
|
|
68
|
85
|
sql,
|
|
69
|
86
|
"ORDER BY F_CustomerId desc",
|
|
70
|
87
|
pagesize,
|
|
|
@@ -140,22 +157,6 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
140
|
157
|
{
|
|
141
|
158
|
return Error("请输入客户名称");
|
|
142
|
159
|
}
|
|
143
|
|
- //if (!Validate.IsValidPhoneAndMobile(mobile) && !string.IsNullOrEmpty(mobile))
|
|
144
|
|
- //{
|
|
145
|
|
- // return Error("请输入有效的客户电话");
|
|
146
|
|
- //}
|
|
147
|
|
- //if (!Validate.IsValidPhoneAndMobile(telphone) && !string.IsNullOrEmpty(telphone))
|
|
148
|
|
- //{
|
|
149
|
|
- // return Error("请输入有效的联系电话");
|
|
150
|
|
- //}
|
|
151
|
|
- //if (!Validate.IsValidZip(postcode) && !string.IsNullOrEmpty(postcode))
|
|
152
|
|
- //{
|
|
153
|
|
- // return Error("请输入有效的邮编号码");
|
|
154
|
|
- //}
|
|
155
|
|
- //if (!Validate.IsEmail(email) && !string.IsNullOrEmpty(email))
|
|
156
|
|
- //{
|
|
157
|
|
- // return Error("请输入有效的Email");
|
|
158
|
|
- //}
|
|
159
|
160
|
#endregion
|
|
160
|
161
|
|
|
161
|
162
|
Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
|
|
|
@@ -286,20 +287,13 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
286
|
287
|
{
|
|
287
|
288
|
Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
|
|
288
|
289
|
model.F_CustomerName = dr[0].ToString(); //客户姓名
|
|
289
|
|
- //model.F_CustomerEName = dr[1].ToString(); //联系人
|
|
290
|
290
|
model.F_Sex = dr[1].ToString(); //性别
|
|
291
|
291
|
model.F_Mobile = dr[2].ToString(); //手机号码
|
|
292
|
|
- model.F_Telephone = dr[3].ToString(); //单位电话
|
|
293
|
|
- model.F_ChargeTelephone = dr[4].ToString(); //其它号码
|
|
294
|
|
- model.F_PostCode = dr[5].ToString(); //邮编
|
|
295
|
|
- model.F_Email = dr[6].ToString(); //Email
|
|
296
|
|
- model.F_ChargeDept = dr[7].ToString(); //所在单位
|
|
297
|
|
- model.F_ServiceDept = dr[8].ToString(); //部门
|
|
298
|
|
- model.F_CustomerIndustry = dr[9].ToString(); //职务
|
|
|
292
|
+ model.F_Email = dr[3].ToString(); //Email
|
|
|
293
|
+ model.F_Address = dr[4].ToString(); //部门
|
|
299
|
294
|
model.F_CreateBy = User.F_UserId;
|
|
300
|
295
|
model.F_CreatedOn = DateTime.Now;
|
|
301
|
296
|
model.F_DeleteFlag = 0;
|
|
302
|
|
-
|
|
303
|
297
|
if (new BLL.T_Cus_CustomerBase().Add(model) <= 0)
|
|
304
|
298
|
{
|
|
305
|
299
|
return Error("第" + headrow + "行,导入失败!");
|
|
|
@@ -313,6 +307,89 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
313
|
307
|
return Success("导入成功");
|
|
314
|
308
|
}
|
|
315
|
309
|
|
|
|
310
|
+
|
|
|
311
|
+
|
|
|
312
|
+
|
|
|
313
|
+
|
|
|
314
|
+ ///// <summary>
|
|
|
315
|
+ ///// 导入excel
|
|
|
316
|
+ ///// </summary>
|
|
|
317
|
+ public ActionResult ImportExcel()
|
|
|
318
|
+ {
|
|
|
319
|
+ HttpPostedFile _upFile = RequestString.GetFile("upFile");
|
|
|
320
|
+ if (_upFile != null)
|
|
|
321
|
+ {
|
|
|
322
|
+ int headrow = 0;
|
|
|
323
|
+ #region 上传文件
|
|
|
324
|
+ string filepath = "";
|
|
|
325
|
+ string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
|
|
|
326
|
+ string aLastName = Path.GetExtension(_upFile.FileName);
|
|
|
327
|
+ string oriname = Path.GetFileNameWithoutExtension(_upFile.FileName);
|
|
|
328
|
+ if (aLastName != ".xls" && aLastName != ".xlsx")
|
|
|
329
|
+ {
|
|
|
330
|
+ return Error("文件类型错误,请选择Excel文件");
|
|
|
331
|
+ }
|
|
|
332
|
+ string newpath = datepath + "_" + _upFile.FileName;
|
|
|
333
|
+ if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData")))
|
|
|
334
|
+ {
|
|
|
335
|
+ Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\ExcelData"));
|
|
|
336
|
+ }
|
|
|
337
|
+ filepath = this.Request.ApplicationPath + "/ExcelData/" + newpath;
|
|
|
338
|
+ string PhysicalPath = Server.MapPath(filepath);
|
|
|
339
|
+ _upFile.SaveAs(PhysicalPath);
|
|
|
340
|
+ #endregion
|
|
|
341
|
+ NPOIHelper np = new NPOIHelper();
|
|
|
342
|
+ DataTable dt = np.ExcelToTable(_upFile, headrow);
|
|
|
343
|
+ string msg = string.Empty;
|
|
|
344
|
+ if (dt == null || dt.Rows.Count == 0)
|
|
|
345
|
+ return Error("文件没有数据");
|
|
|
346
|
+ else
|
|
|
347
|
+ {
|
|
|
348
|
+
|
|
|
349
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
350
|
+ {
|
|
|
351
|
+ headrow = headrow + 1;
|
|
|
352
|
+ if (string.IsNullOrEmpty(dr["联系人姓名"].ToString()))
|
|
|
353
|
+ {
|
|
|
354
|
+ msg = msg + "第" + headrow + "行,联系人姓名,未导入<br>";
|
|
|
355
|
+ continue;
|
|
|
356
|
+ }
|
|
|
357
|
+ if (string.IsNullOrEmpty(dr["联系人电话"].ToString()))
|
|
|
358
|
+ {
|
|
|
359
|
+ msg = msg + "第" + headrow + "行,联系人电话,未导入<br>";
|
|
|
360
|
+ continue;
|
|
|
361
|
+ }
|
|
|
362
|
+ var cusmodel = new BLL .T_Cus_CustomerBase().GetModelBy(dr["联系人电话"].ToString(), dr["联系人姓名"].ToString());
|
|
|
363
|
+ if (cusmodel!=null )
|
|
|
364
|
+ {
|
|
|
365
|
+ msg = msg + "第" + headrow + "行,该联系人已存在,未导入<br>";
|
|
|
366
|
+ continue;
|
|
|
367
|
+ }
|
|
|
368
|
+ Model.T_Cus_CustomerBase model = new Model.T_Cus_CustomerBase();
|
|
|
369
|
+ model.F_CustomerName = dr["联系人姓名"].ToString(); ; //
|
|
|
370
|
+ model.F_Sex = dr["性别"].ToString(); ;
|
|
|
371
|
+ model.F_Mobile = dr["联系人电话"].ToString(); ; //手机号码
|
|
|
372
|
+ model.F_Email = dr["邮箱"].ToString(); ; //手机号码 //Email
|
|
|
373
|
+ model.F_Address = dr["地址"].ToString(); ; //部门
|
|
|
374
|
+ model.F_CreateBy = User.F_UserId;
|
|
|
375
|
+ model.F_CreatedOn = DateTime.Now;
|
|
|
376
|
+ model.F_DeleteFlag = 0;
|
|
|
377
|
+ if (new BLL.T_Cus_CustomerBase().Add(model) <= 0)
|
|
|
378
|
+ {
|
|
|
379
|
+
|
|
|
380
|
+ msg = msg + "第" + headrow + "行,客户电话重复,未导入<br>";
|
|
|
381
|
+ }
|
|
|
382
|
+ }
|
|
|
383
|
+ if (string.IsNullOrEmpty(msg))
|
|
|
384
|
+ return Success("导入成功 ");
|
|
|
385
|
+ else
|
|
|
386
|
+ return Error(msg);
|
|
|
387
|
+ }
|
|
|
388
|
+ }
|
|
|
389
|
+ return Error("数据源上传失败");
|
|
|
390
|
+
|
|
|
391
|
+ }
|
|
|
392
|
+
|
|
316
|
393
|
/// <summary>
|
|
317
|
394
|
/// 导出客户信息
|
|
318
|
395
|
/// </summary>
|
|
|
@@ -324,8 +401,6 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
324
|
401
|
NPOIHelper npoi = new NPOIHelper();
|
|
325
|
402
|
string chargeDept = HttpUtility.UrlDecode(RequestString.GetQueryString("chargeDept"));
|
|
326
|
403
|
string keyWord = HttpUtility.UrlDecode(RequestString.GetQueryString("keyWord"));
|
|
327
|
|
- //string strstarttime = HttpUtility.UrlDecode(RequestString.GetQueryString("starttime"));
|
|
328
|
|
- //string strendtime = HttpUtility.UrlDecode(RequestString.GetQueryString("endtime"));
|
|
329
|
404
|
|
|
330
|
405
|
if (chargeDept.Trim() != "" && chargeDept != "undefined")
|
|
331
|
406
|
{
|
|
|
@@ -335,14 +410,7 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
335
|
410
|
{
|
|
336
|
411
|
sql += " and (F_Telephone like '%" + keyWord + "%' or F_Mobile like '%" + keyWord + "%' or F_ChargeTelephone like '%" + keyWord + "%' or F_Fax like '%" + keyWord + "%' or F_CustomerName like '%" + keyWord + "%') ";
|
|
337
|
412
|
}
|
|
338
|
|
- //if (strstarttime.Trim() != "" && strstarttime != "undefined")
|
|
339
|
|
- //{
|
|
340
|
|
- // sql += " and datediff(day,F_CreatedOn,'" + strstarttime + "')<=0 ";
|
|
341
|
|
- //}
|
|
342
|
|
- //if (strendtime.Trim() != "" && strendtime != "undefined")
|
|
343
|
|
- //{
|
|
344
|
|
- // sql += " and datediff(day,F_CreatedOn,'" + strendtime + "')>=0 ";
|
|
345
|
|
- //}
|
|
|
413
|
+
|
|
346
|
414
|
DataTable dt = bll.GetList(" F_DeleteFlag=0 " + sql).Tables[0];
|
|
347
|
415
|
string result = npoi.ExportToExcel("客户信息", dt);
|
|
348
|
416
|
|