|
|
|
@ -5,6 +5,7 @@ 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.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
@ -29,7 +30,6 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取待付费的业务列表
|
|
|
|
|
/// </summary>
|
|
|
|
@ -37,7 +37,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeApplicationBiz>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var queryList = CreateBizQuery(TenantDb);
|
|
|
|
|
var queryList = CreateBizQuery();
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
@ -66,10 +66,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal static ISugarQueryable<FeeApplicationBiz> CreateBizQuery(SqlSugarScopeProvider tenantDb)
|
|
|
|
|
internal ISugarQueryable<FeeApplicationBiz> CreateBizQuery()
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = tenantDb.Queryable<SeaExport>().InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport>().InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
.GroupBy((s, f) => s.Id)
|
|
|
|
|
.Select(s => new FeeApplicationBiz
|
|
|
|
@ -116,7 +116,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
//海运进口
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tenantDb.UnionAll(new List<ISugarQueryable<FeeApplicationBiz>> { query1 });
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeApplicationBiz>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -195,12 +195,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> DeleteAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
if (await tenantDb.Queryable<FeeApplication>().AnyAsync(x => ids.Contains(x.Id) && (x.Status != ApplicationStatus.Pending && x.Status != ApplicationStatus.AuditRejected)))
|
|
|
|
|
if (await TenantDb.Queryable<FeeApplication>().AnyAsync(x => ids.Contains(x.Id) && (x.Status != ApplicationStatus.Pending && x.Status != ApplicationStatus.AuditRejected)))
|
|
|
|
|
return DataResult.Failed("只能删除状态为‘待审核’或‘驳回’的申请单", MultiLanguageConst.FeeRecordDelete);
|
|
|
|
|
|
|
|
|
|
bool result = await tenantDb.DeleteNav<FeeApplication>(x => ids.Contains(x.Id)).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
|
bool result = await TenantDb.DeleteNav<FeeApplication>(x => ids.Contains(x.Id)).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
|
return result ? DataResult.Successed("删除成功!") : DataResult.Failed("删除失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -223,11 +221,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
ItemCount = SqlFunc.AggregateCount(y.Id)
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
return DataResult.Failed("未能找到申请单记录");
|
|
|
|
|
|
|
|
|
|
if (list.Exists(x => x.Status == ApplicationStatus.AuditSubmittd || x.Status == ApplicationStatus.AuditPassed))
|
|
|
|
|
return DataResult.Failed("提交内容包含正在审批中/已审批的申请单", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
return DataResult.Failed("提交内容包含正在审批中/已审批的申请单");
|
|
|
|
|
|
|
|
|
|
if (list.Exists(x => x.ItemCount == 0))
|
|
|
|
|
return DataResult.Failed("提交审批时必须包含费用明细,请检查", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
return DataResult.Failed("提交审批时必须包含费用明细,请检查");
|
|
|
|
|
|
|
|
|
|
var template = await FindTemplateAsync(auditType);
|
|
|
|
|
if (template == null)
|
|
|
|
@ -244,12 +245,15 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
BusinessId = item.Id,
|
|
|
|
|
TemplateId = template.Id
|
|
|
|
|
});
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ApplicationStatus.AuditSubmittd;
|
|
|
|
|
item.AuditRemark = remark;
|
|
|
|
|
var instance = result.Data as FlowInstance;
|
|
|
|
|
flowService.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable(item).ExecuteCommandAsync();
|
|
|
|
|
item.Status = ApplicationStatus.AuditSubmittd;
|
|
|
|
|
item.FlowId = instance.Id;
|
|
|
|
|
await TenantDb.Updateable(item).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -271,7 +275,48 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var list = await TenantDb.Queryable<FeeApplication>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
|
x => new FeeApplication
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ApplicationNO = x.ApplicationNO,
|
|
|
|
|
Status = x.Status,
|
|
|
|
|
FlowId = x.FlowId
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
return DataResult.Failed("未能找到申请单记录");
|
|
|
|
|
//未在审批状态中
|
|
|
|
|
var list2 = list.FindAll(x => x.FlowId == null).ToList();
|
|
|
|
|
if (list2.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string msg = string.Join("; ", list2.Select(x => $"{x.ApplicationNO}"));
|
|
|
|
|
return DataResult.Failed($"以下:{msg} 未在审批状态中,无需撤销");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var flows = list.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty }).ToList();
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await Db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
item.Status = ApplicationStatus.Pending;
|
|
|
|
|
item.FlowId = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable(list).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Successed("提交成功!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.Failed("提交失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|