booking_auth_dev
wanghaomei 2 years ago
commit 243f6915a9

@ -14,6 +14,7 @@ namespace Myshipping.Application.Entity
/// <summary> /// <summary>
/// 单据ID /// 单据ID
/// </summary> /// </summary>
[Description("单据ID")]
public long? BILLID { get; set; } public long? BILLID { get; set; }
/// <summary> /// <summary>
/// 箱型 /// 箱型

@ -0,0 +1,47 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
///
/// </summary>
[SugarTable("bookinglog")]
[Description("舱单日志信息")]
public class BookingLog
{
/// <summary>
/// 单据ID
/// </summary>
[SugarColumn(ColumnDescription = "Id主键", IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 操作类型(新增,编辑)
/// </summary>
public string Type { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreatedTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long CreatedUserId { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
public string CreatedUserName { get; set; }
/// <summary>
/// 业务id
/// </summary>
public long BookingId { get; set; }
}
}

@ -0,0 +1,39 @@
using System;
using SqlSugar;
using System.ComponentModel;
using Myshipping.Core.Entity;
namespace Myshipping.Application.Entity
{
/// <summary>
///
/// </summary>
[SugarTable("bookinglog_detail")]
[Description("舱单日志详情")]
public class BookingLogDetail
{
/// <summary>
/// 单据ID
/// </summary>
[SugarColumn(ColumnDescription = "Id主键", IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// PID
/// </summary>
public long PId { get; set; }
/// <summary>
/// 字段
/// </summary>
public string Field { get; set; }
/// <summary>
/// 原值
/// </summary>
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
public string NewValue { get; set; }
}
}

@ -179,6 +179,76 @@
备注 备注
</summary> </summary>
</member> </member>
<member name="T:Myshipping.Application.Entity.BookingLog">
<summary>
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.Id">
<summary>
单据ID
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.Type">
<summary>
操作类型(新增,编辑)
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.TenantId">
<summary>
租户Id
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.CreatedTime">
<summary>
创建时间
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.CreatedUserId">
<summary>
创建者Id
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.CreatedUserName">
<summary>
创建者名称
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLog.BookingId">
<summary>
创建者名称
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingLogDetail">
<summary>
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLogDetail.Id">
<summary>
单据ID
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLogDetail.PId">
<summary>
PID
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLogDetail.Field">
<summary>
字段
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLogDetail.OldValue">
<summary>
原值
</summary>
</member>
<member name="P:Myshipping.Application.Entity.BookingLogDetail.NewValue">
<summary>
新值
</summary>
</member>
<member name="T:Myshipping.Application.Entity.BookingOrder"> <member name="T:Myshipping.Application.Entity.BookingOrder">
<summary> <summary>

@ -20,6 +20,9 @@ using Furion.FriendlyException;
using Furion.Logging; using Furion.Logging;
using System; using System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Reflection;
using System.ComponentModel;
using Myshipping.Application.Service.BookingOrder.Dto;
namespace Myshipping.Application namespace Myshipping.Application
{ {
@ -33,13 +36,20 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingCtn> _repCtn; private readonly SqlSugarRepository<BookingCtn> _repCtn;
private readonly SqlSugarRepository<BookingCtnDetail> _ctndetailrep; private readonly SqlSugarRepository<BookingCtnDetail> _ctndetailrep;
private readonly SqlSugarRepository<BookingLog> _bookinglog;
private readonly SqlSugarRepository<BookingLogDetail> _bookinglogdetail;
private readonly ILogger<BookingOrderService> _logger; 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._logger = logger;
this._rep = rep; this._rep = rep;
this._repCtn = repCtn; this._repCtn = repCtn;
this._ctndetailrep = ctndetailrep; this._ctndetailrep = ctndetailrep;
this._bookinglog = bookinglog;
this._bookinglogdetail = bookinglogdetail;
} }
/// <summary> /// <summary>
@ -50,6 +60,7 @@ namespace Myshipping.Application
[HttpGet("/BookingOrder/page")] [HttpGet("/BookingOrder/page")]
public async Task<dynamic> Page([FromQuery] BookingOrderInput input) public async Task<dynamic> Page([FromQuery] BookingOrderInput input)
{ {
List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
var entities = await _rep.AsQueryable() var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.BSSTATUS), u => u.BSSTATUS == input.BSSTATUS) .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)) .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.LANECODE), u => u.LANECODE == input.LANECODE)
.WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME)) .WhereIF(!string.IsNullOrWhiteSpace(input.LANENAME), u => u.LANENAME.Contains(input.LANENAME))
.WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER.Contains(input.FREIGHTPAYER)) .WhereIF(!string.IsNullOrWhiteSpace(input.FREIGHTPAYER), u => u.FREIGHTPAYER.Contains(input.FREIGHTPAYER))
.Where(u => userlist.Contains((long)u.CreatedUserId))
.ToPagedListAsync(input.PageNo, input.PageSize); .ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult(); return entities.XnPagedResult();
} }
@ -203,24 +215,29 @@ namespace Myshipping.Application
await _ctndetailrep.InsertAsync(ctndetail); 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>
/// 删除订舱 /// 删除订舱
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="Id"></param>
/// <returns></returns> /// <returns></returns>
[SqlSugarUnitOfWork] [SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/delete")] [HttpPost("/BookingOrder/delete")]
public async Task Delete(long Id) 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(); 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 _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 }); await _ctndetailrep.UpdateAsync(x => ctnlist.Contains((long)x.CTNID), x => new BookingCtnDetail { IsDeleted = true });
_logger.LogInformation(Id + "删除成功!"); _logger.LogInformation(Id + "删除成功!");
} }
@ -234,6 +251,12 @@ namespace Myshipping.Application
[HttpPost("/BookingOrder/Update")] [HttpPost("/BookingOrder/Update")]
public async Task Update(UpdateBookingOrderInput input) 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>(); var entity = input.Adapt<BookingOrder>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
var ctnlist = await _repCtn.AsQueryable().Where(x => x.BILLID == input.Id).Select(x => x.Id).ToListAsync(); 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); 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>
/// 获取订舱明细 /// 获取订舱明细
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="Id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/BookingOrder/Get")] [HttpGet("/BookingOrder/Get")]
public async Task<BookingOrderOutput> Get(long Id) public async Task<BookingOrderOutput> Get(long Id)
@ -277,5 +346,26 @@ namespace Myshipping.Application
} }
return list; 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;
}
} }
} }

