调整金蝶数据生成出库任务单

This commit is contained in:
18942506660
2023-11-22 10:34:25 +08:00
parent 21291356d7
commit f860206340
2 changed files with 20 additions and 17 deletions

View File

@@ -72,10 +72,10 @@ namespace WMS.Web.Domain.Entitys
/// 明细
/// </summary>
public List<OutStockTaskDetails> Details = new List<OutStockTaskDetails>();
public void Create(OutStockType type, int deliveryOrgId, int receiptCustomerId, DateTime createTime)
public void Create(OutStockType type,string stockCode, int deliveryOrgId, int receiptCustomerId, DateTime createTime)
{
this.Type = type;
//this.SourceBillNos.Add(sourceBillNo);
this.StockCode = stockCode;
this.DeliveryOrgId = deliveryOrgId;
this.ReceiptCustomerId = receiptCustomerId;
this.CreateTime = createTime;

View File

@@ -107,7 +107,7 @@ namespace WMS.Web.Domain.Services
{
var sourcNos = outStockTask.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo).ToList();
//仓库不同 拆分成不同的任务单
var erps = erp_list.Where(w => sourcNos.Contains(w.SourceBillNo)).ToList();
var erps = erp_list.Where(w => sourcNos.Contains(w.SourceBillNo) && outStockTask.StockCode.Equals(w.StockCode)).ToList();
foreach (var erp in erps)
{
//仓库不同 拆分成不同的
@@ -122,20 +122,18 @@ namespace WMS.Web.Domain.Services
}
else
{
//找到物料明细下面对应的来源单明细 然后修改
var erpDetail = detail.ErpDetails.FirstOrDefault(f => f.SourceBillNo.Equals(erp.SourceBillNo));
//找到物料明细下面对应的金蝶明细Id 然后修改(跟金蝶明细一一对应)
var erpDetail = detail.ErpDetails.FirstOrDefault(f => f.Erp_DetailId == erp.Erp_DetailId);
if (erpDetail == null)
{
erpDetail = _mapper.Map<OutStockTaskErpDetails>(erp);
detail.ErpDetails.Add(erpDetail);
outStockTask.Details.Add(detail);
}
else
{
erpDetail.AccruedQty = erp.AccruedQty;
detail.AccruedQty = detail.ErpDetails.Sum(s => s.AccruedQty);
}
}
//操作完后剔除
erp_removeList.Add(erp);
}
@@ -155,21 +153,26 @@ namespace WMS.Web.Domain.Services
if (erp_list.Count != 0)
{
var add_entitys = new List<OutStockTask>();
var billNos = erp_list.GroupBy(x => x.SourceBillNo).Select(x => x.Key).ToList();
//根据来源订单号和仓库分组 一个来源订单号和一个仓库 对应一个任务单
var billNos = erp_list.GroupBy(x => (x.SourceBillNo, x.StockCode)).Select(x => x.Key).ToList();
foreach (var item in billNos)
{
var e = erp_list.FirstOrDefault(f => f.SourceBillNo == item);
var eList = erp_list.Where(f => f.SourceBillNo == item.SourceBillNo && f.StockCode == item.StockCode).ToList();
var e = eList.First();
var entity = new OutStockTask();
entity.Create((OutStockType)e.Type, e.DeliveryOrgId, e.ReceiptCustomerId, (DateTime)e.CreateTime);
entity.Create((OutStockType)e.Type, e.StockCode, e.DeliveryOrgId, e.ReceiptCustomerId, (DateTime)e.CreateTime);
//找到当前对应来源单据编号的集合数据
var current_erp_details = erp_list.Where(x => x.SourceBillNo == item).ToList();
var mIds = eList.GroupBy(g => g.MaterialId).Select(s => s.Key).ToList();
//给到dto的实体明细中
foreach (var erp in current_erp_details)
foreach (var mid in mIds)
{
var detail = _mapper.Map<OutStockTaskDetails>(erp);
var erpDetail = _mapper.Map<OutStockTaskErpDetails>(erp);
detail.ErpDetails.Add(erpDetail);
var emList = eList.Where(w => w.MaterialId == mid).ToList();
var detail = _mapper.Map<OutStockTaskDetails>(emList.First());
var erpDetail = _mapper.Map<List<OutStockTaskErpDetails>>(emList);
detail.ErpDetails.AddRange(erpDetail);
detail.AccruedQty = detail.ErpDetails.Sum(s => s.AccruedQty);
entity.Details.Add(detail);
}
add_entitys.Add(entity);