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;
@@ -91,7 +94,7 @@
            {
                List<object> objects = new List<object>();
                foreach (var item in taskDTOs)
                {
                {
                    foreach (var task in item.tasks)
                    {
                        #region åˆ¤æ–­
@@ -106,7 +109,7 @@
                            continue;
                            //throw new Exception(content.Message);
                        }
                        if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode) != null)
                        if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
@@ -116,7 +119,7 @@
                            continue;
                            //throw new Exception($"任务号【{task.taskCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode) != null)
                        if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
@@ -126,12 +129,12 @@
                            continue;
                            //throw new Exception($"托盘号【{task.containerCode}】已存在任务");
                        }
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode) != null)
                        if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode && x.TaskType == item.taskType) != null)
                        {
                            objects.Add(new
                            {
                                taskCode = task.taskCode,
                                Message = $"起点位置【{task.containerCode}】已存在任务"
                                Message = $"起点位置【{task.fromLocationCode}】已存在任务"
                            });
                            continue;
                            //throw new Exception($"起点位置【{task.containerCode}】已存在任务");
@@ -232,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)
                    {
                        //直接移入历史
@@ -258,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 == "成功")
                    {
                        //直接移入历史
@@ -283,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 == "成功")
                    {
                        //直接移入历史
@@ -373,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)
                    {
@@ -398,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);
@@ -422,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);
@@ -1079,11 +1088,15 @@
            try
            {
                if (getLocationInfo == null) throw new Exception("请求参数不能为空!");
                if (getLocationInfo.AreaCode == 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 = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    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
@@ -1097,7 +1110,11 @@
                }
                else if (getLocationInfo.WarehouseId == 2)
                {
                    List<Dt_KLSLocationInfo> rGVLocationInfos = _kLSLocationInfoService.Repository.QueryData(x => x.WarehouseId == getLocationInfo.AreaCode.ObjToInt());
                    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
@@ -1119,7 +1136,22 @@
                }
                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)
@@ -1222,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