刷新运踪(互联网和云港通)接口

usertest
cjy 4 months ago
parent 9620dd32b5
commit 37d6438edf

@ -1,4 +1,6 @@
namespace DS.Module.Core.Extensions;
using Newtonsoft.Json.Linq;
namespace DS.Module.Core.Extensions;
public static class DateTimeExtension
{
@ -30,4 +32,28 @@ public static class DateTimeExtension
var week = new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
return week[day];
}
/// <summary>
/// 获取datetime值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static DateTime? GetDateTimeValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return null;
}
var strVal = jt.ToString();
DateTime rtnVal = DateTime.MinValue;
if (DateTime.TryParse(strVal, out rtnVal))
{
return rtnVal;
}
return null;
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.EDI
{
public class YGTDataDto
{
public string CNTRNO { get; set; }
public DateTime? YunDiShiJian { get; set; }
public DateTime? WaiLiShiJian { get; set; }
public string MTFX { get; set; }
public DateTime? ZhuangzhaiShiJian { get; set; }
public DateTime? ZhuangChuanShiJian { get; set; }
public DateTime? RuGangShiJian { get; set; }
}
}

@ -203,4 +203,12 @@ public interface ISeaExportService
/// <param name="mblNo">提单号</param>
/// <returns></returns>
Task<DataResult<SeaExportOrderExtension>> SearchOrderInfo(string mblNo);
/// <summary>
/// 刷新运踪(互联网和云港通)
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public Task<DataResult<string>> RefreshYGT(long[] Ids);
}

