using DS.Module.Core;
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.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System.Collections.Generic;
using static System.Runtime.InteropServices.JavaScript.JSType;
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;
///
///
///
///
public ClientCommonService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService();
user = _serviceProvider.GetRequiredService();
saasService = _serviceProvider.GetRequiredService();
}
#region 获取往来单位下拉集合列表
///
/// 获取往来单位下拉集合列表
///
///
public async Task>> GetMultiClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = new List();
var carrier = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("carrier", carrier));
var yard = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("yard", yard));
var booking = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("booking", booking));
var truck = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("truck", truck));
var controller = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("controller", controller));
var custom = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("custom", custom));
var agent = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("agent", agent));
var agentcn = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("agentcn", agentcn));
var express = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("express", express));
var airlines = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("airlines", airlines));
var shipper = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("shipper", shipper));
var notifyparty = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("notifyparty", notifyparty));
var warehouse = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("warehouse", warehouse));
var wharf = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("wharf", wharf));
var insurer = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("insurer", insurer));
var leasing = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("leasing", leasing));
var tradingagency = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("tradingagency", tradingagency));
var shipagency = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("shipagency", shipagency));
var enterprise = await tenantDb.Queryable()
.InnerJoin((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
}
).ToListAsync();
data.Add(new ClientSelectMultiRes("enterprise", enterprise));
return await Task.FromResult(DataResult>.Success(data));
}
#endregion
///
/// 提取汇率信息
///
///
///
public DataResult GetBusinessCurrencyExchangeInfo(BusinessCurrencyExchangeReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
DateTime rateDate;
var data = new BusinessCurrencyExchangeRes();
var opConfig = tenantDb.Queryable().Where(x => x.Status == StatusEnum.Enable && x.Code == "ExchangeRateType").First();
if (opConfig.IsNotNull())
{
#region 根据分公司配置参数
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var order = tenantDb.Queryable().First(x => x.Id == req.BusinessId);
if (opConfig.Value == "ETD")
{
if (order.ETD.IsNull())
{
return DataResult.Failed("订单开船日期不能为空!");
}
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单开船日期在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else if (opConfig.Value == "AccountDate")
{
if (order.AccountDate.IsNull())
{
return DataResult.Failed("订单会计期间不能为空!");
}
//var accountDateTime = DateTime.Parse(order.AccountDate +"-01");
if (DateTime.TryParse(order.AccountDate + "-01", out rateDate))
{
// 转换成功,可以使用date变量
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && rateDate >= x.StartDate && rateDate <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单会计期间在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else
{
// 转换失败,处理错误情况
return DataResult.Failed("订单会计期间不正确!");
}
}
else if (opConfig.Value == "CreateTime")
{
if (order.CreateTime.IsNull())
{
return DataResult.Failed("订单录入时间不能为空!");
}
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && order.CreateTime >= x.StartDate && order.CreateTime <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单录入时间在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else
{
return DataResult.Failed("非法参数类型,请联系管理员!");
}
}
else
{
return DataResult.Failed("非法业务类型,请联系管理员!");
}
#endregion
}
else
{
#region 根据系统配置参数
var sysConfig = tenantDb.Queryable().Where(x => x.Status == StatusEnum.Enable && x.Code == "ExchangeRateType").First();
if (sysConfig.IsNotNull())
{
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var order = tenantDb.Queryable().First(x => x.Id == req.BusinessId);
if (sysConfig.Value == "ETD")
{
if (order.ETD.IsNull())
{
return DataResult.Failed("订单开船日期不能为空!");
}
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单开船日期在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else if (sysConfig.Value == "AccountDate")
{
if (order.AccountDate.IsNull())
{
return DataResult.Failed("订单会计期间不能为空!");
}
//var accountDateTime = DateTime.Parse(order.AccountDate +"-01");
if (DateTime.TryParse(order.AccountDate + "-01", out rateDate))
{
// 转换成功,可以使用date变量
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && rateDate >= x.StartDate && rateDate <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单会计期间在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else
{
// 转换失败,处理错误情况
return DataResult.Failed("订单会计期间不正确!");
}
}
else if (sysConfig.Value == "CreateTime")
{
if (order.CreateTime.IsNull())
{
return DataResult.Failed("订单录入时间不能为空!");
}
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && order.CreateTime >= x.StartDate && order.CreateTime <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单录入时间在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else
{
return DataResult.Failed("非法参数类型,请联系管理员!");
}
}
else
{
return DataResult.Failed("非法业务类型,请联系管理员!");
}
}
else
{
//无系统参数按开船日期取汇率
if (req.BusinessType == BusinessType.OceanShippingExport)
{
var order = tenantDb.Queryable().First(x => x.Id == req.BusinessId);
if (order.ETD.IsNull())
{
return DataResult.Failed("订单开船日期不能为空!");
}
var feeRate = tenantDb.Queryable().First(x => x.CurrencyCode == req.CurrencyCode && order.ETD >= x.StartDate && order.ETD <= x.EndDate);
if (feeRate.IsNull())
{
return DataResult.Failed("订单开船日期在币别设置的汇率不存在!");
}
feeRate.Adapt(data);
return DataResult.Success(data);
}
else
{
return DataResult.Failed("非法业务类型,请联系管理员!");
}
}
#endregion
}
}
///
/// 获取揽货人信息
///
///
public DataResult> GetSaleList()
{
var list = db.Queryable().Where(x => x.Status == StatusEnum.Enable.ToEnumInt() && x.IsSale == true)
.Select()
.ToList();
if (list.Count > 0)
{
foreach (var item in list)
{
var orgs = db.Queryable().Filter(null, true)
.LeftJoin((a, b) => a.OrgId == b.Id)
.Where(a => a.UserId == item.Id)
.Select((a, b) => new OrgList
{
OrgId = (long)a.OrgId,
OrgName = b.OrgName
})
.ToList();
item.SaleOrgList = orgs;
}
}
return DataResult>.Success(list, MultiLanguageConst.DataQuerySuccess); ;
}
///
/// 获取审核日志列表
///
///
///
public DataResult> GetAuditLogList(string id)
{
var data = saasService.GetLogDb().Queryable().Filter(null, true)
.Where(a => a.KeyId == long.Parse(id))
.Select()
.ToList();
return DataResult>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取币别信息下拉选择
///
///
public DataResult> GetFeeCurrencySelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(x => x.Status == StatusEnum.Enable)
.Select()
.ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取费用代码下拉选择
///
///
public DataResult> GetFeeCodeSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(x => x.Status == StatusEnum.Enable)
.Select()
.ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 根据类型获取往来单位下拉列表
///
///
public DataResult> GetClientListByCode(string code = "")
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
code = code.ToLower();
var data = tenantDb.Queryable()
.InnerJoin((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
.WhereIF(code == "carrier", (a, b) => b.IsCarrier == true)
.WhereIF(code == "yard", (a, b) => b.IsYard == true)
.WhereIF(code == "booking", (a, b) => b.IsBooking == true)
.WhereIF(code == "truck", (a, b) => b.IsTruck == true)
.WhereIF(code == "controller", (a, b) => b.IsController == true)
.WhereIF(code == "custom", (a, b) => b.IsCustom == true)
.WhereIF(code == "agent", (a, b) => b.IsAgent == true)
.WhereIF(code == "agentcn", (a, b) => b.IsAgentCn == true)
.WhereIF(code == "express", (a, b) => b.IsExpress == true)
.WhereIF(code == "airlines", (a, b) => b.IsAirLines == true)
.WhereIF(code == "shipper", (a, b) => b.IsShipper == true)
.WhereIF(code == "notifyparty", (a, b) => b.IsNotifyParty == true)
.WhereIF(code == "warehouse", (a, b) => b.IsWareHouse == true)
.WhereIF(code == "wharf", (a, b) => b.IsWharf == true)
.WhereIF(code == "insurer", (a, b) => b.IsInsurer == true)
.WhereIF(code == "leasing", (a, b) => b.IsLeasing == true)
.WhereIF(code == "tradingagency", (a, b) => b.IsTradingAgency == true)
.WhereIF(code == "shipagency", (a, b) => b.IsShipAgency == true)
.WhereIF(code == "enterprise", (a, b) => b.IsEnterprise == true)
.Select((a, b) => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName,
BLContent = a.BLContent,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取所有往来单位下拉列表
///
///
public DataResult> GetAllClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt())
.Select((a, b) => new ClientSelectRes
{
Id = a.Id,
CodeName = a.CodeName,
ShortName = a.ShortName,
EnShortName = a.EnShortName
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取船公司下拉列表
///
///
public DataResult> GetCarrierClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取场站下拉列表
///
///
public DataResult> GetYardClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取订舱公司下拉列表
///
///
public DataResult> GetBookingClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取车队下拉列表
///
///
public DataResult> GetTruckClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取委托单位下拉列表
///
///
public DataResult> GetControllerClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取报关行下拉列表
///
///
public DataResult> GetCustomClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取代理(国外)下拉列表
///
///
public DataResult> GetAgentClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取代理(国内)下拉列表
///
///
public DataResult> GetAgentCnClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取快递公司下拉列表
///
///
public DataResult> GetExpressClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取航空公司下拉列表
///
///
public DataResult> GetAirLinesClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取发货人下拉列表
///
///
public DataResult> GetShipperClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取收货人下拉列表
///
///
public DataResult> GetConsigneeClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取通知人下拉列表
///
///
public DataResult> GetNotifyPartyClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取仓库下拉列表
///
///
public DataResult> GetWareHouseClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取码头下拉列表
///
///
public DataResult> GetWharfClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取保险公司下拉列表
///
///
public DataResult> GetInsurerClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取租箱公司下拉列表
///
///
public DataResult> GetLeasingClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取贸易代理下拉列表
///
///
public DataResult> GetTradingAgencyClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取船代下拉列表
///
///
public DataResult> GetShipAgencyClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取经营单位下拉列表
///
///
public DataResult> GetEnterpriseClientList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.InnerJoin((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>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取签单方式下拉列表
///
///
public DataResult> GetIssueTypeSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取集装箱下拉列表
///
///
public DataResult> GetCtnSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取包装类型下拉列表
///
///
public DataResult> GetPackageSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取船名下拉列表
///
///
public DataResult> GetVesselSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取航次下拉列表
///
///
public DataResult> GetVoynoSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取运输条款下拉列表
///
///
public DataResult> GetServiceSelectList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable()
.Where(a => a.Status == StatusEnum.Enable)
.Select().ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取部门列表
///
/// 机构id
///
public DataResult> GetDeptList(string orgId = "")
{
var list = db.Queryable()
.WhereIF(orgId.IsNotEmptyOrNull(), a => a.ParentId == long.Parse(orgId))
.Where(a => a.Status == StatusEnum.Enable && a.IsDepartment == true)
.Select()
.ToList();
return DataResult>.Success("获取数据成功!", list);
}
///
/// 获取操作员列表
///
///
public DataResult> GetOperatorUserList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsOperator == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取单证员列表
///
///
public DataResult> GetVouchingClerkList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsVouchingClerk == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取销售员列表
///
///
public DataResult> GetSaleUserList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsSale == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取报关员列表
///
///
public DataResult> GetCustomUserList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustom == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取财务员列表
///
///
public DataResult> GetFinancialStaffList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsFinancialStaff == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取客服列表
///
///
public DataResult> GetCustomerServiceList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsCustomerService == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取司机列表
///
///
public DataResult> GetDiverList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDriver == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
///
/// 获取派车调度人员列表
///
///
public DataResult> GetDispatcherList()
{
var data = db.Queryable()
.Where(a => a.Status == StatusEnum.Enable.ToEnumInt() && a.IsDispatcher == true)
.Select(a => new UserSelectRes
{
Id = a.Id,
UserCode = a.UserCode,
UserName = a.UserName,
}
).ToList();
return DataResult>.Success("获取数据成功!", data, MultiLanguageConst.DataQuerySuccess);
}
#region 用户高级查询条件设置
///
/// 获取用户高级查询条件设置
///
///
///
public DataResult GetUserQuerySet(string permissionId)
{
var info = db.Queryable()
.Where(x => x.UserId == long.Parse(user.UserId) && x.PermissionId == long.Parse(permissionId)).First();
return DataResult.Success(info);
}
///
/// 更新用户高级查询条件设置
///
///
///
public DataResult UpdateUserQuerySet(UserQuerySetUpdateReq req)
{
var info = db.Queryable()
.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
///
/// 获取模块新增信息
///
/// 权限模块id
///
public async Task> GetFormSetCreateInfoAsync(string id)
{
var res = new FormSetCreateRes();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//判断有没有自己设置的模板
var ownSet = await tenantDb.Queryable()
.Where(x => x.PermissionId == long.Parse(id) && x.CreateBy == long.Parse(user.UserId))
.Select()
.FirstAsync();
if (ownSet != null)
{
return await Task.FromResult(DataResult.Success(ownSet));
}
else
{
var publicSet = await tenantDb.Queryable()
.Where(x => x.PermissionId == long.Parse(id))
.Select()
.FirstAsync();
if (publicSet != null)
{
return await Task.FromResult(DataResult.Success(publicSet));
}
else
{
return await Task.FromResult(DataResult