Browse Source

合并代码

HQ
lvzb 10 months ago
parent
commit
015f8d9cbd
  1. 9
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/EdiReceive/Interfaces/IImportRecordAppService.cs
  2. 5
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml
  3. 69
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs
  4. 3
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml
  5. 2
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ServerHelper.cs
  6. 4
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Entitys/LastImportHostSN.cs
  7. 241
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/EdiParseDomainService.cs
  8. 16
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/HQ_CacheManagerDomainService.cs
  9. 35
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Services/LastImportHostSNDomainService.cs

9
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/EdiReceive/Interfaces/IImportRecordAppService.cs

@ -6,9 +6,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using WY.NewJit.EdiReceive.Dtos; using WY.NewJit.EdiReceive.Dtos;
using WY.NewJit.MsgCheck;
namespace WY.NewJit.EdiReceive.Interfaces namespace WY.NewJit.EdiReceive.Interfaces
{ {
@ -62,11 +60,10 @@ namespace WY.NewJit.EdiReceive.Interfaces
/// <summary> /// <summary>
/// 导入信息 /// 导入信息
/// </summary> /// </summary>
/// <param name="input">导入文件流</param> /// <param name="files">导入文件流</param>
/// <param name="forceExecute">是否强制执行</param>
/// <returns>执行成功返回真</returns> /// <returns>执行成功返回真</returns>
Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files); Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files, bool forceExecute = false);
[HttpPost, Route("print-timeout-remind"), UnitOfWork]
Task<TimeOutRemindResultDto> PrintTimeoutRemind(TimeOutRemindInputDto input);
#endregion #endregion
} }

5
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml

@ -556,11 +556,12 @@
<param name="input">导出查询条件</param> <param name="input">导出查询条件</param>
<returns>执行成功返回真</returns> <returns>执行成功返回真</returns>
</member> </member>
<member name="M:WY.NewJit.EdiReceive.Interfaces.IImportRecordAppService.ImportAsync(Microsoft.AspNetCore.Http.IFormFileCollection)"> <member name="M:WY.NewJit.EdiReceive.Interfaces.IImportRecordAppService.ImportAsync(Microsoft.AspNetCore.Http.IFormFileCollection,System.Boolean)">
<summary> <summary>
导入信息 导入信息
</summary> </summary>
<param name="input">导入文件流</param> <param name="files">导入文件流</param>
<param name="forceExecute">是否强制执行</param>
<returns>执行成功返回真</returns> <returns>执行成功返回真</returns>
</member> </member>
<member name="T:WY.NewJit.Extends.MenBanPackingListDto"> <member name="T:WY.NewJit.Extends.MenBanPackingListDto">

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

