jianghaiqing 1 year ago
commit 7409d8d3ca

@ -745,6 +745,8 @@ namespace Myshipping.Application
entity.VERSION = Guid.NewGuid().ToString(); entity.VERSION = Guid.NewGuid().ToString();
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString(); entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
entity.BSDATE = DateTime.Today;
entity.BSNO = null;
await _rep.InsertAsync(entity); await _rep.InsertAsync(entity);
if (input.ctnInputs != null) if (input.ctnInputs != null)
{ {
@ -813,6 +815,8 @@ namespace Myshipping.Application
await _rep.AsUpdateable(entity).IgnoreColumns(it => new await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{ {
it.ParentId, it.ParentId,
it.BSDATE,
it.BSNO,
it.TenantId, it.TenantId,
it.CreatedTime, it.CreatedTime,
it.CreatedUserId, it.CreatedUserId,
@ -1037,6 +1041,9 @@ namespace Myshipping.Application
//记录修改日志 //记录修改日志
await SaveLog(order, orderCompare); await SaveLog(order, orderCompare);
//推送东胜
await SendBookingOrder(new long[] { order.Id });
} }
/// <summary> /// <summary>
@ -1407,9 +1414,6 @@ namespace Myshipping.Application
} }
} }
/// <summary> /// <summary>
/// 删除备注 /// 删除备注
/// </summary> /// </summary>
@ -1423,10 +1427,6 @@ namespace Myshipping.Application
await _bookingremark.DeleteAsync(x => x.Id == Id); await _bookingremark.DeleteAsync(x => x.Id == Id);
} }
/// <summary> /// <summary>
/// 增加订舱附件 /// 增加订舱附件
/// </summary> /// </summary>
@ -1884,230 +1884,7 @@ namespace Myshipping.Application
} }
/// <summary>
/// 插入货运动态
/// </summary>
[AllowAnonymous]
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/AddBookingStatusLog")]
public async Task AddBookingStatusLog(List<BookingStatusLogDto> 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<SysDictData>((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 #endregion
#region 放舱(入货通知) #region 放舱(入货通知)
@ -7976,7 +7753,9 @@ namespace Myshipping.Application
[NonAction] [NonAction]
public async Task<dynamic> SendBookingOrder(long[] ids) public async Task<dynamic> 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 (!string.IsNullOrEmpty(itemcode) && itemcode == "true")
{ {
if (ids.Count() == 0) if (ids.Count() == 0)
@ -8058,13 +7837,12 @@ namespace Myshipping.Application
} }
var json = dto.ToJsonString(); var json = dto.ToJsonString();
_logger.LogInformation("订舱数据回推:" + json); _logger.LogInformation("订舱数据回推:" + json);
_logger.LogInformation("订舱数据回推地址:" + _cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
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(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()); factory.Uri = new Uri(BookingOrderMQUri);
using (IConnection conn = factory.CreateConnection()) using (IConnection conn = factory.CreateConnection())
{ {
@ -8078,7 +7856,7 @@ namespace Myshipping.Application
props.DeliveryMode = 2; props.DeliveryMode = 2;
mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes); mqModel.BasicPublish(MqActionExchangeName, queueName, props, messageBodyBytes);
conn.Close(); 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) catch (Exception ex)

@ -32,7 +32,6 @@ namespace Myshipping.Application
Task<List<BookingStatusLogDto>> GetBookingStatusLog(long Id); Task<List<BookingStatusLogDto>> GetBookingStatusLog(long Id);
Task AddBookingStatusLog(List<BookingStatusLogDto> all);
/// <summary> /// <summary>
/// 发送订舱、截单EDI /// 发送订舱、截单EDI
@ -70,6 +69,6 @@ namespace Myshipping.Application
/// <returns></returns> /// <returns></returns>
Task SetGoodsStatus(string code, long bookingId); Task SetGoodsStatus(string code, long bookingId);
Task SaveLog(BookingOrder newOrder, BookingOrder oldOrder);
} }
} }

