货物状态订阅,以及邮件推送

master
wanghaomei 1 year ago
parent 4dd0904dae
commit 72185032a4

@ -0,0 +1,49 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
/// 订舱货物状态
/// </summary>
[SugarTable("booking_goods_status_subscribe")]
[Description("订舱货物状态订阅")]
public class BookingGoodsStatusSubscribe : DBEntityTenant
{
/// <summary>
/// 订舱ID
/// </summary>
public long BookingId { get; set; }
/// <summary>
/// 状态代码
/// </summary>
public string StatusCode { get; set; }
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 发送邮件
/// </summary>
public bool SendMail { get; set; }
/// <summary>
/// 邮箱地址
/// </summary>
public string Email { get; set; }
/// <summary>
/// 推送微信
/// </summary>
public bool SendWeChat { get; set; }
/// <summary>
/// OpenId
/// </summary>
public string OpenId { get; set; }
}
}

@ -229,5 +229,71 @@ namespace Myshipping.Application.Event
throw Oops.Bah(jobjRtn.GetStringValue("message")); throw Oops.Bah(jobjRtn.GetStringValue("message"));
} }
} }
//推送货物状态通知
[EventSubscribe("GoodsStatusSubscribeNotify:Book")]
public async Task GoodsStatusSubscribeNotify(EventHandlerExecutingContext context)
{
_logger.LogInformation($"收到推送货物状态通知请求:{context.Source.Payload}");
dynamic payload = context.Source.Payload;
long bookId = payload.BookingId;
string statusCode = payload.StatusCode;
string statusName = payload.StatusName;
using var scope = _services.CreateScope();
var cache = scope.ServiceProvider.GetRequiredService<ISysCacheService>();
var repoOrder = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingOrder>>();
var repoBookingGoodsStatusSubscribe = scope.ServiceProvider.GetRequiredService<SqlSugarRepository<BookingGoodsStatusSubscribe>>();
var order = await repoOrder.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == bookId);
var subList = await repoBookingGoodsStatusSubscribe.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.BookingId == bookId).ToListAsync();
foreach (var sub in subList)
{
if (sub.SendMail && !string.IsNullOrEmpty(sub.Email) && sub.StatusCode.Split(',').Contains(statusCode))
{
var subject = $"大简云-货物通知:{order.MBLNO}---{order.VESSEL}/{order.VOYNO}{statusName}";
var body = $"尊敬的客户,您好:<br/><br/>您所订阅的提单号{order.MBLNO} ,船名航次{order.VESSEL}/{order.VOYNO}的业务{statusName}。<br/><br/>—— 此邮件为大简云平台自动发送,请勿回复。<br/><br/><img src='https://wechat.myshipping.net:8860/wechat_image/banner.png' style='width:300px;'/>";
var sendUrlCfg = cache.GetAllDictData().Result.FirstOrDefault(x => x.Code == "email_api_url");
if (sendUrlCfg == null)
{
_logger.LogError($"未配置邮件发送URL推送货物状态通知邮件未能发送。订舱ID{bookId},状态:{statusName}({statusCode}),邮箱:{sub.Email}");
}
var mailJson = new dynamic[]{
new
{
SendTo = sub.Email,
Title = subject,
Body = body,
SmtpConfig = "SERVICE"
}
};
var mailStr = mailJson.ToJsonString();
_logger.LogInformation($"准备推送货物状态邮件通知JSON{mailStr}订舱ID{bookId},状态:{statusName}({statusCode}),邮箱:{sub.Email}");
var rtn = await sendUrlCfg.Value
.SetBody(mailStr)
.PostAsStringAsync();
_logger.LogError($"推送货物状态通知邮件发送返回:{rtn}。订舱ID{bookId},状态:{statusName}({statusCode}),邮箱:{sub.Email}");
var jsonRtn = JObject.Parse(rtn);
if (jsonRtn.GetBooleanValue("Success"))
{
_logger.LogInformation($"推送货物状态通知邮件发送成功。订舱ID{bookId},状态:{statusName}({statusCode}),邮箱:{sub.Email}");
}
else
{
_logger.LogError($"推送货物状态通知邮件发送失败:{jsonRtn.GetStringValue("Message")}。订舱ID{bookId},状态:{statusName}({statusCode}),邮箱:{sub.Email}。");
}
}
}
}
} }
} }