@ -20,6 +20,7 @@ using WY.NewJit.Common;
using WY.NewJit.EdiReceive.Dtos; using WY.NewJit.EdiReceive.Dtos;
using WY.NewJit.EdiReceive.Entitys; using WY.NewJit.EdiReceive.Entitys;
using WY.NewJit.EdiReceive.Interfaces; using WY.NewJit.EdiReceive.Interfaces;
using WY.NewJit.EdiReceive.Services;
using WY.NewJit.EntityFrameworkCore; using WY.NewJit.EntityFrameworkCore;
using WY.NewJit.MsgBaseData; using WY.NewJit.MsgBaseData;
using WY.NewJit.MsgCheck; using WY.NewJit.MsgCheck;
@ -58,6 +59,9 @@ namespace WY.NewJit.EdiReceive
/// 字典领域服务 /// 字典领域服务
/// </summary> /// </summary>
private readonly DicDomainService _dicDomainService; private readonly DicDomainService _dicDomainService;
private readonly EdiParseDomainService _ediParseDomainService;
/// <summary> /// <summary>
/// 配置 /// 配置
/// </summary> /// </summary>
@ -86,14 +90,15 @@ namespace WY.NewJit.EdiReceive
NewJitDapperRepository newJitDapperRepository, NewJitDapperRepository newJitDapperRepository,
IBlobContainer<OurFileContainer> blobContainer, IBlobContainer<OurFileContainer> blobContainer,
DicDomainService dicDomainService, DicDomainService dicDomainService,
Microsoft.Extensions.Configuration.IConfiguration configuration EdiParseDomainService ediParseDomainService,
) Microsoft.Extensions.Configuration.IConfiguration configuration)
{ {
_importRecordRepository = importRecordRepository; _importRecordRepository = importRecordRepository;
_logger = logger; _logger = logger;
_newJitDapperRepository = newJitDapperRepository; _newJitDapperRepository = newJitDapperRepository;
_blobContainer = blobContainer; _blobContainer = blobContainer;
_dicDomainService = dicDomainService; _dicDomainService = dicDomainService;
_ediParseDomainService = ediParseDomainService;
_configuration = configuration; _configuration = configuration;
} }
@ -264,8 +269,6 @@ namespace WY.NewJit.EdiReceive
} }
} }
/// <summary> /// <summary>
/// 按主键获取唯一实体 /// 按主键获取唯一实体
/// </summary> /// </summary>
@ -418,11 +421,13 @@ namespace WY.NewJit.EdiReceive
/// 导入 /// 导入
/// </summary> /// </summary>
/// <param name="files">导入文件</param> /// <param name="files">导入文件</param>
/// <param name="forceExecute">校验出错时,是否强制执行</param>
/// <returns>执行成功返回真</returns> /// <returns>执行成功返回真</returns>
[UnitOfWork]
[HttpPost] [HttpPost]
[Route("import")] [Route("import")]
[DisableRequestSizeLimit] [DisableRequestSizeLimit]
public virtual async Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files) public virtual async Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files, bool forceExecute = false)
{ {
_logger.LogDebug(_errorMessagePrefix + "ImportAsync 进入"); _logger.LogDebug(_errorMessagePrefix + "ImportAsync 进入");
@ -439,34 +444,44 @@ namespace WY.NewJit.EdiReceive
//StreamReader sr = new StreamReader(memoryStream, Encoding.Default); //StreamReader sr = new StreamReader(memoryStream, Encoding.Default);
IImporter importer = new ExcelImporter(); IImporter importer = new ExcelImporter();
impResult = await importer.Import<ImportRecordDto>(memoryStream); impResult = await importer.Import<ImportRecordDto>(memoryStream);
if (impResult.HasError) }
if (impResult.HasError)
{
string rowErrStr = "";
foreach (var rowErr in impResult.RowErrors)
{
string fieldErr = string.Concat(rowErr.FieldErrors.Select(itm => $"字段:{itm.Key},错误信息:{itm.Value}"));
rowErrStr += $"行号:{rowErr.RowIndex},{fieldErr}\r\n";
}
string templateErrStr = "";
foreach (var templateErr in impResult.TemplateErrors)
{ {
string rowErrStr = ""; string errorLevel = templateErr.ErrorLevel == ErrorLevels.Error ? "错误" : "警告";
foreach (var rowErr in impResult.RowErrors) templateErrStr += $"错误等级:{errorLevel},列名:{templateErr.ColumnName},需要列:{templateErr.RequireColumnName},错误消息:{templateErr.Message}\r\n";
{
string fieldErr = string.Concat(rowErr.FieldErrors.Select(itm => $"字段:{itm.Key},错误信息:{itm.Value}"));
rowErrStr += $"行号:{rowErr.RowIndex},{fieldErr}\r\n";
}
string templateErrStr = "";
foreach (var templateErr in impResult.TemplateErrors)
{
string errorLevel = templateErr.ErrorLevel == ErrorLevels.Error ? "错误" : "警告";
templateErrStr += $"错误等级:{errorLevel},列名:{templateErr.ColumnName},需要列:{templateErr.RequireColumnName},错误消息:{templateErr.Message}\r\n";
}
ret.Message = rowErrStr + templateErrStr;
ret.Status = false;
return ret;
} }
ret.Message = rowErrStr + templateErrStr;
ret.Status = false;
return ret;
} }
var srcLst = impResult.Data.AsEnumerable().ToList(); var srcLst = impResult.Data.AsEnumerable().ToList();
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)
{ {
tar.CreatePerson = "导入"; //tar.CreatePerson = "导入";
tar.CreateTime = ServerHelper.CurrentDateTime; tar.CreateTime = ServerHelper.CurrentDateTime;
} }
//插入“导入记录表” //报文解析
await _importRecordRepository.InsertManyAsync(tarLst); ObjectResultDto ret2 = await _ediParseDomainService.ParseEdi(tarLst, forceExecute);
if (ret2.Status == false)
{
return ret2;
}
if (ret2.Status == true && ret2.Message.HasValue())
{
return ret2;
}
ret.Status = true; ret.Status = true;
return ret; return ret;
} }
@ -478,8 +493,6 @@ namespace WY.NewJit.EdiReceive
return ret; return ret;
} }
} }
#endregion
/// <summary> /// <summary>
/// 打印时间提醒 /// 打印时间提醒
@ -493,7 +506,7 @@ namespace WY.NewJit.EdiReceive
{ {
TimeOutRemindResultDto retObj = new TimeOutRemindResultDto(); TimeOutRemindResultDto retObj = new TimeOutRemindResultDto();
retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40; retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40;
var qry =await _importRecordRepository.MaxAsync(itm => itm.CreateTime); var qry = await _importRecordRepository.MaxAsync(itm => itm.CreateTime);
retObj.LastReceiveTime = qry != null ? Convert.ToDateTime(qry) : ServerHelper.CurrentDateTime; retObj.LastReceiveTime = qry != null ? Convert.ToDateTime(qry) : ServerHelper.CurrentDateTime;
retObj.TimeoutMinutes = MinuteDiff(retObj.LastReceiveTime, ServerHelper.CurrentDateTime); retObj.TimeoutMinutes = MinuteDiff(retObj.LastReceiveTime, ServerHelper.CurrentDateTime);
return retObj; return retObj;
@ -506,6 +519,6 @@ namespace WY.NewJit.EdiReceive
TimeSpan diffSpan = endSpan.Subtract(beginSpan).Duration(); TimeSpan diffSpan = endSpan.Subtract(beginSpan).Duration();
return (int)(diffSpan.TotalMinutes); return (int)(diffSpan.TotalMinutes);
} }
#endregion
} }
} }

