yanjinhui
2026-03-14 50adfb5ea02f1741a31478868af4362de065d969
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -18,7 +18,9 @@
using AutoMapper;
using SixLabors.ImageSharp.ColorSpaces;
using SqlSugar;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.LocationEnum;
@@ -36,6 +38,7 @@
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
@@ -89,53 +92,107 @@
            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 (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode) != null)
                            throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode) != null)
                            throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode) != null)
                            throw new Exception($"起点位置【{task.containerCode}】已存在任务");
                        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 && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"任务号【{task.taskCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"托盘号【{task.containerCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"起点位置【{task.fromLocationCode}】已存在任务"
                            });
                            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)
            {
                content.Error(ex.Message);
            }
            finally
            {
                _trackloginfoService.AddTrackLog(taskDTOs, content, $"WMS下发任务,", "", "");
            }
            return content;
        }
@@ -178,6 +235,7 @@
                    if (apiInfo == null) throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, KLS.Serialize());
                    GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
                    content.OK(data: agvContent);
                    if (agvContent.success == true && agvContent.code == 0)
                    {
                        //直接移入历史
@@ -204,6 +262,7 @@
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, cancelSXCTake.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    content.OK(data: fOURBOTReturn);
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn.returnUserMsg == "成功")
                    {
                        //直接移入历史
@@ -216,6 +275,7 @@
                    }
                }
                #endregion
                #region æµ·åº·
                if (isHK)
                {
@@ -228,6 +288,7 @@
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, cancelHIKROBOTTask.Serialize());
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    content.OK(data: hIKROBOTReturn);
                    if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "成功")
                    {
                        //直接移入历史
@@ -318,6 +379,7 @@
                    if (apiInfo == null) throw new Exception("未找到凯乐士AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, updateGALAXISTaskGrade.Serialize());
                    GALAXISReturn agvContent = response.DeserializeObject<GALAXISReturn>();
                    content.OK(data: agvContent);
                    if (agvContent.success == true && agvContent.code == 0)
                    {
@@ -343,6 +405,7 @@
                    if (apiInfo == null) throw new Exception("未找到更新四向车任务优先级接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
                    FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                    content.OK(data: fOURBOTReturn);
                    if (fOURBOTReturn.returnCode == 0 && fOURBOTReturn.returnUserMsg == "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
@@ -367,6 +430,7 @@
                    if (apiInfo == null) throw new Exception("未找到四向车AGV任务下发接口配置信息!请检查接口配置");
                    string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize());
                    HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
                    content.OK(data: hIKROBOTReturn);
                    if (hIKROBOTReturn.code == "SUCCESS0" && hIKROBOTReturn.message == "成功")
                    {
                        BaseDal.UpdateData(dt_Task);
@@ -1017,14 +1081,84 @@
        /// <param name="AreaCode"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException">区域号</exception>
        public WebResponseContent LocationInquiry(string AreaCode)
        public WebResponseContent LocationInquiry(WMSGetLocationInfo getLocationInfo)
        {
            if (AreaCode == null)
            WebResponseContent content = new WebResponseContent();
            List<object> list = new List<object>();
            try
            {
                //查询输送线空托缓存信息时返回空位数量
            }
            return WebResponseContent.Instance.OK();
                if (getLocationInfo == null) throw new Exception("请求参数不能为空!");
                //if (getLocationInfo.AreaCode == null) throw new Exception("库区编号不能为空!");
                if (getLocationInfo.WarehouseId == 0) throw new Exception("仓库ID不能为空!");
                if (getLocationInfo.WarehouseId == 1)
                {
                    List<Dt_RGVLocationInfo> rGVLocationInfos = new List<Dt_RGVLocationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    else
                        rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData();
                    foreach (var item in rGVLocationInfos)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 2)
                {
                    List<Dt_KLSLocationInfo> rGVLocationInfos = new List<Dt_KLSLocationInfo>();
                    if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
                        rGVLocationInfos = _kLSLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    else
                        rGVLocationInfos = _kLSLocationInfoService.Repository.QueryData();
                    foreach (var item in rGVLocationInfos)
                    {
                        list.Add(new
                        {
                            LoctionCode = item.LocationCode,
                            LocationStatus = item.LocationStatus,
                            EnableStatus = item.EnableStatus
                        });
                    }
                    content.OK(data: list);
                }
                else if (getLocationInfo.WarehouseId == 3)
                {
                }
                else if (getLocationInfo.WarehouseId == 4)
                {
                }
                else if (getLocationInfo.WarehouseId == 5)
                {
                    //读取光电信号
                    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楼质检门设备连接失败");
                    var sta = _stationMangerService.Repository.QueryData(x => x.Remark == "成品库");
                    foreach (var item in sta)
                    {
                        bool value = device.GetValue<QualityInspectionCommandEnum,bool>(QualityInspectionCommandEnum.R_StockAvailableSymbol, item.StationCode);
                             list.Add(new
                             {
                                 LoctionCode = item.StationCode,
                                 LocationStatus = value?100:0,
                                 EnableStatus = 0,
                             });
                    }
                    content.OK(data: list);
                }
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
@@ -1120,6 +1254,7 @@
                };
                string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize());
                FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
                content.OK(data: fOURBOTReturn);
                if (fOURBOTReturn.returnCode != 0 /*&& fOURBOTReturn.returnUserMsg != $"站点已被占用,(podID={iQC.ContainerCode})"*/)
                    throw new Exception(fOURBOTReturn.returnUserMsg);
                #endregion