@ -1,11 +1,19 @@
using DS.Module.Core;
using Amazon.Runtime.Internal.Util;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Map.Entity;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Mapster;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Ocsp;
namespace DS.WMS.Core.Op.Method
{
@ -237,6 +245,642 @@ namespace DS.WMS.Core.Op.Method
return await Task.FromResult(DataResult<string>.Success(res.Data));
}
}
/// <summary>
/// 刷新运踪(互联网和云港通)
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task<DataResult<string>> RefreshYGT(long[] Ids)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = await tenantDb.Queryable<SeaExport>().Where(x => Ids.Contains(x.Id) && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
if (order == null || order.Count == 0)
{
return await Task.FromResult(DataResult<string>.Failed("存在未订阅单据"));
}
var key = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "billTraceNewUserKey" && x.TenantId == 1288018625843826688).Select(x => x.Value).First();
if (string.IsNullOrEmpty(key))
{
return await Task.FromResult(DataResult<string>.Failed("未获取到运踪相关KEY请联系管理员"));
}
var secret = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "billTraceNewUserSecret" && x.TenantId == 1288018625843826688).Select(x => x.Value).First();
if (string.IsNullOrEmpty(secret))
{
return await Task.FromResult(DataResult<string>.Failed("未获取到运踪相关SECRET请联系管理员"));
}
var url = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "billTraceYgtUrl" && x.TenantId == 1288018625843826688).Select(x => x.Value).First();
if (string.IsNullOrEmpty(secret))
{
return await Task.FromResult(DataResult<string>.Failed("未获取到运港通船期即时查询接口,请联系管理员!"));
}
//var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
JArray jarrHLWTemos = new JArray();
JArray jarrYGTTemos = new JArray();
foreach (var item in order)
{
JObject jobjhlwTemp = new JObject();
jobjhlwTemp.Add("web_code", "HLW_CD");
jobjhlwTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrHLWTemos.Add(jobjhlwTemp);
JObject jobjygtTemp = new JObject();
jobjygtTemp.Add("web_code", "YGT_YZ");
jobjygtTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrYGTTemos.Add(jobjygtTemp);
}
if (jarrHLWTemos.Count > 0)
{
JObject HLWjobjSend = new JObject();
HLWjobjSend.Add("user_key", new JValue(key));
HLWjobjSend.Add("user_secret", new JValue(secret));
HLWjobjSend.Add("customer_id", new JValue(user.TenantId));
HLWjobjSend.Add("customer_name", new JValue(user.TenantName));
HLWjobjSend.Add("data_list", jarrHLWTemos);
var json = HLWjobjSend.ToJsonString();
_logger.Info("运踪查询HLW+参数:" + json);
//var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(HLWjobjSend.ToJsonString()).PostAsStringAsync();
var rtn = await RequestHelper.PostJosnAsyncNoHeaders(url, json);
_logger.Info("运踪查询HLW+查询结果:" + rtn);
await ExecuteHLW(rtn);
}
if (jarrYGTTemos.Count > 0)
{
JObject YGTjobjSend = new JObject();
YGTjobjSend.Add("user_key", new JValue(key));
YGTjobjSend.Add("user_secret", new JValue(secret));
YGTjobjSend.Add("customer_id", new JValue(user.TenantId));
YGTjobjSend.Add("customer_name", new JValue(user.TenantName));
YGTjobjSend.Add("data_list", jarrYGTTemos);
var json = YGTjobjSend.ToJsonString();
_logger.Info("运踪查询YGT参数" + json);
//var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(YGTjobjSend.ToJsonString()).PostAsStringAsync();
var rtn = await RequestHelper.PostJosnAsyncNoHeaders(url, YGTjobjSend.ToJsonString());
_logger.Info("运踪查询YGT查询结果" + rtn);
await ExecuteYGT(rtn);
}
return await Task.FromResult(DataResult<string>.Success("刷新运踪成功!"));
}
[NonAction]
//[SqlSugarUnitOfWork]
public async Task ExecuteHLW(string rtn)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
JObject jobjRtn = JObject.Parse(rtn);
var code = jobjRtn.GetValue("code").ToString();
var msg = jobjRtn.GetValue("msg").ToString();
if (code != "200")
{
_logger.Info($"请求爬虫获取【HLW+数据】出错:{msg}");
throw new Exception(msg);
}
//订舱状态
var dicList = db.Queryable<SysDictData>().Where(x => x.TypeId == 1788810332945387520).ToList();
JArray jarrData = jobjRtn.GetValue("data") as JArray;
foreach (JObject item in jarrData)
{
//每票 货物
var mblno = item.GetValue("bno").ToString();
var bookingId = await tenantDb.Queryable<SeaExport>().Where(x => x.MBLNO == mblno && x.ParentId == 0).Select(x => x.Id).FirstAsync();
var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true)
.InnerJoin<SysDictData>((d, t) => d.StatusCode == t.Value && t.TypeId == 1788810332945387520 && d.StatusGroup == "booking_status_group_billtrace"
&& d.BusinessId == bookingId, "shippingweb8_dev.sys_dict_data")
.Select((d, t) => new
{
BusinessId = d.BusinessId,
StatusCode = d.StatusCode,
StatusName = d.StatusName,
StatusTime = d.StatusTime,
Name = t.Name,
Value = t.Value
}).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray;
if (jarrInnerData.Count == 0)
{
throw new Exception(item.GetStringValue("msg"));
}
DateTime? TimeCangDan = null;
DateTime? FangXingShiJian = null;
foreach (JObject dataItem in jarrInnerData)
{
TimeCangDan = dataItem.GetDateTimeValue("YuPeiShiJian"); //舱单时间
FangXingShiJian = dataItem.GetDateTimeValue("FangXingShiJian"); //放行时间
}
//await _repStatuslog.DeleteAsync(x => x.BookingId == bookingId && x.Category == "yunzong" && (x.Status == "舱单" || x.Status == "报关"));
var oldLog = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == bookingId && x.Group == "yunzong" && (x.Status == "舱单" || x.Status == "报关")).ToListAsync();
if (oldLog.Count > 0)
{
//var oldid = oldLog.Select(x => x.Id).ToList();
////删除日志详情和日志
//var oldLogDetails = await tenantDb.Queryable<BookingStatusLogDetail>().Where(x => oldid.Contains(x.PId)).ToListAsync();
//if (oldLogDetails.Count > 0)
//{
// await tenantDb.Deleteable(oldLogDetails).ExecuteCommandAsync();
//}
await tenantDb.Deleteable(oldLog).ExecuteCommandAsync();
}
if (TimeCangDan != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"舱单",
Group = "yunzong",
OpTime = TimeCangDan,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
if (list.Where(x => x.StatusCode == "status_cangdan").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_cangdan",
StatusName = dicList.Where(x => x.Value == "status_cangdan").Select(x => x.Name).First(),
StatusTime = TimeCangDan,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
}
}
if (FangXingShiJian != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"报关",
Group = "yunzong",
OpTime = FangXingShiJian,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
if (list.Where(x => x.StatusCode == "status_haifang").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_haifang",
StatusName = dicList.Where(x => x.Value == "status_haifang").Select(x => x.Name).First(),
StatusTime = TimeCangDan,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("BG", bookingId, tenantDb);
}
}
}
}
[NonAction]
//[SqlSugarUnitOfWork]
public async Task ExecuteYGT(string rtn)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
JObject jobjRtn = JObject.Parse(rtn);
var code = jobjRtn.GetValue("code").ToString();
var msg = jobjRtn.GetValue("msg").ToString();
if (code != "200")
{
_logger.Info($"请求爬虫获取【YGT数据】出错{msg}");
throw new Exception(msg);
}
var dicList = db.Queryable<SysDictData>().Where(x => x.TypeId == 1788810332945387520).ToList();
JArray jarrData = jobjRtn.GetValue("data") as JArray;
foreach (JObject item in jarrData)
{
//每票 货物
var mblno = item.GetValue("bno").ToString();
var bookingId = await tenantDb.Queryable<SeaExport>().Where(x => x.MBLNO == mblno && x.ParentId == 0).Select(x => x.Id).FirstAsync();
var list = await tenantDb.Queryable<BookingStatus>().Filter(null, true)
.InnerJoin<SysDictData>((d, t) => d.StatusCode == t.Value && t.TypeId == 1788810332945387520 && d.StatusGroup == "booking_status_group_billtrace"
&& d.BusinessId == bookingId, "shippingweb8_dev.sys_dict_data")
.Select((d, t) => new
{
BusinessId = d.BusinessId,
StatusCode = d.StatusCode,
StatusName = d.StatusName,
StatusTime = d.StatusTime,
Name = t.Name,
Value = t.Value
}).ToListAsync();
var jarrInnerData = item.GetValue("data") as JArray;
List<YGTDataDto> ygtdto = new List<YGTDataDto>();
DateTime? SJLGShiJian = null;//ATD
DateTime? YJDGShiJian = null;//ETA
DateTime? SJDGShiJian = null;//ATA
DateTime? YJLGShiJian = null;//ETD
int xl = 0;
foreach (JObject dataItem in jarrInnerData)
{
SJLGShiJian = dataItem.GetDateTimeValue("sjlg_time"); //实际离港时间
YJDGShiJian = dataItem.GetDateTimeValue("yjdk_time"); //预计到港时间
SJDGShiJian = dataItem.GetDateTimeValue("sjdk_time"); //实际到港时间
YJLGShiJian = dataItem.GetDateTimeValue("yjlk_time"); //预计离港时间
var xh_info = dataItem.GetValue("xh_info") as JArray;
xl = xh_info.Count();
foreach (JObject it in xh_info)
{
var CNTRNO = it.GetStringValue("ctn_no"); //箱号
var yd_time = it.GetDateTimeValue("yd_time"); //运抵时间
var wl_time = it.GetDateTimeValue("wl_time"); //外理时间
var mtfx = it.GetStringValue("mtfx"); //码头放行
var zz_time = it.GetDateTimeValue("zz_time"); //装载时间
var ck_time = it.GetDateTimeValue("ck_time"); //装船时间
var rg_time = it.GetDateTimeValue("rg_lr_time"); //入港时间
ygtdto.Add(new YGTDataDto
{
CNTRNO = CNTRNO,
YunDiShiJian = yd_time,
WaiLiShiJian = wl_time,
MTFX = mtfx,
ZhuangzhaiShiJian = zz_time,
ZhuangChuanShiJian = ck_time,
RuGangShiJian = rg_time
});
}
}
var rgnum = ygtdto.Where(x => x.RuGangShiJian != null).Count();
var ydnum = ygtdto.Where(x => x.YunDiShiJian != null).Count();
var zznum = ygtdto.Where(x => x.ZhuangzhaiShiJian != null).Count();
var wlnum = ygtdto.Where(x => x.WaiLiShiJian != null).Count();
var mfnum = ygtdto.Where(x => x.MTFX == "Y").Count();
var zcnum = ygtdto.Where(x => x.ZhuangChuanShiJian != null).Count();
var oldLog = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == bookingId && x.Group == "yunzong" && (x.Status == "运抵" || x.Status == "装载" || x.Status == "外理" || x.Status == "码放" || x.Status == "装船" || x.Status == "入港" || x.Status == "ATD")).ToListAsync();
if (oldLog.Count > 0)
{
var oldid = oldLog.Select(x => x.Id).ToList();
//删除日志详情和日志
var oldLogDetails = await tenantDb.Queryable<BookingStatusLogDetail>().Where(x => oldid.Contains(x.PId)).ToListAsync();
if (oldLogDetails.Count > 0)
{
await tenantDb.Deleteable(oldLogDetails).ExecuteCommandAsync();
}
await tenantDb.Deleteable(oldLog).ExecuteCommandAsync();
}
if (xl > 0 && rgnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"入港",
Group = "yunzong",
OpTime = xl == ydnum ? ygtdto.Select(x => x.RuGangShiJian).Max() : null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
foreach (var dt in ygtdto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail()
{
PId = bookingStatusLog.Id,
Status = "入港",
CNTRNO = dt.CNTRNO,
OpTime = dt.RuGangShiJian
};
await tenantDb.Insertable(BookingStatusLogDetail).ExecuteCommandAsync();
}
if (list.Where(x => x.Value == "status_rugang").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_rugang",
StatusName = dicList.Where(x => x.Value == "status_rugang").Select(x => x.Name).First(),
StatusTime = xl == ydnum ? ygtdto.Select(x => x.RuGangShiJian).Max() : null,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("YRG", bookingId, tenantDb);
}
}
if (xl > 0 && ydnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"运抵",
Group = "yunzong",
OpTime = xl == ydnum ? ygtdto.Select(x => x.YunDiShiJian).Max() : null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
foreach (var dt in ygtdto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail()
{
PId = bookingStatusLog.Id,
Status = "运抵",
CNTRNO = dt.CNTRNO,
OpTime = dt.YunDiShiJian
};
await tenantDb.Insertable(BookingStatusLogDetail).ExecuteCommandAsync();
}
}
if (xl > 0 && zznum > 0 && zznum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"装载",
Group = "yunzong",
OpTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
if (list.Where(x => x.Value == "status_zhuangzai").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_zhuangzai",
StatusName = dicList.Where(x => x.Value == "status_zhuangzai").Select(x => x.Name).First(),
StatusTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("ZZFX", bookingId, tenantDb);
}
}
if (xl > 0 && wlnum > 0 && wlnum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"外理",
Group = "yunzong",
OpTime = null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
}
if (xl > 0 && mfnum > 0 && mfnum == xl)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"码放",
Group = "yunzong",
OpTime = null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
if (list.Where(x => x.Value == "status_mafang").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_mafang",
StatusName = dicList.Where(x => x.Value == "status_mafang").Select(x => x.Name).First(),
StatusTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
await seaComService.SetGoodsStatus("MTFX", bookingId, tenantDb);
};
}
if (xl > 0 && zcnum > 0)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"装船",
Group = "yunzong",
OpTime = xl == ydnum ? ygtdto.Select(x => x.ZhuangChuanShiJian).Max() : null,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
foreach (var dt in ygtdto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail()
{
PId = bookingStatusLog.Id,
Status = "装船",
CNTRNO = dt.CNTRNO,
OpTime = dt.ZhuangChuanShiJian
};
await tenantDb.Insertable(BookingStatusLogDetail).ExecuteCommandAsync();
}
if (list.Where(x => x.Value == "status_zhuangchuan").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_zhuangchuan",
StatusName = dicList.Where(x => x.Value == "status_zhuangchuan").Select(x => x.Name).First(),
StatusTime = xl == ydnum ? ygtdto.Select(x => x.ZhuangChuanShiJian).Max() : null,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
};
}
if (SJLGShiJian != null)
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"ATD",
Group = "yunzong",
OpTime = SJLGShiJian,
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
if (list.Where(x => x.Value == "status_atd").FirstOrDefault() == null)
{
BookingStatus bookingStatus = new BookingStatus()
{
BusinessId = bookingId,
StatusCode = "status_atd",
StatusName = dicList.Where(x => x.Value == "status_atd").Select(x => x.Name).First(),
StatusTime = SJLGShiJian,
StatusGroup = "booking_status_group_billtrace"
};
await tenantDb.Insertable(bookingStatus).ExecuteCommandAsync();
};
}
var bookingOrder = await tenantDb.Queryable<SeaExport>().FirstAsync(x => x.Id == bookingId);
//ATD
if (SJLGShiJian != null && bookingOrder.ATD != SJLGShiJian)
{
//var oldorder = bookingOrder;
bookingOrder.ATD = SJLGShiJian;
bookingOrder.Note = "刷新运踪";
await tenantDb.Updateable(bookingOrder).UpdateColumns(x => new
{
x.ATD,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
if (!string.IsNullOrEmpty(bookingOrder.Vessel) && !string.IsNullOrEmpty(bookingOrder.Voyno) && !string.IsNullOrEmpty(bookingOrder.Carrier))
{
var neworder = await tenantDb.Queryable<SeaExport>().Where(x => x.Voyno == bookingOrder.Voyno && x.Vessel == bookingOrder.Vessel && x.CarrierId == bookingOrder.CarrierId && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it.Adapt<SeaExport>();
if (it.ATD != SJLGShiJian)
{
_oldorder.ATD = SJLGShiJian;
_oldorder.Note = "刷新运踪";
await tenantDb.Updateable(_oldorder).UpdateColumns(x => new
{
x.ATD,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
}
}
//ETA
if (YJDGShiJian != null && bookingOrder.StartETA != YJDGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.StartETA = YJDGShiJian;
bookingOrder.Note = "刷新运踪";
await tenantDb.Updateable(bookingOrder).UpdateColumns(x => new
{
x.StartETA,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
if (!string.IsNullOrEmpty(bookingOrder.Vessel) && !string.IsNullOrEmpty(bookingOrder.Voyno) && !string.IsNullOrEmpty(bookingOrder.Carrier))
{
var neworder = await tenantDb.Queryable<SeaExport>().Where(x => x.Voyno == bookingOrder.Voyno && x.Vessel == bookingOrder.Vessel && x.CarrierId == bookingOrder.CarrierId && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it.Adapt<SeaExport>();
if (it.StartETA != YJDGShiJian)
{
_oldorder.StartETA = YJDGShiJian;
_oldorder.Note = "刷新运踪";
await tenantDb.Updateable(_oldorder).UpdateColumns(x => new
{
x.ATD,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
}
}
//ATA
if (SJDGShiJian != null && bookingOrder.StartATA != SJDGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.StartATA = SJDGShiJian;
bookingOrder.Note = "刷新运踪";
await tenantDb.Updateable(bookingOrder).UpdateColumns(x => new
{
x.StartATA,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
if (!string.IsNullOrEmpty(bookingOrder.Vessel) && !string.IsNullOrEmpty(bookingOrder.Voyno) && !string.IsNullOrEmpty(bookingOrder.Carrier))
{
var neworder = await tenantDb.Queryable<SeaExport>().Where(x => x.Voyno == bookingOrder.Voyno && x.Vessel == bookingOrder.Vessel && x.CarrierId == bookingOrder.CarrierId && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it.Adapt<SeaExport>();
if (it.StartATA != SJDGShiJian)
{
_oldorder.StartATA = SJDGShiJian;
_oldorder.Note = "刷新运踪";
await tenantDb.Updateable(_oldorder).UpdateColumns(x => new
{
x.StartATA,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
}
}
//ETD
if (YJLGShiJian != null && bookingOrder.YgtETD != YJLGShiJian)
{
var oldorder = bookingOrder;
bookingOrder.YgtETD = YJLGShiJian;
bookingOrder.Note = "刷新运踪";
await tenantDb.Updateable(bookingOrder).UpdateColumns(x => new
{
x.YgtETD,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
if (!string.IsNullOrEmpty(bookingOrder.Vessel) && !string.IsNullOrEmpty(bookingOrder.Voyno) && !string.IsNullOrEmpty(bookingOrder.Carrier))
{
var neworder = await tenantDb.Queryable<SeaExport>().Where(x => x.Voyno == bookingOrder.Voyno && x.Vessel == bookingOrder.Vessel && x.CarrierId == bookingOrder.CarrierId && x.Id != bookingOrder.Id).ToListAsync();
foreach (var it in neworder)
{
var _oldorder = it.Adapt<SeaExport>();
if (it.YgtETD != YJLGShiJian)
{
_oldorder.YgtETD = YJLGShiJian;
_oldorder.Note = "刷新运踪";
await tenantDb.Updateable(_oldorder).UpdateColumns(x => new
{
x.YgtETD,
x.Note
}).EnableDiffLogEvent().ExecuteCommandAsync();
}
}
}
}
}
}
#endregion
}
}

@ -443,4 +443,16 @@ public class SeaExportController : ApiController
var res = await _invokeService.PrintShippingOrderPDF(id);
return res;
}
/// <summary>
/// 刷新运踪(互联网和云港通)
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("RefreshYGT")]
public async Task<DataResult<string>> RefreshYGT([FromQuery] IdModel req)
{
return await _invokeService.RefreshYGT(req.Ids);
}
}
Loading…
Cancel
Save