# Conflicts:
#	Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
optimize
wet 1 year ago
commit 052a678329

@ -12,15 +12,15 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public enum TrackingSourceTypeEnum public enum TrackingSourceTypeEnum
{ {
/// <summary>
/// 自动
/// </summary>
[Description("自动")]
AUTO,
/// <summary> /// <summary>
/// 人工 /// 人工
/// </summary> /// </summary>
[Description("人工")] [Description("人工")]
MANUAL, MANUAL,
/// <summary>
/// 自动
/// </summary>
[Description("自动")]
AUTO
} }
} }

@ -130,8 +130,12 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingLineOpMgrConfig> _repLineOpMgrConfig; private readonly SqlSugarRepository<BookingLineOpMgrConfig> _repLineOpMgrConfig;
private readonly SqlSugarRepository<SysEmp> _repSysEmp; private readonly SqlSugarRepository<SysEmp> _repSysEmp;
private readonly SqlSugarRepository<Booking_AutoYardImport> _repAutoYard; private readonly SqlSugarRepository<Booking_AutoYardImport> _repAutoYard;
private readonly SqlSugarRepository<BookingExtendState> _repextendstate; private readonly SqlSugarRepository<BookingExtendState> _repextendstate;
private readonly IServiceWorkFlowManageService _serviceWorkFlowManageService;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING"; const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT"; const string CONST_MAPPING_MODULE_ROUTE = "BOOK_OR_CLOSING_RT";
private const string PrintRecentListTypeKey = "booking_print_recent_list"; private const string PrintRecentListTypeKey = "booking_print_recent_list";
@ -152,7 +156,8 @@ namespace Myshipping.Application
SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, 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<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingServiceItem> serviceItem,
SqlSugarRepository<ParaContractNoInfo> paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository<DjyWebsiteAccountConfig> djyWebsiteAccountConfigRepository, 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._logger = logger;
this._rep = rep; this._rep = rep;
@ -192,13 +197,12 @@ namespace Myshipping.Application
this._repPrintTemplateShare = repPrintTemplateShare; this._repPrintTemplateShare = repPrintTemplateShare;
_httpContextAccessor = httpContextAccessor; _httpContextAccessor = httpContextAccessor;
_GoodsConfig = GoodsConfig; _GoodsConfig = GoodsConfig;
_djyWebsiteAccountConfigRepository = djyWebsiteAccountConfigRepository; _djyWebsiteAccountConfigRepository = djyWebsiteAccountConfigRepository;
this._repLineOpMgrConfig = repLineOpMgrConfig; this._repLineOpMgrConfig = repLineOpMgrConfig;
this._repSysEmp = repSysEmp; this._repSysEmp = repSysEmp;
this._repAutoYard = repAutoYard; this._repAutoYard = repAutoYard;
this._repextendstate = repextendstate; this._repextendstate = repextendstate;
_serviceWorkFlowManageService = serviceWorkFlowManageService;
} }
#region 主表和箱信息 #region 主表和箱信息
@ -981,23 +985,41 @@ namespace Myshipping.Application
if (string.IsNullOrEmpty(entity.CUSTNO)) if (string.IsNullOrEmpty(entity.CUSTNO))
{ {
var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault(); if (App.Configuration["ServiceStatusOpenAuto"] == "1")
if (Config != null)
{ {
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); await SetGoodsStatusCancel("YDC",Id);
//更新货物状态
await SetBookingOrderGoodsStatus(Id); await SetBookingOrderGoodsStatus(Id);
} }
else
{
var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault();
if (Config != null)
{
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id);
//更新货物状态
await SetBookingOrderGoodsStatus(Id);
}
}
} }
if (string.IsNullOrEmpty(entity.MBLNO)) if (string.IsNullOrEmpty(entity.MBLNO))
{ {
var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault(); if (App.Configuration["ServiceStatusOpenAuto"] == "1")
if (Config != null)
{ {
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id); await SetGoodsStatusCancel("YSDBC", Id);
//更新货物状态
await SetBookingOrderGoodsStatus(Id); await SetBookingOrderGoodsStatus(Id);
} }
else
{
var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault();
if (Config != null)
{
_goodsStatus.Delete(x => x.bookingId == Id && x.ConfigId == Config.Id);
//更新货物状态
await SetBookingOrderGoodsStatus(Id);
}
}
} }
#endregion #endregion
} }
@ -8427,6 +8449,12 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
public async Task SetGoodsStatus(string code, long bookingId) 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(); var CreatedUserId = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First();
if (CreatedUserId != null) if (CreatedUserId != null)
{ {
@ -8838,6 +8866,194 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
await SendBookingOrder(orderlist.ToArray()); await SendBookingOrder(orderlist.ToArray());
} }
#endregion
#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 #endregion
@ -8902,17 +9118,18 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
{ {
//订舱号(单号) //订舱号(单号)
var mb = item.GetStringValue("bookingno"); //提单号 var mb = item.GetStringValue("bookingno"); //提单号
if (mb==order.MBLNO) { if (mb == order.MBLNO)
{
var noApply= item.GetIntValue("noApply"); //未申请
var applyNoPrint = item.GetIntValue("applyNoPrint"); //已申请未打印 var noApply = item.GetIntValue("noApply"); //未申请
var print = item.GetIntValue("print"); //已打印 var applyNoPrint = item.GetIntValue("applyNoPrint"); //已申请未打印
var print = item.GetIntValue("print"); //已打印
await _repextendstate.InsertAsync(new BookingExtendState await _repextendstate.InsertAsync(new BookingExtendState
{ {
bookingId=Id, bookingId = Id,
noApply= noApply, noApply = noApply,
applyNoPrint= applyNoPrint, applyNoPrint = applyNoPrint,
print= print print = print
}); });
} }
} }
@ -8926,5 +9143,6 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
#endregion #endregion
} }
} }

