改箱调整
This commit is contained in:
@@ -275,9 +275,9 @@
|
|||||||
单据头ID
|
单据头ID
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:WMS.Web.Core.Dto.BoxResponse.BoxId">
|
<member name="P:WMS.Web.Core.Dto.BoxResponse.BoxBillNo">
|
||||||
<summary>
|
<summary>
|
||||||
箱Id
|
箱号
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:WMS.Web.Core.Dto.BoxResponse.Details">
|
<member name="F:WMS.Web.Core.Dto.BoxResponse.Details">
|
||||||
@@ -395,11 +395,6 @@
|
|||||||
保存改箱
|
保存改箱
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.MaterialId">
|
|
||||||
<summary>
|
|
||||||
物料ID
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.SrcBoxId">
|
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.SrcBoxId">
|
||||||
<summary>
|
<summary>
|
||||||
原箱子ID
|
原箱子ID
|
||||||
@@ -410,11 +405,26 @@
|
|||||||
目标箱子ID
|
目标箱子ID
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordRequest.Qty">
|
<member name="T:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest">
|
||||||
|
<summary>
|
||||||
|
明细
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.MaterialId">
|
||||||
|
<summary>
|
||||||
|
物料ID
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.Qty">
|
||||||
<summary>
|
<summary>
|
||||||
数量
|
数量
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:WMS.Web.Core.Dto.ChangeBoxRecord.SaveChangeBoxRecordDetailsRequest.SerialNumbers">
|
||||||
|
<summary>
|
||||||
|
序列号
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:WMS.Web.Core.Dto.EnumStatusResponse">
|
<member name="T:WMS.Web.Core.Dto.EnumStatusResponse">
|
||||||
<summary>
|
<summary>
|
||||||
所有枚举信息
|
所有枚举信息
|
||||||
|
|||||||
@@ -220,11 +220,6 @@
|
|||||||
物料ID
|
物料ID
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.StockId">
|
|
||||||
<summary>
|
|
||||||
仓库Id
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.SerialNumbers">
|
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.SerialNumbers">
|
||||||
<summary>
|
<summary>
|
||||||
序列号
|
序列号
|
||||||
@@ -245,16 +240,6 @@
|
|||||||
目标箱子ID
|
目标箱子ID
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.SrcSubStockId">
|
|
||||||
<summary>
|
|
||||||
原仓位ID
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.DestSubStockId">
|
|
||||||
<summary>
|
|
||||||
目标仓位ID
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.CreatorId">
|
<member name="P:WMS.Web.Domain.Entitys.ChangeBoxRecord.CreatorId">
|
||||||
<summary>
|
<summary>
|
||||||
操作人
|
操作人
|
||||||
@@ -265,11 +250,14 @@
|
|||||||
操作时间
|
操作时间
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:WMS.Web.Domain.Entitys.ChangeBoxRecord.Create(System.Int32)">
|
<member name="M:WMS.Web.Domain.Entitys.ChangeBoxRecord.Create(System.Int32,System.Decimal,System.Int32,System.Collections.Generic.List{System.String},System.Int32,System.Int32)">
|
||||||
<summary>
|
<summary>
|
||||||
创建
|
创建
|
||||||
</summary>
|
</summary>
|
||||||
<param name="creatorId"></param>
|
<param name="creatorId"></param>
|
||||||
|
<param name="qty"></param>
|
||||||
|
<param name="materialId"></param>
|
||||||
|
<param name="serialNumbers"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:WMS.Web.Domain.Entitys.InStock">
|
<member name="T:WMS.Web.Domain.Entitys.InStock">
|
||||||
<summary>
|
<summary>
|
||||||
|
|||||||
@@ -38,5 +38,9 @@ namespace WMS.Web.Core.Dto.ChangeBoxRecord
|
|||||||
///</summary>
|
///</summary>
|
||||||
[Required(ErrorMessage = "数量不能为空")]
|
[Required(ErrorMessage = "数量不能为空")]
|
||||||
public decimal Qty { get; set; }
|
public decimal Qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 序列号
|
||||||
|
/// </summary>
|
||||||
|
public List<string> SerialNumbers { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using WMS.Web.Core;
|
||||||
|
using WMS.Web.Core.Internal.Results;
|
||||||
|
using WMS.Web.Domain.Values;
|
||||||
|
|
||||||
namespace WMS.Web.Domain.Entitys
|
namespace WMS.Web.Domain.Entitys
|
||||||
{
|
{
|
||||||
@@ -11,12 +15,12 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[Table("t_ops_box")]
|
[Table("t_ops_box")]
|
||||||
public class Box
|
public class Box : EntityBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ID
|
/// ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public override int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对应老OPS的箱ID
|
/// 对应老OPS的箱ID
|
||||||
@@ -37,5 +41,41 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
/// 明细
|
/// 明细
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<BoxDetails> Details = new List<BoxDetails>();
|
public List<BoxDetails> Details = new List<BoxDetails>();
|
||||||
|
|
||||||
|
//移出
|
||||||
|
public Result Out(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||||
|
{
|
||||||
|
foreach(var l in list)
|
||||||
|
{
|
||||||
|
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||||
|
if (d == null) return Result.ReFailure(ResultCodes.BoxMateriaNoData);
|
||||||
|
d.Qty = d.Qty - l.Qty;
|
||||||
|
if (d.Qty <= 0) this.Details.Remove(d);
|
||||||
|
foreach (var s in l.SerialNumbers) d.SerialNumbers.Remove(s);
|
||||||
|
}
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
//移入
|
||||||
|
public Result In(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
|
||||||
|
{
|
||||||
|
foreach (var l in list)
|
||||||
|
{
|
||||||
|
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
|
||||||
|
if (d == null)
|
||||||
|
{
|
||||||
|
this.Details.Add(new BoxDetails()
|
||||||
|
{
|
||||||
|
MaterialId = l.MaterialId,
|
||||||
|
Qty=l.Qty,
|
||||||
|
SerialNumbers=l.SerialNumbers
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
d.Qty = d.Qty + l.Qty;
|
||||||
|
d.SerialNumbers.AddRange(l.SerialNumbers);
|
||||||
|
}
|
||||||
|
return Result.ReSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using WMS.Web.Core;
|
||||||
|
|
||||||
namespace WMS.Web.Domain.Entitys
|
namespace WMS.Web.Domain.Entitys
|
||||||
{
|
{
|
||||||
@@ -11,12 +12,12 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[Table("t_ops_box_details")]
|
[Table("t_ops_box_details")]
|
||||||
public class BoxDetails
|
public class BoxDetails : EntityBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ID
|
/// ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public override int Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单据头ID
|
/// 单据头ID
|
||||||
|
|||||||
@@ -25,11 +25,6 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
[Column("MaterialId")]
|
[Column("MaterialId")]
|
||||||
public int MaterialId { get; set; }
|
public int MaterialId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 仓库Id
|
|
||||||
/// </summary>
|
|
||||||
[Column("StockId")]
|
|
||||||
public int StockId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 序列号
|
/// 序列号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column("SerialNumbers")]
|
[Column("SerialNumbers")]
|
||||||
@@ -50,16 +45,6 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
[Column("DestBoxId")]
|
[Column("DestBoxId")]
|
||||||
public int DestBoxId { get; set; }
|
public int DestBoxId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原仓位ID
|
|
||||||
/// </summary>
|
|
||||||
[Column("SrcSubStockId")]
|
|
||||||
public int SrcSubStockId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 目标仓位ID
|
|
||||||
/// </summary>
|
|
||||||
[Column("DestSubStockId")]
|
|
||||||
public int DestSubStockId { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 操作人
|
/// 操作人
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column("CreatorId")]
|
[Column("CreatorId")]
|
||||||
@@ -73,8 +58,16 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
/// 创建
|
/// 创建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="creatorId"></param>
|
/// <param name="creatorId"></param>
|
||||||
public void Create(int creatorId)
|
/// <param name="qty"></param>
|
||||||
|
/// <param name="materialId"></param>
|
||||||
|
/// <param name="serialNumbers"></param>
|
||||||
|
public void Create(int creatorId,decimal qty,int materialId, List<string> serialNumbers,int srcBoxId,int destBoxId)
|
||||||
{
|
{
|
||||||
|
this.SrcBoxId = srcBoxId;
|
||||||
|
this.DestBoxId = destBoxId;
|
||||||
|
this.SerialNumbers = serialNumbers;
|
||||||
|
this.MaterialId = materialId;
|
||||||
|
this.Qty = qty;
|
||||||
this.CreatorId = creatorId;
|
this.CreatorId = creatorId;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBoxRepositories
|
public interface IBoxRepositories
|
||||||
{
|
{
|
||||||
Task<Box> Get(string BoxBillNo);
|
Task<Box> Get(int id);
|
||||||
//根据箱号查询明细信息
|
//根据箱号查询明细信息
|
||||||
Task<BoxResponse> GetBox(string BoxBillNo);
|
Task<BoxResponse> GetBox(string BoxBillNo);
|
||||||
|
//批量修改
|
||||||
|
Task<bool> EditEntityList(List<Box> entitys, bool isTransaction = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace WMS.Web.Domain.Infrastructure
|
|||||||
{
|
{
|
||||||
// 新增
|
// 新增
|
||||||
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
Task<ChangeBoxRecord> Add(ChangeBoxRecord entity, bool isTransaction = true);
|
||||||
|
// 批量新增
|
||||||
|
Task<bool> AddRange(List<ChangeBoxRecord> list, bool isTransaction = true);
|
||||||
|
|
||||||
// 获取列表
|
// 获取列表
|
||||||
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
Task<(List<ChangeBoxRecordQueryInfoResponse> list,int total)> GetListAsync(ChangeBoxRecordQueryRequest dto);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
using WMS.Web.Core.Dto.ChangeBoxRecord;
|
||||||
@@ -24,15 +25,17 @@ namespace WMS.Web.Domain.Services
|
|||||||
private readonly IChangeBoxRecordRepositories _changeBoxRecordRepositories;
|
private readonly IChangeBoxRecordRepositories _changeBoxRecordRepositories;
|
||||||
public readonly ITransactionRepositories _transactionRepositories;
|
public readonly ITransactionRepositories _transactionRepositories;
|
||||||
private readonly IMoveBoxRecordRepositories _moveBoxRecordRepositories;
|
private readonly IMoveBoxRecordRepositories _moveBoxRecordRepositories;
|
||||||
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
private readonly IBoxRepositories _boxRepositories;
|
||||||
|
public ChangeMoveBoxService(IMapper mapper, ILoginService loginService,
|
||||||
IChangeBoxRecordRepositories changeBoxRecordRepositories, ITransactionRepositories transactionRepositories,
|
IChangeBoxRecordRepositories changeBoxRecordRepositories, ITransactionRepositories transactionRepositories,
|
||||||
IMoveBoxRecordRepositories moveBoxRecordRepositories)
|
IMoveBoxRecordRepositories moveBoxRecordRepositories, IBoxRepositories boxRepositories)
|
||||||
{
|
{
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_loginService = loginService;
|
_loginService = loginService;
|
||||||
_changeBoxRecordRepositories = changeBoxRecordRepositories;
|
_changeBoxRecordRepositories = changeBoxRecordRepositories;
|
||||||
_transactionRepositories = transactionRepositories;
|
_transactionRepositories = transactionRepositories;
|
||||||
_moveBoxRecordRepositories = moveBoxRecordRepositories;
|
_moveBoxRecordRepositories = moveBoxRecordRepositories;
|
||||||
|
_boxRepositories = boxRepositories;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 改箱保存
|
/// 改箱保存
|
||||||
@@ -40,10 +43,32 @@ namespace WMS.Web.Domain.Services
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="loginInfo"></param>
|
/// <param name="loginInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
public async Task<Result> ChangeBoxSave(SaveChangeBoxRecordRequest dto, LoginInDto loginInfo)
|
||||||
{
|
{
|
||||||
var entity = _mapper.Map<ChangeBoxRecord>(dto);
|
List<Box> boxList = new List<Box>();
|
||||||
entity.Create(loginInfo.UserInfo.StaffId);
|
var srcBox = await _boxRepositories.Get(dto.SrcBoxId);
|
||||||
|
var destBox = await _boxRepositories.Get(dto.DestBoxId);
|
||||||
|
if (srcBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||||
|
if (destBox == null) return Result.ReFailure(ResultCodes.BoxNoData);
|
||||||
|
var l = dto.Details.Select(s => (s.MaterialId, s.Qty, s.SerialNumbers)).ToList();
|
||||||
|
//原箱移出
|
||||||
|
var res = srcBox.Out(l);
|
||||||
|
if (!res.IsSuccess) return res;
|
||||||
|
//目标箱移入
|
||||||
|
res = destBox.In(l);
|
||||||
|
if (!res.IsSuccess) return res;
|
||||||
|
|
||||||
|
boxList.Add(srcBox);
|
||||||
|
boxList.Add(destBox);
|
||||||
|
|
||||||
|
//var entity = _mapper.Map<ChangeBoxRecord>(dto);\
|
||||||
|
List<ChangeBoxRecord> list = new List<ChangeBoxRecord>();
|
||||||
|
foreach (var d in dto.Details)
|
||||||
|
{
|
||||||
|
ChangeBoxRecord entity = new ChangeBoxRecord();
|
||||||
|
entity.Create(loginInfo.UserInfo.StaffId, d.Qty, d.MaterialId, d.SerialNumbers, dto.SrcBoxId, dto.DestBoxId);
|
||||||
|
list.Add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
//需要填写序列号
|
//需要填写序列号
|
||||||
//需要修改库存
|
//需要修改库存
|
||||||
@@ -51,8 +76,12 @@ namespace WMS.Web.Domain.Services
|
|||||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||||
bool isRollback = false;
|
bool isRollback = false;
|
||||||
bool isSuccess = true;
|
bool isSuccess = true;
|
||||||
entity = await _changeBoxRecordRepositories.Add(entity, true);
|
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
|
||||||
if (entity == null) isRollback = true;
|
if (!isSuccess) isRollback = true;
|
||||||
|
|
||||||
|
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
|
||||||
|
if (!isSuccess) isRollback = true;
|
||||||
|
|
||||||
|
|
||||||
//提交事务
|
//提交事务
|
||||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||||
|
|||||||
@@ -24,5 +24,8 @@ namespace WMS.Web.Domain.Values
|
|||||||
|
|
||||||
//出库任务单
|
//出库任务单
|
||||||
public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并");
|
public static ValueTuple<int, string> MergeStatusError = (70000, "所选单据数据不一致,不能合并");
|
||||||
|
|
||||||
|
public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在");
|
||||||
|
public static ValueTuple<int, string> BoxMateriaNoData = (800010, "箱对应物料信息不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WMS.Web.Core.Dto;
|
using WMS.Web.Core.Dto;
|
||||||
|
using WMS.Web.Core.Help;
|
||||||
using WMS.Web.Domain.Entitys;
|
using WMS.Web.Domain.Entitys;
|
||||||
using WMS.Web.Domain.Infrastructure;
|
using WMS.Web.Domain.Infrastructure;
|
||||||
using WMS.Web.Domain.IService.Public;
|
using WMS.Web.Domain.IService.Public;
|
||||||
|
using WMS.Web.Domain.Mappers;
|
||||||
using WMS.Web.Repositories.Configuration;
|
using WMS.Web.Repositories.Configuration;
|
||||||
|
|
||||||
namespace WMS.Web.Repositories
|
namespace WMS.Web.Repositories
|
||||||
@@ -35,10 +38,12 @@ namespace WMS.Web.Repositories
|
|||||||
_loginRepositories = loginRepositories;
|
_loginRepositories = loginRepositories;
|
||||||
_basicsRepositories = basicsRepositories;
|
_basicsRepositories = basicsRepositories;
|
||||||
}
|
}
|
||||||
public async Task<Box> Get(string BoxBillNo)
|
public async Task<Box> Get(int id)
|
||||||
{
|
{
|
||||||
return await _context.Box.Include(x => x.Details)
|
var entity= await _context.Box.Include(x => x.Details)
|
||||||
.FirstOrDefaultAsync(f => f.BoxBillNo.Equals(BoxBillNo));
|
.FirstOrDefaultAsync(f => f.Id.Equals(id));
|
||||||
|
|
||||||
|
return entity.Clone();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据箱号查询物料信息
|
/// 根据箱号查询物料信息
|
||||||
@@ -71,5 +76,41 @@ namespace WMS.Web.Repositories
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量修改
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entitys"></param>
|
||||||
|
/// <param name="isTransaction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> EditEntityList(List<Box> entitys, bool isTransaction = true)
|
||||||
|
{
|
||||||
|
IDbContextTransaction _transaction = null;
|
||||||
|
if (isTransaction)
|
||||||
|
_transaction = _context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||||
|
|
||||||
|
var res = await _context.Box
|
||||||
|
.Include(s => s.Details)
|
||||||
|
.Where(f => list.Contains(f.Id)).ToListAsync();
|
||||||
|
|
||||||
|
_mapper.ToMapList(entitys, res);
|
||||||
|
_mapper.ToMapList(entitys.SelectMany(s => s.Details).ToList(), res.SelectMany(s => s.Details).ToList());
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
if (_transaction != null)
|
||||||
|
_transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_transaction != null)
|
||||||
|
_transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,34 @@ namespace WMS.Web.Repositories
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量添加
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="isTransaction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> AddRange(List<ChangeBoxRecord> list, bool isTransaction = true)
|
||||||
|
{
|
||||||
|
IDbContextTransaction _transaction = null;
|
||||||
|
if (isTransaction)
|
||||||
|
_transaction = _context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_context.ChangeBoxRecord.AddRange(list);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
if (_transaction != null)
|
||||||
|
_transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (_transaction != null)
|
||||||
|
_transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 列表
|
/// 列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -99,12 +127,12 @@ namespace WMS.Web.Repositories
|
|||||||
query = query.Where(w => EF.Functions.Like(w.srcBox.BoxBillNo, "%" + dto.SrcBox + "%"));
|
query = query.Where(w => EF.Functions.Like(w.srcBox.BoxBillNo, "%" + dto.SrcBox + "%"));
|
||||||
if (!string.IsNullOrEmpty(dto.DestBox))
|
if (!string.IsNullOrEmpty(dto.DestBox))
|
||||||
query = query.Where(w => EF.Functions.Like(w.destBox.BoxBillNo, "%" + dto.DestBox + "%"));
|
query = query.Where(w => EF.Functions.Like(w.destBox.BoxBillNo, "%" + dto.DestBox + "%"));
|
||||||
if (dto.StockId != null)
|
//if (dto.StockId != null)
|
||||||
query = query.Where(w => w.changeBox.StockId == dto.StockId);
|
// query = query.Where(w => w.changeBox.StockId == dto.StockId);
|
||||||
if (dto.SrcSubStockId != null)
|
//if (dto.SrcSubStockId != null)
|
||||||
query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
|
// query = query.Where(w => w.changeBox.SrcSubStockId == dto.SrcSubStockId);
|
||||||
if (dto.DestSubStockId != null)
|
//if (dto.DestSubStockId != null)
|
||||||
query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
|
// query = query.Where(w => w.changeBox.DestSubStockId == dto.DestSubStockId);
|
||||||
if (dto.CreateBeginDate != null)
|
if (dto.CreateBeginDate != null)
|
||||||
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
|
query = query.Where(w => w.changeBox.CreateTime >= dto.CreateBeginDate);
|
||||||
if (dto.CreateEndDate != null)
|
if (dto.CreateEndDate != null)
|
||||||
@@ -117,12 +145,12 @@ namespace WMS.Web.Repositories
|
|||||||
MaterialName = "",
|
MaterialName = "",
|
||||||
MaterialNumber = "",
|
MaterialNumber = "",
|
||||||
Specifications = "",
|
Specifications = "",
|
||||||
Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.changeBox.StockId),
|
//Stock = _singleDataService.GetSingleData(SingleAction.Stocks, _loginRepositories.CompanyId, s.changeBox.StockId),
|
||||||
SerialNumbers = JsonConvert.SerializeObject(s.changeBox.SerialNumbers),
|
SerialNumbers = JsonConvert.SerializeObject(s.changeBox.SerialNumbers),
|
||||||
SrcBox = s.srcBox.BoxBillNo,
|
SrcBox = s.srcBox.BoxBillNo,
|
||||||
DestBox = s.destBox.BoxBillNo,
|
DestBox = s.destBox.BoxBillNo,
|
||||||
SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
|
//SrcSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.SrcSubStockId),
|
||||||
DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
|
//DestSubStock = _singleDataService.GetSingleData(SingleAction.SubStocks, _loginRepositories.CompanyId, s.changeBox.DestSubStockId),
|
||||||
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
|
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.changeBox.CreatorId),
|
||||||
CreateTime = s.changeBox.CreateTime.DateToStringSeconds()
|
CreateTime = s.changeBox.CreateTime.DateToStringSeconds()
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user