定时任务提箱小票、VGM链接任务添加事务处理

usertest
cjy 3 months ago
parent e8d8692142
commit 47ec50983f

@ -56,17 +56,7 @@ namespace DS.WMS.Core.HangfireJob.Method
_logger.Error("海运出口信息不存在!");
throw new Exception("海运出口信息不存在!");
}
var orderUrl = tenantDb.Queryable<BookingOrderUrl>().First(x => x.BusinessId == bookingId);
if (orderUrl == null)
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
tenantDb.Insertable(orderUrl).ExecuteCommand();
}
//if (!string.IsNullOrEmpty(orderUrl.UrlVgm))
//{
// return await Task.FromResult(DataResult<string[]>.Success(new string[] { orderUrl.UrlVgm, orderUrl.UrlVgmSi }));
@ -210,25 +200,42 @@ namespace DS.WMS.Core.HangfireJob.Method
_logger.Error(jobjResp.GetStringValue("message"));
throw new Exception(jobjResp.GetStringValue("message"));
}
try
{
tenantDb.Ado.BeginTran();
var orderUrl = tenantDb.Queryable<BookingOrderUrl>().First(x => x.BusinessId == bookingId);
if (orderUrl == null)
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
tenantDb.Insertable(orderUrl).ExecuteCommand();
}
//保存url
var memoData = jobjResp.GetJObjectValue("memoData");
orderUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
orderUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
tenantDb.Updateable(orderUrl).ExecuteCommand();
//保存url
var memoData = jobjResp.GetJObjectValue("memoData");
orderUrl.UrlVgm = memoData.GetStringValue("vgmUrl");
orderUrl.UrlVgmSi = memoData.GetStringValue("vgmAndSiUrl");
tenantDb.Updateable(orderUrl).ExecuteCommand();
//货运动态
var bookingStatus = new BookingStatusLog()
//货运动态
var bookingStatus = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"生成VGM链接",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
tenantDb.Insertable(bookingStatus).ExecuteCommand();
tenantDb.Ado.CommitTran();
}
catch (Exception ex)
{
BusinessId = bookingId,
Status = $"生成VGM链接",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
tenantDb.Insertable(bookingStatus).ExecuteCommand();
tenantDb.Ado.RollbackTran();
throw new Exception(ex.ToString());
}
}
public void TxxpLinkJob(BaseJobReq req)
@ -238,17 +245,7 @@ namespace DS.WMS.Core.HangfireJob.Method
var bookingId = req.Id;
var order = tenantDb.Queryable<SeaExport>().First(x => x.Id == bookingId);
var orderUrl = tenantDb.Queryable<BookingOrderUrl>().First(x => x.BusinessId == bookingId);
if (orderUrl == null)
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
tenantDb.Insertable(orderUrl).ExecuteCommand();
}
//校验船公司
if (string.IsNullOrEmpty(order.Carrier) || order.CarrierId == 0)
{
@ -377,26 +374,44 @@ namespace DS.WMS.Core.HangfireJob.Method
_logger.Error(jobjResp.GetStringValue("message"));
throw new Exception(jobjResp.GetStringValue("message"));
}
try
{
tenantDb.Ado.BeginTran();
var orderUrl = tenantDb.Queryable<BookingOrderUrl>().First(x => x.BusinessId == bookingId);
if (orderUrl == null)
{
orderUrl = new BookingOrderUrl()
{
BusinessId = bookingId
};
tenantDb.Insertable(orderUrl).ExecuteCommand();
}
var addUrlFlag = string.IsNullOrEmpty(orderUrl.UrlTxxp) ? true : false; //新生成还是更新链接
//保存url
var addUrlFlag = string.IsNullOrEmpty(orderUrl.UrlTxxp) ? true : false; //新生成还是更新链接
//保存url
//保存url
var txxpUrl = jobjResp.GetStringValue("data");
orderUrl.UrlTxxp = txxpUrl;
tenantDb.Updateable(orderUrl).ExecuteCommand();
//保存url
var txxpUrl = jobjResp.GetStringValue("data");
orderUrl.UrlTxxp = txxpUrl;
tenantDb.Updateable(orderUrl).ExecuteCommand();
//货运动态
var bookingStatus = new BookingStatusLog()
//货运动态
var bookingStatus = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"{(addUrlFlag ? "" : "")}提箱小票链接",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
tenantDb.Insertable(bookingStatus).ExecuteCommand();
tenantDb.Ado.CommitTran();
}
catch (Exception ex)
{
BusinessId = bookingId,
Status = $"{(addUrlFlag ? "" : "")}提箱小票链接",
Group = "ship",
OpTime = DateTime.Now,
MBLNO = order.MBLNO
};
tenantDb.Insertable(bookingStatus).ExecuteCommand();
tenantDb.Ado.RollbackTran();
throw new Exception(ex.ToString());
}
}
}
}

@ -31,7 +31,7 @@ builder.Logging.AddNLog("nlog.config");
//Autofac注入
builder.ConfigureContainer(new AutofacServiceProviderFactory(), builder => builder.RegisterModule(new AutofacModuleRegister()));
builder.Services.AddTransient<IProblemDetailsWriter, SampleProblemDetailsWriter>();
//builder.Services.AddTransient<IProblemDetailsWriter, SampleProblemDetailsWriter>();
//builder.Services.AddExceptionHandler<GlobalExceptionsFilter>(); //全局异常
builder.Services.AddControllers(options =>
{

Loading…
Cancel
Save