|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
using Castle.Core.Resource;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
@ -13,8 +12,6 @@ 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
|
|
|
|
@ -31,15 +28,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 一键审核支持的类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly string[] AuditTypes = [AuditType.FeeAudit.ToString(), AuditType.FeeModify.ToString(), AuditType.FeeDelete.ToString()];
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工作流运行状态值
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static readonly int RunningStatus = (int)FlowStatusEnum.Running;
|
|
|
|
|
//一键审核支持的类型
|
|
|
|
|
static readonly string[] AuditTypes = [AuditType.FeeAudit.ToString(), AuditType.FeeModify.ToString(), AuditType.FeeDelete.ToString()];
|
|
|
|
|
|
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
@ -102,7 +92,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项费用数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateQuery(IEnumerable<FlowInstance>? additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateQuery(List<FlowInstance>? additions)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
@ -238,7 +228,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateBizQuery(IEnumerable<FlowInstance>? additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateBizQuery(List<FlowInstance>? additions)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
@ -326,12 +316,96 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusinessQuery>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前登录用户的待审批工作流的查询对象
|
|
|
|
|
internal ISugarQueryable<FlowInstance> GetCurrentFlowsQuery(string[] auditTypes)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据查询条件获取费用明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="query"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditItem>>> GetFeesAsync(long id, BusinessType businessType, string query)
|
|
|
|
|
{
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == id &&
|
|
|
|
|
f.BusinessType == businessType && AuditStatusArray.Contains(f.FeeStatus))
|
|
|
|
|
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
|
|
|
|
|
.LeftJoin<InfoClient>((f, s, i) => f.CustomerId == i.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 list = await queryList.Select<FeeAuditItem>().ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
|
var UserIds = list.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 list)
|
|
|
|
|
{
|
|
|
|
|
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 });
|
|
|
|
|
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = DataResult<List<FeeAuditItem>>.Success(list);
|
|
|
|
|
result.Count = list.Count;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -417,7 +491,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(FeeBizAuditRequest request)
|
|
|
|
|
public async Task<DataResult> AuditAsync(BizAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync();
|
|
|
|
|
var query = CreateQuery(flowList);
|
|
|
|
@ -428,7 +502,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
query = query.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bizList = await query.Select(x => new BizAudit { Id = x.Id, BusinessType = x.BusinessType }).ToArrayAsync();
|
|
|
|
|
var bizList = await query.Select(x => new BizAuditItem { Id = x.Id, BusinessType = x.BusinessType }).ToArrayAsync();
|
|
|
|
|
//取所选业务与过滤条件所产生的并集
|
|
|
|
|
var intersects = request.Items.Intersect(bizList);
|
|
|
|
|
if (!intersects.Any())
|
|
|
|
@ -453,7 +527,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">审批请求</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditBusinessAsync(FeeBizAuditRequest request)
|
|
|
|
|
public async Task<DataResult> AuditBusinessAsync(BizAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var gpList = request.Items.GroupBy(x => x.BusinessType).ToList();
|
|
|
|
|
foreach (var gp in gpList)
|
|
|
|
@ -716,91 +790,5 @@ 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();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|