wanggang 1 year ago
parent
commit
f4b204e640
  1. 8
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs
  3. 125
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs
  4. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

8
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -53,10 +53,10 @@ public class Startup
{
//scheduler.Schedule<HBPOSeSyncAppService>().EveryMinute();
//scheduler.Schedule<BBACSeSyncAppService>().EveryMinute();
scheduler.Schedule<ZhiGongBBACSeSyncAppService>().EveryMinute();
scheduler.Schedule<ZhiGongHBPOSeSyncAppService>().EveryMinute();
scheduler.Schedule<BeiSeSyncAppService>().EveryMinute();
scheduler.Schedule<YinDuSeSyncAppService>().EveryMinute();
//scheduler.Schedule<ZhiGongBBACSeSyncAppService>().EveryMinute();
//scheduler.Schedule<ZhiGongHBPOSeSyncAppService>().EveryMinute();
//scheduler.Schedule<BeiSeSyncAppService>().EveryMinute();
//scheduler.Schedule<YinDuSeSyncAppService>().EveryMinute();
});
var contentTypeProvider = new FileExtensionContentTypeProvider();
contentTypeProvider.Mappings.Add(".mjs", "text/javascript");

53
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs

@ -51,47 +51,44 @@ public class BBACSeSyncAppService : ApplicationService, IInvocable
[HttpPost]
public async Task Invoke()
{
await SyncJitRecord();
//await SyncJisRecord();
await SyncJitRecordAsync();
await SyncJisRecordAsync();
}
/// <summary>
/// 同步JitRecord
/// </summary>
/// <returns></returns>
private async Task SyncJitRecord()
private async Task SyncJitRecordAsync()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIT_RECORD";
var syncTableName = "JisBBACSeSync_Jit";
//BBAC类型集合
var EnumDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{
EnumDeliverSubBillType.BBAC,
EnumDeliverSubBillType.BBAC,
EnumDeliverSubBillType.BBAC,
EnumDeliverSubBillType.BBAC,
EnumDeliverSubBillType.JIT直供件BBAC
EnumDeliverSubBillType.BBAC
};
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);
if (syncPositionFlag != null)
{
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> expression = (t) => t.UID > int.Parse(syncPositionFlag.Position);
var body = expression.Body;
predicate = Expression.Lambda<Func<TM_BJBMPT_JIT_RECORD, bool>>(Expression.And(predicate.Body, body), predicate.Parameters);
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType);
}
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).ToList();
//WMS发运记录
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).ToList();
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(jitRecords);
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords);
if (bbacSeDetails.Any())
{
await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jitRecords.Last().UID.ToString();
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
@ -99,34 +96,46 @@ public class BBACSeSyncAppService : ApplicationService, IInvocable
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jitRecords.Last().UID.ToString()
Position = wmsSeRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
private async Task SyncJisRecord()
/// <summary>
/// 同步JisRecord
/// </summary>
private async Task SyncJisRecordAsync()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIS_RECORD";
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => true;
var syncTableName = "JisBBACSeSync_Jis";
//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);
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.Where(predicate).OrderBy(b => b.UID).ToList();
//WMS发运数据
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).ToList();
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(jisRecords);
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(wmsRecords);
if (bbacSeDetails.Any())
{
await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jisRecords.Last().UID.ToString();
syncPositionFlag.Position = wmsRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
@ -134,7 +143,7 @@ public class BBACSeSyncAppService : ApplicationService, IInvocable
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jisRecords.Last().UID.ToString()
Position = wmsRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}

125
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Coravel.Invocable;
@ -48,117 +49,46 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
_hbpoSeDetailRepository = hbpoSeDetailRepository;
}
//private readonly IRepository<TM_BJBMPT_JIT_RECORD> _TMBJBMPTJITRECORDRepository;
//public HBPOSeSyncAppService(IRepository<TM_BJBMPT_JIT_RECORD> TMBJBMPTJITRECORDRepository)
//{
// _TMBJBMPTJITRECORDRepository = TMBJBMPTJITRECORDRepository;
//}
[HttpPost]
public async Task Invoke()
{
await SyncJitRecord();
//await SyncJisRecord();
//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}执行了");
await SyncJitRecordAsync();
await SyncJisRecordAsync();
}
/// <summary>
/// 同步JitRecord
/// </summary>
/// <returns></returns>
private async Task SyncJitRecord()
private async Task SyncJitRecordAsync()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIT_RECORD";
var syncTableName = "JisHBPOSeSync_Jit";
//HBPO类型集合
var EnumDeliverSubBillTypes = new List<EnumDeliverSubBillType>
{
EnumDeliverSubBillType.HBPO,
EnumDeliverSubBillType.HBPO,
EnumDeliverSubBillType.HBPO,
EnumDeliverSubBillType.HBPO,
EnumDeliverSubBillType.JIT直供件HBPO
EnumDeliverSubBillType.HBPO
};
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);
if (syncPositionFlag != null)
{
//var inv = Expression.Invoke(t=>t.UID > int.Parse(syncPositionFlag.Position), predicate.Parameters);
//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));
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType);
}
Console.WriteLine($"表达式:{predicate}");
var jitRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
//WMS发运数据
var wmsRecords = _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())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jitRecords.Last().UID.ToString();
syncPositionFlag.Position = wmsRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
@ -166,37 +96,46 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jitRecords.Last().UID.ToString()
Position = wmsRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}
}
}
private async Task SyncJisRecord()
/// <summary>
/// 同步JisRecord
/// </summary>
private async Task SyncJisRecordAsync()
{
//同步表名称
var syncTableName = "TM_BJBMPT_JIS_RECORD";
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => true;
var syncTableName = "JisHBPOSeSync_Jis";
//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);
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
.Where(predicate)
.OrderBy(b => b.UID)
.ToList();
//WMS发运数据
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).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())
{
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails);
if (syncPositionFlag != null)
{
syncPositionFlag.Position = jisRecords.Last().UID.ToString();
syncPositionFlag.Position = wmsRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag);
}
else
@ -204,7 +143,7 @@ public class HBPOSeSyncAppService : ApplicationService, IInvocable //IJobService
syncPositionFlag = new SyncPositionFlag()
{
TableName = syncTableName,
Position = jisRecords.Last().UID.ToString()
Position = wmsRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag);
}

18
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -96,6 +96,13 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
where item1.Price != item2.Price && item1.BeginTime == item2.BeginTime && item1.EndTime == item1.EndTime
select new PriceList(item2.Id, item2.LU, item1.Price, item2.BeginTime, item2.EndTime, item2.ClientCode, item2.Date, item2.ContractNo);
//新日期
var updateNewDate = from item1 in entities
join item2 in pricelist
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode }
where item1.BeginTime != item2.BeginTime || item1.EndTime != item2.EndTime
select item1;
update = update.Concat(updateNewDate);
if (update.Any())
{
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
@ -109,17 +116,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
//新日期
var addNewDate = from item1 in entities
join item2 in pricelist
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode }
where item1.BeginTime != item2.BeginTime || item1.EndTime != item2.EndTime
select item1;
var add = addNewLu.Concat(addNewDate);
if (add.Any())
if (addNewLu.Any())
{
await _repository.GetDbContext().BulkInsertAsync(add.ToList());
await _repository.GetDbContext().BulkInsertAsync(addNewLu.ToList());
}
return _errorList;

Loading…
Cancel
Save