|
|
|
@ -20,6 +20,9 @@ using Furion.FriendlyException;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -33,13 +36,20 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _repCtn;
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtnDetail> _ctndetailrep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLog> _bookinglog;
|
|
|
|
|
private readonly SqlSugarRepository<BookingLogDetail> _bookinglogdetail;
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<BookingOrderService> _logger;
|
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep, ILogger<BookingOrderService> logger)
|
|
|
|
|
public BookingOrderService(SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn, SqlSugarRepository<BookingCtnDetail> ctndetailrep,
|
|
|
|
|
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail,
|
|
|
|
|
ILogger<BookingOrderService> logger)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
|
this._repCtn = repCtn;
|
|
|
|
|
this._ctndetailrep = ctndetailrep;
|
|
|
|
|
this._bookinglog = bookinglog;
|
|
|
|
|
this._bookinglogdetail = bookinglogdetail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -50,6 +60,7 @@ namespace Myshipping.Application
|
|
|
|
|
[HttpGet("/BookingOrder/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] BookingOrderInput input)
|
|
|
|
|
{
|
|
|
|
|
List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
|
|
|
|
|
var entities = await _rep.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.BSSTATUS), u => u.BSSTATUS == input.BSSTATUS)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.MBLNO), u => input.MBLNO.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Contains(u.MBLNO))
|
|
|
|
@ -171,6 +182,7 @@ namespace Myshipping.Application
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.LANECODE), u => u.LANECODE == input.LANECODE)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER.Contains(input.FREIGHTPAYER))
|
|
|
|
|
.Where(u => userlist.Contains((long)u.CreatedUserId))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
return entities.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
@ -203,24 +215,29 @@ namespace Myshipping.Application
|
|
|
|
|
await _ctndetailrep.InsertAsync(ctndetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////添加booking日志
|
|
|
|
|
await _bookinglog.InsertAsync(new BookingLog
|
|
|
|
|
{
|
|
|
|
|
Type = "Add",
|
|
|
|
|
BookingId = entity.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除订舱
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[SqlSugarUnitOfWork]
|
|
|
|
|
[HttpPost("/BookingOrder/delete")]
|
|
|
|
|
public async Task Delete(long Id)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
await _rep.UpdateAsync(x => x.Id == Id, x => new BookingOrder { IsDeleted = true });
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
await _repCtn.UpdateAsync(x => x.BILLID == Id, x => new BookingCtn { IsDeleted = true });
|
|
|
|
|
|
|
|
|
|
await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
|
|
|
|
|
_logger.LogInformation(Id + "删除成功!");
|
|
|
|
|
}
|
|
|
|
@ -234,6 +251,12 @@ namespace Myshipping.Application
|
|
|
|
|
[HttpPost("/BookingOrder/Update")]
|
|
|
|
|
public async Task Update(UpdateBookingOrderInput input)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
JsonUtil.PropToUpper(input, "ORDNO", "BSSTATUS", "YardContract", "YardContractTel", "YardContractEmail");
|
|
|
|
|
JsonUtil.TrimFields(input);
|
|
|
|
|
var groupList = input.ctnInputs.Where(x => x.CTNNUM > 0).GroupBy(c => c.CTNALL).Select(g => $"{g.Key}*{g.Sum(gg => gg.CTNNUM)}");
|
|
|
|
|
input.CNTRTOTAL = string.Join(" / ", groupList);
|
|
|
|
|
var main = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
|
|
|
var entity = input.Adapt<BookingOrder>();
|
|
|
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync();
|
|
|
|
@ -251,12 +274,58 @@ namespace Myshipping.Application
|
|
|
|
|
await _ctndetailrep.InsertAsync(ctndetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool flag = true;
|
|
|
|
|
long bid = 0;
|
|
|
|
|
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(entity))
|
|
|
|
|
{
|
|
|
|
|
string name = descriptor.Name;
|
|
|
|
|
if (name == "TenantId" || name == "CreatedTime" || name == "UpdatedTime" || name == "CreatedUserId" || name == "CreatedUserName")
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
object value = descriptor.GetValue(entity);
|
|
|
|
|
var oldvalue = main.GetType().GetProperty(name).GetValue(main, null);
|
|
|
|
|
|
|
|
|
|
if (name == "KGS" || name == "CBM")
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToDecimal(value) == Convert.ToDecimal(oldvalue))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string _oldvalue = oldvalue != null ? oldvalue.ToString() : "";
|
|
|
|
|
string _value = value != null ? value.ToString() : "";
|
|
|
|
|
if (_oldvalue != _value)
|
|
|
|
|
{
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
////添加booking日志
|
|
|
|
|
bid = await _bookinglog.InsertReturnSnowflakeIdAsync(new BookingLog
|
|
|
|
|
{
|
|
|
|
|
Type = "Edit",
|
|
|
|
|
BookingId = entity.Id,
|
|
|
|
|
TenantId = Convert.ToInt64(UserManager.TENANT_ID),
|
|
|
|
|
CreatedTime = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserManager.UserId,
|
|
|
|
|
CreatedUserName = UserManager.Name
|
|
|
|
|
});
|
|
|
|
|
flag = false;
|
|
|
|
|
}
|
|
|
|
|
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
|
|
|
|
|
{
|
|
|
|
|
PId = bid,
|
|
|
|
|
Field = name,
|
|
|
|
|
OldValue = _oldvalue,
|
|
|
|
|
NewValue = _value,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取订舱明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/Get")]
|
|
|
|
|
public async Task<BookingOrderOutput> Get(long Id)
|
|
|
|
@ -277,5 +346,26 @@ namespace Myshipping.Application
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取日志明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/BookingOrder/GetLog")]
|
|
|
|
|
public async Task<BookingLogDto> GetLog(long Id)
|
|
|
|
|
{
|
|
|
|
|
BookingLogDto list = new BookingLogDto();
|
|
|
|
|
var main = await _bookinglog.FirstOrDefaultAsync(u => u.BookingId== Id);
|
|
|
|
|
if (main != null)
|
|
|
|
|
{
|
|
|
|
|
list = main.Adapt<BookingLogDto>();
|
|
|
|
|
var details = await _bookinglogdetail.AsQueryable().Where(x => x.PId == main.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
list.details = details;
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|