@ -37,6 +37,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
private readonly ISysUserInfoServices _sysUserInfoServices ;
private readonly ICurrentTeamTimeServices _currentTeamTimeServices ;
private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices ;
private readonly IBoxFoamDataRealTimeServices ? _boxFoamDataRealTimeServices ;
private readonly IBoxFoamDataRealTimeHistoryServices _boxFoamDataRealTimeHistoryServices ;
private static readonly log4net . ILog log = LogManager . GetLogger ( typeof ( OldBoxFoamPageViewModel ) ) ;
Collection collection = new Collection ( ) ;
System . Timers . Timer timer2 = new System . Timers . Timer ( 3000 ) ;
@ -49,8 +52,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
_boxFoamPlanServices = App . ServiceProvider . GetService < IBoxFoamPlanServices > ( ) ;
_sysUserInfoServices = App . ServiceProvider . GetService < ISysUserInfoServices > ( ) ;
_currentTeamTimeServices = App . ServiceProvider . GetService < ICurrentTeamTimeServices > ( ) ;
// _currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>() ;
_boxFoamDataRealTimeServices = App . ServiceProvider . GetService < IBoxFoamDataRealTimeServices > ( ) ;
_boxFoamDataRecordServices = App . ServiceProvider . GetService < IBoxFoamDataRecordServices > ( ) ;
_boxFoamDataRealTimeHistoryServices = App . ServiceProvider . GetService < IBoxFoamDataRealTimeHistoryServices > ( ) ;
//AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
//timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
@ -102,9 +106,9 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
{
try
{
collection . startCollect ( ) ;
if ( c ollection. listFixtureStatus = = null ) return ;
var prderList = c ollection. listFixtureStatus ;
//Collection.startCollect() ;
if ( C ollection. listFixtureStatus = = null ) return ;
var prderList = C ollection. listFixtureStatus ;
int num = prderList . Sum ( d = > d . Yield ) ;
if ( prderList . Count = = 0 ) return ;
totalAmount = 0 ;
@ -238,298 +242,496 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
}
# endregion
Semaphore semaphore = new Semaphore ( 1 , 1 ) ;
#region 将采集到的数据保存
/// <summary>
/// 将采集到的数据保存
/// </summary>
/// <param name="mode"></param>
public async void RealTimeFoamingTask ( object? sender , ElapsedEventArgs e )
{
semaphore . WaitOne ( ) ;
try
{
string productLineCode = Appsettings . app ( "StationInfo" , "ProductLineCode" ) ;
if ( collection . listFixtureStatus = = null ) return ;
DateTime now = DateTime . Now ;
CurrentTeamTime time = await _currentTeamTimeServices . FirstAsync ( d = > d . StartTime < = now & & d . EndTime > = now ) ;
if ( time ! = null )
List < CurrentTeamTime > timeList = await _currentTeamTimeServices . QueryAsync ( d = > d . StartTime < = now & & d . EndTime > = now ) ;
if ( timeList . Count > 0 )
{
ExecHourData ( productLineCode ) ;
ExecHourData Async ( productLineCode ) ;
}
else
{
ShiftChange ( productLineCode ) ;
ShiftChange Async ( productLineCode ) ;
}
}
catch ( Exception ex )
{
Console . WriteLine ( ex . Message .ToString ( ) );
Console . WriteLine ( ex . Message );
}
finally
{
semaphore . Release ( ) ;
}
}
private async void ShiftChange ( string productLineCode )
{
//切换班组计划
var list = await _oldBoxFoamDataServices . QueryAsync ( d = > d . ProductLineCode = = productLineCode ) ;
List < BoxFoamDataRecord > recordList = new List < BoxFoamDataRecord > ( ) ;
var currentTeamTimeList = await _sysUserInfoServices . GetTeamData ( ) ;
if ( currentTeamTimeList . Count = = 0 ) return ;
//更新计划表操作
CurrentTeamTime currentTeamTime = await _currentTeamTimeServices . FirstAsync ( ) ;
currentTeamTime . TeamName = currentTeamTimeList . FirstOrDefault ( ) . TeamName ;
currentTeamTime . StartTime = currentTeamTimeList . Min ( d = > d . StartTime ) ;
currentTeamTime . EndTime = currentTeamTimeList . Max ( d = > d . EndTime ) ;
await _currentTeamTimeServices . UpdateAsync ( currentTeamTime ) ;
//可以使用Mapping 映射
list . ForEach ( d = >
{
BoxFoamDataRecord record = new BoxFoamDataRecord ( ) ;
record . OrderCode = d . OrderCode ;
record . ProductLineCode = d . ProductLineCode ;
record . Fixturestatus = d . Production ;
record . CuringTimeSettingValue = d . CuringTimeSettingValue ;
record . ActualValue = d . ActualValue ;
record . AnHour = d . AnHour ;
record . TwoHour = d . TwoHour ;
record . ThreeHour = d . ThreeHour ;
record . FourHour = d . FourHour ;
record . FiveHour = d . FiveHour ;
record . SixHour = d . SixHour ;
record . SevenHour = d . SevenHour ;
record . EightHour = d . EightHour ;
record . NineHour = d . NineHour ;
record . TenHour = d . TenHour ;
record . ElevenHour = d . ElevenHour ;
record . TwelveHour = d . TwelveHour ;
record . BoxFixturesideplate = d . BoxFixturesideplate ;
record . BoxClosebetatemperature = d . BoxClosebetatemperature ;
record . BoxBeat = d . BoxBeat ;
record . CreateTime = DateTime . Now ;
} ) ;
int result = await _boxFoamDataRecordServices . AddAsync ( recordList ) ;
if ( result > 0 )
{
var obj2 = PlcHelper . melsecList . FirstOrDefault ( d = > d . EquipName . Equals ( "OldMelsecPlc1" ) ) ;
if ( obj2 = = null ) { return ; }
obj2 . plc . WriteInt16 ( "M216" , "1" ) ; //换班 数据清空
//清空 当班计划
await _oldBoxFoamDataServices . DeletesAsync ( list ) ;
}
}
Semaphore semaphore = new Semaphore ( 1 , 1 ) ;
}
# endregion
private async void ExecHourData ( string productLineCode )
#region 获取小时数据
public async void ExecHourDataAsync ( string productLineCode )
{
try
List < FixtureStatus > bLis = Collection . listFixtureStatus ;
if ( bLis . Count = = 0 ) return ;
List < BoxFoamPlan > planList = await _boxFoamPlanServices . QueryAsync ( ) ;
List < BoxFoamDataRealTime > bfds = await _boxFoamDataRealTimeServices . QueryAsync ( ) ;
for ( int j = 0 ; j < bLis . Count ; j + + )
{
List < FixtureStatus > bList = new List < FixtureStatus > ( ) ;
var collectionList = collection . listFixtureStatus ;
if ( collectionList . Count = = 0 ) return ;
bList . AddRange ( collectionList ) ;
List < BoxFoamData > bfds = await _oldBoxFoamDataServices . QueryAsync ( ) ;
List < OldBoxFoamType > spaceList = await _oldBoxFoamTypeServices . QueryAsync ( ) ;
List < BoxFoamPlan > planList = await _boxFoamPlanServices . QueryAsync ( ) ;
for ( int j = 0 ; j < bList . Count ; j + + )
try
{
try
if ( string . IsNullOrEmpty ( bLis [ j ] . FixtureBoxType ) ) continue ;
BoxFoamPlan plan = planList . FirstOrDefault ( d = > d . MaterialCode = = bLis [ j ] . FixtureBoxType & & d . PlanAmount > d . CompleteAmount ) ;
if ( plan ! = null )
{
OldBoxFoamType space = spaceList . FirstOrDefault ( d = > d . Boxtype = = bList [ j ] . FixtureBoxType ) ;
//根据夹具找货道,根据货道找物料
if ( spaceList ! = null )
int complateAmount = 0 ;
BoxFoamDataRealTime bfd = bfds . SingleOrDefault ( d = > d . FixtureBoxtype = = bLis [ j ] . FixtureBoxType & & d . SerialNumber = = bLis [ j ] . ObjId ) ;
if ( bfd ! = null )
{
BoxFoamPlan plan = planList . FirstOrDefault ( d = > d . MaterialCode = = space . MaterialCode & & d . PlanAmount > d . CompleteAmount ) ;
if ( plan ! = null )
{
int complateAmount = 0 ;
//更新小时数据
BoxFoamData bfd = bfds . FirstOrDefault ( d = > d . Fixtureboxtype = = bList [ j ] . FixtureBoxType & & d . MainId = = bList [ j ] . ObjId ) ;
if ( bfd ! = null )
{
//更新计划数量
complateAmount = bList [ j ] . Yield - bfd . Production ;
UpdateBoxData ( bList [ j ] , bfd ) ;
}
else
{
SaveBoxData ( productLineCode , bList [ j ] ) ;
}
plan . CompleteAmount = plan . CompleteAmount + complateAmount ;
await _boxFoamPlanServices . UpdateAsync ( plan ) ;
}
else
{
//更新小时数据
BoxFoamData bfd = bfds . FirstOrDefault ( d = > d . Fixtureboxtype = = bList [ j ] . FixtureBoxType & & d . MainId = = bList [ j ] . ObjId ) ;
if ( bfd ! = null )
{
UpdateBoxData ( bList [ j ] , bfd ) ;
}
else
{
SaveBoxData ( productLineCode , bList [ j ] ) ;
}
}
//更新计划数量
complateAmount = bLis [ j ] . Yield - bfd . FixtureProductioncapacity ;
UpdateClampData ( bLis [ j ] , bfd ) ;
}
else
{
//更新小时数据
BoxFoamData bfd = bfds . FirstOrDefault ( d = > d . Fixtureboxtype = = bList [ j ] . FixtureBoxType & & d . MainId = = bList [ j ] . ObjId ) ;
if ( bfd ! = null )
{
UpdateBoxData ( bList [ j ] , bfd ) ;
}
else
{
SaveBoxData ( productLineCode , bList [ j ] ) ;
}
FixtureStatus fixtureStatus = bLis [ j ] ;
SaveClampData ( productLineCode , fixtureStatus ) ;
}
}
catch { }
plan . CompleteAmount = plan . CompleteAmount + complateAmount ;
if ( complateAmount > 0 )
{
//保存历史记录
BoxFoamDataRealTimeHistory history = new BoxFoamDataRealTimeHistory ( ) ;
history . PlantCode = bfd . PlantCode ;
history . ProductlineCode = bfd . ProductlineCode ;
history . ProcessCode = bfd . ProcessCode ;
history . StationCode = bfd . StationCode ;
history . FixtureProductioncapacity = bLis [ j ] . Yield ;
history . FixtureCuringtimesettingvalue = bLis [ j ] . PlanCuringTime . ToString ( ) ;
history . FixtureActualtime = bLis [ j ] . RealCuringTime . ToString ( ) ;
history . UpdatedTime = DateTime . Now ;
//事务合并
await _boxFoamDataRealTimeHistoryServices . AddAsync ( history ) ;
await _boxFoamPlanServices . UpdateAsync ( plan ) ;
}
}
else
{
//更新小时数据
BoxFoamDataRealTime bfd = bfds . SingleOrDefault ( d = > d . FixtureBoxtype = = bLis [ j ] . FixtureBoxType & & d . SerialNumber = = bLis [ j ] . ObjId ) ;
if ( bfd ! = null )
{
UpdateClampData ( bLis [ j ] , bfd ) ;
}
else
{
SaveClampData ( productLineCode , bLis [ j ] ) ;
}
}
}
OldBoxFoamOnLoad ( bList ) ;
}
catch ( Exception ex )
{
Console . WriteLine ( ex . Message ) ;
catch { }
}
}
}
# endregion
private async void UpdateBoxData ( FixtureStatus item , BoxFoamData bfd )
#region 切换班组
private async void ShiftChangeAsync ( string productLineCode )
{
int hour = GetTeamHour ( DateTime . Now ) . Seq ;
switch ( hour )
try
{
case 1 :
bfd . AnHour = item . Yield - bfd . Production ;
break ;
case 2 :
bfd . TwoHour = item . Yield - bfd . Production ;
break ;
case 3 :
bfd . ThreeHour = item . Yield - bfd . Production ;
break ;
case 4 :
bfd . FourHour = item . Yield - bfd . Production ;
break ;
case 5 :
bfd . FiveHour = item . Yield - bfd . Production ;
break ;
case 6 :
bfd . SixHour = item . Yield - bfd . Production ;
break ;
case 7 :
bfd . SevenHour = item . Yield - bfd . Production ;
break ;
case 8 :
bfd . EightHour = item . Yield - bfd . Production ;
break ;
case 9 :
bfd . NineHour = item . Yield - bfd . Production ;
break ;
case 10 :
bfd . TenHour = item . Yield - bfd . Production ;
break ;
case 11 :
bfd . ElevenHour = item . Yield - bfd . Production ;
break ;
case 12 :
bfd . TwelveHour = item . Yield - bfd . Production ;
break ;
default :
break ;
}
//切换班组计划
var currentTeamTimeList = await _sysUserInfoServices . GetTeamData ( ) ;
if ( currentTeamTimeList . Count = = 0 ) return ;
var list = await _boxFoamDataRealTimeServices . QueryAsync ( d = > d . ProductlineCode = = productLineCode ) ;
//更新计划表操作
CurrentTeamTime currentTeamTime = await _currentTeamTimeServices . FirstAsync ( ) ;
currentTeamTime . TeamName = currentTeamTimeList . FirstOrDefault ( ) . TeamName ;
currentTeamTime . StartTime = currentTeamTimeList . Min ( d = > d . StartTime ) ;
currentTeamTime . EndTime = currentTeamTimeList . Max ( d = > d . EndTime ) ;
bfd . Production = item . Yield ;
bool result = await _currentTeamTimeServices . UpdateAsync ( currentTeamTime ) ;
if ( result )
{
var obj2 = PlcHelper . siemensList . FirstOrDefault ( d = > d . EquipName . Equals ( "foamLine1Plc" ) ) ;
if ( obj2 = = null ) { return ; }
await _oldBoxFoamDataServices . UpdateAsync ( bfd ) ;
}
//清空 当班计划
var realTimeList = await _boxFoamDataRealTimeHistoryServices . QueryAsync ( d = > d . ProductlineCode = = productLineCode ) ;
await _boxFoamDataRealTimeHistoryServices . DeletesAsync ( realTimeList ) ;
private async void SaveBoxData ( string productLineCode , FixtureStatus item )
{
BoxFoamData bfdata = new BoxFoamData ( ) ;
bfdata . MainId = item . ObjId ;
bfdata . ProductLineCode = productLineCode ;
bfdata . Fixtureboxtype = item . FixtureBoxType ;
bfdata . Fixturestatus = item . Status ;
bfdata . Production = item . Yield ;
bfdata . CuringTimeSettingValue = item . PlanCuringTime . ToString ( ) ;
bfdata . ActualValue = item . RealCuringTime . ToString ( ) ;
int hour = GetTeamHour ( DateTime . Now ) . Seq ;
switch ( hour )
{
case 1 :
bfdata . AnHour = item . Yield = bfdata . Production ;
break ;
case 2 :
bfdata . TwoHour = item . Yield = bfdata . Production ;
break ;
case 3 :
bfdata . ThreeHour = item . Yield = bfdata . Production ;
break ;
case 4 :
bfdata . FourHour = item . Yield = bfdata . Production ;
break ;
case 5 :
bfdata . FiveHour = item . Yield = bfdata . Production ;
break ;
case 6 :
bfdata . SixHour = item . Yield = bfdata . Production ;
break ;
case 7 :
bfdata . SevenHour = item . Yield = bfdata . Production ;
break ;
case 8 :
bfdata . EightHour = item . Yield = bfdata . Production ;
break ;
case 9 :
bfdata . NineHour = item . Yield = bfdata . Production ;
break ;
case 10 :
bfdata . TenHour = item . Yield = bfdata . Production ;
break ;
case 11 :
bfdata . ElevenHour = item . Yield = bfdata . Production ;
break ;
case 12 :
bfdata . TwelveHour = item . Yield = bfdata . Production ;
break ;
default :
break ;
var plan = await _boxFoamPlanServices . QueryAsync ( d = > d . ProductLineCode = = productLineCode ) ;
await _boxFoamPlanServices . DeletesAsync ( plan ) ;
}
}
bfdata . MainId = item . ObjId ;
await _oldBoxFoamDataServices . AddAsync ( bfdata ) ;
catch { }
}
public CurrentTeamTimeView GetTeamHour ( )
# endregion
#region 更新夹具型号
/// <summary>
/// 更新夹具型号
/// </summary>
public async void UpdateClampData ( FixtureStatus fixtureStatus , BoxFoamDataRealTime bfd )
{
DateTime now = DateTime . Now ;
var list = _sysUserInfoServices . GetTeamData ( ) . Result ;
if ( list ! = null )
try
{
//var obj = list.FirstOrDefault().EndTime.ToString("HH:mm");
var view = list . FirstOrDefault ( ) ;
return view ;
bfd . FixtureBoxtype = fixtureStatus . FixtureBoxType ;
bfd . FixtureStatus = fixtureStatus . Status . ToString ( ) ;
bfd . FixtureProductioncapacity = fixtureStatus . Yield ;
bfd . FixtureCuringtimesettingvalue = fixtureStatus . PlanCuringTime . ToString ( ) ;
bfd . FixtureActualtime = fixtureStatus . RealCuringTime . ToString ( ) ;
bfd . UpdatedTime = DateTime . Now ;
await _boxFoamDataRealTimeServices . UpdateAsync ( bfd ) ;
}
return null ;
catch { }
}
# endregion
public CurrentTeamTimeView GetTeamHour ( DateTime now )
#region 新增夹具型号
/// <summary>
/// 更新夹具型号
/// </summary>
public async void SaveClampData ( string productLineCode , FixtureStatus fixtureStatus )
{
var obj = _sysUserInfoServices . GetTeamData ( now ) . Result ;
var obj = await _sysUserInfoServices . GetProductLineInfo ( productLineCode ) ;
if ( obj ! = null )
{
return obj ;
BoxFoamDataRealTime bfd = new BoxFoamDataRealTime ( ) ;
bfd . PlantCode = obj . PlantCode ;
bfd . ProductlineCode = productLineCode ;
bfd . ProcessCode = obj . ProcessCode ;
bfd . StationCode = obj . StationCode ;
bfd . SerialNumber = fixtureStatus . ObjId ;
bfd . FixtureBoxtype = fixtureStatus . FixtureBoxType ;
bfd . FixtureStatus = fixtureStatus . Status . ToString ( ) ;
bfd . FixtureProductioncapacity = fixtureStatus . Yield ;
bfd . FixtureCuringtimesettingvalue = fixtureStatus . PlanCuringTime . ToString ( ) ;
bfd . FixtureActualtime = fixtureStatus . RealCuringTime . ToString ( ) ;
bfd . CreatedTime = DateTime . Now ;
bfd . UpdatedTime = DateTime . Now ;
await _boxFoamDataRealTimeServices . AddAsync ( bfd ) ;
}
return null ;
}
# endregion
#region 原数据采集方法
/// <summary>
/// 将采集到的数据保存
/// </summary>
/// <param name="mode"></param>
//public async void RealTimeFoamingTask(object? sender, ElapsedEventArgs e)
//{
// semaphore.WaitOne();
// try
// {
// string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
// if (Collection.listFixtureStatus == null|| Collection.listFixtureStatus.Count==0) return;
// DateTime now = DateTime.Now;
// CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now);
// if (time != null)
// {
// ExecHourData(productLineCode);
// }
// else
// {
// ShiftChange(productLineCode);
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex.Message.ToString());
// }
// finally
// {
// semaphore.Release();
// }
//}
//private async void ShiftChange(string productLineCode)
//{
// //切换班组计划
// var list = await _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode);
// List<BoxFoamDataRecord> recordList = new List<BoxFoamDataRecord>();
// var currentTeamTimeList = await _sysUserInfoServices.GetTeamData();
// if (currentTeamTimeList.Count == 0) return;
// //更新计划表操作
// CurrentTeamTime currentTeamTime = await _currentTeamTimeServices.FirstAsync();
// currentTeamTime.TeamName = currentTeamTimeList.FirstOrDefault().TeamName;
// currentTeamTime.StartTime = currentTeamTimeList.Min(d => d.StartTime);
// currentTeamTime.EndTime = currentTeamTimeList.Max(d => d.EndTime);
// await _currentTeamTimeServices.UpdateAsync(currentTeamTime);
// //可以使用Mapping 映射
// list.ForEach(d =>
// {
// BoxFoamDataRecord record = new BoxFoamDataRecord();
// record.OrderCode = d.OrderCode;
// record.ProductLineCode = d.ProductLineCode;
// record.Fixturestatus = d.Production;
// record.CuringTimeSettingValue = d.CuringTimeSettingValue;
// record.ActualValue = d.ActualValue;
// record.AnHour = d.AnHour;
// record.TwoHour = d.TwoHour;
// record.ThreeHour = d.ThreeHour;
// record.FourHour = d.FourHour;
// record.FiveHour = d.FiveHour;
// record.SixHour = d.SixHour;
// record.SevenHour = d.SevenHour;
// record.EightHour = d.EightHour;
// record.NineHour = d.NineHour;
// record.TenHour = d.TenHour;
// record.ElevenHour = d.ElevenHour;
// record.TwelveHour = d.TwelveHour;
// record.BoxFixturesideplate = d.BoxFixturesideplate;
// record.BoxClosebetatemperature = d.BoxClosebetatemperature;
// record.BoxBeat = d.BoxBeat;
// record.CreateTime = DateTime.Now;
// });
// int result = await _boxFoamDataRecordServices.AddAsync(recordList);
// if (result > 0)
// {
// var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
// if (obj2 == null) { return; }
// obj2.plc.WriteInt16("M216", "1");//换班 数据清空
// //清空 当班计划
// await _oldBoxFoamDataServices.DeletesAsync(list);
// }
//}
//Semaphore semaphore = new Semaphore(1, 1);
//private async void ExecHourData(string productLineCode)
//{
// try
// {
// List<FixtureStatus> bList = new List<FixtureStatus>();
// var collectionList = collection.listFixtureStatus;
// if (collectionList.Count == 0) return;
// bList.AddRange(collectionList);
// List<BoxFoamData> bfds = await _oldBoxFoamDataServices.QueryAsync();
// List<OldBoxFoamType> spaceList = await _oldBoxFoamTypeServices.QueryAsync();
// List<BoxFoamPlan> planList = await _boxFoamPlanServices.QueryAsync();
// for (int j = 0; j < bList.Count; j++)
// {
// try
// {
// OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bList[j].FixtureBoxType);
// //根据夹具找货道,根据货道找物料
// if (spaceList != null)
// {
// BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount);
// if (plan != null)
// {
// int complateAmount = 0;
// //更新小时数据
// BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId);
// if (bfd != null)
// {
// //更新计划数量
// complateAmount = bList[j].Yield - bfd.Production;
// UpdateBoxData(bList[j], bfd);
// }
// else
// {
// SaveBoxData(productLineCode, bList[j]);
// }
// plan.CompleteAmount = plan.CompleteAmount + complateAmount;
// await _boxFoamPlanServices.UpdateAsync(plan);
// }
// else
// {
// //更新小时数据
// BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId);
// if (bfd != null)
// {
// UpdateBoxData(bList[j], bfd);
// }
// else
// {
// SaveBoxData(productLineCode, bList[j]);
// }
// }
// }
// else
// {
// //更新小时数据
// BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bList[j].FixtureBoxType && d.MainId == bList[j].ObjId);
// if (bfd != null)
// {
// UpdateBoxData(bList[j], bfd);
// }
// else
// {
// SaveBoxData(productLineCode, bList[j]);
// }
// }
// }
// catch { }
// }
// OldBoxFoamOnLoad(bList);
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex.Message);
// }
//}
//private async void UpdateBoxData(FixtureStatus item, BoxFoamData bfd)
//{
// int hour = GetTeamHour(DateTime.Now).Seq;
// switch (hour)
// {
// case 1:
// bfd.AnHour = item.Yield - bfd.Production;
// break;
// case 2:
// bfd.TwoHour = item.Yield - bfd.Production;
// break;
// case 3:
// bfd.ThreeHour = item.Yield - bfd.Production;
// break;
// case 4:
// bfd.FourHour = item.Yield - bfd.Production;
// break;
// case 5:
// bfd.FiveHour = item.Yield - bfd.Production;
// break;
// case 6:
// bfd.SixHour = item.Yield - bfd.Production;
// break;
// case 7:
// bfd.SevenHour = item.Yield - bfd.Production;
// break;
// case 8:
// bfd.EightHour = item.Yield - bfd.Production;
// break;
// case 9:
// bfd.NineHour = item.Yield - bfd.Production;
// break;
// case 10:
// bfd.TenHour = item.Yield - bfd.Production;
// break;
// case 11:
// bfd.ElevenHour = item.Yield - bfd.Production;
// break;
// case 12:
// bfd.TwelveHour = item.Yield - bfd.Production;
// break;
// default:
// break;
// }
// bfd.Production = item.Yield;
// await _oldBoxFoamDataServices.UpdateAsync(bfd);
//}
//private async void SaveBoxData(string productLineCode, FixtureStatus item)
//{
// BoxFoamData bfdata = new BoxFoamData();
// bfdata.MainId = item.ObjId;
// bfdata.ProductLineCode = productLineCode;
// bfdata.Fixtureboxtype = item.FixtureBoxType;
// bfdata.Fixturestatus = item.Status;
// bfdata.Production = item.Yield;
// bfdata.CuringTimeSettingValue = item.PlanCuringTime.ToString();
// bfdata.ActualValue = item.RealCuringTime.ToString();
// int hour = GetTeamHour(DateTime.Now).Seq;
// switch (hour)
// {
// case 1:
// bfdata.AnHour = item.Yield = bfdata.Production;
// break;
// case 2:
// bfdata.TwoHour = item.Yield = bfdata.Production;
// break;
// case 3:
// bfdata.ThreeHour = item.Yield = bfdata.Production;
// break;
// case 4:
// bfdata.FourHour = item.Yield = bfdata.Production;
// break;
// case 5:
// bfdata.FiveHour = item.Yield = bfdata.Production;
// break;
// case 6:
// bfdata.SixHour = item.Yield = bfdata.Production;
// break;
// case 7:
// bfdata.SevenHour = item.Yield = bfdata.Production;
// break;
// case 8:
// bfdata.EightHour = item.Yield = bfdata.Production;
// break;
// case 9:
// bfdata.NineHour = item.Yield = bfdata.Production;
// break;
// case 10:
// bfdata.TenHour = item.Yield = bfdata.Production;
// break;
// case 11:
// bfdata.ElevenHour = item.Yield = bfdata.Production;
// break;
// case 12:
// bfdata.TwelveHour = item.Yield = bfdata.Production;
// break;
// default:
// break;
// }
// bfdata.MainId = item.ObjId;
// await _oldBoxFoamDataServices.AddAsync(bfdata);
//}
//public CurrentTeamTimeView GetTeamHour()
//{
// DateTime now = DateTime.Now;
// var list = _sysUserInfoServices.GetTeamData().Result;
// if (list != null)
// {
// //var obj = list.FirstOrDefault().EndTime.ToString("HH:mm");
// var view = list.FirstOrDefault();
// return view;
// }
// return null;
//}
//public CurrentTeamTimeView GetTeamHour(DateTime now)
//{
// var obj = _sysUserInfoServices.GetTeamData(now).Result;
// if (obj != null)
// {
// return obj;
// }
// return null;
//}
# endregion
}
}