From 0128fce75a5e7cc9afc4bd89ce1966eb2231b69f Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期二, 31 三月 2026 10:55:33 +0800
Subject: [PATCH] 编写海康跨楼层接口
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 108 insertions(+), 9 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
index 203a99b..3bf1406 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
@@ -13,6 +13,7 @@
using WIDESEAWCS_DTO;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_QuartzJob;
namespace WIDESEAWCS_TaskInfoService
{
@@ -27,18 +28,20 @@
public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
{
WebResponseContent content = new WebResponseContent();
+ Dt_KLSLocationInfo? kLSLocationInfo = null;
try
{
int containerType = taskDTO.containerCode.Contains("LLM") ? (int)LocationTypeEnum.LargePallet : (int)LocationTypeEnum.SmallPallet;
#region 鐐瑰埌鐐�
if (!string.IsNullOrEmpty(taskDTO.toLocationCode))
{
- var LocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐硅揣浣嶃�恵taskDTO.toLocationCode}銆�");
- if (LocationInfo.LocationStatus != (int)LocationStatusEnum.Free) throw new Exception($"缁堢偣璐т綅銆恵taskDTO.toLocationCode}銆戣揣浣嶇姸鎬佷笉涓虹┖璐т綅");
+ kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒扮粓鐐硅揣浣嶃�恵taskDTO.toLocationCode}銆�");
+ if (kLSLocationInfo.LocationStatus != (int)LocationStatusEnum.Free) throw new Exception($"缁堢偣璐т綅銆恵taskDTO.toLocationCode}銆戣揣浣嶇姸鎬佷笉涓虹┖璐т綅");
}
#endregion
//鑾峰彇璐т綅淇℃伅
- Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
+ else
+ kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
Dt_Task dt_Task = new()
{
TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
@@ -60,6 +63,7 @@
content = SendKLSTask(dt_Task);
if (!content.Status) throw new Exception(content.Message);
dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
#endregion
try
{
@@ -125,6 +129,7 @@
content = SendKLSTask(dt_Task);
if (!content.Status) throw new Exception(content.Message);
dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
#endregion
try
{
@@ -197,18 +202,91 @@
}
#endregion
- #region 5 璺ㄦゼ灞傝繍杈撲换鍔″垱寤�
+ #region 5 璺ㄦゼ灞傝繍杈撲换鍔″垱寤� 锛堥兘鏄偣鍒扮偣锛�
public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
+ Dt_HKLocationInfo? hKLocationInfo = null;
+ Dt_StationInfo? stationInfo = null;
+ Dt_Task dt_Task = null;
+ //鍏ュ簱 鍒颁竴妤间笁涓珯鍙扮殑浣嶇疆
+ if (taskType == (int)TaskTypeEnum.Q3RK)
+ {
+ //璇诲彇鍏夌數淇″彿
+ var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "F1") as OtherDevice;
+ if (device == null) throw new Exception("鏈壘鍒�1妤艰川妫�闂ㄨ澶囦俊鎭�");
+ if (!device.IsConnected) throw new Exception("PLC1妤艰川妫�闂ㄨ澶囪繛鎺ュけ璐�");
+ bool value = device.GetValue<QualityInspectionCommandEnum, bool>(QualityInspectionCommandEnum.R_StockAvailableSymbol, taskDTO.toLocationCode);
+ if (value)
+ {
+ content.Error($"{taskDTO.toLocationCode}绔欏彴鏈夎揣锛屾棤娉曞叆搴�");
+ }
+ dt_Task = new Dt_Task()
+ {
+ TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ WMSTaskNum = taskDTO.taskCode,
+ Grade = taskDTO.taskPriority,
+ PalletCode = taskDTO.containerCode,
+ Roadway = hKLocationInfo.RoadwayNo,
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = taskType,
+ SourceAddress = taskDTO.fromLocationCode,
+ CurrentAddress = taskDTO.fromLocationCode,
+ NextAddress = taskDTO.toLocationCode,
+ TargetAddress = taskDTO.toLocationCode,
+ Creater = "WMS",
+ };
- return WebResponseContent.Instance.OK();
+ }
+ //鍑哄簱
+ if (taskType == (int)TaskTypeEnum.Q3CK)
+ {
+ stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+ if (stationInfo.StationName != LocationStatusEnum.InStock.ToString()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.toLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+ if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.toLocationCode}銆戠粦瀹氭枡绠卞彿銆恵stationInfo.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+ dt_Task = new Dt_Task()
+ {
+ TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ WMSTaskNum = taskDTO.taskCode,
+ //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ Grade = taskDTO.taskPriority,
+ PalletCode = taskDTO.containerCode,
+ Roadway = hKLocationInfo.RoadwayNo,
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = taskType,
+ SourceAddress = taskDTO.fromLocationCode,
+ CurrentAddress = taskDTO.fromLocationCode,
+ NextAddress = taskDTO.toLocationCode,
+ TargetAddress = taskDTO.toLocationCode,
+ Creater = "WMS",
+ };
+ }
+ try
+ {
+ Db.Ado.BeginTran();
+ BaseDal.AddData(dt_Task);
+ _hKLocationInfoService.Repository.UpdateData(hKLocationInfo);
+ _stationInfo.Repository.UpdateData(stationInfo);
+ Db.Ado.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ return content.OK(data: new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = "鎴愬姛锛�"
+ });
}
catch (Exception ex)
{
- throw new Exception(ex.Message);
+ content.Error(ex.Message);
}
+ return content;
}
#endregion
@@ -216,15 +294,36 @@
#region 6 瑁佸壀閫佽揣
public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
-
- return WebResponseContent.Instance.OK();
+ Dt_Task dt_Task = new Dt_Task()
+ {
+ TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ WMSTaskNum = taskDTO.taskCode,
+ //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ Grade = taskDTO.taskPriority,
+ PalletCode = taskDTO.containerCode,
+ Roadway = "",
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = taskType,
+ SourceAddress = taskDTO.fromLocationCode,
+ CurrentAddress = taskDTO.fromLocationCode,
+ NextAddress = taskDTO.toLocationCode,
+ TargetAddress = taskDTO.toLocationCode,
+ Creater = "WMS",
+ };
+ content = SendHIKROBOTTask(dt_Task);
+ if (!content.Status) throw new Exception(content.Message);
+ dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
+ BaseDal.AddData(dt_Task);
}
catch (Exception ex)
{
- throw new Exception(ex.Message);
+ content.Error(ex.Message);
}
+ return content;
}
#endregion
}
--
Gitblit v1.9.3