@ -723,7 +723,7 @@ namespace Myshipping.Application
/// 接收反馈订舱审核回执 /// 接收反馈订舱审核回执
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost("/BookingCustomerOrder/RecBookingAuditFeedback"), AllowAnonymous, ApiUser(ApiCode = "BookingRecAuditFeedback")] [HttpPost("/BookingCustomerOrder/RecBookingAuditFeedback"), AllowAnonymous, ApiUser(ApiCode = "CustomerBookingSync")]
public async Task<long> RecBookingAuditFeedback(BookingCustomerRecAduitFeedbackDto dto) public async Task<long> RecBookingAuditFeedback(BookingCustomerRecAduitFeedbackDto dto)
{ {
var id = Convert.ToInt64(dto.Id); var id = Convert.ToInt64(dto.Id);
@ -788,15 +788,15 @@ namespace Myshipping.Application
} }
//附件 //附件
var files = await _repFile.Where(x => x.BookingId == model.Id).ToListAsync(); var files = await _repFile.AsQueryable().Filter(null, true).Where(x => x.BookingId == model.Id && x.IsDeleted == false).ToListAsync();
foreach(var file in files) foreach (var file in files)
{ {
file.Id = YitIdHelper.NextId(); file.Id = YitIdHelper.NextId();
file.BookingId = bkOrder.Id; file.BookingId = bkOrder.Id;
await _repFile.InsertAsync(file); await _repFile.InsertAsync(file);
} }
return bkOrder.Id; return bkOrder.Id;
} }

