|
|
@ -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<BillNumberRecord, Guid> _billNumberRepository; |
|
|
|
// private readonly IRepository<WaitPrint, Guid> _waitPrintRepository;
|
|
|
|
private ILogger<M100CheckDomainService> _logger; |
|
|
|
private readonly LogRemindDomainService _logRemindDomainService; |
|
|
|
public static List<BillNumberRecord> _billNumberRecordCaches= new List<BillNumberRecord>() ; |
|
|
|
|
|
|
|
public BillNumberRecordDomainService( |
|
|
|
IRepository<BillNumberRecord, Guid> billNumberRepository, |
|
|
|
ILogger<M100CheckDomainService> logger, |
|
|
@ -24,99 +28,120 @@ namespace WY.NewJit.MsgCheck |
|
|
|
_logger = logger; |
|
|
|
_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) |
|
|
|
{ |
|
|
|
BillNumberRecord record = new BillNumberRecord(); |
|
|
|
List<PrintData> datas = new List<PrintData>(); |
|
|
|
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);
|
|
|
|
} |
|
|
|
data.BillNumberType = type; |
|
|
|
|
|
|
|
item = CreatPrintData(type, i + recordNumber, (roundNumber - 1) * 100000); |
|
|
|
} |
|
|
|
datas.Add(item); |
|
|
|
} |
|
|
|
recordNumber = number; |
|
|
|
record.RoundNumber= roundNumber+1; |
|
|
|
recordcache.RecordNumber = number; |
|
|
|
recordcache.RoundNumber = roundNumber; |
|
|
|
} |
|
|
|
//当接到顺序号减去记录的顺序号小于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<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(); |
|
|
|
return reslut; |
|
|
|
PrintData item = new PrintData(); |
|
|
|
item.BillNumberType = type; |
|
|
|
item.HostSN = hostSn; |
|
|
|
item.Round = round; |
|
|
|
item.HostSN2 = item.HostSN + item.Round; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|