|
@@ -27,6 +27,7 @@ using System.Runtime.Intrinsics.Arm;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Xml.Linq;
|
|
|
+using XAct;
|
|
|
using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
|
|
|
using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
|
|
|
|
|
@@ -209,8 +210,10 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
/// <returns></returns>
|
|
|
public async Task<Result> QueryNewClientData(NewClientDataQueryDto dto)
|
|
|
{
|
|
|
+ Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
|
|
+ int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
|
|
|
try
|
|
|
{
|
|
|
#region 交集
|
|
@@ -290,36 +293,8 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- //foreach (var item in intList)
|
|
|
- //{
|
|
|
- // NewClientDataId += item + ",";
|
|
|
- //}
|
|
|
- //if (!string.IsNullOrWhiteSpace(NewClientDataId))
|
|
|
- //{
|
|
|
- // NewClientDataId = NewClientDataId.Substring(0, NewClientDataId.Length - 1);
|
|
|
- //}
|
|
|
- Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
-
|
|
|
- //var clientDatas = await NewClientDataRedis(1);
|
|
|
-
|
|
|
-
|
|
|
- var clientDatas = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (state == -1)
|
|
|
- {
|
|
|
- clientDatas = clientDatas.WhereIF(intList.Count > 0, x => intList.Contains(x.Id)).ToList();
|
|
|
- }
|
|
|
-
|
|
|
- #region 地市州条件
|
|
|
- if (dto.Lvlid != 0)
|
|
|
- {
|
|
|
- clientDatas = clientDatas.Where(x => x.Lvlid == dto.Lvlid).ToList();
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
#region 省域条件
|
|
|
+ var rangeSetDataList = new List<int>();
|
|
|
if (dto.Range != 0)
|
|
|
{
|
|
|
string setDataSql = "select * from Sys_SetData where STid = 33 and isdel = 0 ";
|
|
@@ -357,55 +332,77 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- var RangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
|
|
|
-
|
|
|
- clientDatas = clientDatas.WhereIF(RangeSetDataList.Count > 0, x => RangeSetDataList.Contains(x.Lvlid)).ToList();
|
|
|
+ rangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region 客户类别
|
|
|
- clientDatas = clientDatas.WhereIF(dto.Category > 0, x => x.Category == dto.Category).ToList();
|
|
|
- #endregion
|
|
|
-
|
|
|
- string contact = dto.Contact,location = dto.Location,clientDto = dto.Client;
|
|
|
+ var NewClientDataView = new List<NewClientDataView>();
|
|
|
+ var count = 0;
|
|
|
+ string contact = dto.Contact, location = dto.Location, clientDto = dto.Client;
|
|
|
+ if (string.IsNullOrEmpty(contact) && string.IsNullOrEmpty(location) && string.IsNullOrEmpty(clientDto)) //数据库分页
|
|
|
+ {
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var clientDatas = await _sqlSugar.Queryable<Crm_NewClientData>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .WhereIF(intList.Count > 0, x => intList.Contains(x.Id))
|
|
|
+ .WhereIF(dto.Lvlid != 0, x => x.Lvlid == dto.Lvlid) //地市州条件
|
|
|
+ .WhereIF(rangeSetDataList.Count > 0, x => rangeSetDataList.Contains(x.Lvlid)) //省域条件
|
|
|
+ .WhereIF(dto.Category > 0, x => x.Category == dto.Category) //客户类别
|
|
|
+ .OrderByDescending(x => x.CreateTime)
|
|
|
+ .ToPageListAsync(pageIndex, pageSize, total);
|
|
|
+
|
|
|
+ NewClientDataView = _mapper.Map<List<NewClientDataView>>(clientDatas);
|
|
|
+ count = total;
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(contact) || !string.IsNullOrEmpty(location) || !string.IsNullOrEmpty(clientDto))
|
|
|
+ }
|
|
|
+ else //代码层分页
|
|
|
{
|
|
|
- foreach (var data in clientDatas)
|
|
|
+ var clientDatas = await _sqlSugar.Queryable<Crm_NewClientData>()
|
|
|
+ .Where(x => x.IsDel == 0)
|
|
|
+ .WhereIF(intList.Count > 0, x => intList.Contains(x.Id))
|
|
|
+ .WhereIF(dto.Lvlid != 0, x => x.Lvlid == dto.Lvlid) //地市州条件
|
|
|
+ .WhereIF(rangeSetDataList.Count > 0, x => rangeSetDataList.Contains(x.Lvlid)) //省域条件
|
|
|
+ .WhereIF(dto.Category > 0, x => x.Category == dto.Category) //客户类别
|
|
|
+ .OrderByDescending(x => x.CreateTime)
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(contact) || !string.IsNullOrEmpty(location) || !string.IsNullOrEmpty(clientDto))
|
|
|
{
|
|
|
- //EncryptionProcessor.DecryptProperties(data);
|
|
|
- if (!string.IsNullOrEmpty(contact)) data.Contact = AesEncryptionHelper.Decrypt(data.Contact);
|
|
|
- if (!string.IsNullOrEmpty(location)) data.Location = AesEncryptionHelper.Decrypt(data.Location);
|
|
|
- if (!string.IsNullOrEmpty(clientDto)) data.Client = AesEncryptionHelper.Decrypt(data.Client);
|
|
|
+ foreach (var data in clientDatas)
|
|
|
+ {
|
|
|
+ //EncryptionProcessor.DecryptProperties(data);
|
|
|
+ if (!string.IsNullOrEmpty(contact)) data.Contact = AesEncryptionHelper.Decrypt(data.Contact);
|
|
|
+ if (!string.IsNullOrEmpty(location)) data.Location = AesEncryptionHelper.Decrypt(data.Location);
|
|
|
+ if (!string.IsNullOrEmpty(clientDto)) data.Client = AesEncryptionHelper.Decrypt(data.Client);
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (dto.PortType == 1)
|
|
|
- {
|
|
|
- clientDatas = clientDatas
|
|
|
- .WhereIF(!string.IsNullOrEmpty(contact), x => !string.IsNullOrEmpty(x.Contact) && x.Contact.Contains(contact)) //联系人条件
|
|
|
- .WhereIF(!string.IsNullOrEmpty(location), x => !string.IsNullOrEmpty(x.Location) && x.Location.Contains(location)) //地区条件
|
|
|
- .WhereIF(!string.IsNullOrEmpty(clientDto), x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains(clientDto)) //单位条件
|
|
|
- .ToList();
|
|
|
|
|
|
- }
|
|
|
- else if (dto.PortType == 2 || dto.PortType == 3)
|
|
|
- {
|
|
|
- clientDatas = clientDatas.Where(x => x.Contact.Contains(clientDto) || x.Location.Contains(clientDto) || x.Client.Contains(clientDto)).ToList();
|
|
|
- }
|
|
|
+ if (dto.PortType == 1)
|
|
|
+ {
|
|
|
+ clientDatas = clientDatas
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(contact), x => !string.IsNullOrEmpty(x.Contact) && x.Contact.Contains(contact)) //联系人条件
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(location), x => !string.IsNullOrEmpty(x.Location) && x.Location.Contains(location)) //地区条件
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(clientDto), x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains(clientDto)) //单位条件
|
|
|
+ .ToList();
|
|
|
|
|
|
- int pIndex = dto.PageIndex * dto.PageSize - dto.PageSize + 1;
|
|
|
- int pSize = dto.PageIndex * dto.PageSize;
|
|
|
- int skip = (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ }
|
|
|
+ else if (dto.PortType == 2 || dto.PortType == 3)
|
|
|
+ {
|
|
|
+ clientDatas = clientDatas.Where(x => x.Contact.Contains(clientDto) || x.Location.Contains(clientDto) || x.Client.Contains(clientDto)).ToList();
|
|
|
+ }
|
|
|
|
|
|
- var pageData = clientDatas.OrderByDescending(x => x.CreateTime).Skip(skip).Take(dto.PageSize).ToList();
|
|
|
+ int pIndex = dto.PageIndex * dto.PageSize - dto.PageSize + 1;
|
|
|
+ int pSize = dto.PageIndex * dto.PageSize;
|
|
|
+ int skip = (dto.PageIndex - 1) * dto.PageSize;
|
|
|
+ count = clientDatas.Count;
|
|
|
+ var pageData = clientDatas.OrderByDescending(x => x.CreateTime).Skip(skip).Take(dto.PageSize).ToList();
|
|
|
+ NewClientDataView = _mapper.Map<List<NewClientDataView>>(clientDatas);
|
|
|
+ }
|
|
|
|
|
|
- var NewClientDataView = _mapper.Map<List<NewClientDataView>>(pageData);
|
|
|
var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
|
|
|
|
|
|
-
|
|
|
#region 下拉框初始化数据
|
|
|
//负责人下拉框
|
|
|
var _Users = GetNewExistClient(dto.OperationUserId).Select(x => new { x.Id, Name = x.CnName }).ToList();
|
|
@@ -423,11 +420,11 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
var _ServiceClass = setDatas.Where(u => u.STid == 36).Select(x => new { x.Id, x.Name }).ToList();
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
var groupNumber = await QueryNumberGroups();
|
|
|
- stopwatch.Stop();
|
|
|
+
|
|
|
if (NewClientDataView.Count > 0)
|
|
|
{
|
|
|
- int count = clientDatas.Count;
|
|
|
float totalPage = (float)count / dto.PageSize;//总页数
|
|
|
if (totalPage == 0) totalPage = 1;
|
|
|
else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
@@ -437,20 +434,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
int index = 1;
|
|
|
foreach (var item in NewClientDataView)
|
|
|
{
|
|
|
- //EncryptionProcessor.DecryptProperties(item);
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty(contact)) item.Contact = AesEncryptionHelper.Decrypt(item.Contact);
|
|
|
- if (string.IsNullOrEmpty(location)) item.Location = AesEncryptionHelper.Decrypt(item.Location);
|
|
|
- if (string.IsNullOrEmpty(clientDto)) item.Client = AesEncryptionHelper.Decrypt(item.Client);
|
|
|
-
|
|
|
- item.Wechat = AesEncryptionHelper.Decrypt(item.Wechat);
|
|
|
- item.Job = AesEncryptionHelper.Decrypt(item.Job);
|
|
|
- item.Telephone = AesEncryptionHelper.Decrypt(item.Telephone);
|
|
|
- item.Phone = AesEncryptionHelper.Decrypt(item.Phone);
|
|
|
- item.Remark = AesEncryptionHelper.Decrypt(item.Remark);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ EncryptionProcessor.DecryptProperties(item); //解密
|
|
|
item.RowNumber = index;
|
|
|
item.CategoryStr = setDatas.Find(x => x.Id == item.Category)?.Name ?? "-";
|
|
|
item.LvlidStr = setDatas.Find(x => x.Id == item.Lvlid)?.Name ?? "-";
|
|
@@ -491,27 +475,27 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
int index = 1;
|
|
|
foreach (var item in NewClientDataView)
|
|
|
{
|
|
|
- //newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
|
- //{
|
|
|
- // RowNumber = index,
|
|
|
- // Id = item.Id,
|
|
|
- // Client = AesEncryptionHelper.Decrypt( item.Client),
|
|
|
- // Contact = AesEncryptionHelper.Decrypt(item.Contact),
|
|
|
- // Job = AesEncryptionHelper.Decrypt(item.Job),
|
|
|
- // Telephone = AesEncryptionHelper.Decrypt(item.Telephone),
|
|
|
- // Location = AesEncryptionHelper.Decrypt(item.Location),
|
|
|
- //});
|
|
|
-
|
|
|
newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
|
{
|
|
|
RowNumber = index,
|
|
|
Id = item.Id,
|
|
|
- Client = item.Client,
|
|
|
- Contact = item.Contact,
|
|
|
- Job = item.Job,
|
|
|
- Telephone = item.Telephone,
|
|
|
- Location = item.Location,
|
|
|
+ Client = AesEncryptionHelper.Decrypt(item.Client),
|
|
|
+ Contact = AesEncryptionHelper.Decrypt(item.Contact),
|
|
|
+ Job = AesEncryptionHelper.Decrypt(item.Job),
|
|
|
+ Telephone = AesEncryptionHelper.Decrypt(item.Telephone),
|
|
|
+ Location = AesEncryptionHelper.Decrypt(item.Location),
|
|
|
});
|
|
|
+
|
|
|
+ //newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
|
+ //{
|
|
|
+ // RowNumber = index,
|
|
|
+ // Id = item.Id,
|
|
|
+ // Client = item.Client,
|
|
|
+ // Contact = item.Contact,
|
|
|
+ // Job = item.Job,
|
|
|
+ // Telephone = item.Telephone,
|
|
|
+ // Location = item.Location,
|
|
|
+ //});
|
|
|
index++;
|
|
|
}
|
|
|
|
|
@@ -552,6 +536,9 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
{
|
|
|
result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
}
|
|
|
+
|
|
|
+ stopwatch.Stop();
|
|
|
+ result.Msg = $"耗时: {stopwatch.ElapsedMilliseconds} 毫秒";
|
|
|
return result;
|
|
|
}
|
|
|
|