|
@ -1,6 +1,7 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Linq.Dynamic.Core; |
|
|
using System.Linq.Expressions; |
|
|
using System.Linq.Expressions; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Coravel.Invocable; |
|
|
using Coravel.Invocable; |
|
@ -48,117 +49,46 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService |
|
|
_hbpoSeDetailRepository = hbpoSeDetailRepository; |
|
|
_hbpoSeDetailRepository = hbpoSeDetailRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//private readonly IRepository<TM_BJBMPT_JIT_RECORD> _TMBJBMPTJITRECORDRepository;
|
|
|
|
|
|
|
|
|
|
|
|
//public HBPOSeSyncAppService(IRepository<TM_BJBMPT_JIT_RECORD> TMBJBMPTJITRECORDRepository)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// _TMBJBMPTJITRECORDRepository = TMBJBMPTJITRECORDRepository;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
public async Task Invoke() |
|
|
public async Task Invoke() |
|
|
{ |
|
|
{ |
|
|
await SyncJitRecord(); |
|
|
await SyncJitRecordAsync(); |
|
|
//await SyncJisRecord();
|
|
|
await SyncJisRecordAsync(); |
|
|
//if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// this._balanceRepository.AsNoTracking().ForEachAsync(o =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// dbContext.Set<VmiBalance>().Add(o);
|
|
|
|
|
|
// });
|
|
|
|
|
|
// dbContext.SaveChanges();
|
|
|
|
|
|
// var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
|
|
|
|
|
|
// this._snapshotRepository.InsertAsync(snapshot).Wait();
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//using (var context = new HouseDbContext(optionsBuilder.Options))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var one = context.Notices.FirstOrDefault(n => n.Id == notice.Id);
|
|
|
|
|
|
// // 当然你也可以直接初始化其他的Service
|
|
|
|
|
|
// var nService = new NoticeService(context, null);
|
|
|
|
|
|
// var one = nService.FindOne(notice.Id);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var TM_BJBMPT_JIT_RECORDs = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
|
|
|
|
|
|
// .Where(b => b.UID > 3)
|
|
|
|
|
|
// .OrderBy(b => b.BillTime)
|
|
|
|
|
|
// .ToList();
|
|
|
|
|
|
//foreach (var TM_BJBMPT_JIT_RECORD in TM_BJBMPT_JIT_RECORDs)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// Console.WriteLine($"{TM_BJBMPT_JIT_RECORD.UID}");
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//using (var db = new WMSBJBMPTDbContext())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var blogs = db.TM_BJBMPT_JIT_RECORD
|
|
|
|
|
|
// .Where(b => b.UID > 3)
|
|
|
|
|
|
// .OrderBy(b => b.BillTime)
|
|
|
|
|
|
// .ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// foreach (var blog in blogs)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Console.WriteLine($"{blog.UID}");
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
Console.WriteLine($"{GetType().FullName}执行了"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 同步JitRecord
|
|
|
/// 同步JitRecord
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private async Task SyncJitRecordAsync() |
|
|
private async Task SyncJitRecord() |
|
|
|
|
|
{ |
|
|
{ |
|
|
//同步表名称
|
|
|
//同步表名称
|
|
|
var syncTableName = "TM_BJBMPT_JIT_RECORD"; |
|
|
var syncTableName = "JisHBPOSeSync_Jit"; |
|
|
//HBPO类型集合
|
|
|
//HBPO类型集合
|
|
|
var EnumDeliverSubBillTypes = new List<EnumDeliverSubBillType> |
|
|
var EnumDeliverSubBillTypes = new List<EnumDeliverSubBillType> |
|
|
{ |
|
|
{ |
|
|
EnumDeliverSubBillType.保险杠HBPO, |
|
|
EnumDeliverSubBillType.保险杠HBPO, |
|
|
EnumDeliverSubBillType.买单件保险杠HBPO, |
|
|
EnumDeliverSubBillType.买单件保险杠HBPO, |
|
|
EnumDeliverSubBillType.买单件小件HBPO, |
|
|
EnumDeliverSubBillType.买单件小件HBPO, |
|
|
EnumDeliverSubBillType.小件HBPO, |
|
|
EnumDeliverSubBillType.小件HBPO |
|
|
EnumDeliverSubBillType.JIT直供件HBPO |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
|
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
|
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|
|
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|
|
if (syncPositionFlag != null) |
|
|
if (syncPositionFlag != null) |
|
|
{ |
|
|
{ |
|
|
//var inv = Expression.Invoke(t=>t.UID > int.Parse(syncPositionFlag.Position), predicate.Parameters);
|
|
|
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
|
//return Expression.Lambda<Func<T, bool>>(Expression.And(exp.Body, inv), exp.Parameters);
|
|
|
|
|
|
|
|
|
|
|
|
//predicate.And(t => t.UID > int.Parse(syncPositionFlag.Position));
|
|
|
|
|
|
|
|
|
|
|
|
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> expression = (t) => t.UID > int.Parse(syncPositionFlag.Position); |
|
|
|
|
|
var body = expression.Body; |
|
|
|
|
|
|
|
|
|
|
|
//var inv = Expression.Invoke(condition, exp.Parameters);
|
|
|
|
|
|
predicate = Expression.Lambda<Func<TM_BJBMPT_JIT_RECORD, bool>>(Expression.And(predicate.Body, body), predicate.Parameters); |
|
|
|
|
|
|
|
|
|
|
|
//Expression.Lambda<Func<T, bool>>(Expression.Equal(member, constant), parameter);
|
|
|
|
|
|
//var expression = predicate.And(t => t.UID > int.Parse(syncPositionFlag.Position));
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Console.WriteLine($"表达式:{predicate}"); |
|
|
//WMS发运数据
|
|
|
|
|
|
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); |
|
|
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD |
|
|
|
|
|
.Where(predicate) |
|
|
|
|
|
.OrderBy(b => b.UID) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(jitRecords); |
|
|
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(wmsRecords); |
|
|
if (hbpoSeDetails.Any()) |
|
|
if (hbpoSeDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails); |
|
|
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails); |
|
|
|
|
|
|
|
|
if (syncPositionFlag != null) |
|
|
if (syncPositionFlag != null) |
|
|
{ |
|
|
{ |
|
|
syncPositionFlag.Position = jitRecords.Last().UID.ToString(); |
|
|
syncPositionFlag.Position = wmsRecords.Last().UID.ToString(); |
|
|
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
|
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -166,37 +96,46 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService |
|
|
syncPositionFlag = new SyncPositionFlag() |
|
|
syncPositionFlag = new SyncPositionFlag() |
|
|
{ |
|
|
{ |
|
|
TableName = syncTableName, |
|
|
TableName = syncTableName, |
|
|
Position = jitRecords.Last().UID.ToString() |
|
|
Position = wmsRecords.Last().UID.ToString() |
|
|
}; |
|
|
}; |
|
|
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
|
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task SyncJisRecord() |
|
|
/// <summary>
|
|
|
|
|
|
/// 同步JisRecord
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private async Task SyncJisRecordAsync() |
|
|
{ |
|
|
{ |
|
|
//同步表名称
|
|
|
//同步表名称
|
|
|
var syncTableName = "TM_BJBMPT_JIS_RECORD"; |
|
|
var syncTableName = "JisHBPOSeSync_Jis"; |
|
|
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => true; |
|
|
//BBAC类型集合
|
|
|
|
|
|
var EnumDeliverSubBillTypes = new List<EnumDeliverSubBillType> |
|
|
|
|
|
{ |
|
|
|
|
|
EnumDeliverSubBillType.保险杠BBAC, |
|
|
|
|
|
EnumDeliverSubBillType.买单件保险杠BBAC, |
|
|
|
|
|
EnumDeliverSubBillType.买单件小件BBAC, |
|
|
|
|
|
EnumDeliverSubBillType.小件BBAC |
|
|
|
|
|
}; |
|
|
|
|
|
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
|
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|
|
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|
|
if (syncPositionFlag != null) |
|
|
if (syncPositionFlag != null) |
|
|
{ |
|
|
{ |
|
|
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position); |
|
|
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var jisRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD |
|
|
//WMS发运数据
|
|
|
.Where(predicate) |
|
|
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); |
|
|
.OrderBy(b => b.UID) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(jisRecords); |
|
|
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(wmsRecords); |
|
|
if (hbpoSeDetails.Any()) |
|
|
if (hbpoSeDetails.Any()) |
|
|
{ |
|
|
{ |
|
|
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails); |
|
|
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails); |
|
|
|
|
|
|
|
|
if (syncPositionFlag != null) |
|
|
if (syncPositionFlag != null) |
|
|
{ |
|
|
{ |
|
|
syncPositionFlag.Position = jisRecords.Last().UID.ToString(); |
|
|
syncPositionFlag.Position = wmsRecords.Last().UID.ToString(); |
|
|
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
|
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -204,7 +143,7 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService |
|
|
syncPositionFlag = new SyncPositionFlag() |
|
|
syncPositionFlag = new SyncPositionFlag() |
|
|
{ |
|
|
{ |
|
|
TableName = syncTableName, |
|
|
TableName = syncTableName, |
|
|
Position = jisRecords.Last().UID.ToString() |
|
|
Position = wmsRecords.Last().UID.ToString() |
|
|
}; |
|
|
}; |
|
|
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
|
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
|
} |
|
|
} |
|
|