|
|
|
@ -23,6 +23,9 @@ using NPOI.SS.Formula.Functions;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
/*
|
|
|
|
|
* 首页信息
|
|
|
|
|
*/
|
|
|
|
@ -215,12 +218,13 @@ namespace Aucma.Core.SheetMetal.ViewModels
|
|
|
|
|
var list = _taskExecutionPlanInfoServices.QueryAsync(x => x.IsFlag == 0 && x.ProductLineCode == stationCode && x.BeginTime > view.StartTime || x.ExecuteStatus == 2).Result;
|
|
|
|
|
if (list == null) return Task.CompletedTask;
|
|
|
|
|
|
|
|
|
|
var execList = list.OrderByDescending(d => d.ExecuteOrder);
|
|
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
string planType = string.Empty;
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
var execList = list.OrderByDescending(d => d.ExecuteOrder);
|
|
|
|
|
foreach (var item in execList)
|
|
|
|
|
{
|
|
|
|
|
TaskExecModel task = new TaskExecModel();
|
|
|
|
@ -303,7 +307,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
|
|
|
|
|
private async Task MoveUp(string Id)
|
|
|
|
|
{
|
|
|
|
|
string stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
|
bool result = await _taskExecutionPlanInfoServices.PlanMoveUp(Id, stationCode);
|
|
|
|
|
bool result = await _taskExecutionPlanInfoServices.PlanMoveDown(Id, stationCode);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
await LoadData();
|
|
|
|
@ -319,10 +323,9 @@ namespace Aucma.Core.SheetMetal.ViewModels
|
|
|
|
|
private async Task MoveDown(string Id)
|
|
|
|
|
{
|
|
|
|
|
string stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
|
bool result = await _taskExecutionPlanInfoServices.PlanMoveDown(Id, stationCode);
|
|
|
|
|
bool result = await _taskExecutionPlanInfoServices.PlanMoveUp(Id, stationCode);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
await LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -338,31 +341,110 @@ namespace Aucma.Core.SheetMetal.ViewModels
|
|
|
|
|
MessageBoxResult msg = MessageBox.Show("确定要删除吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
|
|
|
|
|
if (MessageBoxResult.Yes == msg)
|
|
|
|
|
{
|
|
|
|
|
int id = Convert.ToInt32(Id);
|
|
|
|
|
ExecutePlanInfo executionPlanInfo= _taskExecutionPlanInfoServices.FirstAsync(s => s.ObjId == id).Result;
|
|
|
|
|
|
|
|
|
|
if (executionPlanInfo.PlanAmount== executionPlanInfo.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划已经完成,不可以删除!", "系统信息");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
executionPlanInfo.IsFlag = 1;
|
|
|
|
|
bool result = await _taskExecutionPlanInfoServices.UpdateAsync(executionPlanInfo);
|
|
|
|
|
if (result)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//下发该计划取消PLC任务
|
|
|
|
|
//var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
|
|
|
|
|
//var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
|
|
|
|
|
//obj_backPanel.plc.WriteInt16("D4021","5");//下传5为计划结束
|
|
|
|
|
int id = Convert.ToInt32(Id);
|
|
|
|
|
ExecutePlanInfo executionPlanInfo = _taskExecutionPlanInfoServices.FirstAsync(s => s.ObjId == id).Result;
|
|
|
|
|
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
await LoadData();
|
|
|
|
|
MessageBox.Show("执行计划删除成功", "系统信息");
|
|
|
|
|
if (executionPlanInfo.PlanAmount == executionPlanInfo.CompleteAmount)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划已经完成,不可以删除!", "系统信息");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (executionPlanInfo.PlanType == 1)
|
|
|
|
|
{
|
|
|
|
|
var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
|
|
|
|
|
var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
|
|
|
|
|
string taskSideCode = this.GetSidePlanCode(obj_sidePanel);
|
|
|
|
|
string taskBackCode = this.GetBackPlanCode(obj_backPanel);
|
|
|
|
|
if (taskSideCode.Equals(executionPlanInfo.TaskCode))
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt16("D6021", "5");
|
|
|
|
|
}
|
|
|
|
|
if (taskBackCode.Equals(executionPlanInfo.TaskCode))
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt16("D4021", "5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var backPanelList = _recordBackPanelComplateServices.QueryAsync(d => d.PlanCode.Equals(executionPlanInfo.TaskCode)).Result;
|
|
|
|
|
int backPanelCount = backPanelList.Sum(d => d.OutPutAmount);
|
|
|
|
|
var sidePanelList = _recordSidePanelComplateServices.QueryAsync(d => d.PlanCode.Equals(executionPlanInfo.TaskCode)).Result;
|
|
|
|
|
int sidePanelCount = sidePanelList.Sum(d => d.OutPutAmount);
|
|
|
|
|
if (backPanelCount == 0&& sidePanelCount==0)
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag =0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (executionPlanInfo.PlanType == 2)
|
|
|
|
|
{
|
|
|
|
|
var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
|
|
|
|
|
string taskSideCode = this.GetSidePlanCode(obj_sidePanel);
|
|
|
|
|
if (taskSideCode.Equals(executionPlanInfo.TaskCode))
|
|
|
|
|
{
|
|
|
|
|
obj_sidePanel.plc.WriteInt16("D6021", "5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var sidePanelList = _recordSidePanelComplateServices.QueryAsync(d => d.PlanCode.Equals(executionPlanInfo.TaskCode)).Result;
|
|
|
|
|
int sidePanelCount = sidePanelList.Sum(d => d.OutPutAmount);
|
|
|
|
|
if (sidePanelCount == 0)
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (executionPlanInfo.PlanType == 3)
|
|
|
|
|
{
|
|
|
|
|
var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
|
|
|
|
|
string taskBackCode = this.GetBackPlanCode(obj_backPanel);
|
|
|
|
|
if (taskBackCode.Equals(executionPlanInfo.TaskCode))
|
|
|
|
|
{
|
|
|
|
|
obj_backPanel.plc.WriteInt16("D4021", "5");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var backPanelList = _recordBackPanelComplateServices.QueryAsync(d => d.PlanCode.Equals(executionPlanInfo.TaskCode)).Result;
|
|
|
|
|
int backPanelCount = backPanelList.Sum(d => d.OutPutAmount);
|
|
|
|
|
if (backPanelCount == 0)
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
executionPlanInfo.IsFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool result= false;
|
|
|
|
|
if (executionPlanInfo.IsFlag == 0)
|
|
|
|
|
{
|
|
|
|
|
result = await _taskExecutionPlanInfoServices.DeleteAsync(executionPlanInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = await _taskExecutionPlanInfoServices.UpdateAsync(executionPlanInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
PlanInfoDataGrid.Clear();
|
|
|
|
|
await LoadData();
|
|
|
|
|
MessageBox.Show("执行计划删除成功", "系统信息");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划删除失败", "系统信息");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("执行计划删除失败", "系统信息");
|
|
|
|
|
log.Error("钣金取消计划异常:"+ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -915,5 +997,50 @@ namespace Aucma.Core.SheetMetal.ViewModels
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string GetSidePlanCode(PlcModel obj)
|
|
|
|
|
{
|
|
|
|
|
bool flag = true;
|
|
|
|
|
string planCode = string.Empty;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
byte[] info = obj.plc.Read("D6030", 59);
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计划编号
|
|
|
|
|
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(planCode)) flag = false;
|
|
|
|
|
} while (flag);
|
|
|
|
|
return planCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetBackPlanCode(PlcModel obj)
|
|
|
|
|
{
|
|
|
|
|
bool flag = true;
|
|
|
|
|
string planCode = string.Empty;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
byte[] info = obj.plc.Read("D4030", 59);
|
|
|
|
|
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//计划编号
|
|
|
|
|
planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray()).Replace("\0", "").Trim();
|
|
|
|
|
if (!string.IsNullOrEmpty(planCode)) flag = false;
|
|
|
|
|
} while (flag);
|
|
|
|
|
return planCode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|