This commit is contained in:
tongfei
2023-11-10 18:26:58 +08:00
parent 1a76ffdfc1
commit 848083c707
3 changed files with 85 additions and 2 deletions

View File

@@ -2532,6 +2532,14 @@
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="M:WMS.Web.Domain.Services.InStockTaskService.SysnMiscellaneous(System.Collections.Generic.List{System.String},System.Boolean)">
<summary>
同步:其他入库单
</summary>
<param name="billNos"></param>
<param name="isTransaction"></param>
<returns></returns>
</member>
<member name="T:WMS.Web.Domain.Services.OutStockService">
<summary>
出库服务

View File

@@ -344,11 +344,11 @@ namespace WMS.Web.Domain.Services
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.BoxNoData);
//3.比对false为比对失败;
bool isRight = box.Details.All(x => task.Details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty == x.Qty)) && box.Details.Count == task.Details.Count;
bool isRight = box.Details.All(x => task.Details.Any(t => t.MaterialId == x.MaterialId && t.AccruedQty >= x.Qty)) && box.Details.Count == task.Details.Count;
if(!isRight)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.ContrastError);
//4.是否存在箱号判断:存在的话,就不能收货或者非采购上架
//4.是否任务单存在绑定箱号判断:存在的话,就不能收货或者非采购上架
bool isHave = task.Boxs.Where(x => x.BoxBillNo == box.BoxBillNo).Any();
if(isHave)
return Result<ContrastMaterialsResponse>.ReFailure(ResultCodes.BoxHaveError);

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto.Erp;
using WMS.Web.Core.Dto.Erp.Purchase;
using WMS.Web.Core.Dto.InStockTask;
using WMS.Web.Core.Internal.Results;
@@ -169,5 +170,79 @@ namespace WMS.Web.Domain.Services
return Result.ReSuccess();
}
/// <summary>
/// 同步:其他入库单
/// </summary>
/// <param name="billNos"></param>
/// <param name="isTransaction"></param>
/// <returns></returns>
public async Task<Result> SysnMiscellaneous(List<string> billNos = null, bool isTransaction = true)
{
//1.获取金蝶数据:其他入库订单数据
var erp_result = await _erpService.BillQueryForMiscellaneous(billNos);
if (!erp_result.IsSuccess)
return Result.ReFailure(erp_result.Message, erp_result.Status);
var erp_list = erp_result.Data;
//2.通过单据编号找到wms系统现有的任务单并修改
var erp_removeList = new List<ErpMiscellaneousDto>();
var SourceBillNo_list = erp_list.GroupBy(x => x.BillNo).Select(x => x.Key).ToList();
var data_list = await _inStockTaskRepositories.GetListBy(SourceBillNo_list);
if (data_list.Count != 0)
{
//2.1提取出wms任务单明细信息
var data_list_details = data_list.SelectMany(x => x.Details).ToList();
foreach (var item in data_list_details)
{
var data = data_list.Where(x => x.Id == item.Fid).FirstOrDefault();
//2.1.1对比erp的物料信息
var erp_data = erp_list.Where(x => x.BillNo == data.SourceBillNo && x.MaterialId == item.MaterialId).FirstOrDefault();
if (erp_data != null)
{
//2.1.2修改数量
item.AccruedQty = erp_data.Qty;
erp_removeList.Add(erp_data);
}
}
//2.2.提交修改
var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction);
if (!isSuccess)
return ResultList<ErpPurchaseInStockResultDto>.ReFailure(ResultCodes.DateWriteError);
//2.3剔除:已修改的单据
foreach (var item in erp_removeList)
{
erp_list.Remove(item);
}
}
//3.wms任务单的来源单据编号不存在于erp中那么就新增
if (erp_list.Count != 0)
{
var add_entitys = new List<InStockTask>();
var current_billNos = erp_list.GroupBy(x => x.BillNo).Select(x => x.Key).ToList();
foreach (var item in current_billNos)
{
var dto = new InStockTask();
dto.SourceBillNo = item;
dto.Create(InstockType.Purchase);
//找到当前对应来源单据编号的集合数据
var current_erp_details = erp_list.Where(x => x.BillNo == item).ToList();
//给到dto的实体明细中
dto.Details = _mapper.Map<List<InStockTaskDetails>>(current_erp_details);
add_entitys.Add(dto);
}
//3.1提交新增
var isSuccess = await _inStockTaskRepositories.AddRange(add_entitys, isTransaction);
if (!isSuccess)
return ResultList<ErpPurchaseInStockResultDto>.ReFailure(ResultCodes.DateWriteError);
}
return Result.ReSuccess();
}
}
}