diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/UnknownAssemblys/Interfaces/IUnknownAssemblyAppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/UnknownAssemblys/Interfaces/IUnknownAssemblyAppService.cs index d7bf628..4bd4bcf 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/UnknownAssemblys/Interfaces/IUnknownAssemblyAppService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgCheck/UnknownAssemblys/Interfaces/IUnknownAssemblyAppService.cs @@ -64,7 +64,7 @@ namespace WY.NewJit.MsgCheck.UnknownAssemblys /// /// /// - ObjectResultDto BatchParseAsync(BatchParseParam input); + //ObjectResultDto BatchParseAsync(BatchParseParam input); /// /// 根据vin从天合mes系统中取erp总成编码列表 diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml index 1a00604..096cb7e 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml @@ -3400,13 +3400,6 @@ 总成、分总成、零件三级关系实体 执行成功返回真 - - - 系统初始化时使用,批量解析 - - - - 根据vin从天合mes系统中取erp总成编码列表 diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/UnknownAssemblys/UnknownAssemblyAppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/UnknownAssemblys/UnknownAssemblyAppService.cs index f477eaa..f683607 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/UnknownAssemblys/UnknownAssemblyAppService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgCheck/UnknownAssemblys/UnknownAssemblyAppService.cs @@ -23,9 +23,9 @@ using WY.NewJit.MsgCheck.UnknownAssemblys; using WY.NewJit.MsgTransmission; using Volo.Abp.EventBus.Distributed; using WY.NewJit.SettleAccountFis; -using WY.NewJit.MsgTransmission.PaiGe; +//using WY.NewJit.MsgTransmission.PaiGe; -namespace WY.NewJit.MsgCheck +namespace WY.NewJit.MsgCheck { /// /// 未知总成应用服务实现 @@ -53,7 +53,7 @@ namespace WY.NewJit.MsgCheck /// private readonly IRepository _assemblyCfgErpRepository; - private readonly MsgTransmissionAppService _msgTransmissionAppService; + //private readonly MsgTransmissionAppService _msgTransmissionAppService; /// /// R100报文解析及校验领域服务 @@ -127,7 +127,7 @@ namespace WY.NewJit.MsgCheck IRepository billM100Repository, IBlobContainer blobContainer, IRepository assemblyCfgErpRepository, - MsgTransmissionAppService msgTransmissionAppService, + //MsgTransmissionAppService msgTransmissionAppService, R100CheckDomainService r100CheckDomainSrv, M100CheckDomainService m100CheckDomainService, IDistributedEventBus distributedEventBus, @@ -148,7 +148,7 @@ namespace WY.NewJit.MsgCheck _billM100Repository = billM100Repository; _blobContainer = blobContainer; _assemblyCfgErpRepository = assemblyCfgErpRepository; - _msgTransmissionAppService = msgTransmissionAppService; + //_msgTransmissionAppService = msgTransmissionAppService; _r100CheckDomainSrv = r100CheckDomainSrv; _m100CheckDomainService = m100CheckDomainService; _distributedEventBus = distributedEventBus; @@ -953,74 +953,74 @@ select * from /// /// /// - [HttpPost] - //[UnitOfWork(true)] - [Route("batch-parse")] - public virtual ObjectResultDto BatchParseAsync(BatchParseParam input) - { - _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 进入"); - //批量删除未匹配单据 - //string delSql = "delete from FisNotMatchTempBill"; - // _newJitDapperRepository.ExecuteSql(delSql, null, true); - - ObjectResultDto ret = new ObjectResultDto(); - try - { - string sql = @" - with b as - ( - select Id, OnlineTime from FisBillM100 where BillStatus =1 {1} - ) - select top {0} a.Id from FisUnknownAssembly a - join b on a.BillId = b.Id - where a.IsDeleted <> 1 and a.ExtraProperties is null - order by b.OnlineTime desc - "; - int takeCount = input.TakeCount; - string sqlWhere = ""; - if (input.BeginDate != null && input.EndDate != null) - { - sqlWhere = "and OnlineTime between convert(datetime,'{0}', 20) and convert(datetime,'{1}', 20)"; - sqlWhere = string.Format(sqlWhere, ((DateTime)input.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"), ((DateTime)input.EndDate).ToString("yyyy-MM-dd HH:mm:ss")); - } - - sql = string.Format(sql, takeCount, sqlWhere); - List selLst = _newJitDapperRepository.GetListBySql(sql, true); - - int matchNum = 0; - int notMatchNum = 0; - - //_msgTransmissionAppService.ClearPub(); - _msgTransmissionAppService.InitPub(); - foreach (Guid selId in selLst) - { - bool isMatch = OneParseAsync(selId); - if (isMatch) - { - matchNum++; - } - else - { - notMatchNum++; - } - - } //foreach - - ret.Status = true; - ret.Message = $"本次共重新解析{matchNum + notMatchNum}条,其中匹配{matchNum}条、不匹配{notMatchNum}条"; - ret.Item = ret.Message; - _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 完成:" + ret.Message); - - return ret; - } - catch (Exception ex) - { - ret.Status = false; - ret.Message = _errorMessagePrefix + "BatchParseAsync 执行出错:" + ex.Message; - _logger.LogError(ret.Message); - return ret; - } - } + // [HttpPost] + // //[UnitOfWork(true)] + // [Route("batch-parse")] + // public virtual ObjectResultDto BatchParseAsync(BatchParseParam input) + // { + // _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 进入"); + // //批量删除未匹配单据 + // //string delSql = "delete from FisNotMatchTempBill"; + // // _newJitDapperRepository.ExecuteSql(delSql, null, true); + + // ObjectResultDto ret = new ObjectResultDto(); + // try + // { + // string sql = @" + // with b as + // ( + // select Id, OnlineTime from FisBillM100 where BillStatus =1 {1} + // ) + // select top {0} a.Id from FisUnknownAssembly a + //join b on a.BillId = b.Id + //where a.IsDeleted <> 1 and a.ExtraProperties is null + //order by b.OnlineTime desc + // "; + // int takeCount = input.TakeCount; + // string sqlWhere = ""; + // if (input.BeginDate != null && input.EndDate != null) + // { + // sqlWhere = "and OnlineTime between convert(datetime,'{0}', 20) and convert(datetime,'{1}', 20)"; + // sqlWhere = string.Format(sqlWhere, ((DateTime)input.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"), ((DateTime)input.EndDate).ToString("yyyy-MM-dd HH:mm:ss")); + // } + + // sql = string.Format(sql, takeCount, sqlWhere); + // List selLst = _newJitDapperRepository.GetListBySql(sql, true); + + // int matchNum = 0; + // int notMatchNum = 0; + + // //_msgTransmissionAppService.ClearPub(); + // _msgTransmissionAppService.InitPub(); + // foreach (Guid selId in selLst) + // { + // bool isMatch = OneParseAsync(selId); + // if (isMatch) + // { + // matchNum++; + // } + // else + // { + // notMatchNum++; + // } + + // } //foreach + + // ret.Status = true; + // ret.Message = $"本次共重新解析{matchNum + notMatchNum}条,其中匹配{matchNum}条、不匹配{notMatchNum}条"; + // ret.Item = ret.Message; + // _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 完成:" + ret.Message); + + // return ret; + // } + // catch (Exception ex) + // { + // ret.Status = false; + // ret.Message = _errorMessagePrefix + "BatchParseAsync 执行出错:" + ex.Message; + // _logger.LogError(ret.Message); + // return ret; + // } + // } /// /// 根据vin从天合mes系统中取erp总成编码列表 @@ -1169,5 +1169,10 @@ select u.Id, up.PartCode, up.PartNum, up.[Description], } } + public class BillResult + { + public BillR100 R100Bill { get; set; } + public BillM100 M100Bill { get; set; } + } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgTransmission/PaiGe/MsgTransmissionAppService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgTransmission/PaiGe/MsgTransmissionAppService.cs index a087c7f..54d8c35 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgTransmission/PaiGe/MsgTransmissionAppService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgTransmission/PaiGe/MsgTransmissionAppService.cs @@ -1,4 +1,5 @@ -using Magicodes.ExporterAndImporter.Core; +/* +using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Excel; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -955,3 +956,4 @@ namespace WY.NewJit.MsgTransmission.PaiGe } } +*/ diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml index 5fe8c04..0ed41b0 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml @@ -1810,7 +1810,7 @@ 错误信息前缀 - + 构造函数 @@ -1885,13 +1885,6 @@ 总成、分总成、零件三级关系实体 执行成功返回真 - - - 系统初始化时使用,批量解析【天合版本】 - - - - 根据vin从天合mes系统中取erp总成编码列表 @@ -1906,157 +1899,6 @@ 导出查询条件 执行成功返回真 - - - 报文传输应用服务实现 - - - - - 报文传输方式配置表仓储 - - - - - 报文接收表仓储 - - - - - 报文版本配置表 - - - - - 系统内通知 - - - - - R100报文解析及校验领域服务 - - - - - M100报文解析及校验领域服务 - - - - - 日志 - - - - - 配置 - - - - - R100单据 - - - - - M100单据 - - - - - 重复R100 - - - - - 重复M100 - - - - - 排除零件配置 - - - - - 未知总成维护 - - - - - 整车总成配置仓库 - - - - - Dapper仓储 - - - - - 字典领域服务 - - - - - 报文车型对应格拉默车型 - - - - - R100格拉默车型对应生产线 - - - - - M100格拉默车型对应生产线 - - - - - 结算件信息列表 - - - - - 错误信息前缀 - - - - - 大众顺序号,写日志时用 - - - - - 解析Erp总成时的循环数量 - - - - - 每次传输文件数量(工作目录到备份目录) - - - - - 构造函数 - - - - - 传输报文 - 功能描述:1.将报文移动到工作目录,2.保存到报文接收表,3.将报文移动到备份目录,4.如果中途出错将报文从工作目录移动到错误目录 - 提醒:无论什么文件先保存到报文接收表再说,文件过滤交给后续功能(文件转换)处理 - - - - - - 将报文内容转换成BillR100或BillM100 - - - - - 区域相关应用服务 diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs index d9ce666..4e3d891 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain.Shared/Common/ExtMethod.cs @@ -304,6 +304,30 @@ namespace WY.NewJit.Common } return false; } + public static bool HasValue(this string p_str) + { + return string.IsNullOrEmpty(p_str?.Trim()) ? false : true; + } + + public static bool IsNullOrEmpty2(this string p_str) + { + return string.IsNullOrEmpty(p_str?.Trim()) ? true : false; + } + //public static string Left(this string str, int len) + //{ + // string result = str.Substring(0, len); + // return result; + //} + + //public static string Right(this string str, int len) + //{ + // if (str.Length < len) + // { + // return str; + // } + // string result = str.Substring(str.Length - len, len); + // return result; + //} } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgBaseData/Services/DicDomainService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgBaseData/Services/DicDomainService.cs index 3689855..664563f 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgBaseData/Services/DicDomainService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgBaseData/Services/DicDomainService.cs @@ -28,6 +28,10 @@ namespace WY.NewJit.MsgBaseData { ret = _dicItemRepository.Where(itm => itm.DicTypeCode == typeObj.DicTypeCode).ToList(); } + else + { + ret = _dicItemRepository.Where(itm => itm.DicTypeCode == dicTypeName).ToList(); + } return ret; } } @@ -57,6 +61,7 @@ namespace WY.NewJit.MsgBaseData public const string 客户零件类型2 = "客户零件类型2"; + public const string 零件大类 = "零件大类"; } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100.cs index cc7474d..12a1bd2 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100.cs @@ -142,26 +142,7 @@ namespace WY.NewJit.MsgCheck //因为它会被来自数据库的值覆盖.可能不适用于私有构造函数. } - //protected BillM100(Guid id) - // :base(id) - //{ } - //public BillM100(Guid id, Guid? messageFileReceiveID, int? serialNum, int? hostSN, string kNR, string vIN, Guid? assemblyID, DateTime? onlineTime, string vehicleModelCode, string version, DateTime? receiveTime, BillStatusEnum billStatus) - // : base(id) - //{ - // MessageFileReceiveID = messageFileReceiveID; - // SerialNum = serialNum; - // HostSN = hostSN; - // KNR = kNR; - // VIN = vIN; - // AssemblyID = assemblyID; - // OnlineTime = onlineTime; - // VehicleModelCode = vehicleModelCode; - // Version = version; - // ReceiveTime = receiveTime; - // BillStatus = billStatus; - // BillM100Parts = new List(); - //} public BillM100(Guid id, Guid? messageFileReceiveID, int? serialNum, string serialNumStr, int? hostSN, string kNR, string vIN, Guid? assemblyID, DateTime? onlineTime, string vehicleModelCode, string version, DateTime? receiveTime, BillStatusEnum billStatus, ManualOperationTypeEnum operationType = ManualOperationTypeEnum.None, string @operator = null, DateTime? operationTime = null) :base(id) @@ -258,6 +239,30 @@ namespace WY.NewJit.MsgCheck // this.SerialNumStr = ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + hostSN.ToString().PadLeft(5, '0'); //} + + public static BillM100 Clone(BillM100 soureObj) + { + BillM100 targetObj = new BillM100(); + targetObj.MessageFileReceiveID = soureObj.MessageFileReceiveID; + targetObj.SerialNum = soureObj.SerialNum; + targetObj.SerialNumStr = soureObj.SerialNumStr; + targetObj.HostSN = soureObj.HostSN; + targetObj.KNR = soureObj.KNR; + targetObj.VIN = soureObj.VIN; + targetObj.AssemblyID = soureObj.AssemblyID; + targetObj.OnlineTime = soureObj.OnlineTime; + targetObj.VehicleModelCode = soureObj.VehicleModelCode; + targetObj.Version = soureObj.Version; + targetObj.ReceiveTime = soureObj.ReceiveTime; + targetObj.BillStatus = soureObj.BillStatus; + targetObj.BillM100Parts = new List(); + targetObj.OperationType = soureObj.OperationType; + targetObj.Operator = soureObj.Operator; + targetObj.OperationTime = soureObj.OperationTime; + targetObj.CreationTime = soureObj.CreationTime; + return targetObj; + } + } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100Part.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100Part.cs index 21f8524..0cdb3cf 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100Part.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillM100Part.cs @@ -30,17 +30,17 @@ namespace WY.NewJit.MsgCheck public virtual string Description { get; set; } /// - /// 零件类型 0 空 1 控制件 2 柱护板 + /// 零件类型:产线 /// public virtual string PartType { get; set; } /// - /// 零件子类型(取通用字典)B柱下,A上C上等 + /// 零件类型:分组 /// public virtual string PartType2 { get; set; } /// - /// 零件类型3 + /// 零件类型:零件大类 /// public virtual string PartType3 { get; set; } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100.cs index 75ac5c9..31bcbf8 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100.cs @@ -163,7 +163,24 @@ namespace WY.NewJit.MsgCheck // } // this.SerialNumStr = ((DateTime)onlineTime).ToString("yyyyMMddHHmm") + hostSN.ToString().PadLeft(5, '0'); //} - + public static BillR100 Clone(BillR100 soureObj) + { + BillR100 targetObj = new BillR100(); + targetObj.MessageFileReceiveID = soureObj.MessageFileReceiveID; + targetObj.SerialNum = soureObj.SerialNum; + targetObj.SerialNumStr = soureObj.SerialNumStr; + targetObj.HostSN = soureObj.HostSN; + targetObj.KNR = soureObj.KNR; + targetObj.AssemblyID = soureObj.AssemblyID; + targetObj.OnlineTime = soureObj.OnlineTime; + targetObj.VehicleModelCode = soureObj.VehicleModelCode; + targetObj.Version = soureObj.Version; + targetObj.ReceiveTime = soureObj.ReceiveTime; + targetObj.BillStatus = soureObj.BillStatus; + targetObj.BillR100Parts = new List(); + targetObj.CreationTime = soureObj.CreationTime; + return targetObj; + } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100Part.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100Part.cs index 422efbf..288fef6 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100Part.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Entitys/BillR100Part.cs @@ -29,17 +29,17 @@ namespace WY.NewJit.MsgCheck public virtual string Description { get; set; } /// - /// 零件类型 0 空 1 控制件 2 柱护板 + /// 零件类型:产线 /// public virtual string PartType { get; set; } /// - /// 零件子类型(取通用字典)B柱下,A上C上等 + /// 零件类型2:分组 /// public virtual string PartType2 { get; set; } /// - /// 零件类型3 + /// 零件类型3:零件大类 /// public virtual string PartType3 { get; set; } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs index df2b246..04280cb 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/M100CheckDomainService.cs @@ -1,25 +1,26 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; +using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Linq.Dynamic.Core; using System.Text; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; +using Volo.Abp.ObjectMapping; using Volo.Abp.Uow; -using Microsoft.AspNetCore.Mvc; +using WY.NewJit.Common; +using WY.NewJit.IRepositories; using WY.NewJit.MsgBaseData; -using Newtonsoft.Json.Linq; -using System.Threading; -using System.IO; -using WY.NewJit.MsgTransmission; -using Volo.Abp.Domain.Services; using WY.NewJit.MsgCheck; -using WY.NewJit.Common; using WY.NewJit.MsgConversion; -using Volo.Abp.ObjectMapping; -using WY.NewJit.IRepositories; +using WY.NewJit.MsgTransmission; namespace WY.NewJit.MsgCheck @@ -27,7 +28,7 @@ namespace WY.NewJit.MsgCheck /// /// 报文校验领域服务实现 /// - public class M100CheckDomainService : DomainService + public class M100CheckDomainService : DomainService { /// @@ -209,159 +210,166 @@ namespace WY.NewJit.MsgCheck /// /// /// - public ObjectResultDto DoCheckM100Bill(string fileName, BillM100 m100Bill) - { - ObjectResultDto ret = new ObjectResultDto(false, null); - MessageReceive msgReceiveObj = new MessageReceive(Guid.Empty, fileName, null, ReceiveStatusEnum.Received, ServerHelper.CurrentDateTime); - _hostSN = m100Bill.HostSN; - _billNumber = m100Bill.VIN; - _fileName = fileName; - try - { - bool isRepeat = _billM100Repository.Any(itm => itm.HostSN == m100Bill.HostSN && itm.VIN == m100Bill.VIN); - if (isRepeat == true) - { - #region 重复报文 - var succObj = InsertM100RepeatBill(msgReceiveObj, m100Bill); - string errorMsg = "报文重复,请到重复报文模块查看:" + msgReceiveObj.MessageFileName; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj != null); - return ret; - #endregion - } - else - { - #region 更新不可打印标志 - //List canNotPrintLst = _billM100Repository.Where(itm => - // itm.ProductLine == m100Bill.ProductLine - // && itm.HostSN == m100Bill.HostSN - // && (itm.CanNotPrint == null || itm.CanNotPrint == false)).ToList(); - //foreach (BillM100 canNotPrintObj in canNotPrintLst) - //{ - // canNotPrintObj.CanNotPrint = true; - // _billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); - //} - #endregion - - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) - { - } - else - { - #region 根据"排除模块配置"过滤掉不需要的结算件 - List excludeLst = new List(); - string vehicleModelCode = m100Bill.VehicleModelCode; - foreach (BillM100Part partItem in m100Bill.BillM100Parts) //遍历单据零件 - { - bool existExclude = _excludePartCfgRepository.Any(itm => itm.VehicleModelCode == vehicleModelCode && itm.PartCode == partItem.PartCode); - if (existExclude) - { - excludeLst.Add(partItem.Id); - } - } - int delCnt = m100Bill.BillM100Parts.RemoveAll(itm2 => excludeLst.Contains(itm2.Id)); - if (delCnt > 0) - { - _logger.LogDebug(_errorMessagePrefix + $"排除掉{delCnt}个零件。VIN :{m100Bill.VIN},大众顺序号:{m100Bill.HostSN}"); - } - #endregion - } + //public ObjectResultDto DoCheckM100Bill(string fileName, BillM100 m100Bill) + //{ + // ObjectResultDto ret = new ObjectResultDto(false, null); + // MessageReceive msgReceiveObj = new MessageReceive(Guid.Empty, fileName, null, ReceiveStatusEnum.Received, ServerHelper.CurrentDateTime); + // _hostSN = m100Bill.HostSN; + // _billNumber = m100Bill.VIN; + // _fileName = fileName; + // try + // { + // bool isRepeat = _billM100Repository.Any(itm => itm.HostSN == m100Bill.HostSN && itm.VIN == m100Bill.VIN); + // if (isRepeat == true) + // { + // #region 重复报文 + // var succObj = InsertM100RepeatBill(msgReceiveObj, m100Bill); + // string errorMsg = "报文重复,请到重复报文模块查看:" + msgReceiveObj.MessageFileName; + // _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); + // _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{_hostSN}-{_billNumber}-{_fileName}"); + // ret.Status = (succObj != null); + // return ret; + // #endregion + // } + // else + // { + // #region 更新不可打印标志 + // //List canNotPrintLst = _billM100Repository.Where(itm => + // // itm.ProductLine == m100Bill.ProductLine + // // && itm.HostSN == m100Bill.HostSN + // // && (itm.CanNotPrint == null || itm.CanNotPrint == false)).ToList(); + // //foreach (BillM100 canNotPrintObj in canNotPrintLst) + // //{ + // // canNotPrintObj.CanNotPrint = true; + // // _billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); + // //} + // #endregion + + // if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) + // { + // } + // else + // { + // #region 根据"排除模块配置"过滤掉不需要的结算件 + // List excludeLst = new List(); + // string vehicleModelCode = m100Bill.VehicleModelCode; + // foreach (BillM100Part partItem in m100Bill.BillM100Parts) //遍历单据零件 + // { + // bool existExclude = _excludePartCfgRepository.Any(itm => itm.VehicleModelCode == vehicleModelCode && itm.PartCode == partItem.PartCode); + // if (existExclude) + // { + // excludeLst.Add(partItem.Id); + // } + // } + // int delCnt = m100Bill.BillM100Parts.RemoveAll(itm2 => excludeLst.Contains(itm2.Id)); + // if (delCnt > 0) + // { + // _logger.LogDebug(_errorMessagePrefix + $"排除掉{delCnt}个零件。VIN :{m100Bill.VIN},大众顺序号:{m100Bill.HostSN}"); + // } + // #endregion + // } - bool isMatch = DoMatchAssembly(m100Bill); - if (isMatch) - { - #region 判断是否断号 - ////断号判断规则:大众顺序号生成规则是1至1999的重复循环,重复循环到1时判断之前最近的相同车型的VIN和当前VIN是否连续,如果不连续则表示断号 - ////断号判断:大众顺序号按生产线分类判断;VIN按车型分类判断 - //string curProductLine = m100Bill.ProductLine; - //string curSerialNumStr = m100Bill.SerialNumStr; //排序依据 - //int curHostSN = m100Bill.HostSN ?? 0; - //string curVehicleModel = m100Bill.VehicleModelCode; - //int curVinNum = m100Bill.SerialNum ?? 0; //VIN后六位 - ////取当前生产线最近一条SerialNumStr - //string priorSerialNumStr = _billM100Repository.Where(itm => - // itm.ProductLine == curProductLine - // && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 - // ).Max(itm => itm.SerialNumStr); - //if (priorSerialNumStr != null) - //{ - // //取当前生产线最近一条 - // int priorHostSN = _billM100Repository.FirstOrDefault(itm => itm.ProductLine == curProductLine && itm.SerialNumStr == priorSerialNumStr).HostSN ?? 0; - // if (curHostSN == priorHostSN + 1) - // { - // //不断号 - // } - // else - // { - // //取当前生产线、相同车型、最近一条SerialNumStr - // string priorSerialNumStr2 = _billM100Repository.Where(itm => - // itm.ProductLine == curProductLine - // && itm.VehicleModelCode == curVehicleModel - // && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 - // ).Max(itm => itm.SerialNumStr); - // if (priorSerialNumStr2 != null) - // { - // int priorVinNum = _billM100Repository.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr2).SerialNum ?? 0; - // if (curVinNum == priorVinNum + 1) - // { - // //不断号 - // } - // else - // { - // //断号提醒 - // string errorMsg = $"{curProductLine}生产线M100报文出现断号,当前VIN:{curVinNum}:{curHostSN},上一VIN:{priorVinNum}:{priorHostSN}。可以操作M100单据信息维护模块进行补号!"; - // _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - // } - // } - // } - //} - #endregion + // bool isMatch = DoMatchAssembly(m100Bill); + // if (isMatch) + // { + // #region 判断是否断号 + // ////断号判断规则:大众顺序号生成规则是1至1999的重复循环,重复循环到1时判断之前最近的相同车型的VIN和当前VIN是否连续,如果不连续则表示断号 + // ////断号判断:大众顺序号按生产线分类判断;VIN按车型分类判断 + // //string curProductLine = m100Bill.ProductLine; + // //string curSerialNumStr = m100Bill.SerialNumStr; //排序依据 + // //int curHostSN = m100Bill.HostSN ?? 0; + // //string curVehicleModel = m100Bill.VehicleModelCode; + // //int curVinNum = m100Bill.SerialNum ?? 0; //VIN后六位 + // ////取当前生产线最近一条SerialNumStr + // //string priorSerialNumStr = _billM100Repository.Where(itm => + // // itm.ProductLine == curProductLine + // // && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 + // // ).Max(itm => itm.SerialNumStr); + // //if (priorSerialNumStr != null) + // //{ + // // //取当前生产线最近一条 + // // int priorHostSN = _billM100Repository.FirstOrDefault(itm => itm.ProductLine == curProductLine && itm.SerialNumStr == priorSerialNumStr).HostSN ?? 0; + // // if (curHostSN == priorHostSN + 1) + // // { + // // //不断号 + // // } + // // else + // // { + // // //取当前生产线、相同车型、最近一条SerialNumStr + // // string priorSerialNumStr2 = _billM100Repository.Where(itm => + // // itm.ProductLine == curProductLine + // // && itm.VehicleModelCode == curVehicleModel + // // && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 + // // ).Max(itm => itm.SerialNumStr); + // // if (priorSerialNumStr2 != null) + // // { + // // int priorVinNum = _billM100Repository.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr2).SerialNum ?? 0; + // // if (curVinNum == priorVinNum + 1) + // // { + // // //不断号 + // // } + // // else + // // { + // // //断号提醒 + // // string errorMsg = $"{curProductLine}生产线M100报文出现断号,当前VIN:{curVinNum}:{curHostSN},上一VIN:{priorVinNum}:{priorHostSN}。可以操作M100单据信息维护模块进行补号!"; + // // _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); + // // } + // // } + // // } + // //} + // #endregion - #region 当前单据在未匹配时已经参与打印,重新解析后进入补打 - //var m100Obj = m100Bill; - //string curPL = m100Obj.ProductLine; - //string curSNStr = m100Obj.SerialNumStr; - //bool hasPrintData = _billM100Repository.Any(itm => itm.ProductLine == curPL && itm.SerialNumStr.CompareTo(curSNStr) > 0 && itm.BillStatus == BillStatusEnum.Publish); - //if (hasPrintData) //该单据处于未解析时,已经打印 - //{ - // m100Obj.NeedReplenishPrint = 1; - // _billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); - //} - #endregion + // #region 当前单据在未匹配时已经参与打印,重新解析后进入补打 + // //var m100Obj = m100Bill; + // //string curPL = m100Obj.ProductLine; + // //string curSNStr = m100Obj.SerialNumStr; + // //bool hasPrintData = _billM100Repository.Any(itm => itm.ProductLine == curPL && itm.SerialNumStr.CompareTo(curSNStr) > 0 && itm.BillStatus == BillStatusEnum.Publish); + // //if (hasPrintData) //该单据处于未解析时,已经打印 + // //{ + // // m100Obj.NeedReplenishPrint = 1; + // // _billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); + // //} + // #endregion - ret.Status = true; - } - else //未匹配总成 - { - _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - //更新单据表 - m100Bill.SetAssemblyID(null); - m100Bill.SetBillStatus(BillStatusEnum.NotMatch); - var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); - - //不匹配时,插入未知总成 - var succObj2 = InsertUnknownAssembly(m100Bill); - //写系统内通知 - string errorMsg = "出现未知总成,请到未知总成模块查看:" + this._billNumber; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj1 != null && succObj2 != null); - } + // ret.Status = true; + // } + // else //未匹配总成 + // { + // _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成开始:{_hostSN}-{_billNumber}-{_fileName}"); + // //更新单据表 + // m100Bill.SetAssemblyID(null); + // m100Bill.SetBillStatus(BillStatusEnum.NotMatch); + // var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + + // //不匹配时,插入未知总成 + // var succObj2 = InsertUnknownAssembly(m100Bill); + // //写系统内通知 + // string errorMsg = "出现未知总成,请到未知总成模块查看:" + this._billNumber; + // _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); + // _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成完成:{_hostSN}-{_billNumber}-{_fileName}"); + // ret.Status = (succObj1 != null && succObj2 != null); + // } - } - return ret; + // } + // return ret; - } - catch (Exception ex) - { - string errorMsg = "调用报文解析及校验方法DoCheckM100Bill出错:" + ex.Message; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - _logger.LogError(errorMsg); - throw new Exception(errorMsg); - } - } + // } + // catch (Exception ex) + // { + // string errorMsg = "调用报文解析及校验方法DoCheckM100Bill出错:" + ex.Message; + // _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); + // _logger.LogError(errorMsg); + // throw new Exception(errorMsg); + // } + //} + /// + /// M100报文解析-正常入口 + /// + /// + /// + /// + /// public ObjectResultDto DoCheckM100Bill(MessageReceive msgReceiveObj, BillM100 m100Bill) { ObjectResultDto ret = new ObjectResultDto(false, null); @@ -370,140 +378,72 @@ namespace WY.NewJit.MsgCheck _fileName = msgReceiveObj.MessageFileName; try { - bool isRepeat = _billM100Repository.Any(itm => itm.HostSN == m100Bill.HostSN && itm.VIN == m100Bill.VIN); - if (isRepeat == true) + #region 更新不可打印标志 + List canNotPrintLst = _billM100Repository.Where(itm => + itm.ProductLine == m100Bill.ProductLine + && itm.HostSN == m100Bill.HostSN + && (itm.CanNotPrint == null || itm.CanNotPrint == false)).ToList(); + foreach (BillM100 canNotPrintObj in canNotPrintLst) { - #region 重复报文 - var succObj = InsertM100RepeatBill(msgReceiveObj, m100Bill); - string errorMsg = "报文重复,请到重复报文模块查看:" + msgReceiveObj.MessageFileName; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj != null); - return ret; - #endregion + canNotPrintObj.CanNotPrint = true; + _billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); } - else - { - #region 更新不可打印标志 - List canNotPrintLst = _billM100Repository.Where(itm => - itm.ProductLine == m100Bill.ProductLine - && itm.HostSN == m100Bill.HostSN - && (itm.CanNotPrint == null || itm.CanNotPrint == false) ).ToList(); - foreach (BillM100 canNotPrintObj in canNotPrintLst) - { - canNotPrintObj.CanNotPrint = true; - _billM100Repository.UpdateAsync(canNotPrintObj, true).GetAwaiter().GetResult(); - } - #endregion + #endregion - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) - { - } - else + + bool isMatch = DoMatchAssembly(m100Bill); //仅仅插入或更新M100主子表 + if (isMatch) + { + #region 判断是否断号 + //断号判断规则:大众顺序号生成规则是1至1999的重复循环,重复循环到1时判断之前最近的相同车型的VIN和当前VIN是否连续,如果不连续则表示断号 + //断号判断:大众顺序号按生产线分类判断;VIN按车型分类判断 + string curProductLine = m100Bill.ProductLine; + string curSerialNumStr = m100Bill.SerialNumStr; //排序依据 + int curHostSN = m100Bill.HostSN ?? 0; + string curVehicleModel = m100Bill.VehicleModelCode; + int curVinNum = m100Bill.SerialNum ?? 0; //VIN后六位 + //取当前生产线最近一条SerialNumStr + string priorSerialNumStr = _billM100Repository.Where(itm => + itm.ProductLine == curProductLine + && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 + ).Max(itm => itm.SerialNumStr); + if (priorSerialNumStr != null) { - #region 根据"排除模块配置"过滤掉不需要的结算件 - List excludeLst = new List(); - string vehicleModelCode = m100Bill.VehicleModelCode; - foreach (BillM100Part partItem in m100Bill.BillM100Parts) //遍历单据零件 + //取当前生产线最近一条 + int priorHostSN = _billM100Repository.FirstOrDefault(itm => itm.ProductLine == curProductLine && itm.SerialNumStr == priorSerialNumStr).HostSN ?? 0; + if (curHostSN == priorHostSN + 1) { - bool existExclude = _excludePartCfgRepository.Any(itm => itm.VehicleModelCode == vehicleModelCode && itm.PartCode == partItem.PartCode); - if (existExclude) - { - excludeLst.Add(partItem.Id); - } - } - int delCnt = m100Bill.BillM100Parts.RemoveAll(itm2 => excludeLst.Contains(itm2.Id)); - if (delCnt > 0) - { - _logger.LogDebug(_errorMessagePrefix + $"排除掉{delCnt}个零件。VIN :{m100Bill.VIN},大众顺序号:{m100Bill.HostSN}"); + //不断号 } - #endregion - } - - bool isMatch = DoMatchAssembly(m100Bill); - if (isMatch) - { - #region 判断是否断号 - //断号判断规则:大众顺序号生成规则是1至1999的重复循环,重复循环到1时判断之前最近的相同车型的VIN和当前VIN是否连续,如果不连续则表示断号 - //断号判断:大众顺序号按生产线分类判断;VIN按车型分类判断 - string curProductLine = m100Bill.ProductLine; - string curSerialNumStr = m100Bill.SerialNumStr; //排序依据 - int curHostSN = m100Bill.HostSN ?? 0; - string curVehicleModel = m100Bill.VehicleModelCode; - int curVinNum = m100Bill.SerialNum ?? 0; //VIN后六位 - //取当前生产线最近一条SerialNumStr - string priorSerialNumStr = _billM100Repository.Where(itm => - itm.ProductLine == curProductLine - && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 - ).Max(itm => itm.SerialNumStr); - if (priorSerialNumStr != null) + else { - //取当前生产线最近一条 - int priorHostSN = _billM100Repository.FirstOrDefault(itm => itm.ProductLine == curProductLine && itm.SerialNumStr == priorSerialNumStr).HostSN ?? 0; - if (curHostSN == priorHostSN + 1) + //取当前生产线、相同车型、最近一条SerialNumStr + string priorSerialNumStr2 = _billM100Repository.Where(itm => + itm.ProductLine == curProductLine + && itm.VehicleModelCode == curVehicleModel + && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 + ).Max(itm => itm.SerialNumStr); + if (priorSerialNumStr2 != null) { - //不断号 - } - else - { - //取当前生产线、相同车型、最近一条SerialNumStr - string priorSerialNumStr2 = _billM100Repository.Where(itm => - itm.ProductLine == curProductLine - && itm.VehicleModelCode == curVehicleModel - && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 - ).Max(itm => itm.SerialNumStr); - if (priorSerialNumStr2 != null) + int priorVinNum = _billM100Repository.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr2).SerialNum ?? 0; + if (curVinNum == priorVinNum + 1) { - int priorVinNum = _billM100Repository.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr2).SerialNum ?? 0; - if (curVinNum == priorVinNum + 1) - { - //不断号 - } - else - { - //断号提醒 - string errorMsg = $"{curProductLine}生产线M100报文出现断号,当前VIN:{curVinNum}:{curHostSN},上一VIN:{priorVinNum}:{priorHostSN}。可以操作M100单据信息维护模块进行补号!"; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - } + //不断号 + } + else + { + //断号提醒 + string errorMsg = $"{curProductLine}生产线M100报文出现断号,当前VIN:{curVinNum}:{curHostSN},上一VIN:{priorVinNum}:{priorHostSN}。可以操作M100单据信息维护模块进行补号!"; + _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); } } } - #endregion - - #region 当前单据在未匹配时已经参与打印,重新解析后进入补打 - var m100Obj = m100Bill; - string curPL = m100Obj.ProductLine; - string curSNStr = m100Obj.SerialNumStr; - bool hasPrintData = _billM100Repository.Any(itm => itm.ProductLine == curPL && itm.SerialNumStr.CompareTo(curSNStr) > 0 && itm.BillStatus == BillStatusEnum.Publish); - if (hasPrintData) //该单据处于未解析时,已经打印 - { - m100Obj.NeedReplenishPrint = 1; - _billM100Repository.UpdateAsync(m100Obj, true).GetAwaiter().GetResult(); - } - #endregion - - ret.Status = true; - } - else //未匹配总成 - { - _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - //更新单据表 - m100Bill.SetAssemblyID(null); - m100Bill.SetBillStatus(BillStatusEnum.NotMatch); - var succObj1 = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); - - //不匹配时,插入未知总成 - var succObj2 = InsertUnknownAssembly(m100Bill); - //写系统内通知 - string errorMsg = "出现未知总成,请到未知总成模块查看:" + this._billNumber; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.M100); - _logger.LogDebug(_errorMessagePrefix + $"未匹配总成,插入未知总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj1 != null && succObj2 != null); } + #endregion + ret.Status = true; } return ret; - } catch (Exception ex) { @@ -519,105 +459,33 @@ namespace WY.NewJit.MsgCheck bool ret = false; try { - BillM100 succObj = null; - //判断总成 - CompareAssemblyResult compareResult = IsMatchAssembly(m100Bill); - if (compareResult.VehicleAssemblyResult != null) //匹配整车总成 + #region 更新单据表 + m100Bill.SetAssemblyID(Guid.Parse("00000000-0000-0000-0000-000000000000")); + m100Bill.SetBillStatus(BillStatusEnum.Match); + BillM100 succObj; + if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) { - _logger.LogDebug(_errorMessagePrefix + $"已匹配整车总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - - #region 更新单据表 - m100Bill.SetAssemblyID(compareResult.VehicleAssemblyResult.VehicleId); - m100Bill.SetBillStatus(BillStatusEnum.Match); - m100Bill.IsPartSwitch = compareResult.IsPartSwitch; - - if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) + if (isUnknowAssembly) { - if (isUnknowAssembly) - { - succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); - } - else - { - succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); - } + succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); } else { - succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); - } - - if (succObj == null) - { - throw new Exception("插入或更新M100整车总成ID返回结果为空InsertAsync!"); + succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); } - #endregion - - _logger.LogDebug(_errorMessagePrefix + $"已匹配整车总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret = true; - return ret; } - else if (compareResult.ErpAssemblyResult != null) //匹配ERP总成 + else { - _logger.LogDebug(_errorMessagePrefix + $"已匹配Erp总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - - #region 插入整车总成 - var erpIdLst = compareResult.ErpAssemblyResult.ErpAssemblyIdList; //Erp总成ID列表 - Guid curVehicleAssemblyId = GuidGenerator.Create(); - AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(curVehicleAssemblyId, null, compareResult.VehicleModel, null, true); - foreach (Guid erpId in erpIdLst) //插入子表 - { - vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), erpId); - } - var vehicleAssemblyResu = _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, true).GetAwaiter().GetResult(); - if (vehicleAssemblyResu == null) - { - throw new Exception("插入整车总成返回结果为空InsertAsync!"); - } - #endregion - - #region 将新的整车总成 插入内存 - if (_vehicle2partDict.ContainsKey(curVehicleAssemblyId) == false) - { - _vehicle2partDict.Add(curVehicleAssemblyId, compareResult.ErpAssemblyResult.Vehicle2PartList); - } - if (_vehicleAssemblyIdList.Any(itm => itm.Id == curVehicleAssemblyId) == false) //插入到整车总成主表ID列表,用于整车总成匹配时执行遍历 - { - _vehicleAssemblyIdList.Add(new VehicleAssemblyMainList(curVehicleAssemblyId, compareResult.VehicleModel)); - } - #endregion - - #region 更新单据表 - m100Bill.SetAssemblyID(vehicleAssemblyResu.Id); - m100Bill.SetBillStatus(BillStatusEnum.Match); - m100Bill.IsPartSwitch = compareResult.IsPartSwitch; - - if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) - { - if (isUnknowAssembly) - { - succObj = _billM100Repository.UpdateAsync(m100Bill).GetAwaiter().GetResult(); - } - else - { - succObj = _billM100Repository.UpdateAsync(m100Bill, true).GetAwaiter().GetResult(); - } - } - else - { - succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); - } - - if (succObj == null) - { - throw new Exception("插入或更新M100整车总成ID返回结果为空InsertAsync!!"); - } - #endregion + succObj = _billM100Repository.InsertAsync(m100Bill, true).GetAwaiter().GetResult(); + } - _logger.LogDebug(_errorMessagePrefix + $"已匹配Erp总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret = true; - return ret; + if (succObj == null) + { + throw new Exception("插入或更新M100整车总成ID返回结果为空InsertAsync!!"); } + #endregion + + ret = true; return ret; } catch (Exception ex) @@ -631,7 +499,7 @@ namespace WY.NewJit.MsgCheck #region 私有方法 - private RepeatM100 InsertM100RepeatBill(MessageReceive msgReceiveObj, BillM100 m100Bill) //, int? maxSerialNum + public RepeatM100 InsertM100RepeatBill(MessageReceive msgReceiveObj, BillM100 m100Bill) //, int? maxSerialNum { RepeatM100 ret = null; int newSN = ServerHelper.VinToSN(m100Bill.VIN); @@ -1073,7 +941,7 @@ namespace WY.NewJit.MsgCheck /// 不匹配时,插入未知总成,写提醒日志 /// /// - private UnknownAssembly InsertUnknownAssembly(BillM100 bill) + public UnknownAssembly InsertUnknownAssembly(BillM100 bill) { UnknownAssembly ret = null; try diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/R100CheckDomainService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/R100CheckDomainService.cs index 005006e..3cb7ec6 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/R100CheckDomainService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Domain/MsgCheck/Services/R100CheckDomainService.cs @@ -1,32 +1,33 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; +using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Linq.Dynamic.Core; using System.Text; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Domain.Services; +using Volo.Abp.ObjectMapping; using Volo.Abp.Uow; -using Microsoft.AspNetCore.Mvc; +using WY.NewJit.Common; +using WY.NewJit.IRepositories; using WY.NewJit.MsgBaseData; -using Newtonsoft.Json.Linq; -using System.Threading; -using System.IO; -using WY.NewJit.MsgTransmission; -using Volo.Abp.Domain.Services; using WY.NewJit.MsgCheck; -using WY.NewJit.Common; using WY.NewJit.MsgConversion; -using Volo.Abp.ObjectMapping; -using WY.NewJit.IRepositories; +using WY.NewJit.MsgTransmission; namespace WY.NewJit.MsgCheck { /// /// 报文校验领域服务实现 /// - public class R100CheckDomainService : DomainService + public class R100CheckDomainService : DomainService { @@ -182,7 +183,7 @@ namespace WY.NewJit.MsgCheck } #region 私有方法 - private RepeatR100 InsertR100Repeat(MessageReceive msgReceiveObj, BillR100 r100Bill) + public RepeatR100 InsertR100Repeat(MessageReceive msgReceiveObj, BillR100 r100Bill) { RepeatR100 ret = null; RepeatR100 repeatBill = new RepeatR100( @@ -626,7 +627,7 @@ namespace WY.NewJit.MsgCheck /// 不匹配时,插入未知总成,写提醒日志 /// /// - private UnknownAssembly InsertUnknownAssembly(BillR100 bill) + public UnknownAssembly InsertUnknownAssembly(BillR100 bill) { UnknownAssembly ret = null; try @@ -665,6 +666,13 @@ namespace WY.NewJit.MsgCheck _switchTargetPartCodeList = partSwitchList.Select(itm => itm.TargetPartCode).ToList(); //切换目标零件编码,判断单据是否存在切换零件时使用 } + /// + /// R100报文解析-正常入口 + /// + /// + /// + /// + /// public ObjectResultDto DoCheckR100(MessageReceive msgReceiveObj, BillR100 r100Bill) { ObjectResultDto ret = new ObjectResultDto(false, null); @@ -673,94 +681,40 @@ namespace WY.NewJit.MsgCheck string _fileName = msgReceiveObj.MessageFileName; try { - bool isRepeat = _billR100Repos.Any(itm => itm.HostSN == r100Bill.HostSN && itm.KNR == r100Bill.KNR); - if (isRepeat == true) - { - //插入重复报文 - var succObj = InsertR100Repeat(msgReceiveObj, r100Bill); - string errorMsg = "报文重复,请到重复报文模块查看:" + msgReceiveObj.MessageFileName; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.R100); - _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj != null); - return ret; - } - else + bool isMatch = DoMatchAssembly(r100Bill); + if (isMatch == true) { - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) - { - } - else + #region 判断是否断号 + //断号判断规则:大众顺序号生成规则是1至1999的重复循环,大众顺序号按生产线分类判断 + string curProductLine = r100Bill.ProductLine; + string curSerialNumStr = r100Bill.SerialNumStr; //排序依据 + int curHostSN = r100Bill.HostSN ?? 0; + //取当前生产线最近一条SerialNumStr + string priorSerialNumStr = _billR100Repos.Where(itm => + itm.ProductLine == curProductLine + && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 + ).Max(itm => itm.SerialNumStr); + if (priorSerialNumStr != null) { - #region 根据"排除模块配置"过滤掉不需要的结算件 - List excludeLst = new List(); - string vehicleModelCode = r100Bill.VehicleModelCode; - foreach (BillR100Part partItm in r100Bill.BillR100Parts) //遍历单据零件 + //取当前生产线最近一条 + var priorBill = _billR100Repos.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr); + int priorHostSN = priorBill.HostSN ?? 0; + if (curHostSN == priorHostSN + 1 || curHostSN + 1999 == priorHostSN + 1) { - bool existExclude = _excludePartCfgRepository.Any(itm => itm.VehicleModelCode == vehicleModelCode && itm.PartCode == partItm.PartCode); - if (existExclude) - { - excludeLst.Add(partItm.Id); - } + //不断号 } - int delCnt = r100Bill.BillR100Parts.RemoveAll(itm2 => excludeLst.Contains(itm2.Id)); - if (delCnt > 0) + else { - _logger.LogDebug(_errorMessagePrefix + $"排除掉{delCnt}个零件。KNR :{r100Bill.KNR},大众顺序号:{r100Bill.HostSN}"); + //断号提醒 + string errorMsg = $"R100报文出现断号,当前KNR:{r100Bill.KNR}-{curHostSN},上一KNR:{priorBill.KNR}-{priorHostSN}"; + _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.R100); } - #endregion } + #endregion - bool isMatch = DoMatchAssembly(r100Bill); - if (isMatch == true) - { - #region 判断是否断号 - //断号判断规则:大众顺序号生成规则是1至1999的重复循环,大众顺序号按生产线分类判断 - string curProductLine = r100Bill.ProductLine; - string curSerialNumStr = r100Bill.SerialNumStr; //排序依据 - int curHostSN = r100Bill.HostSN ?? 0; - //取当前生产线最近一条SerialNumStr - string priorSerialNumStr = _billR100Repos.Where(itm => - itm.ProductLine == curProductLine - && itm.SerialNumStr.CompareTo(curSerialNumStr) < 0 - ).Max(itm => itm.SerialNumStr); - if (priorSerialNumStr != null) - { - //取当前生产线最近一条 - var priorBill = _billR100Repos.FirstOrDefault(itm => itm.SerialNumStr == priorSerialNumStr); - int priorHostSN = priorBill.HostSN ?? 0; - if (curHostSN == priorHostSN + 1 || curHostSN + 1999 == priorHostSN + 1) - { - //不断号 - } - else - { - //断号提醒 - string errorMsg = $"R100报文出现断号,当前KNR:{r100Bill.KNR}-{curHostSN},上一KNR:{priorBill.KNR}-{priorHostSN}"; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.R100); - } - } - #endregion - - ret.Status = true; - } - else //未匹配总成 - { - _logger.LogDebug(_errorMessagePrefix + $"插入未知总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - //更新单据表 - r100Bill.SetAssemblyID(null); - r100Bill.SetBillStatus(BillStatusEnum.NotMatch); - var succObj1 = _billR100Repos.InsertAsync(r100Bill, true).GetAwaiter().GetResult(); - //不匹配时,插入未知总成 - var succObj2 = InsertUnknownAssembly(r100Bill); - //写系统内通知 - string errorMsg = "出现未知总成,请到未知总成模块查看:" + this._billNumber; - _logRemindDomainService.WriteLogRemind(_billNumber, errorMsg, LogTypeEnum.R100); - _logger.LogDebug(_errorMessagePrefix + $"插入未知总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret.Status = (succObj1 != null && succObj2 != null); - } + ret.Status = true; } return ret; - } catch (Exception ex) { @@ -777,101 +731,34 @@ namespace WY.NewJit.MsgCheck bool ret = false; try { + #region 更新单据表 + r100Bill.SetAssemblyID(Guid.Parse("00000000-0000-0000-0000-000000000000")); + r100Bill.SetBillStatus(BillStatusEnum.Match); BillR100 succObj = null; - //判断总成 - CompareAssemblyResult compareResult = IsMatchAssembly(r100Bill); - if (compareResult.VehicleAssemblyResult != null) //匹配整车总成 - { - _logger.LogDebug(_errorMessagePrefix + $"已匹配整车总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - - # region 更新单据表 - r100Bill.SetAssemblyID(compareResult.VehicleAssemblyResult.VehicleId); - r100Bill.SetBillStatus(BillStatusEnum.Match); - r100Bill.IsPartSwitch = compareResult.IsPartSwitch; - if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) + if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) + { + if (isUnknowAssembly) { - if (isUnknowAssembly) - { - succObj = _billR100Repos.UpdateAsync(r100Bill).GetAwaiter().GetResult(); - } - else - { - succObj = _billR100Repos.UpdateAsync(r100Bill, true).GetAwaiter().GetResult(); - } + succObj = _billR100Repos.UpdateAsync(r100Bill).GetAwaiter().GetResult(); } else { - succObj = _billR100Repos.InsertAsync(r100Bill, true).GetAwaiter().GetResult(); - } - - if (succObj == null) - { - throw new Exception("插入或更新 R100 整车总成ID返回结果为空InsertAsync!"); + succObj = _billR100Repos.UpdateAsync(r100Bill, true).GetAwaiter().GetResult(); } - #endregion - - _logger.LogDebug(_errorMessagePrefix + $"已匹配整车总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret = true; - return ret; } - else if (compareResult.ErpAssemblyResult != null) //匹配ERP总成 + else { - _logger.LogDebug(_errorMessagePrefix + $"已匹配Erp总成开始:{_hostSN}-{_billNumber}-{_fileName}"); - - #region 插入整车总成 - var erpIdLst = compareResult.ErpAssemblyResult.ErpAssemblyIdList; //Erp总成ID列表 - Guid curVehicleAssemblyId = GuidGenerator.Create(); - AssemblyCfgVehicle vehicleAssemblyCfgObj = new AssemblyCfgVehicle(curVehicleAssemblyId, null, compareResult.VehicleModel, null, true); - foreach (Guid erpId in erpIdLst) //插入子表 - { - vehicleAssemblyCfgObj.AddChildObj(GuidGenerator.Create(), erpId); - } - var vehicleAssemblyResu = _assemblyCfgVehicleRepository.InsertAsync(vehicleAssemblyCfgObj, true).GetAwaiter().GetResult(); - #endregion - - #region 将新的整车总成 插入内存 - if (_vehicle2partDict.ContainsKey(curVehicleAssemblyId) == false) - { - _vehicle2partDict.Add(curVehicleAssemblyId, compareResult.ErpAssemblyResult.Vehicle2PartList); - } - if (_vehicleAssemblyIdList.Any(itm => itm.Id == curVehicleAssemblyId) == false) //插入到整车总成主表ID列表,用于整车总成匹配时执行遍历 - { - _vehicleAssemblyIdList.Add(new VehicleAssemblyMainList(curVehicleAssemblyId, compareResult.VehicleModel)); - } - #endregion - - #region 更新单据表 - r100Bill.SetAssemblyID(vehicleAssemblyResu.Id); - r100Bill.SetBillStatus(BillStatusEnum.Match); - r100Bill.IsPartSwitch = compareResult.IsPartSwitch; - - if (isBillUpdate == true) //未知总成模块-重新解析时修改R100单据(单据已经存在) - { - if (isUnknowAssembly) - { - succObj = _billR100Repos.UpdateAsync(r100Bill).GetAwaiter().GetResult(); - } - else - { - succObj = _billR100Repos.UpdateAsync(r100Bill, true).GetAwaiter().GetResult(); - } - } - else - { - succObj = _billR100Repos.InsertAsync(r100Bill, true).GetAwaiter().GetResult(); - } - - if (succObj == null) - { - throw new Exception("插入或更新 R100 整车总成ID返回结果为空InsertAsync!!"); - } - #endregion + succObj = _billR100Repos.InsertAsync(r100Bill, true).GetAwaiter().GetResult(); + } - _logger.LogDebug(_errorMessagePrefix + $"已匹配Erp总成完成:{_hostSN}-{_billNumber}-{_fileName}"); - ret = true; - return ret; + if (succObj == null) + { + throw new Exception("插入或更新 R100 整车总成ID返回结果为空InsertAsync!!"); } + #endregion + + ret = true; return ret; } catch (Exception ex) diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs index 45b39b2..edc3cdf 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/Messages/MsgTransmissionService.cs @@ -19,6 +19,7 @@ using WY.NewJit.MsgCheck; using WY.NewJit.MsgConversion; using WY.NewJit.MsgTransmission; using Microsoft.EntityFrameworkCore; +using WY.NewJit.Extends; namespace WY.NewJit.Job.ConsoleApp.Messages @@ -147,6 +148,11 @@ namespace WY.NewJit.Job.ConsoleApp.Messages /// private static List _partCfgList = new List(); + /// + /// 零件大类 + /// + private static List _partLargeTypeList = new List(); + #endregion #region 变量 @@ -208,7 +214,7 @@ namespace WY.NewJit.Job.ConsoleApp.Messages private DateTime _lastRefreshCacheTime = DateTime.Now; #endregion - private static string errorHeader = ""; //错误头 + private static string errorHeader = ""; //错误头 #region 构造函数 /// @@ -260,7 +266,7 @@ namespace WY.NewJit.Job.ConsoleApp.Messages #region 公共方法 /// - /// 报文转换,BOM解析 + /// 报文转换,BOM解析(根入口) /// /// [UnitOfWork] @@ -274,8 +280,6 @@ namespace WY.NewJit.Job.ConsoleApp.Messages string fileName = ""; try { - //PathConfigInfo cfgInfo = ReadConfig(); - int countPerTime = _configuration["ConfigDic:TransferFileCountPerTime"].TryToInt() ?? 10; InitLoadCache(); @@ -438,7 +442,7 @@ namespace WY.NewJit.Job.ConsoleApp.Messages } #region 无法缓存的 //结算件信息列表,库存系统同步过来,无法缓存 - string partCfgSql = @"select Id, PartCode, PartName, PartType, Description, PartType2, PartType3, RelationKey from FisPartCfg where 1=1"; //,DaXiaoLiangGang,DoorPlankCode,MaterialDescription,SAPMaterialNum + string partCfgSql = @"select Id, PartCode, PartName, PartType, Description, PartType2, PartType3, RelationKey from FisPartCfg where 1=1 and IsDeleted = 0"; //,DaXiaoLiangGang,DoorPlankCode,MaterialDescription,SAPMaterialNum _partCfgList = _newJitDapperRepository.GetListBySql(partCfgSql, true); #endregion @@ -455,67 +459,83 @@ namespace WY.NewJit.Job.ConsoleApp.Messages /// private void DoInitLoadCache() { - //取整车总成主表 - string vehicleSql = "select Id, VehicleModelCode as VehicleModel from FisAssemblyCfgVehicle v where NewVersionId is null order by CreationTime desc"; - List vehicleAssemblyIdList = _newJitDapperRepository.GetListBySql(vehicleSql, true); - - //取整车总成的零件:按整车总成Id、零件编码分组汇总数量 - const string vehicle2PartSql = @" - select v.Id as VehicleAssemblyId, ep.PartCode, sum(ep.PartNum) as PartNum - from FisAssemblyCfgVehicle v - join FisAssemblyCfgVehicleChild vc on v.Id = vc.AssemblyCfgVehicleId - join FisAssemblyCfgErp e on vc.ErpAssemblyId = e.Id - join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId - where 1=1 and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) - and v.NewVersionId is null - and ep.PartCode is not null - group by v.Id, ep.PartCode - order by v.Id, ep.PartCode - "; - var vehicle2partList = _newJitDapperRepository.GetListBySql(vehicle2PartSql, true); - - //取ERP总成主表 - string erpMainSql = "select Id, VehicleModel from FisAssemblyCfgErp where NewVersionId is null order by ErpAssemblyVersion, CreationTime desc"; - List erpAssemblyMainList = _newJitDapperRepository.GetListBySql(erpMainSql, true); - //取ERP总成的零件 - List erp2partList = new List(); - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) - { - //取所有零件(IsDisable = 1时表示不参与解析BOM)(派格版本根据长描述分组过滤,不过滤NewVersionId) - string erp2partSql = @" - select e.GroupId, e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey - from FisAssemblyCfgErp e - join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId - where ep.PartCode is not null - and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) - /*and ep.PartCode in (select distinct RelationKey from FisMaterialExt where MaterialGroup like '72%')*/ - "; - erp2partList = _newJitDapperRepository.GetListBySql(erp2partSql, true); - - //结算件切换列表 - string partSwitchSql = "select SourcePartCode, TargetPartCode, ActiveBeginTime, ActiveEndTime from FisPartSwitch"; - _partSwitchList = _newJitDapperRepository.GetListBySql(partSwitchSql, true); - } - else + ////取整车总成主表 + //string vehicleSql = "select Id, VehicleModelCode as VehicleModel from FisAssemblyCfgVehicle v where NewVersionId is null order by CreationTime desc"; + //List vehicleAssemblyIdList = _newJitDapperRepository.GetListBySql(vehicleSql, true); + + ////取整车总成的零件:按整车总成Id、零件编码分组汇总数量 + //const string vehicle2PartSql = @" + // select v.Id as VehicleAssemblyId, ep.PartCode, sum(ep.PartNum) as PartNum + // from FisAssemblyCfgVehicle v + // join FisAssemblyCfgVehicleChild vc on v.Id = vc.AssemblyCfgVehicleId + // join FisAssemblyCfgErp e on vc.ErpAssemblyId = e.Id + // join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId + // where 1=1 and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) + // and v.NewVersionId is null + // and ep.PartCode is not null + // group by v.Id, ep.PartCode + // order by v.Id, ep.PartCode + // "; + //var vehicle2partList = _newJitDapperRepository.GetListBySql(vehicle2PartSql, true); + + ////取ERP总成主表 + //string erpMainSql = "select Id, VehicleModel from FisAssemblyCfgErp where NewVersionId is null order by ErpAssemblyVersion, CreationTime desc"; + //List erpAssemblyMainList = _newJitDapperRepository.GetListBySql(erpMainSql, true); + ////取ERP总成的零件 + //List erp2partList = new List(); + //if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) + //{ + // //取所有零件(IsDisable = 1时表示不参与解析BOM)(派格版本根据长描述分组过滤,不过滤NewVersionId) + // string erp2partSql = @" + // select e.GroupId, e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey + // from FisAssemblyCfgErp e + // join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId + // where ep.PartCode is not null + // and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) + // /*and ep.PartCode in (select distinct RelationKey from FisMaterialExt where MaterialGroup like '72%')*/ + // "; + // erp2partList = _newJitDapperRepository.GetListBySql(erp2partSql, true); + + // //结算件切换列表 + // string partSwitchSql = "select SourcePartCode, TargetPartCode, ActiveBeginTime, ActiveEndTime from FisPartSwitch"; + // _partSwitchList = _newJitDapperRepository.GetListBySql(partSwitchSql, true); + //} + //else + //{ + // //取所有零件(IsDisable = 1时表示不需要解析BOM) + // string erp2partSql = @" + // select e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey + // from FisAssemblyCfgErp e + // join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId + // where e.NewVersionId is null + // and ep.PartCode is not null + // and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) + // "; + // erp2partList = _newJitDapperRepository.GetListBySql(erp2partSql, true); + //} + + //_r100CheckDomainSrv.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList); //整车总成内存及时刷新, ERP总成增删改时触发刷新标志 + //_m100CheckDomainService.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList); + + _msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.报文车型对应格拉默车型); + //_r100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.R100格拉默车型对应生产线); + //_m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100格拉默车型对应生产线); + + #region 加载零件大类 + _partLargeTypeList = new List(); + var largeTypeDic = _dicDomainService.GetDicItems(DicTypeName.零件大类); + foreach (var item in largeTypeDic) { - //取所有零件(IsDisable = 1时表示不需要解析BOM) - string erp2partSql = @" - select e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey - from FisAssemblyCfgErp e - join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId - where e.NewVersionId is null - and ep.PartCode is not null - and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc.PartCode) - "; - erp2partList = _newJitDapperRepository.GetListBySql(erp2partSql, true); + PartLargeType partLargeType = new PartLargeType(); + partLargeType.LargeTypeCode = item.DicItemCode; //零件大类 + partLargeType.LargeTypeName = item.DicItemName; + partLargeType.Group = item.DicItemSort1; //分组 + partLargeType.ProductLine = item.DicItemSort2; //产线 + partLargeType.VehicleModel = item.DicItemSort3; //车型 + _partLargeTypeList.Add(partLargeType); } + #endregion - _r100CheckDomainSrv.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList); //整车总成内存及时刷新, ERP总成增删改时触发刷新标志 - _m100CheckDomainService.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList); - - _msgToPaiGeVehicleModelList = _dicDomainService.GetDicItems(DicTypeName.报文车型对应格拉默车型); - _r100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.R100格拉默车型对应生产线); - _m100VehicleModelProductLineList = _dicDomainService.GetDicItems(DicTypeName.M100格拉默车型对应生产线); _logger.LogDebug("重新刷新报文解析缓存!"); } @@ -532,13 +552,12 @@ namespace WY.NewJit.Job.ConsoleApp.Messages string billType = null; try { - #region 报文转换 fileName = msgReceiveObj.MessageFileName; text = msgReceiveObj.MessageContent; errorHeader = "报文校验"; string errorMsg = CheckEdiFile(text, fileName, out billType); - if (string.IsNullOrEmpty(errorMsg) == false) + if (errorMsg.HasValue()) //Edi报表格式错误 { MessageReceiveArchive msgReceArv2 = new MessageReceiveArchive(GuidGenerator.Create(), msgReceiveObj.MessageFileName, msgReceiveObj.MessageContent, ReceiveStatusEnum.ArchiveFailed, msgReceiveObj.ReceiveTime, msgReceiveObj.LastUpdateTime, msgReceiveObj.Id, "M110"); var succObj2 = _messageReceiveArchiveRepository.InsertAsync(msgReceArv2).GetAwaiter().GetResult(); @@ -552,66 +571,109 @@ namespace WY.NewJit.Job.ConsoleApp.Messages //将报文内容转换成BillR100或BillM100 var billResObj = ConvertToBill(msgReceiveObj, billType); //------------ - //更新车型、生产线 - UpdateProductLine(billResObj); - - #region 更新SerialNumStr - if (billResObj.M100Bill != null) + # region 重复报文 + if (billResObj.R100Bill != null) { - var m100 = billResObj.M100Bill; - string snStr = ServerHelper.ToSerialNumStr(m100.OnlineTime, m100.HostSN, "m100", m100.ProductLine); - billResObj.M100Bill.SetSerialNumStr(snStr); + var r100Bill = billResObj.R100Bill; + bool isRepeat = _billR100Repos.Any(itm => itm.HostSN == r100Bill.HostSN && itm.KNR == r100Bill.KNR && itm.MessageFileReceiveID != msgReceiveObj.Id); + if (isRepeat == true) + { + var succObj = _r100CheckDomainSrv.InsertR100Repeat(msgReceiveObj, r100Bill); + _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{msgReceiveObj.MessageFileName}"); + return; + } } - if (billResObj.R100Bill != null) + else if (billResObj.M100Bill != null) { - var r100 = billResObj.R100Bill; - string snStr = ServerHelper.ToSerialNumStr(r100.OnlineTime, r100.HostSN, "r100", r100.ProductLine); - billResObj.R100Bill.SetSerialNumStr(snStr); + var m100Bill = billResObj.M100Bill; + bool isRepeat = _billM100Repository.Any(itm => itm.HostSN == m100Bill.HostSN && itm.VIN == m100Bill.VIN && itm.MessageFileReceiveID != msgReceiveObj.Id); + if (isRepeat == true) + { + var succObj = _m100CheckDomainService.InsertM100RepeatBill(msgReceiveObj, m100Bill); + _logger.LogDebug(_errorMessagePrefix + $"是重复报文:{msgReceiveObj.MessageFileName}"); + return; + } } #endregion - //区分门板和柱护板 - DifferenceMenBan_ZhuHuBan(billResObj); - - //KNR前缀加两位年、预批量 - UpdatePrebatch(billResObj); + #region 更新三个零件类别,有不识别零件时直接中断程序 + string unknowPartCode = UpdatePartLargeType(billResObj); + if (unknowPartCode.HasValue()) //有不识别零件 + { + throw new Exception($"存在不识别的零件{unknowPartCode}:{msgReceiveObj.MessageFileName}"); //零件大类没有维护时,直接返回解析失败,程序执行中断,报警(不进入未知总成) + } #endregion - #region BOM解析 - errorHeader = "文件解析"; - DateTime? billOnlineTime = null; - int? billHostSN = null; - bool isSucc = false; + //根据 产线、分组,将一个报文拆分成若干R100或M100记录(同时更新生产线,单据状态是已匹配) + List billResultLst = SplitBillByGroup(billResObj); - if (billType == "R100") - { - var resu = _r100CheckDomainSrv.DoCheckR100(msgReceiveObj, billResObj.R100Bill); - billOnlineTime = billResObj.R100Bill.OnlineTime; - billHostSN = billResObj.R100Bill.HostSN; - isSucc = resu.Status; - } - else if (billType == "M100") + foreach (var billResultObj in billResultLst) //遍历多个成品件 { - var resu = _m100CheckDomainService.DoCheckM100Bill(msgReceiveObj, billResObj.M100Bill); - billOnlineTime = billResObj.M100Bill.OnlineTime; - billHostSN = billResObj.M100Bill.HostSN; - isSucc = resu.Status; - } - if (isSucc) - { - MessageReceiveArchive msgReceArv = new MessageReceiveArchive(GuidGenerator.Create(), msgReceiveObj.MessageFileName, msgReceiveObj.MessageContent, - ReceiveStatusEnum.Archived, msgReceiveObj.ReceiveTime, msgReceiveObj.LastUpdateTime, msgReceiveObj.Id, billType, billOnlineTime, billHostSN); - var succObj = _messageReceiveArchiveRepository.InsertAsync(msgReceArv).GetAwaiter().GetResult(); - if (succObj != null) + //更新车型 + UpdateVehicleModel(billResultObj); + + #region 更新SerialNumStr + if (billResultObj.M100Bill != null) { - _messageReceiveRepository.DeleteAsync(msgReceiveObj.Id).GetAwaiter().GetResult(); + var m100 = billResultObj.M100Bill; + string snStr = ServerHelper.ToSerialNumStr(m100.OnlineTime, m100.HostSN, "m100", m100.ProductLine); + billResultObj.M100Bill.SetSerialNumStr(snStr); } - else + if (billResultObj.R100Bill != null) { - throw new Exception("解析报文失败:" + msgReceiveObj.MessageFileName); + var r100 = billResultObj.R100Bill; + string snStr = ServerHelper.ToSerialNumStr(r100.OnlineTime, r100.HostSN, "r100", r100.ProductLine); + billResultObj.R100Bill.SetSerialNumStr(snStr); } - } - #endregion + #endregion + + //区分门板和柱护板 + //DifferenceMenBan_ZhuHuBan(billResultObj); + + //KNR前缀加两位年、预批量 + UpdatePrebatch(billResultObj); + + #region BOM解析 + errorHeader = "文件解析"; + DateTime? billOnlineTime = null; + int? billHostSN = null; + bool isSucc = false; + + if (billType == "R100") + { + var resu = _r100CheckDomainSrv.DoCheckR100(msgReceiveObj, billResultObj.R100Bill); + billOnlineTime = billResultObj.R100Bill.OnlineTime; + billHostSN = billResultObj.R100Bill.HostSN; + isSucc = resu.Status; + } + else if (billType == "M100") + { + var resu = _m100CheckDomainService.DoCheckM100Bill(msgReceiveObj, billResultObj.M100Bill); + billOnlineTime = billResultObj.M100Bill.OnlineTime; + billHostSN = billResultObj.M100Bill.HostSN; + isSucc = resu.Status; + } + if (isSucc) + { + MessageReceiveArchive msgReceArv = new MessageReceiveArchive(GuidGenerator.Create(), msgReceiveObj.MessageFileName, msgReceiveObj.MessageContent, + ReceiveStatusEnum.Archived, msgReceiveObj.ReceiveTime, msgReceiveObj.LastUpdateTime, msgReceiveObj.Id, billType, billOnlineTime, billHostSN); + var succObj = _messageReceiveArchiveRepository.InsertAsync(msgReceArv).GetAwaiter().GetResult(); + if (succObj != null) + { + _messageReceiveRepository.DeleteAsync(msgReceiveObj.Id).GetAwaiter().GetResult(); + } + else + { + throw new Exception("解析报文失败:" + msgReceiveObj.MessageFileName); + } + } + #endregion + + } //遍历多个成品件 + + + + } catch (Exception ex0) { @@ -627,6 +689,147 @@ namespace WY.NewJit.Job.ConsoleApp.Messages } } + /// + /// 根据 产线、分组,将一个报文拆分成若干R100或M100记录(更新主表:生产线,单据状态是已匹配) + /// + /// + /// + private List SplitBillByGroup(BillResult billResObj) + { + List billResultLst = new List(); + //按成品件拆分 + if (billResObj.R100Bill != null) + { + var r100Bill = billResObj.R100Bill; + var billPartLst = billResObj.R100Bill.BillR100Parts; //包含多个成品件 + var partGroups = billPartLst.GroupBy(itm => new { itm.PartType, itm.PartType2 }).Select(itm => new + { + ProductLine = itm.Key.PartType, + Group = itm.Key.PartType2, + PartList = itm.ToList() + }).ToList(); + + foreach (var item in partGroups) + { + var newBill = BillR100.Clone(r100Bill); + newBill.SetId(GuidGenerator.Create()); + newBill.ProductLine = item.ProductLine; + newBill.SetBillStatus(BillStatusEnum.Match); + newBill.BillR100Parts.Clear(); + newBill.BillR100Parts.AddRange(item.PartList); + billResultLst.Add(new BillResult(newBill, null)); + } + + } + else if (billResObj.M100Bill != null) + { + var m100bill = billResObj.M100Bill; + var billPartLst = billResObj.M100Bill.BillM100Parts; //包含多个成品件 + var partGroups = billPartLst.GroupBy(itm => new { itm.PartType, itm.PartType2 }).Select(itm => new + { + ProductLine = itm.Key.PartType, + Group = itm.Key.PartType2, + PartList = itm.ToList() + }).ToList(); + foreach (var item in partGroups) + { + var newBill = BillM100.Clone(m100bill); + newBill.SetId(GuidGenerator.Create()); + newBill.ProductLine = item.ProductLine; + newBill.SetBillStatus(BillStatusEnum.Match); + newBill.BillM100Parts.Clear(); + newBill.BillM100Parts.AddRange(item.PartList); + billResultLst.Add(new BillResult(null, newBill)); + } + } + return billResultLst; + } + + /// + /// 更新R100或M100子表的三个零件类型(分别更新为产线,分组,零件大类) + /// + /// + /// 存在没有识别的,返回该子件号 + private string UpdatePartLargeType(BillResult billResObj) + { + string ret = ""; + if (billResObj.R100Bill != null) + { + var billPartLst = billResObj.R100Bill.BillR100Parts; //包含多个成品件 + foreach (var billPart in billPartLst) + { + string partLargeType = billPart.PartCode.Substring(6, 3); //取客户零件代码的7-9位,是零件大类 + var partCfgObj = _partLargeTypeList.FirstOrDefault(itm => itm.LargeTypeCode == partLargeType); //是否加车型过滤//?? + if (partCfgObj != null) + { + billPart.PartType = partCfgObj.ProductLine; + billPart.PartType2 = partCfgObj.Group; + billPart.PartType3 = partCfgObj.LargeTypeCode; + } + else + { + ret = billPart.PartCode; + break; + } + } + } + else if (billResObj.M100Bill != null) + { + var billPartLst = billResObj.M100Bill.BillM100Parts; //包含多个成品件 + foreach (var billPart in billPartLst) + { + string partLargeType = billPart.PartCode.Substring(6, 3); //取客户零件代码的7-9位,是零件大类 + var partCfgObj = _partLargeTypeList.FirstOrDefault(itm => itm.LargeTypeCode == partLargeType); //是否加车型过滤//?? + if (partCfgObj != null) + { + billPart.PartType = partCfgObj.ProductLine; + billPart.PartType2 = partCfgObj.Group; + billPart.PartType3 = partCfgObj.LargeTypeCode; + } + else + { + ret = billPart.PartCode; + break; + } + } + } + return ret; + } + + /// + /// 插入未知总成 + /// + /// + /// + //private bool InsertUnAssembly(BillResult billResObj) + //{ + // if (billResObj.R100Bill != null) + // { + // var r100Bill = billResObj.R100Bill; + // r100Bill.SetAssemblyID(null); + // r100Bill.SetBillStatus(BillStatusEnum.NotMatch); + // var succObj1 = _billR100Repos.InsertAsync(r100Bill).GetAwaiter().GetResult(); + + // var succObj = _r100CheckDomainSrv.InsertUnknownAssembly(r100Bill); + // _logger.LogDebug(_errorMessagePrefix + $"部分零件不识别,进入未知总成:{r100Bill.KNR}-{r100Bill.HostSN}"); + + // } + // else if (billResObj.M100Bill != null) + // { + // var m100Bill = billResObj.M100Bill; + // m100Bill.SetAssemblyID(null); + // m100Bill.SetBillStatus(BillStatusEnum.NotMatch); + // var succObj1 = _billM100Repository.InsertAsync(m100Bill).GetAwaiter().GetResult(); + + // var succObj = _m100CheckDomainService.InsertUnknownAssembly(m100Bill); + // _logger.LogDebug(_errorMessagePrefix + $"部分零件不识别,进入未知总成:{m100Bill.VIN}-{m100Bill.HostSN}"); + + // } + // return true; + //} + + + /// /// 校验报文(出错时返回) /// @@ -845,91 +1048,91 @@ namespace WY.NewJit.Job.ConsoleApp.Messages } /// - /// 更新车型、生产线 + /// 更新车型 /// /// - private void UpdateProductLine(BillResult billResObj) + private void UpdateVehicleModel(BillResult billResObj) { - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) + if (billResObj.R100Bill != null) { - if (billResObj.R100Bill != null) + var bill = billResObj.R100Bill; + string ediVehicleModel = bill.VehicleModelCode; //报文车型 + //报文车型转换为零件生产工厂车型:3H 转 CC;FY 转 Q5 + var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); + if (obj1 != null) { - var bill = billResObj.R100Bill; - string ediVehicleModel = bill.VehicleModelCode; //报文车型 - //报文车型转换为零件生产工厂车型:3H 转 CC;FY 转 Q5 - var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); - if (obj1 != null) + string paigeVehicleModel = obj1.DicItemName; // CC + if (paigeVehicleModel.Contains('-')) //去掉B8L-PHEV中的-PHEV { - string paigeVehicleModel = obj1.DicItemName; // CC - if (paigeVehicleModel.Contains('-')) //去掉B8L-PHEV中的-PHEV - { - paigeVehicleModel = paigeVehicleModel.Split('-')[0]; - } - - bill.SetVehicleModelCode(paigeVehicleModel); - //根据车型取对应生产线 - var obj2 = _r100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel); - if (obj2 != null) - { - string productLine = obj2.DicItemName; - bill.SetProductLine(productLine); - } - else - { - SetProductLineByExcept(bill); - string errorMsg = $"零件生产工厂车型{paigeVehicleModel}没有对应的生产线!"; - //throw new Exception(errorMsg); - _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.R100); - _logger.LogError(errorMsg); - } - } - else - { - SetProductLineByExcept(bill); - string errorMsg = $"报文车型{ediVehicleModel}没有对应的零件生产工厂车型!!KNR={bill.KNR}【不终止错误】"; - //throw new Exception(errorMsg); - _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.R100); - _logger.LogError(errorMsg); + paigeVehicleModel = paigeVehicleModel.Split('-')[0]; } + + bill.SetVehicleModelCode(paigeVehicleModel); + + //string partType2 = bill.BillR100Parts.Count > 0 ? bill.BillR100Parts[0].PartType2 : ""; + + ////根据车型、产成品 取对应生产线 + //var obj2 = _r100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel && itm.DicItemSort1 == partType2); + //if (obj2 != null) + //{ + // string productLine = obj2.DicItemName; + // bill.SetProductLine(productLine); + //} + //else + //{ + // SetProductLineByExcept(bill); + // string errorMsg = $"零件生产工厂车型{paigeVehicleModel}和成品件{partType2}没有对应的生产线!"; + // //throw new Exception(errorMsg); + // _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.R100); + // _logger.LogError(errorMsg); + //} } - else if (billResObj.M100Bill != null) + else { - var bill = billResObj.M100Bill; - string ediVehicleModel = bill.VehicleModelCode; //报文车型 - //车型转换:3H 转 CC - var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); - if (obj1 != null) - { - string paigeVehicleModel = obj1.DicItemName; // CC - if (paigeVehicleModel.Contains('-')) //去掉B8L-PHEV中的-PHEV - { - paigeVehicleModel = paigeVehicleModel.Split('-')[0]; - } - bill.SetVehicleModelCode(paigeVehicleModel); - //根据车型取对应生产线 - var obj2 = _m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel); - if (obj2 != null) - { - string productLine = obj2.DicItemName; - bill.SetProductLine(productLine); - } - else - { - SetProductLineByExcept(bill); - string errorMsg = $"零件生产工厂车型{paigeVehicleModel}没有对应的生产线!"; - //throw new Exception(errorMsg); - _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.M100); - _logger.LogError(errorMsg); - } - } - else //报文车型 没有对应的 格拉默车型 + //SetProductLineByExcept(bill); + //string errorMsg = $"报文车型{ediVehicleModel}没有对应的零件生产工厂车型!!KNR={bill.KNR}【不终止错误】"; + //_logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.R100); + //_logger.LogError(errorMsg); + } + } + else if (billResObj.M100Bill != null) + { + var bill = billResObj.M100Bill; + string ediVehicleModel = bill.VehicleModelCode; //报文车型 + //车型转换:3H 转 CC + var obj1 = _msgToPaiGeVehicleModelList.FirstOrDefault(itm => itm.DicItemCode == ediVehicleModel); + if (obj1 != null) + { + string paigeVehicleModel = obj1.DicItemName; // CC + if (paigeVehicleModel.Contains('-')) //去掉B8L-PHEV中的-PHEV { - SetProductLineByExcept(bill); - string errorMsg = $"报文车型{ediVehicleModel}没有对应的零件生产工厂车型!"; - //throw new Exception(errorMsg); - _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.M100); - _logger.LogError(errorMsg); + paigeVehicleModel = paigeVehicleModel.Split('-')[0]; } + bill.SetVehicleModelCode(paigeVehicleModel); + //string partType2 = bill.BillM100Parts.Count > 0 ? bill.BillM100Parts[0].PartType2 : ""; + + ////根据车型、产成品 取对应生产线 + //var obj2 = _m100VehicleModelProductLineList.FirstOrDefault(itm => itm.DicItemCode == paigeVehicleModel && itm.DicItemSort1 == partType2); + //if (obj2 != null) + //{ + // string productLine = obj2.DicItemName; + // bill.SetProductLine(productLine); + //} + //else + //{ + // SetProductLineByExcept(bill); + // string errorMsg = $"零件生产工厂车型{paigeVehicleModel}和成品件{partType2}没有对应的生产线!"; + // //throw new Exception(errorMsg); + // _logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.M100); + // _logger.LogError(errorMsg); + //} + } + else //报文车型 没有对应的 格拉默车型 + { + //SetProductLineByExcept(bill); + //string errorMsg = $"报文车型{ediVehicleModel}没有对应的零件生产工厂车型!"; + //_logRemindDomainService.WriteLogRemind("报文格式转换", errorMsg, LogTypeEnum.M100); + //_logger.LogError(errorMsg); } } } @@ -956,79 +1159,79 @@ namespace WY.NewJit.Job.ConsoleApp.Messages /// //区分门板和柱护板 /// /// - private void DifferenceMenBan_ZhuHuBan(BillResult billResObj) - { - //根据物料组区分门板、柱护板, 柱护板不参与匹配,但是参与发货 - if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) - { - if (billResObj.R100Bill != null) - { - if (billResObj.R100Bill.VehicleModelCode == "Q5") - { - foreach (BillR100Part billPart in billResObj.R100Bill.BillR100Parts) - { - PartCfg partObj = _partCfgList.FirstOrDefault(itm => itm.PartCode == billPart.PartCode); - if (partObj != null) - { - billPart.PartType = partObj.PartType; - billPart.Description = partObj.PartType == "2" ? "柱护板" : "控制件"; - billPart.PartType2 = partObj.PartType2; - } - else - { - billPart.PartType = "1"; - billPart.Description = "控制件"; - string errorMsg = $"R100结算件{billPart.PartCode}在结算件信息表中不存在!KNR={billResObj.R100Bill.KNR}"; - //throw new Exception(errorMsg); ////???? 此处需要优化,不触发异常,直接入库 - _logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.R100); - _logger.LogError(errorMsg); - } - } - } - else //除Q5,其它车型没有柱护板 - { - foreach (BillR100Part partItm in billResObj.R100Bill.BillR100Parts) - { - partItm.PartType = "1"; - partItm.Description = "控制件"; - } - } - } - else if (billResObj.M100Bill != null) - { - if (billResObj.M100Bill.VehicleModelCode == "Q5") - { - foreach (BillM100Part billPart in billResObj.M100Bill.BillM100Parts) - { - PartCfg partObj = _partCfgList.FirstOrDefault(itm => itm.PartCode == billPart.PartCode); - if (partObj != null) - { - billPart.PartType = partObj.PartType; - billPart.Description = partObj.PartType == "2" ? "柱护板" : "控制件"; - billPart.PartType2 = partObj.PartType2; - } - else - { - billPart.PartType = "1"; - billPart.Description = "控制件"; - string errorMsg = $"M100结算件{billPart.PartCode}在结算件信息表中不存在!VIN={billResObj.M100Bill.VIN}"; - _logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.M100); - _logger.LogError(errorMsg); - //throw new Exception(errorMsg); - } - } - } - else - { - foreach (BillM100Part partItm in billResObj.M100Bill.BillM100Parts) - { - partItm.PartType = "1"; - partItm.Description = "控制件"; - } - } - } - } - } + //private void DifferenceMenBan_ZhuHuBan(BillResult billResObj) + //{ + // //根据物料组区分门板、柱护板, 柱护板不参与匹配,但是参与发货 + // if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格) + // { + // if (billResObj.R100Bill != null) + // { + // if (billResObj.R100Bill.VehicleModelCode == "Q5") + // { + // foreach (BillR100Part billPart in billResObj.R100Bill.BillR100Parts) + // { + // PartCfg partObj = _partCfgList.FirstOrDefault(itm => itm.PartCode == billPart.PartCode); + // if (partObj != null) + // { + // billPart.PartType = partObj.PartType; + // billPart.Description = partObj.PartType == "2" ? "柱护板" : "控制件"; + // billPart.PartType2 = partObj.PartType2; + // } + // else + // { + // billPart.PartType = "1"; + // billPart.Description = "控制件"; + // string errorMsg = $"R100结算件{billPart.PartCode}在结算件信息表中不存在!KNR={billResObj.R100Bill.KNR}"; + // //throw new Exception(errorMsg); ////???? 此处需要优化,不触发异常,直接入库 + // _logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.R100); + // _logger.LogError(errorMsg); + // } + // } + // } + // else //除Q5,其它车型没有柱护板 + // { + // foreach (BillR100Part partItm in billResObj.R100Bill.BillR100Parts) + // { + // partItm.PartType = "1"; + // partItm.Description = "控制件"; + // } + // } + // } + // else if (billResObj.M100Bill != null) + // { + // if (billResObj.M100Bill.VehicleModelCode == "Q5") + // { + // foreach (BillM100Part billPart in billResObj.M100Bill.BillM100Parts) + // { + // PartCfg partObj = _partCfgList.FirstOrDefault(itm => itm.PartCode == billPart.PartCode); + // if (partObj != null) + // { + // billPart.PartType = partObj.PartType; + // billPart.Description = partObj.PartType == "2" ? "柱护板" : "控制件"; + // billPart.PartType2 = partObj.PartType2; + // } + // else + // { + // billPart.PartType = "1"; + // billPart.Description = "控制件"; + // string errorMsg = $"M100结算件{billPart.PartCode}在结算件信息表中不存在!VIN={billResObj.M100Bill.VIN}"; + // _logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.M100); + // _logger.LogError(errorMsg); + // //throw new Exception(errorMsg); + // } + // } + // } + // else + // { + // foreach (BillM100Part partItm in billResObj.M100Bill.BillM100Parts) + // { + // partItm.PartType = "1"; + // partItm.Description = "控制件"; + // } + // } + // } + // } + //} /// /// KNR前缀加两位年、预批量 @@ -1070,11 +1273,53 @@ namespace WY.NewJit.Job.ConsoleApp.Messages #endregion + } public class BillResult { public BillR100 R100Bill { get; set; } public BillM100 M100Bill { get; set; } + + public BillResult() + { + + } + public BillResult(BillR100 r100Bill, BillM100 m100Bill) + { + R100Bill = r100Bill; + M100Bill = m100Bill; + } + } + + /// + /// 零件大类 + /// + public class PartLargeType + { + /// + /// 零件大类 + /// + public string LargeTypeCode { get; set; } + + /// + /// 大类名称 + /// + public string LargeTypeName { get;set; } + + /// + /// 分组 + /// + public string Group { get; set; } + + /// + /// 产线 + /// + public string ProductLine { get; set; } + + /// + /// 车型 + /// + public string VehicleModel { get; set; } } diff --git a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/appsettings.json b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/appsettings.json index 2497939..f8ea5ce 100644 --- a/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/appsettings.json +++ b/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Job.ConsoleApp/appsettings.json @@ -6,7 +6,7 @@ "ConfigDic": { "CurrentVersion": "PaiGe", - "TransferFileCountPerTime": 10, + "TransferFileCountPerTime": 1, //每次读取的报文数 "ParseAssemblyCycleCount": 4, "MsgTransmessionTimer": { "IsStop": false, diff --git a/Modules/新版JIT或JIS系统服务端/src/src报文解析.rar b/Modules/新版JIT或JIS系统服务端/src/src报文解析.rar new file mode 100644 index 0000000..90dcb7d Binary files /dev/null and b/Modules/新版JIT或JIS系统服务端/src/src报文解析.rar differ