海运出口日志部分

usertest
cjy 4 months ago
parent 9f115f2bda
commit 9e952c2fd9

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AnyDiff" Version="1.0.99" />
<PackageReference Include="Autofac" Version="8.0.0" /> <PackageReference Include="Autofac" Version="8.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" /> <PackageReference Include="AutoMapper" Version="12.0.1" />

@ -0,0 +1,47 @@
using DS.WMS.Core.Op.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Dtos
{
/// <summary>
///
/// </summary>
public class SeaExportSaveLog
{
/// <summary>
/// 操作方式:新增(Create)、更新(Update)、删除(Delete)
/// </summary>
public string OperateType { get; set; } = "Update";
/// <summary>
/// 旧值
/// </summary>
public SeaExport OldOrder { get; set; }
/// <summary>
/// 新值
/// </summary>
public SeaExport NewOrder { get; set; }
/// <summary>
/// 业务来源代码
/// </summary>
public string SourceCode { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public string SourceName { get; set; }
/// <summary>
///
/// </summary>
public List<string> UpdateFields { get; set; }
}
}

@ -14,6 +14,12 @@ namespace DS.WMS.Core.Op.Interface
{ {
public interface ISeaExportCommonService public interface ISeaExportCommonService
{ {
/// <summary>
/// 海运出口差异日志
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task SaveSeaExportLog(SeaExportSaveLog req);
/// <summary> /// <summary>
/// 获取第三方账户 /// 获取第三方账户
/// </summary> /// </summary>

@ -1,5 +1,4 @@
using Amazon.S3.Model; using DS.Module.Core;
using DS.Module.Core;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
using DS.Module.UserModule; using DS.Module.UserModule;
@ -15,17 +14,18 @@ using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Sys.Interface;
using LanguageExt.Pipes; using LanguageExt.Pipes;
using Mapster; using Mapster;
using Masuit.Tools;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NLog; using NLog;
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.Formula.Functions;
using SqlSugar; using SqlSugar;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Logger = NLog.Logger; using Logger = NLog.Logger;
using AnyDiff.Extensions;
namespace DS.WMS.Core.Op.Method namespace DS.WMS.Core.Op.Method
{ {
@ -53,6 +53,78 @@ namespace DS.WMS.Core.Op.Method
_environment = _serviceProvider.GetRequiredService<IWebHostEnvironment>(); _environment = _serviceProvider.GetRequiredService<IWebHostEnvironment>();
} }
/// <summary>
/// 忽略的字段
/// </summary>
private static readonly List<string> IgnoreColumns = new List<string>()
{
"CreateTime",
"CreateUserName",
"CreateBy",
"UpdateTime",
"UpdateUserName",
"UpdateBy",
"DeleteTime",
"DeleteUserName",
"DeleteBy",
"TenantId",
"TenantName",
};
public async Task SaveSeaExportLog(SeaExportSaveLog req) {
bool flag = true;
long bid = 0;
var diff = req.NewOrder.Diff(req.OldOrder);
//var obj1 = new { Name = "Tom", Age = 20 };
//var obj2 = new { Name = "Jerry", Age = 21 };
//var diff = obj1.Diff(obj2).ToList();
foreach (var change in diff)
{
Console.WriteLine($"{change.PropertyType} - {change.Property}: {change.LeftValue} => {change.RightValue}");
}
//foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(req.NewOrder))
//{
// //基础字段不记录
// string name = descriptor.Name;
// if (IgnoreColumns.Contains(name))
// {
// continue;
// }
// // 如果已经明确了被修改的字段,且当前字段不在其中,则跳过
// if (req.UpdateFields.IsNotNull() && !req.UpdateFields.Contains(name))
// {
// continue;
// }
// object value = descriptor.GetValue(req.NewOrder);
// var oldvalue = req.OldOrder.GetType().GetProperty(name).GetValue(req.OldOrder, 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 && !string.IsNullOrWhiteSpace(descriptor.Description))
// {
// var data = new OpBusinessLog()
// {
// BusinessId = req.OldOrder.Id,
// OldValue = JsonConvert.SerializeObject(req.OldOrder),
// NewValue= JsonConvert.SerializeObject(req.NewOrder),
// };
// }
//}
}
#region 获取客户结算方式及结算日期 #region 获取客户结算方式及结算日期

@ -520,6 +520,7 @@ public partial class SeaExportService : ISeaExportService
{ {
return await Task.FromResult(DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock)); return await Task.FromResult(DataResult.Failed("海运出口信息业务已锁定!", MultiLanguageConst.SeaExportBusinessLock));
} }
var oldOrder = info;
info = req.Adapt(info); info = req.Adapt(info);
//TODO 会计期间不允许小于已结转期间 //TODO 会计期间不允许小于已结转期间
if (info.CloseDocDate.IsNotNull() && info.CloseDocDate > info.ETD) if (info.CloseDocDate.IsNotNull() && info.CloseDocDate > info.ETD)
@ -554,6 +555,15 @@ public partial class SeaExportService : ISeaExportService
await dbScope.Ado.BeginTranAsync(); await dbScope.Ado.BeginTranAsync();
info.Note = "正常编辑"; info.Note = "正常编辑";
await tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommandAsync(); await tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommandAsync();
await seaComService.SaveSeaExportLog(new SeaExportSaveLog()
{
OperateType = "Update",
OldOrder = oldOrder,
NewOrder = info,
SourceCode = "NormalEdit",
SourceName = "正常编辑",
});
//处理订单联系人信息 //处理订单联系人信息
DealBusinessOrderContact(info, tenantDb); DealBusinessOrderContact(info, tenantDb);

Loading…
Cancel
Save