dengjunjie
2026-03-17 644819a289399eff1d5972c3df41ec55cb9d8c95
´úÂë¹ÜÀí/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,21 @@
        /// <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}】可用空货位!");
                #region ç‚¹åˆ°ç‚¹
                //if (!string.IsNullOrEmpty(taskDTO.toLocationCode))
                //{
                //    var LocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.toLocationCode) ?? throw new Exception($"未找到终点货位【{taskDTO.toLocationCode}】");
                //    if (LocationInfo.LocationStatus != LocationStatusEnum.Free.ObjToInt()) throw new Exception($"终点货位【{taskDTO.toLocationCode}】货位状态不为空货位");
                //}
                #endregion
                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 +50,25 @@
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = stationManger.Remark,//找入库站台对应的外形检测编号
                    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();
                return WebResponseContent.Instance.Error(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        /// <summary>
@@ -70,17 +79,59 @@
        /// <returns></returns>
        public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Db.Ado.BeginTran();
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
                var stationManger = _stationMangerService.GetOutStationInfo(taskDTO.toLocationCode);
                if (stationManger==null)
                {
                    return content.Error($"{taskDTO.toLocationCode}不是出库站台");
                }
                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}】当前库位状态不可出库!");
                if (rGVLocationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】绑定料箱号【{rGVLocationInfo.PalletCode}】与任务料箱号【{taskDTO.containerCode}】不匹配!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = rGVLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = taskDTO.toLocationCode,
                    TargetAddress = taskDTO.toLocationCode,
                    Creater = "WMS",
                };
                rGVLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
                try
                {
                    Db.Ado.BeginTran();
                    BaseDal.AddData(dt_Task);
                    _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
                    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();
                return WebResponseContent.Instance.Error(ex.Message);
                content.Data = new
                {
                    taskCode = taskDTO.taskCode,
                    Message = $"失败!{ex.Message}"
                };
                return content.Error(ex.Message);
            }
        }
        #endregion