日志
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -252,7 +253,7 @@ namespace WMS.Web.Domain.Services
|
||||
if (!AssembledApp_result.IsSuccess)
|
||||
return Result.ReFailure(AssembledApp_result.Message, AssembledApp_result.Status);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
List<string> Instock_sourceBillNos = new List<string>();
|
||||
List<string> Miscellaneous_sourceBillNos = new List<string>();
|
||||
@@ -519,15 +520,18 @@ namespace WMS.Web.Domain.Services
|
||||
// erp_list.RemoveAll(a => a.BillNo == b.BillNo);
|
||||
//}
|
||||
//2.1遍历任务单明细:改变已有的值和要添加的明细
|
||||
foreach (var data_item in data_list)
|
||||
_logger.LogInformation("拉取金蝶数据:SysnDataNew1->" + JsonConvert.SerializeObject(data_list));
|
||||
foreach (var det in data_list.SelectMany(t => t.Details))
|
||||
{
|
||||
foreach (var det in data_item.Details)
|
||||
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 == data_item.SourceBillNo);
|
||||
var erp_data = erp_list.FirstOrDefault(a => a.ErpDetailId == det.ErpDetailId && a.BillNo == order.SourceBillNo);
|
||||
if (erp_data != null)
|
||||
{
|
||||
if (erp_data.MaterialId == det.MaterialId)
|
||||
{
|
||||
_logger.LogInformation("拉取金蝶数据:SysnDataNew2->" + JsonConvert.SerializeObject(erp_data));
|
||||
//物料相同的,就改变数值
|
||||
det.Remark = erp_data.Remark;
|
||||
det.AccruedQty = erp_data.Qty;
|
||||
@@ -536,16 +540,18 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("拉取金蝶数据:SysnDataNew3->" + JsonConvert.SerializeObject(erp_data));
|
||||
//老物料,应收数量修改为0
|
||||
det.AccruedQty = 0;
|
||||
}
|
||||
//操作完后剔除
|
||||
erp_removeList.Add(erp_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//2.1.1当物料相同,仓库不同或者物料不同,就新增一条明细
|
||||
foreach (var erp_data in erp_list)
|
||||
{
|
||||
@@ -569,33 +575,39 @@ namespace WMS.Web.Domain.Services
|
||||
});
|
||||
|
||||
//2.3遍历任务单:改变任务单的状态
|
||||
data_list.ForEach(order =>
|
||||
data_list.ForEach(order =>
|
||||
{
|
||||
//当应入库数量大于实际入库数量:状态就部分入库
|
||||
//当应入库数量小于等于实际入库数量:状态就已入库
|
||||
var AccruedQtyTotal = order.Details.Where(x => x.AccruedQty != 0).Sum(x => x.AccruedQty);
|
||||
var RealityQtyTotal = order.Details.Where(x=>x.AccruedQty!=0).Sum(x => x.RealityQty);
|
||||
if(RealityQtyTotal!=0 && AccruedQtyTotal > RealityQtyTotal)
|
||||
var RealityQtyTotal = order.Details.Where(x => x.AccruedQty != 0).Sum(x => x.RealityQty);
|
||||
if (RealityQtyTotal != 0 && AccruedQtyTotal > RealityQtyTotal)
|
||||
order.Status = InstockStatus.Part;
|
||||
else if(AccruedQtyTotal<= RealityQtyTotal)
|
||||
order.Status = InstockStatus.Already;
|
||||
else if (AccruedQtyTotal <= RealityQtyTotal)
|
||||
order.Status = InstockStatus.Already;
|
||||
});
|
||||
|
||||
|
||||
//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; });
|
||||
|
||||
_logger.LogInformation("拉取金蝶数据:SysnDataNew4->" + JsonConvert.SerializeObject(data_list));
|
||||
|
||||
//2.3.提交任务单的修改
|
||||
var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
}
|
||||
|
||||
//2.3.提交任务单的修改
|
||||
var isSuccess = await _inStockTaskRepositories.UpdateRange(data_list, isTransaction);
|
||||
if (!isSuccess)
|
||||
return Result.ReFailure(ResultCodes.DateWriteError);
|
||||
|
||||
|
||||
//2.4剔除:已修改的单据
|
||||
foreach (var item in erp_removeList.Distinct().ToList())
|
||||
erp_list.Remove(item);
|
||||
|
||||
_logger.LogInformation("拉取金蝶数据:SysnDataNew5->" + JsonConvert.SerializeObject(erp_list));
|
||||
|
||||
//3.wms任务单的来源单据编号不存在于erp中,那么就新增
|
||||
if (erp_list.Count != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user