From 9376389dbf19d202f766a4fe47cf80dfe4db4f42 Mon Sep 17 00:00:00 2001
From: xiaojiao <xiaojiao@kaokeziliao.com>
Date: 星期四, 30 四月 2026 11:47:19 +0800
Subject: [PATCH] 规范读取modbus,增加容器出入场调接口
---
项目代码/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs | 66 +++++++++++++++------------------
1 files changed, 30 insertions(+), 36 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs"
index 3610ae9..450e111 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs"
@@ -11,6 +11,7 @@
using WIDESEAWCS_Common.StationEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
+using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.PDA;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_IBasicInfoService;
@@ -58,32 +59,27 @@
//string Region = "鍚庡簳鏉�1";
//ModbusTcp modbusTcp = new ModbusTcp(ip, port, Region);
//modbusTcp.Connect();
- Baseconversion baseconversion = new Baseconversion();
- Dictionary<int, int> Signal = new Dictionary<int, int>() { [10] = 2, [30] = 3, [50] = 4, [70] = 5 };
- Dictionary<int, int> FeedingPoint = new Dictionary<int, int>() { [10] = 2001, [30] = 2002, [50] = 2003, [70] = 2004 }; // 鍙枡鐨勭偣浣� 缁堢偣浣嶇疆
+ // Dictionary<int, int> Signal = new Dictionary<int, int>() { [10] = 2, [30] = 3, [50] = 4, [70] = 5 };
+ // Dictionary<int, int> FeedingPoint = new Dictionary<int, int>() { [10] = 2001, [30] = 2002, [50] = 2003, [70] = 2004 }; // 鍙枡鐨勭偣浣� 缁堢偣浣嶇疆
+ Baseconversion baseconversion = new Baseconversion();
try
{
- for (int i = 10; i < 90; i += 20)
- {
- byte[] SignalNumber = device.Communicator.Read(Signal[i].ToString(), 1); // 淇″彿 1锛氬彨鏂� 2锛氭媺鍑虹┖妗�
+ List<Dt_StationManager> dt_StationManagers = _stationManagerRepository.QueryData(x =>
+ x.StationStatus == ((int)StationEnum.Enable).ToString()
+ && x.StationArea == ((int)StationEnum.Rearbaseplate1).ToString()
+ && x.Remark == "涓婄嚎鐐�").ToList();
- Dt_StationManager dt_StationManager = _stationManagerRepository.QueryFirst(
- x => x.StationLocation == FeedingPoint[i].ToString()
- && x.StationStatus != ((int)StationEnum.Disable).ToString());
- if (dt_StationManager == null)
- {
- // 杩欓噷搴旇瑕佸姞鏃ュ織 璁板綍鎵句笉鍒扮珯鍙扮殑淇℃伅
- Console.WriteLine($"{DateTime.Now} 褰撳墠绔欏彴銆恵FeedingPoint[i].ToString()} 鏈厤缃垨宸茬鐢ㄣ��");
- continue;
- }
+ foreach (var item in dt_StationManagers)
+ {
+ byte[] SignalNumber = device.Communicator.Read(item.StationChildCode, 1); // 淇″彿 1锛氬彨鏂� 2锛氭媺鍑虹┖妗�
if (SignalNumber[1] == 1)
{
- byte[] PartNumber = device.Communicator.Read(i.ToString(), 20); // 璇诲彇闆朵欢鍙�
+ byte[] PartNumber = device.Communicator.Read(item.StationDeviceCode, 20); // 璇诲彇闆朵欢鍙�
string Ku1_Value = baseconversion.TenthTurn16(PartNumber);
- if (Ku1_Value != "" && Ku1_Value != null)
+ if (Ku1_Value.IsNotEmptyOrNull())
{
// 绛夊姛鑳芥祴璇曞畬锛岃繖閲岃鍋氭棩蹇楄褰�
@@ -91,7 +87,7 @@
// 鎵惧搴旂殑闆朵欢鍙锋槸鍚﹀凡缁忕粦瀹�(缁勭洏) // 杩欓噷瑕佹敼瑕佸姞鍖哄煙 鍔犳槸鍚﹀凡鐢熸垚浠诲姟 杩樿鏍规嵁鏃堕棿鎺掑簭 鍏堢粦瀹氱殑鍏堝彂杩囧幓
Dt_MaterialInfo? dt_MaterialInfo = _IDt_MaterialInfoRepository.QueryData(x => x.MaterialName == Ku1_Value
&& x.Region == ((int)StationEnum.Rearbaseplate1).ToString()
- && (x.EndPosition == null || x.EndPosition == "")).OrderBy(x => x.CreateDate).FirstOrDefault();
+ && (x.IsNotEmptyOrNull())).OrderBy(x => x.CreateDate).FirstOrDefault();
if (dt_MaterialInfo != null)
{
@@ -101,20 +97,19 @@
dt_Task = new Dt_Task();
dt_Task.PalletCode = dt_MaterialInfo.ContainerCode;
dt_Task.SourceAddress = dt_MaterialInfo.Position; // 褰撳墠浣嶇疆
- dt_Task.TargetAddress = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
+ dt_Task.TargetAddress = item.StationLocation; // 缁堢偣浣嶇疆
dt_Task.Grade = 2;
- dt_Task.TaskState = TaskAGVCarryStatusEnum.AGV_CarryNew.ObjToInt();
- dt_Task.TaskType = TaskAGVCarryTypeEnum.Carry.ObjToInt();
- dt_Task.Roadway = (Signal[i] - 1).ToString(); // 搴�1 鍙枡閭e氨鏄�1宸烽亾
+ dt_Task.TaskState = (int)TaskAGVCarryStatusEnum.AGV_CarryNew;
+ dt_Task.TaskType = (int)TaskAGVCarryTypeEnum.Carry;
+ dt_Task.Roadway = (int.Parse(item.StationChildCode) - 1).ToString(); // 搴�1 鍙枡閭e氨鏄�1宸烽亾
dt_Task.CurrentAddress = dt_MaterialInfo.Position; // 褰撳墠浣嶇疆
- dt_Task.NextAddress = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
+ dt_Task.NextAddress = item.StationLocation; // 缁堢偣浣嶇疆
- dt_MaterialInfo.EndPosition = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
+ dt_MaterialInfo.EndPosition = item.StationLocation; // 缁堢偣浣嶇疆
- dt_StationManager.StationStatus = ((int)StationEnum.Thereisatask).ToString();
- dt_StationManager.StationRemark = dt_MaterialInfo.ContainerCode;
- _stationManagerRepository.UpdateData(dt_StationManager);
-
+ item.StationStatus = ((int)StationEnum.Thereisatask).ToString();
+ item.StationRemark = dt_MaterialInfo.ContainerCode;
+ _stationManagerRepository.UpdateData(item);
_taskRepository.AddData(dt_Task);
_IDt_MaterialInfoRepository.UpdateData(dt_MaterialInfo);
@@ -126,7 +121,7 @@
if (SignalNumber[1] == 2) // 琛ㄧず鎷夊嚭绌烘
{
- Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.SourceAddress == FeedingPoint[i].ToString() && x.TaskType == (int)TaskAGVCarryTypeEnum.CarryEmpty);
+ Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.SourceAddress == item.StationLocation && x.TaskType == (int)TaskAGVCarryTypeEnum.CarryEmpty);
if (dt_Task != null) continue;
Dt_StationManager RecyclingpointStation = _stationManagerRepository.QueryFirst(x =>
@@ -140,14 +135,14 @@
continue;
}
dt_Task = new Dt_Task();
- dt_Task.PalletCode = dt_StationManager.StationRemark;
- dt_Task.SourceAddress = FeedingPoint[i].ToString();
+ dt_Task.PalletCode = item.StationRemark;
+ dt_Task.SourceAddress = item.StationLocation;
dt_Task.TargetAddress = RecyclingpointStation.StationLocation;
dt_Task.Grade = 2;
- dt_Task.TaskState = TaskAGVCarryStatusEnum.AGV_CarryNew.ObjToInt();
- dt_Task.TaskType = TaskAGVCarryTypeEnum.CarryEmpty.ObjToInt();
- dt_Task.Roadway = (Signal[i] - 1).ToString(); // 搴�1 鍙枡閭e氨鏄�1宸烽亾
- dt_Task.CurrentAddress = FeedingPoint[i].ToString(); // 褰撳墠浣嶇疆
+ dt_Task.TaskState = (int)TaskAGVCarryStatusEnum.AGV_CarryNew;
+ dt_Task.TaskType = (int)TaskAGVCarryTypeEnum.CarryEmpty;
+ dt_Task.Roadway = (int.Parse(item.StationChildCode) - 1).ToString(); // 搴�1 鍙枡閭e氨鏄�1宸烽亾
+ dt_Task.CurrentAddress = item.StationLocation; // 褰撳墠浣嶇疆
dt_Task.NextAddress = RecyclingpointStation.StationLocation;// 缁堢偣浣嶇疆
RecyclingpointStation.StationStatus = ((int)StationEnum.Thereisatask).ToString();
@@ -155,7 +150,6 @@
_stationManagerRepository.UpdateData(RecyclingpointStation);
_taskRepository.AddData(dt_Task);
}
-
}
}
catch (Exception)
--
Gitblit v1.9.3