收货-优化
This commit is contained in:
@@ -1725,6 +1725,11 @@
|
||||
箱信息ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskBoxRequest.ErpDetailId">
|
||||
<summary>
|
||||
对应金蝶的明细ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskBoxRequest.BoxBillNo">
|
||||
<summary>
|
||||
箱号
|
||||
@@ -1735,9 +1740,9 @@
|
||||
修改-入库任务单-明细对象
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskDetailsRequest.Id">
|
||||
<member name="P:WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskDetailsRequest.ErpDetailId">
|
||||
<summary>
|
||||
明细ID
|
||||
对应金蝶的明细ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskDetailsRequest.MaterialId">
|
||||
|
||||
@@ -675,11 +675,6 @@
|
||||
创建时间(erp那边的创建时间)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTask.Boxs">
|
||||
<summary>
|
||||
箱信息集合
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTask.Details">
|
||||
<summary>
|
||||
明细
|
||||
@@ -748,6 +743,41 @@
|
||||
箱号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBox.Details">
|
||||
<summary>
|
||||
明细
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockTaskBoxDetails">
|
||||
<summary>
|
||||
erp入库任务单的对应box箱信息表的明细表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBoxDetails.Id">
|
||||
<summary>
|
||||
ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBoxDetails.Fid">
|
||||
<summary>
|
||||
上级ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBoxDetails.ErpDetailId">
|
||||
<summary>
|
||||
对应金蝶的明细ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBoxDetails.MaterialId">
|
||||
<summary>
|
||||
物料ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:WMS.Web.Domain.Entitys.InStockTaskBoxDetails.ReceiveQty">
|
||||
<summary>
|
||||
收货数量
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Entitys.InStockTaskDetails">
|
||||
<summary>
|
||||
erp入库任务明细表
|
||||
@@ -1934,6 +1964,33 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories">
|
||||
<summary>
|
||||
箱与任务单绑定(收货)关系表-仓储接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetListBy(System.Int32)">
|
||||
<summary>
|
||||
集合:任务单ID
|
||||
</summary>
|
||||
<param name="taskId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.GetBy(System.String)">
|
||||
<summary>
|
||||
实体:箱号ID
|
||||
</summary>
|
||||
<param name="boxBillNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskBoxRepositories.AddRange(System.Collections.Generic.List{WMS.Web.Domain.Entitys.InStockTaskBox},System.Boolean)">
|
||||
<summary>
|
||||
批量添加
|
||||
</summary>
|
||||
<param name="entitys"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories">
|
||||
<summary>
|
||||
入库任务-仓储接口
|
||||
@@ -1953,13 +2010,6 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetBy(System.String)">
|
||||
<summary>
|
||||
实体:根据箱号
|
||||
</summary>
|
||||
<param name="boxBillNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetBySource(System.String)">
|
||||
<summary>
|
||||
实体:根据来源单号
|
||||
@@ -1967,13 +2017,6 @@
|
||||
<param name="sourceBillNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.IsExist(System.String)">
|
||||
<summary>
|
||||
箱号是否绑定了入库任务单实体:待入库和部分入库状态中
|
||||
</summary>
|
||||
<param name="boxBillNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Infrastructure.IInStockTaskRepositories.GetList(System.Collections.Generic.List{System.Int32})">
|
||||
<summary>
|
||||
列表
|
||||
@@ -2372,16 +2415,6 @@
|
||||
<param name="boxBillNo"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.Update(WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskRequest,System.Int32,System.Nullable{System.Boolean},System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
修改-入库任务信息
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<param name="staffId"></param>
|
||||
<param name="isReceive"></param>
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.IService.IInStockService.UpdateRange(System.Collections.Generic.List{System.Int32},System.Int32,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
批量修改-入库任务信息
|
||||
@@ -3620,7 +3653,7 @@
|
||||
<param name="isTransaction"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Update(WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskRequest,System.Int32,System.Nullable{System.Boolean},System.Boolean,System.Boolean)">
|
||||
<member name="M:WMS.Web.Domain.Services.InStockService.Receive(WMS.Web.Core.Dto.InStockTask.UpdateInStockTaskRequest,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
修改-入库任务信息
|
||||
</summary>
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace WMS.Web.Core.Dto.InStockTask
|
||||
/// </summary>
|
||||
public int BoxId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对应金蝶的明细ID
|
||||
/// </summary>
|
||||
public int ErpDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱号
|
||||
/// </summary>
|
||||
|
||||
@@ -9,11 +9,12 @@ namespace WMS.Web.Core.Dto.InStockTask
|
||||
/// </summary>
|
||||
public class UpdateInStockTaskDetailsRequest : EntityBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 明细ID
|
||||
/// 对应金蝶的明细ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; } = 0;
|
||||
|
||||
public int ErpDetailId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
|
||||
@@ -33,5 +33,10 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 箱号
|
||||
/// </summary>
|
||||
public string BoxBillNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public List<InStockTaskBoxDetails> Details { get; set; } = new List<InStockTaskBoxDetails>();
|
||||
}
|
||||
}
|
||||
|
||||
37
src/WMS.Web.Domain/Entitys/InStockTaskBoxDetails.cs
Normal file
37
src/WMS.Web.Domain/Entitys/InStockTaskBoxDetails.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
using WMS.Web.Core;
|
||||
|
||||
namespace WMS.Web.Domain.Entitys
|
||||
{
|
||||
/// <summary>
|
||||
/// erp入库任务单的对应box箱信息表的明细表
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_erp_instock_task_box_details")]
|
||||
public class InStockTaskBoxDetails : EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public override int Id { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 上级ID
|
||||
/// </summary>
|
||||
public int Fid { get; set; }
|
||||
/// <summary>
|
||||
/// 对应金蝶的明细ID
|
||||
/// </summary>
|
||||
public int ErpDetailId { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public int MaterialId { get; set; }
|
||||
/// <summary>
|
||||
/// 收货数量
|
||||
/// </summary>
|
||||
public decimal ReceiveQty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -57,11 +57,6 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 箱信息集合
|
||||
/// </summary>
|
||||
public List<InStockTaskBox> Boxs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 明细
|
||||
/// </summary>
|
||||
|
||||
@@ -56,16 +56,6 @@ namespace WMS.Web.Domain.IService
|
||||
/// <returns></returns>
|
||||
Task<Result<BoxInStockTaskDto>> GetInfoByBox(string boxBillNo);
|
||||
|
||||
/// <summary>
|
||||
/// 修改-入库任务信息
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="staffId"></param>
|
||||
/// <param name="isReceive"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<Result<InStockTask>> Update(UpdateInStockTaskRequest dto, int staffId, bool? isReceive, bool isTransaction = true, bool isNoPurchaseShelf = false);
|
||||
|
||||
/// <summary>
|
||||
/// 批量修改-入库任务信息
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
|
||||
namespace WMS.Web.Domain.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱与任务单绑定(收货)关系表-仓储接口
|
||||
/// </summary>
|
||||
public interface IInStockTaskBoxRepositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 集合:任务单ID
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<InStockTaskBox>> GetListBy(int taskId);
|
||||
|
||||
/// <summary>
|
||||
/// 实体:箱号ID
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<InStockTaskBox> GetBy(string boxBillNo);
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRange(List<InStockTaskBox> entitys, bool isTransaction = true);
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,6 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <returns></returns>
|
||||
Task<InStockTask> Get(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 实体:根据箱号
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<InStockTask> GetBy(string boxBillNo);
|
||||
|
||||
/// <summary>
|
||||
/// 实体:根据来源单号
|
||||
/// </summary>
|
||||
@@ -43,13 +36,6 @@ namespace WMS.Web.Domain.Infrastructure
|
||||
/// <returns></returns>
|
||||
Task<InStockTask> GetBySource(string sourceBillNo);
|
||||
|
||||
/// <summary>
|
||||
/// 箱号是否绑定了入库任务单实体:待入库和部分入库状态中
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExist(string boxBillNo);
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
|
||||
@@ -18,12 +18,11 @@ namespace WMS.Web.Domain.Mappers
|
||||
public InStockMapper()
|
||||
{
|
||||
CreateMap<UpdateInStockTaskRequest, InStockTask>()
|
||||
.ForMember(x => x.Boxs, opt => opt.Ignore())
|
||||
.ForMember(x => x.Details, opt => opt.Ignore());
|
||||
CreateMap<UpdateInStockTaskDetailsRequest, InStockTaskDetails>();
|
||||
CreateMap<UpdateInStockTaskBoxRequest, InStockTaskBox>();
|
||||
CreateMap<UpdateInStockTaskDetailsRequest, InStockTaskBoxDetails>();
|
||||
CreateMap<UpdateInStockTaskBoxRequest, InStockTaskBox>()
|
||||
.ForMember(x => x.Details, opt => opt.Ignore());
|
||||
CreateMap<InStockTask, InStockTask>()
|
||||
.ForMember(x => x.Boxs, opt => opt.Ignore())
|
||||
.ForMember(x => x.Details, opt => opt.Ignore());
|
||||
CreateMap<InStockTaskDetails, InStockTaskDetails>();
|
||||
CreateMap<InStockTaskBox, InStockTaskBox>();
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly ILoginService _loginService;
|
||||
private readonly ISerialNumberService _serialNumberService;
|
||||
private readonly ISerialNumbersRepositories _serialNumbersRepositories;
|
||||
private readonly IInStockTaskBoxRepositories _inStockTaskBoxRepositories;
|
||||
private readonly IChangeMoveBoxService _changeMoveBoxService;
|
||||
private readonly IBoxRepositories _boxRepositories;
|
||||
private readonly IBoxInventoryService _boxInventoryService;
|
||||
@@ -41,7 +42,7 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IInStockTaskRepositories _inStockTaskRepositories;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
public InStockService(IMapper mapper, ISerialNumbersRepositories serialNumbersRepositories, IErpService erpService, IBoxInventoryService boxInventoryService, ISerialNumberService serialNumberService, ILoginService loginService, IBoxRepositories boxRepositories,
|
||||
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, IChangeMoveBoxService changeMoveBoxService,
|
||||
IBasicsRepositories basicsRepositories, IErpBasicDataExtendService erpBasicDataExtendService, IChangeMoveBoxService changeMoveBoxService, IInStockTaskBoxRepositories inStockTaskBoxRepositories,
|
||||
IInStockRepositories inStockRepositories, IInStockTaskRepositories inStockTaskRepositories)
|
||||
{
|
||||
_mapper = mapper;
|
||||
@@ -53,6 +54,7 @@ namespace WMS.Web.Domain.Services
|
||||
_changeMoveBoxService = changeMoveBoxService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_inStockRepositories = inStockRepositories;
|
||||
_inStockTaskBoxRepositories = inStockTaskBoxRepositories;
|
||||
_inStockTaskRepositories = inStockTaskRepositories;
|
||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||
_serialNumbersRepositories = serialNumbersRepositories;
|
||||
@@ -79,7 +81,7 @@ namespace WMS.Web.Domain.Services
|
||||
IDbContextTransaction _transaction = _basicsRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isTransaction = false;
|
||||
var result = await this.Update(dto, loginInfo.UserInfo.StaffId, true, isTransaction);
|
||||
var result = await this.Receive(dto, loginInfo.UserInfo.StaffId, isTransaction);
|
||||
if (!result.IsSuccess) isRollback = true;
|
||||
|
||||
//提交事务
|
||||
@@ -147,10 +149,13 @@ namespace WMS.Web.Domain.Services
|
||||
materials = materials_result.Data.ToList();
|
||||
|
||||
//1.先判断:箱号已经绑定了入库任务单中;备注:业务说法就是箱是否收货了
|
||||
var tast = await _inStockTaskRepositories.GetBy(boxBillNo);
|
||||
if (tast == null)
|
||||
var tast_box= await _inStockTaskBoxRepositories.GetBy(boxBillNo);
|
||||
if (tast_box == null)
|
||||
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data);
|
||||
|
||||
//1.2找到任务单
|
||||
var tast = await _inStockTaskRepositories.Get(tast_box.TaskId);
|
||||
|
||||
//2.找到箱对应的物料信息
|
||||
var box = await _boxRepositories.GetByNo(boxBillNo);
|
||||
if (box == null)
|
||||
@@ -166,25 +171,29 @@ namespace WMS.Web.Domain.Services
|
||||
result.SourceBillNo = tast.SourceBillNo;
|
||||
result.TaskId = tast.Id;
|
||||
result.BoxId = box.Id;
|
||||
foreach (var item in tast.Details)
|
||||
//获取:当前箱的与收货绑定的信息
|
||||
foreach (var item in tast_box.Details)
|
||||
{
|
||||
//这里找箱的物料条件
|
||||
var current_box_Det = box.Details.Where(x => x.MaterialId == item.MaterialId).FirstOrDefault();
|
||||
var current_task_det = tast.Details.Where(x => x.ErpDetailId == item.ErpDetailId).FirstOrDefault();
|
||||
if (current_task_det != null)
|
||||
{
|
||||
//3.2映射返回明细对象
|
||||
var box_task_detail = new BoxDetailsInStockTaskDto();
|
||||
box_task_detail.SupplierId = current_task_det.SupplierId;
|
||||
box_task_detail.OrgId = current_task_det.OrgId;
|
||||
box_task_detail.ReceiveQty = current_task_det.ReceiveQty;
|
||||
box_task_detail.AccruedQty = current_task_det.AccruedQty;
|
||||
box_task_detail.ErpDetailId = item.ErpDetailId;
|
||||
box_task_detail.MaterialId = item.MaterialId;
|
||||
box_task_detail.BoxMaterialQty = item.ReceiveQty;
|
||||
box_task_detail.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, item.MaterialId);
|
||||
box_task_detail.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, item.MaterialId);
|
||||
box_task_detail.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, item.MaterialId);
|
||||
result.Details.Add(box_task_detail);
|
||||
}
|
||||
|
||||
//3.2映射返回明细对象
|
||||
var box_task_detail = new BoxDetailsInStockTaskDto();
|
||||
box_task_detail.SupplierId = item.SupplierId;
|
||||
box_task_detail.OrgId = item.OrgId;
|
||||
box_task_detail.ReceiveQty = item.ReceiveQty;
|
||||
box_task_detail.AccruedQty = item.AccruedQty;
|
||||
box_task_detail.ErpDetailId= item.ErpDetailId;
|
||||
box_task_detail.MaterialId = item.MaterialId;
|
||||
box_task_detail.BoxMaterialQty = current_box_Det==null?0:current_box_Det.Qty;
|
||||
box_task_detail.MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, item.MaterialId);
|
||||
box_task_detail.MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, item.MaterialId);
|
||||
box_task_detail.Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, item.MaterialId);
|
||||
result.Details.Add(box_task_detail);
|
||||
}
|
||||
|
||||
return Result<BoxInStockTaskDto>.ReSuccess(result);
|
||||
}
|
||||
|
||||
@@ -343,7 +352,7 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
//通过序列号,获取序列号对应的箱
|
||||
var cureent_serialNumbs = await _serialNumbersRepositories.GetEntityList(dto.Boxs.SelectMany(x => x.Details).SelectMany(x => x.SerialNumbers).ToList());
|
||||
var current_boxIds= cureent_serialNumbs.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var current_boxIds = cureent_serialNumbs.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
|
||||
//要改箱的数据集合
|
||||
var ganenrateChangeBoxs = new List<SaveChangeBoxRecordRequest>();
|
||||
@@ -401,38 +410,50 @@ namespace WMS.Web.Domain.Services
|
||||
/// <param name="isReceive"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<InStockTask>> Update(UpdateInStockTaskRequest dto, int staffId, bool? isReceive, bool isTransaction = true, bool isNoPurchaseShelf = false)
|
||||
public async Task<Result<InStockTask>> Receive(UpdateInStockTaskRequest dto, int staffId, bool isTransaction)
|
||||
{
|
||||
//1.修改任务单的数据
|
||||
var entity = await _inStockTaskRepositories.Get(dto.Id);
|
||||
if (entity == null)
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
entity = _mapper.Map(dto, entity);
|
||||
////子集单独映射:这个弃用;这个不好的地方就是,前端必须拿到全部的boxs集合一起给到后端处理;
|
||||
//entity.Boxs = _mapper.ToMapList(dto.Boxs, entity.Boxs);
|
||||
//子集单独映射:box子集单独组装获取;这个好处就是前端就只传新增的box过来;
|
||||
entity.Receive(staffId);
|
||||
//子集单独映射
|
||||
entity.Details.ForEach(x =>
|
||||
{
|
||||
//当前明细收货的明细:可以通过erp明细ID获取唯一一个;并变更收货数量
|
||||
var current_dto_det = dto.Details.Where(x => x.ErpDetailId == x.ErpDetailId).FirstOrDefault();
|
||||
if (current_dto_det != null)
|
||||
x.ReceiveQty = x.ReceiveQty + current_dto_det.ReceiveQty;
|
||||
});
|
||||
|
||||
//2.修改箱和任务单的绑定关系,先判断箱没有被收货过
|
||||
var taskBoxList= await _inStockTaskBoxRepositories.GetListBy(entity.Id);
|
||||
var dto_boxIds= dto.Boxs.GroupBy(x => x.BoxId).Select(x => x.Key).ToList();
|
||||
var isHaveBox= taskBoxList.Where(x => dto_boxIds.Contains(x.BoxId)).Any();
|
||||
if (isHaveBox)
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.InStockTaskBoxIsHaveData);
|
||||
|
||||
//3.组装绑定关系表,要添加的集合
|
||||
var boxEntitys= await _boxRepositories.GetEntityList(dto_boxIds);
|
||||
var taskBoxAdd = new List<InStockTaskBox>();
|
||||
foreach (var item in dto.Boxs)
|
||||
{
|
||||
var box = _mapper.Map<InStockTaskBox>(item);
|
||||
entity.Boxs.Add(box);
|
||||
var taskBox = _mapper.Map<InStockTaskBox>(item);
|
||||
var current_dto_box_dets= boxEntitys.Where(x => x.Id == item.BoxId).Select(x=>x.Details).ToList();
|
||||
taskBox.Details = _mapper.Map<List<InStockTaskBoxDetails>>(current_dto_box_dets);
|
||||
taskBoxAdd.Add(taskBox);
|
||||
}
|
||||
|
||||
//子集单独映射
|
||||
entity.Details = _mapper.ToMapList(dto.Details, entity.Details);
|
||||
if (isNoPurchaseShelf)
|
||||
entity.NoPurchaseShelf(staffId);
|
||||
else
|
||||
{
|
||||
if (isReceive.HasValue && isReceive.Value)
|
||||
entity.Receive(staffId);
|
||||
else
|
||||
entity.Shelf(staffId);
|
||||
}
|
||||
var result = await _inStockTaskRepositories.Update(entity, isTransaction);
|
||||
if (result != null)
|
||||
return Result<InStockTask>.ReSuccess(entity);
|
||||
else
|
||||
var isSuccess= await _inStockTaskBoxRepositories.AddRange(taskBoxAdd);
|
||||
if(!isSuccess)
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
|
||||
//数据库操作
|
||||
var result = await _inStockTaskRepositories.Update(entity, isTransaction);
|
||||
if (result == null)
|
||||
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
|
||||
return Result<InStockTask>.ReSuccess(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -489,22 +510,23 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
//3.比对:false为比对失败;
|
||||
bool isRight = boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty >= x.Qty)) && boxDetails.Count <= task_details.Count;
|
||||
if (!isRight)
|
||||
if (!isRight)
|
||||
{
|
||||
var qtyIsError= boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty < x.Qty));
|
||||
var qtyIsError = boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty < x.Qty));
|
||||
|
||||
if (boxDetails.Count> task_details.Count && qtyIsError)
|
||||
if (boxDetails.Count > task_details.Count && qtyIsError)
|
||||
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.ContrastError);
|
||||
else if(qtyIsError)
|
||||
else if (qtyIsError)
|
||||
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Qty_Error);
|
||||
else
|
||||
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Count_Error);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//4.是否任务单存在绑定箱号判断:存在的话,就不能收货或者非采购上架
|
||||
bool isHave = task.Boxs.Where(x => dto.BoxBillNos.Contains(x.BoxBillNo)).Any();
|
||||
var taskBoxList= await _inStockTaskBoxRepositories.GetListBy(task.Id);
|
||||
bool isHave = taskBoxList.Where(x => dto.BoxBillNos.Contains(x.BoxBillNo)).Any();
|
||||
if (isHave)
|
||||
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.BoxHaveError);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace WMS.Web.Domain.Values
|
||||
|
||||
public static ValueTuple<int, string> BoxIsTrueShelf = (80000, "该箱已上架,请选择其它箱进行上架!");
|
||||
public static ValueTuple<int, string> BoxNoData = (80000, "箱信息不存在");
|
||||
public static ValueTuple<int, string> InStockTaskBoxIsHaveData = (80000, "该箱已收货");
|
||||
public static ValueTuple<int, string> BoxMateriaNoData = (800010, "箱对应物料信息不存在");
|
||||
public static ValueTuple<int, string> MateriaNoData = (800011, "物料信息不存在");
|
||||
public static ValueTuple<int, string> BoxInventorySerialNumbersNoData = (800012, "序列号不存在于箱库存数据中");
|
||||
|
||||
@@ -211,19 +211,24 @@ namespace WMS.Web.Repositories.Configuration
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
ent.HasMany(p => p.Boxs)
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.TaskId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
builder.Entity<InStockTaskDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_erp_instock_task_details");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
builder.Entity<InStockTaskBox>(ent =>
|
||||
{
|
||||
ent.ToTable("t_erp_instock_task_box");
|
||||
ent.HasKey(x => x.Id);
|
||||
ent.HasMany(p => p.Details)
|
||||
.WithOne()
|
||||
.HasForeignKey(p => p.Fid)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
builder.Entity<InStockTaskDetails>(ent =>
|
||||
builder.Entity<InStockTaskBoxDetails>(ent =>
|
||||
{
|
||||
ent.ToTable("t_erp_instock_task_details");
|
||||
ent.ToTable("t_erp_instock_task_box_details");
|
||||
ent.HasKey(x => x.Id);
|
||||
});
|
||||
#endregion
|
||||
@@ -332,6 +337,7 @@ namespace WMS.Web.Repositories.Configuration
|
||||
public DbSet<InStockDetails> InStockDetails { get; set; }
|
||||
public DbSet<InStockTask> InStockTask { get; set; }
|
||||
public DbSet<InStockTaskBox> InstockTaskBox { get; set; }
|
||||
public DbSet<InStockTaskBoxDetails> InStockTaskBoxDetails { get; set; }
|
||||
public DbSet<InStockTaskDetails> InStockTaskDetails { get; set; }
|
||||
public DbSet<BackRecord> BackRecord { get; set; }
|
||||
public DbSet<BackRecordDetails> BackRecordDetails { get; set; }
|
||||
|
||||
104
src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs
Normal file
104
src/WMS.Web.Repositories/InStockTaskBoxRepositories.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Domain.Entitys;
|
||||
using WMS.Web.Domain.Infrastructure;
|
||||
using WMS.Web.Domain.IService.Public;
|
||||
using WMS.Web.Repositories.Configuration;
|
||||
|
||||
namespace WMS.Web.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// 箱与任务单绑定(收货)关系表-仓储
|
||||
/// </summary>
|
||||
public class InStockTaskBoxRepositories: IInStockTaskBoxRepositories
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly RepositoryDbContext _context;
|
||||
private readonly ISingleDataService _singleDataService;
|
||||
private readonly IBasicsRepositories _basicsRepositories;
|
||||
private readonly ILoginRepositories _loginRepositories;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
|
||||
|
||||
|
||||
public InStockTaskBoxRepositories(RepositoryDbContext context,
|
||||
IMapper mapper,
|
||||
IErpService erpService,
|
||||
IBasicsRepositories basicsRepositories,
|
||||
IServiceProvider serviceProvider,
|
||||
ISingleDataService singleDataService,
|
||||
ILoginRepositories loginRepositories,
|
||||
IErpBasicDataExtendService erpBasicDataExtendService)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
_erpService = erpService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_serviceProvider = serviceProvider;
|
||||
_singleDataService = singleDataService;
|
||||
_loginRepositories = loginRepositories;
|
||||
_erpBasicDataExtendService = erpBasicDataExtendService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合:任务ID
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<InStockTaskBox>> GetListBy(int taskId)
|
||||
{
|
||||
var entitys = await _context.InstockTaskBox
|
||||
.Include(s => s.Details).Where(x => x.TaskId == taskId).ToListAsync();
|
||||
return entitys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体:箱号ID
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStockTaskBox> GetBy(string boxBillNo)
|
||||
{
|
||||
var entity = await _context.InstockTaskBox
|
||||
.Include(s => s.Details).Where(x => x.BoxBillNo == boxBillNo).FirstOrDefaultAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量添加
|
||||
/// </summary>
|
||||
/// <param name="entitys"></param>
|
||||
/// <param name="isTransaction"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> AddRange(List<InStockTaskBox> entitys, bool isTransaction = true)
|
||||
{
|
||||
IDbContextTransaction _transaction = null;
|
||||
if (isTransaction)
|
||||
_transaction = _context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
if (entitys != null && entitys.Count != 0)
|
||||
{
|
||||
await _context.InstockTaskBox.AddRangeAsync(entitys);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
if (_transaction != null)
|
||||
_transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_transaction != null)
|
||||
_transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,28 +172,11 @@ namespace WMS.Web.Repositories
|
||||
public async Task<InStockTask> Get(int id)
|
||||
{
|
||||
var entity = await _context.InStockTask
|
||||
.Include(x => x.Boxs)
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == id);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体:根据箱号
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<InStockTask> GetBy(string boxBillNo)
|
||||
{
|
||||
var entity = await _context.InStockTask
|
||||
.Include(s => s.Boxs.Where(b => b.BoxBillNo == boxBillNo))
|
||||
.Include(s => s.Details)
|
||||
.Where(w => w.Boxs.Where(b => b.BoxBillNo == boxBillNo).Count() > 0).FirstOrDefaultAsync();
|
||||
|
||||
return entity;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体:根据来源单号
|
||||
/// </summary>
|
||||
@@ -202,7 +185,6 @@ namespace WMS.Web.Repositories
|
||||
public async Task<InStockTask> GetBySource(string sourceBillNo)
|
||||
{
|
||||
var entity = await _context.InStockTask
|
||||
.Include(s => s.Boxs)
|
||||
.Include(s => s.Details)
|
||||
.Where(w => w.SourceBillNo == sourceBillNo).FirstOrDefaultAsync();
|
||||
|
||||
@@ -210,20 +192,6 @@ namespace WMS.Web.Repositories
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 箱号是否绑定了任务实体:待入库和部分入库状态中
|
||||
/// </summary>
|
||||
/// <param name="boxBillNo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> IsExist(string boxBillNo)
|
||||
{
|
||||
return await _context.InStockTask
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Boxs.Where(b => b.BoxBillNo == boxBillNo))
|
||||
.Include(s => s.Details)
|
||||
.Where(w => (w.Status == InstockStatus.Part || w.Status == InstockStatus.Wait) && w.Boxs.Where(b => b.BoxBillNo == boxBillNo).Count() > 0).AnyAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
@@ -468,7 +436,7 @@ namespace WMS.Web.Repositories
|
||||
try
|
||||
{
|
||||
List<int> list = entitys.Select(s => s.Id).ToList();
|
||||
var res = await _context.InStockTask.AsNoTracking().Include(x => x.Boxs).Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
var res = await _context.InStockTask.AsNoTracking().Include(x => x.Details).Where(f => list.Contains(f.Id)).ToListAsync();
|
||||
_mapper.ToMapList(entitys, res);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
@@ -498,15 +466,12 @@ namespace WMS.Web.Repositories
|
||||
{
|
||||
var model = await _context.InStockTask
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Boxs)
|
||||
.Include(s => s.Details)
|
||||
.FirstOrDefaultAsync(f => f.Id == entity.Id);
|
||||
if (model == null)
|
||||
return null;
|
||||
_mapper.Map(entity, model);
|
||||
//子集单独映射
|
||||
_mapper.ToMapList(entity.Boxs, model.Boxs);
|
||||
//子集单独映射
|
||||
_mapper.ToMapList(entity.Details, model.Details);
|
||||
await _context.SaveChangesAsync();
|
||||
if (_transaction != null)
|
||||
|
||||
Reference in New Issue
Block a user