From ef409d6ed01cf7da29f0033f0180b192f18d1e1c Mon Sep 17 00:00:00 2001
From: xiaojiao <xiaojiao@kaokeziliao.com>
Date: 星期四, 30 四月 2026 08:52:46 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/KuKa/BeiJingBeiQiAGV
---
项目代码/WIDESEA_WCSServer/WIDESEAWCS_Tasks/TaskAcquisition/TaskAcquisition_Back1_Job.cs | 195 +++++++++++++++++++++++++++++-------------------
1 files changed, 116 insertions(+), 79 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 0598f50..3610ae9 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"
@@ -8,8 +8,10 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Common.StationEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
+using WIDESEAWCS_DTO.PDA;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_ISystemServices;
@@ -43,101 +45,136 @@
}
public Task Execute(IJobExecutionContext context)
{
- string ip = "127.0.0.1";
- int port = 502;
- string Region = "鍚庡簳鏉�1";
- ModbusTcp modbusTcp = new ModbusTcp(ip, port, Region);
- Baseconversion baseconversion = new Baseconversion();
- modbusTcp.Connect();
-
- 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 }; // 鍙枡鐨勭偣浣� 缁堢偣浣嶇疆
-
- try
+ bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
+ if (flag && value != null)
{
- for (int i = 10; i < 90; i += 20)
+ OtherDevice device = (OtherDevice)value;
+ if (!device.IsConnected)
{
- byte[] SignalNumber = modbusTcp.Read(Signal[i].ToString(), 1); // 淇″彿 1锛氬彨鏂� 2锛氭媺鍑虹┖妗�
+ return Task.CompletedTask;
+ }
+ //string ip = "127.0.0.1";
+ //int port = 502;
+ //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 }; // 鍙枡鐨勭偣浣� 缁堢偣浣嶇疆
- if (SignalNumber[1] == 1)
+ try
+ {
+ for (int i = 10; i < 90; i += 20)
{
- byte[] PartNumber = modbusTcp.Read(i.ToString(), 20); // 璇诲彇闆朵欢鍙�
+ byte[] SignalNumber = device.Communicator.Read(Signal[i].ToString(), 1); // 淇″彿 1锛氬彨鏂� 2锛氭媺鍑虹┖妗�
- if (PartNumber[1] == 0) continue;
-
- string Ku1_Value = baseconversion.TenthTurn16(PartNumber);
- if (Ku1_Value != "" && Ku1_Value != null)
+ Dt_StationManager dt_StationManager = _stationManagerRepository.QueryFirst(
+ x => x.StationLocation == FeedingPoint[i].ToString()
+ && x.StationStatus != ((int)StationEnum.Disable).ToString());
+ if (dt_StationManager == null)
{
- // 绛夊姛鑳芥祴璇曞畬锛岃繖閲岃鍋氭棩蹇楄褰�
-
- Console.WriteLine(Ku1_Value);
- // 鎵惧搴旂殑闆朵欢鍙锋槸鍚﹀凡缁忕粦瀹�(缁勭洏)
- Dt_MaterialInfo dt_MaterialInfo = _IDt_MaterialInfoRepository.QueryFirst(x => x.MaterialName == Ku1_Value);
-
- if (dt_MaterialInfo != null && dt_MaterialInfo.IsBind && dt_MaterialInfo.EndPosition == null)
- {
- Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.PalletCode == dt_MaterialInfo.ContainerCode);
- if (dt_Task != null) continue; //璇佹槑鏈夊綋鍓嶄换鍔�
-
- 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.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.CurrentAddress = dt_MaterialInfo.Position; // 褰撳墠浣嶇疆
- dt_Task.NextAddress = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
-
- dt_MaterialInfo.EndPosition = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
-
- _taskRepository.AddData(dt_Task);
- _IDt_MaterialInfoRepository.UpdateData(dt_MaterialInfo);
- }
-
- // 濡傛灉娌$粦瀹氬垯涓嶇敓鎴愪换鍔� 濡傛灉鏌ユ壘鍒板搴旂殑闆朵欢鍙风粦瀹氫簡 鍒欑敓鎴愪竴鏉′换鍔℃暟鎹�
+ // 杩欓噷搴旇瑕佸姞鏃ュ織 璁板綍鎵句笉鍒扮珯鍙扮殑淇℃伅
+ Console.WriteLine($"{DateTime.Now} 褰撳墠绔欏彴銆恵FeedingPoint[i].ToString()} 鏈厤缃垨宸茬鐢ㄣ��");
+ continue;
}
+
+ if (SignalNumber[1] == 1)
+ {
+ byte[] PartNumber = device.Communicator.Read(i.ToString(), 20); // 璇诲彇闆朵欢鍙�
+
+ string Ku1_Value = baseconversion.TenthTurn16(PartNumber);
+ if (Ku1_Value != "" && Ku1_Value != null)
+ {
+ // 绛夊姛鑳芥祴璇曞畬锛岃繖閲岃鍋氭棩蹇楄褰�
+
+ Console.WriteLine(Ku1_Value);
+ // 鎵惧搴旂殑闆朵欢鍙锋槸鍚﹀凡缁忕粦瀹�(缁勭洏) // 杩欓噷瑕佹敼瑕佸姞鍖哄煙 鍔犳槸鍚﹀凡鐢熸垚浠诲姟 杩樿鏍规嵁鏃堕棿鎺掑簭 鍏堢粦瀹氱殑鍏堝彂杩囧幓
+ 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();
+
+ if (dt_MaterialInfo != null)
+ {
+ Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.PalletCode == dt_MaterialInfo.ContainerCode);
+ if (dt_Task != null) continue; //璇佹槑鏈夊綋鍓嶄换鍔�
+
+ 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.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.CurrentAddress = dt_MaterialInfo.Position; // 褰撳墠浣嶇疆
+ dt_Task.NextAddress = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
+
+ dt_MaterialInfo.EndPosition = FeedingPoint[i].ToString(); // 缁堢偣浣嶇疆
+
+ dt_StationManager.StationStatus = ((int)StationEnum.Thereisatask).ToString();
+ dt_StationManager.StationRemark = dt_MaterialInfo.ContainerCode;
+ _stationManagerRepository.UpdateData(dt_StationManager);
+
+
+ _taskRepository.AddData(dt_Task);
+ _IDt_MaterialInfoRepository.UpdateData(dt_MaterialInfo);
+ }
+
+ // 濡傛灉娌$粦瀹氬垯涓嶇敓鎴愪换鍔� 濡傛灉鏌ユ壘鍒板搴旂殑闆朵欢鍙风粦瀹氫簡 鍒欑敓鎴愪竴鏉′换鍔℃暟鎹�
+ }
+ }
+
+ if (SignalNumber[1] == 2) // 琛ㄧず鎷夊嚭绌烘
+ {
+ Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.SourceAddress == FeedingPoint[i].ToString() && x.TaskType == (int)TaskAGVCarryTypeEnum.CarryEmpty);
+ if (dt_Task != null) continue;
+
+ Dt_StationManager RecyclingpointStation = _stationManagerRepository.QueryFirst(x =>
+ x.StationStatus == ((int)StationEnum.Enable).ToString()
+ && x.StationArea == ((int)StationEnum.Rearbaseplate1).ToString()
+ && x.Remark == "鍥炴敹鐐�");
+
+ if (RecyclingpointStation == null)
+ {
+ // 璁板綍閿欒鏃ュ織
+ continue;
+ }
+ dt_Task = new Dt_Task();
+ dt_Task.PalletCode = dt_StationManager.StationRemark;
+ dt_Task.SourceAddress = FeedingPoint[i].ToString();
+ 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.NextAddress = RecyclingpointStation.StationLocation;// 缁堢偣浣嶇疆
+
+ RecyclingpointStation.StationStatus = ((int)StationEnum.Thereisatask).ToString();
+
+ _stationManagerRepository.UpdateData(RecyclingpointStation);
+ _taskRepository.AddData(dt_Task);
+ }
+
}
+ }
+ catch (Exception)
+ {
- if (SignalNumber[1] == 2) // 琛ㄧず鎷夊嚭绌烘
- {
- Dictionary<int, int> Endpointposition = new Dictionary<int, int>() { [10] = 3001, [20] = 3002, [30] = 3003, [40] = 3004 }; // 鍙枡鐨勭偣浣� 缁堢偣浣嶇疆
- Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.SourceAddress == FeedingPoint[i].ToString() && x.TaskType == (int)TaskAGVCarryTypeEnum.CarryEmpty);
- if (dt_Task != null) continue;
-
- dt_Task = new Dt_Task();
- dt_Task.PalletCode = "绌烘瀛�";
- dt_Task.SourceAddress = FeedingPoint[i].ToString();
- dt_Task.TargetAddress = Endpointposition[i].ToString();
- 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.NextAddress = Endpointposition[i].ToString(); // 缁堢偣浣嶇疆
- _taskRepository.AddData(dt_Task);
- }
-
+ throw;
}
}
- catch (Exception)
- {
-
- throw;
- }
-
// 16杩涘埗杞垚10杩涘埗
// 2. 16杩涘埗 鈫� 杞洖鍗佽繘鍒讹紙浣犺鐨勫姛鑳斤級
- ulong decimalResult = Convert.ToUInt64("123", 16);
- Console.WriteLine("16杩涘埗杞洖鍗佽繘鍒讹細" + decimalResult);
+ //ulong decimalResult = Convert.ToUInt64("123", 16);
+ //Console.WriteLine("16杩涘埗杞洖鍗佽繘鍒讹細" + decimalResult);
- // 鍐欏叆
- bool flag = modbusTcp.Write("30", decimalResult.ToString());
+ //// 鍐欏叆
+ //bool flag2 = modbusTcp.Write("30", decimalResult.ToString());
- modbusTcp.Disconnect();
- Console.WriteLine("杩涘叆浜員askAcquisition_Back1_Job");
+ //modbusTcp.Disconnect();
+ //Console.WriteLine("杩涘叆浜員askAcquisition_Back1_Job");
return Task.CompletedTask;
}
}
--
Gitblit v1.9.3