From 98cd144e4d58dbfcc09a2ffb0dbb6925519088b3 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 06 十一月 2024 14:12:56 +0800
Subject: [PATCH] 最新代码更改
---
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 169 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 134 insertions(+), 35 deletions(-)
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index 53676e6..63d8ec4 100644
--- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -1,4 +1,5 @@
锘�#region << 鐗� 鏈� 娉� 閲� >>
+
/*----------------------------------------------------------------
* 鍛藉悕绌洪棿锛歐IDESEAWCS_TaskInfoService
* 鍒涘缓鑰咃細鑳$搴�
@@ -11,32 +12,27 @@
* 淇敼鏃堕棿锛�
* 鐗堟湰锛歏1.0.1
* 淇敼璇存槑锛�
- *
+ *
*----------------------------------------------------------------*/
+
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using HslCommunication;
+using Newtonsoft.Json;
using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
-using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
-using WIDESEAWCS_Common.TaskEnum;
namespace WIDESEAWCS_TaskInfoService
{
@@ -53,7 +49,8 @@
{nameof(Dt_Task.CreateDate),OrderByType.Asc},
};
- public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
+ public Dictionary<string, OrderByType> TaskOrderBy
+ { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
public List<int> TaskInboundTypes => typeof(TaskInboundTypeEnum).GetEnumIndexList();
@@ -134,14 +131,41 @@
WebResponseContent content = new WebResponseContent();
try
{
+ #region 鐪熷疄鏁版嵁
+ // TODO: 璋冪敤鎺ュ彛鑾峰彇涓嬩竴涓湴鍧�
+ //// 鍒涘缓璇锋眰瀵硅薄
+ //RequestTaskDto request = new RequestTaskDto()
+ //{
+ // Position = sourceAddress,
+ // PalletCode = palletCode,
+ //};
+
+ //// 鍙戦�佽姹傚苟绛夊緟鍝嶅簲
+ //var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result;
+
+ //// 鍙嶅簭鍒楀寲鍝嶅簲鍐呭
+ //content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ //// 妫�鏌ョ姸鎬佸苟杩斿洖
+ //if (!content.Status)
+ // return content;
+
+ //// 鍙嶅簭鍒楀寲浠诲姟鏁版嵁
+ //WMSTaskDTO task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+
+ //// 澶勭悊浠诲姟骞惰繑鍥炵粨鏋�
+ //content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
+
+ #endregion
+
WMSTaskDTO taskDTO = new WMSTaskDTO()
{
TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
Grade = 1,
PalletCode = palletCode,
- RoadWay = "SC01",
+ RoadWay = "CHSC01",
SourceAddress = sourceAddress,
- TargetAddress = "SC01",
+ TargetAddress = "CHSC01",
TaskState = (int)TaskInStatusEnum.InNew,
Id = 0,
TaskType = (int)TaskInboundTypeEnum.Inbound
@@ -168,6 +192,28 @@
}
/// <summary>
+ /// 鏍规嵁璁惧缂栧彿銆佸綋鍓嶅湴鍧�鏌ヨ杈撻�佺嚎鏈墽琛岀殑浠诲姟
+ /// </summary>
+ /// <param name="deviceNo">璁惧缂栧彿</param>
+ /// <param name="currentAddress">褰撳墠鍦板潃</param>
+ /// <returns></returns>
+ public Dt_Task QueryNextConveyorLineTask(string deviceNo, string currentAddress)
+ {
+ return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.NextAddress == currentAddress, TaskOrderBy);
+ }
+
+ /// <summary>
+ /// 鏍规嵁鎵樼洏鍙枫�佸綋鍓嶅湴鍧�鏌ヨ杈撻�佺嚎鏈墽琛岀殑浠诲姟
+ /// </summary>
+ /// <param name="Barcode">鎵樼洏鍙�</param>
+ /// <param name="currentAddress">褰撳墠鍦板潃</param>
+ /// <returns></returns>
+ public Dt_Task QueryBarCodeConveyorLineTask(string Barcode, string currentAddress)
+ {
+ return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.CurrentAddress == currentAddress && x.PalletCode == Barcode, TaskOrderBy);
+ }
+
+ /// <summary>
/// 鏍规嵁浠诲姟鍙枫�佷笅涓�鍦板潃鏌ヨ杈撻�佺嚎鎵ц涓殑浠诲姟
/// </summary>
/// <param name="taskNum">浠诲姟鍙�</param>
@@ -187,6 +233,17 @@
public Dt_Task QueryCompletedConveyorLineTask(int taskNum, string currentAddress)
{
return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish), TaskOrderBy);
+ }
+
+ /// <summary>
+ /// 鏍规嵁浠诲姟鍙枫�佸綋鍓嶅湴鍧�鏌ヨ杈撻�佺嚎鏂板缓鐨勪换鍔�
+ /// </summary>
+ /// <param name="taskNum">浠诲姟鍙�</param>
+ /// <param name="currentAddress">褰撳墠鍦板潃</param>
+ /// <returns></returns>
+ public Dt_Task QueryCraneConveyorLineTask(int taskNum, string currentAddress)
+ {
+ return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.InNew || x.TaskState == (int)TaskOutStatusEnum.OutNew), TaskOrderBy);
}
/// <summary>
@@ -362,10 +419,48 @@
if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish)
{
- Random random = new Random();
- task.CurrentAddress = task.NextAddress;
- task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}";
- task.TargetAddress = task.NextAddress;
+ if (task.Roadway.Contains("CH"))
+ {
+ Random random = new Random();
+ task.CurrentAddress = task.NextAddress;
+ task.NextAddress = $"{random.Next(1, 1).ToString().PadLeft(3, '0')}-{random.Next(0, 0).ToString().PadLeft(3, '0')}-{random.Next(1, 1).ToString().PadLeft(3, '0')}";
+ task.TargetAddress = task.NextAddress;
+ }
+ else
+ {
+ Random random = new Random();
+ task.CurrentAddress = task.NextAddress;
+ task.NextAddress = "002-020-001";
+ task.TargetAddress = task.NextAddress;
+ }
+
+ #region 鐪熷疄鏁版嵁
+ // TODO: 璋冪敤鎺ュ彛鑾峰彇涓嬩竴涓湴鍧�
+ //// 鍒涘缓璇锋眰瀵硅薄
+ //RequestTaskDto request = new RequestTaskDto()
+ //{
+ // Position = task.NextAddress,
+ // PalletCode = task.PalletCode,
+ //};
+
+ //// 鍙戦�佽姹傚苟绛夊緟鍝嶅簲
+ //var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result;
+
+ //// 鍙嶅簭鍒楀寲鍝嶅簲鍐呭
+ //content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ //// 妫�鏌ョ姸鎬佸苟杩斿洖
+ //if (!content.Status)
+ // return content;
+
+ //// 鍙嶅簭鍒楀寲浠诲姟鏁版嵁
+ //WMSTaskDTO taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+
+ //task.CurrentAddress = task.NextAddress;
+ //task.NextAddress = taskResult.TargetAddress;
+ //task.TargetAddress = task.NextAddress;
+ #endregion
+
}
}
else
@@ -461,7 +556,7 @@
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
{
- //todo
+ //todo 鍚屾鍒癢MS
int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
task.TaskState = nextStatus;
task.ModifyDate = DateTime.Now;
@@ -469,20 +564,25 @@
BaseDal.UpdateData(task);
_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄叆搴撳畬鎴�");
- WMSTaskDTO taskDTO = new WMSTaskDTO()
- {
- TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
- Grade = 1,
- PalletCode = task.PalletCode + "S",
- RoadWay = "SC01",
- SourceAddress = task.TargetAddress,
- TargetAddress = "CLOutAreaA",
- TaskState = (int)TaskOutStatusEnum.OutNew,
- Id = 0,
- TaskType = (int)TaskOutboundTypeEnum.Outbound
- };
- content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+ //var x = new { taskNum = taskNum };
+ //var result = HttpHelper.GetAsync("http:127.0.0.1:8098/api/Task/CompleteTaskAsync", x.ToJsonString()).Result;
+ //content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ //WMSTaskDTO taskDTO = new WMSTaskDTO()
+ //{
+ // TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
+ // Grade = 1,
+ // PalletCode = task.PalletCode + "S",
+ // RoadWay = "SC01",
+ // SourceAddress = task.TargetAddress,
+ // TargetAddress = "CLOutAreaA",
+ // TaskState = (int)TaskOutStatusEnum.OutNew,
+ // Id = 0,
+ // TaskType = (int)TaskOutboundTypeEnum.Outbound
+ //};
+
+ //content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
{
@@ -490,13 +590,12 @@
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
{
-
}
else
{
throw new Exception($"浠诲姟绫诲瀷閿欒,鏈壘鍒拌浠诲姟绫诲瀷,浠诲姟鍙�:銆恵taskNum}銆�,浠诲姟绫诲瀷:銆恵task.TaskType}銆�");
}
- content = WebResponseContent.Instance.OK();
+ //content = WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
@@ -596,4 +695,4 @@
return content;
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3