货物状态更新时保存编码

dev
zhangxiaofeng 2 months ago
parent f4eaf9b3ce
commit 6c118d52a1

@ -81,7 +81,7 @@ namespace DS.WMS.Core.Op.Method
{ {
var diff = req.NewOrder.Diff(req.OldOrder); var diff = req.NewOrder.Diff(req.OldOrder);
var log = new OpBusinessLog() var log = new OpBusinessLog()
{ {
BusinessId = req.NewOrder.Id, BusinessId = req.NewOrder.Id,
@ -162,7 +162,7 @@ namespace DS.WMS.Core.Op.Method
} }
} }
#endregion #endregion
#region 获取客户结算方式及结算日期 #region 获取客户结算方式及结算日期
public DataResult<CustomerStlRes> GetCustomerStlInfo(CustomerStlReq req) public DataResult<CustomerStlRes> GetCustomerStlInfo(CustomerStlReq req)
@ -183,14 +183,15 @@ namespace DS.WMS.Core.Op.Method
{ {
return DataResult<CustomerStlRes>.Failed("开船日期格式不正确!"); return DataResult<CustomerStlRes>.Failed("开船日期格式不正确!");
} }
var accDate = tenantDb.Queryable<InfoClientAccountDate>().First(x=>x.ClientId == req.CustomerId && etd >= x.BeginDate && etd <= x.EndDate); var accDate = tenantDb.Queryable<InfoClientAccountDate>().First(x => x.ClientId == req.CustomerId && etd >= x.BeginDate && etd <= x.EndDate);
if (accDate.IsNull()) if (accDate.IsNull())
{ {
return DataResult<CustomerStlRes>.Success(new CustomerStlRes() { return DataResult<CustomerStlRes>.Success(new CustomerStlRes()
StlName ="票结", {
StlDate = req.ETD, StlName = "票结",
AccountDate = Convert.ToDateTime(req.ETD).ToString("yyyy-MM") StlDate = req.ETD,
AccountDate = Convert.ToDateTime(req.ETD).ToString("yyyy-MM")
}); });
} }
if (accDate.AccountType == "月结") if (accDate.AccountType == "月结")
@ -262,7 +263,7 @@ namespace DS.WMS.Core.Op.Method
}); });
} }
else if (accDate.AccountType == "半月结") else if (accDate.AccountType == "半月结")
{ {
var tmpYear = etd.Year; var tmpYear = etd.Year;
var tmpMonth = etd.Month; var tmpMonth = etd.Month;
var tmpDay = etd.Day; var tmpDay = etd.Day;
@ -277,11 +278,12 @@ namespace DS.WMS.Core.Op.Method
if (tmpDay2 < (int)accDate.AccountDays) if (tmpDay2 < (int)accDate.AccountDays)
{ {
tmpDay = tmpDay2; tmpDay = tmpDay2;
} }
} }
stlDate = DateTime.Parse(tmpYear.ToString() + "-" + tmpMonth.ToString() + "-" + tmpDay.ToString()); stlDate = DateTime.Parse(tmpYear.ToString() + "-" + tmpMonth.ToString() + "-" + tmpDay.ToString());
} }
else { else
{
tmpDay = (int)accDate.AccountMonth; tmpDay = (int)accDate.AccountMonth;
if ((int)accDate.AccountMonth > 28) if ((int)accDate.AccountMonth > 28)
@ -292,11 +294,11 @@ namespace DS.WMS.Core.Op.Method
if (tmpDay2 < (int)accDate.AccountMonth) if (tmpDay2 < (int)accDate.AccountMonth)
{ {
tmpDay = tmpDay2; tmpDay = tmpDay2;
} }
} }
stlDate = DateTime.Parse(tmpYear.ToString() + "-" + tmpMonth.ToString() + "-" + accDate.AccountMonth.ToString()).AddMonths(1); stlDate = DateTime.Parse(tmpYear.ToString() + "-" + tmpMonth.ToString() + "-" + accDate.AccountMonth.ToString()).AddMonths(1);
} }
return DataResult<CustomerStlRes>.Success(new CustomerStlRes() return DataResult<CustomerStlRes>.Success(new CustomerStlRes()
{ {
StlName = accDate.AccountType, StlName = accDate.AccountType,
@ -305,8 +307,8 @@ namespace DS.WMS.Core.Op.Method
}); });
} }
else if (accDate.AccountType == "季结") else if (accDate.AccountType == "季结")
{ {
stlDate = etd.AddDays((int)accDate.AccountMonth*90); stlDate = etd.AddDays((int)accDate.AccountMonth * 90);
return DataResult<CustomerStlRes>.Success(new CustomerStlRes() return DataResult<CustomerStlRes>.Success(new CustomerStlRes()
{ {
StlName = accDate.AccountType, StlName = accDate.AccountType,
@ -351,7 +353,7 @@ namespace DS.WMS.Core.Op.Method
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<CodeEdiSet> GetAllEdiSet() public List<CodeEdiSet> GetAllEdiSet()
{ {
var data = db.Queryable<CodeEdiSet>().Where(x => x.Status == StatusEnum.Enable).ToList(); var data = db.Queryable<CodeEdiSet>().Where(x => x.Status == StatusEnum.Enable).ToList();
return data; return data;
} }
@ -381,14 +383,14 @@ namespace DS.WMS.Core.Op.Method
/// <param name="tenantDb"></param> /// <param name="tenantDb"></param>
/// <param name="customerId"></param> /// <param name="customerId"></param>
/// <returns></returns> /// <returns></returns>
public CodeThirdParty GetCodeThirdParty(string type,string userId, SqlSugarScopeProvider tenantDb,long customerId =0) public CodeThirdParty GetCodeThirdParty(string type, string userId, SqlSugarScopeProvider tenantDb, long customerId = 0)
{ {
//var account = new CodeThirdParty(); //var account = new CodeThirdParty();
if (userId.IsNull()) if (userId.IsNull())
{ {
return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type) ; return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type);
} }
var uId = long.Parse(userId); var uId = long.Parse(userId);
if (customerId == 0) if (customerId == 0)
@ -408,7 +410,7 @@ namespace DS.WMS.Core.Op.Method
{ {
return tenantDb.Queryable<CodeThirdParty>().Where(x => x.AccountType == type && x.CreateBy == uId && x.CustomerId == customerId).First(); return tenantDb.Queryable<CodeThirdParty>().Where(x => x.AccountType == type && x.CreateBy == uId && x.CustomerId == customerId).First();
} }
else if(tenantDb.Queryable<CodeThirdParty>().Where(x => x.AccountType == type && x.CreateBy == uId).Any()) else if (tenantDb.Queryable<CodeThirdParty>().Where(x => x.AccountType == type && x.CreateBy == uId).Any())
{ {
return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type && x.CreateBy == uId); return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type && x.CreateBy == uId);
} }
@ -417,7 +419,7 @@ namespace DS.WMS.Core.Op.Method
return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type); return tenantDb.Queryable<CodeThirdParty>().First(x => x.AccountType == type);
} }
} }
//return account; //return account;
} }
/// <summary> /// <summary>
@ -447,7 +449,7 @@ namespace DS.WMS.Core.Op.Method
} }
} }
/// <summary> /// <summary>
/// 获取场站代码 /// 获取场站代码
/// </summary> /// </summary>
@ -473,7 +475,7 @@ namespace DS.WMS.Core.Op.Method
/// <param name="tenantDb"></param> /// <param name="tenantDb"></param>
/// <returns></returns> /// <returns></returns>
public EDIMapperInfo GetYardMapper(long Id, SqlSugarScopeProvider tenantDb) public EDIMapperInfo GetYardMapper(long Id, SqlSugarScopeProvider tenantDb)
{ {
var yard = tenantDb.Queryable<InfoClient>().First(v => v.Id == Id && v.Status == StatusEnum.Enable.ToEnumInt()); var yard = tenantDb.Queryable<InfoClient>().First(v => v.Id == Id && v.Status == StatusEnum.Enable.ToEnumInt());
if (yard.IsNull()) if (yard.IsNull())
@ -482,7 +484,7 @@ namespace DS.WMS.Core.Op.Method
} }
var code = yard.EDICode.IsNull() ? yard.CodeName : yard.EDICode; var code = yard.EDICode.IsNull() ? yard.CodeName : yard.EDICode;
var map= tenantDb.Queryable<MappingYard>().Where(v => v.Code == code).Select<EDIMapperInfo>().First(); var map = tenantDb.Queryable<MappingYard>().Where(v => v.Code == code).Select<EDIMapperInfo>().First();
if (map.IsNull()) if (map.IsNull())
{ {
@ -539,7 +541,7 @@ namespace DS.WMS.Core.Op.Method
/// <param name="tenantDb"></param> /// <param name="tenantDb"></param>
/// <returns></returns> /// <returns></returns>
public string GetPortCode(long Id, SqlSugarScopeProvider tenantDb) public string GetPortCode(long Id, SqlSugarScopeProvider tenantDb)
{ {
if (Id == 0) if (Id == 0)
return ""; return "";
var port = tenantDb.Queryable<CodePort>().First(v => v.Id == Id && v.Status == StatusEnum.Enable); var port = tenantDb.Queryable<CodePort>().First(v => v.Id == Id && v.Status == StatusEnum.Enable);
@ -951,7 +953,7 @@ namespace DS.WMS.Core.Op.Method
//更新货物状态 //更新货物状态
await SetBookingOrderGoodsStatus(bookingId, tenantDb); await SetBookingOrderGoodsStatus(bookingId, tenantDb);
} }
} }
} }
/// <summary> /// <summary>
@ -959,14 +961,14 @@ namespace DS.WMS.Core.Op.Method
/// </summary> /// </summary>
/// <param name="bookingId"></param> /// <param name="bookingId"></param>
/// <returns></returns> /// <returns></returns>
public async Task SetBookingOrderGoodsStatus(long bookingId,SqlSugarScopeProvider tenantDb) public async Task SetBookingOrderGoodsStatus(long bookingId, SqlSugarScopeProvider tenantDb)
{ {
//var tenantDb = saasService.GetBizDbScopeById(user.TenantId); //var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = tenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == bookingId); var order = tenantDb.Queryable<SeaExport>().Filter(null, true).First(x => x.Id == bookingId);
//获取当前用户已经录入的货物状态 //获取当前用户已经录入的货物状态
var list = await tenantDb.Queryable<BookingGoodsStatus>().LeftJoin(tenantDb.Queryable<BookingGoodsStatusConfig>(), var list = await tenantDb.Queryable<BookingGoodsStatus>().LeftJoin(tenantDb.Queryable<BookingGoodsStatusConfig>(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => goods.BusinessId == bookingId). (goods, config) => config.Id == goods.ConfigId).Where((goods, config) => goods.BusinessId == bookingId).
OrderBy((goods, config) => config.OrderNo). OrderBy((goods, config) => config.OrderNo).
Select((goods, config) => new Select((goods, config) => new
{ {
@ -984,15 +986,20 @@ namespace DS.WMS.Core.Op.Method
if (list != null) if (list != null)
{ {
//回写主单状态 //回写主单状态
var StatusName = list.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.OrderNo).Select(x => x.StatusName).FirstOrDefault(); var status = list.Where(x => x.FinishTime.HasValue).OrderByDescending(x => x.OrderNo).Select(x => new { x.SystemCode, x.StatusName }).FirstOrDefault();
if (StatusName == null) if (status == null)
{ {
StatusName = ""; status = new
{
SystemCode = "",
StatusName = ""
};
} }
var oldOrder = order.Adapt<SeaExport>(); var oldOrder = order.Adapt<SeaExport>();
order.BusinessStatusName = StatusName; order.BusinessStatusName = status.StatusName;
order.BusinessStatus = status.SystemCode;
//order.Note = "更新主单货物状态"; //order.Note = "更新主单货物状态";
await tenantDb.Updateable(order).EnableDiffLogEvent().ExecuteCommandAsync(); await tenantDb.Updateable(order).UpdateColumns(x => new { x.BusinessStatusName, x.BusinessStatus }).EnableDiffLogEvent().ExecuteCommandAsync();
// 记录日志 // 记录日志
await SaveSeaExportLogAsync(new SeaExportSaveLog() await SaveSeaExportLogAsync(new SeaExportSaveLog()
{ {
@ -2055,13 +2062,14 @@ namespace DS.WMS.Core.Op.Method
/// </summary> /// </summary>
/// <param name="req"></param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> SeaExportOpenEdit(SeaExportOpenEditReq req) public async Task<DataResult> SeaExportOpenEdit(SeaExportOpenEditReq req)
{ {
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var order = tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).First(); var order = tenantDb.Queryable<SeaExport>().Where(x => x.Id == req.Id).First();
if (order.IsNull()) { if (order.IsNull())
{
return await Task.FromResult(DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist)); return await Task.FromResult(DataResult.Failed("海运出口信息不存在!", MultiLanguageConst.SeaExportNotExist));
} }

Loading…
Cancel
Save