|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
using DS.Module.DjyRulesEngine;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
@ -25,6 +27,7 @@ using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
{
|
|
|
|
@ -386,16 +389,19 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
|
|
|
|
|
if (updateFlag)
|
|
|
|
|
{
|
|
|
|
|
result = await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
if (!FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
BusinessId = request.BusinessId,
|
|
|
|
|
BusinessType = request.BusinessType,
|
|
|
|
|
TaskTypeName = request.TaskTypeName,
|
|
|
|
|
TaskStatus = TaskStatusEnum.Create
|
|
|
|
|
}, false);
|
|
|
|
|
result = await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = request.BusinessId,
|
|
|
|
|
BusinessType = request.BusinessType,
|
|
|
|
|
TaskTypeName = request.TaskTypeName,
|
|
|
|
|
TaskStatus = TaskStatusEnum.Create
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (FeeTypes.Contains(request.TaskType)) //费用审核需拆分任务
|
|
|
|
|
{
|
|
|
|
@ -553,25 +559,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
DataResult result;
|
|
|
|
|
if (FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
var biz = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var relativeTasks = await TenantDb.Queryable<BusinessTask>()
|
|
|
|
|
.InnerJoin<FeeRecord>((t, f) => t.BusinessId == f.Id)
|
|
|
|
|
.Where((t, f) => f.BusinessId == fee.BusinessId && f.BusinessType == fee.BusinessType && FeeTypes.Contains(t.TaskType) && t.RecvUsers.Contains(User.UserId))
|
|
|
|
|
.Select((t, f) => new
|
|
|
|
|
{
|
|
|
|
|
t.Id,
|
|
|
|
|
t.BusinessId,
|
|
|
|
|
t.TaskType,
|
|
|
|
|
t.TaskStatus,
|
|
|
|
|
t.RecvUsers
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var relativeTasks = await GetFeeTasks(biz.BusinessType, biz.BusinessId);
|
|
|
|
|
var groups = relativeTasks.GroupBy(x => x.TaskStatus).Select(x => x.Key).ToList();
|
|
|
|
|
if (groups.Count == 1 && groups.All(x => x == request.TaskStatus))
|
|
|
|
|
{
|
|
|
|
@ -612,7 +607,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
Dictionary<string, object>? dic = null;
|
|
|
|
|
if (task.NextType == TaskBaseTypeEnum.WAIT_BOOKING)
|
|
|
|
|
{
|
|
|
|
|
dic = new Dictionary<string, object>();
|
|
|
|
|
dic = [];
|
|
|
|
|
var param = await ClientParamService.Value.GetParamAsync<string>(task.BusinessId, BookingSelector.Booking_Route,
|
|
|
|
|
(x, y) => x.CustomerId == y.ForwarderId);
|
|
|
|
|
dic[TaskFlowDataNameConst.ClientParam] = param;
|
|
|
|
@ -646,13 +641,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取业务的任务信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="types">任务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<BusinessTaskDto>>> GetTasks(long id, BusinessType? businessType, params TaskBaseTypeEnum[] types)
|
|
|
|
|
public async Task<DataResult<List<BusinessTaskDto>>> GetTasks(long bsId, BusinessType? businessType, params TaskBaseTypeEnum[] types)
|
|
|
|
|
{
|
|
|
|
|
var list = await TenantDb.Queryable<BusinessTask>().Where(x => x.BusinessId == id)
|
|
|
|
|
var list = await TenantDb.Queryable<BusinessTask>().Where(x => x.BusinessId == bsId)
|
|
|
|
|
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
|
|
|
|
|
.WhereIF(types != null && types.Length > 0, x => types.Contains(x.TaskType))
|
|
|
|
|
.Select<BusinessTaskDto>().ToListAsync();
|
|
|
|
@ -662,6 +657,27 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取指定业务的所有关联费用类任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bsType">业务类型</param>
|
|
|
|
|
/// <param name="bsIds">业务ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal async Task<List<BusinessTask>> GetFeeTasks(BusinessType bsType, params long[] bsIds)
|
|
|
|
|
{
|
|
|
|
|
return await TenantDb.Queryable<BusinessTask>()
|
|
|
|
|
.InnerJoin<FeeRecord>((t, f) => t.BusinessId == f.Id)
|
|
|
|
|
.Where((t, f) => bsIds.Contains(f.BusinessId) && f.BusinessType == bsType && FeeTypes.Contains(t.TaskType) && t.RecvUsers.Contains(User.UserId))
|
|
|
|
|
.Select((t, f) => new BusinessTask
|
|
|
|
|
{
|
|
|
|
|
Id = t.Id,
|
|
|
|
|
BusinessId = t.BusinessId,
|
|
|
|
|
TaskType = t.TaskType,
|
|
|
|
|
TaskStatus = t.TaskStatus,
|
|
|
|
|
RecvUsers = t.RecvUsers
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回指定类型的任务是否已存在
|
|
|
|
|
/// </summary>
|
|
|
|
@ -786,11 +802,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (!AuditTaskTypes.Contains(request.TaskType))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskTypeNotSupported));
|
|
|
|
|
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).Select(x => new
|
|
|
|
|
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).Select(x => new BusinessTask
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.TaskStatus,
|
|
|
|
|
x.FlowId
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
TaskStatus = x.TaskStatus,
|
|
|
|
|
FlowId = x.FlowId,
|
|
|
|
|
RecvUsers = x.RecvUsers
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
if (task == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
@ -801,16 +818,32 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
if (!task.FlowId.HasValue)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInFlows));
|
|
|
|
|
|
|
|
|
|
DataResult result;
|
|
|
|
|
DateTime dt = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (useTransaction)
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, TaskStatusEnum.Cancel, dt);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
if (FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
//if (request.ExtraData is not FeeRecord fee)
|
|
|
|
|
// return DataResult.Failed("缺少请求传递的费用数据");
|
|
|
|
|
|
|
|
|
|
//var relativeTasks = await GetFeeTasks(fee.BusinessType, fee.BusinessId);
|
|
|
|
|
//if (relativeTasks.Count == 1 || relativeTasks.Where(x => x.BusinessId != request.BusinessId && x.TaskStatus != TaskStatusEnum.Complete).All(x => x.TaskStatus == TaskStatusEnum.Cancel))
|
|
|
|
|
//{
|
|
|
|
|
// result = await ManagerService.SetTaskStatusWithBsno(fee.BusinessId, request.TaskType, TaskStatusEnum.Cancel, dt, userIdList: [.. task.RecvUserIdArray]);
|
|
|
|
|
// if (!result.Succeeded)
|
|
|
|
|
// return result;
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, TaskStatusEnum.Cancel, dt);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = await FlowService.Value.WithdrawAsync([task.FlowId.Value], "用户撤销审核");
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|