diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs
new file mode 100644
index 00000000..cc68bf46
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ExChangeCarryInput.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto
+{
+ ///
+ /// 更换载具输入参数
+ ///
+
+ public class ExChangeCarryInput
+ {
+ ///
+ /// 老载具ID
+ ///
+ public string old_carry_id { get; set; }
+ ///
+ /// 新载具ID
+ ///
+ public string new_carry_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
index b71ca2b2..84d8360b 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryCode.cs
@@ -97,12 +97,12 @@ public partial class WmsCarryCode : BaseEntity
///
/// 创建用户
///
- public string create_id { get; set; } = string.Empty;
+ public string? create_id { get; set; }
///
/// 创建时间
///
- public DateTime create_time { get; set; } = DateTime.Now;
+ public DateTime? create_time { get; set; }
///
/// 修改用户
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
index 0bfbdd28..553c5500 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryD.cs
@@ -42,12 +42,12 @@ public partial class WmsCarryD : BaseEntity
///
/// 创建用户
///
- public string create_id { get; set; } = string.Empty;
+ public string? create_id { get; set; }
///
/// 创建时间
///
- public DateTime create_time { get; set; } = DateTime.Now;
+ public DateTime? create_time { get; set; }
///
/// 最后修改人员ID
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
index 30b9e324..76092322 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryH.cs
@@ -42,7 +42,7 @@ public partial class WmsCarryH : BaseEntity
///
/// 载具状态
///
- public string carry_status { get; set; } = string.Empty;
+ public int carry_status { get; set; };
///
/// 载具分类ID
@@ -114,4 +114,19 @@ public partial class WmsCarryH : BaseEntity
///
public DateTime? timestamp { get; set; }
+ ///
+ /// 打包号
+ ///
+ public string? bale_num { get; set; }
+
+ ///
+ /// 齐套搭配方案ID
+ ///
+ public string? collocation_scheme_id { get; set; }
+
+ ///
+ /// 齐套搭配方案编号
+ ///
+ public string? collocation_scheme_code { get; set; }
+
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
index e1d544cc..283918af 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryMat.cs
@@ -82,12 +82,12 @@ public partial class WmsCarryMat : BaseEntity
///
/// 时间戳
///
- public DateTime time_stamp { get; set; } = DateTime.Now;
+ public DateTime? time_stamp { get; set; }
///
/// 创建用户
///
- public string create_id { get; set; } = string.Empty;
+ public string? create_id { get; set; }
///
/// 创建时间
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs
index 2575f6af..1656af9f 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceCode.cs
@@ -77,12 +77,12 @@ public partial class WmsCarryReplaceCode : BaseEntity
///
/// 创建用户
///
- public string create_id { get; set; } = string.Empty;
+ public string? create_id { get; set; }
///
/// 创建时间
///
- public DateTime create_time { get; set; } = DateTime.Now;
+ public DateTime? create_time { get; set; }
///
/// 修改用户
@@ -94,9 +94,4 @@ public partial class WmsCarryReplaceCode : BaseEntity
///
public DateTime? modify_time { get; set; }
- ///
- /// 行号
- ///
- public int no { get; set; }
-
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs
index f2d39eae..1ebfc67c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryReplaceH.cs
@@ -17,7 +17,7 @@ public partial class WmsCarryReplaceH : BaseEntity
///
/// 租户ID
///
- public string tenant_id { get; set; } = string.Empty;
+ public string? tenant_id { get; set; }
///
/// 所属组织ID
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs
new file mode 100644
index 00000000..c7bbef14
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumCarryStatus.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Enums
+{
+ ///
+ /// 载具状态枚举
+ ///
+ public enum EnumCarryStatus
+ {
+ 空闲 = 0,
+ 占用 = 1,
+ 齐套 = 3,
+ 寄存 = 4,
+ 齐套分拣 = 5,
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs
new file mode 100644
index 00000000..f13e2e51
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumOutStatus.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Enums
+{
+ ///
+ /// 出库状态
+ ///
+ public enum EnumOutStatus
+ {
+ 正常 = 0,
+ 全部出 = 1,
+ 分拣出 = 2,
+ 齐套出 = 3,
+ 寄存出 = 4,
+ 齐套分拣出 = 5,
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs
deleted file mode 100644
index 8c120287..00000000
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Tnb.WarehouseMgr.Interfaces
-{
- public class Class1
- {
-
- }
-}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs
new file mode 100644
index 00000000..f2d71a03
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryEntity.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ public class IWmsCarryEntity
+ {
+ string carry_id { get; set; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs
new file mode 100644
index 00000000..4eeff321
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryService.cs
@@ -0,0 +1,17 @@
+using Tnb.WarehouseMgr.Entities;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// 载具服务接口
+ ///
+ public interface IWmsCarryService
+ {
+ ///
+ /// 更新空载具
+ ///
+ ///
+ ///
+ Task UpdateNullCarry(WmsCarryH carryObj);
+ }
+}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs b/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs
deleted file mode 100644
index b5b0a256..00000000
--- a/WarehouseMgr/Tnb.WarehouseMgr/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Tnb.WarehouseMgr
-{
- public class Class1
- {
-
- }
-}
\ No newline at end of file
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
new file mode 100644
index 00000000..5fede318
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs
@@ -0,0 +1,137 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.Common.Utils;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Enums;
+using Tnb.WarehouseMgr.Interfaces;
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 载具服务
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+
+ public class WmsCarryService : IWmsCarryService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarClient _db;
+ private readonly IUserManager _userManager;
+ public WmsCarryService(ISqlSugarRepository repository, IUserManager userManager)
+ {
+ _db = repository.AsSugarClient();
+ _userManager = userManager;
+ }
+ ///
+ /// 更换载具
+ ///
+ ///
+ /// 输入参数:
+ ///
{
+ ///
old_carry_id:老载具id
+ ///
new_carry_id:新载具ID
+ ///
}
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task Exchange(ExChangeCarryInput input)
+ {
+ var row = -1;
+ if (input == null) throw new ArgumentNullException("input");
+ var oldCarry = await _db.Queryable().FirstAsync(it => it.id == input.old_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status != 0);
+ var newCarry = await _db.Queryable().FirstAsync(it => it.id == input.new_carry_id && it.is_lock == 0 && it.status == 0 && it.carry_status == 0);
+ if (oldCarry != null && newCarry != null)
+ {
+ var subCarrys = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
+ if (subCarrys?.Count > 0)
+ {
+ List newSubCarrys = DeepCopyHelper.DeepCopyList(subCarrys);
+ if (newSubCarrys?.Count > 0)
+ {
+ newSubCarrys.ForEach(x => x.carry_id = newCarry.id);
+ row = await _db.Insertable(newSubCarrys).ExecuteCommandAsync();
+ }
+ if (row > 0)
+ {
+ row = await _db.Deleteable(subCarrys).ExecuteCommandAsync();
+ }
+ }
+ var subCarryMats = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
+ if (subCarryMats?.Count > 0)
+ {
+ List newCarryMats = DeepCopyHelper.DeepCopyList(subCarryMats);
+ if (newCarryMats?.Count > 0)
+ {
+ newCarryMats.ForEach(x => x.carry_id = newCarry.id);
+ row = await _db.Insertable(newCarryMats).ExecuteCommandAsync();
+ }
+ if (row > 0)
+ {
+ row = await _db.Deleteable(subCarryMats).ExecuteCommandAsync();
+ }
+ }
+ var subCarryCodes = await _db.Queryable().Where(it => it.carry_id == oldCarry.id).ToListAsync();
+ if (subCarryCodes?.Count > 0)
+ {
+ List newCarrayCodes = DeepCopyHelper.DeepCopyList(subCarryCodes);
+ if (newCarrayCodes?.Count > 0)
+ {
+ newCarrayCodes.ForEach(x => x.carry_id = newCarry.id);
+ row = await _db.Insertable(newCarrayCodes).ExecuteCommandAsync();
+ }
+ if (row > 0)
+ {
+ row = await _db.Deleteable(subCarryCodes).ExecuteCommandAsync();
+ }
+ }
+ if (row > 0)
+ {
+ newCarry.carry_name = oldCarry.carry_name;
+ newCarry.status = oldCarry.status;
+ newCarry.carry_status = oldCarry.carry_status;
+ newCarry.carrystd_id = oldCarry.carrystd_id;
+ newCarry.location_id = oldCarry.location_id;
+ newCarry.carry_code = oldCarry.location_code;
+ newCarry.is_lock = oldCarry.is_lock;
+ newCarry.out_status = oldCarry.out_status;
+ newCarry.is_check = oldCarry.is_check;
+ newCarry.bale_num = oldCarry.bale_num;
+ newCarry.collocation_scheme_id = oldCarry.collocation_scheme_id;
+ newCarry.collocation_scheme_code = oldCarry.collocation_scheme_code;
+ newCarry.source_id = oldCarry.source_id;
+ newCarry.source_code = oldCarry.source_code;
+ newCarry.create_id = _userManager.UserId;
+ newCarry.create_time = DateTime.Now;
+ row = await _db.Updateable(newCarry).ExecuteCommandAsync();
+ row = await UpdateNullCarry(oldCarry);
+ }
+ }
+ if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
+ }
+
+ public Task UpdateNullCarry(WmsCarryH carryObj)
+ {
+ carryObj.carry_name = null;
+ carryObj.status = 0;
+ carryObj.carry_status = 0;
+ carryObj.carrystd_id = null;
+ carryObj.location_id = null;
+ carryObj.carry_code = null;
+ carryObj.out_status = null;
+ carryObj.is_check = 0;
+ carryObj.bale_num = null;
+ carryObj.collocation_scheme_id = null;
+ carryObj.collocation_scheme_code = null;
+ carryObj.source_id = null;
+ carryObj.source_code = null;
+ return _db.Updateable(carryObj).ExecuteCommandAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/common/Tnb.Common/Utils/DeepCopyHelper.cs b/common/Tnb.Common/Utils/DeepCopyHelper.cs
new file mode 100644
index 00000000..1c4cc78c
--- /dev/null
+++ b/common/Tnb.Common/Utils/DeepCopyHelper.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.Common.Utils
+{
+ public class DeepCopyHelper where T : class, new() // 需要无参构造函数,构造表达式树的时候需要利用无参构造函数创建对象
+ {
+ ///
+ /// 映射表达式,泛型缓存每个类型存一份
+ ///
+ private static readonly Func s_CopyFunc = null;
+
+ ///
+ /// 静态构造函数,每个泛型类型会且只会执行一次
+ ///
+ static DeepCopyHelper()
+ {
+ BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
+ ParameterExpression parameterExpression = Expression.Parameter(typeof(T), "m"); // 参数m :m =>
+ List memberBindingList = new List();
+ foreach (var item in typeof(T).GetProperties(bindingFlags))
+ {
+ if (!item.CanWrite) // 只读属性不拷贝
+ {
+ continue;
+ }
+ MemberExpression property = Expression.Property(parameterExpression, item); // m.Name
+ MemberBinding memberBinding = Expression.Bind(item, property); // Name = m.Name
+ memberBindingList.Add(memberBinding);
+ }
+ foreach (var item in typeof(T).GetFields(bindingFlags))
+ {
+ MemberExpression property = Expression.Field(parameterExpression, item);
+ MemberBinding memberBinding = Expression.Bind(item, property);
+ memberBindingList.Add(memberBinding);
+ }
+ MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(T)), memberBindingList.ToArray());// new T() {Name = m.Name}
+ Expression> lambda = Expression.Lambda>(memberInitExpression, new ParameterExpression[]
+ {
+ parameterExpression
+ }); // m => new T() {Name = m.Name}
+
+ s_CopyFunc = lambda.Compile();
+ }
+
+ ///
+ /// 对象拷贝(拷贝private/public:实例成员、属性、静态成员)
+ ///
+ /// 源
+ ///
+ public static T DeepCopy(T data)
+ {
+ return s_CopyFunc(data);
+ }
+
+ ///
+ /// 集合拷贝(拷贝private/public:实例成员、属性、静态成员)
+ ///
+ /// 源
+ ///
+ public static List DeepCopyList(List data)
+ {
+ if (data == null || data.Count < 1)
+ {
+ return Enumerable.Empty().ToList();
+ }
+ return data.Select(a => DeepCopy(a)).ToList();
+ }
+ }
+
+}