diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs index 7efe002..52fc123 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/BillM100s/BillM100AppService.cs @@ -118,7 +118,7 @@ namespace WY.NewJit.MsgCheck /// 序列领域服务 /// private readonly SequenceDomainService _sequenceDomainService; - + private readonly BillNumberRecordDomainService _aaa; /// /// 配置 /// @@ -180,11 +180,12 @@ namespace WY.NewJit.MsgCheck IRepository tbBillHisRepository, IRepository tsSortDetailHisRepository, IRepository printTemplateConfigurationRepository, - IRepository zHBPrintStatusRepository - + IRepository zHBPrintStatusRepository, + BillNumberRecordDomainService aaa ) { + _aaa = aaa; _billM100Repository = BillM100Repository; _billM100PartRepository = BillM100PartRepository; _logger = logger; @@ -213,6 +214,28 @@ namespace WY.NewJit.MsgCheck #endregion #region 私有方法 + [UnitOfWork] + [HttpPost] + [Route("get-billnumber")] + public async Task GetBillNumber(int number, string productLine,bool t) + { + if (t) + { + _aaa.CleanBillNumberRecordCache(); + } + + var res=await _aaa.GetBillNumber(number, productLine); + return res; + } + [UnitOfWork] + [HttpPost] + [Route("get-billnumberrec")] + public async Task> GetBillNumberRec(bool isupdate) + { + + var aaa =await _aaa.GetOrUpDateBillNumberRecordCache(isupdate); + return aaa; + } /// /// 查询柱护板 /// diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml index e35eb76..b89c4e8 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml @@ -988,7 +988,7 @@ 柱护板缓存列表(打印柱护板时用到) - + 构造函数 diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillNumberRecord.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillNumberRecord.cs index 9ad9cde..88dfda1 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillNumberRecord.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillNumberRecord.cs @@ -15,6 +15,21 @@ namespace WY.NewJit.MsgCheck /// public class BillNumberRecord : AuditedAggregateRoot { + public BillNumberRecord() + { + + } + + public BillNumberRecord(Guid id, string productLine, int roundNumber, int recordNumber, int insertedRows, DateTime updateTime) : base(id) + { + ProductLine = productLine; + RoundNumber = roundNumber; + RecordNumber = recordNumber; + InsertedRows = insertedRows; + UpdateTime = updateTime; + } + + /// /// 产线# /// @@ -39,7 +54,7 @@ namespace WY.NewJit.MsgCheck /// 一次处理后成的号码列表 /// [NotMapped] - public virtual List Datas { get; set; } + public virtual List Datas { get; set; } = new List(); } } 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 f22ca44..4e9b251 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 @@ -7,14 +7,18 @@ using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; using WY.NewJit.MsgBaseData; +using WY.NewJit.PrintTable; namespace WY.NewJit.MsgCheck { public class BillNumberRecordDomainService : DomainService { private readonly IRepository _billNumberRepository; + // private readonly IRepository _waitPrintRepository; private ILogger _logger; private readonly LogRemindDomainService _logRemindDomainService; + public static List _billNumberRecordCaches= new List() ; + public BillNumberRecordDomainService( IRepository billNumberRepository, ILogger logger, @@ -24,99 +28,120 @@ namespace WY.NewJit.MsgCheck _logger = logger; _logRemindDomainService = logRemindDomainService; } + /// + /// 清空缓存 + /// + public void CleanBillNumberRecordCache() + { + _billNumberRecordCaches.Clear(); + } + public async Task> GetOrUpDateBillNumberRecordCache(bool isupdate) + { + if (isupdate) + { + await _billNumberRepository.UpdateManyAsync(_billNumberRecordCaches); + } + else + { + _billNumberRecordCaches = await _billNumberRepository.GetListAsync(); + //foreach (var item in _billNumberRecordCaches) + //{ + // var iii=await _waitPrintRepository.GetListAsync(r => r.ProductLine == item.ProductLine); + // var ss= iii.Select(r => r.HostSN2).Max(); + //} + } + return _billNumberRecordCaches; + } + /// + /// 解析号码 + /// + /// + /// + /// public async Task GetBillNumber(int number, string productLine) { - BillNumberRecord record = new BillNumberRecord(); List datas = new List(); - var bill = await _billNumberRepository.GetAsync(r => r.ProductLine == productLine); - int recordNumber = bill.RecordNumber;//记录号 - int roundNumber = bill.RoundNumber; + var recordcache= _billNumberRecordCaches.FirstOrDefault(r=>r.ProductLine==productLine); + int recordNumber = recordcache.RecordNumber;//记录号 + int roundNumber = recordcache.RoundNumber; //记录轮数 int x = number - recordNumber; + //当接到顺序号减去记录的顺序号小于-1000时代表了该号码属于新轮次里的顺序号(下一轮) + //更新数据库记录号、轮数+1 + //插入未打印列表 数为 (1999-r)+(x-1)+1 if (x <= -1000) { roundNumber++; - record.InsertedRows = (1999 - recordNumber) + (number - 1) + 1; - for (int i = 1; i <= record.InsertedRows; i++) + recordcache.InsertedRows = (1999 - recordNumber) + (number - 1) + 1; + + for (int i = 1; i <= recordcache.InsertedRows; i++) { - PrintData data = new PrintData(); + PrintData item = new PrintData(); BillNumberTypeEnum type = BillNumberTypeEnum.正常; if (i + recordNumber > 1999) { if ((i + recordNumber - 1999) != number) type = BillNumberTypeEnum.断号; - data.HostSN = i + recordNumber - 1999; - data.Round = roundNumber * 100000; - data.HostSN2 = roundNumber * 100000 + i + recordNumber - 1999; - // ls.Add((roundNumber.ToString()+(i + recordNumber - 1999).ToString()), type); + item = CreatPrintData(type, i + recordNumber - 1999, roundNumber * 100000); } else { if ((i + recordNumber) != number) type = BillNumberTypeEnum.断号; - data.HostSN = i + recordNumber; - data.Round = roundNumber * 100000; - data.HostSN2 = roundNumber * 100000 + i + recordNumber; - // ls.Add((roundNumber.ToString()+(i + recordNumber).ToString()), type); + + item = CreatPrintData(type, i + recordNumber, (roundNumber - 1) * 100000); } - data.BillNumberType = type; - + datas.Add(item); } - recordNumber = number; - record.RoundNumber= roundNumber+1; + recordcache.RecordNumber = number; + recordcache.RoundNumber = roundNumber; } - else if (-1000 < x && x < 0) + //当接到顺序号减去记录的顺序号小于0大于-1000时代表了该号码属于记录轮次里的顺序号(当前轮) + //不更新数据库记录号和轮数 + else if (-1000 < x && x < 0) { - PrintData data = new PrintData(); - record.RoundNumber = roundNumber; - record.InsertedRows = 0; - data.BillNumberType = BillNumberTypeEnum.迟到; - data.HostSN = recordNumber; - data.Round = roundNumber * 100000; - data.HostSN2 = roundNumber * 100000 + recordNumber; - datas.Add(data); - // ls.Add((roundNumber.ToString() + (recordNumber).ToString()), BillNumberTypeEnum.迟到); + var item = CreatPrintData(BillNumberTypeEnum.迟到, number, roundNumber * 100000); + datas.Add(item); } + //当接到顺序号减去记录的顺序号小于1000大于0时代表了该号码属于记录轮次里的顺序号(当前轮) + //更新数据库记录号、不更新轮数 + //插入未打印列表 插入条数为|x-r|条 else if (0 < x && x < 1000) { - record.RoundNumber = roundNumber; - record.RoundNumber = (number - recordNumber); - - for (int i = 1; i <= record.RoundNumber; i++) + recordcache.InsertedRows = (number - recordNumber); + for (int i = 1; i <= recordcache.InsertedRows; i++) { - PrintData data = new PrintData(); BillNumberTypeEnum type = BillNumberTypeEnum.正常; if ((i + recordNumber) != number) type = BillNumberTypeEnum.断号; - - data.BillNumberType = type; - data.HostSN = i + recordNumber; - data.Round = roundNumber * 100000; - data.HostSN2 = roundNumber * 100000 + i + recordNumber; - datas.Add(data); - - // ls.Add((roundNumber.ToString() + (i + recordNumber).ToString()), type); + var item = CreatPrintData(type, i + recordNumber, roundNumber * 100000); + datas.Add(item); } - recordNumber = number; - + recordcache.RecordNumber = number; } + //当接到顺序号减去记录的顺序号大于1000时代表了该号码属于记录轮次的上一个轮次里的顺序号(上一轮) + //不更新数据库记录号和轮数 else if (x >= 1000) { - PrintData data = new PrintData(); - record.RoundNumber = roundNumber - 1; - record.RoundNumber = 0; - data.BillNumberType = BillNumberTypeEnum.迟到; - data.HostSN = recordNumber; - data.Round = roundNumber * 100000; - data.HostSN2 = roundNumber * 100000 + recordNumber; - datas.Add(data); - // ls.Add((roundNumber.ToString() + (recordNumber).ToString()), BillNumberTypeEnum.迟到); + var item = CreatPrintData(BillNumberTypeEnum.迟到, number, (roundNumber - 1) * 100000); + datas.Add(item); } - record.Datas = datas; - return record; - } + recordcache.Datas = datas; - public async Task UpdateBillNumberRecord(BillNumberRecord record) + return recordcache; + } + /// + /// 创建实体 + /// + /// + /// + /// + /// + private PrintData CreatPrintData(BillNumberTypeEnum type ,int hostSn,int round ) { - ObjectResultDto reslut = new ObjectResultDto(); - return reslut; + PrintData item = new PrintData(); + item.BillNumberType = type; + item.HostSN = hostSn; + item.Round = round; + item.HostSN2 = item.HostSN + item.Round; + return item; } } }