|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EFCore.BulkExtensions; |
|
|
@ -8,7 +9,9 @@ using Newtonsoft.Json; |
|
|
|
using SettleAccount.Bases; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Volo.Abp.SettingManagement; |
|
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
|
|
using Win.Sfs.SettleAccount.Entities.CodeSettings; |
|
|
|
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
@ -63,10 +66,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
/// </remarks>
|
|
|
|
public async Task JisSeDetailsSaveConsignAsync<T>(List<T> seDetails, bool isJisTable) where T : JisSeBase |
|
|
|
{ |
|
|
|
var value = _settleAccountDbContext.Set<CodeSetting>().FirstOrDefault(p => p.Project == "库存账期").Value; |
|
|
|
var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.发货); |
|
|
|
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退货); |
|
|
|
var dateTimeNow = DateTime.Now; |
|
|
|
|
|
|
|
|
|
|
|
var vmiLogList = deliverSeDetails.Select(t => new VmiLog |
|
|
|
{ |
|
|
|
LogType = VmiLogType.Type100, |
|
|
@ -93,7 +98,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
Seq = t.Seq, |
|
|
|
UniqueCode = isJisTable ? t.UniqueCode : t.DeliverCode, |
|
|
|
VinCode = t.PN, |
|
|
|
factory = t.Factory |
|
|
|
Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段
|
|
|
|
factory = t.BusinessType.ToString() |
|
|
|
}).ToList(); |
|
|
|
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog |
|
|
|
{ |
|
|
@ -121,7 +127,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
Seq = t.Seq, |
|
|
|
UniqueCode = isJisTable ? t.UniqueCode : t.DeliverCode, |
|
|
|
VinCode = t.VinCode, |
|
|
|
factory = t.Factory |
|
|
|
Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段
|
|
|
|
factory = t.BusinessType.ToString() |
|
|
|
}).ToList(); |
|
|
|
vmiLogList.AddRange(returnVmiLogList); |
|
|
|
await SaveVmiLogsAsync(vmiLogList).ConfigureAwait(false); |
|
|
@ -136,6 +143,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
/// </remarks>
|
|
|
|
public async Task PubSeDetailsSaveConsignAsync(List<PUB_SE_DETAIL> seDetails) |
|
|
|
{ |
|
|
|
var value = _settleAccountDbContext.Set<CodeSetting>().FirstOrDefault(p => p.Project == "库存账期").Value; |
|
|
|
var deliverSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.发货); |
|
|
|
var returnSeDetails = seDetails.FindAll(t => t.TransType == EnumDelTransType.退货); |
|
|
|
var dateTimeNow = DateTime.Now; |
|
|
@ -158,7 +166,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
Qty = t.Qty, |
|
|
|
ReMark = t.Remark, |
|
|
|
RealPartCode = t.PartCode, |
|
|
|
VinCode = t.PN |
|
|
|
VinCode = t.PN, |
|
|
|
Version=GetVersionByBillTimeAsync(t.BillTime.Value,value),//加区间字段
|
|
|
|
factory=t.BusinessType.ToString() |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
var returnVmiLogList = returnSeDetails.Select(t => new VmiLog |
|
|
|
{ |
|
|
@ -177,7 +188,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
OrderNum = t.DeliveryIndex, |
|
|
|
Qty = -t.Qty, |
|
|
|
ReMark = t.Remark, |
|
|
|
RealPartCode = t.PartCode |
|
|
|
RealPartCode = t.PartCode, |
|
|
|
Version = GetVersionByBillTimeAsync(t.BillTime.Value, value),//加区间字段
|
|
|
|
factory = t.BusinessType.ToString() |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
vmiLogList.AddRange(returnVmiLogList); |
|
|
|
await SaveVmiLogsAsync(vmiLogList).ConfigureAwait(false); |
|
|
@ -203,5 +217,68 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs |
|
|
|
}).ToList(); |
|
|
|
await _settleAccountDbContext.BulkInsertAsync(vmiMessages).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int GetVersionByBillTimeAsync(DateTime p_billtime,string p_day) |
|
|
|
{ |
|
|
|
|
|
|
|
var before = p_billtime.Year; |
|
|
|
var last = before - 1; |
|
|
|
DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last,p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间
|
|
|
|
DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before,p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间
|
|
|
|
|
|
|
|
//var result = seDetails
|
|
|
|
// .Select(log =>
|
|
|
|
// {
|
|
|
|
string version = null; |
|
|
|
|
|
|
|
if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1)) |
|
|
|
{ |
|
|
|
version = $"{before.ToString()}01"; |
|
|
|
} |
|
|
|
else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2)) |
|
|
|
{ version = $"{before.ToString()}02"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3)) |
|
|
|
{ version = $"{before.ToString()}03"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4)) |
|
|
|
{ version = $"{before.ToString()}04"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(4) && p_billtime <= lastYear.AddMonths(5)) |
|
|
|
{ version = $"{before.ToString()}05"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(5) && p_billtime <= lastYear.AddMonths(6)) |
|
|
|
{ version = $"{before.ToString()}06"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(6) && p_billtime <= lastYear.AddMonths(7)) |
|
|
|
{ version = $"{before.ToString()}07"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(7) && p_billtime <= lastYear.AddMonths(8)) |
|
|
|
{ version = $"{before.ToString()}08"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(8) && p_billtime <= lastYear.AddMonths(9)) |
|
|
|
{ version = $"{before.ToString()}09"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(9) && p_billtime <= lastYear.AddMonths(10)) |
|
|
|
{ version = $"{before.ToString()}10"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11)) |
|
|
|
{ version = $"{before.ToString()}11"; } |
|
|
|
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear) |
|
|
|
{ version = $"{before.ToString()}12"; } |
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(version)) |
|
|
|
{ |
|
|
|
return 200802 ;//找不到的数据默认写到这个区间
|
|
|
|
} |
|
|
|
|
|
|
|
return int.Parse(version); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|