bug修复

usertest
嵇文龙 4 months ago
parent 810681ae5d
commit 174d129606

@ -216,7 +216,7 @@ public class DataResult<TData> : IDataResult<ResultCode, TData>
/// <summary> /// <summary>
/// 初始化一个<see cref="DataResult{TResultType,TData}"/>类型的新实例 /// 初始化一个<see cref="DataResult{TResultType,TData}"/>类型的新实例
/// </summary> /// </summary>
public DataResult(ResultCode type, string message, TData data, string multiCode = "", int count = 0) public DataResult(ResultCode type, string message, TData? data, string multiCode = "", int count = 0)
{ {
if (message == null) if (message == null)
{ {
@ -275,7 +275,10 @@ public class DataResult<TData> : IDataResult<ResultCode, TData>
/// </summary> /// </summary>
public bool Succeeded => Code == ResultCode.Success; public bool Succeeded => Code == ResultCode.Success;
public TData Data { get; set; } /// <summary>
/// 数据
/// </summary>
public TData? Data { get; set; }
/// <summary> /// <summary>
/// 附加数据 /// 附加数据

@ -28,5 +28,5 @@ public interface IDataResult<TResultCode, TData>
/// <summary> /// <summary>
/// 获取或设置 结果数据 /// 获取或设置 结果数据
/// </summary> /// </summary>
TData Data { get; set; } TData? Data { get; set; }
} }

@ -2,6 +2,7 @@
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace DS.Module.Core namespace DS.Module.Core
@ -89,8 +90,14 @@ namespace DS.Module.Core
return DataResult<T>.Failed(result.Message, result.MultiCode); return DataResult<T>.Failed(result.Message, result.MultiCode);
var response = result.Data; var response = result.Data;
string json = await response.Content.ReadAsStringAsync(); T? data = default;
return DataResult<T>.Success(JsonConvert.DeserializeObject<T>(json)); if (response != null)
{
string json = await response.Content.ReadAsStringAsync();
data = JsonConvert.DeserializeObject<T>(json);
}
return new DataResult<T>(result.Code, result.Message, data, result.MultiCode);
} }
/// <summary> /// <summary>
@ -108,8 +115,14 @@ namespace DS.Module.Core
return DataResult<T>.Failed(result.Message, result.MultiCode); return DataResult<T>.Failed(result.Message, result.MultiCode);
var response = result.Data; var response = result.Data;
string json = await response.Content.ReadAsStringAsync(); T? data = default;
return DataResult<T>.Success(JsonConvert.DeserializeObject<T>(json)); if (response != null)
{
string json = await response.Content.ReadAsStringAsync();
data = JsonConvert.DeserializeObject<T>(json);
}
return new DataResult<T>(result.Code, result.Message, data, result.MultiCode);
} }
/// <summary> /// <summary>

@ -28,6 +28,11 @@ namespace DS.WMS.Core.Flow.Dtos
/// </summary> /// </summary>
public AuditType? Type { get; set; } public AuditType? Type { get; set; }
/// <summary>
/// 审批结果
/// </summary>
public FlowStatusEnum Status { get; set; }
/// <summary> /// <summary>
/// 变更执行人的用户ID /// 变更执行人的用户ID
/// </summary> /// </summary>

@ -117,4 +117,10 @@ public class FlowInstance : BaseTenantModel<long>
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public string? CallbackURL { get; set; } public string? CallbackURL { get; set; }
/// <summary>
/// 工作流是否已完成
/// </summary>
[SugarColumn(IsIgnore = true)]
public bool IsCompleted => string.IsNullOrEmpty(MakerList) || MakerList == "-1" || MakerList == "1";
} }

