1
HuBingJie
2025-12-05 28110912ca4803e5793f181517d7bf2d7a5ea2ad
´úÂë¹ÜÀí/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvOperationService.cs
@@ -49,15 +49,19 @@
using System.Net;
using WIDESEAWCS_ISystemServices;
using System.Security.Claims;
using WIDESEAWCS_Common.TaskEnum;
using SqlSugar.Extensions;
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 +168,7 @@
        }
        /// <summary>
        /// å†™å…¥å¤ä½ï¼ˆå…¥åº“端)
        /// ä¸€é”®å¯åŠ¨å…¥åº“å­æ¯è½¦
        /// </summary>
        public WebResponseContent WriteInReset(SaveModel saveModel)
        {
@@ -173,7 +177,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 +205,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 +227,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 +268,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();
@@ -287,6 +309,123 @@
            return Commonstacker.Communicator.Write<short>(DeviceProDataBlock, rgvvalues);
        }
        /// <summary>
        /// æ­£å¸¸å…¥åº“
        /// </summary>
        public WebResponseContent WriteInNormal(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                int taskNum = saveModel.MainData.FirstOrDefault(x => x.Key == "taskNum").Value.ObjToInt();
                Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.InAbnormalFinish && x.TaskNum == taskNum);
                if (dt_Task == null)
                {
                    return content.Error("没有异常入库任务");
                }
                dt_Task.TaskState = (int)TaskInStatusEnum.RGV_InPickupFinish;
                dt_Task.RGVTaskType = (int)RGVTaskTypeEnum.Placing;
                dt_Task.NextAddress = "1021";
                _taskRepository.UpdateData(dt_Task);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error("正常入库调取异常,原因:" + ex.Message);
                throw;
            }
        }
        /// <summary>
        /// å…¥åº“异常排出
        /// </summary>
        public WebResponseContent WriteInAbnormal(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                int taskNum = saveModel.MainData.FirstOrDefault(x => x.Key == "taskNum").Value.ObjToInt();
                Dt_Task dt_Task = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskInStatusEnum.InAbnormalFinish && x.TaskNum == taskNum);
                if (dt_Task == null)
                {
                    return WebResponseContent.Instance.Error("没有异常入库任务");
                }
                dt_Task.TaskState = (int)TaskInStatusEnum.InexceptionalSelection;
                dt_Task.RGVTaskType = (int)RGVTaskTypeEnum.Placing;
                _taskRepository.UpdateData(dt_Task);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error("异常排除调取异常,原因:" + ex.Message);
                throw;
            }
        }
        public static List<string> OutStationareaList = new List<string>() { "RGV111", "RGV116", "RGV110", "RGV112", "RGV114", "RGV115", "RGV118" };
        public static List<string> InStationareaList = new List<string>() { "RGV101", "RGV103", "RGV105", "RGV108", "RGV109", "RGV104", "RGV107" };
        /// <summary>
        /// æŸ¥çœ‹æŠ¥è­¦
        /// </summary>
        public static string AQMReadAlarminform()
        {
            string deviceName = "RGV101";
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceName);
                if (device == null) return null;
                SpeStackerCrane stacker = (SpeStackerCrane)device;
                DeviceProDTO? faultInfo = GetRGVDeviceProDTO(stacker, deviceName, "RGV_Faultcode", "ReadDeviceCommand");
                int alarmCode = GetLine(stacker, faultInfo.DeviceProAddress);
            var alarmMessages = new Dictionary<int, string>
{
    {0, "无报警"},
    {1, "RGV小车急停被按下"},
    {2, "正转雷达报警"},
    {3, "反转雷达报警"},
    {4, "前进限位报警"},
    {5, "后退限位报警"},
    {6, ""},
    {7, "PLC模块故障"},  // ä¿®æ­£ï¼šæ‘¸å— â†’ æ¨¡å—
    {8, "PLC扩展模块故障"},
    {9, "称重模块故障"},
    {10, "扫码定位故障"},
    {11, "RGV长时间空转故障"},
    {12, "目的地不等于实际位置故障"},
    {13, "与总控通讯故障"},
    {14, "前雷达屏蔽警告"},
    {15, "后雷达屏蔽警告"},
    {16, "行走变频器故障"},
    {17, "伸缩叉变频器故障"},
    {18, "液压单元过载保护故障"},
    {19, "液压上升超时报警"},
    {20, "液压下降超时报警"},
    {21, "伸缩叉伸出超时报警"},
    {22, "伸缩叉缩回超时报警"},
    {23, "外形检测报警"},
    {24, "称重超重报警"},
    {25, "货叉伸出极限限位报警"},
    {26, "货叉缩回极限限位报警"},
    {27, "取货时自身有货物报警"},
    {28, "放货时自身无货物报警"},
    {29, "货叉未回到初始位报警"},
    {30, "触发仅移动命令时货叉不在初始位报警"},
    {31, "货叉到达初始位但中位传感器未检测到报警"},
    {32, "行走轴没到位禁止货叉伸出"},
    {33, "取货异常报警"},
    {34, "放货异常报警"},
    {35, "外型检测-前超出报警"},
    {36, "外型检测-后超出报警"},
    {37, "外型检测-左超出报警"},
    {38, "外型检测-右超出报警"},
    {39, "外型检测-上超出报警"}
};
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";
        }
        /// <summary>
        /// æŸ¥çœ‹æŠ¥è­¦
@@ -301,7 +440,7 @@
            DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Faultcode", "ReadDeviceCommand");
            int baoj = GetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress);
            string alarmMessage = "";
            if (DeviceName == "RGV118")
            if (DeviceName == "RGV118" || DeviceName == "RGV101")
            {
                 alarmMessage = GetAlarmMessage(baoj);
            }
@@ -354,7 +493,7 @@
        {28, "放货时自身无货物报警"},
        {29, "货叉未回到初始位报警"},
        {30, "触发仅移动命令时货叉不在初始位报警"},
        {31, "货叉到达初始位但中位传感器未检测到报警"}
                {31, "货叉到达初始位但中位传感器未检测到报警"}
            };
            return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "未知报警代码";