|
|
|
@ -40,51 +40,52 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices;
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OldBoxFoamPageViewModel));
|
|
|
|
|
Collection collection = new Collection();
|
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(2000);
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(10000);
|
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(5000);
|
|
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(3000);
|
|
|
|
|
int totalAmount = 0;
|
|
|
|
|
|
|
|
|
|
bool flag = true;
|
|
|
|
|
public OldBoxFoamPageViewModel() {
|
|
|
|
|
_oldBoxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
|
|
|
|
|
_oldBoxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
|
|
|
|
|
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
|
|
|
|
|
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
|
|
|
|
|
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
|
|
|
|
|
_currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
|
|
|
|
|
// _currentTeamTimeServices = App.ServiceProvider.GetService<ICurrentTeamTimeServices>();
|
|
|
|
|
_boxFoamDataRecordServices = App.ServiceProvider.GetService<IBoxFoamDataRecordServices>();
|
|
|
|
|
//AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
//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;
|
|
|
|
|
|
|
|
|
|
timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
|
|
|
|
|
timer2.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
|
|
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
|
|
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
|
|
|
|
|
//Task.WaitAll(OldBoxFoamOnLoad3());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 初始化加载数据
|
|
|
|
|
|
|
|
|
|
private void OldBoxFoamOnLoad(object? sender, ElapsedEventArgs e)
|
|
|
|
|
private void OldBoxFoamOnLoad(List<FixtureStatus> prderList)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//collection.startCollect();
|
|
|
|
|
///if (collection.listFixtureStatus == null) return;
|
|
|
|
|
//var prderList= collection.listFixtureStatus;
|
|
|
|
|
int num = prderList.Sum(d => d.Yield);
|
|
|
|
|
if (prderList.Count==0) return;
|
|
|
|
|
totalAmount = 0;
|
|
|
|
|
_fixtureName.Clear();
|
|
|
|
|
_production.Clear();
|
|
|
|
|
_beat.Clear();
|
|
|
|
|
_statusColor.Clear();
|
|
|
|
|
|
|
|
|
|
if (collection.listFixtureStatus == null) return;
|
|
|
|
|
int i = 0;
|
|
|
|
|
var prderList= collection.listFixtureStatus;
|
|
|
|
|
int num = prderList.Sum(d => d.Yield);
|
|
|
|
|
|
|
|
|
|
foreach (var item in prderList)
|
|
|
|
|
{
|
|
|
|
|
if (item.Status == 1)//生产
|
|
|
|
|
if (item.Status == 2)//生产
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("green");
|
|
|
|
|
}
|
|
|
|
@ -112,44 +113,36 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public async Task OldBoxFoamOnLoad3(List<BoxFoamData> list)
|
|
|
|
|
public async Task OldBoxFoamOnLoad3()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
collection.startCollect();
|
|
|
|
|
if (collection.listFixtureStatus == null) return;
|
|
|
|
|
var prderList = collection.listFixtureStatus;
|
|
|
|
|
int num = prderList.Sum(d => d.Yield);
|
|
|
|
|
if (prderList.Count==0) return;
|
|
|
|
|
totalAmount = 0;
|
|
|
|
|
_fixtureName.Clear();
|
|
|
|
|
_production.Clear();
|
|
|
|
|
_beat.Clear();
|
|
|
|
|
_statusColor.Clear();
|
|
|
|
|
foreach (var item in prderList)
|
|
|
|
|
{
|
|
|
|
|
_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)
|
|
|
|
|
if (item.Status == 1)//生产
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
_statusColor.Add("green");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_statusColor.Add("red");
|
|
|
|
|
}
|
|
|
|
|
_fixtureName.Add(item.FixtureBoxType);
|
|
|
|
|
_production.Add(item.Yield);
|
|
|
|
|
//_beat.Add(item.BoxBeat);
|
|
|
|
|
totalAmount = totalAmount + item.Yield;
|
|
|
|
|
}
|
|
|
|
|
Totle = totalAmount.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@ -157,9 +150,10 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (GetStoreTimer != null)
|
|
|
|
|
{
|
|
|
|
|
GetStoreTimer.Change(10000, Timeout.Infinite);
|
|
|
|
|
GetStoreTimer.Change(20000, Timeout.Infinite);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -353,8 +347,6 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
|
|
|
|
|
private async void ExecHourData(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<FixtureStatus> bLis = new List<FixtureStatus>();
|
|
|
|
@ -362,44 +354,60 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
collection.startCollect();
|
|
|
|
|
bLis = collection.listFixtureStatus;
|
|
|
|
|
if (bLis.Count == 0) return;
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
List<BoxFoamData> bfds = await _oldBoxFoamDataServices.QueryAsync();
|
|
|
|
|
List<OldBoxFoamType> spaceList = await _oldBoxFoamTypeServices.QueryAsync();
|
|
|
|
|
List < BoxFoamPlan> planList = await _boxFoamPlanServices.QueryAsync();
|
|
|
|
|
List<BoxFoamPlan> planList = await _boxFoamPlanServices.QueryAsync();
|
|
|
|
|
for (int j = 0; j < bLis.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bLis[j].FixtureBoxType);
|
|
|
|
|
//根据夹具找货道,根据货道找物料
|
|
|
|
|
if (space != null)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount);
|
|
|
|
|
if (plan != null)
|
|
|
|
|
OldBoxFoamType space = spaceList.FirstOrDefault(d => d.Boxtype == bLis[j].FixtureBoxType);
|
|
|
|
|
//根据夹具找货道,根据货道找物料
|
|
|
|
|
if (space != null)
|
|
|
|
|
{
|
|
|
|
|
int complateAmount = 0;
|
|
|
|
|
//更新小时数据
|
|
|
|
|
BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
BoxFoamPlan plan = planList.FirstOrDefault(d => d.MaterialCode == space.MaterialCode && d.PlanAmount > d.CompleteAmount);
|
|
|
|
|
if (plan != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxData(bLis[j], bfd);
|
|
|
|
|
//更新计划数量
|
|
|
|
|
complateAmount = bLis[j].Yield - bfd.Production;
|
|
|
|
|
int complateAmount = 0;
|
|
|
|
|
//更新小时数据
|
|
|
|
|
BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
{
|
|
|
|
|
//更新计划数量
|
|
|
|
|
complateAmount = bLis[j].Yield - bfd.Production;
|
|
|
|
|
UpdateBoxData(bLis[j], bfd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SaveBoxData(productLineCode, bLis[j]);
|
|
|
|
|
}
|
|
|
|
|
plan.CompleteAmount = plan.CompleteAmount + complateAmount;
|
|
|
|
|
await _boxFoamPlanServices.UpdateAsync(plan);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SaveBoxData(productLineCode, bLis[j]);
|
|
|
|
|
//更新小时数据
|
|
|
|
|
BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxData(bLis[j], bfd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SaveBoxData(productLineCode, bLis[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
plan.CompleteAmount = plan.CompleteAmount + complateAmount;
|
|
|
|
|
await _boxFoamPlanServices.UpdateAsync(plan);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//更新小时数据
|
|
|
|
|
//List<BoxFoamData> bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
|
|
|
|
|
BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
if (bfd!=null)
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxData(bLis[j], bfd);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -407,22 +415,11 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//更新小时数据
|
|
|
|
|
//List<BoxFoamData> bfd = await _oldBoxFoamDataServices.QueryAsync(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
catch { }
|
|
|
|
|
|
|
|
|
|
BoxFoamData bfd = bfds.FirstOrDefault(d => d.Fixtureboxtype == bLis[j].FixtureBoxType && d.MainId == bLis[j].ObjId);
|
|
|
|
|
if (bfd != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateBoxData(bLis[j], bfd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SaveBoxData(productLineCode, bLis[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OldBoxFoamOnLoad(bLis);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|