|
|
|
@ -5,14 +5,19 @@ using Admin.Core.Model.ViewModels;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Admin.Core.Tasks;
|
|
|
|
|
using Aucma.Core.OldBoxFoam.Models;
|
|
|
|
|
using Aucma.Core.Tasks;
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
/**
|
|
|
|
|
* 老发泡线监控
|
|
|
|
|
* */
|
|
|
|
@ -22,56 +27,49 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
|
IBoxFoamDataServices? _oldBoxFoamDataServices;
|
|
|
|
|
IOldBoxFoamTypeServices _oldBoxFoamTypeServices;
|
|
|
|
|
public static System.Threading.Timer GetStoreTimer;
|
|
|
|
|
private readonly IBoxFoamPlanServices _boxFoamPlanServices;
|
|
|
|
|
private readonly ISysUserInfoServices _sysUserInfoServices;
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OldBoxFoamPageViewModel));
|
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(2000);
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(2000);
|
|
|
|
|
|
|
|
|
|
public OldBoxFoamPageViewModel() {
|
|
|
|
|
_oldBoxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
|
|
|
|
|
_oldBoxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
|
|
|
|
|
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
|
|
|
|
|
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
|
|
|
|
|
//Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3;
|
|
|
|
|
AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
|
|
|
|
|
//GetStoreTimer = new System.Threading.Timer(OldBoxFoamOnLoad, null, 0, Timeout.Infinite);
|
|
|
|
|
//Task.WaitAll(OldBoxFoamOnLoad());
|
|
|
|
|
|
|
|
|
|
timer1.Elapsed += new System.Timers.ElapsedEventHandler(OldBoxFoamOnLoad); //到达时间的时候执行事件;
|
|
|
|
|
timer1.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
|
|
timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
|
|
timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
|
|
|
|
|
Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3;
|
|
|
|
|
Job_OldBoxFoam_Quartz.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
|
|
|
|
|
|
|
|
|
|
// Task.WaitAll(OldBoxFoamOnLoad(), OldBoxFoamTypeOnLoad());
|
|
|
|
|
timer2.Elapsed += new System.Timers.ElapsedEventHandler(OldBoxFoamOnLoad); //到达时间的时候执行事件;
|
|
|
|
|
timer2.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
|
|
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
|
|
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 初始化加载数据
|
|
|
|
|
|
|
|
|
|
public async Task OldBoxFoamOnLoad()
|
|
|
|
|
{
|
|
|
|
|
List<BoxFoamData> list = await _oldBoxFoamDataServices.QueryAsync();
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
|
|
|
|
|
model.ObjId = item.ObjId;
|
|
|
|
|
model.Fixtureboxtype = item.Fixtureboxtype;
|
|
|
|
|
model.Fixturestatus = item.Fixturestatus;
|
|
|
|
|
model.Production = item.Production;
|
|
|
|
|
model.CuringTimeSettingValue = item.CuringTimeSettingValue;
|
|
|
|
|
if (item.Fixturestatus == 1)//停止
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("green");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("red");
|
|
|
|
|
}
|
|
|
|
|
_fixtureName.Add(item.Fixtureboxtype);
|
|
|
|
|
_production.Add(item.Production);
|
|
|
|
|
_beat.Add(item.BoxBeat);
|
|
|
|
|
i =+ item.Production;
|
|
|
|
|
}
|
|
|
|
|
_totle = list.Sum(d=>d.Production);
|
|
|
|
|
}
|
|
|
|
|
public Task OldBoxFoamOnLoad3(List<BoxFoamData> list)
|
|
|
|
|
private void OldBoxFoamOnLoad(object? sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (list == null) return Task.CompletedTask;
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)( () =>
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamDataGrid.Clear();
|
|
|
|
|
_fixtureName.Clear();
|
|
|
|
|
_production.Clear();
|
|
|
|
|
_beat.Clear();
|
|
|
|
|
_statusColor.Clear();
|
|
|
|
|
List<BoxFoamData> list = _oldBoxFoamDataServices.QueryAsync().Result;
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
var prderList= list.OrderBy(d=>d.MainId);
|
|
|
|
|
foreach (var item in prderList)
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
|
|
|
|
|
model.ObjId = item.ObjId;
|
|
|
|
@ -93,9 +91,71 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
_beat.Add(item.BoxBeat);
|
|
|
|
|
i = +item.Production;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
_totle = list.Sum(d => d.Production);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("获取库存接口数据异常." + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (GetStoreTimer != null)
|
|
|
|
|
{
|
|
|
|
|
GetStoreTimer.Change(20000, Timeout.Infinite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public async Task OldBoxFoamOnLoad3(List<BoxFoamData> list)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// List<BoxFoamData> list = await _oldBoxFoamDataServices.QueryAsync();
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
_fixtureName.Clear();
|
|
|
|
|
_production.Clear();
|
|
|
|
|
_beat.Clear();
|
|
|
|
|
_statusColor.Clear();
|
|
|
|
|
OldBoxFoamDataGrid.Clear();
|
|
|
|
|
int i = 0;
|
|
|
|
|
var prderList = list.OrderBy(d => d.MainId);
|
|
|
|
|
foreach (var item in prderList)
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
|
|
|
|
|
model.ObjId = item.ObjId;
|
|
|
|
|
model.Fixtureboxtype = item.Fixtureboxtype;
|
|
|
|
|
model.Fixturestatus = item.Fixturestatus;
|
|
|
|
|
model.Production = item.Production;
|
|
|
|
|
model.CuringTimeSettingValue = item.CuringTimeSettingValue;
|
|
|
|
|
if (item.Fixturestatus == 1)//停止
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("green");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("red");
|
|
|
|
|
}
|
|
|
|
|
_fixtureName.Add(item.Fixtureboxtype);
|
|
|
|
|
_production.Add(item.Production);
|
|
|
|
|
_beat.Add(item.BoxBeat);
|
|
|
|
|
i = +item.Production;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("获取库存接口数据异常." + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (GetStoreTimer != null)
|
|
|
|
|
{
|
|
|
|
|
GetStoreTimer.Change(10000, Timeout.Infinite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public async Task OldBoxFoamTypeOnLoad()
|
|
|
|
|
{
|
|
|
|
@ -200,5 +260,41 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
set => SetProperty(ref _totle, value);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将采集到的数据梳理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mode"></param>
|
|
|
|
|
public async void RealTimeFoamingTask(object? sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var list = _boxFoamPlanServices.QueryAsync().Result;
|
|
|
|
|
//根据夹具找箱型找货道,根据货道找物料
|
|
|
|
|
var spaceList=await _oldBoxFoamTypeServices.QueryAsync(d=>d.Boxtype== mode);
|
|
|
|
|
if (spaceList.Count>0)
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamType type= spaceList.FirstOrDefault();
|
|
|
|
|
BoxFoamPlan plan= list.FirstOrDefault(d=>d.MaterialCode== type.MaterialCode);
|
|
|
|
|
if (plan!=null)
|
|
|
|
|
{
|
|
|
|
|
plan.CompleteAmount = plan.CompleteAmount + 1;
|
|
|
|
|
|
|
|
|
|
_boxFoamPlanServices.UpdateAsync(plan);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|