3
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml

@ -122,11 +122,12 @@
<param name="input">导出查询条件</param> <param name="input">导出查询条件</param>
<returns>执行成功返回真</returns> <returns>执行成功返回真</returns>
</member> </member>
<member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.ImportAsync(Microsoft.AspNetCore.Http.IFormFileCollection)"> <member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.ImportAsync(Microsoft.AspNetCore.Http.IFormFileCollection,System.Boolean)">
<summary> <summary>
导入 导入
</summary> </summary>
<param name="files">导入文件</param> <param name="files">导入文件</param>
<param name="forceExecute">校验出错时,是否强制执行</param>
<returns>执行成功返回真</returns> <returns>执行成功返回真</returns>
</member> </member>
<member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.PrintTimeoutRemind(WY.NewJit.MsgCheck.TimeOutRemindInputDto)"> <member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.PrintTimeoutRemind(WY.NewJit.MsgCheck.TimeOutRemindInputDto)">

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

@ -146,7 +146,7 @@ namespace WY.NewJit
{ {
throw new Exception("ToSerialNumStr大众顺序号不能为空!"); throw new Exception("ToSerialNumStr大众顺序号不能为空!");
} }
return ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + "00" + hostSN.ToString().PadLeft(5, '0'); return ((DateTime)onlineTime).ToString("yyyyMMddHHmmss") + hostSN.ToString().PadLeft(5, '0');
} }
/// <summary> /// <summary>

4
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/EdiReceive/Entitys/LastImportHostSN.cs

@ -13,5 +13,9 @@ namespace WY.NewJit.EdiReceive.Entitys
public int HostSN { get; set; } public int HostSN { get; set; }
public LastImportHostSN(Guid id)
:base(id)
{
}
} }
} }

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

@ -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)
@ -180,47 +183,24 @@ namespace WY.NewJit.EdiReceive.Services
} }
} }
#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 1112
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;
} }

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