@ -0,0 +1,46 @@
using Myshipping.Application.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Service.BookingOrder.Dto
{
public class BookingLogDto
{
public long Id { get; set; }
/// <summary>
/// 操作类型(新增,编辑)
/// </summary>
public string Type { get; set; }
/// <summary>
/// 租户Id
/// </summary>
public long TenantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreatedTime { get; set; }
/// <summary>
/// 创建者Id
/// </summary>
public long CreatedUserId { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
public string CreatedUserName { get; set; }
/// <summary>
/// 创建者名称
/// </summary>
public long BookingId { get; set; }
public List<BookingLogDetail> details { get; set; }
}
}

@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks; using System.Threading.Tasks;
using Myshipping.Application.Entity; using Myshipping.Application.Entity;
using Myshipping.Application.Service.BookingOrder.Dto;
namespace Myshipping.Application namespace Myshipping.Application
{ {
public interface IBookingOrderService public interface IBookingOrderService
@ -12,6 +14,6 @@ namespace Myshipping.Application
Task Update(UpdateBookingOrderInput input); Task Update(UpdateBookingOrderInput input);
Task<BookingOrderOutput> Get(long Id); Task<BookingOrderOutput> Get(long Id);
Task<dynamic> Page([FromQuery] BookingOrderInput input); Task<dynamic> Page([FromQuery] BookingOrderInput input);
Task<BookingLogDto> GetLog(long Id);
} }
} }
Loading…
Cancel
Save