From d662639715b6f5e56734a3f36a5d43ba433b1cc4 Mon Sep 17 00:00:00 2001
From: wxw <Administrator@DESKTOP-5BIMHQ3>
Date: 星期日, 15 九月 2024 16:34:57 +0800
Subject: [PATCH] 任务管理任务日志操作列增加上传按钮
---
Admin.NET/WCS.Application/Hub/PlcDeviceHub.cs | 82 +++++++++++++++++++++++++++++------------
1 files changed, 58 insertions(+), 24 deletions(-)
diff --git a/Admin.NET/WCS.Application/Hub/PlcDeviceHub.cs b/Admin.NET/WCS.Application/Hub/PlcDeviceHub.cs
index 7a8ff9c..fdff08a 100644
--- a/Admin.NET/WCS.Application/Hub/PlcDeviceHub.cs
+++ b/Admin.NET/WCS.Application/Hub/PlcDeviceHub.cs
@@ -71,7 +71,7 @@
// 鐢ㄤ簬淇濆瓨姣忎釜璁惧鐨勫垵濮嬬姸鎬�
var initialStates = new Dictionary<long, WcsDeviceOutput>();
- var listPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine).ToList();
+ var listPlc = _db.Queryable<WcsPlc>().Where(s => s.Type == PLCTypeEnum.StackingMachine || s.Type == PLCTypeEnum.ConveyorLine).Where(s => s.Enable == YesNoEnum.Y).ToList();
var listPlcId = listPlc.Select(s => s.Id).ToList();
var listPlcDevice = _db.Queryable<WcsDevice>().Where(s => s.DeviceType == DeviceTypeEnum.Business && listPlcId.Contains(s.PlcId)).Select<WcsDeviceOutput>().ToList();
var listPlcDeviceId = listPlcDevice.Select(s => s.Id).ToList();
@@ -110,50 +110,84 @@
modDevice.Wcs = Convert.ToString(wcs);
//浠诲姟鍙�
var modPositionTask = listPosition.FirstOrDefault(s => s.Text == "浠诲姟鍙�");
- (result, var taskNo) = modConn.GetPlcDBValue(modPositionTask.PosType, modDevice.DbNumber, modPositionTask.PlcPos, modPositionTask.StringLength);
- modDevice.TaskNo = Convert.ToString(taskNo);
+ if (modPositionTask != null)
+ {
+ (result, var taskNo) = modConn.GetPlcDBValue(modPositionTask.PosType, modDevice.DbNumber, modPositionTask.PlcPos, modPositionTask.StringLength);
+ modDevice.TaskNo = Convert.ToString(taskNo);
+ }
//浠诲姟绫诲瀷
var modPositionTaskType = listPosition.FirstOrDefault(s => s.Text == "浠诲姟绫诲瀷");
- (result, var taskType) = modConn.GetPlcDBValue(modPositionTaskType.PosType, modDevice.DbNumber, modPositionTaskType.PlcPos);
- modDevice.TaskType = (TaskTypeEnum)Convert.ToInt32(taskType);
+ if (modPositionTaskType != null)
+ {
+ (result, var taskType) = modConn.GetPlcDBValue(modPositionTaskType.PosType, modDevice.DbNumber, modPositionTaskType.PlcPos);
+ modDevice.TaskType = (TaskTypeEnum)Convert.ToInt32(taskType);
+ }
//璧峰宸ヤ綅
var modPositionStartLocatNo = listPosition.FirstOrDefault(s => s.Text == "璧峰宸ヤ綅");
- (result, var startLocatNo) = modConn.GetPlcDBValue(modPositionStartLocatNo.PosType, modDevice.DbNumber, modPositionStartLocatNo.PlcPos);
- modDevice.StartLocatNo = Convert.ToString(startLocatNo);
+ if (modPositionStartLocatNo != null)
+ {
+ (result, var startLocatNo) = modConn.GetPlcDBValue(modPositionStartLocatNo.PosType, modDevice.DbNumber, modPositionStartLocatNo.PlcPos);
+ modDevice.StartLocatNo = Convert.ToString(startLocatNo);
+ }
//鐩殑宸ヤ綅
var modPositionEndLocatNo = listPosition.FirstOrDefault(s => s.Text == "鐩殑宸ヤ綅");
- (result, var endLocatNo) = modConn.GetPlcDBValue(modPositionEndLocatNo.PosType, modDevice.DbNumber, modPositionEndLocatNo.PlcPos);
- modDevice.EndLocatNo = Convert.ToString(endLocatNo);
+ if (modPositionEndLocatNo != null)
+ {
+ (result, var endLocatNo) = modConn.GetPlcDBValue(modPositionEndLocatNo.PosType, modDevice.DbNumber, modPositionEndLocatNo.PlcPos);
+ modDevice.EndLocatNo = Convert.ToString(endLocatNo);
+ }
//鎵樼洏鐮�
var modPositionPalletNo = listPosition.FirstOrDefault(s => s.Text == "鎵樼洏鐮�");
- (result, var palletNo) = modConn.GetPlcDBValue(modPositionPalletNo.PosType, modDevice.DbNumber, modPositionPalletNo.PlcPos, modPositionPalletNo.StringLength);
- modDevice.PalletNo = Convert.ToString(palletNo);
+ if (modPositionPalletNo != null)
+ {
+ (result, var palletNo) = modConn.GetPlcDBValue(modPositionPalletNo.PosType, modDevice.DbNumber, modPositionPalletNo.PlcPos, modPositionPalletNo.StringLength);
+ modDevice.PalletNo = Convert.ToString(palletNo);
+ }
if (modPlc.Type == PLCTypeEnum.ConveyorLine)
{
//鏀捐揣鎺�
var modPositionReleaseRow = listPosition.FirstOrDefault(s => s.Text == "鏀捐揣鎺�");
- (result, var releaseRow) = modConn.GetPlcDBValue(modPositionReleaseRow.PosType, modDevice.DbNumber, modPositionReleaseRow.PlcPos);
- modDevice.ReleaseRow = Convert.ToInt32(releaseRow);
+ if (modPositionReleaseRow != null)
+ {
+ (result, var releaseRow) = modConn.GetPlcDBValue(modPositionReleaseRow.PosType, modDevice.DbNumber, modPositionReleaseRow.PlcPos);
+ modDevice.ReleaseRow = Convert.ToInt32(releaseRow);
+ }
//鏀捐揣鍒�
var modPositionReleaseCol = listPosition.FirstOrDefault(s => s.Text == "鏀捐揣鍒�");
- (result, var releaseCol) = modConn.GetPlcDBValue(modPositionReleaseCol.PosType, modDevice.DbNumber, modPositionReleaseCol.PlcPos);
- modDevice.ReleaseCol = Convert.ToInt32(releaseCol);
+ if (modPositionReleaseCol != null)
+ {
+ (result, var releaseCol) = modConn.GetPlcDBValue(modPositionReleaseCol.PosType, modDevice.DbNumber, modPositionReleaseCol.PlcPos);
+ modDevice.ReleaseCol = Convert.ToInt32(releaseCol);
+ }
//鏀捐揣灞�
var modPositionReleaseStorey = listPosition.FirstOrDefault(s => s.Text == "鏀捐揣灞�");
- (result, var releaseStorey) = modConn.GetPlcDBValue(modPositionReleaseStorey.PosType, modDevice.DbNumber, modPositionReleaseStorey.PlcPos);
- modDevice.ReleaseStorey = Convert.ToInt32(releaseStorey);
+ if (modPositionReleaseStorey != null)
+ {
+ (result, var releaseStorey) = modConn.GetPlcDBValue(modPositionReleaseStorey.PosType, modDevice.DbNumber, modPositionReleaseStorey.PlcPos);
+ modDevice.ReleaseStorey = Convert.ToInt32(releaseStorey);
+ }
//鍙栬揣鎺�
var modPositionPickRow = listPosition.FirstOrDefault(s => s.Text == "鍙栬揣鎺�");
- (result, var pickRow) = modConn.GetPlcDBValue(modPositionPickRow.PosType, modDevice.DbNumber, modPositionPickRow.PlcPos);
- modDevice.PickRow = Convert.ToInt32(pickRow);
+ if (modPositionPickRow != null)
+ {
+ (result, var pickRow) = modConn.GetPlcDBValue(modPositionPickRow.PosType, modDevice.DbNumber, modPositionPickRow.PlcPos);
+ modDevice.PickRow = Convert.ToInt32(pickRow);
+ }
//鍙栬揣鍒�
var modPositionPickCol = listPosition.FirstOrDefault(s => s.Text == "鍙栬揣鍒�");
- (result, var pickCol) = modConn.GetPlcDBValue(modPositionPickCol.PosType, modDevice.DbNumber, modPositionPickCol.PlcPos);
- modDevice.PickCol = Convert.ToInt32(pickCol);
+ if (modPositionPickCol != null)
+ {
+ (result, var pickCol) = modConn.GetPlcDBValue(modPositionPickCol.PosType, modDevice.DbNumber, modPositionPickCol.PlcPos);
+ modDevice.PickCol = Convert.ToInt32(pickCol);
+ }
//鍙栬揣灞�
var modPositionPickStorey = listPosition.FirstOrDefault(s => s.Text == "鍙栬揣灞�");
- (result, var pickStorey) = modConn.GetPlcDBValue(modPositionPickStorey.PosType, modDevice.DbNumber, modPositionPickStorey.PlcPos);
- modDevice.PickStorey = Convert.ToInt32(pickStorey);
+ if (modPositionPickStorey != null)
+ {
+ (result, var pickStorey) = modConn.GetPlcDBValue(modPositionPickStorey.PosType, modDevice.DbNumber, modPositionPickStorey.PlcPos);
+ modDevice.PickStorey = Convert.ToInt32(pickStorey);
+ }
+
}
}
//else
@@ -169,7 +203,7 @@
if (initialStates.TryGetValue(modDevice.Id, out var initialState))
{
if (modDevice.Status != initialState.Status ||
- modDevice.Plc != initialState.Plc ||
+ (modDevice.Plc.IsNullOrEmpty() && modDevice.Plc != initialState.Plc) ||
modDevice.Wcs != initialState.Wcs ||
modDevice.TaskNo != initialState.TaskNo ||
modDevice.TaskType != initialState.TaskType ||
--
Gitblit v1.8.0