调用规则库返回错误时写入日志

dev
嵇文龙 2 weeks ago
parent ee9efa753e
commit f01369ce6b

@ -452,19 +452,29 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="ids">费用记录ID</param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(params long[] ids)
{
await TenantDb.Ado.BeginTranAsync();
try
{
var model = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).FirstAsync();
if (await IsFeeLockedAsync(model.BusinessId, model.BusinessType))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeLocked));
if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)))
if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FeeRecordDelete));
int result = await TenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
await TenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
await WriteBackStatusAsync(model.BusinessId, model.BusinessType);
return result > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
#region 审核相关
@ -534,6 +544,8 @@ namespace DS.WMS.Core.Fee.Method
x.SubmitBy,
x.SubmitDate
}).ExecuteCommandAsync();
await WriteBackStatusAsync(bid, bType);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
@ -869,6 +881,7 @@ namespace DS.WMS.Core.Fee.Method
}
await TenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.SubmitBy, x.SubmitDate }).ExecuteCommandAsync();
await WriteBackStatusAsync(fees[0].BusinessId, fees[0].BusinessType);
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
@ -1002,6 +1015,8 @@ namespace DS.WMS.Core.Fee.Method
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.Withdraw || x.FeeStatus == FeeStatus.RejectSubmission))
.SetColumns(x => x.FeeStatus == FeeStatus.AuditSubmitted).ExecuteCommandAsync();
await WriteBackStatusAsync(bid, type);
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
@ -1092,6 +1107,8 @@ namespace DS.WMS.Core.Fee.Method
await TenantDb.Updateable<FeeRecord>().Where(x => x.BusinessId == bid && x.BusinessType == type && x.FeeStatus == FeeStatus.AuditSubmitted)
.SetColumns(x => x.FeeStatus == FeeStatus.Entering).ExecuteCommandAsync();
await WriteBackStatusAsync(bid, type);
await TenantDb.Ado.CommitTranAsync();
return result;
}

@ -114,6 +114,12 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[Description("删除")]
Delete = 10,
/// <summary>
/// 规则验证
/// </summary>
[Description("规则验证")]
Validation = 11,
/// <summary>
/// 审核
/// </summary>

@ -159,6 +159,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
await SetLockAsync(biz);
}
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)

@ -25,6 +25,7 @@ using Mapster;
using Masuit.Tools;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Method
@ -235,7 +236,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
result = await CheckRulesAsync(request.BusinessId, request.BusinessType.Value, RuleEngineType.COMMON_ORDER_AUDIT);
result = await CheckRulesAsync(request.TaskType, request.BusinessId, request.BusinessType.Value, RuleEngineType.COMMON_ORDER_AUDIT);
if (!result.Succeeded)
return result;
}
@ -754,7 +755,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
if (task.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
result = await CheckRulesAsync(request.BusinessId, request.BusinessType.Value, RuleEngineType.COMMON_ORDER_AUDIT);
result = await CheckRulesAsync(request.TaskType, request.BusinessId, request.BusinessType.Value, RuleEngineType.COMMON_ORDER_AUDIT);
if (!result.Succeeded)
return result;
}
@ -970,7 +971,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
//如果当前审批为终审,则调用规则库进行校验
if (request.Result == 1 && request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.GetMarkerList().Length == 1)
{
result = await CheckRulesAsync(instance.BusinessId, request.BusinessType.GetValueOrDefault(), RuleEngineType.COMMON_OCEAN_BOOKING);
result = await CheckRulesAsync(request.TaskType, instance.BusinessId, request.BusinessType.GetValueOrDefault(), RuleEngineType.COMMON_OCEAN_BOOKING);
if (!result.Succeeded)
return result;
}
@ -1229,7 +1230,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
return info;
}
async Task<DataResult> CheckRulesAsync(long bsId, BusinessType businessType, RuleEngineType ruleType)
//调用规则库
async Task<DataResult> CheckRulesAsync(TaskBaseTypeEnum taskType, long bsId, BusinessType businessType, RuleEngineType ruleType)
{
var rulesReq = new RuleEngineReq();
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId).FirstAsync();
@ -1239,7 +1241,17 @@ namespace DS.WMS.Core.TaskInteraction.Method
var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq);
if (string.Equals(ruleResult.Succ, bool.FalseString, StringComparison.OrdinalIgnoreCase))
{
return DataResult.Failed(ruleResult.Msg);
string msg = "校验规则API返回了错误" + ruleResult.Msg;
var taskLog = new BusinessTaskLog
{
BusinessId = bsId,
BusinessType = businessType,
ActionType = ActionType.Validation,
TaskType = taskType,
Remark = msg + ";请求参数:" + JsonConvert.SerializeObject(rulesReq)
};
await LogService.WriteLogAsync(taskLog);
return DataResult.Failed(msg);
}
else if (ruleResult.Extra.DetailList?.Count > 0)
{

Loading…
Cancel
Save