Browse Source

报文导入-初步测试通过

HQ
liuyunfeng 10 months ago
parent
commit
558da06c8c
  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. 65
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/EdiReceive/ImportRecordAppService.cs
  4. 5
      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. 237
      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. 33
      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 Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using WY.NewJit.EdiReceive.Dtos;
using WY.NewJit.MsgCheck;
namespace WY.NewJit.EdiReceive.Interfaces
{
@ -62,11 +60,10 @@ namespace WY.NewJit.EdiReceive.Interfaces
/// <summary>
/// 导入信息
/// </summary>
/// <param name="input">导入文件流</param>
/// <param name="files">导入文件流</param>
/// <param name="forceExecute">是否强制执行</param>
/// <returns>执行成功返回真</returns>
Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files);
[HttpPost, Route("print-timeout-remind"), UnitOfWork]
Task<TimeOutRemindResultDto> PrintTimeoutRemind(TimeOutRemindInputDto input);
Task<ObjectResultDto> ImportAsync([FromForm] IFormFileCollection files, bool forceExecute = false);
#endregion
}

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

@ -556,11 +556,12 @@
<param name="input">导出查询条件</param>
<returns>执行成功返回真</returns>
</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>
<param name="input">导入文件流</param>
<param name="files">导入文件流</param>
<param name="forceExecute">是否强制执行</param>
<returns>执行成功返回真</returns>
</member>
<member name="T:WY.NewJit.Extends.MenBanPackingListDto">

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

@ -20,9 +20,9 @@ using WY.NewJit.Common;
using WY.NewJit.EdiReceive.Dtos;
using WY.NewJit.EdiReceive.Entitys;
using WY.NewJit.EdiReceive.Interfaces;
using WY.NewJit.EdiReceive.Services;
using WY.NewJit.EntityFrameworkCore;
using WY.NewJit.MsgBaseData;
using WY.NewJit.MsgCheck;
namespace WY.NewJit.EdiReceive
{
@ -58,10 +58,8 @@ namespace WY.NewJit.EdiReceive
/// 字典领域服务
/// </summary>
private readonly DicDomainService _dicDomainService;
/// <summary>
/// 配置
/// </summary>
private readonly Microsoft.Extensions.Configuration.IConfiguration _configuration;
private readonly EdiParseDomainService _ediParseDomainService;
/// <summary>
/// 错误信息前缀
@ -86,15 +84,14 @@ namespace WY.NewJit.EdiReceive
NewJitDapperRepository newJitDapperRepository,
IBlobContainer<OurFileContainer> blobContainer,
DicDomainService dicDomainService,
Microsoft.Extensions.Configuration.IConfiguration configuration
)
EdiParseDomainService ediParseDomainService)
{
_importRecordRepository = importRecordRepository;
_logger = logger;
_newJitDapperRepository = newJitDapperRepository;
_blobContainer = blobContainer;
_dicDomainService = dicDomainService;
_configuration = configuration;
_ediParseDomainService = ediParseDomainService;
}
#region 私有方法
@ -264,8 +261,6 @@ namespace WY.NewJit.EdiReceive
}
}
/// <summary>
/// 按主键获取唯一实体
/// </summary>
@ -418,11 +413,13 @@ namespace WY.NewJit.EdiReceive
/// 导入
/// </summary>
/// <param name="files">导入文件</param>
/// <param name="forceExecute">校验出错时,是否强制执行</param>
/// <returns>执行成功返回真</returns>
[UnitOfWork]
[HttpPost]
[Route("import")]
[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 进入");
@ -439,6 +436,8 @@ namespace WY.NewJit.EdiReceive
//StreamReader sr = new StreamReader(memoryStream, Encoding.Default);
IImporter importer = new ExcelImporter();
impResult = await importer.Import<ImportRecordDto>(memoryStream);
}
if (impResult.HasError)
{
string rowErrStr = "";
@ -457,16 +456,24 @@ namespace WY.NewJit.EdiReceive
ret.Status = false;
return ret;
}
}
var srcLst = impResult.Data.AsEnumerable().ToList();
var tarLst = ObjectMapper.Map<List<ImportRecordDto>, List<ImportRecord>>(srcLst);
foreach (var tar in tarLst)
{
tar.CreatePerson = "导入";
//tar.CreatePerson = "导入";
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;
return ret;
}
@ -479,33 +486,5 @@ namespace WY.NewJit.EdiReceive
}
}
#endregion
/// <summary>
/// 打印时间提醒
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[UnitOfWork]
[HttpPost]
[Route("print-timeout-remind")]
public virtual async Task<TimeOutRemindResultDto> PrintTimeoutRemind(TimeOutRemindInputDto input)
{
TimeOutRemindResultDto retObj = new TimeOutRemindResultDto();
retObj.ConfigMinutes = _configuration[$"ConfigDic:ProductLineTimeoutRemind_New:{"Record"}"].TryToInt() ?? 40;
var qry =await _importRecordRepository.MaxAsync(itm => itm.CreateTime);
retObj.LastReceiveTime = qry != null ? Convert.ToDateTime(qry) : ServerHelper.CurrentDateTime;
retObj.TimeoutMinutes = MinuteDiff(retObj.LastReceiveTime, ServerHelper.CurrentDateTime);
return retObj;
}
private int MinuteDiff(DateTime beginTime, DateTime endTime)
{
TimeSpan beginSpan = new TimeSpan(beginTime.Ticks);
TimeSpan endSpan = new TimeSpan(endTime.Ticks);
TimeSpan diffSpan = endSpan.Subtract(beginSpan).Duration();
return (int)(diffSpan.TotalMinutes);
}
}
}

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

