From b7da1f32d5d9997378b5ac535593a3f6144af46b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 17:15:38 +0800
Subject: [PATCH] 新增AGV与堆垛机移库判断及缓存优化
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs | 137 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 120 insertions(+), 17 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
index ee96461..7032f8e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
@@ -1,23 +1,26 @@
-锘縰sing SqlSugar;
-using System.Data;
-using System.Linq.Expressions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Reflection;
-using WIDESEA_Core.Helper;
+锘縰sing AngleSharp.Dom;
using Microsoft.Data.SqlClient;
-using System.Drawing.Printing;
-using WIDESEA_Core.Tenants;
-using WIDESEA_Core.Seed;
-using WIDESEA_Core.DB;
-using WIDESEA_Core.Const;
-using WIDESEA_Core.AOP;
-using AngleSharp.Dom;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using SharpCompress.Common;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.AOP;
+using WIDESEA_Core.Const;
+using WIDESEA_Core.DB;
+using WIDESEA_Core.DB.Models;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
+using WIDESEA_Core.Seed;
+using WIDESEA_Core.Tenants;
+using WIDESEA_Core.Utilities;
namespace WIDESEA_Core.BaseRepository
{
@@ -890,6 +893,106 @@
return _db.UpdateNav(Entity).IncludesAllFirstLayer().ExecuteCommand();
}
+ public bool DeleteAndMoveIntoHty(TEntity entity, OperateTypeEnum operateType)
+ {
+ Type type = entity.GetType();
+ Assembly assembly = type.Assembly;
+ Type? htyType = assembly.GetType(type.FullName + "_Hty");
+ if (htyType != null)
+ {
+ object? obj = Activator.CreateInstance(htyType);
+ PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
+ PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
+ PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
+ if (obj != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
+ {
+ operateTypePro.SetValue(obj, operateType.ToString());
+ sourceIdPro.SetValue(obj, keyPro.GetValue(entity));
+
+ List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
+
+ for (int i = 0; i < propertyInfos.Count; i++)
+ {
+ PropertyInfo propertyInfo = propertyInfos[i];
+ PropertyInfo? property = type.GetProperty(propertyInfo.Name);
+
+ if (property != null)
+ {
+ if (propertyInfo.Name == nameof(BaseEntity.Modifier))
+ {
+ propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
+ }
+ else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
+ {
+ propertyInfo.SetValue(obj, DateTime.Now);
+ }
+ else
+ {
+ propertyInfo.SetValue(obj, property.GetValue(entity));
+ }
+ }
+ }
+ if (obj != null)
+ _db.InsertableByObject(obj).AS(type.Name + "_Hty").ExecuteCommand();
+ }
+ }
+ return DeleteData(entity);
+ }
+
+ public bool DeleteAndMoveIntoHty(List<TEntity> entities, OperateTypeEnum operateType)
+ {
+ Type type = typeof(TEntity);
+ Assembly assembly = type.Assembly;
+ Type? htyType = assembly.GetType(type.FullName + "_Hty");
+ if (htyType != null)
+ {
+ object? obj2 = Activator.CreateInstance(htyType);
+ PropertyInfo keyPro = typeof(TEntity).GetKeyProperty();
+ PropertyInfo? operateTypePro = htyType.GetProperty(nameof(IBaseHistoryEntity.OperateType));
+ PropertyInfo? sourceIdPro = htyType.GetProperty(nameof(IBaseHistoryEntity.SourceId));
+ if (obj2 != null && keyPro != null && operateTypePro != null && sourceIdPro != null)
+ {
+ List<PropertyInfo> propertyInfos = htyType.GetProperties().Where(x => x.Name != operateTypePro.Name && x.Name != sourceIdPro.Name && x.Name != keyPro.Name).ToList();
+ List<object> list = new List<object>();
+ foreach (var item in entities)
+ {
+ object? obj = Activator.CreateInstance(htyType);
+ if (obj != null)
+ {
+ operateTypePro.SetValue(obj, operateType.ToString());
+ sourceIdPro.SetValue(obj, keyPro.GetValue(item));
+ for (int i = 0; i < propertyInfos.Count; i++)
+ {
+ PropertyInfo propertyInfo = propertyInfos[i];
+ PropertyInfo? property = type.GetProperty(propertyInfo.Name);
+
+ if (property != null)
+ {
+ if (propertyInfo.Name == nameof(BaseEntity.Modifier))
+ {
+ propertyInfo.SetValue(obj, App.User.UserId > 0 ? App.User.UserName : "System");
+ }
+ else if (propertyInfo.Name == nameof(BaseEntity.ModifyDate))
+ {
+ propertyInfo.SetValue(obj, DateTime.Now);
+ }
+ else
+ {
+ propertyInfo.SetValue(obj, property.GetValue(item));
+ }
+ }
+ }
+ list.Add(obj);
+ }
+ }
+ if (list.Count > 0)
+ _db.InsertableByObject(list).AS(type.Name + "_Hty").ExecuteCommand();
+
+ }
+ }
+ return DeleteData(entities);
+ }
+
//List<TResult> QueryMuch<T, T2, T3, TResult>(
// Expression<Func<T, T2, T3, object[]>> joinExpression,
// Expression<Func<T, T2, T3, TResult>> selectExpression,
--
Gitblit v1.9.3