@ -71,11 +71,15 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<CodeForwarder> _codeForwarder; private readonly SqlSugarRepository<CodeForwarder> _codeForwarder;
private readonly SqlSugarRepository<BookingFile> _bookingfile; private readonly SqlSugarRepository<BookingFile> _bookingfile;
private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _accountconfig; private readonly SqlSugarRepository<DjyWebsiteAccountConfig> _accountconfig;
private readonly SqlSugarRepository<BookingStatusLog> _repStatuslog;
private readonly SqlSugarRepository<BookingStatusLogDetail> _statuslogdetail;
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
private readonly IBookingOrderService _bookingorderservice; private readonly IBookingOrderService _bookingorderservice;
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,
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer, SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer,
SqlSugarRepository<BookingStatusLog> statuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail, SqlSugarRepository<BookingStatus> repBookingStatus,
SqlSugarRepository<DjyCustomerContact> djycustomercontact, SqlSugarRepository<DjyVesselInfo> vesselinfo, SqlSugarRepository<BookingCtnDetail> ctndetailrep SqlSugarRepository<DjyCustomerContact> djycustomercontact, SqlSugarRepository<DjyVesselInfo> vesselinfo, SqlSugarRepository<BookingCtnDetail> ctndetailrep
, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, , SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail,
SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig, SqlSugarRepository<DjyTenantLine> repline,
@ -109,6 +113,9 @@ namespace Myshipping.Application
this._accountconfig = accountconfig; this._accountconfig = accountconfig;
this._bookingfile = bookingfile; this._bookingfile = bookingfile;
this._bookingorderservice = bookingorderservice; this._bookingorderservice = bookingorderservice;
this._repStatuslog = statuslog;
this._statuslogdetail = statuslogdetail;
this._repBookingStatus = repBookingStatus;
} }
@ -465,14 +472,6 @@ namespace Myshipping.Application
{ {
entity.ETA = m.ETA; 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(); await _vesselinfo.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
} }
////根据船公司船名航次更新船期信息 ////根据船公司船名航次更新船期信息
@ -486,19 +485,12 @@ namespace Myshipping.Application
_logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据"); _logger.LogInformation($"同步船期_查询到{UserManager.TENANT_NAME}需要更新{order.Count()}条订舱数据");
foreach (var it in order) foreach (var it in order)
{ {
var old = it;
//更新订舱船期 //更新订舱船期
if (it.ETD != item.ETD && item.ETD != null) if (it.ETD != item.ETD && item.ETD != null)
{ {
it.ETD = item.ETD; 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 await _rep.AsUpdateable(it).IgnoreColumns(it => new
{ {
it.ParentId, it.ParentId,
@ -518,55 +510,14 @@ namespace Myshipping.Application
it.LstShipOrderCompareRltName, it.LstShipOrderCompareRltName,
it.LstShipOrderCompareMode it.LstShipOrderCompareMode
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
//记录日志 await _bookingorderservice.SaveLog(it, old);
////添加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,
// });
//}
} }
} }
var ids = order.Where(x => x.ParentId == 0).Select(x => x.Id).ToArray(); 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); await _bookingorderservice.SendBookingOrder(ids);
} }
@ -1696,99 +1647,33 @@ namespace Myshipping.Application
{ {
foreach (var it in order) foreach (var it in order)
{ {
var old = it;
bool flag = false; bool flag = false;
if (it.StartETA != item.ETA) if (it.StartETA != item.ETA)
{ {
flag = true; 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; it.StartETA = item.ETA;
} }
if (it.YgtETD != item.ETD) if (it.YgtETD != item.ETD)
{ {
flag = true; 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; it.YgtETD = item.ETD;
} }
if (it.ATD != item.ATD && it.ATD == null) if (it.ATD != item.ATD && it.ATD == null)
{ {
flag = true; 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; it.ATD = item.ATD;
} }
if (it.StartATA != item.ATA) if (it.StartATA != item.ATA)
{ {
flag = true; 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; it.StartATA = item.ATA;
} }
if (flag) if (flag)
{ {
issend = true; issend = true;
await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync(); await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync();
await _bookingorderservice.SaveLog(it, old);
} }
@ -1831,140 +1716,45 @@ namespace Myshipping.Application
{ {
foreach (var it in order) foreach (var it in order)
{ {
var old = it;
bool flag = false; bool flag = false;
if (it.ETA != item.ETA) if (it.ETA != item.ETA)
{ {
flag = true; 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; it.ETA = item.ETA;
} }
if (it.MiddleETA != item.MiddleETA) if (it.MiddleETA != item.MiddleETA)
{ {
flag = true; 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; it.MiddleETA = item.MiddleETA;
} }
if (it.MiddleETD != item.MiddleETD) if (it.MiddleETD != item.MiddleETD)
{ {
flag = true; 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; it.MiddleETD = item.MiddleETD;
} }
if (item.MiddleATA != it.MiddleATA) if (item.MiddleATA != it.MiddleATA)
{ {
flag = true; 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; it.MiddleATA = item.MiddleATA;
} }
if (item.MiddleATD != it.MiddleATD) if (item.MiddleATD != it.MiddleATD)
{ {
flag = true; 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; it.MiddleATD = item.MiddleATD;
} }
if (item.ATA != it.ATA) if (item.ATA != it.ATA)
{ {
flag = true; 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; it.ATA = item.ATA;
} }
@ -1972,6 +1762,7 @@ namespace Myshipping.Application
{ {
issend = true; issend = true;
await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync(); await _rep.AsUpdateable(it).IgnoreColumns().ExecuteCommandAsync();
await _bookingorderservice.SaveLog(it, old);
} }
} }
if (issend) if (issend)
@ -2246,6 +2037,200 @@ namespace Myshipping.Application
} }
}); });
}
/// <summary>
/// 插入货运动态
/// </summary>
[SqlSugarUnitOfWork]
[HttpPost("/DataSync/AddBookingStatusLog"), ApiUser(ApiCode = "AddBookingStatusLog")]
public async Task AddBookingStatusLog(List<BookingStatusLogDto> 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<SysDictData>((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 #endregion
@ -2258,7 +2243,6 @@ namespace Myshipping.Application
[HttpGet("/DataSync/GetSyncVesselDate"), ApiUser(ApiCode = "GetSyncVesselDate")] [HttpGet("/DataSync/GetSyncVesselDate"), ApiUser(ApiCode = "GetSyncVesselDate")]
public async Task<dynamic> GetSyncVesselDate() public async Task<dynamic> 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 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, 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(); var order = await _rep.AsQueryable().Filter(null, true).Where(x => x.Id == input.Id).FirstAsync();
if (order.MBLNO != input.MBLNO) var old = order;
{
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,
});
}
order.MBLNO = input.MBLNO; order.MBLNO = input.MBLNO;
order.TMBLNO = input.TMBLNO; order.TMBLNO = input.TMBLNO;
order.BOOKINGNO = input.BOOKINGNO; order.BOOKINGNO = input.BOOKINGNO;
@ -2407,11 +2331,9 @@ namespace Myshipping.Application
it.TenantName, it.TenantName,
it.IsDeleted, it.IsDeleted,
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
await _bookingorderservice.SaveLog(order, old);
} }
/// <summary> /// <summary>
/// 获取接口Key 个人或公司 /// 获取接口Key 个人或公司
/// </summary> /// </summary>
@ -2509,13 +2431,6 @@ namespace Myshipping.Application
} }
} }
#endregion #endregion
} }
} }

