修改订舱保存状态

optimize
jianghaiqing 1 year ago
parent 8b2031b137
commit a03b155d5e

@ -130,7 +130,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingLineOpMgrConfig> _repLineOpMgrConfig;
private readonly SqlSugarRepository<SysEmp> _repSysEmp;
private readonly SqlSugarRepository<Booking_AutoYardImport> _repAutoYard;
private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
@ -152,7 +152,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig,
SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingServiceItem> serviceItem,
SqlSugarRepository<ParaContractNoInfo> paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository<DjyWebsiteAccountConfig> djyWebsiteAccountConfigRepository,
ISysOrgService orgService, SqlSugarRepository<BookingLineOpMgrConfig> repLineOpMgrConfig, SqlSugarRepository<SysEmp> repSysEmp, SqlSugarRepository<Booking_AutoYardImport> repAutoYard)
ISysOrgService orgService, SqlSugarRepository<BookingLineOpMgrConfig> repLineOpMgrConfig, SqlSugarRepository<SysEmp> repSysEmp, SqlSugarRepository<Booking_AutoYardImport> repAutoYard,
IServiceWorkFlowManageService serviceWorkFlowManageService)
{
this._logger = logger;
this._rep = rep;
@ -198,6 +199,8 @@ namespace Myshipping.Application
this._repLineOpMgrConfig = repLineOpMgrConfig;
this._repSysEmp = repSysEmp;
this._repAutoYard = repAutoYard;
_serviceWorkFlowManageService = serviceWorkFlowManageService;
}
#region 主表和箱信息
@ -979,6 +982,14 @@ namespace Myshipping.Application
if (string.IsNullOrEmpty(entity.CUSTNO))
{
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
await SetGoodsStatusCancel("YDC",Id);
await SetBookingOrderGoodsStatus(Id);
}
else
{
var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault();
if (Config != null)
@ -988,7 +999,16 @@ namespace Myshipping.Application
await SetBookingOrderGoodsStatus(Id);
}
}
}
if (string.IsNullOrEmpty(entity.MBLNO))
{
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
await SetGoodsStatusCancel("YSDBC", Id);
await SetBookingOrderGoodsStatus(Id);
}
else
{
var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault();
if (Config != null)
@ -998,6 +1018,7 @@ namespace Myshipping.Application
await SetBookingOrderGoodsStatus(Id);
}
}
}
#endregion
}
@ -8422,6 +8443,12 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
public async Task SetGoodsStatus(string code, long bookingId)
{
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
await SetGoodsStatusPush(code, bookingId);
return;
}
var CreatedUserId = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First();
if (CreatedUserId != null)
{
@ -8831,6 +8858,193 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
await SendBookingOrder(orderlist.ToArray());
}
#region 推送服务状态
/// <summary>
/// 推送服务状态
/// </summary>
/// <param name="code">服务状态代码</param>
/// <param name="bookingId">订舱ID</param>
/// <param name="isAutoSyncDS">是否默认同步东胜 true-自动同步 false-不自动同步</param>
/// <returns></returns>
public async Task SetGoodsStatusPush(string code, long bookingId, bool isAutoSyncDS = false)
{
string batchNo = IDGen.NextID().ToString();
/*
1
2BSSTATUSNAME
3
*/
if (string.IsNullOrWhiteSpace(code))
{
_logger.LogInformation("批次={no} 调取{name} 服务状态代码不能为空", batchNo, nameof(SetGoodsStatusPush));
throw Oops.Oh($"服务状态代码不能为空");
}
if (bookingId == 0)
{
_logger.LogInformation("批次={no} 调取{name} 订舱ID不能为空", batchNo, nameof(SetGoodsStatusPush));
throw Oops.Oh($"订舱ID不能为空");
}
var saveStatusRlt = await _serviceWorkFlowManageService.SaveServiceStatus(new ModifyServiceProjectStatusDto
{
BookingId = bookingId,
SourceType = TrackingSourceTypeEnum.AUTO,
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
new ModifyServiceProjectStatusDetailDto {
StatusCode = code
}
}
});
_logger.LogInformation("批次={no} 异步推送状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt));
if (saveStatusRlt.succ)
{
//拉取最新的状态数据,并取已完成的排序最大的状态写入订舱的字段 BSSTATUSNAME
var bookingOrder = _rep.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus
{
BookingId = bookingId,
QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT,
TenantId = bookingOrder.TenantId.Value
};
var queryRlt = await _serviceWorkFlowManageService.GetEnableStatusListByBusiness(queryInfo);
if (queryRlt.succ)
{
var statusList = JSON.Deserialize<List<ServiceProjectStatusDto>>(JSON.Serialize(queryRlt.ext));
if (statusList != null)
{
var maxStatus = statusList.Where(a => a.IsYield)
.OrderByDescending(a => a.CalcSortNo).FirstOrDefault();
if (maxStatus != null)
{
var model = _rep.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
model.BSSTATUSNAME = maxStatus.ShowName;
model.VERSION = IDGen.NextID().ToString().Replace("-", "");
//更新订舱
_rep.AsUpdateable(model)
.UpdateColumns(it => new
{
it.BSSTATUSNAME,
it.VERSION
}).ExecuteCommand();
//推送东胜
if (isAutoSyncDS)
await SendBookingOrder(new long[] { bookingId });
}
}
}
}
}
#endregion
#region 取消服务状态
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="code">服务状态代码</param>
/// <param name="bookingId">订舱编号</param>
/// <param name="isAutoSyncDS">是否默认同步东胜 true-自动同步 false-不自动同步</param>
/// <returns></returns>
public async Task SetGoodsStatusCancel(string code, long bookingId, bool isAutoSyncDS = false)
{
string batchNo = IDGen.NextID().ToString();
/*
1
2BSSTATUSNAME
3
*/
if (string.IsNullOrWhiteSpace(code))
{
_logger.LogInformation("批次={no} 调取{name} 服务状态代码不能为空", batchNo, nameof(SetGoodsStatusPush));
throw Oops.Oh($"服务状态代码不能为空");
}
if (bookingId == 0)
{
_logger.LogInformation("批次={no} 调取{name} 订舱ID不能为空", batchNo, nameof(SetGoodsStatusPush));
throw Oops.Oh($"订舱ID不能为空");
}
var saveStatusRlt = await _serviceWorkFlowManageService.CancelServiceStatus(new ModifyServiceProjectStatusDto
{
BookingId = bookingId,
SourceType = TrackingSourceTypeEnum.AUTO,
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
new ModifyServiceProjectStatusDetailDto {
StatusCode = code
}
}
});
_logger.LogInformation("批次={no} 异步取消状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt));
if (saveStatusRlt.succ)
{
//拉取最新的状态数据,并取已完成的排序最大的状态写入订舱的字段 BSSTATUSNAME
var bookingOrder = _rep.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus
{
BookingId = bookingId,
QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT,
TenantId = bookingOrder.TenantId.Value
};
var queryRlt = await _serviceWorkFlowManageService.GetEnableStatusListByBusiness(queryInfo);
if (queryRlt.succ)
{
var statusList = JSON.Deserialize<List<ServiceProjectStatusDto>>(JSON.Serialize(queryRlt.ext));
if (statusList != null)
{
var maxStatus = statusList.Where(a => a.IsYield)
.OrderByDescending(a => a.CalcSortNo).FirstOrDefault();
var model = _rep.AsQueryable().Filter(null, true)
.First(a => a.Id == bookingId);
if (maxStatus != null)
{
model.BSSTATUSNAME = maxStatus.ShowName;
}
else
{
model.BSSTATUSNAME = string.Empty;
}
model.VERSION = IDGen.NextID().ToString().Replace("-", "");
//更新订舱
_rep.AsUpdateable(model)
.UpdateColumns(it => new
{
it.BSSTATUSNAME,
it.VERSION
}).ExecuteCommand();
//推送东胜
await SendBookingOrder(new long[] { bookingId });
}
}
}
}
#endregion
}
}

@ -78,6 +78,22 @@ namespace Myshipping.Application
Task AutoYardData(long bookId);
/// <summary>
/// 推送服务状态
/// </summary>
/// <param name="code">服务状态代码</param>
/// <param name="bookingId">订舱ID</param>
/// <param name="isAutoSyncDS">是否默认同步东胜 true-自动同步 false-不自动同步</param>
/// <returns></returns>
Task SetGoodsStatusPush(string code, long bookingId, bool isAutoSyncDS = false);
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="code">服务状态代码</param>
/// <param name="bookingId">订舱编号</param>
/// <param name="isAutoSyncDS">是否默认同步东胜 true-自动同步 false-不自动同步</param>
/// <returns></returns>
Task SetGoodsStatusCancel(string code, long bookingId, bool isAutoSyncDS = false);
}
}

@ -125,6 +125,6 @@
"SendBookingOrderMQUri": "amqp://hechuan_booking:hechuan_booking123@47.104.207.5:12567/hechuan_booking",
"ShippingOrderCompareUrl": "http://60.209.125.238:35210/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare",
"BCOrDraftUserKey": "BookingOrderPlat",
"BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6"
"BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6",
"ServiceStatusOpenAuto": "0"
}
Loading…
Cancel
Save