|
|
@ -158,6 +158,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
public virtual async Task<ObjectResultDto> ParseEdi(List<ImportRecord> input, bool forceExecute = false) |
|
|
|
{ |
|
|
|
ObjectResultDto ret = new ObjectResultDto(); |
|
|
|
bool autoSave = false; |
|
|
|
|
|
|
|
//扣除重复导入的订单
|
|
|
|
List<ImportRecord> notRepeatOrder = await GetNotRepeatOrder(input); |
|
|
@ -190,12 +191,18 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
_hqCacheManagerDomainService.InitLoadCache(); |
|
|
|
|
|
|
|
//批量插入 导入记录
|
|
|
|
await _importRecordRepository.InsertManyAsync(notRepeatOrder, true); |
|
|
|
await _importRecordRepository.InsertManyAsync(notRepeatOrder, autoSave); |
|
|
|
|
|
|
|
//过滤掉其它厂家的订单,只取派格订单
|
|
|
|
var paigeOrderLst = notRepeatOrder.Where(itm => itm.VehicleModelCode.Substring(0, 2) == _vehicleModelPrefix).OrderBy(itm => itm.HostSN).ToList(); |
|
|
|
int idx = 0; |
|
|
|
foreach (ImportRecord orderItem in paigeOrderLst) |
|
|
|
{ |
|
|
|
idx++; |
|
|
|
if (idx % 10 == 0) |
|
|
|
{ |
|
|
|
_logger.LogDebug(_errorMessagePrefix + $"循环中:{idx}/{paigeOrderLst.Count}"); |
|
|
|
} |
|
|
|
//构建M100实体
|
|
|
|
BillM100 m100Obj = BuildM100Entity(orderItem); |
|
|
|
//更新车型、产线
|
|
|
@ -206,7 +213,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
if (isRepeat == true) |
|
|
|
{ |
|
|
|
#region 重复报文
|
|
|
|
var succObj = await InsertM100RepeatBill(orderItem, m100Obj); |
|
|
|
var succObj = await InsertM100RepeatBill(orderItem, m100Obj, autoSave); |
|
|
|
_logger.LogDebug(_errorMessagePrefix + $"流水号{orderItem.HostSN}是重复报文"); |
|
|
|
ret.Status = (succObj != null); |
|
|
|
return ret; |
|
|
@ -226,7 +233,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
{ |
|
|
|
vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id); |
|
|
|
} |
|
|
|
var vehicleAssemblyResu = await _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, true); |
|
|
|
var vehicleAssemblyResu = await _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, autoSave); |
|
|
|
if (vehicleAssemblyResu == null) |
|
|
|
{ |
|
|
|
throw new Exception("插入整车总成返回结果为空InsertAsync!"); |
|
|
@ -238,7 +245,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
m100Obj.SetBillStatus(BillStatusEnum.Match); |
|
|
|
m100Obj.SpecExplain = specExplain; |
|
|
|
m100Obj.ColorExplain = colorExplain; |
|
|
|
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, true); |
|
|
|
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, autoSave); |
|
|
|
if (insM100Ret == null) |
|
|
|
{ |
|
|
|
throw new Exception("插入M100返回结果为空InsertAsync!"); |
|
|
@ -253,10 +260,10 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
m100Obj.SetBillStatus(BillStatusEnum.NotMatch); |
|
|
|
m100Obj.SpecExplain = specExplain; |
|
|
|
m100Obj.ColorExplain = colorExplain; |
|
|
|
var succObj1 = await _hqM100DomainServie.InsertM100(m100Obj, true); |
|
|
|
var succObj1 = await _hqM100DomainServie.InsertM100(m100Obj, autoSave); |
|
|
|
|
|
|
|
//不匹配时,插入未知总成
|
|
|
|
var succObj2 = await InsertUnknownAssembly(m100Obj, true); |
|
|
|
var succObj2 = await InsertUnknownAssembly(m100Obj, autoSave); |
|
|
|
_logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成完成:{orderItem.HostSN}"); |
|
|
|
ret.Status = (succObj1 != null && succObj2 != null); |
|
|
|
} |
|
|
@ -265,7 +272,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
|
|
|
|
//更新本次导入的最大HostSN
|
|
|
|
int curMaxHostSN = input.Max(itm => itm.HostSN); |
|
|
|
await _lastImportHostSNDomainService.SetCurrentImportMaxHostSN(curMaxHostSN); |
|
|
|
await _lastImportHostSNDomainService.SetCurrentImportMaxHostSN(curMaxHostSN, true); //取最大号必须缓存autoSave = true
|
|
|
|
|
|
|
|
if (notRepeatOrder.Count < input.Count) |
|
|
|
{ |
|
|
@ -480,7 +487,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<RepeatM100> InsertM100RepeatBill(ImportRecord impordRec, BillM100 m100Bill) |
|
|
|
private async Task<RepeatM100> InsertM100RepeatBill(ImportRecord impordRec, BillM100 m100Bill, bool autoSave = false) |
|
|
|
{ |
|
|
|
RepeatM100 ret = null; |
|
|
|
int newSN = ServerHelper.VinToSN(m100Bill.VIN); |
|
|
@ -500,13 +507,13 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
BillStatusEnum.None |
|
|
|
); |
|
|
|
|
|
|
|
//零件子表赋值
|
|
|
|
foreach (BillM100Part m100Part in m100Bill.BillM100Parts) |
|
|
|
{ |
|
|
|
repeatBill.AddChildObj(GuidGenerator.Create(), m100Part.PartCode, m100Part.PartNum, m100Part.Description); |
|
|
|
} |
|
|
|
//零件子表赋值【红旗版没有子零件表数据】
|
|
|
|
//foreach (BillM100Part m100Part in m100Bill.BillM100Parts)
|
|
|
|
//{
|
|
|
|
// repeatBill.AddChildObj(GuidGenerator.Create(), m100Part.PartCode, m100Part.PartNum, m100Part.Description);
|
|
|
|
//}
|
|
|
|
//插入重复单据
|
|
|
|
ret = await _repeatM100Repository.InsertAsync(repeatBill, true); |
|
|
|
ret = await _repeatM100Repository.InsertAsync(repeatBill, autoSave); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|