@ -31,17 +31,17 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
} }
/// <summary> /// <summary>
/// 获取当前工作流的所有执行人;当工作流类型为会签时,返回首个执行人 /// 当工作流类型为会签时,返回首个执行人
/// </summary> /// </summary>
/// <param name="instance">运行实例</param> /// <param name="instance">运行实例</param>
/// <returns></returns> /// <returns></returns>
public static string[] GetNextMarkers(FlowInstance instance) public static string GetNextMarkers(FlowInstance instance)
{ {
string[] markers = GetMarkers(instance); string[] markers = GetMarkers(instance);
if (instance.ActivityType == 0 && markers.Length > 0) if (instance.ActivityType == 0 && markers.Length > 0)
return [markers[0]]; return markers[0];
return markers; return string.Empty;
} }
/// <summary> /// <summary>
@ -51,7 +51,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
/// <returns></returns> /// <returns></returns>
public static string[] GetMarkers(FlowInstance instance) public static string[] GetMarkers(FlowInstance instance)
{ {
if (instance.MakerList.IsNullOrEmpty() || instance.MakerList == "-1") if (instance.IsCompleted)
return []; return [];
return instance.MakerList.Split(',', StringSplitOptions.RemoveEmptyEntries); return instance.MakerList.Split(',', StringSplitOptions.RemoveEmptyEntries);
@ -385,11 +385,11 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
instance.MakerList = GetForkNodeMakers(runtime, runtime.CurrentNodeId); instance.MakerList = GetForkNodeMakers(runtime, runtime.CurrentNodeId);
} }
var markers = GetNextMarkers(instance); var marker = GetNextMarkers(instance);
//获取会签下一执行人,进行通知 //获取会签下一执行人,进行通知
if (markers?.Length > 0 && !instance.MarkerNotifyURL.IsNullOrEmpty() && markers?.Length > 0) if (!string.IsNullOrEmpty(marker) && !instance.MarkerNotifyURL.IsNullOrEmpty())
{ {
Task.Factory.StartNew(() => NotifyMakerChangedAsync(instance, [long.Parse(markers[0])])); Task.Factory.StartNew(() => NotifyMakerChangedAsync(status, instance, long.Parse(marker)));
} }
} }
@ -457,10 +457,11 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
/// <summary> /// <summary>
/// 运行执行人变更回调 /// 运行执行人变更回调
/// </summary> /// </summary>
/// <param name="status">审批结果</param>
/// <param name="instance">运行实例</param> /// <param name="instance">运行实例</param>
/// <param name="nextUserId">下一执行人ID</param> /// <param name="nextUserId">下一执行人ID</param>
/// <returns></returns> /// <returns></returns>
protected virtual async Task NotifyMakerChangedAsync(FlowInstance instance, long[] nextUserId) protected virtual async Task NotifyMakerChangedAsync(int status, FlowInstance instance, params long[] nextUserId)
{ {
ArgumentNullException.ThrowIfNull(instance, nameof(instance)); ArgumentNullException.ThrowIfNull(instance, nameof(instance));
@ -471,6 +472,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
BusinessId = instance.BusinessId, BusinessId = instance.BusinessId,
BusinessType = instance.BusinessType, BusinessType = instance.BusinessType,
Type = instance.Type, Type = instance.Type,
Status = status == 1 ? FlowStatusEnum.Approve : FlowStatusEnum.Reject,
NextUserId = nextUserId NextUserId = nextUserId
}; };