@ -130,6 +130,7 @@ 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<BookingAutoYardImport> _repAutoYard; private readonly SqlSugarRepository<BookingAutoYardImport> _repAutoYard;
private readonly SqlSugarRepository<BookingGoodsStatusSubscribe> _repBookingStatusSubscribe;
private readonly SqlSugarRepository<BookingExtendState> _repextendstate; private readonly SqlSugarRepository<BookingExtendState> _repextendstate;
@ -157,7 +158,7 @@ namespace Myshipping.Application
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<BookingAutoYardImport> repAutoYard, ISysOrgService orgService, SqlSugarRepository<BookingLineOpMgrConfig> repLineOpMgrConfig, SqlSugarRepository<SysEmp> repSysEmp, SqlSugarRepository<BookingAutoYardImport> repAutoYard,
IServiceWorkFlowManageService serviceWorkFlowManageService) IServiceWorkFlowManageService serviceWorkFlowManageService, SqlSugarRepository<BookingGoodsStatusSubscribe> repBookingStatusSubscribe)
{ {
this._logger = logger; this._logger = logger;
this._rep = rep; this._rep = rep;
@ -203,6 +204,7 @@ namespace Myshipping.Application
this._repAutoYard = repAutoYard; this._repAutoYard = repAutoYard;
this._repextendstate = repextendstate; this._repextendstate = repextendstate;
_serviceWorkFlowManageService = serviceWorkFlowManageService; _serviceWorkFlowManageService = serviceWorkFlowManageService;
this._repBookingStatusSubscribe = repBookingStatusSubscribe;
} }
#region 主表和箱信息 #region 主表和箱信息
@ -1896,156 +1898,80 @@ namespace Myshipping.Application
#region 货物状态
/// <summary> /// <summary>
/// 增加货物状态 /// 设置货物状态
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[SqlSugarUnitOfWork] [HttpPost("/BookingOrder/SetGoodsStatus")]
[HttpPost("/BookingOrder/SaveGoodsStatus")] public async Task<List<GoodsStatusDto>> SetGoodsStatus(GoodsStatusSetDto input)
public async Task<dynamic> SaveGoodsStatus(GoodsStatusDtoList input)
{ {
if (input.BookingId == null || input.BookingId == 0) var order = await _rep.FirstOrDefaultAsync(x => x.Id == input.BookingId);
if (order == null)
{ {
throw Oops.Bah("未传入业务id"); throw Oops.Bah("订舱数据未找到");
} }
await _goodsStatus.DeleteAsync(x => x.bookingId == input.BookingId); var gsCfg = await _goodsStatusConfig.FirstOrDefaultAsync(x => x.Id == input.GoodsStatusConfigId);
foreach (var item in input.item) if (gsCfg == null)
{ {
var entity = item.Adapt<BookingGoodsStatus>(); throw Oops.Bah("货物状态配置未找到");
entity.bookingId = input.BookingId;
if (item.FinishTime.HasValue) //2023年5月25日王书岚可以只填写申请箱使天数但是没有完成申请箱使
{
entity.FinishUser = UserManager.Name;
entity.FinishTime = item.FinishTime;
entity.FinishUserId = UserManager.UserId;
}
await _goodsStatus.InsertAsync(entity);
} }
//更新货物状态 if (input.IsCancel)
await SetBookingOrderGoodsStatus((long)input.BookingId);
_logger.LogInformation("货物状态直推东胜:");
//推送东胜
await SendBookingOrder(new long[] { Convert.ToInt64(input.BookingId) });
var order = _rep.Where(x => x.Id == input.BookingId).First();
var userid = order.CreatedUserId;
if (userid != null)
{ {
//获取当前用户已经录入的货物状态 await _goodsStatus.DeleteAsync(x => x.ConfigId == gsCfg.Id
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(), && x.bookingId == order.Id);
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUser,
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
//配置中所有的货物状态 CustomerBookingSyncHelper.SyncBookingGoodsStatus(new GoodsStatusSyncDto() { Id = input.BookingId.Value, Code = gsCfg.SystemCode, IsCancel = true });
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery }
else
{
var gs = await _goodsStatus.FirstOrDefaultAsync(x => x.bookingId == input.BookingId && x.ConfigId == input.GoodsStatusConfigId);
if (gs == null)
{ {
gs = new BookingGoodsStatus();
ConfigId = config.Id, gs.Id = YitIdHelper.NextId();
SystemCode = config.SystemCode, gs.bookingId = order.Id;
StatusName = config.StatusName, gs.ConfigId = gsCfg.Id;
FinishTime = null, gs.FinishUserId = UserManager.UserId;
FinishUser = null, gs.FinishUser = UserManager.Name;
FinishUserId = null, gs.FinishTime = input.FinishTime.HasValue ? input.FinishTime.Value : DateTime.Now;
IsPublic = false, gs.Remark = input.Remark;
ExtData = null, await _goodsStatus.InsertAsync(gs);
Remark = null, }
Sort = config.Sort else
}).ToList();
//去掉两个list中重复的货物状态
foreach (var item in list)
{ {
config.RemoveAll(x => x.ConfigId == item.ConfigId); gs.FinishUserId = UserManager.UserId;
gs.FinishUser = UserManager.Name;
gs.FinishTime = input.FinishTime.HasValue ? input.FinishTime.Value : DateTime.Now;
gs.Remark = input.Remark;
await _goodsStatus.UpdateAsync(gs);
} }
var t = list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
return t; CustomerBookingSyncHelper.SyncBookingGoodsStatus(new GoodsStatusSyncDto() { Id = input.BookingId.Value, Code = gsCfg.SystemCode, FinishTime = gs.FinishTime, IsCancel = false });
} }
return await GetGoodsStatus(order.Id);
return null;
} }
/// <summary> /// <summary>
/// 获取货物状态 /// 设置货物状态
/// </summary> /// </summary>
/// <param name="bookingId"></param> /// <param name="bookId">订舱id</param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/BookingOrder/GetGoodsStatusList")] [HttpPost("/BookingOrder/GetGoodsStatus")]
public async Task<List<GoodsStatusQuery>> GetGoodsStatusList(long bookingId) public async Task<List<GoodsStatusDto>> GetGoodsStatus(long bookId)
{ {
var userid = _rep.Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First(); var lst = await _goodsStatus.Where(x => x.bookingId == bookId).ToListAsync();
if (userid != null) return lst.Adapt<List<GoodsStatusDto>>();
{
//获取当前用户已经录入的货物状态
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == bookingId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUser,
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
//配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = null,
FinishUser = null,
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null,
Sort = config.Sort
}).ToList();
//去掉两个list中重复的货物状态
foreach (var item in list)
{
config.RemoveAll(x => x.ConfigId == item.ConfigId);
}
return list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
}
return null;
} }
#endregion
#endregion #endregion
#region 运踪 #region 运踪
@ -8384,104 +8310,104 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
[NonAction] [NonAction]
public async Task<dynamic> SendBookingOrder(long[] ids) public async Task<dynamic> SendBookingOrder(long[] ids)
{ {
_logger.LogInformation("开始同步订舱数据"); //_logger.LogInformation("开始同步订舱数据");
var itemcode = App.Configuration["ITEMCODE"].ToString(); //var itemcode = App.Configuration["ITEMCODE"].ToString();
var BookingOrderMQUri = App.Configuration["SendBookingOrderMQUri"]; //var BookingOrderMQUri = App.Configuration["SendBookingOrderMQUri"];
_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri + itemcode); //_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri + itemcode);
if (!string.IsNullOrEmpty(itemcode) && itemcode == "True") //if (!string.IsNullOrEmpty(itemcode) && itemcode == "True")
{ //{
if (ids.Count() == 0) // if (ids.Count() == 0)
{ // {
throw Oops.Bah("请上传正确数据"); // throw Oops.Bah("请上传正确数据");
} // }
var order = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id) && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); // var order = await _rep.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id) && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
foreach (var item in order) // foreach (var item in order)
{ // {
var dto = item.Adapt<SyncBookingOrderDto>(); // var dto = item.Adapt<SyncBookingOrderDto>();
//箱使 // //箱使
var CtnDayNumlist = await GetGoodsStatusList(item.Id); // var CtnDayNumlist = await GetGoodsStatusList(item.Id);
if (CtnDayNumlist != null) // if (CtnDayNumlist != null)
{ // {
dto.CtnDayNum = CtnDayNumlist.Where(x => x.StatusName == "申请箱使").Select(x => x.ExtData).FirstOrDefault(); // dto.CtnDayNum = CtnDayNumlist.Where(x => x.StatusName == "申请箱使").Select(x => x.ExtData).FirstOrDefault();
} // }
var ctn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id && x.IsDeleted == false).ToListAsync(); // var ctn = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == item.Id && x.IsDeleted == false).ToListAsync();
dto.ctnInputs = ctn.Adapt<List<BookingCtnDto>>(); // dto.ctnInputs = ctn.Adapt<List<BookingCtnDto>>();
foreach (var it in dto.ctnInputs) // foreach (var it in dto.ctnInputs)
{ // {
var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync(); // var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>(); // it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>();
} // }
//EDI // //EDI
var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync(); // var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync();
if (BookingEDIExt != null) // if (BookingEDIExt != null)
{ // {
dto.BookingEDIExt = BookingEDIExt.Adapt<BookingEDIExtDto>(); // dto.BookingEDIExt = BookingEDIExt.Adapt<BookingEDIExtDto>();
} // }
//货物状态 // //货物状态
dto.GoodsStatus = await _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.Id).InnerJoin<BookingGoodsStatusConfig>((t, d) => t.ConfigId == d.Id).Select((t, d) => new BookingGoodsStatusDto // dto.GoodsStatus = await _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.Id).InnerJoin<BookingGoodsStatusConfig>((t, d) => t.ConfigId == d.Id).Select((t, d) => new BookingGoodsStatusDto
{ // {
StatusName = d.StatusName, // StatusName = d.StatusName,
FinishTime = t.FinishTime, // FinishTime = t.FinishTime,
Remark = t.Remark, // Remark = t.Remark,
ExtData = t.ExtData // ExtData = t.ExtData
}).Distinct().ToListAsync(); // }).Distinct().ToListAsync();
var childrens = await _rep.AsQueryable().Filter(null, true).Where(x => x.ParentId == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync(); // var childrens = await _rep.AsQueryable().Filter(null, true).Where(x => x.ParentId == item.Id && x.TenantId == UserManager.TENANT_ID && x.IsDeleted == false).ToListAsync();
dto.childrens = childrens.Adapt<List<Children>>(); // dto.childrens = childrens.Adapt<List<Children>>();
foreach (var childitem in dto.childrens) // foreach (var childitem in dto.childrens)
{ // {
var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync(); // var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync();
childitem.ctnInputs = ctnInputs.Adapt<List<BookingCtnDto>>(); // childitem.ctnInputs = ctnInputs.Adapt<List<BookingCtnDto>>();
foreach (var it in childitem.ctnInputs) // foreach (var it in childitem.ctnInputs)
{ // {
var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync(); // var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>(); // it.ctnDetailInputs = ctnDetailInputs.Adapt<List<BookingCtnDetailDto>>();
} // }
var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync(); // var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync();
if (childBookingEDIExt != null) // if (childBookingEDIExt != null)
{ // {
childitem.BookingEDIExt = childBookingEDIExt.Adapt<BookingEDIExtDto>(); // childitem.BookingEDIExt = childBookingEDIExt.Adapt<BookingEDIExtDto>();
} // }
} // }
var json = dto.ToJsonString(); // var json = dto.ToJsonString();
json = $"[{json}]"; // json = $"[{json}]";
_logger.LogInformation("订舱数据回推:" + json); // _logger.LogInformation("订舱数据回推:" + json);
try // try
{ // {
const string MqActionExchangeName = "djy.output.dingcang.ds6"; // const string MqActionExchangeName = "djy.output.dingcang.ds6";
const string MqActionQueueName = "djy.output.dingcang.ds6"; // const string MqActionQueueName = "djy.output.dingcang.ds6";
ConnectionFactory factory = new ConnectionFactory(); // ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri(BookingOrderMQUri); // factory.Uri = new Uri(BookingOrderMQUri);
using (IConnection conn = factory.CreateConnection()) // using (IConnection conn = factory.CreateConnection())
{ // {
IModel mqModel = conn.CreateModel(); // IModel mqModel = conn.CreateModel();
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct); // mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}"; // var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
mqModel.QueueDeclare(queueName, false, false, false, null); // mqModel.QueueDeclare(queueName, false, false, false, null);
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null); // mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json)); // byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json));
IBasicProperties props = mqModel.CreateBasicProperties(); // IBasicProperties props = mqModel.CreateBasicProperties();
props.DeliveryMode = 2; // props.DeliveryMode = 2;
mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); // mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
conn.Close(); // conn.Close();
_logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,数据内容:【{json}】"); // _logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,数据内容:【{json}】");
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
_logger.LogError(ex.Message); // _logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace); // _logger.LogError(ex.StackTrace);
} // }
await SendLetterYard(item.Id); // await SendLetterYard(item.Id);
} // }
return order; // return order;
} //}
return null; return null;
} }
@ -9407,5 +9333,31 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
#endregion #endregion
#region 订阅货物状态
/// <summary>
/// 订阅货物状态(不同用户都可订阅同一票货)
/// </summary>
/// <returns></returns>
[HttpPost("/BookingOrder/GoodsStatusSubscribe")]
public async Task GoodsStatusSubscribe(BookingStatusSubscribeDto dto)
{
await _repBookingStatusSubscribe.DeleteAsync(x => x.BookingId == dto.BookingId && x.CreatedUserId == UserManager.UserId);
var model = dto.Adapt<BookingGoodsStatusSubscribe>();
model.Id = YitIdHelper.NextId();
await _repBookingStatusSubscribe.InsertAsync(model);
}
/// <summary>
/// 获取订阅货物状态
/// </summary>
/// <returns></returns>
[HttpPost("/BookingOrder/GetGoodsStatusSubscribe")]
public async Task<BookingStatusSubscribeDto> GetGoodsStatusSubscribe(long bookId)
{
var model = await _repBookingStatusSubscribe.FirstOrDefaultAsync(x => x.BookingId == bookId && x.CreatedUserId == UserManager.UserId);
return model.Adapt<BookingStatusSubscribeDto>();
}
#endregion
} }
} }

@ -90,7 +90,45 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
} }
/// <summary>
/// 订舱货物状态订阅dto
/// </summary>
public class BookingStatusSubscribeDto
{
/// <summary>
/// 订舱ID
/// </summary>
public long BookingId { get; set; }
/// <summary>
/// 状态代码(多个状态拼接为一个字符串,中间用,隔开)
/// </summary>
public string StatusCode { get; set; }
/// <summary>
/// 状态名称(多个状态拼接为一个字符串,中间用,隔开)
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 发送邮件
/// </summary>
public bool SendMail { get; set; }
/// <summary>
/// 邮箱地址
/// </summary>
public string Email { get; set; }
/// <summary>
/// 推送微信
/// </summary>
public bool SendWeChat { get; set; }
/// <summary>
/// OpenId
/// </summary>
public string OpenId { get; set; }
}
} }

@ -143,4 +143,36 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
/// </summary> /// </summary>
public bool IsLast { get; set; } = false; public bool IsLast { get; set; } = false;
} }
/// <summary>
/// 设置、取消货物状态dto
/// </summary>
public class GoodsStatusSetDto
{
/// <summary>
/// 订舱ID
/// </summary>
public long? BookingId { get; set; }
/// <summary>
/// 货物状态配置ID
/// </summary>
public long? GoodsStatusConfigId { get; set; }
/// <summary>
/// 是否为取消状态
/// </summary>
public bool IsCancel { get; set; } = false;
/// <summary>
/// 完成时间
/// </summary>
public DateTime? FinishTime { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
} }

@ -37,6 +37,7 @@ using Myshipping.Application.Enum;
using Myshipping.Core.Helper; using Myshipping.Core.Helper;
using Furion.TaskScheduler; using Furion.TaskScheduler;
using System.Linq.Expressions; using System.Linq.Expressions;
using Furion.EventBus;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -76,6 +77,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus; private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
private readonly IBookingOrderService _bookingorderservice; private readonly IBookingOrderService _bookingorderservice;
private readonly SqlSugarRepository<BookingExtendState> _bookingextstate; private readonly SqlSugarRepository<BookingExtendState> _bookingextstate;
private readonly IEventPublisher _publisher;
public DataSyncService(ILogger<DataSyncService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, public DataSyncService(ILogger<DataSyncService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
@ -86,7 +88,7 @@ namespace Myshipping.Application
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline,
SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier, SqlSugarRepository<CodeForwarder> codeForwarder, SqlSugarRepository<BookingExtendState> bookingextstate, SqlSugarRepository<BookingRemark> bookingremark, SqlSugarRepository<MappingCarrier> mapcarrier, SqlSugarRepository<CodeForwarder> codeForwarder, SqlSugarRepository<BookingExtendState> bookingextstate,
SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep, ICommonDBService commonDBService, SqlSugarRepository<RelaPortCarrierLane> relaPortLane, SqlSugarRepository<CodePort> codePortRep, SqlSugarRepository<CodeLane> codeLaneRep, ICommonDBService commonDBService, SqlSugarRepository<RelaPortCarrierLane> relaPortLane,
SqlSugarRepository<DjyWebsiteAccountConfig> accountconfig, SqlSugarRepository<BookingFile> bookingfile, IBookingOrderService bookingorderservice) SqlSugarRepository<DjyWebsiteAccountConfig> accountconfig, SqlSugarRepository<BookingFile> bookingfile, IBookingOrderService bookingorderservice, IEventPublisher publisher)
{ {
this._logger = logger; this._logger = logger;
this._rep = rep; this._rep = rep;
@ -118,6 +120,7 @@ namespace Myshipping.Application
this._statuslogdetail = statuslogdetail; this._statuslogdetail = statuslogdetail;
this._repBookingStatus = repBookingStatus; this._repBookingStatus = repBookingStatus;
this._bookingextstate = bookingextstate; this._bookingextstate = bookingextstate;
this._publisher = publisher;
} }
@ -2581,6 +2584,8 @@ namespace Myshipping.Application
await _goodsStatus.UpdateAsync(gs); await _goodsStatus.UpdateAsync(gs);
} }
await _publisher.PublishAsync(new ChannelEventSource("GoodsStatusSubscribeNotify:Book", new { BookingId = dbOrder.Id, StatusCode = gsCfg.SystemCode, StatusName = gsCfg.StatusName }));
} }
} }

Loading…
Cancel
Save