diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
index 2e8d04f8..6c2e1e43 100644
--- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
+++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml
@@ -1511,6 +1511,14 @@
+
+
+ 批量删除
+
+
+
+
+
老ops箱信息
@@ -1789,6 +1797,9 @@
根据箱Id查询集合
+
+ 根据箱Ids查询集合
+
修改实体集合
@@ -3060,6 +3071,14 @@
+
+
+ 移箱-箱库存的变更
+
+
+
+
+
出库服务
diff --git a/src/WMS.Web.Domain/Entitys/BoxInventoryDetails.cs b/src/WMS.Web.Domain/Entitys/BoxInventoryDetails.cs
index 1c1c0446..8c24f755 100644
--- a/src/WMS.Web.Domain/Entitys/BoxInventoryDetails.cs
+++ b/src/WMS.Web.Domain/Entitys/BoxInventoryDetails.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
+using WMS.Web.Core;
namespace WMS.Web.Domain.Entitys
{
@@ -10,12 +11,12 @@ namespace WMS.Web.Domain.Entitys
///
[Serializable]
[Table("t_wms_box_inventory_details")]
- public class BoxInventoryDetails
+ public class BoxInventoryDetails : EntityBase
{
///
/// ID
///
- public int Id { get; set; }
+ public override int Id { get; set; }
///
/// 上级ID
diff --git a/src/WMS.Web.Domain/Infrastructure/IBoxInventoryRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IBoxInventoryRepositories.cs
index 1b18e306..05be0b92 100644
--- a/src/WMS.Web.Domain/Infrastructure/IBoxInventoryRepositories.cs
+++ b/src/WMS.Web.Domain/Infrastructure/IBoxInventoryRepositories.cs
@@ -55,5 +55,13 @@ namespace WMS.Web.Domain.Infrastructure
///
///
Task UpdateRange(List entitys, bool isTransaction = true);
+
+ ///
+ /// 批量删除
+ ///
+ ///
+ ///
+ ///
+ Task DeleteRange(List ids, bool isTransaction = false);
}
}
diff --git a/src/WMS.Web.Domain/Mappers/InventoryMapper.cs b/src/WMS.Web.Domain/Mappers/InventoryMapper.cs
index 6b11d148..bb0b5034 100644
--- a/src/WMS.Web.Domain/Mappers/InventoryMapper.cs
+++ b/src/WMS.Web.Domain/Mappers/InventoryMapper.cs
@@ -19,7 +19,7 @@ namespace WMS.Web.Domain.Mappers
//移箱映射
CreateMap();
- CreateMap();
+ CreateMap() ;
}
}
}
diff --git a/src/WMS.Web.Domain/Services/InventoryService.cs b/src/WMS.Web.Domain/Services/InventoryService.cs
index 18011a36..7b7a4faf 100644
--- a/src/WMS.Web.Domain/Services/InventoryService.cs
+++ b/src/WMS.Web.Domain/Services/InventoryService.cs
@@ -135,29 +135,42 @@ namespace WMS.Web.Domain.Services
#endregion
}
+ var isSuccess = true;
//4.数据库更新操作:更新和添加
- var isSuccess= await _boxInventoryRepositories.AddRange(add_entitys, isTransaction);
- if(!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
-
- isSuccess = await _boxInventoryRepositories.UpdateRange(update_entitys, isTransaction);
- if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
+ if (add_entitys.Count != 0)
+ {
+ isSuccess = await _boxInventoryRepositories.AddRange(add_entitys, isTransaction);
+ if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
+ }
+ if (update_entitys.Count != 0)
+ {
+ isSuccess = await _boxInventoryRepositories.UpdateRange(update_entitys, isTransaction);
+ if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
+ }
return Result.ReSuccess();
}
+ ///
+ /// 移箱-箱库存的变更
+ ///
+ ///
+ ///
+ ///
public async Task GenerateMoveBox(List dtoDatas, bool isTransaction)
{
//1.判断来源数据是否存在
if (dtoDatas != null || dtoDatas.Count == 0)
return Result.ReFailure(ResultCodes.InventoryNoSourceError);
- var update_entitys = new List();
+ var delete_entitys = new List();
var add_entitys = new List();
//2.获取“箱库存集合”和“箱基本信息集合”
var boxIds = dtoDatas.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
var boxInventorys = await _boxInventoryRepositories.GetList(boxIds);
var boxs= await _boxRepositories.GetEntityList(boxIds);
+ var serialNumbers = await _serialNumbersRepositories.GetEntityListByBoxIds(boxIds);
//3.遍历:dto
foreach (var dto in dtoDatas)
@@ -165,26 +178,57 @@ namespace WMS.Web.Domain.Services
//上架
if (dto.IsOn)
{
- //3.1上架的时候:箱一定是不存在于箱库存当中的,
+ //3.1上架的时候:箱一定是不存在于箱库存当中的,有则返回提示“已有箱库存,不需要再扫上架”
var ishave = boxInventorys.Where(x => x.BoxId == dto.BoxId).Any();
if (ishave)
return Result.ReFailure(ResultCodes.BoxInventoryHaveInventoryError);
+ //3.1.1取箱信息
var box = boxs.Where(x => x.Id == dto.BoxId).FirstOrDefault();
- //var serialNumbers= _serialNumbersRepositories.ge
- if (box==null)
+ if (box == null)
return Result.ReFailure(ResultCodes.BoxNoData);
+ //3.1.2去箱对应的序列号信息
+ var box_serialNumbers = serialNumbers.Where(x => x.BoxId == dto.BoxId).Select(x=>new { x.MaterialId,x.SerialNumber}).ToList();
+ //3.2组装要新增的箱库存信息:箱和明细
var addEntity = _mapper.Map(dto);
- addEntity.Details = new List();
+ addEntity.Details = _mapper.Map>(box.Details);
+ //3.3组装要新增的箱库存:明细中的序列号
+ foreach (var item in addEntity.Details)
+ {
+ var box_serialNub = box_serialNumbers.Where(x => x.MaterialId == item.MaterialId).FirstOrDefault();
+ if (box_serialNub != null)
+ item.SerialNumbers.Add(box_serialNub.SerialNumber);
+ }
+ add_entitys.Add(addEntity);
}//下架
else
{
-
+ //3.1下架的时候:箱一定是存在于箱库存当中的,没有则返回提示“箱不存在于库存,请扫其它箱”
+ var ishave = boxInventorys.Where(x => x.BoxId == dto.BoxId).Any();
+ if (!ishave)
+ return Result.ReFailure(ResultCodes.BoxInventoryNoDataError);
+
+ //3.2整箱移货下架-直接删除当前箱子所在的库存
+ var box_inventory= boxInventorys.Where(x => x.BoxId == dto.BoxId).FirstOrDefault();
+ delete_entitys.Add(box_inventory);
}
}
+ var isSuccess = true;
+ //4.数据库操作处理
+ if (add_entitys.Count != 0)
+ {
+ isSuccess = await _boxInventoryRepositories.AddRange(add_entitys, isTransaction);
+ if(!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
+ }
+ if (delete_entitys.Count != 0)
+ {
+ var delete_ids = add_entitys.Select(x => x.Id).ToList();
+ isSuccess = await _boxInventoryRepositories.DeleteRange(delete_ids,isTransaction);
+ if (!isSuccess) return Result.ReFailure(ResultCodes.DateWriteError);
+ }
return Result.ReSuccess();
}
}
diff --git a/src/WMS.Web.Repositories/BoxInventoryRepositories.cs b/src/WMS.Web.Repositories/BoxInventoryRepositories.cs
index 7ccb0ba6..84958856 100644
--- a/src/WMS.Web.Repositories/BoxInventoryRepositories.cs
+++ b/src/WMS.Web.Repositories/BoxInventoryRepositories.cs
@@ -207,5 +207,34 @@ namespace WMS.Web.Repositories
return true;
}
}
+
+ ///
+ /// 批量删除
+ ///
+ ///
+ ///
+ public async Task DeleteRange(List ids, bool isTransaction = false)
+ {
+ IDbContextTransaction _transaction = null;
+ if (isTransaction)
+ _transaction = _context.Database.BeginTransaction();
+ try
+ {
+ var list = await _context.BoxInventory.Include(x => x.Details)
+ .Where(f => ids.Contains(f.Id)).ToListAsync();
+ _context.BoxInventory.RemoveRange(list);
+ await _context.SaveChangesAsync();
+
+ if (_transaction != null)
+ _transaction.Commit();
+ }
+ catch (Exception ex)
+ {
+ if (_transaction != null)
+ _transaction.Rollback();
+ return false;
+ }
+ return true;
+ }
}
}