zhangxiaofeng 2 months ago
commit ca170e4dc7

@ -1,4 +1,5 @@
using SqlSugar;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -10,6 +11,10 @@ namespace DS.WMS.Core.Op.Dtos
{
public class OpBusinessLogRes
{
/// <summary>
/// 详情
/// </summary>
public List<OpBusinessLogDetail> Details { get; set; }
/// <summary>
/// 主键Id
/// </summary>
@ -23,18 +28,18 @@ namespace DS.WMS.Core.Op.Dtos
/// </summary>
public string OperateType { get; set; }
/// <summary>
/// 旧值
/// </summary>
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
public string NewValue { get; set; }
/// <summary>
/// 差异数据
/// </summary>
public string DiffData { get; set; }
///// <summary>
///// 旧值
///// </summary>
//public string OldValue { get; set; }
///// <summary>
///// 新值
///// </summary>
//public string NewValue { get; set; }
///// <summary>
///// 差异数据
///// </summary>
//public string DiffData { get; set; }
/// <summary>
/// 业务来源代码

@ -803,7 +803,7 @@ public class SeaExportReq
/// <summary>
/// Desc:清关日期
/// </summary>
public DateTime ClearCustomDate { get; set; }
public DateTime? ClearCustomDate { get; set; }
/// <summary>
/// Desc:报检项目
@ -916,7 +916,7 @@ public class SeaExportReq
/// 交货日期
/// </summary>
public DateTime DeliveryDate { get; set; }
public DateTime? DeliveryDate { get; set; }
/// <summary>
/// 场站联系人

@ -25,21 +25,21 @@ namespace DS.WMS.Core.Op.Entity
[SugarColumn(ColumnDescription = "操作方式:新增(Create)、更新(Update)、删除(Delete) ",IsNullable = false,Length =20)]
public string OperateType { get; set; }
/// <summary>
/// 旧值
/// </summary>
[SugarColumn(ColumnDescription = "旧值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
[SugarColumn(ColumnDescription = "新值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string NewValue { get; set; }
/// <summary>
/// 差异数据
/// </summary>
[SugarColumn(ColumnDescription = "差异数据", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string DiffData { get; set; }
///// <summary>
///// 旧值
///// </summary>
//[SugarColumn(ColumnDescription = "旧值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
//public string OldValue { get; set; }
///// <summary>
///// 新值
///// </summary>
//[SugarColumn(ColumnDescription = "新值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
//public string NewValue { get; set; }
///// <summary>
///// 差异数据
///// </summary>
//[SugarColumn(ColumnDescription = "差异数据", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
//public string DiffData { get; set; }
/// <summary>
/// 业务来源代码

@ -0,0 +1,45 @@
using DS.Module.Core.Data;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.WMS.Core.Op.Entity
{
/// <summary>
/// 业务日志明细
/// </summary>
[SqlSugar.SugarTable("op_business_log_detail", "业务日志明细")]
public class OpBusinessLogDetail
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 上级id
/// </summary>
[SugarColumn(ColumnDescription = "上级id")]
public long? Pid { get; set; }
/// <summary>
/// 字段
/// </summary>
[SugarColumn(ColumnDescription = "字段", IsNullable = true, Length = 100)]
public string FieldValue { get; set; }
/// <summary>
/// 旧值
/// </summary>
[SugarColumn(ColumnDescription = "旧值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
[SugarColumn(ColumnDescription = "新值", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string NewValue { get; set; }
}
}

File diff suppressed because it is too large Load Diff

@ -57,6 +57,9 @@ using Microsoft.VisualBasic.FileIO;
using Microsoft.Extensions.Logging;
using AnyDiff.Extensions;
using DS.WMS.Core.Sys.Entity;
using LanguageExt;
using Masuit.Tools.Models;
using System.ComponentModel;
namespace DS.WMS.Core.Op.Method
{
@ -4525,36 +4528,73 @@ namespace DS.WMS.Core.Op.Method
{
var diff = req.NewOrder.Diff(req.OldOrder);
StringBuilder sb = new StringBuilder();
foreach (var item in diff)
{
Console.WriteLine($"{item.PropertyType} - {item.Property}: {item.LeftValue} => {item.RightValue}");
//StringBuilder sb = new StringBuilder();
//foreach (var item in diff)
//{
// Console.WriteLine($"{item.PropertyType} - {item.Property}: {item.LeftValue} => {item.RightValue}");
if (item.LeftValue.IsNotNull() && item.RightValue.IsNotNull())
{
if (IgnoreColumns.Contains(item.Property))
continue;
if (!item.LeftValue.Equals(item.RightValue))
{
sb.Append($"[字段:{item.Property},修改前:{item.LeftValue},修改后:{item.RightValue}]");
}
}
}
// if (item.LeftValue.IsNotNull() && item.RightValue.IsNotNull())
// {
// if (IgnoreColumns.Contains(item.Property))
// continue;
// if (!item.LeftValue.Equals(item.RightValue))
// {
// sb.Append($"[字段:{item.Property},修改前:{item.LeftValue},修改后:{item.RightValue}]");
// }
// }
//}
var log = new OpBusinessLog()
{
BusinessId = req.NewOrder.Id,
OperateType = "Update",
OldValue = JsonConvert.SerializeObject(req.OldOrder),
NewValue = JsonConvert.SerializeObject(req.NewOrder),
DiffData = sb.ToString(),
//OldValue = JsonConvert.SerializeObject(req.OldOrder),
//NewValue = JsonConvert.SerializeObject(req.NewOrder),
//DiffData = sb.ToString(),
SourceCode = req.SourceCode,
SourceName = req.SourceName,
};
await tenantDb.Insertable(log).ExecuteCommandAsync();
//await tenantDb.Insertable(log).ExecuteCommandAsync();
var logId = await tenantDb.Insertable(log).ExecuteReturnEntityAsync();
var detail = new List<OpBusinessLogDetail>();
var list = TypeDescriptor.GetProperties(req.NewOrder);
foreach (PropertyDescriptor descriptor in list)
{
string name = descriptor.Name;
if (IgnoreColumns.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))
{
detail.Add(new OpBusinessLogDetail()
{
Pid = logId.Id,
OldValue = _oldvalue,
NewValue = _value,
FieldValue = descriptor.Description,
});
}
}
if (detail.Count > 0)
{
await tenantDb.Insertable(detail).ExecuteCommandAsync();
}
}
#endregion
}

@ -30,6 +30,8 @@ using static AnyDiff.DifferenceLines;
using Newtonsoft.Json;
using Masuit.Tools.Hardware;
using DS.Module.Core.Data;
using Masuit.Tools.Models;
using System.ComponentModel;
namespace DS.WMS.Core.Op.Method
{
@ -79,36 +81,86 @@ namespace DS.WMS.Core.Op.Method
{
var diff = req.NewOrder.Diff(req.OldOrder);
StringBuilder sb = new StringBuilder();
foreach (var item in diff)
{
Console.WriteLine($"{item.PropertyType} - {item.Property}: {item.LeftValue} => {item.RightValue}");
if (item.LeftValue.IsNotNull() && item.RightValue.IsNotNull())
{
if (IgnoreColumns.Contains(item.Property))
continue;
if (!item.LeftValue.Equals(item.RightValue))
{
sb.Append($"[字段:{item.Property},修改前:{item.LeftValue},修改后:{item.RightValue}]");
}
}
}
var log = new OpBusinessLog()
{
BusinessId = req.NewOrder.Id,
OperateType = "Update",
OldValue = JsonConvert.SerializeObject(req.OldOrder),
NewValue = JsonConvert.SerializeObject(req.NewOrder),
DiffData = sb.ToString(),
SourceCode = req.SourceCode,
SourceName = req.SourceName,
};
var logId = await tenantDb.Insertable(log).ExecuteReturnEntityAsync();
var detail = new List<OpBusinessLogDetail>();
var list = TypeDescriptor.GetProperties(req.NewOrder);
//foreach (var item in diff)
//{
// Console.WriteLine($"{item.PropertyType} - {item.Property}: {item.LeftValue} => {item.RightValue}");
// if (!item.LeftValue.Equals(item.RightValue))
// {
// if (IgnoreColumns.Contains(item.Property))
// continue;
// var des = string.Empty;
// foreach (PropertyDescriptor descriptor in list)
// {
// string name = descriptor.Name;
// if (!name.Equals(item.Property))
// {
// continue;
// }
// else
// {
// des = string.IsNullOrEmpty(descriptor.Description)? item.Property : descriptor.Description;
// }
// }
// detail.Add(new OpBusinessLogDetail()
// {
// Pid = logId.Id,
// OldValue = item.LeftValue.ToString(),
// NewValue = item.RightValue.ToString(),
// FieldValue = des,
// });
// }
//}
foreach (PropertyDescriptor descriptor in list)
{
string name = descriptor.Name;
if (IgnoreColumns.Contains(name))
{
continue;
}
object value = descriptor.GetValue(req.NewOrder);
var oldvalue = req.OldOrder.GetType().GetProperty(name).GetValue(req.OldOrder, null);
await tenantDb.Insertable(log).ExecuteCommandAsync();
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))
{
detail.Add(new OpBusinessLogDetail()
{
Pid = logId.Id,
OldValue = _oldvalue,
NewValue = _value,
FieldValue = descriptor.Description,
});
}
}
if (detail.Count > 0)
{
await tenantDb.Insertable(detail).ExecuteCommandAsync();
}
}
#endregion
#region 获取客户结算方式及结算日期

@ -314,7 +314,7 @@ public partial class SeaExportService : ISeaExportService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
await ex.LogAsync(tenantDb);
await ex.LogAsync(db);
return await Task.FromResult(DataResult.Failed("添加失败!" + ",请联系管理员!"));
}
}
@ -488,7 +488,7 @@ public partial class SeaExportService : ISeaExportService
catch (Exception ex)
{
await dbScope.Ado.RollbackTranAsync();
await ex.LogAsync(tenantDb);
await ex.LogAsync(db);
return await Task.FromResult(DataResult.Failed("更新失败!" + ",请联系管理员!"));
}
}
@ -510,16 +510,28 @@ public partial class SeaExportService : ISeaExportService
GoodName = seaExport.GoodsName,
HSCode = seaExport.HSCode
};
var checkInfo = sqlSugarScope.Queryable<CodeGoods>().Where(x => x.HSCode == seaExport.HSCode && x.GoodName ==seaExport.GoodsName).First();
if (checkInfo.IsNotNull())
{
return checkInfo.Id;
}
else
{
var entity = sqlSugarScope.Insertable(data).RemoveDataCache($"{SqlSugarCacheConst.Goods}{user.TenantId}").ExecuteReturnEntityAsync();
seaExport.GoodsId = entity.Id;
return entity.Id;
}
}
else
{
var info = sqlSugarScope.Queryable<CodeGoods>().Where(x => x.Id == seaExport.GoodsId).First();
if (info.IsNull())
{
throw new Exception("商品信息不存在!");
}
info.GoodName = seaExport.GoodsName;
info.HSCode = seaExport.HSCode;
@ -742,7 +754,13 @@ public partial class SeaExportService : ISeaExportService
//it.FormSetList = tenantDb.Queryable<CodeFormSet>().Where(x => x.PermissionName == "海运出口-详情").Select<CodeFormSetRes>().ToList();
it.BusinessLogList = tenantDb.Queryable<OpBusinessLog>().Where(x => x.BusinessId == it.Id).Select<OpBusinessLogRes>().ToList();
it.BusinessLogList = tenantDb.Queryable<OpBusinessLog>().Where(x => x.BusinessId == it.Id)
.Select<OpBusinessLogRes>()
.Mapper(a =>
{
a.Details = tenantDb.Queryable<OpBusinessLogDetail>().Where(x => x.Pid == a.Id).ToList();
})
.ToList();
it.OrderContactList = tenantDb.Queryable<BusinessOrderContact>().Where(x => x.BusinessId == it.Id).Select<BusinessOrderContactRes>().ToList();

@ -56,7 +56,7 @@ public interface IUserService
/// 查询客户端 用户拥有的菜单权限
/// </summary>
/// <returns></returns>
public Task<DataResult<List<RouteItem>>> GetClientUserPermissions();
public Task<DataResult<List<RouteItem>>> GetClientUserPermissions(string id);
/// <summary>

@ -120,7 +120,7 @@ public class ClientCommonService : IClientCommonService
var data = await tenantDb.Queryable<InfoClient>()
.InnerJoin<InfoClientTag>((a, b) => a.Id == b.ClientId)
.Where((a, b) => a.Status == StatusEnum.Enable.ToEnumInt() && b.IsController == true)
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey))
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
.Select((a, b) => new ControllerClientRes
{
Id = a.Id,
@ -1219,7 +1219,7 @@ public class ClientCommonService : IClientCommonService
.WhereIF(!string.IsNullOrEmpty(code) && code == "shipagency", (a, b) => b.IsShipAgency == true)
.WhereIF(!string.IsNullOrEmpty(code) && code == "enterprise", (a, b) => b.IsEnterprise == true)
.WhereIF(!string.IsNullOrEmpty(code) && code == "contract", (a, b) => b.IsContract == true)
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey))
.WhereIF(!string.IsNullOrEmpty(queryKey), (a, b) => a.CodeName.Contains(queryKey) || a.ShortName.Contains(queryKey) || a.Description.Contains(queryKey))
.Select((a, b) => new ClientSelectRes
{
Id = a.Id,

@ -25,6 +25,7 @@ public class SequenceService : ISequenceService
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
/// <summary>
@ -52,7 +53,7 @@ public class SequenceService : ISequenceService
if (req.Id == 0)
{
if (db.Queryable<SysSequence>().Where(x => x.PermissionId == req.PermissionId && x.OrderNo == req.OrderNo).Any())
if (db.Queryable<SysSequence>().Where(x => x.PermissionId == req.PermissionId && x.SequenceName == req.SequenceName).Any())
{
return DataResult.Failed("系统编码已存在!", MultiLanguageConst.SequenceExist);
}

@ -279,11 +279,11 @@ public class UserService : IUserService
/// 查询客户端 用户拥有的菜单权限
/// </summary>
/// <returns></returns>
public async Task<DataResult<List<RouteItem>>> GetClientUserPermissions()
public async Task<DataResult<List<RouteItem>>> GetClientUserPermissions(string id)
{
List<RouteItem> list = new List<RouteItem>();
var userId = long.Parse(user.UserId);
var userId = long.Parse(id);
var userInfo = await db.Queryable<SysUser>().Where(x => x.Id == userId).FirstAsync();

@ -105,9 +105,9 @@ public class UserController : ApiController
/// <returns></returns>
[HttpGet]
[Route("GetClientUserPermissions")]
public async Task<DataResult<List<RouteItem>>> GetClientUserPermissions()
public async Task<DataResult<List<RouteItem>>> GetClientUserPermissions([FromQuery] string id)
{
var res = await _invokeService.GetClientUserPermissions();
var res = await _invokeService.GetClientUserPermissions(id);
return res;
}
@ -118,6 +118,7 @@ public class UserController : ApiController
/// <returns></returns>
[HttpGet]
[Route("GetDataRuleListByPermission")]
[Obsolete]
public async Task<DataResult<List<DataRuleRes>>> GetDataRuleListByPermission([FromQuery] string permissionId)
{
var res = await _invokeService.GetDataRuleListByPermission(permissionId);

Loading…
Cancel
Save