审核查询条件集成

usertest
嵇文龙 6 months ago
parent 379ebe5ed3
commit a616668d5a

@ -1,10 +1,86 @@
using System.Runtime.Serialization;
using DS.Module.Core;
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using Masuit.Tools.Systems;
namespace DS.WMS.Core.Fee.Dtos
{
/// <summary>
/// 费用审批查询条件
/// </summary>
//public class FeeAuditQuery
//{
// /// <summary>
// /// 业务类型
// /// </summary>
// public BusinessType BusinessType { get; set; }
// /// <summary>
// /// 委托编号
// /// </summary>
// public string CustomerNo { get; set; }
// /// <summary>
// /// 船名
// /// </summary>
// public string Vessel { get; set; }
// /// <summary>
// /// 航次
// /// </summary>
// public string Voyage { get; set; }
// /// <summary>
// /// 国外代理ID
// /// </summary>
// public long? AgencyId { get; set; }
// /// <summary>
// /// 结算对象
// /// </summary>
// public long? FeeCustomerId { get; set; }
// /// <summary>
// /// 运输类型
// /// </summary>
// public string ShipmentType { get; set; }
// /// <summary>
// /// 揽货人
// /// </summary>
// public long? SaleId { get; set; }
// /// <summary>
// /// 委托单位
// /// </summary>
// public long? CustomerId { get; set; }
// /// <summary>
// /// 业务日期
// /// </summary>
// public DateTime? BusinessDate { get; set; }
// /// <summary>
// /// 费用名称ID
// /// </summary>
// public long? FeeId { get; set; }
// /// <summary>
// /// 业务来源
// /// </summary>
// public long? SourceId { get; set; }
// /// <summary>
// /// 会计期间
// /// </summary>
// public string? AccountDate { get; set; }
// /// <summary>
// /// 操作员
// /// </summary>
// public long? OperatorId { get; set; }
//}
public class FeeAuditBusiness
{
/// <summary>
@ -47,14 +123,22 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string ChangeOrder { get; set; }
//[IgnoreDataMember]
public long? CustomerId { get; set; }
/// <summary>
/// 委托单位
/// </summary>
[IgnoreDataMember]
public long? CustomerId { get; set; }
public string CustomerName { get; set; }
public long? FeeCustomerId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
public string? FeeCustomerName { get; set; }
/// <summary>
/// 主提单号
/// </summary>
@ -69,7 +153,7 @@ namespace DS.WMS.Core.Fee.Dtos
/// 开船日期
/// </summary>
public DateTime? ETD { get; set; }
/// <summary>
/// 业务状态
/// </summary>
@ -95,11 +179,12 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string CustomNo { get; set; }
//[IgnoreDataMember]
public long? SaleId { get; set; }
/// <summary>
/// 揽货人
/// </summary>
[IgnoreDataMember]
public long? SaleId { get; set; }
public string SaleName { get; set; }
@ -113,19 +198,20 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string? AccountDate { get; set; }
//[IgnoreDataMember]
public long? SourceId { get; set; }
/// <summary>
/// 业务来源
/// </summary>
[IgnoreDataMember]
public long? SourceId { get; set; }
public string SourceName { get; set; }
//[IgnoreDataMember]
public long? SourceDetailId { get; set; }
/// <summary>
/// 来源明细
/// </summary>
[IgnoreDataMember]
public long? SourceDetailId { get; set; }
public string DetailName { get; set; }
@ -144,19 +230,20 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string Note { get; set; }
//[IgnoreDataMember]
public long CreateBy { get; set; }
/// <summary>
/// 录入人
/// </summary>
[IgnoreDataMember]
public long CreateBy { get; set; }
public string CreateByName { get; set; }
//[IgnoreDataMember]
public long? OperatorId { get; set; }
/// <summary>
/// 操作员
/// </summary>
[IgnoreDataMember]
public long? OperatorId { get; set; }
public string Operator { get; set; }
@ -200,12 +287,12 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public decimal? CBM { get; set; }
//[IgnoreDataMember]
public long? CustomerService { get; set; }
/// <summary>
/// 客服员
/// </summary>
[IgnoreDataMember]
public long? CustomerService { get; set; }
public string CustomerServiceName { get; set; }
/// <summary>
@ -218,11 +305,12 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string ChangeReason { get; set; }
//[IgnoreDataMember]
public long Doc { get; set; }
/// <summary>
/// 单证
/// </summary>
[IgnoreDataMember]
public long Doc { get; set; }
public string DocName { get; set; }
@ -291,24 +379,14 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string TransitTerms { get; set; }
/// <summary>
/// 整票提交
/// </summary>
//public int MyProperty { get; set; }
//[IgnoreDataMember]
public long SaleDeptId { get; set; }
/// <summary>
/// 所属部门
/// </summary>
[IgnoreDataMember]
public long SaleDeptId { get; set; }
public string SaleDeptName { get; set; }
/// <summary>
/// 所属分部
/// </summary>
//public int MyProperty { get; set; }
/// <summary>
/// 装运方式
/// </summary>
@ -324,48 +402,46 @@ namespace DS.WMS.Core.Fee.Dtos
/// </summary>
public string DangerClass { get; set; }
/// <summary>
/// 国外代理
/// </summary>
[IgnoreDataMember]
public long? AgencyId { get; set; }
/// <summary>
/// 运输类型
/// </summary>
public string ShipmentType { get; set; }
public string ShipmentType { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? BusinessDate { get; set; }
}
public class FeeAuditBusinessQuery : FeeAuditBusiness
{
/// <summary>
/// 是否费用提交
/// 国外代理ID
/// </summary>
public bool IsSubmited { get; set; }
public long? AgencyId { get; set; }
/// <summary>
/// 利润减少
/// 费用名称ID
/// </summary>
////public string ProfitReduction { get; set; }
public long? FeeId { get; set; }
}
public class FeeAudit
/// <summary>
/// 费用记录查询结果
/// </summary>
public class FeeAuditItem
{
/// <summary>
/// 主键Id
/// 费用记录ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 业务Id
/// 业务ID
/// </summary>
public long BusinessId { get; set; }
public BusinessType BusinessType { get; set; }
/// <summary>
/// 收付类型(收、付) 1应收 2 应付
/// </summary>
@ -568,24 +644,79 @@ namespace DS.WMS.Core.Fee.Dtos
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}
public long? SubmitBy { get; set; }
public class FeeAuditItemQuery : FeeAuditItem
{
/// <summary>
/// 提交人
/// 业务类型
/// </summary>
public string SubmitByName { get; set; }
public BusinessType BusinessType { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string CustomerNo { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyage { get; set; }
/// <summary>
/// 提交日期
/// 国外代理ID
/// </summary>
public long? AgencyId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
public DateTime? SubmitDate { get; set; }
public long? FeeCustomerId { get; set; }
/// <summary>
/// 审核人
/// 运输类型
/// </summary>
public string AuditOperator { get; set; }
public string ShipmentType { get; set; }
/// <summary>
/// 审核日期
/// 揽货人
/// </summary>
public DateTime? AuditDate { get; set; }
public long? SaleId { get; set; }
/// <summary>
/// 委托单位
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? BusinessDate { get; set; }
/// <summary>
/// 费用名称ID
/// </summary>
public long? FeeId { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public long? SourceId { get; set; }
/// <summary>
/// 会计期间
/// </summary>
public string? AccountDate { get; set; }
/// <summary>
/// 操作员
/// </summary>
public long? OperatorId { get; set; }
}
}

@ -33,6 +33,8 @@ namespace DS.WMS.Core.Fee.Dtos
public class FeeBizAuditRequest: AuditRequest
{
public string? QueryCondition { get; set; }
public List<BizAudit> Items { get; set; }
}

@ -1,4 +1,5 @@
using DS.Module.Core;
using Castle.Core.Resource;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Dtos;
@ -7,10 +8,13 @@ using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using NPOI.SS.Formula.Functions;
using NPOI.Util;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method
@ -20,6 +24,8 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
public class FeeAuditService : FeeServiceBase, IFeeAuditService
{
const string Audit_Only = "AuditOnly=1";
/// <summary>
/// 待审核的状态值
/// </summary>
@ -55,61 +61,17 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
public async Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest request)
{
var flowList = await Db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
&& SqlFunc.SplitIn(x.MakerList, User.UserId) && AuditTypes.Contains(x.AuditType))
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
var queryList = CreateQuery(flowList);
//queryList = queryList.Where(x => SqlFunc.Subqueryable<FlowInstance>().Where(
// y => y.BusinessId == x.Id && y.BusinessType == x.BusinessType && SqlFunc.SplitIn(y.MakerList, User.UserId)).Any());
if (!request.QueryCondition.IsNullOrEmpty())
List<FlowInstance> flowList = null;
if (string.Equals(request.OtherQueryCondition, Audit_Only))
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
queryList = queryList.Where(whereList);
}
flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync();
var result = await queryList.ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
//关联用户名称
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
.Union(result.Data.Select(x => x.CreateBy))
.Distinct();
var Users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
if (item.OperatorId.HasValue)
{
item.Operator = Users.Find(x => x.Id == item.OperatorId.Value)?.UserName;
}
}
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
}
return result;
}
/// <summary>
/// 获取整票审核列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request)
{
string auditType = AuditType.FeeBusiness.ToString();
var flowList = await Db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
&& SqlFunc.SplitIn(x.MakerList, User.UserId) && x.AuditType == auditType)
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
var queryList = CreateBizQuery(flowList);
var queryList = CreateQuery(flowList);
if (!request.QueryCondition.IsNullOrEmpty())
{
@ -117,14 +79,14 @@ namespace DS.WMS.Core.Fee.Method
queryList = queryList.Where(whereList);
}
var result = await queryList.ToQueryPageAsync(request.PageCondition);
var result = await queryList.Select<FeeAuditBusiness>().ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
//关联用户名称
var UserIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
.Union(result.Data.Select(x => x.CreateBy))
.Distinct();
var Users = await Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
var Users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
@ -140,7 +102,7 @@ namespace DS.WMS.Core.Fee.Method
}
//创建各项费用数据的查询并集
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(IEnumerable<FlowInstance> additions)
internal ISugarQueryable<FeeAuditBusinessQuery> CreateQuery(IEnumerable<FlowInstance>? additions)
{
//海运出口
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
@ -152,7 +114,7 @@ namespace DS.WMS.Core.Fee.Method
))
.WhereIF(ids1 != null && ids1.Length > 0, (s, b, f) => ids1.Contains(f.Id))
.GroupBy(s => s.Id)
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
.Select((s, b, f, cs, csd) => new FeeAuditBusinessQuery
{
Id = s.Id,
AccountDate = s.AccountDate,
@ -181,6 +143,9 @@ namespace DS.WMS.Core.Fee.Method
Doc = s.Doc,
ETD = s.ETD,
Forwarder = s.Forwarder,
FeeId = f.FeeId,
FeeCustomerId = f.CustomerId,
FeeCustomerName = f.CustomerName,
GoodsName = s.GoodsName,
HBLNO = s.HBLNO,
InvoiceNo = s.InvoiceNo,
@ -222,22 +187,70 @@ namespace DS.WMS.Core.Fee.Method
//海运进口
//var ids2 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingImport).Select(x => x.BusinessId).ToArray();
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusinessQuery>> { query1 });
}
/// <summary>
/// 获取整票审核列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request)
{
List<FlowInstance> flowList = null;
if (string.Equals(request.OtherQueryCondition, Audit_Only))
{
flowList = await GetCurrentFlowsQuery([AuditType.FeeBusiness.ToString()]).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
}
var queryList = CreateBizQuery(flowList);
if (!request.QueryCondition.IsNullOrEmpty())
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
queryList = queryList.Where(whereList);
}
var result = await queryList.Select<FeeAuditBusiness>().ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
//关联用户名称
var UserIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
.Union(result.Data.Select(x => x.CreateBy))
.Distinct();
var Users = await Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
if (item.OperatorId.HasValue)
{
item.Operator = Users.Find(x => x.Id == item.OperatorId.Value)?.UserName;
}
}
}
return result;
}
//创建各项业务数据的查询并集
internal ISugarQueryable<FeeAuditBusiness> CreateBizQuery(IEnumerable<FlowInstance> additions)
internal ISugarQueryable<FeeAuditBusinessQuery> CreateBizQuery(IEnumerable<FlowInstance>? additions)
{
//海运出口
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
var query1 = TenantDb.Queryable<SeaExport, BusinessFeeStatus, CodeSource, CodeSourceDetail>((s, b, cs, csd) => new JoinQueryInfos(
var query1 = TenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord, CodeSource, CodeSourceDetail>((s, b, f, cs, csd) => new JoinQueryInfos(
JoinType.Left, s.Id == b.BusinessId && b.BusinessType == BusinessType.OceanShippingExport,
JoinType.Inner, s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport && AuditStatusArray.Contains(f.FeeStatus),
JoinType.Left, s.SourceId == cs.Id,
JoinType.Left, s.SourceDetailId == csd.Id
))
.WhereIF(ids1 != null && ids1.Length > 0, (s, b) => ids1.Contains(s.Id))
.GroupBy(s => s.Id)
.Select((s, b, cs, csd) => new FeeAuditBusiness
.Select((s, b, f, cs, csd) => new FeeAuditBusinessQuery
{
Id = s.Id,
AccountDate = s.AccountDate,
@ -266,6 +279,9 @@ namespace DS.WMS.Core.Fee.Method
Doc = s.Doc,
ETD = s.ETD,
Forwarder = s.Forwarder,
FeeId = f.FeeId,
FeeCustomerId = f.CustomerId,
FeeCustomerName = f.CustomerName,
GoodsName = s.GoodsName,
HBLNO = s.HBLNO,
InvoiceNo = s.InvoiceNo,
@ -307,7 +323,15 @@ namespace DS.WMS.Core.Fee.Method
//海运进口
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusinessQuery>> { query1 });
}
//获取当前登录用户的待审批工作流的查询对象
internal ISugarQueryable<FlowInstance> GetCurrentFlowsQuery(string[] auditTypes)
{
return Db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
&& SqlFunc.SplitIn(x.MakerList, User.UserId) && auditTypes.Contains(x.AuditType))
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType });
}
/// <summary>
@ -380,9 +404,7 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
public async Task<DataResult> AuditAsync(int yesOrNo, string remark)
{
var recordIds = await Db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus &&
SqlFunc.SplitIn(x.MakerList, User.UserId) && AuditTypes.Contains(x.AuditType))
.Select(x => x.BusinessId).ToArrayAsync();
var recordIds = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).ToArrayAsync();
//没有待审批的列表直接返回不再执行后续查询
if (recordIds.Length == 0)
return DataResult.Failed("当前暂无待审批的费用");
@ -397,15 +419,31 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
public async Task<DataResult> AuditAsync(FeeBizAuditRequest request)
{
var list1 = request.Items.Select(x => x.Id).ToList();
var list2 = request.Items.Select(x => x.BusinessType).Distinct().ToList();
var recordIds = await TenantDb.Queryable<FeeRecord>().Where(x =>
var flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync();
var query = CreateQuery(flowList);
if (!request.QueryCondition.IsNullOrEmpty())
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
query = query.Where(whereList);
}
var bizList = await query.Select(x => new BizAudit { Id = x.Id, BusinessType = x.BusinessType }).ToArrayAsync();
//取所选业务与过滤条件所产生的并集
var intersects = request.Items.Intersect(bizList);
if (!intersects.Any())
return DataResult.Failed("暂无符合当前查询条件的待审批费用");
var list1 = intersects.Select(x => x.Id).ToList();
var list2 = intersects.Select(x => x.BusinessType).Distinct().ToList();
var recordIds = await TenantDb.Queryable<FeeRecord>().Where(x =>
list1.Contains(x.BusinessId) && list2.Contains(x.BusinessType) && AuditStatusArray.Contains(x.FeeStatus))
.Select(x => x.Id).ToArrayAsync();
//没有待审批的列表直接返回不再执行后续查询
if (recordIds.Length == 0)
return DataResult.Failed("当前暂无待审批的费用");
return DataResult.Failed("暂无符合当前查询条件的待审批费用");
return await AuditAsync(request.Result, request.Remark, recordIds);
}
@ -678,84 +716,91 @@ namespace DS.WMS.Core.Fee.Method
}
}
/// <summary>
/// 根据查询条件获取费用明细
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public async Task<DataResult<List<FeeAuditItem>>> GetFeesAsync(string query)
{
var query1 = TenantDb.Queryable<FeeRecord>()
.InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.LeftJoin<InfoClient>((x, y, z) => x.CustomerId == z.Id)
.Select((f, s, i) => new FeeAuditItemQuery
{
Id = f.Id,
BusinessId = f.BusinessId,
BusinessType = f.BusinessType,
FeeStatus = f.FeeStatus,
FeeType = f.FeeType,
FeeId = f.FeeId,
FeeName = f.FeeName,
FeeEnName = f.FeeEnName,
FeeCustomerId = f.CustomerId,
CustomerName = s.CustomerName,
CustomerFullName = i.Description, //结算对象全称
CustomerType = f.CustomerType,
CustomerTypeText = f.CustomerTypeText,
Unit = f.Unit,
UnitText = f.UnitText,
UnitPrice = f.UnitPrice,
TaxUnitPrice = f.TaxUnitPrice,
Quantity = f.Quantity,
TaxRate = f.TaxRate,
NoTaxAmount = f.NoTaxAmount,
Amount = f.Amount,
Currency = f.Currency,
CurrencyText = f.CurrencyText,
ExchangeRate = f.ExchangeRate,
AccTaxRate = f.AccTaxRate,//销项汇率
Remark = f.Remark,
IsAdvancedPay = f.IsAdvancedPay,//是否垫付
IsInvoice = f.IsInvoice, //是否开发票
//FRT
CommissionRate = f.CommissionRate, //佣金比率
CreateBy = f.CreateBy,
CreateTime = f.CreateTime,
SettlementAmount = f.SettlementAmount,//结算金额
InvoiceAmount = f.InvoiceAmount,//开票金额
OrderAmount = f.OrderAmount,//申请金额
InvoiceNum = f.InvoiceNum,//发票号
Tax = f.Tax,//税额
DebitNo = f.DebitNo,//对账编号
SaleOrg = f.SaleOrg,
Reason = f.Reason,
CustomerNo = s.CustomerNo,
Vessel = s.Vessel,
Voyage = s.Voyno,
SaleId = s.SaleId,
CustomerId = s.CustomerId,
BusinessDate = s.BusinessDate,
SourceId = s.SourceId,
AccountDate = s.AccountDate,
OperatorId = s.OperatorId
});
var queryList = TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditItemQuery>> { query1 });
if (!query.IsNullOrEmpty())
{
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(query);
queryList = queryList.Where(whereList);
}
var result = await queryList.Select<FeeAuditItem>().ToListAsync();
//public DataResult<List<FeeAudit>> GetListByPage(PageRequest request)
//{
// var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
// var query1 = TenantDb.Queryable<FeeRecord>()
// .InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
// .LeftJoin<InfoClient>((x, y, z) => x.CustomerId == z.Id)
// .Select((x, y, z) => new FeeAudit
// {
// Id = x.Id,
// BusinessId = x.BusinessId,
// BusinessType = x.BusinessType,
// FeeStatus = x.FeeStatus,
// FeeType = x.FeeType,
// FeeName = x.FeeName,
// FeeEnName = x.FeeEnName,
// CustomerName = x.CustomerName,
// CustomerFullName = z.Description, //结算对象全称
// CustomerType = x.CustomerType,
// CustomerTypeText = x.CustomerTypeText,
// Unit = x.Unit,
// UnitText = x.UnitText,
// UnitPrice = x.UnitPrice,
// TaxUnitPrice = x.TaxUnitPrice,
// Quantity = x.Quantity,
// TaxRate = x.TaxRate,
// NoTaxAmount = x.NoTaxAmount,
// Amount = x.Amount,
// Currency = x.Currency,
// CurrencyText = x.CurrencyText,
// ExchangeRate = x.ExchangeRate,
// AccTaxRate = x.AccTaxRate,//销项汇率
// Remark = x.Remark,
// IsAdvancedPay = x.IsAdvancedPay,//是否垫付
// IsInvoice = x.IsInvoice, //是否开发票
// //FRT
// CommissionRate = x.CommissionRate, //佣金比率
// CreateBy = x.CreateBy,
// CreateTime = x.CreateTime,
// AuditOperator = x.AuditOperator,
// AuditDate = x.AuditDate,
// SettlementAmount = x.SettlementAmount,//结算金额
// InvoiceAmount = x.InvoiceAmount,//开票金额
// OrderAmount = x.OrderAmount,//申请金额
// InvoiceNum = x.InvoiceNum,//发票号
// Tax = x.Tax,//税额
// DebitNo = x.DebitNo,//对账编号
// SubmitBy = x.SubmitBy,
// SubmitDate = x.SubmitDate,
// SaleOrg = x.SaleOrg,
// Reason = x.Reason,
// IsOpen = x.IsOpen,//是否机密
// });
// var queryList = TenantDb.UnionAll(new List<ISugarQueryable<FeeAudit>> { query1 });
// var result = queryList.Where(whereList).ToQueryPage(request.PageCondition);
// if (result.Data.Count > 0)
// {
// //关联用户名称
// var UserIds = result.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.Value)
// .Union(result.Data.Select(x => x.CreateBy))
// .Distinct();
// var Users = Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
// foreach (var item in result.Data)
// {
// item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
// if (item.SubmitBy.HasValue)
// {
// item.SubmitByName = Users.Find(x => x.Id == item.SubmitBy.Value)?.UserName;
// }
// }
// }
// return result;
//}
if (result.Count > 0)
{
//关联用户名称
var UserIds = result.Select(x => x.CreateBy).Distinct();
var Users = Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
foreach (var item in result)
{
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
}
}
return DataResult<List<FeeAuditItem>>.Success(result);
}
}
}

@ -1,5 +1,4 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;

Loading…
Cancel
Save