@ -25,6 +25,8 @@ using Volo.Abp.EventBus.Distributed;
using WY.NewJit.SettleAccountFis ;
using WY.NewJit.SettleAccountFis ;
using WY.NewJit.MsgTransmission.PaiGe ;
using WY.NewJit.MsgTransmission.PaiGe ;
using WY.NewJit.PrintTable ;
using WY.NewJit.PrintTable ;
using WY.NewJit.EdiReceive.Services ;
using WY.NewJit.EdiReceive.Entitys ;
namespace WY.NewJit.MsgCheck
namespace WY.NewJit.MsgCheck
{
{
@ -61,12 +63,12 @@ namespace WY.NewJit.MsgCheck
/// <summary>
/// <summary>
/// R100报文解析及校验领域服务
/// R100报文解析及校验领域服务
/// </summary>
/// </summary>
private readonly R100CheckDomainService _ r100CheckDomainSrv ;
//private readonly R100CheckDomainService _r100CheckDomainSrv;
/// <summary>
/// <summary>
/// M100报文解析及校验领域服务
/// M100报文解析及校验领域服务
/// </summary>
/// </summary>
private readonly M100CheckDomainService _ m100CheckDomainService ;
//private readonly M100CheckDomainService _m100CheckDomainService;
/// <summary>
/// <summary>
/// 日志
/// 日志
@ -91,12 +93,28 @@ namespace WY.NewJit.MsgCheck
/// <summary>
/// <summary>
/// 零件基本信息
/// 零件基本信息
/// </summary>
/// </summary>
private readonly IRepository < PartCfg , Guid > _ partCfgRepository ;
//private readonly IRepository<PartCfg, Guid> _partCfgRepository;
/// <summary>
/// 缓存管理 领域服务
/// </summary>
private readonly HQ_CacheManagerDomainService _ hqCacheManagerDomainService ;
/// <summary>
/// 报文解析 领域服务
/// </summary>
private readonly EdiParseDomainService _ ediParseDomainService ;
/// <summary>
/// 导入记录仓储
/// </summary>
private readonly IRepository < ImportRecord , Guid > _ importRecordRepository ;
/// <summary>
/// <summary>
/// 结算件切换列表
/// 结算件切换列表
/// </summary>
/// </summary>
private List < PartSwitch > _ partSwitchList = new List < PartSwitch > ( ) ;
//private List<PartSwitch> _partSwitchList = new List<PartSwitch>();
/// <summary>
/// <summary>
/// 结算件信息列表
/// 结算件信息列表
@ -131,13 +149,16 @@ namespace WY.NewJit.MsgCheck
IBlobContainer < OurFileContainer > blobContainer ,
IBlobContainer < OurFileContainer > blobContainer ,
IRepository < AssemblyCfgErp , Guid > assemblyCfgErpRepository ,
IRepository < AssemblyCfgErp , Guid > assemblyCfgErpRepository ,
MsgTransmissionAppService msgTransmissionAppService ,
MsgTransmissionAppService msgTransmissionAppService ,
R100CheckDomainService r100CheckDomainSrv ,
//R100CheckDomainService r100CheckDomainSrv,
M100CheckDomainService m100CheckDomainService ,
//M100CheckDomainService m100CheckDomainService,
IDistributedEventBus distributedEventBus ,
IDistributedEventBus distributedEventBus ,
IRepository < PartCfg , Guid > partCfgRepository ,
//IRepository<PartCfg, Guid> partCfgRepository,
IRepository < WaitPrint , Guid > waitPrintRepository ,
IRepository < WaitPrint , Guid > waitPrintRepository ,
M100DomainService m100DomainService
M100DomainService m100DomainService ,
)
HQ_CacheManagerDomainService hqCacheManagerDomainService
,
EdiParseDomainService ediParseDomainService ,
IRepository < ImportRecord , Guid > importRecordRepository )
{
{
_ UnknownAssemblyRepository = UnknownAssemblyRepository ;
_ UnknownAssemblyRepository = UnknownAssemblyRepository ;
_ UnknownAssemblyPartRepository = UnknownAssemblyPartRepository ;
_ UnknownAssemblyPartRepository = UnknownAssemblyPartRepository ;
@ -154,12 +175,15 @@ namespace WY.NewJit.MsgCheck
_ blobContainer = blobContainer ;
_ blobContainer = blobContainer ;
_ assemblyCfgErpRepository = assemblyCfgErpRepository ;
_ assemblyCfgErpRepository = assemblyCfgErpRepository ;
_ msgTransmissionAppService = msgTransmissionAppService ;
_ msgTransmissionAppService = msgTransmissionAppService ;
_ r100CheckDomainSrv = r100CheckDomainSrv ;
//_r100CheckDomainSrv = r100CheckDomainSrv;
_ m100CheckDomainService = m100CheckDomainService ;
//_m100CheckDomainService = m100CheckDomainService;
_d istributedEventBus = distributedEventBus ;
_d istributedEventBus = distributedEventBus ;
_ partCfgRepository = partCfgRepository ;
//_partCfgRepository = partCfgRepository;
_ waitPrintRepository = waitPrintRepository ;
_ waitPrintRepository = waitPrintRepository ;
_ m100DomainService = m100DomainService ;
_ m100DomainService = m100DomainService ;
_ hqCacheManagerDomainService = hqCacheManagerDomainService ;
_ ediParseDomainService = ediParseDomainService ;
_ importRecordRepository = importRecordRepository ;
}
}
#endregion
#endregion
@ -174,8 +198,8 @@ namespace WY.NewJit.MsgCheck
string sqlCnt = @ "
string sqlCnt = @ "
with b as
with b as
(
(
select Id , HostSN , KNR , ' ' as VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus from FisBillR100 where BillStatus = 1
- - select Id , HostSN , KNR , ' ' as VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus from FisBillR100 where BillStatus = 1
union all
- - union all
select Id , HostSN , KNR , VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus from FisBillM100 where BillStatus = 1
select Id , HostSN , KNR , VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus from FisBillM100 where BillStatus = 1
)
)
, d as
, d as
@ -188,7 +212,7 @@ select * from
from FisUnknownAssembly a
from FisUnknownAssembly a
join b on a . BillID = b . Id
join b on a . BillID = b . Id
left join d on b . VehicleModelCode = d . DicItemCode
left join d on b . VehicleModelCode = d . DicItemCode
where a . IsDeleted < > 1 { 0 }
where a . IsDeleted = 0 { 0 }
) t
) t
";
";
@ -196,8 +220,8 @@ select * from
with b as
with b as
(
(
select Id , HostSN , KNR , ' ' as VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus , Description , SerialNumStr from FisBillR100 where BillStatus = 1
- - select Id , HostSN , KNR , ' ' as VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus , Description , SerialNumStr from FisBillR100 where BillStatus = 1
union all
- - union all
select Id , HostSN , KNR , VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus , Description , SerialNumStr from FisBillM100 where BillStatus = 1
select Id , HostSN , KNR , VIN , AssemblyID , OnlineTime , ReceiveTime , VehicleModelCode , ProductLine , [ Version ] , BillStatus , Description , SerialNumStr from FisBillM100 where BillStatus = 1
)
)
, d as
, d as
@ -211,7 +235,7 @@ select * from
from FisUnknownAssembly a
from FisUnknownAssembly a
join b on a . BillID = b . Id
join b on a . BillID = b . Id
left join d on b . VehicleModelCode = d . DicItemCode
left join d on b . VehicleModelCode = d . DicItemCode
where a . IsDeleted < > 1 { 0 }
where a . IsDeleted = 0 { 0 }
) t where row_number between { 1 } and { 2 }
) t where row_number between { 1 } and { 2 }
";
";
string where = "" ;
string where = "" ;
@ -281,28 +305,28 @@ select * from
return ret ;
return ret ;
}
}
[UnitOfWork]
//[UnitOfWork]
private bool OneParseAsync ( Guid unknownAssemblyId )
//private bool OneParseAsync(Guid unknownAssemblyId)
{
//{
bool isMatch = false ;
// bool isMatch = false;
//根据未知总成ID取单据Id
// //根据未知总成ID取单据Id
UnknownAssembly unknownAssemblyObj = _ UnknownAssemblyRepository . GetAsync ( unknownAssemblyId , false ) . GetAwaiter ( ) . GetResult ( ) ;
// UnknownAssembly unknownAssemblyObj = _UnknownAssemblyRepository.GetAsync(unknownAssemblyId, false).GetAwaiter().GetResult();
if ( unknownAssemblyObj . ScanPoint = = "R100" ) //!!
// if (unknownAssemblyObj.ScanPoint == "R100") //!!
{
// {
}
// }
else if ( unknownAssemblyObj . ScanPoint = = "M100" )
// else if (unknownAssemblyObj.ScanPoint == "M100")
{
// {
//天合版本的匹配总成算法:
// //天合版本的匹配总成算法:
//匹配上时:插入整车总成配置表、更新单据表的整车总成ID字段、返回true
// //匹配上时:插入整车总成配置表、更新单据表的整车总成ID字段、返回true
//匹配不上时返回false
// //匹配不上时返回false
//isMatch = _msgTransmissionAppServiceTianHe.MatchAssembly_Init(unknownAssemblyObj.BillID);
// //isMatch = _msgTransmissionAppServiceTianHe.MatchAssembly_Init(unknownAssemblyObj.BillID);
var billObj = _ billM100Repository . GetAsync ( unknownAssemblyObj . BillID ) . GetAwaiter ( ) . GetResult ( ) ;
// var billObj = _billM100Repository.GetAsync(unknownAssemblyObj.BillID).GetAwaiter().GetResult();
_ m100CheckDomainService . DoMatchAssembly ( billObj ) ;
// _m100CheckDomainService.DoMatchAssembly(billObj);
}
// }
unknownAssemblyObj . SetExtraProperties ( "1" ) ;
// unknownAssemblyObj.SetExtraProperties("1");
_ UnknownAssemblyRepository . UpdateAsync ( unknownAssemblyObj ) . GetAwaiter ( ) . GetResult ( ) ;
// _UnknownAssemblyRepository.UpdateAsync(unknownAssemblyObj).GetAwaiter().GetResult();
return isMatch ;
// return isMatch;
}
//}
private FISVersionEto ConvertToFISVersion ( List < BillM100 > m100BillList )
private FISVersionEto ConvertToFISVersion ( List < BillM100 > m100BillList )
{
{
@ -434,147 +458,147 @@ select * from
return isEqual ;
return isEqual ;
}
}
private void DoInitLoadCache ( )
//private void DoInitLoadCache()
{
//{
//取全部整车总成ID
// //取全部整车总成ID
string vehicleSql = "select Id, VehicleModelCode as VehicleModel from FisAssemblyCfgVehicle v where NewVersionId is null order by CreationTime desc" ;
// string vehicleSql = "select Id, VehicleModelCode as VehicleModel from FisAssemblyCfgVehicle v where NewVersionId is null order by CreationTime desc";
List < VehicleAssemblyMainList > vehicleAssemblyIdList = _ newJitDapperRepository . GetListBySql < VehicleAssemblyMainList > ( vehicleSql , true ) ;
// List<VehicleAssemblyMainList> vehicleAssemblyIdList = _newJitDapperRepository.GetListBySql<VehicleAssemblyMainList>(vehicleSql, true);
//取全部零件:按整车总成Id、零件编码分组汇总数量
// //取全部零件:按整车总成Id、零件编码分组汇总数量
const string vehicle2PartSql = @ "
// const string vehicle2PartSql = @ "
select v . Id as VehicleAssemblyId , ep . PartCode , sum ( ep . PartNum ) as PartNum
// select v.Id as VehicleAssemblyId, ep.PartCode, sum(ep.PartNum) as PartNum
from FisAssemblyCfgVehicle v
// from FisAssemblyCfgVehicle v
join FisAssemblyCfgVehicleChild vc on v . Id = vc . AssemblyCfgVehicleId
// join FisAssemblyCfgVehicleChild vc on v.Id = vc.AssemblyCfgVehicleId
join FisAssemblyCfgErp e on vc . ErpAssemblyId = e . Id
// join FisAssemblyCfgErp e on vc.ErpAssemblyId = e.Id
join FisAssemblyCfgPart ep on e . Id = ep . AssemblyCfgErpId
// 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 )
// 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 v.NewVersionId is null
and ep . PartCode is not null
// and ep.PartCode is not null
group by v . Id , ep . PartCode
// group by v.Id, ep.PartCode
order by v . Id , ep . PartCode
// order by v.Id, ep.PartCode
";
// ";
var vehicle2partList = _ newJitDapperRepository . GetListBySql < AssemblyCfgVehicle2Part > ( vehicle2PartSql , true ) ;
// var vehicle2partList = _newJitDapperRepository.GetListBySql<AssemblyCfgVehicle2Part>(vehicle2PartSql, true);
//取Erp总成
// //取Erp总成
string erpMainSql = "select Id, VehicleModel from FisAssemblyCfgErp where NewVersionId is null order by ErpAssemblyVersion, CreationTime desc" ;
// string erpMainSql = "select Id, VehicleModel from FisAssemblyCfgErp where NewVersionId is null order by ErpAssemblyVersion, CreationTime desc";
List < ErpAssemblyMain > erpAssemblyMainList = _ newJitDapperRepository . GetListBySql < ErpAssemblyMain > ( erpMainSql , true ) ;
// List<ErpAssemblyMain> erpAssemblyMainList = _newJitDapperRepository.GetListBySql<ErpAssemblyMain>(erpMainSql, true);
List < AssemblyCfgErp2Part > erp2partList = new List < AssemblyCfgErp2Part > ( ) ;
// List<AssemblyCfgErp2Part> erp2partList = new List<AssemblyCfgErp2Part>();
if ( ConfigDic . CurrentVersion = = ConfigDicVersionOption . 派 格 )
// if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格)
{
// {
//取所有零件(IsDisable = 1时表示不需要解析BOM)
// //取所有零件(IsDisable = 1时表示不需要解析BOM)
string erp2partSql = @ "
// string erp2partSql = @ "
select e . GroupId , e . Id as ErpAssemblyId , e . ErpAssemblyCode , ep . Id as PartId , ep . PartCode , ep . PartNum , ep . IsKey
// select e.GroupId, e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey
from FisAssemblyCfgErp e
// from FisAssemblyCfgErp e
join FisAssemblyCfgPart ep on e . Id = ep . AssemblyCfgErpId
// join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId
where ep . PartCode is not null
// where ep.PartCode is not null
and not exists ( select PartCode from FisPartCfg pc where IsDisable = 1 and ep . PartCode = pc . PartCode )
// and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc .PartCode)
";
// ";
erp2partList = _ newJitDapperRepository . GetListBySql < AssemblyCfgErp2Part > ( erp2partSql , true ) ;
// erp2partList = _newJitDapperRepository.GetListBySql<AssemblyCfgErp2Part>(erp2partSql, true);
//结算件切换列表
// //结算件切换列表
string partSwitchSql = "select SourcePartCode,TargetPartCode,ActiveBeginTime,ActiveEndTime from FisPartSwitch" ;
// string partSwitchSql = "select SourcePartCode,TargetPartCode,ActiveBeginTime,ActiveEndTime from FisPartSwitch";
_ partSwitchList = _ newJitDapperRepository . GetListBySql < PartSwitch > ( partSwitchSql , true ) ;
// _partSwitchList = _newJitDapperRepository.GetListBySql<PartSwitch>(partSwitchSql, true);
}
// }
else
// else
{
// {
//取所有零件(IsDisable = 1时表示不需要解析BOM)
// //取所有零件(IsDisable = 1时表示不需要解析BOM)
string erp2partSql = @ "
// string erp2partSql = @ "
select e . Id as ErpAssemblyId , e . ErpAssemblyCode , ep . Id as PartId , ep . PartCode , ep . PartNum , ep . IsKey
// select e.Id as ErpAssemblyId, e.ErpAssemblyCode, ep.Id as PartId, ep.PartCode, ep.PartNum, ep.IsKey
from FisAssemblyCfgErp e
// from FisAssemblyCfgErp e
join FisAssemblyCfgPart ep on e . Id = ep . AssemblyCfgErpId
// join FisAssemblyCfgPart ep on e.Id = ep.AssemblyCfgErpId
where e . NewVersionId is null
// where e.NewVersionId is null
and ep . PartCode is not null
// and ep.PartCode is not null
and not exists ( select PartCode from FisPartCfg pc where IsDisable = 1 and ep . PartCode = pc . PartCode )
// and not exists (select PartCode from FisPartCfg pc where IsDisable = 1 and ep.PartCode = pc .PartCode)
";
// ";
erp2partList = _ newJitDapperRepository . GetListBySql < AssemblyCfgErp2Part > ( erp2partSql , true ) ;
// erp2partList = _newJitDapperRepository.GetListBySql<AssemblyCfgErp2Part>(erp2partSql, true);
}
// }
_ r100CheckDomainSrv . InitPub ( vehicleAssemblyIdList , vehicle2partList , erpAssemblyMainList , erp2partList , _ partSwitchList ) ; //整车总成内存及时刷新, ERP总成增删改时触发刷新标志
// _r100CheckDomainSrv.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList); //整车总成内存及时刷新, ERP总成增删改时触发刷新标志
_ m100CheckDomainService . InitPub ( vehicleAssemblyIdList , vehicle2partList , erpAssemblyMainList , erp2partList , _ partSwitchList ) ;
// _m100CheckDomainService.InitPub(vehicleAssemblyIdList, vehicle2partList, erpAssemblyMainList, erp2partList, _partSwitchList);
#region 无法缓存的
// #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"; //,DaXiaoLiangGang,DoorPlankCode,MaterialDescription,SAPMaterialNum
_ partCfgList = _ newJitDapperRepository . GetListBySql < PartCfg > ( partCfgSql , true ) ;
// _partCfgList = _newJitDapperRepository.GetListBySql<PartCfg>(partCfgSql, true);
#endregion
// #endregion
}
//}
private void DifferenceMenBan_ZhuHuBan ( BillResult billResObj )
//private void DifferenceMenBan_ZhuHuBan(BillResult billResObj)
{
//{
//根据物料组区分门板、柱护板, 柱护板不参与匹配,但是参与发货
// //根据物料组区分门板、柱护板, 柱护板不参与匹配,但是参与发货
if ( ConfigDic . CurrentVersion = = ConfigDicVersionOption . 派 格 )
// if (ConfigDic.CurrentVersion == ConfigDicVersionOption.派格)
{
// {
if ( billResObj . R100Bill ! = null )
// if (billResObj.R100Bill != null)
{
// {
if ( billResObj . R100Bill . VehicleModelCode = = "Q5" )
// if (billResObj.R100Bill.VehicleModelCode == "Q5")
{
// {
foreach ( BillR100Part billPart in billResObj . R100Bill . BillR100Parts )
// foreach (BillR100Part billPart in billResObj.R100Bill.BillR100Parts)
{
// {
PartCfg partObj = _ partCfgList . FirstOrDefault ( itm = > itm . PartCode = = billPart . PartCode ) ;
// PartCfg partObj = _partCfgList.FirstOrDefault(itm = > itm.PartCode = = billPart.PartCode);
if ( partObj ! = null )
// if (partObj != null)
{
// {
billPart . PartType = partObj . PartType ;
// billPart.PartType = partObj.PartType;
billPart . Description = partObj . PartType = = "2" ? "柱护板" : "控制件" ;
// billPart.Description = partObj.PartType = = "2" ? "柱护板" : "控制件";
billPart . PartType2 = partObj . PartType2 ;
// billPart.PartType2 = partObj.PartType2;
}
// }
else
// else
{
// {
billPart . PartType = "1" ;
// billPart.PartType = "1";
billPart . Description = "控制件" ;
// billPart.Description = "控制件";
string errorMsg = $"R100结算件{billPart.PartCode}在结算件信息表中不存在!KNR={billResObj.R100Bill.KNR}" ;
// string errorMsg = $"R100结算件{billPart.PartCode}在结算件信息表中不存在!KNR={billResObj.R100Bill.KNR}";
//throw new Exception(errorMsg); ////???? 此处需要优化,不触发异常,直接入库
// //throw new Exception(errorMsg); ////???? 此处需要优化,不触发异常,直接入库
//_logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.R100);
// //_logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.R100);
_l ogger . LogError ( errorMsg ) ;
// _logger.LogError(errorMsg);
}
// }
}
// }
}
// }
else //除Q5,其它车型没有柱护板
// else //除Q5,其它车型没有柱护板
{
// {
foreach ( BillR100Part partItm in billResObj . R100Bill . BillR100Parts )
// foreach (BillR100Part partItm in billResObj.R100Bill.BillR100Parts)
{
// {
partItm . PartType = "1" ;
// partItm.PartType = "1";
partItm . Description = "控制件" ;
// partItm.Description = "控制件";
}
// }
}
// }
}
// }
else if ( billResObj . M100Bill ! = null )
// else if (billResObj.M100Bill != null)
{
// {
if ( billResObj . M100Bill . VehicleModelCode = = "Q5" )
// if (billResObj.M100Bill.VehicleModelCode == "Q5")
{
// {
foreach ( BillM100Part billPart in billResObj . M100Bill . BillM100Parts )
// foreach (BillM100Part billPart in billResObj.M100Bill.BillM100Parts)
{
// {
PartCfg partObj = _ partCfgList . FirstOrDefault ( itm = > itm . PartCode = = billPart . PartCode ) ;
// PartCfg partObj = _partCfgList.FirstOrDefault(itm = > itm.PartCode = = billPart.PartCode);
if ( partObj ! = null )
// if (partObj != null)
{
// {
billPart . PartType = partObj . PartType ;
// billPart.PartType = partObj.PartType;
billPart . Description = partObj . PartType = = "2" ? "柱护板" : "控制件" ;
// billPart.Description = partObj.PartType = = "2" ? "柱护板" : "控制件";
billPart . PartType2 = partObj . PartType2 ;
// billPart.PartType2 = partObj.PartType2;
}
// }
else
// else
{
// {
billPart . PartType = "1" ;
// billPart.PartType = "1";
billPart . Description = "控制件" ;
// billPart.Description = "控制件";
string errorMsg = $"M100结算件{billPart.PartCode}在结算件信息表中不存在!VIN={billResObj.M100Bill.VIN}" ;
// string errorMsg = $"M100结算件{billPart.PartCode}在结算件信息表中不存在!VIN={billResObj.M100Bill.VIN}";
//_logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.M100);
// //_logRemindDomainService.WriteLogRemind("报文解析", errorMsg, LogTypeEnum.M100);
_l ogger . LogError ( errorMsg ) ;
// _logger.LogError(errorMsg);
//throw new Exception(errorMsg);
// //throw new Exception(errorMsg);
}
// }
}
// }
}
// }
else
// else
{
// {
foreach ( BillM100Part partItm in billResObj . M100Bill . BillM100Parts )
// foreach (BillM100Part partItm in billResObj.M100Bill.BillM100Parts)
{
// {
partItm . PartType = "1" ;
// partItm.PartType = "1";
partItm . Description = "控制件" ;
// partItm.Description = "控制件";
}
// }
}
// }
}
// }
}
// }
}
//}
#endregion
#endregion
@ -637,22 +661,21 @@ select * from
throw new Exception ( "不是R100或M100!" ) ;
throw new Exception ( "不是R100或M100!" ) ;
}
}
//填充零件类型
//填充零件类型
if ( vehicleModel = = "Q5" )
//if (vehicleModel == "Q5")
{
//{
foreach ( UnknownAssemblyPartDto partDto in targetObj . UnknownAssemblyParts )
// foreach (UnknownAssemblyPartDto partDto in targetObj.UnknownAssemblyParts)
{
// {
var tempObj = await _ partCfgRepository . FirstOrDefaultAsync ( itm = > itm . PartCode = = partDto . PartCode ) ;
// var tempObj = await _partCfgRepository.FirstOrDefaultAsync(itm => itm.PartCode == partDto.PartCode);
if ( tempObj ! = null )
// if (tempObj != null)
{
// {
partDto . PartType = tempObj . PartType ;
// partDto.PartType = tempObj.PartType;
}
// }
else
// else
{
// {
throw new Exception ( "Q5车型的零件在零件配置中没有对应!" ) ;
// throw new Exception("Q5车型的零件在零件配置中没有对应!");
}
// }
}
// }
//}
}
ret . Item = targetObj ;
ret . Item = targetObj ;
return ret ;
return ret ;
@ -836,8 +859,8 @@ select * from
string sql = @ "
string sql = @ "
with b as
with b as
(
(
select Id from FisBillR100 where BillStatus = 1
- - select Id from FisBillR100 where BillStatus = 1
union all
- - union all
select Id from FisBillM100 where BillStatus = 1
select Id from FisBillM100 where BillStatus = 1
)
)
select a . Id from FisUnknownAssembly a where IsDeleted = 0 and BillID in ( select Id from b )
select a . Id from FisUnknownAssembly a where IsDeleted = 0 and BillID in ( select Id from b )
@ -850,89 +873,35 @@ select * from
}
}
int matchNum = 0 ;
int matchNum = 0 ;
int notMatchNum = 0 ;
int notMatchNum = 0 ;
//新版初始化缓存
DoInitLoadCache ( ) ; //新版初始化缓存
//DoInitLoadCache();
_ hqCacheManagerDomainService . InitLoadCache ( true ) ;
//取所有总成包含的子零件列表
string allAssemblyPartSql = @ "
select distinct p . PartCode
from FisAssemblyCfgGroup g
join FisAssemblyCfgErp e on g . Id = e . GroupId
join FisAssemblyCfgPart p on e . Id = p . AssemblyCfgErpId
where g . IsDisable < > 1
";
List < string > allAssemblyPartLst = _ newJitDapperRepository . GetListBySql < string > ( allAssemblyPartSql , true ) ;
foreach ( Guid selId in selLst )
foreach ( Guid selId in selLst )
{
{
//根据未知总成ID取单据Id
//根据未知总成ID取单据Id
UnknownAssembly unknownAssemblyObj = await _ UnknownAssemblyRepository . GetAsync ( selId , false ) ;
UnknownAssembly unknownAssemblyObj = await _ UnknownAssemblyRepository . GetAsync ( selId , false ) ;
if ( unknownAssemblyObj . ScanPoint = = "R100" )
{
BillM100 m100Obj = await _ billM100Repository . GetAsync ( unknownAssemblyObj . BillID , false ) ;
//根据单据Id取单据信息
if ( m100Obj . MessageFileReceiveID = = null )
BillR100 r100Obj = await _ billR100Repository . GetAsync ( unknownAssemblyObj . BillID ) ;
//Q5车型区分控制件、柱护板
BillResult billResObj = new BillResult ( ) ;
billResObj . R100Bill = r100Obj ;
DifferenceMenBan_ZhuHuBan ( billResObj ) ;
//匹配上时:插入整车总成配置表、更新单据表的整车总成ID字段、返回true
//匹配不上时返回false
bool isMatch = _ r100CheckDomainSrv . DoMatchAssembly ( r100Obj , true , true ) ;
if ( isMatch )
{
{
matchNum + + ;
throw new Exception ( "M100表的MessageFileReceiveID字段值不能为空:" + m100Obj . HostSN2 . ToString ( ) ) ;
}
}
else
ImportRecord impRecObj = await _ importRecordRepository . GetAsync ( ( Guid ) ( m100Obj . MessageFileReceiveID ) ) ;
string specExplain = impRecObj . SpecDesc ;
string colorExplain = impRecObj . VehicleModelDesc . Trim ( ) . Right ( 7 ) ;
ObjectResultDto < bool > repasingRet = await _ ediParseDomainService . ReParsing ( m100Obj , specExplain , colorExplain ) ;
if ( repasingRet . Status = = false )
{
{
notMatchNum + + ;
throw new Exception ( repasingRet . Message ) ;
var billNotExistPartLst = r100Obj . BillR100Parts . Where ( itm = > itm . PartType = = "1" & & allAssemblyPartLst . Contains ( itm . PartCode ) = = false ) . ToList ( ) ;
if ( billNotExistPartLst . Count > 0 )
{
string desc = "如下是新零件,在总成子零件中不存在:" + billNotExistPartLst . Select ( itm = > itm . PartCode ) . Distinct ( ) . JoinAsString ( "," ) ;
unknownAssemblyObj . Description = desc ;
await _ UnknownAssemblyRepository . UpdateAsync ( unknownAssemblyObj ) ;
}
}
}
}
if ( repasingRet . Item = = true )
else if ( unknownAssemblyObj . ScanPoint = = "M100" )
{
//根据单据Id取单据信息
BillM100 m100Obj = await _ billM100Repository . GetAsync ( unknownAssemblyObj . BillID ) ;
string curPL = m100Obj . ProductLine ;
string curSNStr = m100Obj . SerialNumStr ;
//Q5车型区分控制件、柱护板
BillResult billResObj = new BillResult ( ) ;
billResObj . M100Bill = m100Obj ;
DifferenceMenBan_ZhuHuBan ( billResObj ) ;
//匹配上时:插入整车总成配置表、更新单据表的整车总成ID字段、返回true
//匹配不上时返回false
bool isMatch = _ m100CheckDomainService . DoMatchAssembly ( m100Obj , true , true ) ;
if ( isMatch )
{
{
matchNum + + ;
matchNum + + ;
//判断未打印表是否有数据,有则更新,没有则插入
ObjectResultDto res = await _ m100DomainService . InsertOrUpdateWaitPrintByM100 ( m100Obj ) ;
#region 当前单据在未匹配时已经参与打印,重新解析后进入补打
//bool hasPrintData = _billM100Repository.Any(itm => itm.ProductLine == curPL && itm.SerialNumStr.CompareTo(curSNStr) > 0 && itm.BillStatus == BillStatusEnum.Publish);
//if (hasPrintData) //该单据处于未解析时,已经打印
//{
// m100Obj.NeedReplenishPrint = 1;
// await _billM100Repository.UpdateAsync(m100Obj);
//}
#endregion
}
}
else
else
{
{
notMatchNum + + ;
notMatchNum + + ;
var billNotExistPartLst = m100Obj . BillM100Parts . Where ( itm = > itm . PartType = = "1" & & allAssemblyPartLst . Contains ( itm . PartCode ) = = false ) . ToList ( ) ;
if ( billNotExistPartLst . Count > 0 )
{
string desc = "如下是新零件,在总成子零件中不存在:" + billNotExistPartLst . Select ( itm = > itm . PartCode ) . Distinct ( ) . JoinAsString ( "," ) ;
unknownAssemblyObj . Description = desc ;
await _ UnknownAssemblyRepository . UpdateAsync ( unknownAssemblyObj ) ;
}
}
}
}
} //foreach
} //foreach
@ -962,74 +931,73 @@ select * from
/// </summary>
/// </summary>
/// <param name="input"></param>
/// <param name="input"></param>
/// <returns></returns>
/// <returns></returns>
[HttpPost]
// [HttpPost]
//[UnitOfWork(true)]
// [Route("batch-parse")]
[Route("batch-parse")]
// public virtual ObjectResultDto<string> BatchParseAsync(BatchParseParam input)
public virtual ObjectResultDto < string > BatchParseAsync ( BatchParseParam input )
// {
{
// _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 进入");
_l ogger . LogDebug ( _ errorMessagePrefix + "BatchParseAsync 进入" ) ;
// //批量删除未匹配单据
//批量删除未匹配单据
// //string delSql = "delete from FisNotMatchTempBill";
//string delSql = "delete from FisNotMatchTempBill";
// // _newJitDapperRepository.ExecuteSql(delSql, null, true);
// _newJitDapperRepository.ExecuteSql(delSql, null, true);
// ObjectResultDto<string> ret = new ObjectResultDto<string>();
ObjectResultDto < string > ret = new ObjectResultDto < string > ( ) ;
// try
try
// {
{
// string sql = @"
string sql = @ "
// with b as
with b as
// (
(
// select Id, OnlineTime from FisBillM100 where BillStatus =1 {1}
select Id , OnlineTime from FisBillM100 where BillStatus = 1 { 1 }
// )
)
// select top {0} a.Id from FisUnknownAssembly a
select top { 0 } a . Id from FisUnknownAssembly a
//join b on a.BillId = b.Id
join b on a . BillId = b . Id
//where a.IsDeleted <> 1 and a.ExtraProperties is null
where a . IsDeleted < > 1 and a . ExtraProperties is null
//order by b.OnlineTime desc
order by b . OnlineTime desc
// ";
";
// int takeCount = input.TakeCount;
int takeCount = input . TakeCount ;
// string sqlWhere = "";
string sqlWhere = "" ;
// if (input.BeginDate != null && input.EndDate != null)
if ( input . BeginDate ! = null & & input . EndDate ! = null )
// {
{
// sqlWhere = "and OnlineTime between convert(datetime,'{0}', 20) and convert(datetime,'{1}', 20)";
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"));
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);
sql = string . Format ( sql , takeCount , sqlWhere ) ;
// List<Guid> selLst = _newJitDapperRepository.GetListBySql<Guid>(sql, true);
List < Guid > selLst = _ newJitDapperRepository . GetListBySql < Guid > ( sql , true ) ;
// int matchNum = 0;
int matchNum = 0 ;
// int notMatchNum = 0;
int notMatchNum = 0 ;
// //_msgTransmissionAppService.ClearPub();
//_msgTransmissionAppService.ClearPub();
// _msgTransmissionAppService.InitPub();
_ msgTransmissionAppService . InitPub ( ) ;
// foreach (Guid selId in selLst)
foreach ( Guid selId in selLst )
// {
{
// bool isMatch = OneParseAsync(selId);
bool isMatch = OneParseAsync ( selId ) ;
// if (isMatch)
if ( isMatch )
// {
{
// matchNum++;
matchNum + + ;
// }
}
// else
else
// {
{
// notMatchNum++;
notMatchNum + + ;
// }
}
// } //foreach
} //foreach
// ret.Status = true;
ret . Status = true ;
// ret.Message = $"本次共重新解析{matchNum + notMatchNum}条,其中匹配{matchNum}条、不匹配{notMatchNum}条";
ret . Message = $"本次共重新解析{matchNum + notMatchNum}条,其中匹配{matchNum}条、不匹配{notMatchNum}条" ;
// ret.Item = ret.Message;
ret . Item = ret . Message ;
// _logger.LogDebug(_errorMessagePrefix + "BatchParseAsync 完成:" + ret.Message);
_l ogger . LogDebug ( _ errorMessagePrefix + "BatchParseAsync 完成:" + ret . Message ) ;
// return ret;
return ret ;
// }
}
// catch (Exception ex)
catch ( Exception ex )
// {
{
// ret.Status = false;
ret . Status = false ;
// ret.Message = _errorMessagePrefix + "BatchParseAsync 执行出错:" + ex.Message;
ret . Message = _ errorMessagePrefix + "BatchParseAsync 执行出错:" + ex . Message ;
// _logger.LogError(ret.Message);
_l ogger . LogError ( ret . Message ) ;
// return ret;
return ret ;
// }
}
// }
}
/// <summary>
/// <summary>
/// 根据vin从天合mes系统中取erp总成编码列表
/// 根据vin从天合mes系统中取erp总成编码列表