yanjinhui
7 天以前 aeb971fe12b73d83d31a83b00f0a6e2876b24a00
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs
@@ -14,6 +14,7 @@
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_QuartzJob;
using System.Reflection.Metadata;
namespace WIDESEAWCS_TaskInfoService
{
@@ -208,28 +209,18 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_HKLocationInfo? hKLocationInfo = null;
                Dt_StationInfo? stationInfo = null;
                Dt_StationManger? 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,
                        Roadway = "1",
                        TaskState = (int)TaskStatusEnum.New,
                        TaskType = taskType,
                        SourceAddress = taskDTO.fromLocationCode,
@@ -238,22 +229,20 @@
                        TargetAddress = taskDTO.toLocationCode,
                        Creater = "WMS",
                    };
                }
                //出库
                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()
                    //stationInfo = _stationMangerService.Repository.QueryFirst(x => x.StationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                    //if (stationInfo.IsOccupied != (int)LocationStatusEnum.InStock) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                    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,
                        Roadway = "1",
                        TaskState = (int)TaskStatusEnum.New,
                        TaskType = taskType,
                        SourceAddress = taskDTO.fromLocationCode,
@@ -267,8 +256,6 @@
                {
                    Db.Ado.BeginTran();
                    BaseDal.AddData(dt_Task);
                    _hKLocationInfoService.Repository.UpdateData(hKLocationInfo);
                    _stationInfo.Repository.UpdateData(stationInfo);
                    Db.Ado.CommitTran();
                }
                catch (Exception ex)
@@ -295,8 +282,23 @@
        public WebResponseContent CJCarryTaske(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            Dt_StationInfo? stationInfo = null;
            try
            {
                //#region æ˜¯å¦éœ€è¦åˆ¤æ–­å¹³åº“库位状态
                //if (taskType!= (int)TaskTypeEnum.CK3F)
                //{
                //    stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                //    if (stationInfo.StationName != LocationStatusEnum.InStock.ToString()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                //    if (stationInfo.PalletCode != taskDTO.containerCode) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】绑定料箱号【{stationInfo.PalletCode}】与任务料箱号【{taskDTO.containerCode}】不匹配!");
                //}
                //else
                //{
                //    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}】当前库位状态不可出库!");
                //}
                //#endregion
                Dt_Task dt_Task = new Dt_Task()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
@@ -326,5 +328,43 @@
            return content;
        }
        #endregion
        #region 5空车转运
        public WebResponseContent HKF01Transport(TaskDTO taskDTO, int taskType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                var 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 = "1",
                    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.Dispatchertime = DateTime.Now;
                BaseDal.AddData(dt_Task);
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        #endregion
    }
}