optimize
wet 1 year ago
parent a154299693
commit 9dbfaec6cb

@ -977,6 +977,16 @@ namespace Myshipping.Application
}
}
if (!string.IsNullOrWhiteSpace(input.CUSTNO))
{
var et = await _rep.AsQueryable().Filter(null, true).Where(x => x.IsDeleted == false && x.CUSTNO == input.CUSTNO && x.TenantId == UserManager.TENANT_ID && x.HBLNO == input.HBLNO && x.ParentId == input.ParentId && x.Id != input.Id).FirstAsync();
if (et != null)
{
throw Oops.Bah("当前提单号已存在,请勿重复录入!");
}
}
var entity = input.Adapt<BookingOrder>();
if (input.Id == 0)
{
@ -1170,169 +1180,123 @@ namespace Myshipping.Application
var Id = entity.Id;
BookingOrderOutput ordOut = new BookingOrderOutput();
var main = await _rep.FirstOrDefaultAsync(u => u.Id == Id);
if (main != null)
{
ordOut = main.Adapt<BookingOrderOutput>();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var item in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
ordOut.ctnInputs = ctninput;
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
if (ordUrl != null)
{
ordOut.Link = new BookingOrderUrlOutput()
{
LinkUrlTxxp = ordUrl.UrlTxxp,
LinkUrlVgm = ordUrl.UrlVgm,
LinkUrlVmgSi = ordUrl.UrlVgmSi,
};
}
}
List<BookingOrderDto> HbList = new List<BookingOrderDto>();
var _hblist = await _rep.AsQueryable().Where(x => x.ParentId == Id).ToListAsync();
if (_hblist != null)
{
HbList = _hblist.Adapt<List<BookingOrderDto>>();
foreach (var item in HbList)
{
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == item.Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var it in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == it.Id).ToListAsync();
it.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
item.ctnInputs = ctninput;
//检索EDI扩展
var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == item.Id);
if (ediExt != null)
{
item.BookingEDIExt = ediExt.Adapt<BookingEDIExtDto>();
}
}
ordOut.HbList = HbList;
}
//检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == Id);
if (ediExtEntity != null)
{
ordOut.BookingEDIExt = ediExtEntity.Adapt<BookingEDIExtDto>();
}
if (!string.IsNullOrEmpty(entity.MBLNO) || string.IsNullOrEmpty(entity.CUSTNO))
{
#region 插入货运动态
//配置中所有的货物状态
var config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == main.CreatedUserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{
var config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == main.CreatedUserId).ToList().DistinctBy(x => x.StatusName).ToList();
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = null,
FinishUser = null,
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null,
Sort = config.Sort
}).ToList();
if (config.Count()==0)
if (config.Count() == 0)
{
_GoodsConfig.InitGoodsStatusConfig((long)main.CreatedUserId, main.CreatedUserName);
config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == main.CreatedUserId).ToList().DistinctBy(x => x.StatusName).Select(config => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = null,
FinishUser = null,
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null,
Sort = config.Sort
}).ToList();
config = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(config => config.CreatedUserId == main.CreatedUserId).ToList().DistinctBy(x => x.StatusName).ToList();
if (!string.IsNullOrEmpty(entity.MBLNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YSDBC").Select(x => x.ConfigId).FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == Config.Id);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
ConfigId = Config.Id,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
main.BSSTATUSNAME = Config.StatusName;
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
if (!string.IsNullOrEmpty(entity.CUSTNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YDC").Select(x => x.ConfigId).FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == Config.Id);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
ConfigId = Config.Id,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
main.BSSTATUSNAME = Config.StatusName;
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
}
else
{
if (!string.IsNullOrEmpty(entity.MBLNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YSDBC").Select(x => x.ConfigId).FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
var Config = config.Where(x => x.SystemCode == "YSDBC").FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == Config.Id);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
ConfigId = Config.Id,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
IsPublic = false
});
}
main.BSSTATUSNAME = Config.StatusName;
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
if (!string.IsNullOrEmpty(entity.CUSTNO))
{
var ConfigId = config.Where(x => x.SystemCode == "YDC").Select(x => x.ConfigId).FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == ConfigId);
var Config = config.Where(x => x.SystemCode == "YDC").FirstOrDefault();
var Status = _goodsStatus.FirstOrDefault(x => x.bookingId == Id && x.ConfigId == Config.Id);
if (Status == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = Id,
ConfigId = ConfigId,
ConfigId = Config.Id,
FinishTime = DateTime.Now,
FinishUser = UserManager.Name,
FinishUserId = UserManager.UserId,
@ -1340,11 +1304,24 @@ namespace Myshipping.Application
});
}
main.BSSTATUSNAME = Config.StatusName;
await _rep.AsUpdateable(main).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
}
#endregion
@ -1352,6 +1329,63 @@ namespace Myshipping.Application
}
if (main != null)
{
ordOut = main.Adapt<BookingOrderOutput>();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var item in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == item.Id).ToListAsync();
item.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
ordOut.ctnInputs = ctninput;
var ordUrl = _repOrderUrl.FirstOrDefault(x => x.BookingId == Id);
if (ordUrl != null)
{
ordOut.Link = new BookingOrderUrlOutput()
{
LinkUrlTxxp = ordUrl.UrlTxxp,
LinkUrlVgm = ordUrl.UrlVgm,
LinkUrlVmgSi = ordUrl.UrlVgmSi,
};
}
}
List<BookingOrderDto> HbList = new List<BookingOrderDto>();
var _hblist = await _rep.AsQueryable().Where(x => x.ParentId == Id).ToListAsync();
if (_hblist != null)
{
HbList = _hblist.Adapt<List<BookingOrderDto>>();
foreach (var item in HbList)
{
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == item.Id).ToListAsync();
var ctninput = ctnlist.Adapt<List<BookingCtnDto>>();
foreach (var it in ctninput)
{
var ctndetaillist = await _ctndetailrep.AsQueryable().Where(x => x.CTNID == it.Id).ToListAsync();
it.ctnDetailInputs = ctndetaillist.Adapt<List<BookingCtnDetailDto>>();
}
item.ctnInputs = ctninput;
//检索EDI扩展
var ediExt = _bookingEDIExt.FirstOrDefault(u => u.BookingId == item.Id);
if (ediExt != null)
{
item.BookingEDIExt = ediExt.Adapt<BookingEDIExtDto>();
}
}
ordOut.HbList = HbList;
}
//检索EDI扩展
var ediExtEntity = _bookingEDIExt.FirstOrDefault(u => u.BookingId == Id);
if (ediExtEntity != null)
{
ordOut.BookingEDIExt = ediExtEntity.Adapt<BookingEDIExtDto>();
}
List<long> arr = new List<long>();
@ -2483,7 +2517,8 @@ namespace Myshipping.Application
{
var url = _cache.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "response_seae_billtraceRefreshurl").Value;
if (string.IsNullOrEmpty(url)) {
if (string.IsNullOrEmpty(url))
{
throw Oops.Bah("未找到相关URL,请联系管理员配置");
}
var html = await url.SetHttpMethod(HttpMethod.Post).SetQueries(new { Ids = Ids, flag = true }).SetRetryPolicy(3, 5000).SendAsAsync<RespCommon>();
@ -2634,7 +2669,7 @@ namespace Myshipping.Application
{
var o = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.BookingId).First();
var oldatd = o == null ? null : o.ATD;
if (oldatd != item.OpTime&& item.OpTime!=null)
if (oldatd != item.OpTime && item.OpTime != null)
{
o.ATD = item.OpTime;
await _rep.UpdateAsync(o);
@ -2693,6 +2728,51 @@ namespace Myshipping.Application
}
}
#endregion
#region 入港时间
if (item.Status == "入港")
{
var order = _rep.AsQueryable().Filter(null, true).Where(x => x.Id == item.BookingId).ToList().FirstOrDefault();
var goodconfig = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(x => x.CreatedUserId == order.CreatedUserId && x.SystemCode == "YRG").ToList().FirstOrDefault();
if (goodconfig==null)
{
_GoodsConfig.InitGoodsStatusConfig((long)order.CreatedUserId, order.CreatedUserName);
goodconfig = _goodsStatusConfig.AsQueryable().Filter(null, true).Where(x => x.CreatedUserId == order.CreatedUserId && x.SystemCode == "YRG").ToList().FirstOrDefault();
}
var St = _goodsStatus.AsQueryable().Filter(null, true).Where(x => x.bookingId == item.BookingId && x.ConfigId == goodconfig.Id).ToList().FirstOrDefault();
if (St == null)
{
await _goodsStatus.InsertAsync(new BookingGoodsStatus
{
bookingId = item.BookingId,
ConfigId = goodconfig.Id,
FinishTime = DateTime.Now,
FinishUser = order.CreatedUserName,
FinishUserId = order.CreatedUserId,
IsPublic = false
});
order.BSSTATUSNAME = goodconfig.StatusName;
await _rep.AsUpdateable(order).IgnoreColumns(it => new
{
it.ParentId,
it.TenantId,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.TenantName,
it.IsDeleted,
it.BOOKINGNO
}).ExecuteCommandAsync();
}
}
#endregion
}
}
#endregion
@ -5187,11 +5267,27 @@ namespace Myshipping.Application
ICell cell = row.GetCell(5);
if (cell != null)
{
row.Cells[5].SetCellValue(order.MBLNO);
if (string.IsNullOrEmpty(order.MBLNO))
{
row.Cells[5].SetCellValue(order.CUSTNO);
}
else {
row.Cells[5].SetCellValue(order.MBLNO);
}
}
else
{
row.CreateCell(5).SetCellValue(order.MBLNO);
if (string.IsNullOrEmpty(order.MBLNO))
{
row.CreateCell(5).SetCellValue(order.CUSTNO);
}
else
{
row.CreateCell(5).SetCellValue(order.MBLNO);
}
}
}
if (i == 8)

@ -264,11 +264,11 @@ public static class JsonUtil
return "货描存在中文字符";
}
//if (Regex.IsMatch(sourceVal.ToString(), @"[\u4e00-\u9fa5]") && propName.ToUpper() == "BOOKINGNO")
//{
// return "订舱编号存在中文字符";
if (Regex.IsMatch(sourceVal.ToString(), @"[\u4e00-\u9fa5]") && propName.ToUpper() == "CUSTNO")
{
return "订舱编号存在中文字符";
//}
}
//if (Regex.IsMatch(sourceVal.ToString(), @"[\u4e00-\u9fa5]") && propName.ToUpper() == "PONO")
//{
// return "PONO存在中文字符";

Loading…
Cancel
Save