Admin
2026-03-26 dea22f4759b5c8a4f79a3e93e5af1741f5e00ae4
ÏîÄ¿´úÂë/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/WMSTaskService.cs
@@ -110,6 +110,7 @@
                task.Grade = 1;
                task.Creater = "WMS";
                task.CreateDate = DateTime.Now;
                task.WMStaskid = transfer.barCode;
                task.deviceuuid = transfer.device.uuid;
                _unitOfWorkManage.BeginTran();
@@ -157,23 +158,37 @@
            ApiResponse apiResponse = new ApiResponse();
            try
            {
                //IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1002");
                //if (device == null) return apiResponse.ErrorResponse("WCS未能获取到库口实例");
                //CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                Dictionary<string, int> portStatusDict = new Dictionary<string, int>();
                foreach (string DeStateName in datas)
                {
                    //暂时数据
                    portStatusDict[DeStateName] = 1;
                    string DeciceCodes = "1003";
                    if (DeStateName.StartsWith("C")) DeciceCodes = "1004";
                    /*DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "StationFree");
                    if (deviceProDTO == null) return apiResponse.ErrorResponse($"WCS未找到库口:{DeStateName},对应的协议");
                    conveyorLine.Communicator.Read<bool>(deviceProDTO.DeviceProAddress);
                    bool portStatus = conveyorLine.Communicator.Read<bool>(deviceProDTO.DeviceProAddress);
                    int statusValue = portStatus ? 1 : 0;
                    portStatusDict[DeStateName] = statusValue;*/
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeciceCodes);
                    if (device == null) return apiResponse.ErrorResponse("WCS未能获取到库口实例");
                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                    //是否可进出
                    DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "PermitHandShake");
                    //是否有货
                    DeviceProDTO? StationNumProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "StationNum");
                    if (deviceProDTO == null || StationNumProDTO ==null) return apiResponse.ErrorResponse($"WCS未找到库口:{DeStateName},对应的协议");
                    int statusValue = 0;
                    //1允许取  2允许放
                    int portStatus = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
                    //是否有货
                    int StationStatus = conveyorLine.Communicator.Read<ushort>(StationNumProDTO.DeviceProAddress);
                    //有货,可进信号
                    statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
                    portStatusDict[DeStateName] = statusValue;
                }
                return apiResponse.SuccessResponse(portStatusDict);
@@ -234,9 +249,64 @@
            ApiResponse apiResponse = new ApiResponse();
            try
            {
                string DeciceCodes = "1003";
                if (agvUpdateRequest.warehousenumber.StartsWith("C")) DeciceCodes = "1004";
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeciceCodes);
                if (device == null) return apiResponse.ErrorResponse("WCS未能获取到库口实例");
                CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                return apiResponse.SuccessResponse();
                //是否可进出
                DeviceProDTO? HandShake = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "HandShake");
                if (HandShake == null) return apiResponse.ErrorResponse($"WCS未找到库口:{agvUpdateRequest.warehousenumber},对应的协议");
                if (agvUpdateRequest.agvstatus == 1)
                {
                    //写入plc,agv进入信号
                    bool HandShakebool = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1);
                    if (HandShakebool)
                    {
                        //是否可进出    1允许取  2允许放
                        DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "PermitHandShake");
                        //是否有货
                        DeviceProDTO? StationNumProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "StationNum");
                        if (deviceProDTO == null || StationNumProDTO == null) return apiResponse.ErrorResponse($"WCS未找到库口:{agvUpdateRequest.warehousenumber},对应的协议");
                        int statusValue = 0;
                        int portStatus = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
                        int StationStatus = conveyorLine.Communicator.Read<ushort>(StationNumProDTO.DeviceProAddress);
                        //有货,可进信号
                        statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
                        if (statusValue == 1)
                        {
                            return apiResponse.SuccessResponse();
                        }
                        else
                        {
                            return apiResponse.ErrorResponse("读取plc不可进入信息");
                        }
                    }
                    else
                    {
                        return apiResponse.ErrorResponse("写入plc进入信号失败");
                    }
                }
                else if(agvUpdateRequest.agvstatus == 2)
                {
                    //写入输送线信号
                    bool portStatus = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 0);
                    if (portStatus)
                    {
                        return apiResponse.SuccessResponse();
                    }
                    else
                    {
                        return apiResponse.ErrorResponse("写入plc清除信号失败");
                    }
                }
                else
                {
                    return apiResponse.ErrorResponse($"agv对应的申请错误,字段:agvstatus,申请的值:{agvUpdateRequest.agvstatus}");
                }
            }
            catch (Exception ex)
            {
@@ -257,7 +327,7 @@
                taskInfo1.taskId = taskId;
                taskInfo1.taskType = taskType;
                taskInfo1.invType = invType;
                taskInfo1.psd = psd;
                taskInfo1.psd = "akjfapjfpadaoif";
                commandResult = HttpHelper.Post<CommandResult>(urlWMStaskreturn, taskInfo1, "任务状态回调");
                WriteLog.Write_Log("同步给上游反馈任务完成", "任务信息", $"任务号:{taskId}", $"调取参数:{taskInfo1.ToJson()},返回参数:{commandResult.ToJson()}");
@@ -296,7 +366,7 @@
                        }
                    },
                    dealType = dealType,
                    psd = psd
                    psd = "akjfapjfpadaoif",
                };
               
                commandResult = HttpHelper.Post<CommandResult>(urlWMSdeverror, deviceErrorRequest, "设备故障回调");