@ -2276,7 +2276,7 @@ namespace Myshipping.Application
OpertType = TrackingOperTypeEnum.MANUAL, OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(), OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name, OperUserName = UserManager.Name,
SourceType = TrackingSourceTypeEnum.MANUAL, SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{ {
StatusCode = a.StatusCode, StatusCode = a.StatusCode,
@ -2368,7 +2368,7 @@ namespace Myshipping.Application
OpertType = TrackingOperTypeEnum.MANUAL, OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(), OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name, OperUserName = UserManager.Name,
SourceType = TrackingSourceTypeEnum.MANUAL, SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{ {
StatusCode = a.StatusCode, StatusCode = a.StatusCode,

@ -32,6 +32,11 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public long BookingId { get; set; } public long BookingId { get; set; }
/// <summary>
/// 来源类型
/// </summary>
public TrackingSourceTypeEnum SourceType { get; set; } = TrackingSourceTypeEnum.MANUAL;
/// <summary> /// <summary>
/// 服务项目状态明细 /// 服务项目状态明细
/// </summary> /// </summary>

@ -78,6 +78,22 @@ namespace Myshipping.Application
Task AutoYardData(long bookId); 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);
} }
} }

@ -37,14 +37,18 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository; private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository;
//private readonly SqlSugarRepository<SysUser> _userRepository; //private readonly SqlSugarRepository<SysUser> _userRepository;
private readonly IBookingValueAddedService _bookingValueAddedService;
public TaskShippingOrderCompareService(ISysCacheService cache, ILogger<TaskShippingOrderCompareService> logger, public TaskShippingOrderCompareService(ISysCacheService cache, ILogger<TaskShippingOrderCompareService> logger,
SqlSugarRepository<BookingOrder> bookingOrderRepository, SqlSugarRepository<BookingCtn> bookingOrderContaRepository) SqlSugarRepository<BookingOrder> bookingOrderRepository, SqlSugarRepository<BookingCtn> bookingOrderContaRepository,
IBookingValueAddedService bookingValueAddedService)
{ {
_cache = cache; _cache = cache;
_logger = logger; _logger = logger;
_bookingOrderRepository = bookingOrderRepository; _bookingOrderRepository = bookingOrderRepository;
_bookingOrderContaRepository = bookingOrderContaRepository; _bookingOrderContaRepository = bookingOrderContaRepository;
_bookingValueAddedService = bookingValueAddedService;
} }
/// <summary> /// <summary>
/// 执行下货纸比对 /// 执行下货纸比对
@ -153,6 +157,21 @@ namespace Myshipping.Application
{ {
orderInfo.LstShipOrderCompareRlt = "NO_DIFF"; orderInfo.LstShipOrderCompareRlt = "NO_DIFF";
orderInfo.LstShipOrderCompareRltName = "正常"; orderInfo.LstShipOrderCompareRltName = "正常";
//推送状态JHQ
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
//比对成功后触发下货纸比对状态
var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(new ModifyServiceProjectStatusDto
{
BookingId = long.Parse(bookingId),
SourceType = TrackingSourceTypeEnum.AUTO,
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
new ModifyServiceProjectStatusDetailDto { StatusCode = "XHZBDCHG" } }
});
_logger.LogInformation("批次={no} 异步推送下货纸比对状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt));
}
} }
} }
else else

