You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1255 lines
61 KiB
C#

using Amazon.Runtime.Internal.Util;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.DjyServiceStatus;
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
{
/// <summary>
/// 海运出口运踪相关接口
/// </summary>
public partial class SeaExportService
{
#region 运踪相关
/// <summary>
/// 发起运踪订阅或者更新提单号
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult<string>> SendOrUpdateTrace(List<BillTraceSendReq> req)
{
if (req.Count == 0)
{
return await Task.FromResult(DataResult<string>.Failed("未传入正确参数!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
//var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userPwd" && x.TenantId == 1288018625843826688).First().Value;
//var userId = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userId" && x.TenantId == 1288018625843826688).First().Value;
var reqUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "request_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var resUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "response_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var account = seaComService.GetCodeThirdParty("BillTraceSubcribe", user.UserId, tenantDb);
if (account.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("未配置运踪订阅第三方账号信息!"));
}
if (account.AppSecret.IsNull() || account.AppKey.IsNull() || account.RegistContractName.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("请检查运踪订阅第三方账号关键参数!"));
}
BillTraceMain billdto = new BillTraceMain();
List<BillTraceReq> billTraceList = new List<BillTraceReq>();
foreach (var item in req)
{
var yardCode = seaComService.GetClientCode(item.YardId, tenantDb);
var carrierCode = seaComService.GetCarrierCode(item.CarrierId, tenantDb);
if (!string.IsNullOrWhiteSpace(item.CarrierId.ToString()))
{
var et = await tenantDb.Queryable<BookingStatus>().Where(x => x.StatusCode == "status_mudigang" && x.BusinessId == Convert.ToInt64(item.BusinessId)).FirstAsync();
if (et != null)
{
return await Task.FromResult(DataResult<string>.Failed("\"提单号\" + item.MBLNO + \"已订阅!"));
}
}
if (!string.IsNullOrWhiteSpace(item.YardId.ToString()))
{
var et = await tenantDb.Queryable<BookingStatus>().Where(x => x.StatusCode == "status_qiyungang" && x.BusinessId == Convert.ToInt64(item.BusinessId)).FirstAsync();
if (et != null)
{
return await Task.FromResult(DataResult<string>.Failed("\"提单号\" + item.MBLNO + \"已订阅!"));
}
}
if (item.isBook && (string.IsNullOrWhiteSpace(carrierCode) || string.IsNullOrWhiteSpace(item.Carrier) || string.IsNullOrWhiteSpace(item.MBLNO)))
{
return await Task.FromResult(DataResult<string>.Failed("订阅目的港船公司或提单号不能为空!"));
}
if (!item.isBook && (string.IsNullOrWhiteSpace(item.Yard) || string.IsNullOrWhiteSpace(yardCode) || string.IsNullOrWhiteSpace(item.MBLNO)))
{
return await Task.FromResult(DataResult<string>.Failed("订阅港前数据提单号或场站不能为空!"));
}
var yardMap = tenantDb.Queryable<MappingYard>().Where(x => x.Code == yardCode && x.Module == "BillTrace").First();
if (item.IsFrontPort == true)
{
if (yardMap.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed($"场站代号配置未找到:{yardCode}"));
}
}
//var carrierMap = tenantDb.Queryable<MappingYard>().Where(x => x.Code == yardCode && x.Module == "BillTrace").First();
//if (yardMap.IsNull())
//{
// return await Task.FromResult(DataResult<string>.Failed($"船公司代号配置未找到:{yardCode}"));
//}
var carrierName = string.Empty;
if (string.IsNullOrEmpty(carrierCode))
{
carrierName = "";
}
else
{
carrierName = seaComService.GetCarrierMapper(item.CarrierId, tenantDb).MapName;
}
billTraceList.Add(new BillTraceReq
{
BusinessId = item.BusinessId,
MBLNO = item.MBLNO,
YARD = yardMap?.MapName,
YardCode = yardMap?.MapCode == "" ? null : yardMap?.MapCode,
CARRIER = carrierName,
CARRIERID = carrierCode == "" ? null : carrierCode,
isBook = item.isBook,
IsFrontPort = item.IsFrontPort,
});
var status = string.Empty;
var IsBookingYZ = String.Empty;
if (item.IsFrontPort && item.isBook)
{
status = "订阅起运港,目的港";
IsBookingYZ = "3";
}
else if (item.IsFrontPort && item.isBook == false) {
status = "订阅起运港";
IsBookingYZ = "1";
}
else if (item.isBook && item.IsFrontPort == false)
{
status = "订阅目的港";
IsBookingYZ = "2";
}
else
{
IsBookingYZ = "0";
}
//if (!string.IsNullOrWhiteSpace(yardCode) && !string.IsNullOrWhiteSpace(carrierCode))
//{
// status = "订阅起运港,目的港";
// IsBookingYZ = "3";
//}
//else if (string.IsNullOrWhiteSpace(yardCode) && !string.IsNullOrWhiteSpace(carrierCode))
//{
// status = "订阅目的港";
// IsBookingYZ = "2";
//}
//else if (!string.IsNullOrWhiteSpace(yardCode) && string.IsNullOrWhiteSpace(carrierCode))
//{
// status = "订阅起运港";
// IsBookingYZ = "1";
//}
//else
//{
// IsBookingYZ = "0";
//}
//TODO 添加booking日志
//更新运踪标识
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == Convert.ToInt64(item.BusinessId));
info.IsBookingYZ = IsBookingYZ;
await tenantDb.Updateable(info).ExecuteCommandAsync();
}
billdto.Children = billTraceList;
billdto.Key = account.AppKey;
billdto.PWD = account.AppSecret;
billdto.url = resUrl;
billdto.Gid = account.RegistContractName;
billdto.PushBackKey = user.TenantId;//根据回传的租户Id回调
var json = billdto.ToJsonString();
var postData = new { msg = json };
if (!reqUrl.EndsWith("/"))
{
reqUrl += "/";
}
reqUrl += "BillTrace/SubcribeOrUpdateBilltrace";
var result = RequestHelper.Post(postData.ToJsonString(), reqUrl);
var res = JsonConvert.DeserializeObject<BillTraceRes>(result);
if (!res.Success)
{
return await Task.FromResult(DataResult<string>.Failed($"发起运踪订阅或者更新提单号失败:{res.Message}"));
}
else
{
return await Task.FromResult(DataResult<string>.Success(res.Data.ToJsonString()));
}
}
/// <summary>
/// 运踪退订
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public async Task<DataResult<string>> UnsubscribeBillTrace(List<BillTraceUnsubscribeList> req)
{
if (req.Count == 0)
{
return await Task.FromResult(DataResult<string>.Failed("未传入正确参数!"));
}
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//var userKey = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userKey" && x.TenantId == 1288018625843826688).First().Value;
//var userPwd = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userPwd" && x.TenantId == 1288018625843826688).First().Value;
//var userId = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "seae_billtraceurl_userId" && x.TenantId == 1288018625843826688).First().Value;
var reqUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "request_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var resUrl = db.Queryable<SysConfig>().Filter(null, true).Where(x => x.Code == "response_seae_billtraceurl" && x.TenantId == 1288018625843826688).First().Value;
var account = seaComService.GetCodeThirdParty("BillTraceSubcribe", user.UserId, tenantDb);
if (account.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("未配置运踪订阅第三方账号信息!"));
}
if (account.AppSecret.IsNull() || account.AppKey.IsNull() || account.RegistContractName.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed("请检查运踪订阅第三方账号关键参数!"));
}
BillTraceUnsubscribeDto reqDto = new BillTraceUnsubscribeDto()
{
Children = new List<BillTraceUnsubscribeList>(),
Key = account.AppKey,
PWD = account.AppSecret,
Gid = account.RegistContractName,
PushBackKey = user.TenantId,
};
foreach (var item in req)
{
if (string.IsNullOrEmpty(item.BusinessId))
{
return await Task.FromResult(DataResult<string>.Failed("订舱记录主键不能为空!!"));
}
reqDto.Children.Add(new BillTraceUnsubscribeList(item.BusinessId, item.MBLNO));
//TODO 添加booking日志
//更新运踪标识
var info = tenantDb.Queryable<SeaExport>().First(x => x.Id == Convert.ToInt64(item.BusinessId));
info.IsBookingYZ = "0";
await tenantDb.Updateable(info).ExecuteCommandAsync();
}
var json = reqDto.ToJsonString();
if (!reqUrl.EndsWith("/"))
{
reqUrl += "/";
}
reqUrl += "BillTrace/UnsubscribeBillTrace";
var postData = new { msg = json };
var result = RequestHelper.Post(postData.ToJsonString(), reqUrl);
var res = JsonConvert.DeserializeObject<BillTraceUnsubscribeRes>(result);
if (!res.Success)
{
return await Task.FromResult(DataResult<string>.Failed($"运踪退订失败:{res.Message}"));
}
else
{
return await Task.FromResult(DataResult<string>.Success(res.Data));
}
}
/// <summary>
/// 刷新运踪
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task<DataResult<string>> RefreshYunZong(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 jarrCZTemos = new JArray();
JArray jarrHLWTemos = new JArray();
JArray jarrYGTTemos = new JArray();
foreach (var item in order)
{
if (!string.IsNullOrEmpty(item.Yard) && !string.IsNullOrEmpty(item.MBLNO))
{
var yardMap = tenantDb.Queryable<MappingYard>().Where(x => x.LinkId == item.YardId && x.Module == "BillTrace").First();
if (yardMap.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed($"场站代号配置未找到:{item.Yard}"));
}
JObject jobjczTemp = new JObject();
jobjczTemp.Add("web_code", new JValue(yardMap.MapCode));
jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrCZTemos.Add(jobjczTemp);
}
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 (jarrCZTemos.Count > 0)
{
JObject CZjobjSend = new JObject();
CZjobjSend.Add("user_key", new JValue(key));
CZjobjSend.Add("user_secret", new JValue(secret));
CZjobjSend.Add("customer_id", new JValue(user.TenantId));
CZjobjSend.Add("customer_name", new JValue(user.TenantName));
CZjobjSend.Add("data_list", jarrCZTemos);
var json = CZjobjSend.ToJsonString();
_logger.Info("运踪查询场站参数:" + json);
var rtn = await RequestHelper.PostJsonAsyncNoHeaders(url, CZjobjSend.ToJsonString());
_logger.Info("运踪查询场站查询结果:" + rtn);
await ExecuteYard(rtn);
}
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.PostJsonAsyncNoHeaders(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.PostJsonAsyncNoHeaders(url, YGTjobjSend.ToJsonString());
_logger.Info("运踪查询YGT查询结果" + rtn);
await ExecuteYGT(rtn);
}
return await Task.FromResult(DataResult<string>.Success("刷新运踪成功!"));
}
/// <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.PostJsonAsyncNoHeaders(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.PostJsonAsyncNoHeaders(url, YGTjobjSend.ToJsonString());
_logger.Info("运踪查询YGT查询结果" + rtn);
await ExecuteYGT(rtn);
}
return await Task.FromResult(DataResult<string>.Success("刷新运踪成功!"));
}
2 months ago
/// <summary>
/// 刷新运踪(场站)
2 months ago
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public async Task<DataResult<string>> RefreshYard(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 jarrCZTemos = new JArray();
var listSync = new List<long>();
foreach (var item in order)
{
if (!string.IsNullOrEmpty(item.Yard) && !string.IsNullOrEmpty(item.MBLNO))
{
var yardMap = tenantDb.Queryable<MappingYard>().Where(x => x.LinkId == item.YardId && x.Module == "BillTrace").First();
if (yardMap.IsNull())
{
return await Task.FromResult(DataResult<string>.Failed($"场站代号配置未找到:{item.Yard}"));
}
JObject jobjczTemp = new JObject();
jobjczTemp.Add("web_code", new JValue(yardMap.MapCode));
jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim()));
jarrCZTemos.Add(jobjczTemp);
2 months ago
listSync.Add(item.Id);
}
}
if (jarrCZTemos.Count > 0)
{
JObject CZjobjSend = new JObject();
CZjobjSend.Add("user_key", new JValue(key));
CZjobjSend.Add("user_secret", new JValue(secret));
CZjobjSend.Add("customer_id", new JValue(user.TenantId));
CZjobjSend.Add("customer_name", new JValue(user.TenantName));
CZjobjSend.Add("data_list", jarrCZTemos);
var json = CZjobjSend.ToJsonString();
_logger.Info("运踪查询场站参数:" + json);
var rtn = await RequestHelper.PostJsonAsyncNoHeaders(url, CZjobjSend.ToJsonString());
_logger.Info("运踪查询场站查询结果:" + rtn);
await ExecuteYard(rtn);
}
return await Task.FromResult(DataResult<string>.Success("刷新运踪成功!"));
}
[NonAction]
//[SqlSugarUnitOfWork]
public async Task ExecuteYard(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($"请求爬虫获取【场站数据】出错:{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<YardDataDto> yarddto = new List<YardDataDto>();
if (jarrInnerData.Count == 0)
{
throw new Exception(item.GetStringValue("msg"));
}
DateTime? TimeCangDan = null;
DateTime? FangXingShiJian = null;
foreach (JObject dataItem in jarrInnerData)
{
var CNTRNO = dataItem.GetStringValue("CNTRNO"); //箱号
var TiXiangShiJian = dataItem.GetDateTimeValue("TiXiangShiJian"); //提箱时间
var FanChangShiJian = dataItem.GetDateTimeValue("FanChangShiJian"); //返厂时间
var XiangLiang = dataItem.GetIntValue("XiangLiang"); //箱量
yarddto.Add(new YardDataDto
{
CNTRNO = CNTRNO,
TiXiangShiJian = TiXiangShiJian,
FanChangShiJian = FanChangShiJian,
XiangLiang = XiangLiang,
});
}
var xl = yarddto.Select(x => x.XiangLiang).FirstOrDefault();
var tinum = yarddto.Where(x => x.TiXiangShiJian != null).Count();
var fcnum = yarddto.Where(x => x.FanChangShiJian != null).Count();
var oldLog = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == bookingId && x.Group == "yunzong" && (x.Status == "提箱" || x.Status == "返场")).ToListAsync();
if (oldLog.Count > 0)
{
var ids = oldLog.Select(x=>x.Id);
var logDetails = await tenantDb.Queryable<BookingStatusLogDetail>().Where(x => ids.Contains(x.PId)).ToListAsync();
if (logDetails.Count>0)
await tenantDb.Deleteable(logDetails).ExecuteCommandAsync();
2 months ago
await tenantDb.Deleteable(oldLog).ExecuteCommandAsync();
}
if (xl > 0 && tinum > 0)
2 months ago
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"提箱",
2 months ago
Group = "yunzong",
OpTime = xl == tinum ? yarddto.Select(x => x.TiXiangShiJian).Max() : null,
2 months ago
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
//发送服务状态
var pushModel = new EmbedServiceProjectStatusDto
2 months ago
{
businessId = bookingId.ToString(),
SourceType = 1,
StatusCodes = new List<EmbedServiceProjectStatusDetailDto> {
new EmbedServiceProjectStatusDetailDto{
StatusCode = "YTX",
SetActDate = bookingStatusLog.OpTime
}
}
};
var saveStatusRlt = await _djyServiceStatusService.SaveServiceStatus(pushModel);
_logger.Info("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JsonConvert.SerializeObject(pushModel), JsonConvert.SerializeObject(saveStatusRlt));
foreach (var dt in yarddto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail()
2 months ago
{
PId = bookingStatusLog.Id,
Status = "提箱",
CNTRNO = dt.CNTRNO,
OpTime = dt.TiXiangShiJian
2 months ago
};
await tenantDb.Insertable(BookingStatusLogDetail).ExecuteCommandAsync();
2 months ago
}
//await _bookingorderservice.AutoYardData(bookingId);
2 months ago
}
if (xl > 0 && fcnum > 0)
2 months ago
{
//新增数据
var bookingStatusLog = new BookingStatusLog()
{
BusinessId = bookingId,
Status = $"返场",
2 months ago
Group = "yunzong",
OpTime = xl == tinum ? yarddto.Select(x => x.FanChangShiJian).Max() : null,
2 months ago
MBLNO = mblno
};
await tenantDb.Insertable(bookingStatusLog).ExecuteCommandAsync();
//发送服务状态
var pushModel = new EmbedServiceProjectStatusDto
2 months ago
{
businessId = bookingId.ToString(),
SourceType = 1,
StatusCodes = new List<EmbedServiceProjectStatusDetailDto> {
new EmbedServiceProjectStatusDetailDto{
StatusCode = "YFANCHANG",
SetActDate = bookingStatusLog.OpTime
}
}
};
var saveStatusRlt = await _djyServiceStatusService.SaveServiceStatus(pushModel);
_logger.Info("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JsonConvert.SerializeObject(pushModel), JsonConvert.SerializeObject(saveStatusRlt));
foreach (var dt in yarddto)
{
var BookingStatusLogDetail = new BookingStatusLogDetail()
2 months ago
{
PId = bookingStatusLog.Id,
Status = "返场",
CNTRNO = dt.CNTRNO,
OpTime = dt.FanChangShiJian
2 months ago
};
await tenantDb.Insertable(BookingStatusLogDetail).ExecuteCommandAsync();
2 months ago
}
}
2 months ago
}
}
[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
}
}