|
|
|
@ -5,7 +5,6 @@ using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
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.Dtos.TaskInteraction;
|
|
|
|
@ -53,18 +52,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest<bool> request)
|
|
|
|
|
{
|
|
|
|
|
List<FlowInstance>? flowList = null;
|
|
|
|
|
long[]? ids = null;
|
|
|
|
|
if (request.OtherQueryCondition)
|
|
|
|
|
{
|
|
|
|
|
flowList = await GetCurrentFlowsQuery(AuditTypes)
|
|
|
|
|
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
|
|
|
|
|
ids = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
if (ids.Length == 0)
|
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var queryList = CreateQuery(flowList);
|
|
|
|
|
var queryList = CreateQuery(ids);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
@ -95,17 +93,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项费用数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(List<FlowInstance>? additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(params long[]? bsIds)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
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 == 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, f) => ids1.Contains(f.Id))
|
|
|
|
|
.WhereIF(bsIds != null && bsIds.Length > 0, (s, b, f) => bsIds.Contains(f.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
{
|
|
|
|
@ -190,18 +187,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest<bool> request)
|
|
|
|
|
{
|
|
|
|
|
List<FlowInstance> flowList = null;
|
|
|
|
|
long[]? ids = null;
|
|
|
|
|
if (request.OtherQueryCondition)
|
|
|
|
|
{
|
|
|
|
|
flowList = await GetCurrentFlowsQuery([TaskBaseTypeEnum.FEE_BUSINESS_AUDIT])
|
|
|
|
|
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
|
|
|
|
|
ids = await GetCurrentFlowsQuery(TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
if (ids.Length == 0)
|
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var queryList = CreateBizQuery(flowList);
|
|
|
|
|
var queryList = CreateBizQuery(ids);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
@ -233,17 +229,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateBizQuery(List<FlowInstance>? additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateBizQuery(params long[]? bsIds)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
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 == 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))
|
|
|
|
|
.WhereIF(bsIds != null && bsIds.Length > 0, (s, b) => bsIds.Contains(s.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
{
|
|
|
|
@ -324,16 +319,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据业务和查询条件获取费用明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="query">自定义查询条件</param>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<PendingAuditFee>> GetFeesAsync(long id, BusinessType businessType, string query)
|
|
|
|
|
public async Task<DataResult<PendingAuditFee>> GetFeesAsync(AuditDetailRequest request)
|
|
|
|
|
{
|
|
|
|
|
var pendingAudit = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == id).Select(x => new PendingAuditFee
|
|
|
|
|
var pendingAudit = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == request.Id).Select(x => new PendingAuditFee
|
|
|
|
|
{
|
|
|
|
|
AccountDate = x.AccountDate,
|
|
|
|
|
BusinessType = businessType,
|
|
|
|
|
BusinessType = request.BusinessType,
|
|
|
|
|
Carrier = x.Carrier,
|
|
|
|
|
CustomerNo = x.CustomerNo,
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
@ -348,9 +341,20 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
if (pendingAudit != null)
|
|
|
|
|
{
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == id && f.BusinessType == businessType && AuditStatusArray.Contains(f.FeeStatus))
|
|
|
|
|
long[] ids = [];
|
|
|
|
|
if (request.AuditOnly)
|
|
|
|
|
{
|
|
|
|
|
ids = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (ids.Length == 0)
|
|
|
|
|
return DataResult<PendingAuditFee>.Success(pendingAudit, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
|
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
|
|
|
|
|
.LeftJoin<InfoClient>((f, s, i) => f.CustomerId == i.Id)
|
|
|
|
|
.WhereIF(ids.Length > 0, (f, s, i) => ids.Contains(f.Id) && AuditStatusArray.Contains(f.FeeStatus))
|
|
|
|
|
.Select((f, s, i) => new FeeAuditItemQuery
|
|
|
|
|
{
|
|
|
|
|
Id = f.Id,
|
|
|
|
@ -407,9 +411,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
var queryList = TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditItemQuery>> { query1 });
|
|
|
|
|
|
|
|
|
|
if (!query.IsNullOrEmpty())
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(query);
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
var list = await queryList.Select<AuditItem>().ToListAsync();
|
|
|
|
@ -607,8 +611,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(BizAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var flowList = await GetCurrentFlowsQuery(TaskBaseTypeEnum.FEE_AUDIT).ToListAsync();
|
|
|
|
|
var query = CreateQuery(flowList);
|
|
|
|
|
var ids = await GetCurrentFlowsQuery(TaskBaseTypeEnum.FEE_AUDIT).Select(x => x.BusinessId).ToArrayAsync();
|
|
|
|
|
var query = CreateQuery(ids);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|