|
@ -7,14 +7,18 @@ using System.Threading.Tasks; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Volo.Abp.Domain.Services; |
|
|
using Volo.Abp.Domain.Services; |
|
|
using WY.NewJit.MsgBaseData; |
|
|
using WY.NewJit.MsgBaseData; |
|
|
|
|
|
using WY.NewJit.PrintTable; |
|
|
|
|
|
|
|
|
namespace WY.NewJit.MsgCheck |
|
|
namespace WY.NewJit.MsgCheck |
|
|
{ |
|
|
{ |
|
|
public class BillNumberRecordDomainService : DomainService |
|
|
public class BillNumberRecordDomainService : DomainService |
|
|
{ |
|
|
{ |
|
|
private readonly IRepository<BillNumberRecord, Guid> _billNumberRepository; |
|
|
private readonly IRepository<BillNumberRecord, Guid> _billNumberRepository; |
|
|
|
|
|
// private readonly IRepository<WaitPrint, Guid> _waitPrintRepository;
|
|
|
private ILogger<M100CheckDomainService> _logger; |
|
|
private ILogger<M100CheckDomainService> _logger; |
|
|
private readonly LogRemindDomainService _logRemindDomainService; |
|
|
private readonly LogRemindDomainService _logRemindDomainService; |
|
|
|
|
|
public static List<BillNumberRecord> _billNumberRecordCaches= new List<BillNumberRecord>() ; |
|
|
|
|
|
|
|
|
public BillNumberRecordDomainService( |
|
|
public BillNumberRecordDomainService( |
|
|
IRepository<BillNumberRecord, Guid> billNumberRepository, |
|
|
IRepository<BillNumberRecord, Guid> billNumberRepository, |
|
|
ILogger<M100CheckDomainService> logger, |
|
|
ILogger<M100CheckDomainService> logger, |
|
@ -24,99 +28,120 @@ namespace WY.NewJit.MsgCheck |
|
|
_logger = logger; |
|
|
_logger = logger; |
|
|
_logRemindDomainService = logRemindDomainService; |
|
|
_logRemindDomainService = logRemindDomainService; |
|
|
} |
|
|
} |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清空缓存
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void CleanBillNumberRecordCache() |
|
|
|
|
|
{ |
|
|
|
|
|
_billNumberRecordCaches.Clear(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<List<BillNumberRecord>> 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; |
|
|
|
|
|
} |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 解析号码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="number"></param>
|
|
|
|
|
|
/// <param name="productLine"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
public async Task<BillNumberRecord> GetBillNumber(int number, string productLine) |
|
|
public async Task<BillNumberRecord> GetBillNumber(int number, string productLine) |
|
|
{ |
|
|
{ |
|
|
BillNumberRecord record = new BillNumberRecord(); |
|
|
|
|
|
List<PrintData> datas = new List<PrintData>(); |
|
|
List<PrintData> datas = new List<PrintData>(); |
|
|
var bill = await _billNumberRepository.GetAsync(r => r.ProductLine == productLine); |
|
|
var recordcache= _billNumberRecordCaches.FirstOrDefault(r=>r.ProductLine==productLine); |
|
|
int recordNumber = bill.RecordNumber;//记录号
|
|
|
int recordNumber = recordcache.RecordNumber;//记录号
|
|
|
int roundNumber = bill.RoundNumber; |
|
|
int roundNumber = recordcache.RoundNumber; //记录轮数
|
|
|
int x = number - recordNumber; |
|
|
int x = number - recordNumber; |
|
|
|
|
|
//当接到顺序号减去记录的顺序号小于-1000时代表了该号码属于新轮次里的顺序号(下一轮)
|
|
|
|
|
|
//更新数据库记录号、轮数+1
|
|
|
|
|
|
//插入未打印列表 数为 (1999-r)+(x-1)+1
|
|
|
if (x <= -1000) |
|
|
if (x <= -1000) |
|
|
{ |
|
|
{ |
|
|
roundNumber++; |
|
|
roundNumber++; |
|
|
record.InsertedRows = (1999 - recordNumber) + (number - 1) + 1; |
|
|
recordcache.InsertedRows = (1999 - recordNumber) + (number - 1) + 1; |
|
|
for (int i = 1; i <= record.InsertedRows; i++) |
|
|
|
|
|
|
|
|
for (int i = 1; i <= recordcache.InsertedRows; i++) |
|
|
{ |
|
|
{ |
|
|
PrintData data = new PrintData(); |
|
|
PrintData item = new PrintData(); |
|
|
BillNumberTypeEnum type = BillNumberTypeEnum.正常; |
|
|
BillNumberTypeEnum type = BillNumberTypeEnum.正常; |
|
|
if (i + recordNumber > 1999) |
|
|
if (i + recordNumber > 1999) |
|
|
{ |
|
|
{ |
|
|
if ((i + recordNumber - 1999) != number) type = BillNumberTypeEnum.断号; |
|
|
if ((i + recordNumber - 1999) != number) type = BillNumberTypeEnum.断号; |
|
|
data.HostSN = i + recordNumber - 1999; |
|
|
item = CreatPrintData(type, i + recordNumber - 1999, roundNumber * 100000); |
|
|
data.Round = roundNumber * 100000; |
|
|
|
|
|
data.HostSN2 = roundNumber * 100000 + i + recordNumber - 1999; |
|
|
|
|
|
// ls.Add((roundNumber.ToString()+(i + recordNumber - 1999).ToString()), type);
|
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
if ((i + recordNumber) != number) type = BillNumberTypeEnum.断号; |
|
|
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);
|
|
|
|
|
|
} |
|
|
|
|
|
data.BillNumberType = type; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
item = CreatPrintData(type, i + recordNumber, (roundNumber - 1) * 100000); |
|
|
|
|
|
} |
|
|
|
|
|
datas.Add(item); |
|
|
} |
|
|
} |
|
|
recordNumber = number; |
|
|
recordcache.RecordNumber = number; |
|
|
record.RoundNumber= roundNumber+1; |
|
|
recordcache.RoundNumber = roundNumber; |
|
|
} |
|
|
} |
|
|
|
|
|
//当接到顺序号减去记录的顺序号小于0大于-1000时代表了该号码属于记录轮次里的顺序号(当前轮)
|
|
|
|
|
|
//不更新数据库记录号和轮数
|
|
|
else if (-1000 < x && x < 0) |
|
|
else if (-1000 < x && x < 0) |
|
|
{ |
|
|
{ |
|
|
PrintData data = new PrintData(); |
|
|
var item = CreatPrintData(BillNumberTypeEnum.迟到, number, roundNumber * 100000); |
|
|
record.RoundNumber = roundNumber; |
|
|
datas.Add(item); |
|
|
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.迟到);
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
//当接到顺序号减去记录的顺序号小于1000大于0时代表了该号码属于记录轮次里的顺序号(当前轮)
|
|
|
|
|
|
//更新数据库记录号、不更新轮数
|
|
|
|
|
|
//插入未打印列表 插入条数为|x-r|条
|
|
|
else if (0 < x && x < 1000) |
|
|
else if (0 < x && x < 1000) |
|
|
{ |
|
|
{ |
|
|
record.RoundNumber = roundNumber; |
|
|
recordcache.InsertedRows = (number - recordNumber); |
|
|
record.RoundNumber = (number - recordNumber); |
|
|
for (int i = 1; i <= recordcache.InsertedRows; i++) |
|
|
|
|
|
|
|
|
for (int i = 1; i <= record.RoundNumber; i++) |
|
|
|
|
|
{ |
|
|
{ |
|
|
PrintData data = new PrintData(); |
|
|
|
|
|
BillNumberTypeEnum type = BillNumberTypeEnum.正常; |
|
|
BillNumberTypeEnum type = BillNumberTypeEnum.正常; |
|
|
if ((i + recordNumber) != number) type = BillNumberTypeEnum.断号; |
|
|
if ((i + recordNumber) != number) type = BillNumberTypeEnum.断号; |
|
|
|
|
|
var item = CreatPrintData(type, i + recordNumber, roundNumber * 100000); |
|
|
data.BillNumberType = type; |
|
|
datas.Add(item); |
|
|
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);
|
|
|
|
|
|
} |
|
|
} |
|
|
recordNumber = number; |
|
|
recordcache.RecordNumber = number; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
//当接到顺序号减去记录的顺序号大于1000时代表了该号码属于记录轮次的上一个轮次里的顺序号(上一轮)
|
|
|
|
|
|
//不更新数据库记录号和轮数
|
|
|
else if (x >= 1000) |
|
|
else if (x >= 1000) |
|
|
{ |
|
|
{ |
|
|
PrintData data = new PrintData(); |
|
|
var item = CreatPrintData(BillNumberTypeEnum.迟到, number, (roundNumber - 1) * 100000); |
|
|
record.RoundNumber = roundNumber - 1; |
|
|
datas.Add(item); |
|
|
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.迟到);
|
|
|
|
|
|
} |
|
|
|
|
|
record.Datas = datas; |
|
|
|
|
|
return record; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
recordcache.Datas = datas; |
|
|
|
|
|
|
|
|
public async Task<ObjectResultDto> UpdateBillNumberRecord(BillNumberRecord record) |
|
|
return recordcache; |
|
|
|
|
|
} |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建实体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
/// <param name="hostSn"></param>
|
|
|
|
|
|
/// <param name="round"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private PrintData CreatPrintData(BillNumberTypeEnum type ,int hostSn,int round ) |
|
|
{ |
|
|
{ |
|
|
ObjectResultDto reslut = new ObjectResultDto(); |
|
|
PrintData item = new PrintData(); |
|
|
return reslut; |
|
|
item.BillNumberType = type; |
|
|
|
|
|
item.HostSN = hostSn; |
|
|
|
|
|
item.Round = round; |
|
|
|
|
|
item.HostSN2 = item.HostSN + item.Round; |
|
|
|
|
|
return item; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|