Browse Source

超时问题,终于解决

HQ
liuyunfeng 7 months ago
parent
commit
11cc50a3da
  1. 22
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs
  2. 35
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/EdiParseDomainService.cs
  3. 6
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/LastImportHostSNDomainService.cs

22
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs

@ -476,6 +476,28 @@ namespace WY.NewJit.EdiReceive
//using (var uow = _unitOfWorkManager.Begin()) //using (var uow = _unitOfWorkManager.Begin())
//{ //{
var srcLst = impResult.Data.AsEnumerable().ToList(); var srcLst = impResult.Data.AsEnumerable().ToList();
#region 校验重复报文
string msg = "";
var groupLst = srcLst.GroupBy(itm => new { itm.Vin, itm.HostSN }).Select(itm => new
{
Vin = itm.Key.Vin,
HostSN = itm.Key.HostSN,
Count = itm.Count()
});
var tempLst = groupLst.Where(itm => itm.Count > 1);
foreach (var temp in tempLst)
{
msg += $"底盘{temp.Vin}、顺序号{temp.HostSN}记录重复\r\n";
}
if (msg.Length > 0)
{
ret.Message = msg;
ret.Status = false;
return ret;
}
#endregion
var tarLst = ObjectMapper.Map<List<ImportRecordDto>, List<ImportRecord>>(srcLst); var tarLst = ObjectMapper.Map<List<ImportRecordDto>, List<ImportRecord>>(srcLst);
foreach (var tar in tarLst) foreach (var tar in tarLst)
{ {

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

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

6
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/LastImportHostSNDomainService.cs

@ -82,19 +82,19 @@ namespace WY.NewJit.EdiReceive.Services
} }
} }
public async Task SetCurrentImportMaxHostSN(int maxHostSN) public async Task SetCurrentImportMaxHostSN(int maxHostSN, bool autoSave = false)
{ {
var obj = await _lastImportHostSNRepository.FirstOrDefaultAsync(); var obj = await _lastImportHostSNRepository.FirstOrDefaultAsync();
if (obj != null) if (obj != null)
{ {
obj.HostSN = maxHostSN; obj.HostSN = maxHostSN;
await _lastImportHostSNRepository.UpdateAsync(obj, true); await _lastImportHostSNRepository.UpdateAsync(obj, autoSave);
} }
else else
{ {
LastImportHostSN newObj = new LastImportHostSN(GuidGenerator.Create()); LastImportHostSN newObj = new LastImportHostSN(GuidGenerator.Create());
newObj.HostSN = maxHostSN; newObj.HostSN = maxHostSN;
var insRet = await _lastImportHostSNRepository.InsertAsync(newObj); var insRet = await _lastImportHostSNRepository.InsertAsync(newObj, autoSave);
} }
} }

Loading…
Cancel
Save