Admin
2026-03-23 f679f58dba34055bd579a603762c13fbe1650c9b
ÏîÄ¿´úÂë/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,28 @@
            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;
                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;
                    //是否可进出
                    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},对应的协议");
                    /*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;*/
                    int statusValue = 0;
                    int portStatus = conveyorLine.Communicator.Read<int>(deviceProDTO.DeviceProAddress);
                    int StationStatus = conveyorLine.Communicator.Read<int>(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 +240,71 @@
            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;
                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)
                {
                    //是否可进出
                    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<int>(deviceProDTO.DeviceProAddress);
                    int StationStatus = conveyorLine.Communicator.Read<int>(StationNumProDTO.DeviceProAddress);
                    //有货,可进信号
                    statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0;
                    if (statusValue == 1)
                    {//写入输送线信号
                        bool HandShakebool = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1);
                        if (HandShakebool)
                        {
                            return apiResponse.SuccessResponse();
                        }
                        else
                        {
                            return apiResponse.ErrorResponse("agv写入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 +325,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 +364,7 @@
                        }
                    },
                    dealType = dealType,
                    psd = psd
                    psd = "akjfapjfpadaoif",
                };
               
                commandResult = HttpHelper.Post<CommandResult>(urlWMSdeverror, deviceErrorRequest, "设备故障回调");