@ -50,12 +50,6 @@ namespace WY.NewJit.EdiReceive.Services
#endregion #endregion
#region 缓存 #region 缓存
public static List<ErpAssemblyMain> _erpAssemblyMainList = new List<ErpAssemblyMain>();
/// <summary>
/// 分组VS总成关系
/// </summary>
//public static List<Group2Assembly> _group2assemblyList = new List<Group2Assembly>();
/// <summary> /// <summary>
/// 分组对应多个总成 清单- /// 分组对应多个总成 清单-
@ -192,22 +186,18 @@ namespace WY.NewJit.EdiReceive.Services
/// </summary> /// </summary>
public void DoInitLoadCache() public void DoInitLoadCache()
{ {
//取ERP总成主表
string erpMainSql = "select Id, VehicleModel from FisAssemblyCfgErp where NewVersionId is null order by ErpAssemblyVersion, CreationTime desc";
_erpAssemblyMainList = _newJitDapperRepository.GetListBySql<ErpAssemblyMain>(erpMainSql, true);
//取ERP总成的零件 //取ERP总成的零件
string group2assemblySql = @" string group2assemblySql = @"
select g.Id as GroupId, g.GroupCode, g.VehicleModel, e.Id as ErpAssemblyId, e.ErpAssemblyCode, select g.Id as GroupId, g.GroupCode, g.VehicleModel, e.Id as ErpAssemblyId, e.ErpAssemblyCode, e.ErpAssemblyName,
g.SpecExplain, g.ColorExplain g.SpecExplain, g.ColorExplain
from FisAssemblyCfgGroup g from FisAssemblyCfgGroup g
join FisAssemblyCfgErp e on g.Id = e.GroupId join FisAssemblyCfgErp e on g.Id = e.GroupId
where IsDeleted = 0 and g.IsDisable = 0 where g.IsDisable = 0 and g.IsDeleted = 0
order by g.CreationTime desc order by g.CreationTime desc
"; ";
var group2assemblyList = _newJitDapperRepository.GetListBySql<Group2Assembly>(group2assemblySql, true); var group2assemblyList = _newJitDapperRepository.GetListBySql<Group2Assembly>(group2assemblySql, true);
//转换成分组、总成 两层结构 //转换成分组、总成 两层结构
List<Group_Assembly> _groupAssemblyList = group2assemblyList.GroupBy(itm => itm.GroupId).Select(itm => new Group_Assembly _groupAssemblyList = group2assemblyList.GroupBy(itm => itm.GroupId).Select(itm => new Group_Assembly
{ {
Id = itm.Key, Id = itm.Key,
GroupCode = itm.ElementAt(0).GroupCode, GroupCode = itm.ElementAt(0).GroupCode,

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

@ -55,7 +55,12 @@ namespace WY.NewJit.EdiReceive.Services
_lastImportHostSNRepository = lastImportHostSNRepository; _lastImportHostSNRepository = lastImportHostSNRepository;
} }
public async Task<int> GetLastImportHostSN() /// <summary>
/// 假设:产线之间的流水号都是唯一的
/// </summary>
/// <param name="productLine"></param>
/// <returns></returns>
public async Task<int> GetLastImportMaxHostSN()
{ {
var lst = await _lastImportHostSNRepository.GetListAsync(); var lst = await _lastImportHostSNRepository.GetListAsync();
if (lst.Count > 0) if (lst.Count > 0)
@ -64,8 +69,32 @@ namespace WY.NewJit.EdiReceive.Services
} }
else else
{ {
int maxSN = await _lastImportHostSNRepository.MaxAsync(itm => itm.HostSN); bool hasData = await _importRecordRepository.AnyAsync();
return maxSN; if (hasData)
{
int maxSN = await _importRecordRepository.MaxAsync(itm => itm.HostSN);
return maxSN;
}
else
{
return 0;
}
}
}
public async Task SetCurrentImportMaxHostSN(int maxHostSN)
{
var obj = await _lastImportHostSNRepository.FirstOrDefaultAsync();
if (obj != null)
{
obj.HostSN = maxHostSN;
await _lastImportHostSNRepository.UpdateAsync(obj, true);
}
else
{
LastImportHostSN newObj = new LastImportHostSN(GuidGenerator.Create());
newObj.HostSN = maxHostSN;
var insRet = await _lastImportHostSNRepository.InsertAsync(obj);
} }
} }

Loading…
Cancel
Save