From fb79dc54d6484146b74d29bf5644df880fc1fa01 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 19 六月 2025 12:16:54 +0800
Subject: [PATCH] WMS添加AGV任务完成取消
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 1 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
index 9346461..e974d51 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/BaseRepository/RepositoryBase.cs"
@@ -16,6 +16,11 @@
using WIDESEA_Core.Const;
using WIDESEA_Core.AOP;
using OfficeOpenXml.FormulaParsing.ExpressionGraph;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Utilities;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+using NetTaste;
+using WIDESEA_Core.DB.Models;
namespace WIDESEA_Core.BaseRepository
{
@@ -537,7 +542,7 @@
public virtual List<TResult> QueryTabs<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
- Expression<Func<T,T2, bool>> whereExpressionT1,
+ Expression<Func<T, T2, bool>> whereExpressionT1,
Expression<Func<TResult, bool>> whereExpression)
{
List<TResult> list = _db.Queryable(joinExpression).WhereIF(whereExpressionT1 != null, whereExpressionT1)
@@ -859,6 +864,103 @@
.WhereIF(whereExpression != null, whereExpression).ToListAsync();
}
+ public bool DeleteAndMoveIntoHty(TEntity entity, OperateType 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(OperateType));
+ PropertyInfo? sourceIdPro = htyType.GetProperty("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));
+ }
+ }
+ }
+ _db.InsertableByObject(obj).AS(type.Name + "_Hty").ExecuteCommand();
+ }
+ }
+ return DeleteData(entity);
+ }
+
+ public bool DeleteAndMoveIntoHty(List<TEntity> entities, OperateType 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(OperateType));
+ PropertyInfo? sourceIdPro = htyType.GetProperty("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);
+ }
+ }
+ _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