@ -44,7 +44,7 @@
错误信息前缀
</summary>
</member>
<member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.#ctor(Volo.Abp.Domain.Repositories.IRepository{WY.NewJit.EdiReceive.Entitys.ImportRecord,System.Guid},Microsoft.Extensions.Logging.ILogger{WY.NewJit.EdiReceive.ImportRecordAppService},WY.NewJit.EntityFrameworkCore.NewJitDapperRepository,Volo.Abp.BlobStoring.IBlobContainer{WY.NewJit.Common.OurFileContainer},WY.NewJit.MsgBaseData.DicDomainService)">
<member name="M:WY.NewJit.EdiReceive.ImportRecordAppService.#ctor(Volo.Abp.Domain.Repositories.IRepository{WY.NewJit.EdiReceive.Entitys.ImportRecord,System.Guid},Microsoft.Extensions.Logging.ILogger{WY.NewJit.EdiReceive.ImportRecordAppService},WY.NewJit.EntityFrameworkCore.NewJitDapperRepository,Volo.Abp.BlobStoring.IBlobContainer{WY.NewJit.Common.OurFileContainer},WY.NewJit.MsgBaseData.DicDomainService,WY.NewJit.EdiReceive.Services.EdiParseDomainService)">
<summary>
构造函数
</summary>
@ -117,11 +117,12 @@
<param name="input">导出查询条件</param>
<returns>执行成功返回真</returns>
</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>
<param name="files">导入文件</param>
<param name="forceExecute">校验出错时,是否强制执行</param>
<returns>执行成功返回真</returns>
</member>
<member name="T:WY.NewJit.Extends.ProductLineAuthorityAppService">

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

@ -146,7 +146,7 @@ namespace WY.NewJit
{
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>

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 LastImportHostSN(Guid id)
:base(id)
{
}
}
}

