|
@ -39,7 +39,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
private readonly DicDomainService _dicDomainService; |
|
|
private readonly DicDomainService _dicDomainService; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 零件仓储
|
|
|
/// 导入记录仓储
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<ImportRecord, Guid> _importRecordRepository; |
|
|
private readonly IRepository<ImportRecord, Guid> _importRecordRepository; |
|
|
|
|
|
|
|
@ -51,32 +51,40 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// ERP总成分组仓库
|
|
|
/// ERP总成分组仓库
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<AssemblyCfgGroup, Guid> _assemblyCfgGroupRepository; |
|
|
//private readonly IRepository<AssemblyCfgGroup, Guid> _assemblyCfgGroupRepository;
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// ERP总成仓储
|
|
|
/// ERP总成仓储
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<AssemblyCfgErp, Guid> _assemblyCfgErpRepository; |
|
|
//private readonly IRepository<AssemblyCfgErp, Guid> _assemblyCfgErpRepository;
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 整车总成配置仓库
|
|
|
/// 整车总成配置仓库
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<AssemblyCfgVehicle, Guid> _assemblyCfgVehicleRepository; |
|
|
private readonly IRepository<AssemblyCfgVehicle, Guid> _assemblyCfgVehicleRepository; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入最大流水号 领域服务
|
|
|
|
|
|
/// </summary>
|
|
|
private readonly LastImportHostSNDomainService _lastImportHostSNDomainService; |
|
|
private readonly LastImportHostSNDomainService _lastImportHostSNDomainService; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 缓存管理 领域服务
|
|
|
|
|
|
/// </summary>
|
|
|
private readonly HQ_CacheManagerDomainService _hqCacheManagerDomainService; |
|
|
private readonly HQ_CacheManagerDomainService _hqCacheManagerDomainService; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 插入M100、未打印表 领域服务
|
|
|
|
|
|
/// </summary>
|
|
|
private readonly HQ_M100DomainService _hqM100DomainServie; |
|
|
private readonly HQ_M100DomainService _hqM100DomainServie; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 重复M100
|
|
|
/// 重复报文仓库
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<RepeatM100, Guid> _repeatM100Repository; |
|
|
private readonly IRepository<RepeatM100, Guid> _repeatM100Repository; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 未知总成维护
|
|
|
/// 未知总成仓库
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IRepository<UnknownAssembly, Guid> _unknownAssemblyRepository; |
|
|
private readonly IRepository<UnknownAssembly, Guid> _unknownAssemblyRepository; |
|
|
|
|
|
|
|
@ -84,12 +92,12 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 报文车型对应零件生产工厂车型
|
|
|
/// 报文车型对应零件生产工厂车型
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private static List<DicItem> _msgToPaiGeVehicleModelList = new List<DicItem>(); |
|
|
//private static List<DicItem> _msgToPaiGeVehicleModelList = new List<DicItem>();
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// M100零件生产工厂车型对应生产线
|
|
|
/// M100零件生产工厂车型对应生产线
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private static List<DicItem> _m100VehicleModelProductLineList = new List<DicItem>(); |
|
|
//private static List<DicItem> _m100VehicleModelProductLineList = new List<DicItem>();
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析
|
|
|
/// 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析
|
|
@ -118,12 +126,11 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
_billM100Repository = billM100Repository; |
|
|
_billM100Repository = billM100Repository; |
|
|
_lastImportHostSNDomainService = lastImportHostSNDomainService; |
|
|
_lastImportHostSNDomainService = lastImportHostSNDomainService; |
|
|
|
|
|
|
|
|
_msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.报文车型对应派格车型); |
|
|
//_msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.报文车型对应派格车型);
|
|
|
_m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100派格车型对应生产线); |
|
|
//_m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100派格车型对应生产线);
|
|
|
_assemblyCfgGroupRepository = assemblyCfgGroupRepository; |
|
|
//_assemblyCfgGroupRepository = assemblyCfgGroupRepository;
|
|
|
_assemblyCfgErpRepository = assemblyCfgErpRepository; |
|
|
//_assemblyCfgErpRepository = assemblyCfgErpRepository;
|
|
|
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; |
|
|
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository; |
|
|
|
|
|
|
|
|
_hqCacheManagerDomainService = hqCacheManagerDomainService; |
|
|
_hqCacheManagerDomainService = hqCacheManagerDomainService; |
|
|
_hqM100DomainServie = hqM100DomainServie; |
|
|
_hqM100DomainServie = hqM100DomainServie; |
|
|
_repeatM100Repository = repeatM100Repository; |
|
|
_repeatM100Repository = repeatM100Repository; |
|
@ -132,43 +139,39 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 解析报文
|
|
|
/// 解析报文
|
|
|
|
|
|
/// 一、导入记录表
|
|
|
|
|
|
/// 1. 从客户网站导出EXCEL格式的订单列表
|
|
|
|
|
|
/// 2. 校验 本次导入的最小HostSN必须<= 上次导入的最大HostSN + 1 (上次是10, 本次可以是 9 10 11,不能是12)
|
|
|
|
|
|
/// 3. 根据VIN和HostSN,扣除重复导入的记录
|
|
|
|
|
|
/// 4. 断号提醒:导入Excel时,如果系统中的流水号不能顺序连接,需要给出提醒,是否继续导入,如果选择继续导入,仍可以导入到系统中
|
|
|
|
|
|
/// 5. 最后导入到本系统中 impRecLst
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 二、插入M100
|
|
|
|
|
|
/// 1. 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析
|
|
|
|
|
|
/// 2. 根据VIN判断是否重复报文,将重复报文放到“重复报文表”
|
|
|
|
|
|
/// 3. 通过车型描述中的颜色(条件一)和规格说明(条件二)两个字段能够定位到该底盘对应哪个总成组(4个总成一组)。如果匹配将订单和总成组进行绑定;如果不匹配将订单放入未知总成
|
|
|
|
|
|
/// 4. 插入M100 (更新派格车型、 生产线)
|
|
|
|
|
|
/// 5. 插入WaitPrint
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="impRecLst"></param>
|
|
|
/// <param name="impRecLst">导入Excel内容</param>
|
|
|
|
|
|
/// <param name="forceExecute">校验不通过时,是否强制执行通过</param>
|
|
|
public async Task<ObjectResultDto> ParseEdi(List<ImportRecord> input, bool forceExecute = false) |
|
|
public async Task<ObjectResultDto> ParseEdi(List<ImportRecord> input, bool forceExecute = false) |
|
|
{ |
|
|
{ |
|
|
ObjectResultDto ret = new ObjectResultDto(); |
|
|
ObjectResultDto ret = new ObjectResultDto(); |
|
|
//取本次导入的最小HostSN
|
|
|
|
|
|
int minHostSN = input.Min(itm => itm.HostSN); |
|
|
|
|
|
//上次导入的最大HostSN
|
|
|
|
|
|
int lastHostSN = await _lastImportHostSNDomainService.GetLastImportHostSN(); |
|
|
|
|
|
string betweenBreakNumMsg = ""; |
|
|
|
|
|
if (minHostSN <= lastHostSN + 1) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
if (forceExecute == false) |
|
|
|
|
|
{ |
|
|
|
|
|
//两次导入断号提醒
|
|
|
|
|
|
betweenBreakNumMsg = $"两次导入断号提醒:本次导入的最小流水号是:{minHostSN},上次导入的最大流水号是:{lastHostSN}"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//扣除重复导入的订单
|
|
|
//扣除重复导入的订单
|
|
|
List<ImportRecord> notRepeatOrder = await GetNotRepeatOrder(input); |
|
|
List<ImportRecord> notRepeatOrder = await GetNotRepeatOrder(input); |
|
|
|
|
|
if (notRepeatOrder.Count == 0) |
|
|
#region 断号提醒
|
|
|
|
|
|
string breakNumMsg = ""; |
|
|
|
|
|
notRepeatOrder = notRepeatOrder.OrderBy(itm => itm.HostSN).ToList(); |
|
|
|
|
|
for (int curIdx = 1; curIdx < notRepeatOrder.Count; curIdx++) |
|
|
|
|
|
{ |
|
|
{ |
|
|
int curVal = notRepeatOrder[curIdx].HostSN; |
|
|
ret.Status = true; |
|
|
int priorIdx = curIdx - 1; |
|
|
ret.Message = "根据Vin和HostSN,排除在数据库中重复的Excel订单后,已经没有不重复的订单!"; |
|
|
int priorVal = notRepeatOrder[priorIdx].HostSN; |
|
|
return ret; |
|
|
if (curVal - priorVal != 1) |
|
|
|
|
|
{ |
|
|
|
|
|
breakNumMsg += $"流水号{priorVal}和{curVal}之间存在断号\r\n"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
#region 断号提醒
|
|
|
|
|
|
//校验两次导入之间是否断号
|
|
|
|
|
|
string betweenBreakNumMsg = await CheckBetweenBreakNum(input); |
|
|
|
|
|
//校验本次导入数据是否断号
|
|
|
|
|
|
string breakNumMsg = CheckBreakNum(ref notRepeatOrder); |
|
|
if (betweenBreakNumMsg.HasValue() || breakNumMsg.HasValue()) |
|
|
if (betweenBreakNumMsg.HasValue() || breakNumMsg.HasValue()) |
|
|
{ |
|
|
{ |
|
|
if (forceExecute == false) |
|
|
if (forceExecute == false) |
|
@ -179,48 +182,25 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
//批量插入 导入记录
|
|
|
|
|
|
await _importRecordRepository.InsertManyAsync(notRepeatOrder); |
|
|
|
|
|
|
|
|
|
|
|
//初始化缓存
|
|
|
//初始化缓存
|
|
|
_hqCacheManagerDomainService.InitLoadCache(); |
|
|
_hqCacheManagerDomainService.InitLoadCache(); |
|
|
|
|
|
|
|
|
//过滤掉其它订单,只取派格订单
|
|
|
//批量插入 导入记录
|
|
|
var paigeOrderLst = notRepeatOrder.Where(itm => itm.VehicleModelCode.Substring(0, 2) == _vehicleModelPrefix).OrderBy(itm => itm.HostSN).ToList(); |
|
|
await _importRecordRepository.InsertManyAsync(notRepeatOrder); |
|
|
|
|
|
|
|
|
|
|
|
//过滤掉其它厂家的订单,只取派格订单
|
|
|
|
|
|
var paigeOrderLst = notRepeatOrder.Where(itm => itm.VehicleModelCode.Substring(0, 2) == _vehicleModelPrefix).OrderBy(itm => itm.HostSN).ToList(); |
|
|
foreach (ImportRecord orderItem in paigeOrderLst) |
|
|
foreach (ImportRecord orderItem in paigeOrderLst) |
|
|
{ |
|
|
{ |
|
|
#region 构建M100实体
|
|
|
//构建M100实体
|
|
|
BillM100 m100Obj = new BillM100(GuidGenerator.Create()); |
|
|
BillM100 m100Obj = BuildM100Entity(orderItem); |
|
|
m100Obj.MessageFileReceiveID = orderItem.Id; |
|
|
//更新车型、产线
|
|
|
m100Obj.SerialNum = ServerHelper.VinToSN(orderItem.Vin); |
|
|
|
|
|
m100Obj.SerialNumStr = ServerHelper.ToSerialNumStr(orderItem.OnlineTime, orderItem.HostSN); |
|
|
|
|
|
m100Obj.HostSN = orderItem.HostSN; |
|
|
|
|
|
m100Obj.HostSN2 = orderItem.HostSN; //流水号
|
|
|
|
|
|
m100Obj.KNR = orderItem.VehicleBodyCode; |
|
|
|
|
|
m100Obj.VIN = orderItem.Vin; |
|
|
|
|
|
m100Obj.AssemblyID = null; |
|
|
|
|
|
m100Obj.OnlineTime = orderItem.OnlineTime; |
|
|
|
|
|
m100Obj.VehicleModelCode = orderItem.VehicleBodyCode; |
|
|
|
|
|
m100Obj.ProductLine = ""; |
|
|
|
|
|
m100Obj.Version = ""; |
|
|
|
|
|
m100Obj.ReceiveTime = ServerHelper.CurrentDateTime; |
|
|
|
|
|
m100Obj.BillStatus = BillStatusEnum.NotMatch; |
|
|
|
|
|
m100Obj.Description = ""; |
|
|
|
|
|
//m100Obj.OperationType = operationType;
|
|
|
|
|
|
//m100Obj.Operator = @operator;
|
|
|
|
|
|
//m100Obj.OperationTime = operationTime;
|
|
|
|
|
|
m100Obj.CanNotPrint = false; |
|
|
|
|
|
m100Obj.NeedReplenishPrint = 0; |
|
|
|
|
|
m100Obj.IsPartSwitch = false; |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
UpdateProductLine(m100Obj); |
|
|
UpdateProductLine(m100Obj); |
|
|
string snStr = ServerHelper.ToSerialNumStr(m100Obj.OnlineTime, m100Obj.HostSN); |
|
|
|
|
|
m100Obj.SetSerialNumStr(snStr); |
|
|
|
|
|
|
|
|
|
|
|
//重复报文
|
|
|
//重复报文
|
|
|
bool isRepeat = _billM100Repository.Any(itm => itm.HostSN == orderItem.HostSN && itm.VIN == orderItem.Vin); |
|
|
bool isRepeat = await _billM100Repository.AnyAsync(itm => itm.HostSN == orderItem.HostSN && itm.VIN == orderItem.Vin); |
|
|
if (isRepeat == true) |
|
|
if (isRepeat == true) |
|
|
{ |
|
|
{ |
|
|
#region 重复报文
|
|
|
#region 重复报文
|
|
@ -233,13 +213,12 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
|
|
|
|
|
//绑定总成分组
|
|
|
//绑定总成分组
|
|
|
string colorExplain = orderItem.VehicleModelDesc.Trim().Right(7); |
|
|
string colorExplain = orderItem.VehicleModelDesc.Trim().Right(7); |
|
|
|
|
|
|
|
|
Group_Assembly groupAssemblyObj = HQ_CacheManagerDomainService._groupAssemblyList.FirstOrDefault(itm => itm.SpecExplain == orderItem.SpecDesc && itm.ColorExplain == colorExplain); |
|
|
Group_Assembly groupAssemblyObj = HQ_CacheManagerDomainService._groupAssemblyList.FirstOrDefault(itm => itm.SpecExplain == orderItem.SpecDesc && itm.ColorExplain == colorExplain); |
|
|
if (groupAssemblyObj != null) |
|
|
if (groupAssemblyObj != null) |
|
|
{ |
|
|
{ |
|
|
#region 插入整车总成
|
|
|
#region 插入整车总成
|
|
|
Guid vehicleAssemblyId = GuidGenerator.Create(); |
|
|
Guid vehicleAssemblyId = GuidGenerator.Create(); |
|
|
AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(vehicleAssemblyId, null, "", null, true); |
|
|
AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(vehicleAssemblyId, null, m100Obj.VehicleModelCode, null, true); |
|
|
foreach (OnlyAssemblyInfo assemblyItem in groupAssemblyObj.AssemblyDetails) //插入子表
|
|
|
foreach (OnlyAssemblyInfo assemblyItem in groupAssemblyObj.AssemblyDetails) //插入子表
|
|
|
{ |
|
|
{ |
|
|
vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id); |
|
|
vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id); |
|
@ -253,6 +232,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
|
|
|
|
|
|
//插入M100、未打印表
|
|
|
//插入M100、未打印表
|
|
|
m100Obj.SetAssemblyID(vehicleAssemblyResu.Id); |
|
|
m100Obj.SetAssemblyID(vehicleAssemblyResu.Id); |
|
|
|
|
|
m100Obj.SetBillStatus(BillStatusEnum.Match); |
|
|
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, true); |
|
|
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, true); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@ -270,27 +250,91 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
ret.Status = (succObj1 != null && succObj2 != null); |
|
|
ret.Status = (succObj1 != null && succObj2 != null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} //foreach
|
|
|
|
|
|
|
|
|
/* |
|
|
//更新本次导入的最大HostSN
|
|
|
一、导入记录表 |
|
|
int curMaxHostSN = input.Max(itm => itm.HostSN); |
|
|
1. 从客户网站导出EXCEL格式的订单列表 |
|
|
await _lastImportHostSNDomainService.SetCurrentImportMaxHostSN(curMaxHostSN); |
|
|
2. 校验 本次导入的最小HostSN必须<= 上次导入的最大HostSN + 1 (上次是10, 本次可以是 9 10 11,不能是12) |
|
|
|
|
|
3. 根据VIN和HostSN,扣除重复导入的记录 |
|
|
|
|
|
4. 断号提醒:导入Excel时,如果系统中的流水号不能顺序连接,需要给出提醒,是否继续导入,如果选择继续导入,仍可以导入到系统中 |
|
|
|
|
|
5. 最后导入到本系统中 impRecLst |
|
|
|
|
|
|
|
|
|
|
|
二、插入M100 |
|
|
|
|
|
1. 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析 |
|
|
|
|
|
2. 根据VIN判断是否重复报文,将重复报文放到“重复报文表” |
|
|
|
|
|
3. 通过车型描述中的颜色(条件一)和规格说明(条件二)两个字段能够定位到该底盘对应哪个总成组(4个总成一组)。如果匹配将订单和总成组进行绑定;如果不匹配将订单放入未知总成 |
|
|
|
|
|
4. 插入M100 (更新派格车型、 生产线) |
|
|
|
|
|
5. 插入WaitPrint |
|
|
|
|
|
*/ |
|
|
|
|
|
ret.Status = true; |
|
|
ret.Status = true; |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 上次导入和本次导入之间的流水号是否连续
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async Task<string> CheckBetweenBreakNum(List<ImportRecord> input) |
|
|
|
|
|
{ |
|
|
|
|
|
string ret = ""; |
|
|
|
|
|
//取本次导入的最小HostSN
|
|
|
|
|
|
int curMinHostSN = input.Min(itm => itm.HostSN); |
|
|
|
|
|
//上次导入的最大HostSN
|
|
|
|
|
|
int priorMaxHostSN = await _lastImportHostSNDomainService.GetLastImportMaxHostSN(); |
|
|
|
|
|
if (priorMaxHostSN > 0) //第一次导入时(priorMaxHostSN = 0),不需要校验两次导入之间的断号
|
|
|
|
|
|
{ |
|
|
|
|
|
if (curMinHostSN <= priorMaxHostSN + 1) |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
//两次导入断号提醒
|
|
|
|
|
|
ret = $"两次导入断号提醒:本次导入的最小流水号是:{curMinHostSN},上次导入的最大流水号是:{priorMaxHostSN},两者不连续\r\n"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private BillM100 BuildM100Entity(ImportRecord orderItem) |
|
|
|
|
|
{ |
|
|
|
|
|
BillM100 m100Obj = new BillM100(GuidGenerator.Create()); |
|
|
|
|
|
m100Obj.MessageFileReceiveID = orderItem.Id; |
|
|
|
|
|
m100Obj.SerialNum = ServerHelper.VinToSN(orderItem.Vin); |
|
|
|
|
|
m100Obj.SerialNumStr = ServerHelper.ToSerialNumStr(orderItem.OnlineTime, orderItem.HostSN); |
|
|
|
|
|
m100Obj.HostSN = orderItem.HostSN; |
|
|
|
|
|
m100Obj.HostSN2 = orderItem.HostSN; //流水号
|
|
|
|
|
|
m100Obj.KNR = orderItem.VehicleBodyCode; |
|
|
|
|
|
m100Obj.VIN = orderItem.Vin; |
|
|
|
|
|
m100Obj.AssemblyID = null; |
|
|
|
|
|
m100Obj.OnlineTime = orderItem.OnlineTime; |
|
|
|
|
|
m100Obj.VehicleModelCode = orderItem.VehicleModelCode.Substring(0, 2); |
|
|
|
|
|
m100Obj.ProductLine = null; |
|
|
|
|
|
m100Obj.Version = ""; |
|
|
|
|
|
m100Obj.ReceiveTime = ServerHelper.CurrentDateTime; |
|
|
|
|
|
m100Obj.BillStatus = BillStatusEnum.NotMatch; |
|
|
|
|
|
m100Obj.Description = ""; |
|
|
|
|
|
//m100Obj.OperationType = operationType;
|
|
|
|
|
|
//m100Obj.Operator = @operator;
|
|
|
|
|
|
//m100Obj.OperationTime = operationTime;
|
|
|
|
|
|
m100Obj.CanNotPrint = false; |
|
|
|
|
|
m100Obj.NeedReplenishPrint = 0; |
|
|
|
|
|
m100Obj.IsPartSwitch = false; |
|
|
|
|
|
return m100Obj; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 校验本次导入数据断号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="notRepeatOrder"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private static string CheckBreakNum(ref List<ImportRecord> notRepeatOrder) |
|
|
|
|
|
{ |
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
notRepeatOrder = notRepeatOrder.OrderBy(itm => itm.HostSN).ToList(); |
|
|
|
|
|
for (int curIdx = 1; curIdx < notRepeatOrder.Count; curIdx++) |
|
|
|
|
|
{ |
|
|
|
|
|
int curVal = notRepeatOrder[curIdx].HostSN; |
|
|
|
|
|
int priorIdx = curIdx - 1; |
|
|
|
|
|
int priorVal = notRepeatOrder[priorIdx].HostSN; |
|
|
|
|
|
if (curVal - priorVal != 1) |
|
|
|
|
|
{ |
|
|
|
|
|
sb.AppendLine($"流水号{priorVal}和{curVal}之间存在断号"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return sb.ToString(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 根据流水号、VIN 扣除重复导入的订单
|
|
|
/// 根据流水号、VIN 扣除重复导入的订单
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -299,11 +343,8 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
private async Task<List<ImportRecord>> GetNotRepeatOrder(List<ImportRecord> input) |
|
|
private async Task<List<ImportRecord>> GetNotRepeatOrder(List<ImportRecord> input) |
|
|
{ |
|
|
{ |
|
|
List<ImportRecord> notRepeatLst = new List<ImportRecord>(); |
|
|
List<ImportRecord> notRepeatLst = new List<ImportRecord>(); |
|
|
|
|
|
List<ImportRecord> importHistoryLst = await _importRecordRepository.GetPagedListAsync(0, 10000, "HostSN desc"); |
|
|
|
|
|
|
|
|
List<ImportRecord> importHistoryLst = await _importRecordRepository.AsQueryable() |
|
|
|
|
|
.OrderBy(itm => itm.HostSN) |
|
|
|
|
|
.TakeLast(10000) |
|
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
foreach (ImportRecord item in input) |
|
|
foreach (ImportRecord item in input) |
|
|
{ |
|
|
{ |
|
|
bool hasData = importHistoryLst.Any(itm => itm.HostSN == item.HostSN && itm.Vin == item.Vin); |
|
|
bool hasData = importHistoryLst.Any(itm => itm.HostSN == item.HostSN && itm.Vin == item.Vin); |
|
@ -326,7 +367,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
{ |
|
|
{ |
|
|
string ediVehicleModel = bill.VehicleModelCode; //报文车型
|
|
|
string ediVehicleModel = bill.VehicleModelCode; //报文车型
|
|
|
//车型转换:3H 转 CC
|
|
|
//车型转换:3H 转 CC
|
|
|
var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); |
|
|
var obj1 = HQ_CacheManagerDomainService._msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); |
|
|
if (obj1 != null) |
|
|
if (obj1 != null) |
|
|
{ |
|
|
{ |
|
|
string paigeVehicleModel = obj1.DicItemName; // CC
|
|
|
string paigeVehicleModel = obj1.DicItemName; // CC
|
|
@ -336,7 +377,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
} |
|
|
} |
|
|
bill.SetVehicleModelCode(paigeVehicleModel); |
|
|
bill.SetVehicleModelCode(paigeVehicleModel); |
|
|
//根据车型取对应生产线
|
|
|
//根据车型取对应生产线
|
|
|
var obj2 = _m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel); |
|
|
var obj2 = HQ_CacheManagerDomainService._m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel); |
|
|
if (obj2 != null) |
|
|
if (obj2 != null) |
|
|
{ |
|
|
{ |
|
|
string productLine = obj2.DicItemName; |
|
|
string productLine = obj2.DicItemName; |
|
@ -355,7 +396,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private RepeatM100 InsertM100RepeatBill(ImportRecord impordRec, BillM100 m100Bill) //, int? maxSerialNum
|
|
|
private async Task<RepeatM100> InsertM100RepeatBill(ImportRecord impordRec, BillM100 m100Bill) |
|
|
{ |
|
|
{ |
|
|
RepeatM100 ret = null; |
|
|
RepeatM100 ret = null; |
|
|
int newSN = ServerHelper.VinToSN(m100Bill.VIN); |
|
|
int newSN = ServerHelper.VinToSN(m100Bill.VIN); |
|
@ -381,7 +422,7 @@ namespace WY.NewJit.EdiReceive.Services |
|
|
repeatBill.AddChildObj(GuidGenerator.Create(), m100Part.PartCode, m100Part.PartNum, m100Part.Description); |
|
|
repeatBill.AddChildObj(GuidGenerator.Create(), m100Part.PartCode, m100Part.PartNum, m100Part.Description); |
|
|
} |
|
|
} |
|
|
//插入重复单据
|
|
|
//插入重复单据
|
|
|
ret = _repeatM100Repository.InsertAsync(repeatBill, true).GetAwaiter().GetResult(); |
|
|
ret = await _repeatM100Repository.InsertAsync(repeatBill, true); |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|