bug修复

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

@ -216,7 +216,7 @@ public class DataResult<TData> : IDataResult<ResultCode, TData>
/// <summary>
/// 初始化一个<see cref="DataResult{TResultType,TData}"/>类型的新实例
/// </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)
{
@ -275,7 +275,10 @@ public class DataResult<TData> : IDataResult<ResultCode, TData>
/// </summary>
public bool Succeeded => Code == ResultCode.Success;
public TData Data { get; set; }
/// <summary>
/// 数据
/// </summary>
public TData? Data { get; set; }
/// <summary>
/// 附加数据

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

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

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

@ -117,4 +117,10 @@ public class FlowInstance : BaseTenantModel<long>
/// </summary>
[SugarColumn(IsIgnore = true)]
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>
/// <param name="instance">运行实例</param>
/// <returns></returns>
public static string[] GetNextMarkers(FlowInstance instance)
public static string GetNextMarkers(FlowInstance instance)
{
string[] markers = GetMarkers(instance);
if (instance.ActivityType == 0 && markers.Length > 0)
return [markers[0]];
return markers[0];
return markers;
return string.Empty;
}
/// <summary>
@ -49,9 +49,9 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
/// </summary>
/// <param name="instance">运行实例</param>
/// <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 instance.MakerList.Split(',', StringSplitOptions.RemoveEmptyEntries);
@ -385,11 +385,11 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
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>
/// <param name="status">审批结果</param>
/// <param name="instance">运行实例</param>
/// <param name="nextUserId">下一执行人ID</param>
/// <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));
@ -471,6 +472,7 @@ public class FlowInstanceService : ServiceBase, IFlowInstanceService
BusinessId = instance.BusinessId,
BusinessType = instance.BusinessType,
Type = instance.Type,
Status = status == 1 ? FlowStatusEnum.Approve : FlowStatusEnum.Reject,
NextUserId = nextUserId
};

@ -199,6 +199,14 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
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>
@ -206,6 +214,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns>
public override async Task UpdateBusinessAsync(FlowCallback callback)
{
if (callback.Type != AuditType.SeaExport)
return;
await base.UpdateBusinessAsync(callback);
//todo:海运出口主表信息

@ -161,13 +161,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
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,
x.MakerList,
FlowStatus = x.FlowStatus,
MakerList = x.MakerList,
}).FirstAsync();
result.Data = (string.IsNullOrEmpty(flow.MakerList) || flow.MakerList == "-1") && flow.FlowStatus == FlowStatusEnum.Approve;
result.Data = new { flow.IsCompleted, flow.FlowStatus };
return result;
}
@ -236,7 +236,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
x.ETD,
}).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)
@ -392,7 +392,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
TaskType = task.NextType.Value,
RecvUserIdList = task.RecvUserIdArray,
RecvUserIdList = task.RecvUserIdArray
};
await CreateTaskAsync(req, false);
}
@ -429,13 +429,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <param name="callback">回调信息</param>
/// <returns></returns>
/// <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)
// return;
//var users = await GetRecvUsers(callback.NextUserId);
//var result = await ManagerService.TransferTask(callback.BusinessId, TaskBaseTypeEnum.WAIT_ORDER_AUDIT, users);
//if (!result.Succeeded)
@ -449,8 +451,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
// x.BusinessType == callback.BusinessType && x.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
// .SetColumns(x => x.RecvUsers == recvUser)
// .ExecuteCommandAsync();
return Task.CompletedTask;
}
/// <summary>
@ -470,7 +470,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessType = callback.BusinessType.Value,
TaskType = TaskBaseTypeEnum.WAIT_ORDER_AUDIT,
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
AutoCreateNext = callback.FlowStatus == FlowStatusEnum.Approve
AutoCreateNext = false
});
if (callback.FlowStatus == FlowStatusEnum.Reject)

Loading…
Cancel
Save