|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using WY.NewJit.PrintTable; |
|
|
|
using WY.NewJit.Common; |
|
|
|
|
|
|
|
namespace WY.NewJit.MsgCheck |
|
|
|
{ |
|
|
@ -27,49 +28,118 @@ namespace WY.NewJit.MsgCheck |
|
|
|
/// </summary>
|
|
|
|
private readonly IRepository<WaitPrint, Guid> _waitPrintRepository; |
|
|
|
|
|
|
|
private readonly BillNumberRecordDomainService _billNumRecDomainSrv; |
|
|
|
|
|
|
|
public M100DomainService( |
|
|
|
IRepository<BillM100, Guid> billM100Repository, |
|
|
|
ILogger<M100CheckDomainService> logger, |
|
|
|
IRepository<WaitPrint, Guid> waitPrintRepository |
|
|
|
IRepository<WaitPrint, Guid> waitPrintRepository, |
|
|
|
BillNumberRecordDomainService billNumRecDomainSrv |
|
|
|
) |
|
|
|
{ |
|
|
|
_billM100Repository = billM100Repository; |
|
|
|
_logger = logger; |
|
|
|
_waitPrintRepository = waitPrintRepository; |
|
|
|
_billNumRecDomainSrv = billNumRecDomainSrv; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> InsertM100(BillM100 m100Obj, bool autoSave = false) |
|
|
|
public async Task<BillM100> InsertM100(BillM100 m100Obj, bool autoSave = false) |
|
|
|
{ |
|
|
|
//调用HostSN2方法
|
|
|
|
BillNumberRecord billNumRec = await _billNumRecDomainSrv.GetBillNumber(m100Obj.HostSN.TryToIntNotNull(), m100Obj.ProductLine); |
|
|
|
var normalObj = billNumRec.dic.FirstOrDefault(itm => itm.Value == BillNumberTypeEnum.正常); |
|
|
|
var lateObj = billNumRec.dic.FirstOrDefault(itm => itm.Value == BillNumberTypeEnum.迟到); |
|
|
|
var breaknumLst = billNumRec.dic.Where(itm => itm.Value == BillNumberTypeEnum.断号).ToList(); |
|
|
|
//更新M100
|
|
|
|
m100Obj.HostSN2 = normalObj.Key.TryToInt(); |
|
|
|
//M100转换成WaitPrint:一个底盘、08产线插入3条记录,其它产线插入1条记录
|
|
|
|
WaitPrint[] wpArr; |
|
|
|
if (m100Obj.ProductLine == "08") |
|
|
|
{ |
|
|
|
WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); |
|
|
|
WaitPrint zhbOtherRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.OtherZhuHuBan); |
|
|
|
WaitPrint zhbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.ZhuHuBan); |
|
|
|
wpArr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//处理断号:由生成HostSN方法提供断号数据
|
|
|
|
WaitPrint mbRec = ConvertWaitPrint(m100Obj, BusinessTypeEnum.MenBan); |
|
|
|
wpArr = new WaitPrint[1] { mbRec }; |
|
|
|
} |
|
|
|
|
|
|
|
var m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); |
|
|
|
if (m100Ret != null) |
|
|
|
//处理断号
|
|
|
|
if (breaknumLst.Count > 0) |
|
|
|
{ |
|
|
|
if (m100Obj.ProductLine == "08") |
|
|
|
List<WaitPrint> breakNumLst = new List<WaitPrint>(); |
|
|
|
foreach (var sourceWaitPrint in wpArr) |
|
|
|
{ |
|
|
|
WaitPrint mbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan); |
|
|
|
WaitPrint zhbOtherRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.OtherZhuHuBan); |
|
|
|
WaitPrint zhbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.ZhuHuBan); |
|
|
|
WaitPrint[] arr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; |
|
|
|
await _waitPrintRepository.InsertManyAsync(arr); |
|
|
|
foreach (var breaknum in breaknumLst) |
|
|
|
{ |
|
|
|
WaitPrint targetWaitPrint = new WaitPrint(GuidGenerator.Create()); |
|
|
|
targetWaitPrint.M100Id = Guid.Parse("00000000-0000-0000-0000-000000000000"); |
|
|
|
targetWaitPrint.BusinessType = sourceWaitPrint.BusinessType; |
|
|
|
targetWaitPrint.ProductLine = sourceWaitPrint.ProductLine; |
|
|
|
targetWaitPrint.OnlineTime = sourceWaitPrint.OnlineTime; |
|
|
|
targetWaitPrint.HostSN = breaknum.ToString().Right(5).TryToIntZero(); |
|
|
|
targetWaitPrint.KNR = null; |
|
|
|
targetWaitPrint.VIN = null; |
|
|
|
targetWaitPrint.VehicleModelCode = null; |
|
|
|
targetWaitPrint.AssemblyID = null; |
|
|
|
targetWaitPrint.BillStatus = BillStatusEnum.BreakNum; |
|
|
|
targetWaitPrint.PrintType = PrintTypeEnum.OrderPrint; |
|
|
|
targetWaitPrint.HostSN2 = breaknum.Key.TryToIntZero(); |
|
|
|
targetWaitPrint.Description = null; |
|
|
|
targetWaitPrint.ReceiveTime = null; |
|
|
|
targetWaitPrint.CreationTime = null; |
|
|
|
targetWaitPrint.CreatorId = null; |
|
|
|
targetWaitPrint.LastModificationTime = null; |
|
|
|
targetWaitPrint.LastModifierId = null; |
|
|
|
breakNumLst.Add(targetWaitPrint); |
|
|
|
} |
|
|
|
} |
|
|
|
await _waitPrintRepository.InsertManyAsync(breakNumLst, autoSave); //插入断号
|
|
|
|
} |
|
|
|
//处理正常、迟到
|
|
|
|
BillM100 m100Ret = null; |
|
|
|
if (normalObj.Key != null) //正常
|
|
|
|
{ |
|
|
|
m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); //插入M100
|
|
|
|
await _waitPrintRepository.InsertManyAsync(wpArr, autoSave); //插入未打印表
|
|
|
|
} |
|
|
|
else if (lateObj.Key != null) //迟到
|
|
|
|
{ |
|
|
|
m100Ret = await _billM100Repository.InsertAsync(m100Obj, autoSave); //插入M100
|
|
|
|
|
|
|
|
foreach (var item in wpArr) |
|
|
|
{ |
|
|
|
var insObj = await _waitPrintRepository.FirstOrDefaultAsync(itm => |
|
|
|
itm.HostSN2 == m100Obj.HostSN2 |
|
|
|
&& itm.BillStatus == BillStatusEnum.BreakNum |
|
|
|
&& itm.BusinessType == item.BusinessType); |
|
|
|
if (insObj != null) |
|
|
|
{ |
|
|
|
//如果未打印表有对应断号记录,将迟到记录与之合并
|
|
|
|
Set_WaitPrint(item, insObj); |
|
|
|
var updateRet = await _waitPrintRepository.UpdateAsync(insObj); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
WaitPrint mbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan); |
|
|
|
await _waitPrintRepository.InsertAsync(mbRec); |
|
|
|
//如果未打印表没有----对应断号记录,则插入
|
|
|
|
var insertRet = await _waitPrintRepository.InsertAsync(item, autoSave); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
return m100Ret; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> UpdateM100(BillM100 m100Obj, bool autoSave = false) |
|
|
|
public async Task<BillM100> UpdateM100(BillM100 m100Obj, bool autoSave = false) |
|
|
|
{ |
|
|
|
var m100Ret = await _billM100Repository.UpdateAsync(m100Obj, autoSave); |
|
|
|
if (m100Ret != null) |
|
|
|
{ |
|
|
|
if (m100Obj.ProductLine == "08") |
|
|
|
{ |
|
|
|
//更新已解析状态时,只涉及门板记录
|
|
|
|
WaitPrint mbRec = await _waitPrintRepository.GetAsync(itm => itm.M100Id == m100Ret.Id && itm.BusinessType == BusinessTypeEnum.MenBan); |
|
|
|
ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); |
|
|
|
await _waitPrintRepository.UpdateAsync(mbRec); |
|
|
@ -80,9 +150,9 @@ namespace WY.NewJit.MsgCheck |
|
|
|
ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); |
|
|
|
await _waitPrintRepository.UpdateAsync(mbRec); |
|
|
|
} |
|
|
|
return true; |
|
|
|
return m100Ret; |
|
|
|
} |
|
|
|
return false; |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private WaitPrint ConvertWaitPrint(BillM100 m100Ret, BusinessTypeEnum businessType) |
|
|
@ -121,5 +191,27 @@ namespace WY.NewJit.MsgCheck |
|
|
|
waitPrint.LastModifierId = m100Ret.LastModifierId; |
|
|
|
} |
|
|
|
|
|
|
|
private void Set_WaitPrint(WaitPrint sourceWaitPrint, WaitPrint targetWaitPrint) |
|
|
|
{ |
|
|
|
targetWaitPrint.M100Id = sourceWaitPrint.M100Id; |
|
|
|
targetWaitPrint.BusinessType = sourceWaitPrint.BusinessType; |
|
|
|
targetWaitPrint.ProductLine = sourceWaitPrint.ProductLine; |
|
|
|
targetWaitPrint.OnlineTime = sourceWaitPrint.OnlineTime; |
|
|
|
targetWaitPrint.HostSN = sourceWaitPrint.HostSN; |
|
|
|
targetWaitPrint.KNR = sourceWaitPrint.KNR; |
|
|
|
targetWaitPrint.VIN = sourceWaitPrint.VIN; |
|
|
|
targetWaitPrint.VehicleModelCode = sourceWaitPrint.VehicleModelCode; |
|
|
|
targetWaitPrint.AssemblyID = sourceWaitPrint.AssemblyID; |
|
|
|
targetWaitPrint.BillStatus = sourceWaitPrint.BillStatus; |
|
|
|
targetWaitPrint.PrintType = sourceWaitPrint.PrintType; |
|
|
|
targetWaitPrint.HostSN2 = sourceWaitPrint.HostSN2; |
|
|
|
targetWaitPrint.Description = sourceWaitPrint.Description; |
|
|
|
targetWaitPrint.ReceiveTime = sourceWaitPrint.ReceiveTime; |
|
|
|
targetWaitPrint.CreationTime = sourceWaitPrint.CreationTime; |
|
|
|
targetWaitPrint.CreatorId = sourceWaitPrint.CreatorId; |
|
|
|
targetWaitPrint.LastModificationTime = sourceWaitPrint.LastModificationTime; |
|
|
|
targetWaitPrint.LastModifierId = sourceWaitPrint.LastModifierId; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|