From f45293a0c3c9838567d6ff01eae53157a9ed5284 Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期四, 05 三月 2026 10:59:38 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs | 277 +++++++++----------------------------------------------
1 files changed, 45 insertions(+), 232 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
index e9d33b0..e57cee0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -40,7 +40,7 @@
private readonly IRouterRepository _routerRepository;
private readonly ITask_HtyRepository _taskHtyRepository;
private readonly IDt_needBarcodeRepository _taskNeedBarcodeRepository;
-
+
private Dictionary<string, OrderByType> _taskOrderBy = new()
{
@@ -95,6 +95,8 @@
// 璁剧疆浠诲姟鐨勫垱寤鸿�呬负"WMS"
task.Creater = "WMS";
task.CarType = item.CarType;
+ task.PVI = item.PVI;
+ task.NextAddress = item.NextAddress;
// 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄嚭搴撲换鍔�
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -105,18 +107,11 @@
{
// 璁剧疆浠诲姟鐘舵�佷负鍑哄簱鏂板缓
- task.TaskState =(int)TaskOutStatusEnum.OutNew;
+ task.TaskState = (int)TaskOutStatusEnum.OutNew;
// 璁剧疆褰撳墠鍦板潃涓烘簮鍦板潃
task.CurrentAddress = item.SourceAddress;
// 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
- task.NextAddress = routers.FirstOrDefault().ChildPosi;
-
- if (item.SourceAddress == "2009")
- {
- task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
- // 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
- task.NextAddress = "2015";
- }
+ //task.NextAddress = routers.FirstOrDefault().ChildPosi;
}
else
{
@@ -146,7 +141,7 @@
// 璁剧疆褰撳墠鍦板潃涓烘簮鍦板潃
task.CurrentAddress = item.SourceAddress;
// 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
- task.NextAddress = routers.FirstOrDefault().ChildPosi;
+ //task.NextAddress = routers.FirstOrDefault().ChildPosi;
}
}
// 灏嗚浆鎹㈠悗鐨勪换鍔℃坊鍔犲埌浠诲姟鍒楄〃涓�
@@ -402,6 +397,39 @@
}
/// <summary>
+ /// 妯Щ鏈哄彇杞﹂杞﹀垽瀹�
+ /// </summary>
+ /// <param name="taskNum">浠诲姟鍙�</param>
+ public WebResponseContent TCSendTask([NotNull] Dt_Task task, string Position)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+
+ // 鑾峰彇WMSip鍦板潃
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.TCGetCarPass)?.ConfigValue;
+ if (wmsBase == null || updateTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + updateTask;
+
+ var result = HttpHelper.PostAsync(wmsIpAddress, new { PVI = task.PVI, Position = Position }.ToJsonString()).Result;
+ content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ if (!content.Status) throw new Exception("");
+ return content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+
+ /// <summary>
/// 灏嗕换鍔$姸鎬佷慨鏀逛负涓嬩竴涓姸鎬�
/// </summary>
/// <param name="task">浠诲姟瀹炰綋瀵硅薄</param>
@@ -425,7 +453,8 @@
Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
task_Hty.TaskId = 0;
-
+ //task_Hty.CarType = task.CarType;
+ task_Hty.PVI = task.PVI;
BaseDal.DeleteData(task);
_taskHtyRepository.AddData(task_Hty);
}
@@ -445,7 +474,7 @@
{
#region 鍏ュ簱璋冪敤鎺ュ彛鑾峰彇璐т綅鍦板潃
- // TODO: 璋冪敤鎺ュ彛鑾峰彇璐т綅鍦板潃
+ // 璋冪敤鎺ュ彛鑾峰彇璐т綅鍦板潃
// 鍒涘缓璇锋眰瀵硅薄
var taskDto = new RequestTaskDto()
{
@@ -496,6 +525,7 @@
Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
task_Hty.TaskId = 0;
+ task_Hty.PVI = task.PVI;
BaseDal.DeleteData(task);
_taskHtyRepository.AddData(task_Hty);
@@ -548,7 +578,7 @@
#endregion 鏇存柊浠诲姟鐘舵��
- content = WebResponseContent.Instance.OK();
+ //content = WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
@@ -597,7 +627,7 @@
/// </summary>
/// <param name="taskNum">浠诲姟缂栧彿</param>
/// <returns>杩斿洖澶勭悊缁撴灉</returns>
- public WebResponseContent StackCraneTaskCompleted(int taskNum)
+ public WebResponseContent StackCraneTaskCompleted(int taskNum, bool rfiderror = false)
{
WebResponseContent content = new WebResponseContent();
try
@@ -822,222 +852,5 @@
#endregion 閲嶅啓鏂规硶
-
-
-
-
- //===========================杞﹁酱涓婃枡=====================
- public WebResponseContent GetFeedbackAxleloading()
- {
-
- WebResponseContent content = new WebResponseContent();
- try
- {
- var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
- var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
- var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestAxleloading)?.ConfigValue;
- if (wmsBase == null || completeTask == null)
- {
- throw new InvalidOperationException("WMS IP 鏈厤缃�");
- }
- var wmsIpAddress = wmsBase + completeTask;
- var taskDto = new RequestTaskDto()
- {
- PalletCode = "1",
- };
- var result = HttpHelper.PostAsync(wmsIpAddress,taskDto.ToJsonString()).Result;
- content = JsonConvert.DeserializeObject<WebResponseContent>(result);
- return content;
- }
- catch (Exception ex)
- {
- return content.Error($"{ex.Message}");
- }
- }
-
- public WebResponseContent UpdateAxleCurrentStatue(string CZTM)
- {
-
- WebResponseContent content = new WebResponseContent();
- try
- {
- var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
- var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
- var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateAxleCurrentStatue)?.ConfigValue;
- if (wmsBase == null || completeTask == null)
- {
- throw new InvalidOperationException("WMS IP 鏈厤缃�");
- }
- var wmsIpAddress = wmsBase + completeTask;
- var keys = new Dictionary<string, object>()
- {
- {"CZTM", CZTM}
- };
-
-
- var taskDto = new RequestTaskDto()
- {
- PalletCode = CZTM,
- };
-
-
- var result = HttpHelper.PostAsync(wmsIpAddress, taskDto.ToJsonString()).Result;
- content = JsonConvert.DeserializeObject<WebResponseContent>(result);
- return content;
- }
- catch (Exception ex)
- {
- return content.Error($"{ex.Message}");
- }
- }
-
-
- //璇诲彇鐢宠锛岀粰agv涓嬪彂浠诲姟
- public WebResponseContent GetAGVTaskdistribution(string TargetAddress)
- {
-
- WebResponseContent content = new WebResponseContent();
- try
- {
- var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
- var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
- var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.genAgvSchedulingTask)?.ConfigValue;
- if (wmsBase == null || completeTask == null)
- {
- throw new InvalidOperationException("WMS IP 鏈厤缃�");
- }
- var wmsIpAddress = wmsBase + completeTask;
- var taskDto = new RequestTaskDto()
- {
- RequestType = "999",
- Position = TargetAddress,
- };
-
-
- var result = HttpHelper.PostAsync(wmsIpAddress, taskDto.ToJsonString()).Result;
- content = JsonConvert.DeserializeObject<WebResponseContent>(result);
- return content;
- }
- catch (Exception ex)
- {
- return content.Error($"{ex.Message}");
- }
- }
-
-
- public WebResponseContent SetPlcResponState(string TargetAddress)
- {
- try
- {
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
- DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ResponState");
- if (conveyorLine.Communicator.Write(deviceProDTOt.DeviceProAddress, (short)2))
- {
- Console.Out.WriteLine("鎴愬姛锛佸啓鍑鸿溅杞寸嚎鏈agv鍙栬揣瀹屾垚淇″彿锛�2");
- return WebResponseContent.Instance.OK();
- }
- else
- {
-
- bool st= conveyorLine.Communicator.Write(deviceProDTOt.DeviceProAddress, (short)3);
- Console.Out.WriteLine($"鍐欏嚭杞﹁酱绾挎湯绔痑gv鍙栬揣瀹屾垚淇″彿澶辫触淇℃伅锛屽啓鍏ワ細3,鏄惁鎴愬姛锛歿st}");
- return WebResponseContent.Instance.Error();
- }
- }
- catch (Exception ex)
- {
- Console.Out.WriteLine($"鍐欏嚭杞﹁酱绾挎湯绔痑gv鍙栬揣瀹屾垚淇″彿澶辫触淇℃伅锛屾晠闅滀俊鎭細{ex.Message}");
- return WebResponseContent.Instance.Error();
- }
- }
-
- public WebResponseContent GetPlcState(string TargetAddress)
- {
-
- Dt_StationManager dt_Station=_stationManagerRepository.QueryFirst(x => x.stationLocation == TargetAddress);
- if(dt_Station == null)
- return WebResponseContent.Instance.Error("鏈壘鍒板帇瑁呬綅淇℃伅锛�");
- if(dt_Station.stationStatus=="0")
- return WebResponseContent.Instance.Error("璇ュ帇瑁呬綅宸茶绂佺敤锛佷笉鍙敓鎴恆gv浠诲姟");
-
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
-
- //DeviceProDTO? devicePr = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == "2033" && x.DeviceProParamName == "ConveyorLineSingal");
- short agv20 = conveyorLine.Communicator.Read<short>("DB5.794");
- if (agv20 != 1) //鑾峰彇涓嬭酱澶勬槸鍚︽湁鏂欏崰鐢�
- {
- return WebResponseContent.Instance.Error($"鏈娴嬪埌agv鍙栨枡绔欏彴鏈夎揣锛屼笉鍙笅鍙戜换鍔★紝璇诲彇鍒帮細{agv20}");
- }
-
-
-
-
- DeviceProDTO? deviceProDTOt = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ConveyorLineSingal");
- DeviceProDTO? deviceProDTOt2 = conveyorLine.DeviceProDTOs.Find(x => x.DeviceChildCode == TargetAddress && x.DeviceProParamName == "ResponState");
- if (conveyorLine.Communicator.Read<short>(deviceProDTOt.DeviceProAddress)==1)
- {
- conveyorLine.Communicator.Write(deviceProDTOt2.DeviceProAddress,(short)1);
- return WebResponseContent.Instance.OK();
- }
- else
- {
- conveyorLine.Communicator.Write(deviceProDTOt2.DeviceProAddress, (short)2);
- return WebResponseContent.Instance.Error("璇诲彇鍒板帇瑁呬綅淇″彿鍙嶉涓嶅彲鏀捐揣锛佷笉鍙敓鎴恆gv浠诲姟");
- }
- }
-
-
-
- public WebResponseContent SetPlcPalletCode(SaveModel saveModel)
- {
- WebResponseContent webResponse = new WebResponseContent();
- try
- {
- if (saveModel.DelKeys.Count != 2)
- {
- return webResponse.Error("wcs浼犲弬閿欒锛�");
- }
- string AddStitic = saveModel.DelKeys[0].ToString();
- if (AddStitic == "") return webResponse.Error("閫夋嫨鐨勭珯鍙颁负绌猴紝璇烽�夋嫨閫夋嫨绔欏彴锛�");
- string PalletCode = saveModel.DelKeys[1].ToString();
- if (PalletCode == "") return webResponse.Error("杈撳叆鐨勬潯鐮佷负绌猴紝璇疯緭鍏ユ潯鐮佷俊鎭紒");
-
- IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1000");
- CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
-
- bool setplc = false;
- switch (AddStitic)
- {
- case "1010":
- setplc = conveyorLine.Communicator.Write("DB5.914", (string)PalletCode);
- break;
- case "2015":
- setplc = conveyorLine.Communicator.Write("DB5.434", (string)PalletCode);
- break;
- case "2017":
- setplc = conveyorLine.Communicator.Write("DB5.554", (string)PalletCode);
- break;
- case "2021":
- setplc = conveyorLine.Communicator.Write("DB5.794", (string)PalletCode);
- break;
- }
-
- if (setplc)
- {
- return webResponse.OK($"瀵箋AddStitic}绔欏彴鍐欏叆鏉$爜锛歿PalletCode}锛屾垚鍔�");
- }
- else
- {
- return webResponse.Error($"瀵箋AddStitic}绔欏彴鍐欏叆鏉$爜锛歿PalletCode}锛屽け璐�");
- }
- }
- catch (Exception ex)
- {
- return webResponse.Error($"閿欒淇℃伅锛歿ex.Message}");
- throw;
- }
- }
}
}
\ No newline at end of file
--
Gitblit v1.9.3