@ -199,6 +199,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return extArray.Select(x => x["projectName"]?.Value<string>() ?? string.Empty).ToArray(); return extArray.Select(x => x["projectName"]?.Value<string>() ?? string.Empty).ToArray();
} }
public override async Task UpdateReceiverAsync(MakerChangedCallback callback)
{
if (callback.Type != AuditType.SeaExport)
return;
await base.UpdateReceiverAsync(callback);
}
/// <summary> /// <summary>
/// 审批完成回调更新 /// 审批完成回调更新
/// </summary> /// </summary>
@ -206,6 +214,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns> /// <returns></returns>
public override async Task UpdateBusinessAsync(FlowCallback callback) public override async Task UpdateBusinessAsync(FlowCallback callback)
{ {
if (callback.Type != AuditType.SeaExport)
return;
await base.UpdateBusinessAsync(callback); await base.UpdateBusinessAsync(callback);
//todo:海运出口主表信息 //todo:海运出口主表信息

@ -161,13 +161,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
Instance = await Db.Queryable<FlowInstance>().FirstAsync(x => x.Id == task.FlowId.Value) Instance = await Db.Queryable<FlowInstance>().FirstAsync(x => x.Id == task.FlowId.Value)
}); });
var flow = await Db.Queryable<FlowInstance>().Where(x => x.Id == task.FlowId.Value).Select(x => new var flow = await Db.Queryable<FlowInstance>().Where(x => x.Id == task.FlowId.Value).Select(x => new FlowInstance
{ {
x.FlowStatus, FlowStatus = x.FlowStatus,
x.MakerList, MakerList = x.MakerList,
}).FirstAsync(); }).FirstAsync();
result.Data = (string.IsNullOrEmpty(flow.MakerList) || flow.MakerList == "-1") && flow.FlowStatus == FlowStatusEnum.Approve; result.Data = new { flow.IsCompleted, flow.FlowStatus };
return result; return result;
} }
@ -236,7 +236,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
x.ETD, x.ETD,
}).FirstAsync(x => x.Id == request.BusinessId); }).FirstAsync(x => x.Id == request.BusinessId);
info.Main.TaskDesp = info.Main.TaskTitle = $"{request.TaskType.GetDescription()} {biz.Vessel} {biz.Voyno} ETD:{biz.ETD?.ToString("yyyy-MM-dd")} BLNo:{biz.MBLNO}"; info.Main.TaskDesp = info.Main.TaskTitle = $"{request.TaskType.GetDescription()} {biz?.Vessel} {biz?.Voyno} ETD:{biz?.ETD?.ToString("yyyy-MM-dd")} BLNo:{biz?.MBLNO}";
} }
if (useTransaction) if (useTransaction)
@ -392,7 +392,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessId = request.BusinessId, BusinessId = request.BusinessId,
BusinessType = request.BusinessType, BusinessType = request.BusinessType,
TaskType = task.NextType.Value, TaskType = task.NextType.Value,
RecvUserIdList = task.RecvUserIdArray, RecvUserIdList = task.RecvUserIdArray
}; };
await CreateTaskAsync(req, false); await CreateTaskAsync(req, false);
} }
@ -429,13 +429,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <param name="callback">回调信息</param> /// <param name="callback">回调信息</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception> /// <exception cref="ArgumentNullException"><paramref name="callback"/>为null时引发</exception>
public virtual Task UpdateReceiverAsync(MakerChangedCallback callback) public virtual async Task UpdateReceiverAsync(MakerChangedCallback callback)
{ {
//ArgumentNullException.ThrowIfNull(callback, nameof(callback)); ArgumentNullException.ThrowIfNull(callback, nameof(callback));
long userId = long.Parse(User.UserId);
//if (callback.NextUserId == null) //if (callback.NextUserId == null)
// return; // return;
//var users = await GetRecvUsers(callback.NextUserId); //var users = await GetRecvUsers(callback.NextUserId);
//var result = await ManagerService.TransferTask(callback.BusinessId, TaskBaseTypeEnum.WAIT_ORDER_AUDIT, users); //var result = await ManagerService.TransferTask(callback.BusinessId, TaskBaseTypeEnum.WAIT_ORDER_AUDIT, users);
//if (!result.Succeeded) //if (!result.Succeeded)
@ -449,8 +451,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
// x.BusinessType == callback.BusinessType && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) // x.BusinessType == callback.BusinessType && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
// .SetColumns(x => x.RecvUsers == recvUser) // .SetColumns(x => x.RecvUsers == recvUser)
// .ExecuteCommandAsync(); // .ExecuteCommandAsync();
return Task.CompletedTask;
} }
/// <summary> /// <summary>
@ -470,7 +470,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessType = callback.BusinessType.Value, BusinessType = callback.BusinessType.Value,
TaskType = TaskBaseTypeEnum.WAIT_ORDER_AUDIT, TaskType = TaskBaseTypeEnum.WAIT_ORDER_AUDIT,
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
AutoCreateNext = callback.FlowStatus == FlowStatusEnum.Approve AutoCreateNext = false
}); });
if (callback.FlowStatus == FlowStatusEnum.Reject) if (callback.FlowStatus == FlowStatusEnum.Reject)

Loading…
Cancel
Save