Browse Source

完成插入M100方法

master
liuyunfeng 1 year ago
parent
commit
352c4922f7
  1. 23
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs
  2. 35
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs
  3. 128
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs

23
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs

@ -95,6 +95,17 @@ namespace WY.NewJit.Common
} }
} }
public static int TryToIntNotNull(this int? p_obj)
{
if (p_obj == null)
{
throw new ArgumentNullException(nameof(p_obj));
}
return (int)p_obj;
}
public static double? TryToDouble(this object p_obj) public static double? TryToDouble(this object p_obj)
{ {
string str = p_obj.ToString(); string str = p_obj.ToString();
@ -305,6 +316,18 @@ namespace WY.NewJit.Common
return false; return false;
} }
//public static string Left(this string param, int length)
//{
// string result = param.Substring(0, length);
// return result;
//}
//public static string Right(this string param, int length)
//{
// string result = param.Substring(param.Length - length, length);
// return result;
//}
} }
public class ExtCvt public class ExtCvt

35
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs

@ -84,6 +84,7 @@ namespace WY.NewJit.MsgCheck
/// 零件配置 /// 零件配置
/// </summary> /// </summary>
private readonly IRepository<PartCfg, Guid> _partCfgRepository; private readonly IRepository<PartCfg, Guid> _partCfgRepository;
private readonly M100DomainService _m100DomainService;
/// <summary> /// <summary>
@ -173,7 +174,8 @@ namespace WY.NewJit.MsgCheck
Microsoft.Extensions.Configuration.IConfiguration configuration, Microsoft.Extensions.Configuration.IConfiguration configuration,
INewJitDapperRepository newJitDapperRepository, INewJitDapperRepository newJitDapperRepository,
IRepository<AssemblyCfgVehicle, Guid> assemblyCfgVehicleRepository, IRepository<AssemblyCfgVehicle, Guid> assemblyCfgVehicleRepository,
IRepository<PartCfg, Guid> partCfgRepository IRepository<PartCfg, Guid> partCfgRepository,
M100DomainService m100DomainService
) )
{ {
_billM100Repository = billM100Repository; _billM100Repository = billM100Repository;
@ -187,6 +189,7 @@ namespace WY.NewJit.MsgCheck
_newJitDapperRepository = newJitDapperRepository; _newJitDapperRepository = newJitDapperRepository;
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; _assemblyCfgVehicleRepository = assemblyCfgVehicleRepository;
_partCfgRepository = partCfgRepository; _partCfgRepository = partCfgRepository;
_m100DomainService = m100DomainService;
} }
#region 公共方法 #region 公共方法
@ -338,7 +341,8 @@ namespace WY.NewJit.MsgCheck
//更新单据表 //更新单据表
m100Bill.SetAssemblyID(null); m100Bill.SetAssemblyID(null);
m100Bill.SetBillStatus(BillStatusEnum.NotMatch); m100Bill.SetBillStatus(BillStatusEnum.NotMatch);
var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); //var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult();
var succObj1 = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult();
//不匹配时,插入未知总成 //不匹配时,插入未知总成
var succObj2 = InsertUnknownAssembly(m100Bill); var succObj2 = InsertUnknownAssembly(m100Bill);
@ -392,7 +396,8 @@ namespace WY.NewJit.MsgCheck
foreach (BillM100 canNotPrintObj in canNotPrintLst) foreach (BillM100 canNotPrintObj in canNotPrintLst)
{ {
canNotPrintObj.CanNotPrint = true; canNotPrintObj.CanNotPrint = true;
_billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); //_billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult();
_m100DomainService.UpdateM100(canNotPrintObj, true).GetAwaiter().GetResult();
} }
#endregion #endregion
@ -478,7 +483,8 @@ namespace WY.NewJit.MsgCheck
if (hasPrintData) //该单据处于未解析时,已经打印 if (hasPrintData) //该单据处于未解析时,已经打印
{ {
m100Obj.NeedReplenishPrint = 1; m100Obj.NeedReplenishPrint = 1;
_billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); //_billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult();
_m100DomainService.UpdateM100(m100Obj, true).GetAwaiter().GetResult();
} }
#endregion #endregion
@ -490,7 +496,8 @@ namespace WY.NewJit.MsgCheck
//更新单据表 //更新单据表
m100Bill.SetAssemblyID(null); m100Bill.SetAssemblyID(null);
m100Bill.SetBillStatus(BillStatusEnum.NotMatch); m100Bill.SetBillStatus(BillStatusEnum.NotMatch);
var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); //var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult();
var succObj1 = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult();
//不匹配时,插入未知总成 //不匹配时,插入未知总成
var succObj2 = InsertUnknownAssembly(m100Bill); var succObj2 = InsertUnknownAssembly(m100Bill);
@ -535,16 +542,19 @@ namespace WY.NewJit.MsgCheck
{ {
if (isUnknowAssembly) if (isUnknowAssembly)
{ {
succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); //succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult();
succObj = _m100DomainService.UpdateM100(m100Bill).GetAwaiter().GetResult();
} }
else else
{ {
succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); //succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult();
succObj = _m100DomainService.UpdateM100(m100Bill, true).GetAwaiter().GetResult();
} }
} }
else else
{ {
succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); //succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult();
succObj = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult();
} }
if (succObj == null) if (succObj == null)
@ -596,16 +606,19 @@ namespace WY.NewJit.MsgCheck
{ {
if (isUnknowAssembly) if (isUnknowAssembly)
{ {
succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); //succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult();
succObj = _m100DomainService.UpdateM100(m100Bill).GetAwaiter().GetResult();
} }
else else
{ {
succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); //succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult();
succObj = _m100DomainService.UpdateM100(m100Bill, true).GetAwaiter().GetResult();
} }
} }
else else
{ {
succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); //succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult();
succObj = _m100DomainService.InsertM100(m100Bill, true).GetAwaiter().GetResult();
} }
if (succObj == null) if (succObj == null)

