作废单据不同步更新金蝶数据
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -500,12 +501,19 @@ namespace WMS.Web.Domain.Services
|
||||
//2.1遍历任务单明细:改变已有的值和要添加的明细
|
||||
foreach (var det in data_list.SelectMany(t => t.Details))
|
||||
{
|
||||
var order= data_list.Where(o => o.Id == det.Fid).FirstOrDefault();
|
||||
var order = data_list.Where(o => o.Id == det.Fid).FirstOrDefault();
|
||||
if (order != null)
|
||||
{
|
||||
var erp_data = erp_list.FirstOrDefault(a => a.ErpDetailId == det.ErpDetailId && a.BillNo == order.SourceBillNo);
|
||||
if (erp_data != null)
|
||||
{
|
||||
//如果该明细作废 则不修改了
|
||||
if (det.IsRepeal == true)
|
||||
{
|
||||
//操作完后剔除
|
||||
erp_removeList.Add(erp_data);
|
||||
continue;
|
||||
}
|
||||
if (erp_data.MaterialNumber == det.MaterialNumber)
|
||||
{
|
||||
//物料相同的,就改变数值
|
||||
@@ -530,7 +538,7 @@ namespace WMS.Web.Domain.Services
|
||||
//2.1.1当物料相同,仓库不同或者物料不同,就新增一条明细
|
||||
foreach (var erp_data in erp_list)
|
||||
{
|
||||
var order= data_list.Where(x => x.SourceBillNo == erp_data.BillNo).FirstOrDefault();
|
||||
var order = data_list.Where(x => x.SourceBillNo == erp_data.BillNo).FirstOrDefault();
|
||||
if (order != null)
|
||||
{
|
||||
var IsHaveNewMaterial = order.Details.Where(x => x.ErpDetailId == erp_data.ErpDetailId && erp_data.MaterialNumber == x.MaterialNumber).Any();
|
||||
@@ -570,18 +578,18 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
MaterialNumber = x.Key,
|
||||
AccruedQtyTotal = x.Sum(t => t.AccruedQty),
|
||||
ReceiveQtyTotal=x.Sum(t=>t.ReceiveQty),
|
||||
RealityQtyTotal =x.Sum(t=>t.RealityQty)
|
||||
ReceiveQtyTotal = x.Sum(t => t.ReceiveQty),
|
||||
RealityQtyTotal = x.Sum(t => t.RealityQty)
|
||||
}).ToList();
|
||||
|
||||
bool IsAny = details_Groups.Any(d => d.RealityQtyTotal != 0 && d.AccruedQtyTotal > d.RealityQtyTotal);
|
||||
if (IsAny)
|
||||
order.Status = InstockStatus.Part;
|
||||
else if (details_Groups.Sum(x => x.ReceiveQtyTotal) <= 0 && order.Type== InstockType.Purchase)
|
||||
else if (details_Groups.Sum(x => x.ReceiveQtyTotal) <= 0 && order.Type == InstockType.Purchase)
|
||||
order.Status = InstockStatus.Wait;
|
||||
else if (details_Groups.Sum(x => x.RealityQtyTotal) <= 0)
|
||||
order.Status = InstockStatus.WaitInStock;
|
||||
else if(details_Groups.Sum(x => x.RealityQtyTotal) >= details_Groups.Sum(x => x.AccruedQtyTotal))
|
||||
else if (details_Groups.Sum(x => x.RealityQtyTotal) >= details_Groups.Sum(x => x.AccruedQtyTotal))
|
||||
order.Status = InstockStatus.Already;
|
||||
|
||||
});
|
||||
@@ -590,6 +598,9 @@ namespace WMS.Web.Domain.Services
|
||||
//2.4金蝶删除的明细,要把任务单里的明细应入库数量改为0
|
||||
data_list.SelectMany(x => x.Details).Where(c => !erp_list.Any(a => a.ErpDetailId == c.ErpDetailId)).ToList().ForEach(x => { x.AccruedQty = 0; });
|
||||
|
||||
//过滤掉已经作废的单据
|
||||
data_list = data_list.Where(w => w.Status != InstockStatus.Repeal).ToList();
|
||||
|
||||
//2.3.提交任务单的修改
|
||||
var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction);
|
||||
if (!isSuccess)
|
||||
|
||||
@@ -172,6 +172,13 @@ namespace WMS.Web.Domain.Services
|
||||
{
|
||||
//仓库不同 拆分成不同的
|
||||
var detail = outStockTask.Details.FirstOrDefault(w => w.MaterialNumber == erp.MaterialNumber);
|
||||
//如果该明细作废 则不修改了
|
||||
if (detail != null && detail.IsRepeal == true)
|
||||
{
|
||||
//操作完后剔除
|
||||
erp_removeList.Add(erp);
|
||||
continue;
|
||||
}
|
||||
if (detail == null)
|
||||
{
|
||||
//添加一条物料明细
|
||||
@@ -211,7 +218,8 @@ namespace WMS.Web.Domain.Services
|
||||
outStockTask.GenerateStatus();
|
||||
}
|
||||
}
|
||||
var update_date_list = data_list.Where(w => update_ids.Contains(w.Id)).ToList();
|
||||
//过滤掉已经作废的单据
|
||||
var update_date_list = data_list.Where(w => update_ids.Contains(w.Id) && w.Status != OutStockStatus.Repeal).ToList();
|
||||
//2.2.提交修改
|
||||
var isSuccess = await _outStockTaskRepositories.EditEntityList(update_date_list, isTransaction);
|
||||
if (!isSuccess)
|
||||
|
||||
Reference in New Issue
Block a user