@ -130,7 +130,18 @@ namespace Myshipping.Application
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false); Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false);
/// <summary>
/// 获取可用的服务项目字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableProjectDictTreeList(bool isAvoidCache = false);
/// <summary>
/// 获取可用的服务状态字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableStatusDictTreeList(bool isAvoidCache = false);
} }
} }

@ -77,5 +77,19 @@ namespace Myshipping.Application
/// <param name="model">查询服务项目和状态详情</param> /// <param name="model">查询服务项目和状态详情</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model); Task<TaskManageOrderResultDto> GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model);
/// <summary>
/// 保存服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SaveServiceStatus(ModifyServiceProjectStatusDto model);
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CancelServiceStatus(ModifyServiceProjectStatusDto model);
} }
} }

@ -3,6 +3,7 @@ using Furion.DistributedIDGenerator;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Furion.FriendlyException; using Furion.FriendlyException;
using Furion.JsonSerialization; using Furion.JsonSerialization;
using Furion.Localization;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
@ -12,7 +13,9 @@ using Myshipping.Application.Entity;
using Myshipping.Application.Helper; using Myshipping.Application.Helper;
using Myshipping.Core; using Myshipping.Core;
using Myshipping.Core.Entity; using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common; using MySqlX.XDevAPI.Common;
using Npoi.Mapper;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using NPOI.SS.Formula.PTG; using NPOI.SS.Formula.PTG;
using NPOI.Util; using NPOI.Util;
@ -1766,7 +1769,7 @@ namespace Myshipping.Application
SortNo = a.SortNo SortNo = a.SortNo
}).OrderBy(a => a.SortNo).ToList(); }).OrderBy(a => a.SortNo).ToList();
await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList, TimeSpan.FromHours(8));
} }
return projectList; return projectList;
@ -1794,7 +1797,7 @@ namespace Myshipping.Application
{ {
statusList = ReloadServiceProjectCacheInfo(tenantId); statusList = ReloadServiceProjectCacheInfo(tenantId);
await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList, TimeSpan.FromHours(8));
} }
return statusList; return statusList;
@ -1813,7 +1816,7 @@ namespace Myshipping.Application
{ {
var statusList = ReloadServiceProjectCacheInfo(tenantId); var statusList = ReloadServiceProjectCacheInfo(tenantId);
await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList); await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT_STATUS}_{tenantId}", statusList, TimeSpan.FromHours(8));
_logger.LogInformation($"租户下可用的服务流程详情并写入缓存完成"); _logger.LogInformation($"租户下可用的服务流程详情并写入缓存完成");
@ -1825,7 +1828,7 @@ namespace Myshipping.Application
SortNo = a.SortNo SortNo = a.SortNo
}).OrderBy(a => a.SortNo).ToList(); }).OrderBy(a => a.SortNo).ToList();
await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList); await _cache.SetAsync($"{CONST_CACHE_ENABLE_PROJECT}_{tenantId}", projectList, TimeSpan.FromHours(8));
_logger.LogInformation($"租户下可用的服务写入缓存完成"); _logger.LogInformation($"租户下可用的服务写入缓存完成");
} }
@ -2015,6 +2018,86 @@ namespace Myshipping.Application
} }
#endregion #endregion
#region 获取可用的服务项目字典列表
/// <summary>
/// 获取可用的服务项目字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
[HttpGet("/ServiceWorkFlowBase/GetEnableProjectDictTreeList")]
public async Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableProjectDictTreeList([FromQuery] bool isAvoidCache = false)
{
List<Myshipping.Core.Service.DictTreeOutput> resultList = new List<Core.Service.DictTreeOutput>();
var list = await GetEnableProjectList(UserManager.TENANT_ID.ToString(), isAvoidCache);
if(list.Count > 0)
{
resultList.Add(new Core.Service.DictTreeOutput
{
Code = "booking_service_item",
Name = "订舱服务项目",
Children = list.OrderBy(a => a.SortNo).Select(a => new DictTreeOutput {
Code = a.ServiceProjectCode,
Name = a.ServiceProjectName
}).ToList()
});
}
return resultList;
}
#endregion
#region 获取可用的服务状态字典列表
/// <summary>
/// 获取可用的服务状态字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
[HttpGet("/ServiceWorkFlowBase/GetEnableStatusDictTreeList")]
public async Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableStatusDictTreeList([FromQuery] bool isAvoidCache = false)
{
List<Myshipping.Core.Service.DictTreeOutput> resultList = new List<Core.Service.DictTreeOutput>();
var list = await GetEnableProjectWithStatusList(UserManager.TENANT_ID.ToString(), isAvoidCache);
if (list.Count > 0)
{
resultList.Add(new Core.Service.DictTreeOutput
{
Code = "booking_goods_status",
Name = "订舱货物状态",
Children = list.OrderBy(a => a.SortNo).SelectMany(a => {
var rltList = new List<DictTreeOutput>();
a.StatusList.ForEach(b =>
{
rltList.Add(new DictTreeOutput
{
Code = b.StatusSKUCode,
Name = b.StatusSKUName,
Remark = b.BackgroundColor
});
if (b.SubStatusList != null && b.SubStatusList.Count > 0)
{
rltList.AddRange(b.SubStatusList.Select(c => new DictTreeOutput
{
Code = c.StatusSKUCode,
Name = c.StatusSKUName,
Remark = c.BackgroundColor
}).ToList());
}
});
return rltList;
}).ToList()
});
}
return resultList;
}
#endregion
} }
} }