128
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100DomainService.cs

@ -7,6 +7,7 @@ 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.PrintTable; using WY.NewJit.PrintTable;
using WY.NewJit.Common;
namespace WY.NewJit.MsgCheck namespace WY.NewJit.MsgCheck
{ {
@ -27,49 +28,118 @@ namespace WY.NewJit.MsgCheck
/// </summary> /// </summary>
private readonly IRepository<WaitPrint, Guid> _waitPrintRepository; private readonly IRepository<WaitPrint, Guid> _waitPrintRepository;
private readonly BillNumberRecordDomainService _billNumRecDomainSrv;
public M100DomainService( public M100DomainService(
IRepository<BillM100, Guid> billM100Repository, IRepository<BillM100, Guid> billM100Repository,
ILogger<M100CheckDomainService> logger, ILogger<M100CheckDomainService> logger,
IRepository<WaitPrint, Guid> waitPrintRepository IRepository<WaitPrint, Guid> waitPrintRepository,
BillNumberRecordDomainService billNumRecDomainSrv
) )
{ {
_billM100Repository = billM100Repository; _billM100Repository = billM100Repository;
_logger = logger; _logger = logger;
_waitPrintRepository = waitPrintRepository; _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); foreach (var breaknum in breaknumLst)
WaitPrint zhbOtherRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.OtherZhuHuBan); {
WaitPrint zhbRec = ConvertWaitPrint(m100Ret, BusinessTypeEnum.ZhuHuBan); WaitPrint targetWaitPrint = new WaitPrint(GuidGenerator.Create());
WaitPrint[] arr = new WaitPrint[3] { mbRec, zhbOtherRec, zhbRec }; targetWaitPrint.M100Id = Guid.Parse("00000000-0000-0000-0000-000000000000");
await _waitPrintRepository.InsertManyAsync(arr); 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 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); var m100Ret = await _billM100Repository.UpdateAsync(m100Obj, autoSave);
if (m100Ret != null) if (m100Ret != null)
{ {
if (m100Obj.ProductLine == "08") if (m100Obj.ProductLine == "08")
{ {
//更新已解析状态时,只涉及门板记录
WaitPrint mbRec = await _waitPrintRepository.GetAsync(itm => itm.M100Id == m100Ret.Id && itm.BusinessType == BusinessTypeEnum.MenBan); WaitPrint mbRec = await _waitPrintRepository.GetAsync(itm => itm.M100Id == m100Ret.Id && itm.BusinessType == BusinessTypeEnum.MenBan);
ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec);
await _waitPrintRepository.UpdateAsync(mbRec); await _waitPrintRepository.UpdateAsync(mbRec);
@ -80,9 +150,9 @@ namespace WY.NewJit.MsgCheck
ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec); ConvertWaitPrint(m100Ret, BusinessTypeEnum.MenBan, mbRec);
await _waitPrintRepository.UpdateAsync(mbRec); await _waitPrintRepository.UpdateAsync(mbRec);
} }
return true; return m100Ret;
} }
return false; return null;
} }
private WaitPrint ConvertWaitPrint(BillM100 m100Ret, BusinessTypeEnum businessType) private WaitPrint ConvertWaitPrint(BillM100 m100Ret, BusinessTypeEnum businessType)
@ -121,5 +191,27 @@ namespace WY.NewJit.MsgCheck
waitPrint.LastModifierId = m100Ret.LastModifierId; 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;
}
} }
} }

Loading…
Cancel
Save