优化接口

This commit is contained in:
tongfei
2023-12-06 10:46:02 +08:00
parent 033f442e9d
commit fd7cc0edaf
3 changed files with 48 additions and 35 deletions

View File

@@ -1304,12 +1304,22 @@
</member>
<member name="P:WMS.Web.Domain.Entitys.OutStockTask.OperatorId">
<summary>
操作人(出库人)
操作人
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.OutStockTask.OperateTime">
<summary>
操作时间(出库时间)
操作时间
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.OutStockTask.OutStockId">
<summary>
出库人
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.OutStockTask.OutStockTime">
<summary>
出库时间
</summary>
</member>
<member name="P:WMS.Web.Domain.Entitys.OutStockTask.CreateTime">
@@ -1322,7 +1332,7 @@
明细
</summary>
</member>
<member name="M:WMS.Web.Domain.Entitys.OutStockTask.OutStock(System.Int32,System.Decimal)">
<member name="M:WMS.Web.Domain.Entitys.OutStockTask.OutStock(System.Int32,System.Decimal,System.Int32)">
<summary>
出库 反写 任务单(返回 这个物料下面的来源单号出了多少数量)
</summary>

View File

@@ -151,13 +151,13 @@ namespace WMS.Web.Domain.Services
materials = materials_result.Data.ToList();
//1.先判断:箱号已经绑定了入库任务单中;备注:业务说法就是箱是否收货了
var tast_box= await _inStockTaskBoxRepositories.GetBy(dto.BoxBillNo);
var tast_box = await _inStockTaskBoxRepositories.GetBy(dto.BoxBillNo);
if (tast_box == null)
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.Box_NoBind_Task_Data);
//1.2找到任务单
var tast = await _inStockTaskRepositories.Get(tast_box.TaskId);
if(tast == null)
if (tast == null)
return Result<BoxInStockTaskDto>.ReFailure(ResultCodes.InStockTaskNoData);
//1.2.1判断箱子绑定的物料明细数据的仓库,是不是用户所选的仓库;不是则提示:箱号仓库不对
@@ -251,7 +251,7 @@ namespace WMS.Web.Domain.Services
{
task.Details.ForEach(x =>
{
var current_entityDets= dto.Details.Where(t => t.ErpDetailId == x.ErpDetailId).ToList();
var current_entityDets = dto.Details.Where(t => t.ErpDetailId == x.ErpDetailId).ToList();
if (current_entityDets != null && current_entityDets.Count != 0 && x.ErpDetailId == current_entityDets.FirstOrDefault().ErpDetailId)
{
var current_entityDet_matQty = current_entityDets.Sum(x => x.Qty);
@@ -291,7 +291,7 @@ namespace WMS.Web.Domain.Services
private async Task<Result> ShelfNoPurchaseSave(NoPurchaseShelfRequest dto, LoginInDto loginInfo, bool isTransaction = true)
{
//1.1过滤的明细0数量入库的明细要过滤掉
dto.Boxs.ForEach(x =>
dto.Boxs.ForEach(x =>
{
x.Details.RemoveAll(t => t.Qty == 0);
});
@@ -455,26 +455,26 @@ namespace WMS.Web.Domain.Services
});
//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();
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>();
var boxEntitys = await _boxRepositories.GetEntityList(dto_boxIds);
var taskBoxAdd = new List<InStockTaskBox>();
foreach (var item in dto.Boxs)
{
var taskBox = _mapper.Map<InStockTaskBox>(item);
taskBox.TaskId = entity.Id;
var current_dto_box_dets= boxEntitys.Where(x => x.Id == item.BoxId).SelectMany(x=>x.Details).ToList();
var current_dto_box_dets = boxEntitys.Where(x => x.Id == item.BoxId).SelectMany(x => x.Details).ToList();
taskBox.Details = _mapper.Map<List<InStockTaskBoxDetails>>(current_dto_box_dets);
taskBox.Details.ForEach(x => { x.ErpDetailId = item.ErpDetailId; });
taskBoxAdd.Add(taskBox);
}
var isSuccess= await _inStockTaskBoxRepositories.AddRange(taskBoxAdd,isTransaction);
if(!isSuccess)
var isSuccess = await _inStockTaskBoxRepositories.AddRange(taskBoxAdd, isTransaction);
if (!isSuccess)
return Result<InStockTask>.ReFailure(ResultCodes.DateWriteError);
@@ -536,40 +536,41 @@ namespace WMS.Web.Domain.Services
//判断箱是否存在库存:有的话就提示“箱号已上架入库”
var boxInventory = await _boxInventoryRepositories.GetList(boxs.Select(x => x.Id).ToList());
if(boxInventory!=null && boxInventory.Count!=0)
if (boxInventory != null && boxInventory.Count != 0)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.BoxInventoryHaveInventoryError);
//合并多个箱明细的数据:相同物料数量合并
var boxDetails = boxs.SelectMany(x => x.Details).GroupBy(x => x.MaterialId).Select(x => new { MaterialId = x.Key, Qty = x.Sum(t => t.Qty) }).ToList();
//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 (task.Type == InstockType.Purchase)
{
var qtyIsError = boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty < x.Qty));
if (boxDetails.Count > task_details.Count && qtyIsError)
//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 (task.Type == InstockType.Purchase)
var qtyIsError = boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty < x.Qty));
if (boxDetails.Count > task_details.Count && qtyIsError)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Purchase_Error);
else if (qtyIsError)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Qty_Error);
else
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.ContrastError);
}
else if (qtyIsError)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Qty_Error);
else
{
if (task.Type == InstockType.Purchase)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Purchase_Count_Error);
else
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Count_Error);
}
}
}
//非采购单:不要对比数量,只对比物料
else
{
//3.比对false为比对失败;
bool isRight = boxDetails.All(x => task_details.Any(t => t.MaterialId == x.MaterialId)) && boxDetails.Count <= task_details.Count;
if (!isRight)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.Contrast_Count_Error);
}
//4.是否任务单存在绑定箱号判断:存在的话,就不能收货或者非采购上架
var taskBoxList= await _inStockTaskBoxRepositories.GetListBy(task.Id);
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);
@@ -588,5 +589,7 @@ namespace WMS.Web.Domain.Services
}
return Result<ContrastMaterialsResponse>.ReSuccess(response);
}
}
}

View File

@@ -46,7 +46,7 @@ namespace WMS.Web.Domain.Values
public static ValueTuple<int, string> Box_NoBind_Task_Data = (80001, "该箱号不在收货信息中,请核对再试!");
public static ValueTuple<int, string> OrderNoData = (80002, "单据信息不存在,请核对后再试!");
public static ValueTuple<int, string> ContrastError = (80003, "箱内产品和数量与来源单不一致");
public static ValueTuple<int, string> Contrast_Purchase_Error = (80003, "箱内产品和数量与来源单不一致");
public static ValueTuple<int, string> Contrast_Purchase_Error = (80003, "箱内产品和数量与采购单不一致");
public static ValueTuple<int, string> Contrast_Purchase_Count_Error = (80003, "箱内产品和采购单不一致");
public static ValueTuple<int, string> Contrast_Count_Error = (80003, "箱内产品和来源单不一致");
public static ValueTuple<int, string> Contrast_Qty_Error = (80003, "箱内产品数量超过可入库数量");