@ -783,6 +783,10 @@ namespace Myshipping.Application.Service.DataSync.Dto
/// <summary>
/// 版本号
/// </summary>
public string VERSION { get; set; }
/// <summary> /// <summary>
/// 三方付费 /// 三方付费
/// </summary> /// </summary>

@ -121,7 +121,10 @@
"Path": "TempFiles", "Path": "TempFiles",
"RemainHours": 2 "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", "ShippingOrderCompareUrl": "http://60.209.125.238:35210/api/TaskShippingOrderCompare/ExcuteShippingOrderCompare",
"BCOrDraftUserKey": "BookingOrderPlat", "BCOrDraftUserKey": "BookingOrderPlat",
"BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6" "BCOrDraftUserSecret": "228b2db5952d13291f228d441018c1b6"
} }

@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Myshipping.FlowCenter", "My
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Myshipping.Report", "Myshipping.Report\Myshipping.Report.csproj", "{66E98A13-17A5-4B2A-B78A-A3FC87D2645A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Myshipping.Report", "Myshipping.Report\Myshipping.Report.csproj", "{66E98A13-17A5-4B2A-B78A-A3FC87D2645A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDeamon", "ServiceDeamon\ServiceDeamon.csproj", "{A0F9B98D-6466-465F-B2D1-278B7284C11E}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{66E98A13-17A5-4B2A-B78A-A3FC87D2645A}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ServiceName" value=""/>
</appSettings>
</configuration>

@ -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();
}
}
}
}

@ -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,)

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.1" />
</ItemGroup>
</Project>
Loading…
Cancel
Save