dengjunjie
2026-03-03 2744064f23c2233fb700970801d2ddc802f38160
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs
@@ -15,8 +15,9 @@
{
    public partial class TaskService
    {
        #region å‡¯ä¹å£«ä»»åŠ¡åˆ›å»º
        /// <summary>
        /// åˆ›å»ºå…¥åº“任务
        /// åˆ›å»ºå‡¯ä¹å£«AGV入库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <returns></returns>
@@ -24,22 +25,24 @@
        {
            try
            {
                int containerType = taskDTO.containerCode.Contains("") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
                int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
                //获取货位信息
                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.LocationType == containerType);
                if (kLSLocationInfo == null) throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                Dt_Task dt_Task = new Dt_Task()
                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode, containerType) ?? throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    TaskState = TaskInStatusEnum.InNew.ObjToInt(),
                    Roadway = kLSLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = kLSLocationInfo.LocationCode,
                    TargetAddress = kLSLocationInfo.LocationCode,
                    Creater = "WMS",
                };
                kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
                Db.Ado.BeginTran();
@@ -51,29 +54,36 @@
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// åˆ›å»ºå‡¯ä¹å£«AGV出库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode);
                if (kLSLocationInfo == null) throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                if (kLSLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                Dt_Task dt_Task = new Dt_Task()
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    TaskState = TaskOutStatusEnum.OutNew.ObjToInt(),
                    Roadway = kLSLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = taskDTO.toLocationCode,
                    TargetAddress = taskDTO.toLocationCode,
                    Creater = "WMS",
                };
                kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
                Db.Ado.BeginTran();
@@ -85,8 +95,32 @@
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
                throw new Exception(ex.Message);
            }
        }
        #endregion
        #region 5 è·¨æ¥¼å±‚运输任务创建
        public WebResponseContent CarryTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        #endregion
        #region 6 è£å‰ªé€è´§
        public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
        {
            return WebResponseContent.Instance.OK();
        }
        #endregion
    }
}