|
|
using Amazon.Runtime.Internal;
|
|
|
using DS.Module.Core;
|
|
|
using DS.Module.Core.Constants;
|
|
|
using DS.Module.Core.Data;
|
|
|
using DS.Module.Core.Extensions;
|
|
|
using DS.Module.Core.Log;
|
|
|
using DS.Module.SqlSugar;
|
|
|
using DS.Module.UserModule;
|
|
|
using DS.WMS.Core.Code.Dtos;
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
using DS.WMS.Core.Info.Dtos;
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
using DS.WMS.Core.Op.Dtos;
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
using DS.WMS.Core.Op.Method;
|
|
|
using DS.WMS.Core.Sys.Dtos;
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
using LogicExtensions;
|
|
|
using Mapster;
|
|
|
using Masuit.Tools;
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using SqlSugar;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
|
|
|
namespace DS.WMS.Core.Sys.Method;
|
|
|
|
|
|
public class ClientCommonService : IClientCommonService
|
|
|
{
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
private readonly ISqlSugarClient db;
|
|
|
private readonly IUser user;
|
|
|
private readonly ISaasDbService saasService;
|
|
|
private readonly ICommonService commonService;
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
public ClientCommonService(IServiceProvider serviceProvider)
|
|
|
{
|
|
|
_serviceProvider = serviceProvider;
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
commonService = _serviceProvider.GetRequiredService<ICommonService>();
|
|
|
}
|
|
|
|
|
|
internal ISugarQueryable<SysDictData> DicQueryable(string typeCode, string queryKey)
|
|
|
{
|
|
|
return db.Queryable<SysDictData>().InnerJoin<SysDictType>((d, t) => d.TypeId == t.Id)
|
|
|
.Where((d, t) => t.Code == typeCode)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), (d, t) => d.Name.Contains(queryKey));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取当前机构银行信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<BankRes>>> GetOrgBankListAsync()
|
|
|
{
|
|
|
var list = await db.Queryable<SysBank>()
|
|
|
.Where(x => x.LinkId == user.OrgId && x.Status == StatusEnum.Enable)
|
|
|
.Select<BankRes>().ToListAsync();
|
|
|
var result = DataResult<List<BankRes>>.Success(list);
|
|
|
result.Count = list.Count;
|
|
|
return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取任务类型常量列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<TaskBaseTypeConstRes>>> GetTaskTypeConstList()
|
|
|
{
|
|
|
var data = new List<TaskBaseTypeConstRes>();
|
|
|
var list = EnumUtil.EnumToDictionary<TaskBaseTypeEnum>()
|
|
|
.Select(x => (x.Key, x.Value))
|
|
|
.ToList();
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
data.Add(new TaskBaseTypeConstRes()
|
|
|
{
|
|
|
Key = item.Key,
|
|
|
Value = item.Value.ToString()
|
|
|
});
|
|
|
}
|
|
|
return await Task.FromResult(DataResult<List<TaskBaseTypeConstRes>>.Success(data));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取服务项目下拉数据
|
|
|
/// </summary>
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
/// <param name="queryKey">搜索关键词</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<SelectListItem>>> GetServiceItemAsync(BusinessType businessType, string? queryKey = null)
|
|
|
{
|
|
|
string typeCode;
|
|
|
switch (businessType)
|
|
|
{
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
typeCode = "se-service-item";
|
|
|
break;
|
|
|
default:
|
|
|
typeCode = "N/A";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
var list = await DicQueryable(typeCode, queryKey).Select(d => new SelectListItem
|
|
|
{
|
|
|
Text = d.Name,
|
|
|
Value = d.Value
|
|
|
}).ToListAsync();
|
|
|
var result = DataResult<List<SelectListItem>>.Success(list);
|
|
|
result.Count = list.Count;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取结算方式
|
|
|
/// </summary>
|
|
|
/// <param name="queryKey">搜索关键词</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<CodeStlModeRes>>> GetStlModeAsync(string? queryKey = null)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = await tenantDb.Queryable<CodeStlMode>().Where(x => x.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), x => x.StlCode.Contains(queryKey) || x.StlName.Contains(queryKey))
|
|
|
.Select<CodeStlModeRes>().ToListAsync();
|
|
|
var result = DataResult<List<CodeStlModeRes>>.Success(list);
|
|
|
result.Count = list.Count;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取客户银行
|
|
|
/// </summary>
|
|
|
/// <param name="id">客户ID</param>
|
|
|
/// <param name="queryKey">搜索关键词</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ClientBankRes>>> GetClientBankAsync(long id, string? queryKey = null)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = await tenantDb.Queryable<InfoClientBank>()
|
|
|
.Where(x => x.ClientId == id && x.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), x => x.CodeName.Contains(queryKey) || x.BankName.Contains(queryKey) || x.Currency.Contains(queryKey))
|
|
|
.Select<ClientBankRes>().ToListAsync();
|
|
|
var result = DataResult<List<ClientBankRes>>.Success(list);
|
|
|
result.Count = list.Count;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据五字码获取港口信息-客户端
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<CodePortInfoRes>> GetClientPortInfoByCode(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = await tenantDb.Queryable<CodePort>()
|
|
|
.Where(x => x.Status == StatusEnum.Enable && x.EdiCode == queryKey.Trim())
|
|
|
.Select<CodePortInfoRes>()
|
|
|
.FirstAsync();
|
|
|
return await Task.FromResult(DataResult<CodePortInfoRes>.Success("获取数据成功!", data));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取航线操作员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<UserSelectRes>>> GetLaneUserList(string queryKey = "")
|
|
|
{
|
|
|
var data = await db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsLaner == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}")
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取委托单位下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ControllerClientRes>>> GetControllerClientListByKey(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
var orglist = db.Queryable<SysOrg>().ToList();
|
|
|
|
|
|
var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true)
|
|
|
.Select<ClientContactRes>().ToListAsync();
|
|
|
var conditions = new List<IConditionalModel>();
|
|
|
var otherConditions = new List<IConditionalModel>();
|
|
|
var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt());
|
|
|
//var query = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>();
|
|
|
var scope = string.Empty;
|
|
|
(conditions, scope, otherConditions) = await commonService.GetSpecialVisibleDataRuleFilter<InfoClient>(queryData, tenantDb);
|
|
|
var userids = new List<string>();
|
|
|
if (otherConditions.Count > 0)
|
|
|
{
|
|
|
foreach (ConditionalTree item in otherConditions)
|
|
|
{
|
|
|
Console.WriteLine(item.ConditionalList);
|
|
|
if (item.ConditionalList.Count > 0)
|
|
|
{
|
|
|
foreach (var item1 in item.ConditionalList)
|
|
|
{
|
|
|
var temp = item1.Value as SqlSugar.ConditionalModel;
|
|
|
if (temp.FieldName == "Stakeholders")
|
|
|
{
|
|
|
userids = temp.FieldValue.Split(',').ToList();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (userids.Count == 0)
|
|
|
{
|
|
|
userids.Add(user.UserId);
|
|
|
}
|
|
|
//干系人合集
|
|
|
var exp = Expressionable.Create<InfoClient>();
|
|
|
exp = exp.And(c => SqlFunc.Subqueryable<InfoClientStakeholder>().Where("SYSDATE() BETWEEN StartDate and EndDate").Where(x => userids.Contains(x.UserId.ToString()) && x.ClientId == c.Id).Any());
|
|
|
|
|
|
var queryData1 = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt()).Where(exp.ToExpression());
|
|
|
var queryData2 = queryData.Where(conditions);
|
|
|
var queryData0 = tenantDb.UnionAll(queryData1, queryData2);
|
|
|
//code = code.ToLower();
|
|
|
var data = await queryData0
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true) //&& c.CreateBy == long.Parse(user.UserId) && c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now
|
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
|
|
|
.Select((a, b) => new ControllerClientRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
PinYinCode = a.ShortName + "(" + a.Description + ")" + " " + a.CodeName,
|
|
|
//UserIds = a.Stakeholders.Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now).Select(n=>n.CreateBy).ToList()
|
|
|
}, true
|
|
|
).ClearFilter<ISharedOrgId>()
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientContact = contacts.Where(x => x.ClientId == it.Id).FirstOrDefault();
|
|
|
})
|
|
|
//.MergeTable()
|
|
|
.Distinct().Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync(); ;
|
|
|
//(query, _) = await commonService.GetVisibleDataRuleFilter<ControllerClientRes>(query, tenantDb);
|
|
|
//var data = await query.Where(a=>a.UserIds.Contains(long.Parse(user.UserId)))
|
|
|
// .Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
|
|
|
|
|
|
//var data = await tenantDb.Queryable<InfoClient>()
|
|
|
// .InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
// .Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true)
|
|
|
// .WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
|
|
|
// .Select((a, b) => new ControllerClientRes
|
|
|
// {
|
|
|
// Id = a.Id,
|
|
|
// PinYinCode = a.ShortName + "(" + a.CodeName + ")",
|
|
|
// //SaleOrgName = string.IsNullOrEmpty(a.SaleOrgId) ? "": orglist.Where(x=>x.Id == long.Parse(a.SaleOrgId)).FirstOrDefault().OrgName
|
|
|
// }, true
|
|
|
// )
|
|
|
// .Mapper(it =>
|
|
|
// {
|
|
|
// it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true)
|
|
|
// .Select<ClientContactRes>().First();
|
|
|
// })
|
|
|
// .Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
|
|
|
|
|
|
return await Task.FromResult(DataResult<List<ControllerClientRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取船公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<CodeCarrierRes>>> GetCarrierSelectList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = await tenantDb.Queryable<CodeCarrier>()
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.Code.Contains(queryKey) || a.CnName.Contains(queryKey) || a.EnName.Contains(queryKey) || a.CnShortName.Contains(queryKey) )
|
|
|
.Select(a => new CodeCarrierRes()
|
|
|
{
|
|
|
PinYinCode = a.Code + "(" + a.CnName + ")",
|
|
|
},
|
|
|
true)
|
|
|
.OrderBy(a => a.Code)
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Carrier}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<CodeCarrierRes>>.Success("获取数据成功!", list));
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取约号下拉列表-客户端
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<BookingContractNoSelectRes>>> GetBookingContractNoList(string queryKey = "", long carrierId = 0)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = await tenantDb.Queryable<BookingContractNoManage>()
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.ContractNo.Contains(queryKey) || a.ContractName.Contains(queryKey))
|
|
|
.WhereIF(carrierId != 0, a => a.CarrierId == carrierId)
|
|
|
.Select<BookingContractNoSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.ContractNo}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<BookingContractNoSelectRes>>.Success("获取数据成功!", list));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取商品下拉列表-客户端
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<CodeGoodsSelectRes>>> GetClientGoodsList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = await tenantDb.Queryable<CodeGoods>().Where(a => a.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.GoodsCode.Contains(queryKey) || a.GoodName.Contains(queryKey))
|
|
|
.Select(a => new CodeGoodsSelectRes()
|
|
|
{
|
|
|
PinYinCode = a.GoodName + "(" + a.GoodsCode + ")",
|
|
|
},
|
|
|
true)
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Goods}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<CodeGoodsSelectRes>>.Success("获取数据成功!", list));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据id获取往来单位参数信息
|
|
|
/// </summary>
|
|
|
/// <param name="id"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ClientParamRes>>> GetClientParamListById(string id)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = await tenantDb.Queryable<InfoClientParam>()
|
|
|
.Where(x => x.CustomerId == long.Parse(id) && x.Status == StatusEnum.Enable)
|
|
|
.Select<ClientParamRes>()
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<ClientParamRes>>.Success(data));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据用户ids获取用户邮箱信息
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<UserSelectRes>>> GetUseEmailListByIds(long[] ids)
|
|
|
{
|
|
|
var data = await db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && ids.Contains(a.Id))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<UserSelectRes>>.Success(data));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据类型获取用户下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ApiSelectViewModel>>> GetUserListByCode(string code, string queryKey = "")
|
|
|
{
|
|
|
code = code.ToLower();
|
|
|
var data = await db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt())
|
|
|
.WhereIF(code == "operator", a => a.IsOperator == true)
|
|
|
.WhereIF(code == "doc", a => a.IsVouchingClerk == true)
|
|
|
.WhereIF(code == "sale", a => a.IsSale == true)
|
|
|
.WhereIF(code == "custom", a => a.IsCustom == true)
|
|
|
.WhereIF(code == "finance", a => a.IsFinancialStaff == true)
|
|
|
.WhereIF(code == "service", a => a.IsCustomerService == true)
|
|
|
.WhereIF(code == "driver", a => a.IsDriver == true)
|
|
|
.WhereIF(code == "dispatcher", a => a.IsDispatcher == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select(a => new ApiSelectViewModel
|
|
|
{
|
|
|
Label = a.PinYinCode,
|
|
|
Value = a.Id,
|
|
|
})
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToListAsync();
|
|
|
return DataResult<List<ApiSelectViewModel>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取工厂信息下拉列表-客户端
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodeFactorySelectRes>> GetFactorySelectList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var list = tenantDb.Queryable<CodeFactory>()
|
|
|
.Where(x => x.Status == StatusEnum.Enable)
|
|
|
.Select<CodeFactorySelectRes>()
|
|
|
.ToList();
|
|
|
return DataResult<List<CodeFactorySelectRes>>.Success("获取数据成功!", list);
|
|
|
}
|
|
|
#region 根据单位获取数量箱型信息
|
|
|
/// <summary>
|
|
|
/// 根据单位获取数量箱型信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<UnitSelectInfoRes> GetUnitSelectInfo(UnitSelectInfoReq req)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
//var data = new ClientSelectInfoRes();
|
|
|
if (req.BusinessType == BusinessType.OceanShippingExport)
|
|
|
{
|
|
|
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
|
|
|
if (info.IsNull())
|
|
|
{
|
|
|
return DataResult<UnitSelectInfoRes>.Failed("业务信息不存在!");
|
|
|
}
|
|
|
var ctns = tenantDb.Queryable<OpCtn>().Where(x => x.BSNO == req.BusinessId.ToString()).ToList();
|
|
|
|
|
|
var dictvalue = db.Queryable<SysDictData>().InnerJoin<SysDictType>((a, b) => a.TypeId == b.Id)
|
|
|
.Where((a, b) => b.Code == "fee_unit").Select((a, b) => a.Value).ToList();
|
|
|
if (dictvalue.Where(x => x == req.Code).Any())
|
|
|
{
|
|
|
var data = GetSeaExportUnit(info, req.Code);
|
|
|
return DataResult<UnitSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var codeCtns = tenantDb.Queryable<CodeCtn>().Where(x => x.Status == StatusEnum.Enable).ToList();
|
|
|
|
|
|
if (codeCtns.Where(x => x.CtnName == req.Code).Any())
|
|
|
{
|
|
|
//var data = GetSeaExportCtnsUnit(ctns, codeCtns, req.Code);
|
|
|
var codeCtn = codeCtns.First(x => x.CtnName == req.Code);
|
|
|
var ctns1 = ctns.Where(x => x.Ctn == req.Code).ToList();
|
|
|
|
|
|
var data = new UnitSelectInfoRes();
|
|
|
data.Code = req.Code;
|
|
|
data.Quantity = ctns1.Sum(x => x.CtnNum);
|
|
|
data.TEU = (int)data.Quantity * (int)codeCtn.TEU;
|
|
|
data.CtnTotalNum = ctns.Sum(x => x.CtnNum);
|
|
|
|
|
|
return DataResult<UnitSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
return DataResult<UnitSelectInfoRes>.Failed("没有维护该箱型的集装箱信息!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<UnitSelectInfoRes>.Failed("非法业务类型");
|
|
|
}
|
|
|
}
|
|
|
private UnitSelectInfoRes GetSeaExportUnit(SeaExport seaExport, string code)
|
|
|
{
|
|
|
|
|
|
var data = new UnitSelectInfoRes();
|
|
|
data.Code = code;
|
|
|
switch (code)
|
|
|
{
|
|
|
case "P"://单票
|
|
|
data.Quantity = 1;
|
|
|
break;
|
|
|
case "Z"://重量
|
|
|
data.Quantity = seaExport.KGS;
|
|
|
break;
|
|
|
case "C"://尺码
|
|
|
data.Quantity = seaExport.CBM;
|
|
|
break;
|
|
|
case "J"://件数
|
|
|
data.Quantity = seaExport.PKGS;
|
|
|
break;
|
|
|
case "TEU"://TEU
|
|
|
data.Quantity = seaExport.TEU;
|
|
|
break;
|
|
|
case "JF"://计费吨
|
|
|
data.Quantity = seaExport.KGS / 1000 > seaExport.CBM ? seaExport.KGS / 1000 : seaExport.CBM;
|
|
|
break;
|
|
|
//默认
|
|
|
default:
|
|
|
data.Quantity = 0;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#region 根据类型获取往来单位下拉及业务信息列表
|
|
|
/// <summary>
|
|
|
/// 根据类型获取往来单位下拉及业务信息列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<ClientSelectInfoRes>> GetClientSelectInfoByCode(ClientSelectInfoReq req)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
//var data = new ClientSelectInfoRes();
|
|
|
//var contacts = await tenantDb.Queryable<InfoClientContact>().Where(x => x.Status == StatusEnum.Enable && x.IsDefault == true).Select<ClientContactRes>().ToListAsync();
|
|
|
|
|
|
var code = req.Code.ToLower();
|
|
|
if (req.BusinessType == BusinessType.OceanShippingExport)
|
|
|
{
|
|
|
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
|
|
|
if (info.IsNull())
|
|
|
{
|
|
|
return DataResult<ClientSelectInfoRes>.Failed("业务信息不存在!");
|
|
|
}
|
|
|
//var list = await tenantDb.Queryable<InfoClient>()
|
|
|
//.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
//.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
|
|
|
////.WhereIF(code == "carrier", (a, b) => b.IsCarrier == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "yard", (a, b) => b.IsYard == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "booking", (a, b) => b.IsBooking == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "truck", (a, b) => b.IsTruck == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "controller", (a, b) => b.IsController == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "custom", (a, b) => b.IsCustom == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "agent", (a, b) => b.IsAgent == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "agentcn", (a, b) => b.IsAgentCn == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "express", (a, b) => b.IsExpress == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "airlines", (a, b) => b.IsAirLines == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "shipper", (a, b) => b.IsShipper == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "shippercn", (a, b) => b.IsShipperCn == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "notifyparty", (a, b) => b.IsNotifyParty == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "warehouse", (a, b) => b.IsWareHouse == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "wharf", (a, b) => b.IsWharf == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "insurer", (a, b) => b.IsInsurer == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "leasing", (a, b) => b.IsLeasing == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "tradingagency", (a, b) => b.IsTradingAgency == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "shipagency", (a, b) => b.IsShipAgency == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "enterprise", (a, b) => b.IsEnterprise == true)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(code) && code == "contract", (a, b) => b.IsContract == true)
|
|
|
//.WhereIF(string.IsNullOrEmpty(code), (a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
|
|
|
//.Select((a, b) => new ClientSelectRes
|
|
|
//{
|
|
|
// Id = a.Id,
|
|
|
// CodeName = a.CodeName,
|
|
|
// ShortName = a.ShortName,
|
|
|
// EnShortName = a.EnShortName,
|
|
|
// BLContent = a.BLContent,
|
|
|
//}
|
|
|
//)
|
|
|
////.Mapper(it =>
|
|
|
////{
|
|
|
//// //it.ClientContact = tenantDb.Queryable<InfoClientContact>().Where(x => x.ClientId == it.Id && x.Status == StatusEnum.Enable && x.IsDefault == true)
|
|
|
//// //.Select<ClientContactRes>().First();
|
|
|
//// it.ClientContact = contacts.Where(x => x.ClientId == it.Id).FirstOrDefault();
|
|
|
////})
|
|
|
//.ToListAsync();
|
|
|
var data = GetSeaExportClientInfo(info, code);
|
|
|
//data.ClientList = list;
|
|
|
return await Task.FromResult(DataResult<ClientSelectInfoRes>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return await Task.FromResult(DataResult<ClientSelectInfoRes>.Failed("非法业务类型"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ClientSelectInfoRes GetSeaExportClientInfo(SeaExport seaExport, string code)
|
|
|
{
|
|
|
|
|
|
var data = new ClientSelectInfoRes();
|
|
|
switch (code)
|
|
|
{
|
|
|
case "carrier":
|
|
|
data.ClientId = seaExport.CarrierId;
|
|
|
data.ClientName = seaExport.Carrier;
|
|
|
break;
|
|
|
case "yard":
|
|
|
data.ClientId = seaExport.YardId;
|
|
|
data.ClientName = seaExport.Yard;
|
|
|
break;
|
|
|
case "booking":
|
|
|
data.ClientId = seaExport.ForwarderId;
|
|
|
data.ClientName = seaExport.Forwarder;
|
|
|
break;
|
|
|
case "truck":
|
|
|
data.ClientId = seaExport.TruckerId;
|
|
|
data.ClientName = seaExport.Trucker;
|
|
|
break;
|
|
|
case "controller":
|
|
|
data.ClientId = seaExport.CustomerId;
|
|
|
data.ClientName = seaExport.CustomerName;
|
|
|
break;
|
|
|
case "custom":
|
|
|
data.ClientId = seaExport.CustomserId;
|
|
|
data.ClientName = seaExport.Customser;
|
|
|
break;
|
|
|
case "agent":
|
|
|
data.ClientId = seaExport.AgentId;
|
|
|
data.ClientName = seaExport.Agent;
|
|
|
break;
|
|
|
case "warehouse":
|
|
|
data.ClientId = seaExport.WareHouseId;
|
|
|
data.ClientName = seaExport.WareHouse;
|
|
|
break;
|
|
|
case "agentcn":
|
|
|
break;
|
|
|
case "express":
|
|
|
break;
|
|
|
case "airlines":
|
|
|
break;
|
|
|
case "wharf":
|
|
|
break;
|
|
|
case "insurer":
|
|
|
break;
|
|
|
case "leasing":
|
|
|
break;
|
|
|
case "enterprise":
|
|
|
data.ClientId = (long)seaExport.EnterpriseId;
|
|
|
data.ClientName = seaExport.Enterprise;
|
|
|
break;
|
|
|
case "shipper":
|
|
|
data.ClientId = (long)seaExport.ShipperId;
|
|
|
data.ClientName = seaExport.Shipper;
|
|
|
break;
|
|
|
case "shippercn":
|
|
|
data.ClientId = (long)seaExport.ShipperCnId;
|
|
|
data.ClientName = seaExport.ShipperCn;
|
|
|
break;
|
|
|
case "notifyparty":
|
|
|
data.ClientId = (long)seaExport.NotifyPartyId;
|
|
|
data.ClientName = seaExport.NotifyParty;
|
|
|
break;
|
|
|
case "tradingagency":
|
|
|
break;
|
|
|
case "shipagency":
|
|
|
data.ClientId = seaExport.ShipAgencyId;
|
|
|
data.ClientName = seaExport.ShipAgency;
|
|
|
break;
|
|
|
//默认
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 获取往来单位下拉集合列表
|
|
|
/// <summary>
|
|
|
/// 获取往来单位下拉集合列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ClientSelectMultiRes>>> GetMultiClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
var data = new List<ClientSelectMultiRes>();
|
|
|
var parList = tenantDb.Queryable<InfoClientParam>()
|
|
|
.Where(x => x.Status == StatusEnum.Enable)
|
|
|
.Select<ClientParamRes>()
|
|
|
.ToList();
|
|
|
|
|
|
var carrier = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsCarrier == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("carrier", carrier));
|
|
|
|
|
|
var yard = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsYard == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("yard", yard));
|
|
|
|
|
|
var booking = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsBooking == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("booking", booking));
|
|
|
|
|
|
var truck = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsTruck == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("truck", truck));
|
|
|
|
|
|
var controller = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsController == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("controller", controller));
|
|
|
|
|
|
var custom = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsCustom == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("custom", custom));
|
|
|
|
|
|
var agent = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAgent == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("agent", agent));
|
|
|
|
|
|
var agentcn = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAgentCn == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("agentcn", agentcn));
|
|
|
|
|
|
var express = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsExpress == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("express", express));
|
|
|
|
|
|
var airlines = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsAirLines == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("airlines", airlines));
|
|
|
|
|
|
var shipper = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipper == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("shipper", shipper));
|
|
|
|
|
|
var shippercn = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipperCn == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("shippercn", shippercn));
|
|
|
|
|
|
var notifyparty = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsNotifyParty == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("notifyparty", notifyparty));
|
|
|
|
|
|
|
|
|
var warehouse = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsWareHouse == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("warehouse", warehouse));
|
|
|
|
|
|
|
|
|
var wharf = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsWharf == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("wharf", wharf));
|
|
|
|
|
|
var insurer = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsInsurer == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("insurer", insurer));
|
|
|
|
|
|
var leasing = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsLeasing == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("leasing", leasing));
|
|
|
|
|
|
var tradingagency = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsTradingAgency == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("tradingagency", tradingagency));
|
|
|
|
|
|
var shipagency = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsShipAgency == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
data.Add(new ClientSelectMultiRes("shipagency", shipagency));
|
|
|
|
|
|
var enterprise = await tenantDb.Queryable<InfoClient>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt()).Where(a => SqlFunc.Subqueryable<InfoClientTag>().Where(s => s.ClientId == a.Id && s.IsEnterprise == true).Any())
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
Description = a.Description,
|
|
|
})
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.ClientParams = parList.Where(x => x.CustomerId == it.Id).ToList();
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
|
|
|
return await Task.FromResult(DataResult<List<ClientSelectMultiRes>>.Success(data));
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 提取汇率信息
|
|
|
/// </summary>
|
|
|
/// <param name="req"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<BusinessCurrencyExchangeRes> GetBusinessCurrencyExchangeInfo(BusinessCurrencyExchangeReq req)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
DateTime rateDate;
|
|
|
|
|
|
var data = new BusinessCurrencyExchangeRes();
|
|
|
|
|
|
var opConfig = tenantDb.Queryable<CodeConfig>().Where(x => x.Status == StatusEnum.Enable && x.Code == "ExchangeRateType").First();
|
|
|
if (opConfig.IsNotNull())
|
|
|
{
|
|
|
#region 根据分公司配置参数
|
|
|
if (req.BusinessType == BusinessType.OceanShippingExport)
|
|
|
{
|
|
|
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
|
|
|
if (opConfig.Value == "ETD")
|
|
|
{
|
|
|
if (order.ETD.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期不能为空!");
|
|
|
}
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else if (opConfig.Value == "AccountDate")
|
|
|
{
|
|
|
if (order.AccountDate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间不能为空!");
|
|
|
}
|
|
|
//var accountDateTime = DateTime.Parse(order.AccountDate +"-01");
|
|
|
|
|
|
if (DateTime.TryParse(order.AccountDate + "-01", out rateDate))
|
|
|
{
|
|
|
// 转换成功,可以使用date变量
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && rateDate >= x.StartDate && rateDate <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 转换失败,处理错误情况
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间不正确!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (opConfig.Value == "CreateTime")
|
|
|
{
|
|
|
if (order.CreateTime.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单录入时间不能为空!");
|
|
|
}
|
|
|
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && order.CreateTime >= x.StartDate && order.CreateTime <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单录入时间在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("非法参数类型,请联系管理员!");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("非法业务类型,请联系管理员!");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 根据系统配置参数
|
|
|
var sysConfig = tenantDb.Queryable<SysConfig>().Where(x => x.Status == StatusEnum.Enable && x.Code == "ExchangeRateType").First();
|
|
|
if (sysConfig.IsNotNull())
|
|
|
{
|
|
|
if (req.BusinessType == BusinessType.OceanShippingExport)
|
|
|
{
|
|
|
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
|
|
|
if (sysConfig.Value == "ETD")
|
|
|
{
|
|
|
if (order.ETD.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期不能为空!");
|
|
|
}
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else if (sysConfig.Value == "AccountDate")
|
|
|
{
|
|
|
if (order.AccountDate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间不能为空!");
|
|
|
}
|
|
|
//var accountDateTime = DateTime.Parse(order.AccountDate +"-01");
|
|
|
|
|
|
if (DateTime.TryParse(order.AccountDate + "-01", out rateDate))
|
|
|
{
|
|
|
// 转换成功,可以使用date变量
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && rateDate >= x.StartDate && rateDate <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 转换失败,处理错误情况
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单会计期间不正确!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (sysConfig.Value == "CreateTime")
|
|
|
{
|
|
|
if (order.CreateTime.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单录入时间不能为空!");
|
|
|
}
|
|
|
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && order.CreateTime >= x.StartDate && order.CreateTime <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单录入时间在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("非法参数类型,请联系管理员!");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("非法业务类型,请联系管理员!");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//无系统参数按开船日期取汇率
|
|
|
if (req.BusinessType == BusinessType.OceanShippingExport)
|
|
|
{
|
|
|
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == req.BusinessId);
|
|
|
if (order.ETD.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期不能为空!");
|
|
|
}
|
|
|
var feeRate = tenantDb.Queryable<FeeCurrencyExchange>().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
|
|
|
if (feeRate.IsNull())
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("订单开船日期在币别设置的汇率不存在!");
|
|
|
}
|
|
|
feeRate.Adapt(data);
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Success(data);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return DataResult<BusinessCurrencyExchangeRes>.Failed("非法业务类型,请联系管理员!");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取揽货人信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<SaleSelectListRes>> GetSaleList(string queryKey = "")
|
|
|
{
|
|
|
var list = db.Queryable<SysUser>().Where(x => x.Status == StatusEnum.Enable.ToEnumInt() && x.IsSale == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<SaleSelectListRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
var orgs = db.Queryable<SysOrgUser>().Filter(null, true)
|
|
|
.InnerJoin<SysOrg>((a, b) => a.OrgId == b.Id && b.IsDepartment == false)
|
|
|
.Where(a => a.UserId == item.Id)
|
|
|
.Select((a, b) => new OrgList
|
|
|
{
|
|
|
OrgId = (long)a.OrgId,
|
|
|
OrgName = b.OrgName
|
|
|
})
|
|
|
.ToList();
|
|
|
item.SaleOrgList = orgs;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return DataResult<List<SaleSelectListRes>>.Success(list, MultiLanguageConst.DataQuerySuccess); ;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取审核日志列表
|
|
|
/// </summary>
|
|
|
/// <param name="id"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<AuditLogListRes>>> GetAuditLogList(string id)
|
|
|
{
|
|
|
var data = await saasService.GetLogDb().Queryable<SysLogAudit>().Filter(null, true)
|
|
|
.Where(a => a.KeyId == long.Parse(id))
|
|
|
.Select<AuditLogListRes>()
|
|
|
.ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<AuditLogListRes>>.Success(data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取币别信息下拉选择
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<FeeCurrencySelectRes>> GetFeeCurrencySelectList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<FeeCurrency>()
|
|
|
.Where(x => x.Status == StatusEnum.Enable)
|
|
|
.Select<FeeCurrencySelectRes>()
|
|
|
.ToList();
|
|
|
return DataResult<List<FeeCurrencySelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取费用代码下拉选择
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<FeeCodeSelectRes>> GetFeeCodeSelectList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<FeeCode>()
|
|
|
.Where(x => x.Status == StatusEnum.Enable)
|
|
|
.Select<FeeCodeSelectRes>()
|
|
|
.OrderBy(x => x.Code)
|
|
|
.ToList();
|
|
|
return DataResult<List<FeeCodeSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据类型获取往来单位下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ClientSelectRes>>> GetClientListByCode(string code = "", string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var conditions = new List<IConditionalModel>();
|
|
|
var otherConditions = new List<IConditionalModel>();
|
|
|
var queryData = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt());
|
|
|
//var query = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>();
|
|
|
var scope = string.Empty;
|
|
|
(conditions, scope, otherConditions) = await commonService.GetSpecialVisibleDataRuleFilter<InfoClient>(queryData, tenantDb);
|
|
|
var userids = new List<string>();
|
|
|
if (otherConditions.Count > 0)
|
|
|
{
|
|
|
foreach (ConditionalTree item in otherConditions)
|
|
|
{
|
|
|
Console.WriteLine(item.ConditionalList);
|
|
|
if (item.ConditionalList.Count > 0)
|
|
|
{
|
|
|
foreach (var item1 in item.ConditionalList)
|
|
|
{
|
|
|
var temp = item1.Value as SqlSugar.ConditionalModel;
|
|
|
if (temp.FieldName == "Stakeholders")
|
|
|
{
|
|
|
userids = temp.FieldValue.Split(',').ToList();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (userids.Count == 0)
|
|
|
{
|
|
|
userids.Add(user.UserId);
|
|
|
}
|
|
|
//干系人合集
|
|
|
var exp = Expressionable.Create<InfoClient>();
|
|
|
exp = exp.And(c => SqlFunc.Subqueryable<InfoClientStakeholder>().Where("SYSDATE() BETWEEN StartDate and EndDate").Where(x => userids.Contains(x.UserId.ToString()) && x.ClientId == c.Id).Any());
|
|
|
|
|
|
var queryData1 = tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>().Where(c => c.Status == StatusEnum.Enable.ToEnumInt()).Where(exp.ToExpression());
|
|
|
var queryData2 = queryData.Where(conditions);
|
|
|
var queryData0 = tenantDb.UnionAll(queryData1, queryData2);
|
|
|
//code = code.ToLower();
|
|
|
var data = await queryData0//tenantDb.Queryable<InfoClient>()//.Where(a=> tenantDb.Ado.SqlQuery<dynamic>(sql, new SugarParameter($"@ClientId", a.Id)).Contains(user.UserId))
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() || SqlFunc.Subqueryable<InfoClientStakeholder>().Where("SYSDATE() BETWEEN StartDate and EndDate").Where(c => c.ClientId == a.Id && userids.Contains(c.CreateBy.ToString())).Any())
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "carrier", (a, b) => b.IsCarrier == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "yard", (a, b) => b.IsYard == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "booking", (a, b) => b.IsBooking == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "truck", (a, b) => b.IsTruck == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "controller", (a, b) => b.IsController == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "custom", (a, b) => b.IsCustom == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "agent", (a, b) => b.IsAgent == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "agentcn", (a, b) => b.IsAgentCn == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "express", (a, b) => b.IsExpress == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "airlines", (a, b) => b.IsAirLines == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shipper", (a, b) => b.IsShipper == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shippercn", (a, b) => b.IsShipperCn == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "notifyparty", (a, b) => b.IsNotifyParty == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "warehouse", (a, b) => b.IsWareHouse == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "wharf", (a, b) => b.IsWharf == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "insurer", (a, b) => b.IsInsurer == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "leasing", (a, b) => b.IsLeasing == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "tradingagency", (a, b) => b.IsTradingAgency == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shipagency", (a, b) => b.IsShipAgency == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "enterprise", (a, b) => b.IsEnterprise == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "contract", (a, b) => b.IsContract == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
PinYinCode = a.ShortName + "(" + a.CodeName + ")",
|
|
|
IsFrozen = a.IsFrozen,
|
|
|
Description = a.Description
|
|
|
}
|
|
|
)
|
|
|
.ClearFilter<ISharedOrgId>().MergeTable()
|
|
|
//.Mapper(it =>
|
|
|
// {
|
|
|
// //it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList();
|
|
|
|
|
|
// })
|
|
|
.OrderBy(x => x.CodeName).Distinct().Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 根据类型获取供应商下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<List<ClientSelectRes>>> GetSupplierListByCode(string code = "", string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
//code = code.ToLower();
|
|
|
var data = await tenantDb.Queryable<InfoClient>().ClearFilter<ISharedOrgId>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "carrier", (a, b) => b.IsCarrier == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "yard", (a, b) => b.IsYard == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "booking", (a, b) => b.IsBooking == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "truck", (a, b) => b.IsTruck == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "controller", (a, b) => b.IsController == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "custom", (a, b) => b.IsCustom == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "agent", (a, b) => b.IsAgent == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "agentcn", (a, b) => b.IsAgentCn == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "express", (a, b) => b.IsExpress == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "airlines", (a, b) => b.IsAirLines == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shipper", (a, b) => b.IsShipper == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shippercn", (a, b) => b.IsShipperCn == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "notifyparty", (a, b) => b.IsNotifyParty == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "warehouse", (a, b) => b.IsWareHouse == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "wharf", (a, b) => b.IsWharf == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "insurer", (a, b) => b.IsInsurer == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "leasing", (a, b) => b.IsLeasing == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "tradingagency", (a, b) => b.IsTradingAgency == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "shipagency", (a, b) => b.IsShipAgency == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "enterprise", (a, b) => b.IsEnterprise == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(code) && code == "contract", (a, b) => b.IsContract == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
BLContent = a.BLContent,
|
|
|
PinYinCode = a.ShortName + "(" + a.Description + ")" + " " + a.CodeName,
|
|
|
Description = a.Description
|
|
|
}
|
|
|
)
|
|
|
.ClearFilter<ISharedOrgId>().MergeTable()
|
|
|
.Mapper(it =>
|
|
|
{
|
|
|
it.UserIds = tenantDb.Queryable<InfoClientStakeholder>().Where(c => c.StartDate <= DateTime.Now && c.EndDate >= DateTime.Now && c.ClientId == it.Id).Select(n => n.CreateBy).ToList();
|
|
|
|
|
|
})
|
|
|
.OrderBy(x => x.CodeName).Take(20).WithCache($"{SqlSugarCacheConst.InfoClient}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds).ToListAsync();
|
|
|
return await Task.FromResult(DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取所有往来单位下拉列表
|
|
|
/// </summary>
|
|
|
/// <param name="id"></param>
|
|
|
/// <param name="type"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetAllClientList(long? id = null, string? type = null)
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
List<IConditionalModel> conditions = [];
|
|
|
if (!string.IsNullOrEmpty(type))
|
|
|
{
|
|
|
conditions.Add(new ConditionalModel
|
|
|
{
|
|
|
FieldName = "b.Is" + type.ToUpperCamelCase(),
|
|
|
FieldValue = "1",
|
|
|
CSharpTypeName = "int",
|
|
|
ConditionalType = ConditionalType.Equal
|
|
|
});
|
|
|
}
|
|
|
|
|
|
var data = tenantDb.Queryable<InfoClient>().InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt())
|
|
|
.Where(conditions)
|
|
|
.WhereIF(id.GetValueOrDefault() > 0, a => a.Id != id)
|
|
|
.Select(a => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName,
|
|
|
Description = a.Description,
|
|
|
}).ToList();
|
|
|
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
#region 废弃
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取船公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetCarrierClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsCarrier == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取场站下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetYardClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsYard == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取订舱公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetBookingClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsBooking == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取车队下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetTruckClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsTruck == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取委托单位下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetControllerClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取报关行下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetCustomClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsCustom == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取代理(国外)下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetAgentClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAgent == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取代理(国内)下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetAgentCnClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAgentCn == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取快递公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetExpressClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsExpress == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取航空公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetAirLinesClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsAirLines == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取发货人下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetShipperClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsShipper == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取收货人下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetConsigneeClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsConsignee == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取通知人下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetNotifyPartyClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsNotifyParty == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取仓库下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetWareHouseClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsWareHouse == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取码头下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetWharfClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsWharf == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取保险公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetInsurerClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsInsurer == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取租箱公司下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetLeasingClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsLeasing == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取贸易代理下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetTradingAgencyClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsTradingAgency == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取船代下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetShipAgencyClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsShipAgency == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取经营单位下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<ClientSelectRes>> GetEnterpriseClientList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<InfoClient>()
|
|
|
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
|
|
|
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsEnterprise == true)
|
|
|
.Select((a, b) => new ClientSelectRes
|
|
|
{
|
|
|
Id = a.Id,
|
|
|
CodeName = a.CodeName,
|
|
|
ShortName = a.ShortName,
|
|
|
EnShortName = a.EnShortName
|
|
|
}
|
|
|
).ToList();
|
|
|
return DataResult<List<ClientSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
#endregion
|
|
|
/// <summary>
|
|
|
/// 获取签单方式下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<IssueTypeSelectRes>> GetIssueTypeSelectList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodeIssueType>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.Select<IssueTypeSelectRes>().ToList();
|
|
|
return DataResult<List<IssueTypeSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取集装箱下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodeCtnSelectRes>> GetCtnSelectList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodeCtn>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.CtnName.Contains(queryKey) || a.EdiCode.Contains(queryKey))
|
|
|
.OrderBy(a => a.OrderNo)
|
|
|
.Select<CodeCtnSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Ctn}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<CodeCtnSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取包装类型下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodePackageSelectRes>> GetPackageSelectList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodePackage>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PackageName.Contains(queryKey) || a.EdiCode.Contains(queryKey))
|
|
|
.Select<CodePackageSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Package}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<CodePackageSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取船名下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodeVesselSelectRes>> GetVesselSelectList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodeVessel>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.VesselName.Contains(queryKey) || a.EdiCode.Contains(queryKey))
|
|
|
.Select<CodeVesselSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Vessel}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<CodeVesselSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取航次下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodeVoynoSelectRes>> GetVoynoSelectList(string queryKey = "")
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodeVoyno>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.VoyNo.Contains(queryKey))
|
|
|
.Select<CodeVoynoSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Voyno}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<CodeVoynoSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取运输条款下拉列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<CodeServiceSelectRes>> GetServiceSelectList()
|
|
|
{
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
var data = tenantDb.Queryable<CodeService>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable)
|
|
|
.Select<CodeServiceSelectRes>().ToList();
|
|
|
return DataResult<List<CodeServiceSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取部门列表
|
|
|
/// </summary>
|
|
|
/// <param name="orgId">机构id</param>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<DeptSelectRes>> GetDeptList(string orgId = "", string queryKey = "")
|
|
|
{
|
|
|
|
|
|
//var ids = GetOrgIdsByParent(long.Parse(orgId), db);
|
|
|
var ids = new List<long>();
|
|
|
if (orgId.IsNotEmptyOrNull())
|
|
|
{
|
|
|
ids = GetOrgIdsByParent(long.Parse(orgId), db);
|
|
|
}
|
|
|
//a.ParentId == long.Parse(orgId)
|
|
|
var list = db.Queryable<SysOrg>()
|
|
|
.WhereIF(orgId.IsNotEmptyOrNull(), a => ids.Contains(a.Id))
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => (a.OrgName.Contains(queryKey) || a.OrgFullName.Contains(queryKey) || a.OrgEnName.Contains(queryKey)))
|
|
|
.Where(a => a.Status == StatusEnum.Enable && a.IsDepartment == true)
|
|
|
.OrderByDescending(a => a.CreateTime)
|
|
|
.Select<DeptSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.Org}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<DeptSelectRes>>.Success("获取数据成功!", list);
|
|
|
}
|
|
|
|
|
|
public static List<long> GetOrgIdsByParent(long ParentId, ISqlSugarClient db)
|
|
|
{
|
|
|
List<long> Data = new List<long>();
|
|
|
var parent = db.Queryable<SysOrg>().InSingle(ParentId);
|
|
|
//查询下级部门信息
|
|
|
var childs = db.Queryable<SysOrg>().Where(x => x.ParentId == ParentId).ToList();
|
|
|
if (childs.Count > 0)
|
|
|
{
|
|
|
var orgs = childs.ToList();//.Where(x => x.IsDepartment == false)
|
|
|
foreach (var org in orgs)
|
|
|
{
|
|
|
var childMember = GetOrgIdsByParent(org.Id, db);
|
|
|
Data.AddRange(childMember);
|
|
|
}
|
|
|
Data.AddRange(childs.Where(x => x.IsDepartment == true).Select(x => x.Id).ToList());
|
|
|
}
|
|
|
|
|
|
return Data.Distinct().ToList();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取操作员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetOperatorUserList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsOperator == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取单证员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetVouchingClerkList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsVouchingClerk == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取销售员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetSaleUserList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsSale == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取报关员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetCustomUserList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustom == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取财务员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetFinancialStaffList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsFinancialStaff == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取客服列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetCustomerServiceList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustomerService == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取司机列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetDiverList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDriver == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取派车调度人员列表
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<List<UserSelectRes>> GetDispatcherList(string queryKey = "")
|
|
|
{
|
|
|
var data = db.Queryable<SysUser>()
|
|
|
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDispatcher == true)
|
|
|
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.PinYinCode.Contains(queryKey) || a.UserCode.Contains(queryKey) || a.UserName.Contains(queryKey))
|
|
|
.Select<UserSelectRes>()
|
|
|
.Take(20)
|
|
|
.WithCache($"{SqlSugarCacheConst.User}{user.TenantId}", SqlSugarCacheConst.CacheDurationInSeconds)
|
|
|
.ToList();
|
|
|
return DataResult<List<UserSelectRes>>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
|
|
|
}
|
|
|
|
|
|
#region 用户高级查询条件设置
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取用户高级查询条件设置
|
|
|
/// </summary>
|
|
|
/// <param name="permissionId"></param>
|
|
|
/// <param name="tagNo"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataResult<SysQuerySet> GetUserQuerySet(string permissionId, int tagNo = 0)
|
|
|
{
|
|
|
var info = db.Queryable<SysQuerySet>()
|
|
|
.Where(x => x.UserId == long.Parse(user.UserId) && x.PermissionId == long.Parse(permissionId) && x.TagNo == tagNo).First();
|
|
|
|
|
|
return DataResult<SysQuerySet>.Success(info);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新用户高级查询条件设置
|
|
|
/// </summary>
|
|
|
/// <param name="req"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataResult UpdateUserQuerySet(UserQuerySetUpdateReq req)
|
|
|
{
|
|
|
var info = db.Queryable<SysQuerySet>()
|
|
|
.Where(x => x.UserId == long.Parse(user.UserId) && x.PermissionId == req.PermissionId).First();
|
|
|
|
|
|
if (info.IsNull())
|
|
|
{
|
|
|
var entity = new SysQuerySet
|
|
|
{
|
|
|
UserId = long.Parse(user.UserId),
|
|
|
PermissionId = req.PermissionId,
|
|
|
Content = req.Content
|
|
|
};
|
|
|
db.Insertable(entity).ExecuteCommand();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
info.Content = req.Content;
|
|
|
db.Updateable(info).ExecuteCommand();
|
|
|
}
|
|
|
|
|
|
return DataResult.Successed("更新成功");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取模块新增信息
|
|
|
/// </summary>
|
|
|
/// <param name="id">权限模块id</param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<DataResult<FormSetCreateRes>> GetFormSetCreateInfoAsync(string id)
|
|
|
{
|
|
|
var res = new FormSetCreateRes();
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
//判断有没有自己机构设置的模板
|
|
|
var ownSet = await tenantDb.Queryable<CodeFormSet>()
|
|
|
.Where(x => x.PermissionId == long.Parse(id))
|
|
|
.Select<FormSetCreateRes>()
|
|
|
.FirstAsync();
|
|
|
|
|
|
if (ownSet != null)
|
|
|
{
|
|
|
return await Task.FromResult(DataResult<FormSetCreateRes>.Success(ownSet));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
var publicSet = await tenantDb.Queryable<CodeFormSet>().ClearFilter(typeof(IOrgId))
|
|
|
.Where(x => x.PermissionId == long.Parse(id) && x.IsPublic == true)
|
|
|
.Select<FormSetCreateRes>()
|
|
|
.FirstAsync();
|
|
|
if (publicSet != null)
|
|
|
{
|
|
|
return await Task.FromResult(DataResult<FormSetCreateRes>.Success(publicSet));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return await Task.FromResult(DataResult<FormSetCreateRes>.Failed(MultiLanguageConst.FormSetNotExist));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |