diff --git a/Myshipping.Application/Entity/BookingGoodsStatusSubscribe.cs b/Myshipping.Application/Entity/BookingGoodsStatusSubscribe.cs
new file mode 100644
index 0000000..8826fb6
--- /dev/null
+++ b/Myshipping.Application/Entity/BookingGoodsStatusSubscribe.cs
@@ -0,0 +1,49 @@
+using System;
+using SqlSugar;
+using System.ComponentModel;
+using Myshipping.Core.Entity;
+namespace Myshipping.Application.Entity
+{
+ ///
+ /// 订舱货物状态
+ ///
+ [SugarTable("booking_goods_status_subscribe")]
+ [Description("订舱货物状态订阅")]
+ public class BookingGoodsStatusSubscribe : DBEntityTenant
+ {
+ ///
+ /// 订舱ID
+ ///
+ public long BookingId { get; set; }
+
+ ///
+ /// 状态代码
+ ///
+ public string StatusCode { get; set; }
+
+ ///
+ /// 状态名称
+ ///
+ public string StatusName { get; set; }
+
+ ///
+ /// 发送邮件
+ ///
+ public bool SendMail { get; set; }
+
+ ///
+ /// 邮箱地址
+ ///
+ public string Email { get; set; }
+
+ ///
+ /// 推送微信
+ ///
+ public bool SendWeChat { get; set; }
+
+ ///
+ /// OpenId
+ ///
+ public string OpenId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Myshipping.Application/Event/BookingSyncSubscriber.cs b/Myshipping.Application/Event/BookingSyncSubscriber.cs
index f1cedab..9511e60 100644
--- a/Myshipping.Application/Event/BookingSyncSubscriber.cs
+++ b/Myshipping.Application/Event/BookingSyncSubscriber.cs
@@ -229,5 +229,71 @@ namespace Myshipping.Application.Event
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();
+ var repoOrder = scope.ServiceProvider.GetRequiredService>();
+ var repoBookingGoodsStatusSubscribe = scope.ServiceProvider.GetRequiredService>();
+
+ 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 = $"尊敬的客户,您好:
您所订阅的提单号{order.MBLNO} ,船名航次{order.VESSEL}/{order.VOYNO}的业务{statusName}。
—— 此邮件为大简云平台自动发送,请勿回复。
";
+
+ 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}。");
+ }
+
+ }
+
+ }
+ }
}
}
diff --git a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
index cb3f298..aa47db5 100644
--- a/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
+++ b/Myshipping.Application/Service/BookingCustomerOrder/BookingCustomerOrderService.cs
@@ -723,7 +723,7 @@ namespace Myshipping.Application
/// 接收反馈订舱审核回执
///
///
- [HttpPost("/BookingCustomerOrder/RecBookingAuditFeedback"), AllowAnonymous, ApiUser(ApiCode = "BookingRecAuditFeedback")]
+ [HttpPost("/BookingCustomerOrder/RecBookingAuditFeedback"), AllowAnonymous, ApiUser(ApiCode = "CustomerBookingSync")]
public async Task RecBookingAuditFeedback(BookingCustomerRecAduitFeedbackDto dto)
{
var id = Convert.ToInt64(dto.Id);
@@ -788,15 +788,15 @@ namespace Myshipping.Application
}
//附件
- var files = await _repFile.Where(x => x.BookingId == model.Id).ToListAsync();
- foreach(var file in files)
+ var files = await _repFile.AsQueryable().Filter(null, true).Where(x => x.BookingId == model.Id && x.IsDeleted == false).ToListAsync();
+ foreach (var file in files)
{
file.Id = YitIdHelper.NextId();
file.BookingId = bkOrder.Id;
await _repFile.InsertAsync(file);
}
-
+
return bkOrder.Id;
}
diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
index 30a0c1c..53124cf 100644
--- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
+++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs
@@ -130,6 +130,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository _repLineOpMgrConfig;
private readonly SqlSugarRepository _repSysEmp;
private readonly SqlSugarRepository _repAutoYard;
+ private readonly SqlSugarRepository _repBookingStatusSubscribe;
private readonly SqlSugarRepository _repextendstate;
@@ -157,7 +158,7 @@ namespace Myshipping.Application
SqlSugarRepository repTenant, SqlSugarRepository repBookingStatus, SqlSugarRepository bookingEDIExt, SqlSugarRepository serviceItem,
SqlSugarRepository paraContractNoInfoRepository, IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig, SqlSugarRepository djyWebsiteAccountConfigRepository,
ISysOrgService orgService, SqlSugarRepository repLineOpMgrConfig, SqlSugarRepository repSysEmp, SqlSugarRepository repAutoYard,
- IServiceWorkFlowManageService serviceWorkFlowManageService)
+ IServiceWorkFlowManageService serviceWorkFlowManageService, SqlSugarRepository repBookingStatusSubscribe)
{
this._logger = logger;
this._rep = rep;
@@ -203,6 +204,7 @@ namespace Myshipping.Application
this._repAutoYard = repAutoYard;
this._repextendstate = repextendstate;
_serviceWorkFlowManageService = serviceWorkFlowManageService;
+ this._repBookingStatusSubscribe = repBookingStatusSubscribe;
}
#region 主表和箱信息
@@ -1896,156 +1898,80 @@ namespace Myshipping.Application
-
-
+ #region 货物状态
///
- /// 增加货物状态
+ /// 设置货物状态
///
///
///
- [SqlSugarUnitOfWork]
- [HttpPost("/BookingOrder/SaveGoodsStatus")]
- public async Task SaveGoodsStatus(GoodsStatusDtoList input)
+ [HttpPost("/BookingOrder/SetGoodsStatus")]
+ public async Task> SetGoodsStatus(GoodsStatusSetDto 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);
- foreach (var item in input.item)
+ var gsCfg = await _goodsStatusConfig.FirstOrDefaultAsync(x => x.Id == input.GoodsStatusConfigId);
+ if (gsCfg == null)
{
- var entity = item.Adapt();
- 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);
+ throw Oops.Bah("货物状态配置未找到");
}
- //更新货物状态
- 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)
+ if (input.IsCancel)
{
- //获取当前用户已经录入的货物状态
- var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
- (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();
+ await _goodsStatus.DeleteAsync(x => x.ConfigId == gsCfg.Id
+ && x.bookingId == order.Id);
- //配置中所有的货物状态
- var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
+ CustomerBookingSyncHelper.SyncBookingGoodsStatus(new GoodsStatusSyncDto() { Id = input.BookingId.Value, Code = gsCfg.SystemCode, IsCancel = true });
+ }
+ else
+ {
+ var gs = await _goodsStatus.FirstOrDefaultAsync(x => x.bookingId == input.BookingId && x.ConfigId == input.GoodsStatusConfigId);
+ if (gs == null)
{
-
- 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)
+ gs = new BookingGoodsStatus();
+ gs.Id = YitIdHelper.NextId();
+ gs.bookingId = order.Id;
+ gs.ConfigId = gsCfg.Id;
+ gs.FinishUserId = UserManager.UserId;
+ gs.FinishUser = UserManager.Name;
+ gs.FinishTime = input.FinishTime.HasValue ? input.FinishTime.Value : DateTime.Now;
+ gs.Remark = input.Remark;
+ await _goodsStatus.InsertAsync(gs);
+ }
+ else
{
- 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(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 null;
+ return await GetGoodsStatus(order.Id);
}
-
-
///
- /// 获取货物状态
+ /// 设置货物状态
///
- ///
+ /// 订舱id
///
- [HttpGet("/BookingOrder/GetGoodsStatusList")]
- public async Task> GetGoodsStatusList(long bookingId)
+ [HttpPost("/BookingOrder/GetGoodsStatus")]
+ public async Task> GetGoodsStatus(long bookId)
{
- var userid = _rep.Where(x => x.Id == bookingId).Select(x => x.CreatedUserId).First();
- if (userid != null)
- {
- //获取当前用户已经录入的货物状态
- 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(config).OrderBy(x => x.Sort).DistinctBy(x => x.StatusName).ToList();
-
- }
- return null;
-
-
+ var lst = await _goodsStatus.Where(x => x.bookingId == bookId).ToListAsync();
+ return lst.Adapt>();
}
+ #endregion
+
#endregion
#region 运踪
@@ -8384,104 +8310,104 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
[NonAction]
public async Task SendBookingOrder(long[] ids)
{
- _logger.LogInformation("开始同步订舱数据");
- var itemcode = App.Configuration["ITEMCODE"].ToString();
- var BookingOrderMQUri = App.Configuration["SendBookingOrderMQUri"];
- _logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri + itemcode);
- if (!string.IsNullOrEmpty(itemcode) && itemcode == "True")
- {
- if (ids.Count() == 0)
- {
- 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();
- foreach (var item in order)
- {
- var dto = item.Adapt();
- //箱使
- var CtnDayNumlist = await GetGoodsStatusList(item.Id);
- if (CtnDayNumlist != null)
- {
- 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();
- dto.ctnInputs = ctn.Adapt>();
- foreach (var it in dto.ctnInputs)
- {
- var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
- it.ctnDetailInputs = ctnDetailInputs.Adapt>();
- }
- //EDI
- var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync();
- if (BookingEDIExt != null)
- {
- dto.BookingEDIExt = BookingEDIExt.Adapt();
- }
- //货物状态
- dto.GoodsStatus = await _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.Id).InnerJoin((t, d) => t.ConfigId == d.Id).Select((t, d) => new BookingGoodsStatusDto
- {
- StatusName = d.StatusName,
- FinishTime = t.FinishTime,
- Remark = t.Remark,
- ExtData = t.ExtData
- }).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();
- dto.childrens = childrens.Adapt>();
-
- foreach (var childitem in dto.childrens)
- {
- var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync();
- childitem.ctnInputs = ctnInputs.Adapt>();
-
- foreach (var it in childitem.ctnInputs)
- {
- var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
- it.ctnDetailInputs = ctnDetailInputs.Adapt>();
- }
- var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync();
- if (childBookingEDIExt != null)
- {
- childitem.BookingEDIExt = childBookingEDIExt.Adapt();
- }
- }
-
- var json = dto.ToJsonString();
- json = $"[{json}]";
- _logger.LogInformation("订舱数据回推:" + json);
- try
- {
- const string MqActionExchangeName = "djy.output.dingcang.ds6";
- const string MqActionQueueName = "djy.output.dingcang.ds6";
- ConnectionFactory factory = new ConnectionFactory();
- factory.Uri = new Uri(BookingOrderMQUri);
-
- using (IConnection conn = factory.CreateConnection())
- {
- IModel mqModel = conn.CreateModel();
- mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
- var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
- mqModel.QueueDeclare(queueName, false, false, false, null);
- mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
- byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json));
- IBasicProperties props = mqModel.CreateBasicProperties();
- props.DeliveryMode = 2;
- mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
- conn.Close();
- _logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,数据内容:【{json}】");
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex.Message);
- _logger.LogError(ex.StackTrace);
-
- }
- await SendLetterYard(item.Id);
- }
- return order;
- }
+ //_logger.LogInformation("开始同步订舱数据");
+ //var itemcode = App.Configuration["ITEMCODE"].ToString();
+ //var BookingOrderMQUri = App.Configuration["SendBookingOrderMQUri"];
+ //_logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri + itemcode);
+ //if (!string.IsNullOrEmpty(itemcode) && itemcode == "True")
+ //{
+ // if (ids.Count() == 0)
+ // {
+ // 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();
+ // foreach (var item in order)
+ // {
+ // var dto = item.Adapt();
+ // //箱使
+ // var CtnDayNumlist = await GetGoodsStatusList(item.Id);
+ // if (CtnDayNumlist != null)
+ // {
+ // 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();
+ // dto.ctnInputs = ctn.Adapt>();
+ // foreach (var it in dto.ctnInputs)
+ // {
+ // var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
+ // it.ctnDetailInputs = ctnDetailInputs.Adapt>();
+ // }
+ // //EDI
+ // var BookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id && x.IsDeleted == false).FirstAsync();
+ // if (BookingEDIExt != null)
+ // {
+ // dto.BookingEDIExt = BookingEDIExt.Adapt();
+ // }
+ // //货物状态
+ // dto.GoodsStatus = await _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.Id).InnerJoin((t, d) => t.ConfigId == d.Id).Select((t, d) => new BookingGoodsStatusDto
+ // {
+ // StatusName = d.StatusName,
+ // FinishTime = t.FinishTime,
+ // Remark = t.Remark,
+ // ExtData = t.ExtData
+ // }).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();
+ // dto.childrens = childrens.Adapt>();
+
+ // foreach (var childitem in dto.childrens)
+ // {
+ // var ctnInputs = await _repCtn.AsQueryable().Filter(null, true).Where(x => x.BILLID == childitem.Id && x.IsDeleted == false).ToListAsync();
+ // childitem.ctnInputs = ctnInputs.Adapt>();
+
+ // foreach (var it in childitem.ctnInputs)
+ // {
+ // var ctnDetailInputs = await _ctndetailrep.AsQueryable().Filter(null, true).Where(x => x.CTNID == it.Id && x.IsDeleted == false).ToListAsync();
+ // it.ctnDetailInputs = ctnDetailInputs.Adapt>();
+ // }
+ // var childBookingEDIExt = await _bookingEDIExt.AsQueryable().Filter(null, true).Where(x => x.BookingId == childitem.Id && x.IsDeleted == false).FirstAsync();
+ // if (childBookingEDIExt != null)
+ // {
+ // childitem.BookingEDIExt = childBookingEDIExt.Adapt();
+ // }
+ // }
+
+ // var json = dto.ToJsonString();
+ // json = $"[{json}]";
+ // _logger.LogInformation("订舱数据回推:" + json);
+ // try
+ // {
+ // const string MqActionExchangeName = "djy.output.dingcang.ds6";
+ // const string MqActionQueueName = "djy.output.dingcang.ds6";
+ // ConnectionFactory factory = new ConnectionFactory();
+ // factory.Uri = new Uri(BookingOrderMQUri);
+
+ // using (IConnection conn = factory.CreateConnection())
+ // {
+ // IModel mqModel = conn.CreateModel();
+ // mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
+ // var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
+ // mqModel.QueueDeclare(queueName, false, false, false, null);
+ // mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
+ // byte[] messageBodyBytes = Encoding.UTF8.GetBytes(SharpZipLib.Compress(json));
+ // IBasicProperties props = mqModel.CreateBasicProperties();
+ // props.DeliveryMode = 2;
+ // mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
+ // conn.Close();
+ // _logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,数据内容:【{json}】");
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // _logger.LogError(ex.Message);
+ // _logger.LogError(ex.StackTrace);
+
+ // }
+ // await SendLetterYard(item.Id);
+ // }
+ // return order;
+ //}
return null;
}
@@ -9407,5 +9333,31 @@ HLCUTA12307DPXJ3 以这票为例 6个柜
#endregion
+
+ #region 订阅货物状态
+ ///
+ /// 订阅货物状态(不同用户都可订阅同一票货)
+ ///
+ ///
+ [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();
+ model.Id = YitIdHelper.NextId();
+ await _repBookingStatusSubscribe.InsertAsync(model);
+ }
+
+ ///
+ /// 获取订阅货物状态
+ ///
+ ///
+ [HttpPost("/BookingOrder/GetGoodsStatusSubscribe")]
+ public async Task GetGoodsStatusSubscribe(long bookId)
+ {
+ var model = await _repBookingStatusSubscribe.FirstOrDefaultAsync(x => x.BookingId == bookId && x.CreatedUserId == UserManager.UserId);
+ return model.Adapt();
+ }
+ #endregion
}
}
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
index f58c063..91917d1 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/BookingStatusLogDto.cs
@@ -90,7 +90,45 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
}
+ ///
+ /// 订舱货物状态订阅dto
+ ///
+ public class BookingStatusSubscribeDto
+ {
+ ///
+ /// 订舱ID
+ ///
+ public long BookingId { get; set; }
+ ///
+ /// 状态代码(多个状态拼接为一个字符串,中间用,隔开)
+ ///
+ public string StatusCode { get; set; }
+ ///
+ /// 状态名称(多个状态拼接为一个字符串,中间用,隔开)
+ ///
+ public string StatusName { get; set; }
+
+ ///
+ /// 发送邮件
+ ///
+ public bool SendMail { get; set; }
+
+ ///
+ /// 邮箱地址
+ ///
+ public string Email { get; set; }
+
+ ///
+ /// 推送微信
+ ///
+ public bool SendWeChat { get; set; }
+
+ ///
+ /// OpenId
+ ///
+ public string OpenId { get; set; }
+ }
}
diff --git a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs
index b2ae30e..3c6b333 100644
--- a/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs
+++ b/Myshipping.Application/Service/BookingOrder/Dto/GoodsStatus.cs
@@ -143,4 +143,36 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
///
public bool IsLast { get; set; } = false;
}
+
+ ///
+ /// 设置、取消货物状态dto
+ ///
+ public class GoodsStatusSetDto
+ {
+ ///
+ /// 订舱ID
+ ///
+ public long? BookingId { get; set; }
+
+ ///
+ /// 货物状态配置ID
+ ///
+ public long? GoodsStatusConfigId { get; set; }
+
+ ///
+ /// 是否为取消状态
+ ///
+ public bool IsCancel { get; set; } = false;
+
+ ///
+ /// 完成时间
+ ///
+ public DateTime? FinishTime { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string Remark { get; set; }
+
+ }
}
diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs
index 55f5f9b..401d54c 100644
--- a/Myshipping.Application/Service/DataSync/DataSyncService.cs
+++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs
@@ -37,6 +37,7 @@ using Myshipping.Application.Enum;
using Myshipping.Core.Helper;
using Furion.TaskScheduler;
using System.Linq.Expressions;
+using Furion.EventBus;
namespace Myshipping.Application
{
@@ -76,6 +77,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository _repBookingStatus;
private readonly IBookingOrderService _bookingorderservice;
private readonly SqlSugarRepository _bookingextstate;
+ private readonly IEventPublisher _publisher;
public DataSyncService(ILogger logger, ISysCacheService cache, SqlSugarRepository rep, SqlSugarRepository repCtn,
@@ -86,7 +88,7 @@ namespace Myshipping.Application
SqlSugarRepository goodsStatus, SqlSugarRepository goodsStatusConfig, SqlSugarRepository repline,
SqlSugarRepository bookingremark, SqlSugarRepository mapcarrier, SqlSugarRepository codeForwarder, SqlSugarRepository bookingextstate,
SqlSugarRepository codePortRep, SqlSugarRepository codeLaneRep, ICommonDBService commonDBService, SqlSugarRepository relaPortLane,
- SqlSugarRepository accountconfig, SqlSugarRepository bookingfile, IBookingOrderService bookingorderservice)
+ SqlSugarRepository accountconfig, SqlSugarRepository bookingfile, IBookingOrderService bookingorderservice, IEventPublisher publisher)
{
this._logger = logger;
this._rep = rep;
@@ -118,6 +120,7 @@ namespace Myshipping.Application
this._statuslogdetail = statuslogdetail;
this._repBookingStatus = repBookingStatus;
this._bookingextstate = bookingextstate;
+ this._publisher = publisher;
}
@@ -2581,6 +2584,8 @@ namespace Myshipping.Application
await _goodsStatus.UpdateAsync(gs);
}
+
+ await _publisher.PublishAsync(new ChannelEventSource("GoodsStatusSubscribeNotify:Book", new { BookingId = dbOrder.Id, StatusCode = gsCfg.SystemCode, StatusName = gsCfg.StatusName }));
}
}