|
|
|
@ -20,6 +20,7 @@ using System.Timers;
|
|
|
|
|
using Aucma.Core.BoxFoam.Models;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -32,9 +33,8 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
private readonly ISysUserInfoServices _sysUserInfoServices;
|
|
|
|
|
private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices;
|
|
|
|
|
private readonly IBoxFoamDataRealTimeServices? _boxFoamDataRealTimeServices;
|
|
|
|
|
|
|
|
|
|
private readonly IBoxFoamDataRealTimeHistoryServices _boxFoamDataRealTimeHistoryServices;
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(2000);
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(5000);
|
|
|
|
|
|
|
|
|
|
int totalAmount = 0;
|
|
|
|
|
|
|
|
|
@ -45,7 +45,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
_boxFoamDataRecordServices = App.ServiceProvider.GetService<IBoxFoamDataRecordServices>();
|
|
|
|
|
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
|
|
|
|
|
_boxFoamDataRealTimeHistoryServices = App.ServiceProvider.GetService<IBoxFoamDataRealTimeHistoryServices>();
|
|
|
|
|
// _boxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
|
|
|
|
|
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
|
|
|
|
|
CollectionFoamLine.RefreshBoxFoamDataDelegateEvent += InitData;
|
|
|
|
|
|
|
|
|
|
timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
|
|
|
|
@ -287,7 +287,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int total = 0;
|
|
|
|
|
int totalAmount = 0;
|
|
|
|
|
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
FixtureName.Clear();
|
|
|
|
@ -295,6 +295,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
Beat.Clear();
|
|
|
|
|
InternalTemperature.Clear();
|
|
|
|
|
OutsideTemperature.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item.Status == 1) StatusColor.Add("Green");
|
|
|
|
@ -329,16 +330,17 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
|
|
|
|
|
|
|
//DateTime now = DateTime.Now;
|
|
|
|
|
//CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now);
|
|
|
|
|
//if (time != null)
|
|
|
|
|
//{
|
|
|
|
|
ExecHourDataAsync(productLineCode);
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// //ShiftChangeAsync(productLineCode);
|
|
|
|
|
//}
|
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
|
List<CurrentTeamTime> timeList = await _currentTeamTimeServices.QueryAsync(d => d.StartTime <= now && d.EndTime >= now);
|
|
|
|
|
|
|
|
|
|
if (timeList.Count>0)
|
|
|
|
|
{
|
|
|
|
|
ExecHourDataAsync(productLineCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShiftChangeAsync(productLineCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -369,6 +371,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
BoxFoamDataRealTime bfd = bfds.SingleOrDefault(d => d.FixtureBoxtype == bLis[j].FixtureBoxType && d.SerialNumber == bLis[j].ObjId);
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//更新计划数量
|
|
|
|
|
complateAmount = bLis[j].Yield - bfd.FixtureProductioncapacity;
|
|
|
|
|
UpdateClampData(bLis[j], bfd);
|
|
|
|
@ -419,56 +422,33 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
|
|
|
|
|
private async void ShiftChangeAsync(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
//切换班组计划
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//可以使用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);
|
|
|
|
|
// await _currentTeamTimeServices.UpdateAsync(currentTeamTime);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//切换班组计划
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
bool result = await _currentTeamTimeServices.UpdateAsync(currentTeamTime);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
|
|
|
|
|
if (obj2 == null) { return; }
|
|
|
|
|
|
|
|
|
|
//清空 当班计划
|
|
|
|
|
var realTimeList = await _boxFoamDataRealTimeHistoryServices.QueryAsync(d => d.ProductlineCode == productLineCode);
|
|
|
|
|
await _boxFoamDataRealTimeHistoryServices.DeletesAsync(realTimeList);
|
|
|
|
|
|
|
|
|
|
var plan = await _boxFoamPlanServices.QueryAsync(d => d.ProductLineCode == productLineCode);
|
|
|
|
|
await _boxFoamPlanServices.DeletesAsync(plan);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -478,16 +458,22 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async void UpdateClampData(FixtureStatus fixtureStatus, BoxFoamDataRealTime bfd)
|
|
|
|
|
{
|
|
|
|
|
bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType;
|
|
|
|
|
bfd.FixtureStatus = fixtureStatus.Status.ToString();
|
|
|
|
|
bfd.FixtureProductioncapacity = fixtureStatus.Yield;
|
|
|
|
|
bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString();
|
|
|
|
|
bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString();
|
|
|
|
|
bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.UpdatedTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
await _boxFoamDataRealTimeServices.UpdateAsync(bfd);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bfd.FixtureBoxtype = fixtureStatus.FixtureBoxType;
|
|
|
|
|
bfd.FixtureStatus = fixtureStatus.Status.ToString();
|
|
|
|
|
bfd.FixtureProductioncapacity = fixtureStatus.Yield;
|
|
|
|
|
bfd.FixtureCuringtimesettingvalue = fixtureStatus.PlanCuringTime.ToString();
|
|
|
|
|
bfd.FixtureActualtime = fixtureStatus.RealCuringTime.ToString();
|
|
|
|
|
bfd.ModeInternaltemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.Beat = fixtureStatus.Yield.ToString();
|
|
|
|
|
bfd.UpdatedTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
await _boxFoamDataRealTimeServices.UpdateAsync(bfd);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -497,21 +483,29 @@ namespace Aucma.Core.BoxFoam.ViewModels
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async void SaveClampData(string productLineCode,FixtureStatus fixtureStatus)
|
|
|
|
|
{
|
|
|
|
|
BoxFoamDataRealTime bfd=new BoxFoamDataRealTime();
|
|
|
|
|
|
|
|
|
|
bfd.ProductlineCode = productLineCode;
|
|
|
|
|
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.ModeInternaltemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.CreatedTime = DateTime.Now;
|
|
|
|
|
bfd.UpdatedTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
await _boxFoamDataRealTimeServices.AddAsync(bfd);
|
|
|
|
|
var obj=await _sysUserInfoServices.GetProductLineInfo(productLineCode);
|
|
|
|
|
if (obj!=null)
|
|
|
|
|
{
|
|
|
|
|
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.ModeInternaltemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.ModeOutsidetemperature = fixtureStatus.InternalTemperature;
|
|
|
|
|
bfd.CreatedTime = DateTime.Now;
|
|
|
|
|
bfd.UpdatedTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
await _boxFoamDataRealTimeServices.AddAsync(bfd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|