|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using Myshipping.Application.Service.BookingYunZong.Dto;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 运踪模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "BookingYunZong", Order = 1)]
|
|
|
|
|
public class BookingYunZongService : IBookingYunZong, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<BookingYunZongService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly IDjyWebsiteAccountConfigService _account;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatusLog> _repStatuslog;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatusLogDetail> _statuslogdetail;
|
|
|
|
|
private readonly SqlSugarRepository<BookingStatus> _repBookingStatus;
|
|
|
|
|
private readonly IBookingOrderService _bookingorderservice;
|
|
|
|
|
private readonly IBookingValueAddedService _bookingValueAddedService;
|
|
|
|
|
public BookingYunZongService(ILogger<BookingYunZongService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService account, SqlSugarRepository<BookingStatus> repBookingStatus,
|
|
|
|
|
SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingStatusLog> repStatuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail, IBookingOrderService bookingorderservice, IBookingValueAddedService bookingValueAddedService)
|
|
|
|
|
{
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_account = account;
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_repStatuslog = repStatuslog;
|
|
|
|
|
_statuslogdetail = statuslogdetail;
|
|
|
|
|
_repBookingStatus = repBookingStatus;
|
|
|
|
|
_bookingorderservice = bookingorderservice;
|
|
|
|
|
_bookingValueAddedService = bookingValueAddedService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新运踪
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingYunZong/RefreshYunZong")]
|
|
|
|
|
public async Task RefreshYunZong(long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
|
|
|
|
|
if (order == null || order.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("存在未订阅单据");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(key))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关KEY,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(secret))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关SECRET,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JArray jarrCZTemos = new JArray();
|
|
|
|
|
JArray jarrHLWTemos = new JArray();
|
|
|
|
|
JArray jarrYGTTemos = new JArray();
|
|
|
|
|
foreach (var item in order)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(item.YARDID) && !string.IsNullOrEmpty(item.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var YARDID = _cache.GetAllMappingYard().Result.Where(x => x.Module == "BillTrace" && x.Code == item.YARDID).Select(x => x.MapCode).FirstOrDefault();
|
|
|
|
|
JObject jobjczTemp = new JObject();
|
|
|
|
|
jobjczTemp.Add("web_code", new JValue(YARDID));
|
|
|
|
|
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(UserManager.TENANT_ID));
|
|
|
|
|
CZjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
CZjobjSend.Add("data_list", jarrCZTemos);
|
|
|
|
|
var json = CZjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询场站参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(CZjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询场站查询结果:" + 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(UserManager.TENANT_ID));
|
|
|
|
|
HLWjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
HLWjobjSend.Add("data_list", jarrHLWTemos);
|
|
|
|
|
var json = HLWjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询HLW+参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(HLWjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询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(UserManager.TENANT_ID));
|
|
|
|
|
YGTjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
YGTjobjSend.Add("data_list", jarrYGTTemos);
|
|
|
|
|
var json = YGTjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询YGT参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(YGTjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询YGT查询结果:" + rtn);
|
|
|
|
|
await ExecuteYGT(rtn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新运踪(场站)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingYunZong/RefreshYard")]
|
|
|
|
|
public async Task RefreshYard(long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
|
|
|
|
|
if (order == null || order.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("存在未订阅单据");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(key))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关KEY,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(secret))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关SECRET,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JArray jarrCZTemos = new JArray();
|
|
|
|
|
var listSync = new List<long>();
|
|
|
|
|
foreach (var item in order)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(item.YARDID) && !string.IsNullOrEmpty(item.MBLNO))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var YARDID = _cache.GetAllMappingYard().Result.Where(x => x.Module == "BillTrace" && x.Code == item.YARDID).Select(x => x.MapCode).FirstOrDefault();
|
|
|
|
|
JObject jobjczTemp = new JObject();
|
|
|
|
|
jobjczTemp.Add("web_code", new JValue(YARDID));
|
|
|
|
|
jobjczTemp.Add("bno", new JValue(item.MBLNO.Trim()));
|
|
|
|
|
jarrCZTemos.Add(jobjczTemp);
|
|
|
|
|
|
|
|
|
|
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(UserManager.TENANT_ID));
|
|
|
|
|
CZjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
CZjobjSend.Add("data_list", jarrCZTemos);
|
|
|
|
|
var json = CZjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询场站参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(CZjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询场站查询结果:" + rtn);
|
|
|
|
|
await ExecuteYard(rtn);
|
|
|
|
|
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(listSync.ToArray());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新运踪(互联网和云港通)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/BookingYunZong/RefreshYGT")]
|
|
|
|
|
public async Task RefreshYGT(long[] Ids)
|
|
|
|
|
{
|
|
|
|
|
var order = await _rep.AsQueryable().Filter(null, true).Where(x => Ids.Contains(x.Id) && x.IsDeleted == false && x.ParentId == 0 && x.IsBookingYZ != "0").ToListAsync();
|
|
|
|
|
if (order == null || order.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("存在未订阅单据");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var key = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserKey").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(key))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关KEY,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
var url = _cache.GetAllDictData().Result.Where(x => x.Code == "billTraceYgtUrl").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
var secret = _cache.GetAllSysConfig().Result.Where(x => x.Code == "billTraceNewUserSecret").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
if (string.IsNullOrEmpty(secret))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("未获取到相关SECRET,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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(UserManager.TENANT_ID));
|
|
|
|
|
HLWjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
HLWjobjSend.Add("data_list", jarrHLWTemos);
|
|
|
|
|
var json = HLWjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询HLW+参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(HLWjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询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(UserManager.TENANT_ID));
|
|
|
|
|
YGTjobjSend.Add("customer_name", new JValue(UserManager.TENANT_NAME));
|
|
|
|
|
YGTjobjSend.Add("data_list", jarrYGTTemos);
|
|
|
|
|
var json = YGTjobjSend.ToJsonString();
|
|
|
|
|
_logger.LogInformation("运踪查询YGT参数:" + json);
|
|
|
|
|
var rtn = await url.SetHttpMethod(HttpMethod.Post).SetBody(YGTjobjSend.ToJsonString()).PostAsStringAsync();
|
|
|
|
|
_logger.LogInformation("运踪查询YGT查询结果:" + rtn);
|
|
|
|
|
await ExecuteYGT(rtn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task ExecuteYard(string rtn)
|
|
|
|
|
{
|
|
|
|
|
JObject jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
var code = jobjRtn.GetValue("code").ToString();
|
|
|
|
|
var msg = jobjRtn.GetValue("msg").ToString();
|
|
|
|
|
if (code != "200")
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"请求爬虫获取【场站数据】出错:{msg}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JArray jarrData = jobjRtn.GetValue("data") as JArray;
|
|
|
|
|
|
|
|
|
|
foreach (JObject item in jarrData)
|
|
|
|
|
{
|
|
|
|
|
//每票 货物
|
|
|
|
|
|
|
|
|
|
var mblno = item.GetValue("bno").ToString();
|
|
|
|
|
|
|
|
|
|
var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno && x.IsDeleted == false && x.ParentId == 0).Select(x => x.Id).FirstAsync();
|
|
|
|
|
var jarrInnerData = item.GetValue("data") as JArray;
|
|
|
|
|
List<YardDataDto> yarddto = new List<YardDataDto>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingId && x.Category == "yunzong" && x.IsDeleted == false && (x.Status == "提箱" || x.Status == "返场")).ToListAsync();
|
|
|
|
|
var oldid = old.Select(x => x.Id).ToList();
|
|
|
|
|
await _repStatuslog.DeleteAsync(x => oldid.Contains(x.Id));
|
|
|
|
|
await _statuslogdetail.DeleteAsync(x => oldid.Contains(x.PId));
|
|
|
|
|
|
|
|
|
|
if (xl > 0 && tinum > 0)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingId;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "提箱";
|
|
|
|
|
bookingStatusLog.OpTime = xl == tinum ? yarddto.Select(x => x.TiXiangShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
|
|
|
|
|
//发送服务状态
|
|
|
|
|
var pushModel = new ModifyServiceProjectStatusDto
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId,
|
|
|
|
|
SourceType = TrackingSourceTypeEnum.AUTO,
|
|
|
|
|
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
|
|
|
|
|
new ModifyServiceProjectStatusDetailDto { StatusCode = "YTX", SetActDate = bookingStatusLog.OpTime } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(pushModel);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt));
|
|
|
|
|
|
|
|
|
|
foreach (var dt in yarddto)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = bookingStatusLog.Id;
|
|
|
|
|
BookingStatusLogDetail.Status = "提箱";
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.TiXiangShiJian;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
}
|
|
|
|
|
await _bookingorderservice.AutoYardData(bookingId);
|
|
|
|
|
}
|
|
|
|
|
if (xl > 0 && fcnum > 0)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingId;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "返场";
|
|
|
|
|
bookingStatusLog.OpTime = xl == tinum ? yarddto.Select(x => x.FanChangShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
|
|
|
|
|
//发送服务状态
|
|
|
|
|
var pushModel = new ModifyServiceProjectStatusDto
|
|
|
|
|
{
|
|
|
|
|
BookingId = bookingId,
|
|
|
|
|
SourceType = TrackingSourceTypeEnum.AUTO,
|
|
|
|
|
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
|
|
|
|
|
new ModifyServiceProjectStatusDetailDto { StatusCode = "YFANCHANG", SetActDate = bookingStatusLog.OpTime } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(pushModel);
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation("请求JSON={json} 异步推送服务状态完成,结果={rlt}", JSON.Serialize(pushModel), JSON.Serialize(saveStatusRlt));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var dt in yarddto)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = bookingStatusLog.Id;
|
|
|
|
|
BookingStatusLogDetail.Status = "返场";
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.FanChangShiJian;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task ExecuteHLW(string rtn)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JObject jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
var code = jobjRtn.GetValue("code").ToString();
|
|
|
|
|
var msg = jobjRtn.GetValue("msg").ToString();
|
|
|
|
|
if (code != "200")
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"请求爬虫获取【HLW+数据】出错:{msg}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var dicdatalist = _cache.GetAllDictData().Result;
|
|
|
|
|
JArray jarrData = jobjRtn.GetValue("data") as JArray;
|
|
|
|
|
|
|
|
|
|
foreach (JObject item in jarrData)
|
|
|
|
|
{
|
|
|
|
|
//每票 货物
|
|
|
|
|
|
|
|
|
|
var mblno = item.GetValue("bno").ToString();
|
|
|
|
|
|
|
|
|
|
var bookingId = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno && x.IsDeleted == false && x.ParentId == 0).Select(x => x.Id).FirstAsync();
|
|
|
|
|
var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin<SysDictData>((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == bookingId).Select((d, t) => new
|
|
|
|
|
{
|
|
|
|
|
BookingId = d.BookingId,
|
|
|
|
|
StaCode = d.StaCode,
|
|
|
|
|
StaName = d.StaName,
|
|
|
|
|
StaTime = d.StaTime,
|
|
|
|
|
Code = t.Code,
|
|
|
|
|
Value = t.Value
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
var jarrInnerData = item.GetValue("data") as JArray;
|
|
|
|
|
|
|
|
|
|
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 == "报关"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (TimeCangDan != null)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingId;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "舱单";
|
|
|
|
|
bookingStatusLog.OpTime = TimeCangDan;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
if (list.Where(x => x.StaCode == "sta_cangdan").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingId;
|
|
|
|
|
bookingStatus.StaCode = "sta_cangdan";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_cangdan").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = TimeCangDan;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (FangXingShiJian != null)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingId;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "报关";
|
|
|
|
|
bookingStatusLog.OpTime = FangXingShiJian;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
if (list.Where(x => x.Code == "sta_haifang").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingId;
|
|
|
|
|
bookingStatus.StaCode = "sta_haifang";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_haifang").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = FangXingShiJian;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
await _bookingorderservice.SetGoodsStatus("BG", bookingId);
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { bookingId });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NonAction]
|
|
|
|
|
//[SqlSugarUnitOfWork]
|
|
|
|
|
public async Task ExecuteYGT(string rtn)
|
|
|
|
|
{
|
|
|
|
|
JObject jobjRtn = JObject.Parse(rtn);
|
|
|
|
|
var code = jobjRtn.GetValue("code").ToString();
|
|
|
|
|
var msg = jobjRtn.GetValue("msg").ToString();
|
|
|
|
|
if (code != "200")
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"请求爬虫获取【YGT数据】出错:{msg}");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var dicdatalist = _cache.GetAllDictData().Result;
|
|
|
|
|
JArray jarrData = jobjRtn.GetValue("data") as JArray;
|
|
|
|
|
|
|
|
|
|
foreach (JObject item in jarrData)
|
|
|
|
|
{
|
|
|
|
|
//每票 货物
|
|
|
|
|
var mblno = item.GetValue("bno").ToString();
|
|
|
|
|
|
|
|
|
|
var bookingOrder = await _rep.AsQueryable().Filter(null, true).Where(x => x.MBLNO == mblno && x.IsDeleted == false && x.ParentId == 0).FirstAsync();
|
|
|
|
|
var list = await _repBookingStatus.AsQueryable().Filter(null, true).InnerJoin<SysDictData>((d, t) => d.StaCode == t.Code && d.StaCate == "book_sta_cate_billtrace" && d.BookingId == bookingOrder.Id).Select((d, t) => new
|
|
|
|
|
{
|
|
|
|
|
BookingId = d.BookingId,
|
|
|
|
|
StaCode = d.StaCode,
|
|
|
|
|
StaName = d.StaName,
|
|
|
|
|
StaTime = d.StaTime,
|
|
|
|
|
Code = t.Code,
|
|
|
|
|
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 old = await _repStatuslog.AsQueryable().Filter(null, true).Where(x => x.BookingId == bookingOrder.Id && x.Category == "yunzong" && x.IsDeleted == false && (x.Status == "运抵" || x.Status == "装载" || x.Status == "外理" || x.Status == "码放" || x.Status == "装船" || x.Status == "入港" || x.Status == "ATD")).ToListAsync();
|
|
|
|
|
var oldid = old.Select(x => x.Id).ToList();
|
|
|
|
|
await _repStatuslog.DeleteAsync(x => oldid.Contains(x.Id));
|
|
|
|
|
await _statuslogdetail.DeleteAsync(x => oldid.Contains(x.PId));
|
|
|
|
|
|
|
|
|
|
if (xl > 0 && rgnum > 0)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "入港";
|
|
|
|
|
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.RuGangShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
|
|
|
|
|
foreach (var dt in ygtdto)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = bookingStatusLog.Id;
|
|
|
|
|
BookingStatusLogDetail.Status = "入港";
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.RuGangShiJian;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
}
|
|
|
|
|
if (list.Where(x => x.Code == "sta_rugang").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatus.StaCode = "sta_rugang";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_rugang").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = xl == ydnum ? ygtdto.Select(x => x.RuGangShiJian).Max() : null;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
await _bookingorderservice.SetGoodsStatus("YRG", bookingOrder.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (xl > 0 && ydnum > 0)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "运抵";
|
|
|
|
|
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.YunDiShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
|
|
|
|
|
foreach (var dt in ygtdto)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = bookingStatusLog.Id;
|
|
|
|
|
BookingStatusLogDetail.Status = "运抵";
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.YunDiShiJian;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xl > 0 && zznum > 0 && zznum == xl)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "装载";
|
|
|
|
|
bookingStatusLog.OpTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
if (list.Where(x => x.Code == "sta_zhuangzai").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatus.StaCode = "sta_zhuangzai";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangzai").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = xl == zznum ? ygtdto.Select(x => x.ZhuangzhaiShiJian).Max() : null;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
await _bookingorderservice.SetGoodsStatus("ZZFX", bookingOrder.Id);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (xl > 0 && wlnum > 0 && wlnum == xl)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "外理";
|
|
|
|
|
bookingStatusLog.OpTime = null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xl > 0 && mfnum > 0 && mfnum == xl)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "码放";
|
|
|
|
|
bookingStatusLog.OpTime = null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
if (list.Where(x => x.Code == "sta_mafang").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatus.StaCode = "sta_mafang";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_mafang").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = null;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
await _bookingorderservice.SetGoodsStatus("MTFX", bookingOrder.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (xl > 0 && zcnum > 0)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "装船";
|
|
|
|
|
bookingStatusLog.OpTime = xl == ydnum ? ygtdto.Select(x => x.ZhuangChuanShiJian).Max() : null;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
|
|
|
|
|
foreach (var dt in ygtdto)
|
|
|
|
|
{
|
|
|
|
|
var BookingStatusLogDetail = new BookingStatusLogDetail();
|
|
|
|
|
BookingStatusLogDetail.PId = bookingStatusLog.Id;
|
|
|
|
|
BookingStatusLogDetail.Status = "装船";
|
|
|
|
|
BookingStatusLogDetail.CNTRNO = dt.CNTRNO;
|
|
|
|
|
BookingStatusLogDetail.OPTime = dt.ZhuangChuanShiJian;
|
|
|
|
|
await _statuslogdetail.InsertAsync(BookingStatusLogDetail);
|
|
|
|
|
}
|
|
|
|
|
if (list.Where(x => x.Code == "sta_zhuangchuan").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatus.StaCode = "sta_zhuangchuan";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_zhuangchuan").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = xl == ydnum ? ygtdto.Select(x => x.ZhuangChuanShiJian).Max() : null;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (SJLGShiJian != null)
|
|
|
|
|
{
|
|
|
|
|
//新增数据
|
|
|
|
|
var bookingStatusLog = new BookingStatusLog();
|
|
|
|
|
bookingStatusLog.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatusLog.Category = "yunzong";
|
|
|
|
|
bookingStatusLog.CreatedTime = DateTime.Now;
|
|
|
|
|
bookingStatusLog.Status = "ATD";
|
|
|
|
|
bookingStatusLog.OpTime = SJLGShiJian;
|
|
|
|
|
bookingStatusLog.MBLNO = mblno;
|
|
|
|
|
await _repStatuslog.InsertAsync(bookingStatusLog);
|
|
|
|
|
if (list.Where(x => x.Code == "sta_atd").FirstOrDefault() == null)
|
|
|
|
|
{
|
|
|
|
|
BookingStatus bookingStatus = new BookingStatus();
|
|
|
|
|
bookingStatus.BookingId = bookingOrder.Id;
|
|
|
|
|
bookingStatus.StaCode = "sta_atd";
|
|
|
|
|
bookingStatus.StaName = dicdatalist.Where(x => x.Code == "sta_atd").Select(x => x.Value).FirstOrDefault();
|
|
|
|
|
bookingStatus.StaTime = SJLGShiJian;
|
|
|
|
|
bookingStatus.StaCate = "book_sta_cate_billtrace";
|
|
|
|
|
await _repBookingStatus.InsertAsync(bookingStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool open = false;
|
|
|
|
|
//ATD
|
|
|
|
|
if (SJLGShiJian != null && bookingOrder.ATD != SJLGShiJian)
|
|
|
|
|
{
|
|
|
|
|
var oldorder = bookingOrder;
|
|
|
|
|
bookingOrder.ATD = SJLGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { ATD = SJLGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(bookingOrder, oldorder, "刷新运踪");
|
|
|
|
|
open = true;
|
|
|
|
|
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var it in neworder)
|
|
|
|
|
{
|
|
|
|
|
var _oldorder = it.Adapt<BookingOrder>();
|
|
|
|
|
if (it.ATD != SJLGShiJian)
|
|
|
|
|
{
|
|
|
|
|
it.ATD = SJLGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { ATD = SJLGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(it, _oldorder, "刷新运踪");
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ETA
|
|
|
|
|
if (YJDGShiJian != null && bookingOrder.StartETA != YJDGShiJian)
|
|
|
|
|
{
|
|
|
|
|
var oldorder = bookingOrder;
|
|
|
|
|
bookingOrder.StartETA = YJDGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { StartETA = YJDGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(bookingOrder, oldorder, "刷新运踪");
|
|
|
|
|
open = true;
|
|
|
|
|
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var it in neworder)
|
|
|
|
|
{
|
|
|
|
|
var _oldorder = it.Adapt<BookingOrder>();
|
|
|
|
|
if (it.StartETA != YJDGShiJian)
|
|
|
|
|
{
|
|
|
|
|
it.StartETA = YJDGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { StartETA = YJDGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(it, _oldorder, "刷新运踪");
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ATA
|
|
|
|
|
if (SJDGShiJian != null && bookingOrder.StartATA != SJDGShiJian)
|
|
|
|
|
{
|
|
|
|
|
var oldorder = bookingOrder;
|
|
|
|
|
bookingOrder.StartATA = SJDGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { StartATA = SJDGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(bookingOrder, oldorder, "刷新运踪");
|
|
|
|
|
open = true;
|
|
|
|
|
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var it in neworder)
|
|
|
|
|
{
|
|
|
|
|
var _oldorder = it.Adapt<BookingOrder>();
|
|
|
|
|
if (it.StartATA != SJDGShiJian)
|
|
|
|
|
{
|
|
|
|
|
it.StartATA = SJDGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { StartATA = SJDGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(it, _oldorder, "刷新运踪");
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ETD
|
|
|
|
|
if (YJLGShiJian != null && bookingOrder.YgtETD != YJLGShiJian)
|
|
|
|
|
{
|
|
|
|
|
var oldorder = bookingOrder;
|
|
|
|
|
bookingOrder.YgtETD = YJLGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == bookingOrder.Id, x => new BookingOrder { YgtETD = YJLGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(bookingOrder, oldorder, "刷新运踪");
|
|
|
|
|
open = true;
|
|
|
|
|
if (!string.IsNullOrEmpty(bookingOrder.VESSEL) && !string.IsNullOrEmpty(bookingOrder.VOYNO) && !string.IsNullOrEmpty(bookingOrder.CARRIERID))
|
|
|
|
|
{
|
|
|
|
|
var neworder = await _rep.AsQueryable().Filter(null, true).Where(x => x.VOYNO == bookingOrder.VOYNO && x.VESSEL == bookingOrder.VESSEL && x.CARRIERID == bookingOrder.CARRIERID && x.TenantId == bookingOrder.TenantId && x.IsDeleted == false && x.Id != bookingOrder.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var it in neworder)
|
|
|
|
|
{
|
|
|
|
|
var _oldorder = it.Adapt<BookingOrder>();
|
|
|
|
|
if (it.YgtETD != YJLGShiJian)
|
|
|
|
|
{
|
|
|
|
|
it.YgtETD = YJLGShiJian;
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == it.Id, x => new BookingOrder { YgtETD = YJLGShiJian });
|
|
|
|
|
await _bookingorderservice.SaveLog(it, _oldorder, "刷新运踪");
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { it.Id });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (open)
|
|
|
|
|
{
|
|
|
|
|
await _bookingorderservice.SendBookingOrder(new long[] { bookingOrder.Id });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|