调整金蝶数据生成出库任务单
This commit is contained in:
@@ -72,10 +72,10 @@ namespace WMS.Web.Domain.Entitys
|
|||||||
/// 明细
|
/// 明细
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<OutStockTaskDetails> Details = new List<OutStockTaskDetails>();
|
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.Type = type;
|
||||||
//this.SourceBillNos.Add(sourceBillNo);
|
this.StockCode = stockCode;
|
||||||
this.DeliveryOrgId = deliveryOrgId;
|
this.DeliveryOrgId = deliveryOrgId;
|
||||||
this.ReceiptCustomerId = receiptCustomerId;
|
this.ReceiptCustomerId = receiptCustomerId;
|
||||||
this.CreateTime = createTime;
|
this.CreateTime = createTime;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace WMS.Web.Domain.Services
|
|||||||
{
|
{
|
||||||
var sourcNos = outStockTask.Details.SelectMany(s => s.ErpDetails).Select(s => s.SourceBillNo).ToList();
|
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)
|
foreach (var erp in erps)
|
||||||
{
|
{
|
||||||
//仓库不同 拆分成不同的
|
//仓库不同 拆分成不同的
|
||||||
@@ -122,19 +122,17 @@ namespace WMS.Web.Domain.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//找到物料明细下面对应的来源单明细 然后修改
|
//找到物料明细下面对应的金蝶明细Id 然后修改(跟金蝶明细一一对应)
|
||||||
var erpDetail = detail.ErpDetails.FirstOrDefault(f => f.SourceBillNo.Equals(erp.SourceBillNo));
|
var erpDetail = detail.ErpDetails.FirstOrDefault(f => f.Erp_DetailId == erp.Erp_DetailId);
|
||||||
if (erpDetail == null)
|
if (erpDetail == null)
|
||||||
{
|
{
|
||||||
erpDetail = _mapper.Map<OutStockTaskErpDetails>(erp);
|
erpDetail = _mapper.Map<OutStockTaskErpDetails>(erp);
|
||||||
detail.ErpDetails.Add(erpDetail);
|
detail.ErpDetails.Add(erpDetail);
|
||||||
outStockTask.Details.Add(detail);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
erpDetail.AccruedQty = erp.AccruedQty;
|
erpDetail.AccruedQty = erp.AccruedQty;
|
||||||
detail.AccruedQty = detail.ErpDetails.Sum(s => s.AccruedQty);
|
|
||||||
}
|
detail.AccruedQty = detail.ErpDetails.Sum(s => s.AccruedQty);
|
||||||
}
|
}
|
||||||
//操作完后剔除
|
//操作完后剔除
|
||||||
erp_removeList.Add(erp);
|
erp_removeList.Add(erp);
|
||||||
@@ -155,21 +153,26 @@ namespace WMS.Web.Domain.Services
|
|||||||
if (erp_list.Count != 0)
|
if (erp_list.Count != 0)
|
||||||
{
|
{
|
||||||
var add_entitys = new List<OutStockTask>();
|
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)
|
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();
|
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的实体明细中
|
//给到dto的实体明细中
|
||||||
foreach (var erp in current_erp_details)
|
foreach (var mid in mIds)
|
||||||
{
|
{
|
||||||
var detail = _mapper.Map<OutStockTaskDetails>(erp);
|
var emList = eList.Where(w => w.MaterialId == mid).ToList();
|
||||||
var erpDetail = _mapper.Map<OutStockTaskErpDetails>(erp);
|
var detail = _mapper.Map<OutStockTaskDetails>(emList.First());
|
||||||
detail.ErpDetails.Add(erpDetail);
|
var erpDetail = _mapper.Map<List<OutStockTaskErpDetails>>(emList);
|
||||||
|
detail.ErpDetails.AddRange(erpDetail);
|
||||||
|
|
||||||
|
detail.AccruedQty = detail.ErpDetails.Sum(s => s.AccruedQty);
|
||||||
entity.Details.Add(detail);
|
entity.Details.Add(detail);
|
||||||
}
|
}
|
||||||
add_entitys.Add(entity);
|
add_entitys.Add(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user