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