dengjunjie
2026-03-10 a1795465c5b51eb53d83d9a874c7923c9f5bfa85
优化WMS任务下发接口
已修改4个文件
199 ■■■■ 文件已修改
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs
@@ -40,10 +40,19 @@
        /// </summary>
        /// <param name="AreaCode"></param>
        /// <returns></returns>
        public Dt_RGVLocationInfo GetInFreeLocationInfo(string AreaCode)
        public Dt_RGVLocationInfo? GetInFreeLocationInfo(string AreaCode)
        {
            Dt_RGVLocationInfo? rGVLocationInfo = BaseDal.QueryFirst(x => x.WarehouseId.ToString() == AreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy);
            Dt_RGVLocationInfo? rGVLocationInfo = null;
            List<Dt_RGVLocationInfo> rGVLocationInfos = BaseDal.QueryData(x => x.WarehouseId.ToString() == AreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy);
            if (rGVLocationInfos == null || rGVLocationInfos.Count < 1) return rGVLocationInfo;
            #region åˆ¤æ–­å··é“是否有货
            List<string> LocationCodes = new List<string>();
            foreach (var item in rGVLocationInfos)
            {
                Dt_RGVLocationInfo dt_RGVLocationInfo = BaseDal.QueryFirst(x => x.RoadwayNo == item.RoadwayNo && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt(), _emptyAssignOrderBy);
                if (dt_RGVLocationInfo == null) return dt_RGVLocationInfo;
                dt_RGVLocationInfo = BaseDal.QueryFirst(x => x.RoadwayNo == item.RoadwayNo && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.Depth > item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt(), _DepthAscOrderBy);
            }
            if (rGVLocationInfo != null)
            {
                List<string> NoRoadwayNos = new List<string>();
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs
@@ -23,6 +23,7 @@
        /// <returns></returns>
        public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
@@ -45,16 +46,33 @@
                    Creater = "WMS",
                };
                kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
                try
                {
                    Db.Ado.BeginTran();
                    BaseDal.AddData(dt_Task);
                    _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
                    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)
            {
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        /// <summary>
@@ -65,6 +83,7 @@
        /// <returns></returns>
        public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
@@ -86,16 +105,32 @@
                    Creater = "WMS",
                };
                kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
                try
                {
                    Db.Ado.BeginTran();
                    BaseDal.AddData(dt_Task);
                    _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
                    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)
            {
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        #endregion
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs
@@ -10,6 +10,10 @@
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Core.Helper;
using HslCommunication.Core.IMessage;
using WIDESEAWCS_DTO.RGV.FOURBOT;
using Newtonsoft.Json;
using System.Reflection.Metadata;
namespace WIDESEAWCS_TaskInfoService
{
@@ -24,19 +28,14 @@
        /// <returns></returns>
        public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //List<Dt_RGVLocationInfo>? rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt());
                //if (rGVLocationInfos.Count < 1) throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                //var rGVLocationInfo = rGVLocationInfos.OrderBy(x => x.Depth).First();
                //var rGVLocationInfo = _rGVLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                Dt_StationManger stationManger = _stationMangerService.GetInStationInfo(taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点位置【{taskDTO.fromLocationCode}】站台信息!");
                //if (stationManger.IsOccupied == 1) throw new Exception($"起点位置【{taskDTO.fromLocationCode}】站台被占用,请释放!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = taskDTO.toAreaCode,
@@ -44,22 +43,25 @@
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = stationManger.RGVStationCode,//找入库站台对应的外形检测编号
                    NextAddress = stationManger.RGVStationCode,
                    TargetAddress = "",
                    //Remark = taskDTO.toAreaCode,
                    Creater = "WMS",
                };
                //rGVLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
                //Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                //_rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
                //Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
                return content.OK(data: new
                {
                    taskCode = taskDTO.taskCode,
                    Message = "成功!"
                });
            }
            catch (Exception ex)
            {
                //Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        /// <summary>
@@ -70,17 +72,15 @@
        /// <returns></returns>
        public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode);
                //if (dt_Task != null) throw new Exception($"托盘号【{taskDTO.containerCode}】已存在任务");
                Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = rGVLocationInfo.RoadwayNo,
@@ -105,11 +105,20 @@
                    Db.Ado.RollbackTran();
                    throw new Exception(ex.Message);
                }
                return WebResponseContent.Instance.OK();
                return content.OK(data: new
                {
                    taskCode = taskDTO.taskCode,
                    Message = "成功!"
                });
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        #endregion
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -89,49 +89,99 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<object> objects = new List<object>();
                foreach (var item in taskDTOs)
                {
                    foreach (var task in item.tasks)
                    {
                        #region åˆ¤æ–­
                        content = TaskHelpMethods.isOkTaskInfo(task, true, true);
                        if (!content.Status) throw new Exception(content.Message);
                        if (!content.Status)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"任务号【{task.taskCode}】{content.Message}"
                            });
                            continue;
                            //throw new Exception(content.Message);
                        }
                        if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode) != null)
                            throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"任务号【{task.taskCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode) != null)
                            throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"托盘号【{task.containerCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode) != null)
                            throw new Exception($"起点位置【{task.containerCode}】已存在任务");
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"起点位置【{task.containerCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"起点位置【{task.containerCode}】已存在任务");
                        }
                        #endregion
                        switch (item.taskType)
                        {
                            case (int)TaskTypeEnum.MLInbound:
                                CreateKLSNewInTask(task, item.taskType);
                                content = CreateKLSNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.MLOutbound:
                                CreateKLSNewOutTask(task, item.taskType);
                                content = CreateKLSNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CPInbound:
                                CreateRGVNewInTask(task, item.taskType);
                                content= CreateRGVNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CPOutbound:
                                CreateRGVNewOutTask(task, item.taskType);
                                content= CreateRGVNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJInbound:
                                CreateHKNewInTask(task, item.taskType);
                                content = CreateHKNewInTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJOutbound:
                                CreateHKNewOutTask(task, item.taskType);
                                content = CreateHKNewOutTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.Carry:
                                CarryTask(task, item.taskType);
                                content = CarryTask(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            case (int)TaskTypeEnum.CJCarry:
                                CJCarryTaske(task, item.taskType);
                                content = CJCarryTaske(task, item.taskType);
                                objects.Add(content.Data);
                                break;
                            default:
                                objects.Add(new
                                {
                                    taskCode = task.taskCode,
                                    Message = $"未定义的任务类型"
                                });
                                break;
                        }
                    }
                }
                content.Data = objects;
            }
            catch (Exception ex)
            {