|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
using CallCenter.Utility;
|
|
2
|
2
|
using CallCenterApi.DB;
|
|
3
|
3
|
using CallCenterApi.Interface.Controllers.Base;
|
|
|
4
|
+using CallCenterApi.Interface.Models.Dto;
|
|
4
|
5
|
using System;
|
|
5
|
6
|
using System.Collections.Generic;
|
|
6
|
7
|
using System.Data;
|
|
|
@@ -10,7 +11,7 @@ using System.Web.Mvc;
|
|
10
|
11
|
|
|
11
|
12
|
namespace CallCenterApi.Interface.Controllers.customer
|
|
12
|
13
|
{
|
|
13
|
|
- [Authority]
|
|
|
14
|
+ //[Authority]
|
|
14
|
15
|
public class AddressBookController : BaseController
|
|
15
|
16
|
{
|
|
16
|
17
|
BLL.T_Cus_AddressBook bll = new BLL.T_Cus_AddressBook();
|
|
|
@@ -353,41 +354,72 @@ namespace CallCenterApi.Interface.Controllers.customer
|
|
353
|
354
|
/// <returns></returns>
|
|
354
|
355
|
public ActionResult GetAppList()
|
|
355
|
356
|
{
|
|
356
|
|
- //BLL.T_Cus_AddressBook bll = new BLL.T_Cus_AddressBook();
|
|
357
|
357
|
string keyWord = string.Empty;
|
|
358
|
358
|
DataTable dt = new DataTable();
|
|
359
|
|
- string sql = " 1=1 and F_IsDelete=0 ";
|
|
360
|
|
-
|
|
361
|
359
|
keyWord = RequestString.GetQueryString("keyWord");
|
|
|
360
|
+ string sql = " 1=1 and F_IsDelete=0 ";
|
|
362
|
361
|
string sqlkey = "SELECT F_ValueId FROM T_Sys_DictionaryValue WHERE F_Value LIKE '%" + keyWord + "%'";
|
|
363
|
362
|
if (!string.IsNullOrWhiteSpace(keyWord))
|
|
364
|
363
|
{
|
|
365
|
364
|
sql += " and (F_Name like '%" + keyWord + "%' or F_Telephone like '%" + keyWord + "%' or F_Mobile like '%" + keyWord + "%' or F_ElseMobile like '%" + keyWord + "%' or F_CompanyId IN (" + sqlkey + ") or F_DepartmentId IN (" + sqlkey + ") or F_PositionId IN (" + sqlkey + ") ) ";
|
|
366
|
365
|
}
|
|
367
|
366
|
List<Model.T_Cus_AddressBook> modelList = bll.GetModelList(sql);
|
|
368
|
|
- return Success("获取成功",
|
|
369
|
|
- modelList.Select(x => new
|
|
|
367
|
+
|
|
|
368
|
+ List<AddressBookDto> modellists = modelList.Select(x => new AddressBookDto()
|
|
|
369
|
+ {
|
|
|
370
|
+ F_UserId = x.F_UserId,
|
|
|
371
|
+ NameOneCode = ChineseToPinYin.GetSpellOneCode(x.F_Name).ToUpper(), //姓名第一个字母
|
|
|
372
|
+ F_Name = x.F_Name, //姓名
|
|
|
373
|
+ F_Sex = x.F_Sex, //性别
|
|
|
374
|
+ F_Address = x.F_Address, //地址
|
|
|
375
|
+ F_Email = x.F_Email, //邮件
|
|
|
376
|
+ F_Telephone = x.F_Telephone, //单位电话
|
|
|
377
|
+ F_Mobile = x.F_Mobile, //手机号
|
|
|
378
|
+ F_ElseMobile = x.F_ElseMobile,//其他电话
|
|
|
379
|
+ F_Company = x.F_Company, //单位
|
|
|
380
|
+ F_Department = x.F_Department, //部门
|
|
|
381
|
+ F_Position = x.F_Position, //职务
|
|
|
382
|
+ F_Note = x.F_Note //备注
|
|
|
383
|
+ }).ToList();
|
|
|
384
|
+ //去掉其他元素
|
|
|
385
|
+ List<AddressBookCodeDto> resultList = modellists.Select(x => new AddressBookCodeDto()
|
|
|
386
|
+ {
|
|
|
387
|
+ NameOneCode = ChineseToPinYin.GetSpellOneCode(x.F_Name).ToUpper() //姓名第一个字母
|
|
|
388
|
+ }).ToList();
|
|
|
389
|
+ //去重
|
|
|
390
|
+ for (int i = 0; i < resultList.Count; i++) //外循环是循环的次数
|
|
|
391
|
+ {
|
|
|
392
|
+ for (int j = resultList.Count - 1; j > i; j--) //内循环是 外循环一次比较的次数
|
|
370
|
393
|
{
|
|
371
|
|
- F_UserId = x.F_UserId,
|
|
372
|
|
- F_Name = x.F_Name, //姓名
|
|
373
|
|
- F_Sex = x.F_Sex, //性别
|
|
374
|
|
- //F_Birthday = x.F_Birthday, //生日
|
|
375
|
|
- //F_IDCard = x.F_IDCard, //身份证
|
|
376
|
|
- //F_Education = x.F_Education, //学历
|
|
377
|
|
- F_Address = x.F_Address, //地址
|
|
378
|
|
- F_Email = x.F_Email, //邮件
|
|
379
|
|
- F_Telephone = x.F_Telephone, //单位电话
|
|
380
|
|
- F_Mobile = x.F_Mobile, //手机号
|
|
381
|
|
- F_ElseMobile = x.F_ElseMobile,//其他电话
|
|
382
|
|
- //F_CompanyId = x.F_CompanyId, //单位Id
|
|
383
|
|
- F_Company = x.F_Company, //单位
|
|
384
|
|
- //F_DepartmentId = x.F_DepartmentId, //部门Id
|
|
385
|
|
- F_Department = x.F_Department, //部门
|
|
386
|
|
- //F_PositionId = x.F_PositionId, //职务Id
|
|
387
|
|
- F_Position = x.F_Position, //职务
|
|
388
|
|
- F_Note = x.F_Note //备注
|
|
389
|
|
- })
|
|
390
|
|
- );
|
|
|
394
|
+ if (resultList[i].NameOneCode == resultList[j].NameOneCode)
|
|
|
395
|
+ {
|
|
|
396
|
+ resultList.RemoveAt(j);
|
|
|
397
|
+ }
|
|
|
398
|
+ }
|
|
|
399
|
+ }
|
|
|
400
|
+ //排序
|
|
|
401
|
+ var modelListOrder = resultList.OrderBy(x => x.NameOneCode);
|
|
|
402
|
+
|
|
|
403
|
+ //获取数组
|
|
|
404
|
+ var list = new List<AddressBookCodeDto>();
|
|
|
405
|
+ foreach (var item in modelListOrder)
|
|
|
406
|
+ {
|
|
|
407
|
+ var modellist_olds = modellists.Where(y => y.NameOneCode == item.NameOneCode).ToList();
|
|
|
408
|
+
|
|
|
409
|
+ list.Add(new AddressBookCodeDto
|
|
|
410
|
+ {
|
|
|
411
|
+ NameOneCode = item.NameOneCode,
|
|
|
412
|
+ AddressBooklist = modellist_olds
|
|
|
413
|
+ });
|
|
|
414
|
+ }
|
|
|
415
|
+
|
|
|
416
|
+ var obj = new
|
|
|
417
|
+ {
|
|
|
418
|
+ state = "success",
|
|
|
419
|
+ message = "获取成功",
|
|
|
420
|
+ rows = list
|
|
|
421
|
+ };
|
|
|
422
|
+ return Content(obj.ToJson());
|
|
391
|
423
|
}
|
|
392
|
424
|
|
|
393
|
425
|
#endregion
|