liulb@mesnac.com 11 months ago
parent c12b23a282
commit 83d7689a2d

@ -27,6 +27,7 @@ using Admin.Core.Model.Model_New;
using Aucma.Core.SheetMetalTasks;
using Microsoft.IdentityModel.Logging;
using StackExchange.Profiling.Internal;
using Admin.Core.Service;
/*
*
*/
@ -1210,6 +1211,11 @@ namespace Aucma.Core.SheetMetal.ViewModels
string stationCode = Appsettings.app("StationInfo", "StationCode");
try
{
if (SelectedCells==null)
{
MessageBox.Show("请选中要暂停的计划!");
return;
}
//获取当前计划的id
string Id = SelectedCells.ID;
if (string.IsNullOrEmpty(Id))
@ -1225,7 +1231,7 @@ namespace Aucma.Core.SheetMetal.ViewModels
bool result = await _taskExecutionPlanInfoServices.UpdateAsync(taskExecutionPlanInfo);
if (result)
{
await _taskExecutionPlanInfoServices.PlanMoveDown(objId.ToString(), stationCode);
// await _taskExecutionPlanInfoServices.PlanMoveDown(objId.ToString(), stationCode);
MessageBox.Show($"暂停计划成功,任务号:[{SelectedCells.TaskCode}]");
await LoadData();
}
@ -1256,8 +1262,6 @@ namespace Aucma.Core.SheetMetal.ViewModels
return;
}
//获取当前计划的id
string Id = SelectedCells.ID;
if (string.IsNullOrEmpty(Id))
@ -1273,7 +1277,21 @@ namespace Aucma.Core.SheetMetal.ViewModels
bool result = await _taskExecutionPlanInfoServices.UpdateAsync(taskExecutionPlanInfo);
if (result)
{
//await _taskExecutionPlanInfoServices.PlanMoveDown(objId.ToString(), stationCode);
List<SheetMetaSendPlanInfoView> planInfo = await _executePlanInfoServices.QuerySheetMetalSendPlanData("1001");
var task = planInfo.First(d => d.ObjId == objId);
List<ExecutePlanInfo> execList = new List<ExecutePlanInfo>();
task.ExecuteStatus = 1;
SortTaskInfos(ref planInfo, objId);
planInfo.ForEach(async t =>
{
ExecutePlanInfo executePlanInfo = await _executePlanInfoServices.FirstAsync(d=>d.ObjId==t.ObjId);
executePlanInfo.ExecuteOrder = t.ExecuteOrder;
execList.Add(executePlanInfo);
});
bool plan = await _taskExecutionPlanInfoServices.UpdateAsync(execList);
MessageBox.Show($"下发计划成功,任务号:[{SelectedCells.TaskCode}]");
await LoadData();
}
@ -1285,6 +1303,68 @@ namespace Aucma.Core.SheetMetal.ViewModels
}
}
#endregion
/// <summary>
/// 集合排序将指定实体移动至第1位并将执行顺序整体后移
/// </summary>
/// <param name="info"></param>
/// <param name="objId"></param>
/// <exception cref="ArgumentException"></exception>
private void SortTaskInfos(ref List<SheetMetaSendPlanInfoView> info, int objId)
{
if (info == null)
{
throw new ArgumentException($"执行计划排序异常:参数为空");
}
if (objId <= 0)
{
throw new ArgumentException($"执行计划排序异常:主键无效");
}
var taskExecutionPlanInfo = info.First(d => d.ObjId == objId);
if (taskExecutionPlanInfo != null)
{
info.Remove(taskExecutionPlanInfo);
info.Insert(0, taskExecutionPlanInfo);
int[] order = new int[info.Count];
for (int i = 0; i < info.Count; i++)
{
order[i] = info[i].ExecuteOrder;
}
BubbleSort(ref order);
for (int i = 0; i < info.Count; i++)
{
info[i].ExecuteOrder = order[i];
}
}
}
/// <summary>
/// 排序
/// </summary>
/// <param name="arr"></param>
public static void BubbleSort(ref int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < n - i - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
}
}

@ -295,8 +295,8 @@
<StackPanel >
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Right" >
<TextBlock Text="计划列表" FontSize="20" FontWeight="Bold" Foreground="White" />
<!--<Button Content="暂停计划" Command="{Binding StopCommand}" Width="100" Height="30" Background="YellowGreen" Margin="300 0 0 0" />-->
<Button Content="手动下发" Command="{Binding ManualCommand}" Width="100" Height="30" Background="OrangeRed" Margin="380 0 0 0" />
<Button Content="暂停计划" Command="{Binding StopCommand}" Width="100" Height="30" Background="YellowGreen" Margin="300 0 0 0" />
<Button Content="手动下发" Command="{Binding ManualCommand}" Width="100" Height="30" Background="OrangeRed" Margin="10 0 0 0" />
</WrapPanel>
</StackPanel>