237
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;
/// <summary>
/// 零件仓储
/// 导入记录仓储
/// </summary>
private readonly IRepository<ImportRecord, Guid> _importRecordRepository;
@ -51,32 +51,40 @@ namespace WY.NewJit.EdiReceive.Services
/// <summary>
/// ERP总成分组仓库
/// </summary>
private readonly IRepository<AssemblyCfgGroup, Guid> _assemblyCfgGroupRepository;
//private readonly IRepository<AssemblyCfgGroup, Guid> _assemblyCfgGroupRepository;
/// <summary>
/// ERP总成仓储
/// </summary>
private readonly IRepository<AssemblyCfgErp, Guid> _assemblyCfgErpRepository;
//private readonly IRepository<AssemblyCfgErp, Guid> _assemblyCfgErpRepository;
/// <summary>
/// 整车总成配置仓库
/// </summary>
private readonly IRepository<AssemblyCfgVehicle, Guid> _assemblyCfgVehicleRepository;
/// <summary>
/// 导入最大流水号 领域服务
/// </summary>
private readonly LastImportHostSNDomainService _lastImportHostSNDomainService;
/// <summary>
/// 缓存管理 领域服务
/// </summary>
private readonly HQ_CacheManagerDomainService _hqCacheManagerDomainService;
/// <summary>
/// 插入M100、未打印表 领域服务
/// </summary>
private readonly HQ_M100DomainService _hqM100DomainServie;
/// <summary>
/// 重复M100
/// 重复报文仓库
/// </summary>
private readonly IRepository<RepeatM100, Guid> _repeatM100Repository;
/// <summary>
/// 未知总成维护
/// 未知总成仓库
/// </summary>
private readonly IRepository<UnknownAssembly, Guid> _unknownAssemblyRepository;
@ -84,12 +92,12 @@ namespace WY.NewJit.EdiReceive.Services
/// <summary>
/// 报文车型对应零件生产工厂车型
/// </summary>
private static List<DicItem> _msgToPaiGeVehicleModelList = new List<DicItem>();
//private static List<DicItem> _msgToPaiGeVehicleModelList = new List<DicItem>();
/// <summary>
/// M100零件生产工厂车型对应生产线
/// </summary>
private static List<DicItem> _m100VehicleModelProductLineList = new List<DicItem>();
//private static List<DicItem> _m100VehicleModelProductLineList = new List<DicItem>();
/// <summary>
/// 根据车型代码中的前两位(HS),过滤属于派格的订单;只针对派格的订单进行报文解析
@ -118,12 +126,11 @@ namespace WY.NewJit.EdiReceive.Services
_billM100Repository = billM100Repository;
_lastImportHostSNDomainService = lastImportHostSNDomainService;
_msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.);
_m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100派格车型对应生产线);
_assemblyCfgGroupRepository = assemblyCfgGroupRepository;
_assemblyCfgErpRepository = assemblyCfgErpRepository;
//_msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.报文车型对应派格车型);
//_m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100派格车型对应生产线);
//_assemblyCfgGroupRepository = assemblyCfgGroupRepository;
//_assemblyCfgErpRepository = assemblyCfgErpRepository;
_assemblyCfgVehicleRepository = assemblyCfgVehicleRepository;
_hqCacheManagerDomainService = hqCacheManagerDomainService;
_hqM100DomainServie = hqM100DomainServie;
_repeatM100Repository = repeatM100Repository;
@ -132,43 +139,39 @@ namespace WY.NewJit.EdiReceive.Services
/// <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>
/// <param name="impRecLst"></param>
/// <param name="impRecLst">导入Excel内容</param>
/// <param name="forceExecute">校验不通过时,是否强制执行通过</param>
public async Task<ObjectResultDto> ParseEdi(List<ImportRecord> input, bool forceExecute = false)
{
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);
#region 断号提醒
string breakNumMsg = "";
notRepeatOrder = notRepeatOrder.OrderBy(itm => itm.HostSN).ToList();
for (int curIdx = 1; curIdx < notRepeatOrder.Count; curIdx++)
if (notRepeatOrder.Count == 0)
{
int curVal = notRepeatOrder[curIdx].HostSN;
int priorIdx = curIdx - 1;
int priorVal = notRepeatOrder[priorIdx].HostSN;
if (curVal - priorVal != 1)
{
breakNumMsg += $"流水号{priorVal}和{curVal}之间存在断号\r\n";
}
ret.Status = true;
ret.Message = "根据Vin和HostSN,排除在数据库中重复的Excel订单后,已经没有不重复的订单!";
return ret;
}
#region 断号提醒
//校验两次导入之间是否断号
string betweenBreakNumMsg = await CheckBetweenBreakNum(input);
//校验本次导入数据是否断号
string breakNumMsg = CheckBreakNum(ref notRepeatOrder);
if (betweenBreakNumMsg.HasValue() || breakNumMsg.HasValue())
{
if (forceExecute == false)
@ -180,47 +183,24 @@ namespace WY.NewJit.EdiReceive.Services
}
}
#endregion
//批量插入 导入记录
await _importRecordRepository.InsertManyAsync(notRepeatOrder);
//初始化缓存
_hqCacheManagerDomainService.InitLoadCache();
//过滤掉其它订单,只取派格订单
//批量插入 导入记录
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)
{
#region 构建M100实体
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.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
//构建M100实体
BillM100 m100Obj = BuildM100Entity(orderItem);
//更新车型、产线
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)
{
#region 重复报文
@ -233,13 +213,12 @@ namespace WY.NewJit.EdiReceive.Services
//绑定总成分组
string colorExplain = orderItem.VehicleModelDesc.Trim().Right(7);
Group_Assembly groupAssemblyObj = HQ_CacheManagerDomainService._groupAssemblyList.FirstOrDefault(itm => itm.SpecExplain == orderItem.SpecDesc && itm.ColorExplain == colorExplain);
if (groupAssemblyObj != null)
{
#region 插入整车总成
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) //插入子表
{
vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), assemblyItem.Id);
@ -253,6 +232,7 @@ namespace WY.NewJit.EdiReceive.Services
//插入M100、未打印表
m100Obj.SetAssemblyID(vehicleAssemblyResu.Id);
m100Obj.SetBillStatus(BillStatusEnum.Match);
var insM100Ret = await _hqM100DomainServie.InsertM100(m100Obj, true);
}
else
@ -270,27 +250,91 @@ namespace WY.NewJit.EdiReceive.Services
ret.Status = (succObj1 != null && succObj2 != null);
}
} //foreach
//更新本次导入的最大HostSN
int curMaxHostSN = input.Max(itm => itm.HostSN);
await _lastImportHostSNDomainService.SetCurrentImportMaxHostSN(curMaxHostSN);
ret.Status = true;
return ret;
}
/*
1. EXCEL格式的订单列表
2. HostSN必须<= HostSN + 1 10 9 10 1112
3. VIN和HostSN
4. Excel时
5. impRecLst
/// <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";
}
}
M100
1. HS
2. VIN判断是否重复报文
3. 4
4. M100 ( 线)
5. WaitPrint
*/
ret.Status = true;
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>
/// 根据流水号、VIN 扣除重复导入的订单
/// </summary>
@ -299,11 +343,8 @@ namespace WY.NewJit.EdiReceive.Services
private async Task<List<ImportRecord>> GetNotRepeatOrder(List<ImportRecord> input)
{
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)
{
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; //报文车型
//车型转换:3H 转 CC
var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel);
var obj1 = HQ_CacheManagerDomainService._msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel);
if (obj1 != null)
{
string paigeVehicleModel = obj1.DicItemName; // CC
@ -336,7 +377,7 @@ namespace WY.NewJit.EdiReceive.Services
}
bill.SetVehicleModelCode(paigeVehicleModel);
//根据车型取对应生产线
var obj2 = _m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel);
var obj2 = HQ_CacheManagerDomainService._m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel);
if (obj2 != null)
{
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;
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);
}
//插入重复单据
ret = _repeatM100Repository.InsertAsync(repeatBill, true).GetAwaiter().GetResult();
ret = await _repeatM100Repository.InsertAsync(repeatBill, true);
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
#region 缓存
public static List<ErpAssemblyMain> _erpAssemblyMainList = new List<ErpAssemblyMain>();
/// <summary>
/// 分组VS总成关系
/// </summary>
//public static List<Group2Assembly> _group2assemblyList = new List<Group2Assembly>();
/// <summary>
/// 分组对应多个总成 清单-
@ -192,22 +186,18 @@ namespace WY.NewJit.EdiReceive.Services
/// </summary>
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总成的零件
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
from FisAssemblyCfgGroup g
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
";
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,
GroupCode = itm.ElementAt(0).GroupCode,

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

@ -55,7 +55,12 @@ namespace WY.NewJit.EdiReceive.Services
_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();
if (lst.Count > 0)
@ -64,9 +69,33 @@ namespace WY.NewJit.EdiReceive.Services
}
else
{
int maxSN = await _lastImportHostSNRepository.MaxAsync(itm => itm.HostSN);
bool hasData = await _importRecordRepository.AnyAsync();
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