From 3606af5aec6b2d59ace181fb40c29fabd461ee50 Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Tue, 28 Nov 2023 10:36:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E7=BA=AA=E5=BE=8B=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BillNumberRecordDomainService.cs | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/BillNumberRecordDomainService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/BillNumberRecordDomainService.cs index e95797e..478d69f 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/BillNumberRecordDomainService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/BillNumberRecordDomainService.cs @@ -15,7 +15,7 @@ using WY.NewJit.PrintTable; namespace WY.NewJit.MsgCheck { - [Dependency(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton, ReplaceServices =true)] + [Dependency(Microsoft.Extensions.DependencyInjection.ServiceLifetime.Singleton, ReplaceServices = true)] public class BillNumberRecordDomainService : DomainService { private readonly IRepository _billNumberRepository; @@ -23,7 +23,7 @@ namespace WY.NewJit.MsgCheck private ILogger _logger;//日志 private readonly LogRemindDomainService _logRemindDomainService; private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration;//配置 - public static List _billNumberRecordCaches= new List() ;//记录内存 + public static List _billNumberRecordCaches = new List();//记录缓存 public BillNumberRecordDomainService( IRepository billNumberRepository, @@ -41,45 +41,45 @@ namespace WY.NewJit.MsgCheck /// /// 获取和更新记录和内存 /// - /// + /// true 更新缓存 false 获取缓存 /// public async Task GetOrUpDateBillNumberRecordCache(bool isupdate) { ObjectResultDto ret = new ObjectResultDto(true, null); if (isupdate) { - //await _billNumberRepository.UpdateManyAsync(_billNumberRecordCaches); foreach (var item in _billNumberRecordCaches) { - var re = await _billNumberRepository.GetListAsync(r=>r.Id==item.Id); - if (re.Count == 0) - { - await _billNumberRepository.InsertAsync(item); - } - else - { - await _billNumberRepository.UpdateAsync(item); - } + var re = await _billNumberRepository.GetListAsync(r => r.Id == item.Id); + if (re.Count == 0) + { + await _billNumberRepository.InsertAsync(item);//缓存记录表无纪律则插入 + } + else + { + await _billNumberRepository.UpdateAsync(item);//缓存记录表有纪律则更新 + } } } else { - _billNumberRecordCaches.Clear(); - _billNumberRecordCaches = await _billNumberRepository.GetListAsync(); + _billNumberRecordCaches.Clear();//清空缓存 + _billNumberRecordCaches = await _billNumberRepository.GetListAsync(); + //验证验证记录缓存和未打印列表里是否一致 foreach (var item in _billNumberRecordCaches) + { + var list = await _waitPrintRepository.GetListAsync(r => r.ProductLine == item.ProductLine); + if (list.Count > 0) //当未打印列表里有未打印数据则验证 { - var list = await _waitPrintRepository.GetListAsync(r => r.ProductLine == item.ProductLine); - if (list.Count > 0) + var max = list.Select(r => r.HostSN2).Max(); //当前产线未打印列表里hostsn2最大号 + if ((item.RecordNumber + item.RoundNumber * 100000) != max)//验证记录缓存和未打印列表里是否一致不一致报错 { - var max = list.Select(r => r.HostSN2).Max(); - if ((item.RecordNumber + item.RoundNumber * 100000) != max) - { - ret.Status = false; - ret.Message = "获取记录缓存错误!"; - _logger.LogDebug("获取记录缓存错误!"); - } + ret.Status = false; + ret.Message = "获取记录缓存错误!"; + _logger.LogDebug("获取记录缓存错误!"); } } + } } return ret; @@ -87,16 +87,16 @@ namespace WY.NewJit.MsgCheck /// /// 解析号码 /// - /// - /// + /// 大众顺序号 + /// 产线 /// public async Task GetBillNumber(int number, string productLine) { List datas = new List(); - var recordcache= _billNumberRecordCaches.FirstOrDefault(r=>r.ProductLine==productLine); - if (recordcache == null) + var recordcache = _billNumberRecordCaches.FirstOrDefault(r => r.ProductLine == productLine); + if (recordcache == null)//如果缓存为空则插入缓存 { - recordcache = new BillNumberRecord( GuidGenerator.Create(), productLine, 1,number,0, DateTime.Now); + recordcache = new BillNumberRecord(GuidGenerator.Create(), productLine, 1, number, 0, DateTime.Now); _billNumberRecordCaches.Add(recordcache); var item = CreatPrintData(BillNumberTypeEnum.正常, number, 1 * 100000); datas.Add(item); @@ -122,11 +122,11 @@ namespace WY.NewJit.MsgCheck BillNumberTypeEnum type = BillNumberTypeEnum.正常; if (i + recordNumber > 1999) { - if ((i + recordNumber - 1999) != number) + if ((i + recordNumber - 1999) != number) { type = BillNumberTypeEnum.断号; _logger.LogDebug($"#999#产生断号数据【{i + recordNumber - 1999}】,传入号码为【{number}】,缓存号码【{recordcache.RecordNumber}】,插入条数【{recordcache.InsertedRows}】,轮数【{roundNumber}】,下一轮"); - } + } item = CreatPrintData(type, i + recordNumber - 1999, roundNumber * 100000); } else @@ -160,12 +160,12 @@ namespace WY.NewJit.MsgCheck for (int i = 1; i <= recordcache.InsertedRows; i++) { BillNumberTypeEnum type = BillNumberTypeEnum.正常; - if ((i + recordNumber) != number) + if ((i + recordNumber) != number) { type = BillNumberTypeEnum.断号; _logger.LogDebug($"#999#产生断号数据【{i + recordNumber}】,传入号码为【{number}】,缓存号码【{recordcache.RecordNumber}】,插入条数【{recordcache.InsertedRows}】,轮数【{recordcache.RoundNumber}】,方法当前轮数"); } - + var item = CreatPrintData(type, i + recordNumber, roundNumber * 100000); datas.Add(item); } @@ -191,7 +191,7 @@ namespace WY.NewJit.MsgCheck /// /// /// - private PrintData CreatPrintData(BillNumberTypeEnum type ,int hostSn,int round ) + private PrintData CreatPrintData(BillNumberTypeEnum type, int hostSn, int round) { PrintData item = new PrintData(); item.BillNumberType = type;