1
huanghongfeng
10 天以前 eaa07b80e3400da9be84e9a7a834e56d829a625b
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvOperationService.cs
@@ -49,15 +49,18 @@
using System.Net;
using WIDESEAWCS_ISystemServices;
using System.Security.Claims;
using WIDESEAWCS_Common.TaskEnum;
namespace WIDESEAWCS_TaskInfoService
{
    public class RgvOperationService : ServiceBase<Dt_Task_hty, ITask_HtyRepository>, IRgvOperationService
    {
        private readonly IAgvStationService _gvStationService;
        public RgvOperationService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService) : base(BaseDal)
        private readonly ITaskRepository _taskRepository;
        public RgvOperationService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, ITaskRepository taskRepository) : base(BaseDal)
        {
            _gvStationService = agvStationService;
            _taskRepository = taskRepository;
        }
@@ -164,7 +167,7 @@
        }
        /// <summary>
        /// å†™å…¥å¤ä½ï¼ˆå…¥åº“端)
        /// ä¸€é”®å¯åŠ¨å…¥åº“å­æ¯è½¦
        /// </summary>
        public WebResponseContent WriteInReset(SaveModel saveModel)
        {
@@ -173,7 +176,7 @@
            List<AGVStation> rgvdata = _gvStationService.GetInStroller();
            foreach (AGVStation rgvstation in rgvdata)
            {
                string DeviceName = saveModel.DelKeys[0].ToString();    //设备名称
                string DeviceName = rgvstation.ChildPosiDeviceCode;    //设备名称
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
                if (device == null) continue;
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
@@ -201,7 +204,7 @@
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand");        //复位报警信息
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)0);
            }
            return webResponse.OK();
        }
@@ -223,7 +226,25 @@
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");        //复位报警信息
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)0);
            }
            return webResponse.OK();
        }
        public WebResponseContent InWriteOutbuttonpause(SaveModel saveModel)
        {
            WebResponseContent webResponse = new WebResponseContent();
            List<AGVStation> rgvdata = _gvStationService.InGetOutStroller();
            foreach (AGVStation rgvstation in rgvdata)
            {
                string DeviceName = rgvstation.ChildPosiDeviceCode;    //设备名称
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
                if (device == null) continue;
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)0);
            }
            return webResponse.OK();
@@ -246,7 +267,7 @@
                SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
                //获取需要复位的设备
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");        //复位报警信息
                DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand");
                RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
            }
            return webResponse.OK();
@@ -285,6 +306,61 @@
        public static bool RgvSetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock, short rgvvalues)
        {
            return Commonstacker.Communicator.Write<short>(DeviceProDataBlock, rgvvalues);
        }
        /// <summary>
        /// æ­£å¸¸å…¥åº“
        /// </summary>
        public WebResponseContent WriteInNormal(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.InAbnormalFinish);
            dt_Task.TaskState = (int)TaskInStatusEnum.RGV_InPickupFinish;
            dt_Task.RGVTaskType = (int)RGVTaskTypeEnum.Placing;
            dt_Task.NextAddress = "1021";
            _taskRepository.UpdateData(dt_Task);
            return content;
        }
        /// <summary>
        /// å…¥åº“异常排出
        /// </summary>
        public WebResponseContent WriteInAbnormal(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.InAbnormalFinish);
            dt_Task.TaskState = (int)TaskInStatusEnum.InexceptionalSelection;
            dt_Task.RGVTaskType = (int)RGVTaskTypeEnum.Placing;
            _taskRepository.UpdateData(dt_Task);
            return content;
        }
        public static List<string> OutStationareaList = new List<string>() { "RGV111", "RGV116", "RGV110", "RGV112", "RGV114", "RGV115", "RGV118" };
        public static List<string> InStationareaList = new List<string>() { "RGV111", "RGV116", "RGV110", "RGV112", "RGV114", "RGV115", "RGV118" };
        /// <summary>
        /// æŸ¥çœ‹æŠ¥è­¦
        /// </summary>
        public bool AQMReadAlarminform(int tasktype)
        {
            var deviceList = tasktype == 1 ? InStationareaList : OutStationareaList;
            foreach (string deviceName in deviceList)
            {
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceName);
                if (device == null) return false;
                SpeStackerCrane stacker = (SpeStackerCrane)device;
                DeviceProDTO? faultInfo = GetRGVDeviceProDTO(stacker, deviceName, "RGV_Faultcode", "ReadDeviceCommand");
                int alarmCode = GetLine(stacker, faultInfo.DeviceProAddress);
                if (alarmCode != 0)
                {
                    return true;
                }
            }
            return true;
        }
@@ -354,7 +430,7 @@
        {28, "放货时自身无货物报警"},
        {29, "货叉未回到初始位报警"},
        {30, "触发仅移动命令时货叉不在初始位报警"},
        {31, "货叉到达初始位但中位传感器未检测到报警"}
                {31, "货叉到达初始位但中位传感器未检测到报警"}
            };
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";