@ -133,7 +133,7 @@
"EquipName": "SidePanelPlc",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1", //"10.10.91.1",
"IP": "10.10.91.1",
"Port": 5552
},
{
@ -141,7 +141,7 @@
"EquipName": "BackPanelPLC",
"PlcType": "Melsec",
"Enabled": true,
"IP": "127.0.0.1", //"10.10.91.6",
"IP":"10.10.91.6",
"Port": 5553
}
]

@ -1,6 +1,5 @@
using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.Model.Model_New;
using Admin.Core.Model;
using Admin.Core.Model.ViewModels;
using System.Text;
@ -73,6 +72,7 @@ namespace Aucma.Core.SheetMetalTasks
bool sideFlag = true;//前板标识
bool statusFlag = true;//计划任务状态标识
bool complatePlanFlag = true;//计划完成
#region 构造函数
/// <summary>
/// 构造函数
@ -214,7 +214,6 @@ namespace Aucma.Core.SheetMetalTasks
SendPlanTaskToSidPanel(planInfo, obj_sidePanel, smSyncModel.SmProductId.ObjToInt());
//UpdateSidPanelPlanTaskByComplate(planInfo);
// sideFlag = false;
}
if (planInfo.PlanType == 1)
@ -299,9 +298,17 @@ namespace Aucma.Core.SheetMetalTasks
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
bool isTaskFlag = true;
DateTime startTime = DateTime.Now;
do
{
//判断当前是否有手动下发的任务,有退出当前方法
isTaskFlag = GetNewTask(planInfo.ObjId);
if (isTaskFlag)
{
break;
}
int answer = obj_sidePanel.plc.ReadInt16("D6021");
if (answer == 2)
{
@ -310,10 +317,15 @@ namespace Aucma.Core.SheetMetalTasks
RefreshExecInfoEvent?.Invoke($"计划【{planInfo.TaskCode}】,收到前板板设备应答信号,复位应答地址", "White");
startTime = DateTime.Now;
isFlag = false;
break;
}
Thread.Sleep(3000);
} while (isFlag);
if (isTaskFlag) return ;
//更新计划状态为2执行中
planInfo.ExecuteStatus = 2;
bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus, startTime).Result;
@ -595,9 +607,17 @@ namespace Aucma.Core.SheetMetalTasks
#region PLC反馈信号逻辑处理
//循环读取PLC应答信号PLC应答后复位应答信号、更新计划状态为执行中
bool isFlag = true;
bool isTaskFlag = true;
DateTime startTime = DateTime.Now;
do
{
//判断当前是否有手动下发的任务,有退出当前方法
isTaskFlag = GetNewTask(planInfo.ObjId);
if (isTaskFlag)
{
break;
}
int backPalnelAnswer = obj_backPanel.plc.ReadInt16("D4021");
Console.WriteLine($"【{DateTime.Now.ToString("HH:m:s")}】===>应答信号:{backPalnelAnswer}");
if (backPalnelAnswer == 2)
@ -611,6 +631,8 @@ namespace Aucma.Core.SheetMetalTasks
Thread.Sleep(2000);
} while (isFlag);
if (isTaskFlag) return;
//更新计划状态为2执行中
planInfo.ExecuteStatus = 2;
bool result = _executePlanInfoServices.UpdateSheetMetalExecutePlanInfo(planInfo.ObjId, planInfo.ExecuteStatus, startTime).Result;
@ -1495,7 +1517,7 @@ namespace Aucma.Core.SheetMetalTasks
complatePlanFlag = false;
try
{
var planInfoList = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.PlanAmount != d.CompleteAmount).Result;
var planInfoList = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Contains(stationCode) && d.PlanAmount > d.CompleteAmount).Result;
if (planInfoList == null || planInfoList.Count == 0) return;
var list = from d in planInfoList
@ -1999,5 +2021,16 @@ namespace Aucma.Core.SheetMetalTasks
}
}
#endregion
public bool GetNewTask(int Id)
{
List<SheetMetaSendPlanInfoView> planInfoList = _executePlanInfoServices.QuerySheetMetalSendPlanData("1001").Result;
if (planInfoList == null || planInfoList.Count == 0) return false;
var task= planInfoList.FirstOrDefault(d=>d.ExecuteStatus==2&& d.ObjId!= Id);
if (task == null) return false;
else return true;
}
}
}

Loading…
Cancel
Save