diff --git a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs index 7a865400..b7b7e5f6 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingOrderService.cs @@ -745,6 +745,8 @@ namespace Myshipping.Application entity.VERSION = Guid.NewGuid().ToString(); entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString(); + entity.BSDATE = DateTime.Today; + entity.BSNO = null; await _rep.InsertAsync(entity); if (input.ctnInputs != null) { @@ -813,6 +815,8 @@ namespace Myshipping.Application await _rep.AsUpdateable(entity).IgnoreColumns(it => new { it.ParentId, + it.BSDATE, + it.BSNO, it.TenantId, it.CreatedTime, it.CreatedUserId, @@ -1037,6 +1041,9 @@ namespace Myshipping.Application //记录修改日志 await SaveLog(order, orderCompare); + + //推送东胜 + await SendBookingOrder(new long[] { order.Id }); } /// @@ -1407,9 +1414,6 @@ namespace Myshipping.Application } } - - - /// /// 删除备注 /// @@ -1423,10 +1427,6 @@ namespace Myshipping.Application await _bookingremark.DeleteAsync(x => x.Id == Id); } - - - - /// /// 增加订舱附件 /// @@ -1884,230 +1884,7 @@ namespace Myshipping.Application } - /// - /// 插入货运动态 - /// - [AllowAnonymous] - [SqlSugarUnitOfWork] - [HttpPost("/BookingOrder/AddBookingStatusLog")] - public async Task AddBookingStatusLog(List all) - { - try - { - var old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == all[0].BookingId && x.Category == "yunzong" && x.IsDeleted == false).ToListAsync(); - await _repStatuslog.DeleteAsync(x => x.BookingId == all[0].BookingId && x.Category == "yunzong"); - foreach (var ot in old) - { - await _statuslogdetail.DeleteAsync(x => x.PId == ot.Id); - } - var dicdatalist = _cache.GetAllDictData().Result; - foreach (var item in all) - { - #region 日志 - //新增数据 - var bookingStatusLog = new BookingStatusLog(); - bookingStatusLog.BookingId = item.BookingId; - bookingStatusLog.Category = "yunzong"; - bookingStatusLog.CreatedTime = DateTime.Now; - bookingStatusLog.Status = item.Status; - bookingStatusLog.OpTime = item.OpTime; - bookingStatusLog.MBLNO = item.MBLNO; - await _repStatuslog.InsertAsync(bookingStatusLog); - var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == item.BookingId).Select((d, t) => new - { - BookingId = d.BookingId, - StaCode = d.StaCode, - StaName = d.StaName, - StaTime = d.StaTime, - Code = t.Code, - Value = t.Value - }).ToListAsync(); - - if (item.detail != null && item.detail.Count > 0) - { - foreach (var dt in item.detail) - { - var BookingStatusLogDetail = new BookingStatusLogDetail(); - BookingStatusLogDetail.PId = bookingStatusLog.Id; - BookingStatusLogDetail.Status = dt.Status; - BookingStatusLogDetail.CNTRNO = dt.CNTRNO; - BookingStatusLogDetail.OPTime = dt.OPTime; - await _statuslogdetail.InsertAsync(BookingStatusLogDetail); - } - } - #endregion - - #region 订舱状态 - if (item.Status == "舱单") - { - if (list.Where(x => x.Code == "sta_cangdan").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_cangdan"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_cangdan").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.OpTime; - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - } - } - if (item.Status == "海关放行") - { - if (list.Where(x => x.Code == "sta_haifang").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_haifang"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_haifang").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.OpTime; - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - await SetGoodsStatus("BG", item.BookingId); - await SendBookingOrder(new long[] { item.BookingId }); - } - } - if (item.Status == "装载") - { - if (list.Where(x => x.Code == "sta_zhuangzai").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_zhuangzai"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangzai").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.OpTime; - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - await SetGoodsStatus("ZZFX", item.BookingId); - await SendBookingOrder(new long[] { item.BookingId }); - } - } - if (item.Status == "码放") - { - if (list.Where(x => x.Code == "sta_mafang").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_mafang"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_mafang").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.OpTime; - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - await SetGoodsStatus("MTFX", item.BookingId); - await SendBookingOrder(new long[] { item.BookingId }); - } - } - if (item.Status == "装船") - { - if (list.Where(x => x.Code == "sta_zhuangchuan").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_zhuangchuan"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangchuan").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.detail.Max(x => x.OPTime); - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - } - } - if (item.Status == "ATD") - { - if (list.Where(x => x.Code == "sta_atd").FirstOrDefault() == null) - { - BookingStatus bookingStatus = new BookingStatus(); - bookingStatus.BookingId = item.BookingId; - bookingStatus.StaCode = "sta_atd"; - bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_atd").Select(x => x.Value).FirstOrDefault(); - bookingStatus.StaTime = item.OpTime; - bookingStatus.StaCate = "book_sta_cate_billtrace"; - await _repBookingStatus.InsertAsync(bookingStatus); - } - } - #region 入港时间 - if (item.Status == "入港") - { - await SetGoodsStatus("YRG", item.BookingId); - } - #endregion - #endregion - - #region ATD - if (item.Status == "ATD") - { - var o = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.BookingId && x.IsDeleted == false).First(); - var oldatd = o == null ? null : o.ATD; - if (oldatd != item.OpTime && item.OpTime != null) - { - o.ATD = item.OpTime; - await _rep.UpdateAsync(o); - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = item.BookingId, - TenantId = o.TenantId, - CreatedTime = DateTime.Now, - CreatedUserId = o.CreatedUserId, - CreatedUserName = "系统管理员" - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "实际开船", - OldValue = oldatd == null ? "" : oldatd.ToString(), - NewValue = item.OpTime == null ? "" : item.OpTime.ToString(), - }); - await SendBookingOrder(new long[] { o.Id }); - } - if (!string.IsNullOrEmpty(o.VESSEL) && !string.IsNullOrEmpty(o.VOYNO)) - { - var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == o.VOYNO && x.VESSEL == o.VESSEL && x.TenantId == o.TenantId && x.IsDeleted == false && x.Id != item.BookingId).ToListAsync(); - foreach (var it in order) - { - var _oldatd = it.ATD; - if (_oldatd != item.OpTime) - { - it.ATD = item.OpTime; - await _rep.UpdateAsync(it); - ////添加booking日志 - var _bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = it.TenantId, - CreatedTime = DateTime.Now, - CreatedUserId = o.CreatedUserId, - CreatedUserName = "系统管理员" - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = _bid, - Field = "实际开船", - OldValue = _oldatd == null ? "" : _oldatd.ToString(), - NewValue = item.OpTime == null ? "" : item.OpTime.ToString(), - }); - await SendBookingOrder(new long[] { o.Id }); - } - - - } - - - - } - } - #endregion - } - } - catch (Exception ex) - { - - _logger.LogError(ex.Message); - _logger.LogError(ex.StackTrace); - - } - - - } + #endregion #region 放舱(入货通知) @@ -7976,7 +7753,9 @@ namespace Myshipping.Application [NonAction] public async Task SendBookingOrder(long[] ids) { - var itemcode = _cache.GetAllTenantParam().Result.Where(x => x.ParaCode == "BOOKING_DATA_PUSH" && x.TenantId == UserManager.TENANT_ID).Select(x => x.ItemCode).FirstOrDefault(); + var itemcode = App.Configuration["ITEMCODE"]; + var BookingOrderMQUri= App.Configuration["BookingOrderMQUri"]; + _logger.LogInformation("订舱数据回推地址:" + BookingOrderMQUri); if (!string.IsNullOrEmpty(itemcode) && itemcode == "true") { if (ids.Count() == 0) @@ -8058,13 +7837,12 @@ namespace Myshipping.Application } var json = dto.ToJsonString(); _logger.LogInformation("订舱数据回推:" + json); - _logger.LogInformation("订舱数据回推地址:" + _cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()); try { const string MqActionExchangeName = "djy.output.dingcang.ds6"; const string MqActionQueueName = "djy.output.dingcang.ds6"; ConnectionFactory factory = new ConnectionFactory(); - factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()); + factory.Uri = new Uri(BookingOrderMQUri); using (IConnection conn = factory.CreateConnection()) { @@ -8078,7 +7856,7 @@ namespace Myshipping.Application props.DeliveryMode = 2; mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); conn.Close(); - _logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】"); + _logger.LogInformation($"订舱数据回推,已发送数据到消息队列【{BookingOrderMQUri}】,数据内容:【{json}】"); } } catch (Exception ex) diff --git a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs index ffcc057d..23ac2012 100644 --- a/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs +++ b/Myshipping.Application/Service/BookingOrder/IBookingOrderService.cs @@ -31,8 +31,7 @@ namespace Myshipping.Application Task> GetBookingStatusLog(long Id); - - Task AddBookingStatusLog(List all); + /// /// 发送订舱、截单EDI @@ -70,6 +69,6 @@ namespace Myshipping.Application /// Task SetGoodsStatus(string code, long bookingId); - + Task SaveLog(BookingOrder newOrder, BookingOrder oldOrder); } } \ No newline at end of file diff --git a/Myshipping.Application/Service/DataSync/DataSyncService.cs b/Myshipping.Application/Service/DataSync/DataSyncService.cs index 5aee30b2..7f4faea0 100644 --- a/Myshipping.Application/Service/DataSync/DataSyncService.cs +++ b/Myshipping.Application/Service/DataSync/DataSyncService.cs @@ -71,11 +71,15 @@ namespace Myshipping.Application private readonly SqlSugarRepository _codeForwarder; private readonly SqlSugarRepository _bookingfile; private readonly SqlSugarRepository _accountconfig; + private readonly SqlSugarRepository _repStatuslog; + private readonly SqlSugarRepository _statuslogdetail; + private readonly SqlSugarRepository _repBookingStatus; private readonly IBookingOrderService _bookingorderservice; public DataSyncService(ILogger logger, ISysCacheService cache, SqlSugarRepository rep, SqlSugarRepository repCtn, SqlSugarRepository repUser, SqlSugarRepository repTenant, SqlSugarRepository djycustomer, + SqlSugarRepository statuslog, SqlSugarRepository statuslogdetail, SqlSugarRepository repBookingStatus, SqlSugarRepository djycustomercontact, SqlSugarRepository vesselinfo, SqlSugarRepository ctndetailrep , SqlSugarRepository bookingEDIExt, SqlSugarRepository bookinglog, SqlSugarRepository bookinglogdetail, SqlSugarRepository goodsStatus, SqlSugarRepository goodsStatusConfig, SqlSugarRepository repline, @@ -109,6 +113,9 @@ namespace Myshipping.Application this._accountconfig = accountconfig; this._bookingfile = bookingfile; this._bookingorderservice = bookingorderservice; + this._repStatuslog = statuslog; + this._statuslogdetail = statuslogdetail; + this._repBookingStatus = repBookingStatus; } @@ -465,14 +472,6 @@ namespace Myshipping.Application { entity.ETA = m.ETA; } - //if (m.ATD != null) - //{ - // entity.ATD = m.ATD; - //} - //if (m.YgtETD != null) - //{ - // entity.YgtETD = m.YgtETD; - //} await _vesselinfo.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); } ////根据船公司船名航次更新船期信息 @@ -486,19 +485,12 @@ namespace Myshipping.Application _logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据"); foreach (var it in order) { + var old = it; //更新订舱船期 if (it.ETD != item.ETD && item.ETD != null) { it.ETD = item.ETD; - //if (it.ATD != item.ATD && item.ATD != null) - //{ - // it.ATD = item.ATD; - //} - //if (it.YgtETD != item.YgtETD && item.YgtETD != null) - //{ - // it.YgtETD = item.YgtETD; - //} await _rep.AsUpdateable(it).IgnoreColumns(it => new { it.ParentId, @@ -518,58 +510,17 @@ namespace Myshipping.Application it.LstShipOrderCompareRltName, it.LstShipOrderCompareMode }).ExecuteCommandAsync(); - //记录日志 - - - - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = CreatedUserId, - CreatedUserName = item.CreatedUserName - }); - if (it.ETD != item.ETD) - { - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "ETD", - OldValue = it.ETD != null ? it.ETD.ToSqlValue() : null, - NewValue = item.ETD != null ? item.ETD.ToSqlValue() : null, - }); - } - //if (it.ATD != item.ATD) - //{ - // await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - // { - // PId = bid, - // Field = "ATD", - // OldValue = it.ATD != null ? it.ATD.ToSqlValue() : null, - // NewValue = item.ATD != null ? item.ATD.ToSqlValue() : null, - // }); - //} - //if (it.YgtETD != item.YgtETD) - //{ - // await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - // { - // PId = bid, - // Field = "ETD", - // OldValue = it.YgtETD != null ? it.YgtETD.ToSqlValue() : null, - // NewValue = item.YgtETD != null ? item.YgtETD.ToSqlValue() : null, - // }); - //} + await _bookingorderservice.SaveLog(it, old); } + } var ids = order.Where(x => x.ParentId == 0).Select(x => x.Id).ToArray(); - if (ids.Count()>0) { + if (ids.Count() > 0) + { await _bookingorderservice.SendBookingOrder(ids); } - + } } @@ -1696,99 +1647,33 @@ namespace Myshipping.Application { foreach (var it in order) { + var old = it; bool flag = false; if (it.StartETA != item.ETA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "预抵日期", - OldValue = it.StartETA == null ? "" : it.StartETA.ToString(), - NewValue = item.ETA == null ? "" : item.ETA.ToString(), - }); it.StartETA = item.ETA; } if (it.YgtETD != item.ETD) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "ETD", - OldValue = it.YgtETD == null ? "" : it.YgtETD.ToString(), - NewValue = item.ETD == null ? "" : item.ETD.ToString(), - }); it.YgtETD = item.ETD; } if (it.ATD != item.ATD && it.ATD == null) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "实际开船日期", - OldValue = it.ATD == null ? "" : it.ATD.ToString(), - NewValue = item.ATD == null ? "" : item.ATD.ToString(), - }); it.ATD = item.ATD; } if (it.StartATA != item.ATA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "实际抵港", - OldValue = it.StartATA == null ? "" : it.StartATA.ToString(), - NewValue = item.ATA == null ? "" : item.ATA.ToString(), - }); it.StartATA = item.ATA; } if (flag) { issend = true; await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync(); + await _bookingorderservice.SaveLog(it, old); } @@ -1831,140 +1716,45 @@ namespace Myshipping.Application { foreach (var it in order) { + var old = it; bool flag = false; if (it.ETA != item.ETA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "预计到港日期(目的港)", - OldValue = it.ETA == null ? "" : it.ETA.ToString(), - NewValue = item.ETA == null ? "" : item.ETA.ToString(), - }); + it.ETA = item.ETA; } if (it.MiddleETA != item.MiddleETA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "中转预抵", - OldValue = it.MiddleETA == null ? "" : it.MiddleETA.ToString(), - NewValue = item.MiddleETA == null ? "" : item.MiddleETA.ToString(), - }); + it.MiddleETA = item.MiddleETA; } if (it.MiddleETD != item.MiddleETD) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "中转预计离港", - OldValue = it.MiddleETD == null ? "" : it.MiddleETD.ToString(), - NewValue = item.MiddleETD == null ? "" : item.MiddleETD.ToString(), - }); + it.MiddleETD = item.MiddleETD; } if (item.MiddleATA != it.MiddleATA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "中转实际到港", - OldValue = it.MiddleATA == null ? "" : it.MiddleATA.ToString(), - NewValue = item.MiddleATA == null ? "" : item.MiddleATA.ToString(), - }); + it.MiddleATA = item.MiddleATA; } if (item.MiddleATD != it.MiddleATD) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "中转实际离港", - OldValue = it.MiddleATD == null ? "" : it.MiddleATD.ToString(), - NewValue = item.MiddleATD == null ? "" : item.MiddleATD.ToString(), - }); + it.MiddleATD = item.MiddleATD; } if (item.ATA != it.ATA) { flag = true; - ////添加booking日志 - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = it.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = UserManager.UserId, - CreatedUserName = UserManager.Name - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "实际到港(目的港)", - OldValue = it.ATA == null ? "" : it.ATA.ToString(), - NewValue = item.ATA == null ? "" : item.ATA.ToString(), - }); + it.ATA = item.ATA; } @@ -1972,6 +1762,7 @@ namespace Myshipping.Application { issend = true; await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync(); + await _bookingorderservice.SaveLog(it, old); } } if (issend) @@ -2246,6 +2037,200 @@ namespace Myshipping.Application } }); + } + + /// + /// 插入货运动态 + /// + [SqlSugarUnitOfWork] + [HttpPost("/DataSync/AddBookingStatusLog"), ApiUser(ApiCode = "AddBookingStatusLog")] + public async Task AddBookingStatusLog(List all) + { + try + { + var old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == all[0].BookingId && x.Category == "yunzong" && x.IsDeleted == false).ToListAsync(); + await _repStatuslog.DeleteAsync(x => x.BookingId == all[0].BookingId && x.Category == "yunzong"); + foreach (var ot in old) + { + await _statuslogdetail.DeleteAsync(x => x.PId == ot.Id); + } + var dicdatalist = _cache.GetAllDictData().Result; + foreach (var item in all) + { + #region 日志 + //新增数据 + var bookingStatusLog = new BookingStatusLog(); + bookingStatusLog.BookingId = item.BookingId; + bookingStatusLog.Category = "yunzong"; + bookingStatusLog.CreatedTime = DateTime.Now; + bookingStatusLog.Status = item.Status; + bookingStatusLog.OpTime = item.OpTime; + bookingStatusLog.MBLNO = item.MBLNO; + await _repStatuslog.InsertAsync(bookingStatusLog); + var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == item.BookingId).Select((d, t) => new + { + BookingId = d.BookingId, + StaCode = d.StaCode, + StaName = d.StaName, + StaTime = d.StaTime, + Code = t.Code, + Value = t.Value + }).ToListAsync(); + + if (item.detail != null && item.detail.Count > 0) + { + foreach (var dt in item.detail) + { + var BookingStatusLogDetail = new BookingStatusLogDetail(); + BookingStatusLogDetail.PId = bookingStatusLog.Id; + BookingStatusLogDetail.Status = dt.Status; + BookingStatusLogDetail.CNTRNO = dt.CNTRNO; + BookingStatusLogDetail.OPTime = dt.OPTime; + await _statuslogdetail.InsertAsync(BookingStatusLogDetail); + } + } + #endregion + + #region 订舱状态 + if (item.Status == "舱单") + { + if (list.Where(x => x.Code == "sta_cangdan").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_cangdan"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_cangdan").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.OpTime; + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + } + } + if (item.Status == "海关放行") + { + if (list.Where(x => x.Code == "sta_haifang").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_haifang"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_haifang").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.OpTime; + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + await _bookingorderservice.SetGoodsStatus("BG", item.BookingId); + await _bookingorderservice.SendBookingOrder(new long[] { item.BookingId }); + } + } + if (item.Status == "装载") + { + if (list.Where(x => x.Code == "sta_zhuangzai").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_zhuangzai"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangzai").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.OpTime; + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + await _bookingorderservice.SetGoodsStatus("ZZFX", item.BookingId); + await _bookingorderservice.SendBookingOrder(new long[] { item.BookingId }); + } + } + if (item.Status == "码放") + { + if (list.Where(x => x.Code == "sta_mafang").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_mafang"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_mafang").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.OpTime; + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + await _bookingorderservice.SetGoodsStatus("MTFX", item.BookingId); + await _bookingorderservice.SendBookingOrder(new long[] { item.BookingId }); + } + } + if (item.Status == "装船") + { + if (list.Where(x => x.Code == "sta_zhuangchuan").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_zhuangchuan"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangchuan").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.detail.Max(x => x.OPTime); + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + } + } + if (item.Status == "ATD") + { + if (list.Where(x => x.Code == "sta_atd").FirstOrDefault() == null) + { + BookingStatus bookingStatus = new BookingStatus(); + bookingStatus.BookingId = item.BookingId; + bookingStatus.StaCode = "sta_atd"; + bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_atd").Select(x => x.Value).FirstOrDefault(); + bookingStatus.StaTime = item.OpTime; + bookingStatus.StaCate = "book_sta_cate_billtrace"; + await _repBookingStatus.InsertAsync(bookingStatus); + } + } + #region 入港时间 + if (item.Status == "入港") + { + await _bookingorderservice.SetGoodsStatus("YRG", item.BookingId); + } + #endregion + #endregion + + #region ATD + if (item.Status == "ATD") + { + var o = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.BookingId && x.IsDeleted == false).First(); + var oldorder = o; + var oldatd = o == null ? null : o.ATD; + if (oldatd != item.OpTime && item.OpTime != null) + { + o.ATD = item.OpTime; + await _rep.UpdateAsync(o); + + await _bookingorderservice.SendBookingOrder(new long[] { o.Id }); + await _bookingorderservice.SaveLog(o,oldorder); + + + } + if (!string.IsNullOrEmpty(o.VESSEL) && !string.IsNullOrEmpty(o.VOYNO) && !string.IsNullOrEmpty(o.CARRIERID)) + { + var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == o.VOYNO && x.VESSEL == o.VESSEL && x.CARRIERID == o.CARRIERID && x.TenantId == o.TenantId && x.IsDeleted == false && x.Id != item.BookingId).ToListAsync(); + + foreach (var it in order) + { + var _oldorder= it; + var _oldatd = it.ATD; + if (_oldatd != item.OpTime) + { + it.ATD = item.OpTime; + await _rep.UpdateAsync(it); + + await _bookingorderservice.SendBookingOrder(new long[] { it.Id }); + await _bookingorderservice.SaveLog(it, _oldorder); + } + } + } + } + #endregion + } + } + catch (Exception ex) + { + + _logger.LogError(ex.Message); + _logger.LogError(ex.StackTrace); + + } + + } #endregion @@ -2258,7 +2243,6 @@ namespace Myshipping.Application [HttpGet("/DataSync/GetSyncVesselDate"), ApiUser(ApiCode = "GetSyncVesselDate")] public async Task GetSyncVesselDate() { - var list = await _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Sign == false && x.ATD == null && x.TenantId == UserManager.TENANT_ID && (x.Voyno != null && x.Voyno != "")).Select(x => new { Vessel = x.Vessel, @@ -2330,67 +2314,7 @@ namespace Myshipping.Application } var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync(); - if (order.MBLNO != input.MBLNO) - { - - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = order.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = order.CreatedUserId, - CreatedUserName = order.CreatedUserName - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "MBLNO", - OldValue = order.MBLNO, - NewValue = input.MBLNO, - }); - } - - if (order.TMBLNO != input.TMBLNO) - { - - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = order.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = order.CreatedUserId, - CreatedUserName = order.CreatedUserName - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "TMBLNO", - OldValue = order.TMBLNO, - NewValue = input.TMBLNO, - }); - } - if (order.BOOKINGNO != input.BOOKINGNO) - { - - var bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog - { - Type = "Edit", - BookingId = order.Id, - TenantId = Convert.ToInt64(UserManager.TENANT_ID), - CreatedTime = DateTime.Now, - CreatedUserId = order.CreatedUserId, - CreatedUserName = order.CreatedUserName - }); - await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail - { - PId = bid, - Field = "BOOKINGNO", - OldValue = order.BOOKINGNO, - NewValue = input.BOOKINGNO, - }); - } + var old = order; order.MBLNO = input.MBLNO; order.TMBLNO = input.TMBLNO; order.BOOKINGNO = input.BOOKINGNO; @@ -2407,11 +2331,9 @@ namespace Myshipping.Application it.TenantName, it.IsDeleted, }).ExecuteCommandAsync(); + await _bookingorderservice.SaveLog(order, old); } - - - /// /// 获取接口Key 个人或公司 /// @@ -2509,13 +2431,6 @@ namespace Myshipping.Application } } - - - - - - - #endregion } } diff --git a/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs b/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs index 09f97ae3..5262fd1e 100644 --- a/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs +++ b/Myshipping.Application/Service/DataSync/Dto/BookingOrderDto.cs @@ -781,8 +781,12 @@ namespace Myshipping.Application.Service.DataSync.Dto /// public string ForeignAgent { get; set; } - + + /// + /// 版本号 + /// + public string VERSION { get; set; } /// /// 三方付费 /// diff --git a/Myshipping.Web.Core/applicationconfig.json b/Myshipping.Web.Core/applicationconfig.json index f7294c45..5758fee3 100644 --- a/Myshipping.Web.Core/applicationconfig.json +++ b/Myshipping.Web.Core/applicationconfig.json @@ -121,7 +121,10 @@ "Path": "TempFiles", "RemainHours": 2 }, + "ITEMCODE": true, + "BookingOrderMQUri":"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" + } \ No newline at end of file diff --git a/Myshipping.sln b/Myshipping.sln index 9e88214f..04f0a42b 100644 --- a/Myshipping.sln +++ b/Myshipping.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Myshipping.FlowCenter", "My EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Myshipping.Report", "Myshipping.Report\Myshipping.Report.csproj", "{66E98A13-17A5-4B2A-B78A-A3FC87D2645A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDeamon", "ServiceDeamon\ServiceDeamon.csproj", "{A0F9B98D-6466-465F-B2D1-278B7284C11E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Debug|Any CPU.Build.0 = Debug|Any CPU {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Release|Any CPU.ActiveCfg = Release|Any CPU {66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Release|Any CPU.Build.0 = Release|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0F9B98D-6466-465F-B2D1-278B7284C11E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ServiceDeamon/App.config b/ServiceDeamon/App.config new file mode 100644 index 00000000..8780b642 --- /dev/null +++ b/ServiceDeamon/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ServiceDeamon/CheckServiceHelper.cs b/ServiceDeamon/CheckServiceHelper.cs new file mode 100644 index 00000000..9b489d19 --- /dev/null +++ b/ServiceDeamon/CheckServiceHelper.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; + +namespace ServiceDeamon +{ + public class CheckServiceHelper + { + private static ServiceController servCtl; + + + public static void CheckStatus(string servName) + { + if (servCtl == null || servCtl.ServiceName != servName) + { + servCtl = new ServiceController(servName); + } + + if (servCtl != null && servCtl.Status == ServiceControllerStatus.Stopped) + { + servCtl.Start(); + } + } + } +} diff --git a/ServiceDeamon/Program.cs b/ServiceDeamon/Program.cs new file mode 100644 index 00000000..064ff175 --- /dev/null +++ b/ServiceDeamon/Program.cs @@ -0,0 +1,13 @@ +using ServiceDeamon; +using System.Configuration; +using System.ServiceProcess; + +var servName = ConfigurationManager.AppSettings["ServiceName"]; + +//Timer t = new System.Threading.Timer((sta) => +//{ +// CheckServiceHelper.CheckStatus(servName); +//}); + +//t.Change(1000,) + diff --git a/ServiceDeamon/ServiceDeamon.csproj b/ServiceDeamon/ServiceDeamon.csproj new file mode 100644 index 00000000..9af9c439 --- /dev/null +++ b/ServiceDeamon/ServiceDeamon.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + +