Browse Source

销售价格

master
mahao 1 year ago
parent
commit
ae450cbf29
  1. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BBACSeSyncAppService.cs
  2. 125
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HBPOSeSyncAppService.cs
  3. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

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

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

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

@ -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);
} }

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 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); 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()) if (update.Any())
{ {
await _repository.GetDbContext().BulkUpdateAsync(update.ToList()); await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
@ -109,17 +116,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
from item3 in temp.DefaultIfEmpty() from item3 in temp.DefaultIfEmpty()
where item3 == null where item3 == null
select item1; 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 (addNewLu.Any())
if (add.Any())
{ {
await _repository.GetDbContext().BulkInsertAsync(add.ToList()); await _repository.GetDbContext().BulkInsertAsync(addNewLu.ToList());
} }
return _errorList; return _errorList;

Loading…
Cancel
Save