@ -50,6 +50,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<ServiceWorkFlowRunLogInfo> _serviceWorkFlowRunLogInfoRepository; private readonly SqlSugarRepository<ServiceWorkFlowRunLogInfo> _serviceWorkFlowRunLogInfoRepository;
private readonly ICache _cache; private readonly ICache _cache;
private readonly CacheOptions _cacheOptions; private readonly CacheOptions _cacheOptions;
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService; private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
@ -71,7 +72,8 @@ namespace Myshipping.Application
IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository<SysUser> sysUserRepository, IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository<SysUser> sysUserRepository,
SqlSugarRepository<ServiceProjectBaseInfo> serviceProjectBaseInfoRepository, SqlSugarRepository<ServiceProjectBaseInfo> serviceProjectBaseInfoRepository,
SqlSugarRepository<ServiceWorkFlowRunLogInfo> serviceWorkFlowRunLogInfoRepository, SqlSugarRepository<ServiceWorkFlowRunLogInfo> serviceWorkFlowRunLogInfoRepository,
IOptions<CacheOptions> cacheOptions, Func<string, ISingleton, object> resolveNamed) IOptions<CacheOptions> cacheOptions, Func<string, ISingleton, object> resolveNamed,
SqlSugarRepository<BookingOrder> bookingOrderRepository)
{ {
_serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository; _serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository;
_serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository; _serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository;
@ -88,6 +90,7 @@ namespace Myshipping.Application
_sysUserRepository = sysUserRepository; _sysUserRepository = sysUserRepository;
_serviceProjectBaseInfoRepository = serviceProjectBaseInfoRepository; _serviceProjectBaseInfoRepository = serviceProjectBaseInfoRepository;
_serviceWorkFlowRunLogInfoRepository = serviceWorkFlowRunLogInfoRepository; _serviceWorkFlowRunLogInfoRepository = serviceWorkFlowRunLogInfoRepository;
_bookingOrderRepository = bookingOrderRepository;
_cacheOptions = cacheOptions.Value; _cacheOptions = cacheOptions.Value;
_cache = resolveNamed(_cacheOptions.CacheType.ToString(), default) as ICache; _cache = resolveNamed(_cacheOptions.CacheType.ToString(), default) as ICache;
@ -867,6 +870,7 @@ namespace Myshipping.Application
it.ACT_DATE, it.ACT_DATE,
it.IS_YIELD, it.IS_YIELD,
it.ACT_REMARK, it.ACT_REMARK,
it.ACT_VAL,
it.UpdatedTime, it.UpdatedTime,
it.UpdatedUserId, it.UpdatedUserId,
it.UpdatedUserName it.UpdatedUserName
@ -957,6 +961,7 @@ namespace Myshipping.Application
it.ACT_DATE, it.ACT_DATE,
it.IS_YIELD, it.IS_YIELD,
it.ACT_REMARK, it.ACT_REMARK,
it.ACT_VAL,
it.UpdatedTime, it.UpdatedTime,
it.UpdatedUserId, it.UpdatedUserId,
it.UpdatedUserName it.UpdatedUserName
@ -1949,5 +1954,187 @@ namespace Myshipping.Application
} }
#endregion #endregion
/// <summary>
/// 保存服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> SaveServiceStatus(ModifyServiceProjectStatusDto model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
try
{
var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == model.BookingId);
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废");
_logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model));
TrackingMessageInfo msgInfo = new TrackingMessageInfo
{
Head = new TrackingMessageHeadInfo
{
GID = IDGen.NextID().ToString(),
MessageType = "PROJECT",
ReceiverId = "ServiceProjectStatus",
ReceiverName = "服务项目和状态",
SenderId = "BookingOrder",
SenderName = "海运订舱",
RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Version = "2.0",
RequestAction = "AddOrModify",
},
Main = new TrackingMessageMainInfo
{
BusiId = model.BookingId.ToString(),
BusiSystemCode = "BOOKING_ORDER",
MBlNo = bookingOrder.MBLNO,
VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}",
OrderNo = bookingOrder.BSNO,
PushType = TrackingPushTypeEnum.Status,
OperTenantId = bookingOrder.TenantId.Value,
OperTenantName = bookingOrder.TenantName,
OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name,
SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{
StatusCode = a.StatusCode,
StatusDate = a.SetActDate,
StatusVal = a.SetActVal,
Remark = a.ActRemark
}).ToList()
}
};
DateTime bDate = DateTime.Now;
_logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo));
var rlt = await PushStatus(msgInfo);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败")
, JSON.Serialize(rlt));
if (!rlt.succ)
{
result = rlt;
}
else
{
result.succ = true;
result.msg = "推送成功";
}
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"服务项目状态推送失败,原因:{ex.Message}";
}
return result;
}
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> CancelServiceStatus(ModifyServiceProjectStatusDto model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
try
{
var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == model.BookingId);
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废");
_logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model));
TrackingMessageInfo msgInfo = new TrackingMessageInfo
{
Head = new TrackingMessageHeadInfo
{
GID = IDGen.NextID().ToString(),
MessageType = "PROJECT",
ReceiverId = "ServiceProjectStatus",
ReceiverName = "服务项目和状态",
SenderId = "BookingOrder",
SenderName = "海运订舱",
RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Version = "2.0",
RequestAction = "AddOrModify",
},
Main = new TrackingMessageMainInfo
{
BusiId = model.BookingId.ToString(),
BusiSystemCode = "BOOKING_ORDER",
MBlNo = bookingOrder.MBLNO,
VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}",
OrderNo = bookingOrder.BSNO,
PushType = TrackingPushTypeEnum.Status,
OperTenantId = bookingOrder.TenantId.Value,
OperTenantName = bookingOrder.TenantName,
OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name,
SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{
StatusCode = a.StatusCode,
StatusDate = a.SetActDate,
StatusVal = a.SetActVal,
Remark = a.ActRemark
}).ToList()
}
};
DateTime bDate = DateTime.Now;
_logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo));
var rlt = await CancelStatus(msgInfo);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败")
, JSON.Serialize(rlt));
if (!rlt.succ)
{
result = rlt;
}
else
{
result.succ = true;
result.msg = "推送成功";
}
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"服务项目状态推送失败,原因:{ex.Message}";
}
return result;
}
} }
} }

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