| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using AutoMapper.Internal; |
| | | using Castle.Components.DictionaryAdapter.Xml; |
| | | using HslCommunication; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using Microsoft.OpenApi.Any; |
| | |
| | | if (transfer.to == null || string.IsNullOrEmpty(transfer.to.code)) return apiResponse.ErrorResponse("ç®æ ä½ç½®ä¸è½ä¸ºç©º"); |
| | | if (transfer.device == null || string.IsNullOrEmpty(transfer.device.uuid)) return apiResponse.ErrorResponse("è®¾å¤æ è¯ä¸è½ä¸ºç©º"); |
| | | |
| | | Dt_Task setask = BaseDal.QueryData(x => x.WMStaskid == transfer.barCode).FirstOrDefault(); |
| | | Dt_Task? setask = BaseDal.QueryData(x => x.WMStaskid == transfer.barCode).FirstOrDefault(); |
| | | if (setask != null) return apiResponse.ErrorResponse($"WCSå·²æå½åä»»å¡ï¼ä¸å¯éå¤ä¸åï¼æçç¼å·ï¼{transfer.barCode}"); |
| | | |
| | | |
| | |
| | | //æ¯å¦æè´§ |
| | | int StationStatus = conveyorLine.Communicator.Read<ushort>(StationNumProDTO.DeviceProAddress); |
| | | |
| | | //æè´§ï¼å¯è¿ä¿¡å· |
| | | statusValue = ((portStatus == 1 && StationStatus == 1) || (portStatus == 2 && StationStatus == 0)) ? 1 : (portStatus == 0) ? 0 : 0; |
| | | |
| | | if(DeStateName== "G01" || DeStateName == "G06" || DeStateName == "G07") |
| | | { |
| | | //æè´§ï¼å¯è¿ä¿¡å· |
| | | statusValue = (portStatus == 1 && StationStatus == 1) ? 1 : (portStatus == 2 && StationStatus == 0) ?0: (portStatus == 0) ? 0 : 0; |
| | | } |
| | | else |
| | | { |
| | | statusValue = StationStatus == 1 ? 0 : 1; |
| | | } |
| | | portStatusDict[DeStateName] = statusValue; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | //è·åå
å¹ç¶æ |
| | | public ApiResponse getSafeStatus(string[] datas) |
| | | public ApiResponse getSafeStatus(string[] datas) |
| | | { |
| | | WriteLog.Write_Log("è·åå
å¹ç¶ææ¥å£", "è·åå
å¹ç¶æä¿¡æ¯", "è°ååæ°", setCurtain); |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | |
| | | //设置å
å¹ |
| | | public ApiResponse setCurtain(SetCurtainRequest setCurtain) |
| | | { |
| | | //è·åWMSè°åçåæ° |
| | | WriteLog.Write_Log("设置å
广¥å£", "设置å
å¹ä¿¡æ¯", "è°ååæ°", setCurtain); |
| | | |
| | | ApiResponse apiResponse = new ApiResponse(); |
| | | bool HandShakeboolOPEN = false; |
| | | bool HandShakeboolCLOSE = false; |
| | | try |
| | | { |
| | | return apiResponse.SuccessResponse(); |
| | | } |
| | | Dictionary<string, int> portStatusDict = new Dictionary<string, int>(); |
| | | foreach (string DeStateName in setCurtain.Datas) |
| | | { |
| | | string DeciceCodes = "1003"; |
| | | if (DeStateName.StartsWith("C")) DeciceCodes = "1004"; |
| | | |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeciceCodes); |
| | | if (device == null) return apiResponse.ErrorResponse("WCSæªè½è·åå°åºå£å®ä¾"); |
| | | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | |
| | | DeviceProDTO? HandShake = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "HandShake"); |
| | | if (HandShake == null) return apiResponse.ErrorResponse($"WCSæªæ¾å°åºå£ï¼{setCurtain.Datas},对åºçåè®®"); |
| | | DeviceProDTO? Request = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeStateName && x.DeviceProParamName == "Request"); |
| | | if (HandShake == null) return apiResponse.ErrorResponse($"WCSæªæ¾å°åºå£ï¼{setCurtain.Datas},对åºçåè®®"); |
| | | |
| | | if (setCurtain.Operate.Equals("OPEN")) |
| | | { |
| | | //åå
¥plcï¼agvéåºä¸æå¼ä¿¡å· |
| | | HandShakeboolOPEN = conveyorLine.Communicator.Write<short>(Request.DeviceProAddress, 0); |
| | | |
| | | WriteLog.Write_Log("设置æå¼å
广¥å£", "设置æå¼å
å¹ä¿¡æ¯", $"åºå£åç§°ï¼ã{DeStateName}ãï¼æå¼å
å¹ä¿¡å·å°åï¼ã{Request.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(Request.DeviceProAddress)}ã\n" + |
| | | $"åå
¥æå¼å
å¹ä¿¡å·æ¯å¦æåè¿åå¼ï¼ã{HandShakeboolOPEN}ã"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | //åå
¥plcï¼agvè¿å
¥å
³éå
æ
ä¿¡å· |
| | | HandShakeboolCLOSE = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1)&& conveyorLine.Communicator.Write<short>(Request.DeviceProAddress, 1); |
| | | |
| | | WriteLog.Write_Log("设置å
³éå
广¥å£", "设置å
³éå
广¥å£ä¿¡æ¯", $"åºå£åç§°ï¼ã{DeStateName}ãï¼å
³éå
å¹ä¿¡å·å°åï¼ã{HandShake.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(HandShake.DeviceProAddress)}ã" + |
| | | $"å
³éå
å¹ä¿¡å·å¤ç¨å°åï¼ã{Request.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(Request.DeviceProAddress)}ã\n" + |
| | | $"åå
¥å
³éå
å¹ä¿¡å·æ¯å¦æåè¿åå¼ï¼ã{HandShakeboolCLOSE}ã"); |
| | | } |
| | | } |
| | | if ((HandShakeboolOPEN && setCurtain.Operate.Equals("OPEN") )|| (HandShakeboolCLOSE && setCurtain.Operate.Equals("CLOSE"))) |
| | | { |
| | | return apiResponse.SuccessResponse(); |
| | | } |
| | | else |
| | | { |
| | | return apiResponse.ErrorResponse("åå
¥plcè¿å
¥ä¿¡å·å¤±è´¥"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return apiResponse.ErrorResponse($"WCS任塿·»å é误ï¼åå ï¼{ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //agvè¿åºç¶æåé¦ |
| | |
| | | //æ¯å¦å¯è¿åº |
| | | 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) |
| | | DeviceProDTO? Request = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == agvUpdateRequest.warehousenumber && x.DeviceProParamName == "Request"); |
| | | |
| | | if (agvUpdateRequest.agvstatus == 1) |
| | | { |
| | | //æ¯å¦å¯è¿åº 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) |
| | | bool HandShakebool = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 1); |
| | | if (HandShakebool) |
| | | { |
| | | if (Request != null) |
| | | { |
| | | conveyorLine.Communicator.Write<short>(Request.DeviceProAddress, 1); |
| | | } |
| | | //æ¯å¦å¯è¿åº 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; |
| | | WriteLog.Write_Log("ç³è¯·è¿å
¥AGVåé¦ä¿¡å·ä¿¡æ¯", "ç³è¯·è¿å
¥AGVåé¦ä¿¡å·ä¿¡æ¯", $"åºå£ç¼å·ï¼ã{agvUpdateRequest.warehousenumber}ãï¼æ¯å¦å
许è¿å
¥å°åï¼ã{deviceProDTO.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{portStatus}ã\n" + |
| | | $"æ¯å¦æè´§å°åï¼ã{StationNumProDTO.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{StationStatus}ã\n" + |
| | | $"æ¯å¦å¯è¿å
¥ä¿¡å·ï¼ã{statusValue}ã"); |
| | | if (agvUpdateRequest.warehousenumber == "G01" || agvUpdateRequest.warehousenumber == "G06" || agvUpdateRequest.warehousenumber == "G07") |
| | | { |
| | | if (statusValue == 1) |
| | | { |
| | | return apiResponse.SuccessResponse(); |
| | | |
| | | } |
| | | else |
| | | { |
| | | conveyorLine.Communicator.Write<short>(Request.DeviceProAddress, 0); |
| | | return apiResponse.ErrorResponse("读åplcä¸å¯è¿å
¥ä¿¡æ¯"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return apiResponse.SuccessResponse(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return apiResponse.ErrorResponse("åå
¥plcè¿å
¥ä¿¡å·å¤±è´¥"); |
| | | } |
| | | } |
| | | else if (agvUpdateRequest.agvstatus == 2) |
| | | { |
| | | //åå
¥è¾éçº¿ä¿¡å· |
| | | bool portStatus = conveyorLine.Communicator.Write<short>(HandShake.DeviceProAddress, 0); |
| | | if (portStatus) |
| | | { |
| | | if (Request != null) |
| | | { |
| | | conveyorLine.Communicator.Write<short>(Request.DeviceProAddress, 0); |
| | | WriteLog.Write_Log("ç³è¯·ç¦»å¼AGVåé¦ä¿¡å·ä¿¡æ¯", "ç³è¯·ç¦»å¼AGVåé¦ä¿¡å·ä¿¡æ¯", $"åºå£ç¼å·ï¼ã{agvUpdateRequest.warehousenumber}ãï¼ç³è¯·ä¿¡å·å°åï¼ã{HandShake.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(HandShake.DeviceProAddress)}ã\n" + |
| | | $"å¤ç¨ä¿¡å·å°åï¼ã{Request.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(Request.DeviceProAddress)}ã"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | WriteLog.Write_Log("ç³è¯·ç¦»å¼AGVåé¦ä¿¡å·ä¿¡æ¯", "ç³è¯·ç¦»å¼AGVåé¦ä¿¡å·ä¿¡æ¯", $"åºå£ç¼å·ï¼ã{agvUpdateRequest.warehousenumber}ãï¼ç³è¯·ä¿¡å·å°åï¼ã{HandShake.DeviceProAddress}ãï¼è¯»åæ°æ®ï¼ã{conveyorLine.Communicator.Read<ushort>(HandShake.DeviceProAddress)}ã\n" ); |
| | | } |
| | | return apiResponse.SuccessResponse(); |
| | | } |
| | | else |
| | | { |
| | | return apiResponse.ErrorResponse("读åplcä¸å¯è¿å
¥ä¿¡æ¯"); |
| | | return apiResponse.ErrorResponse("åå
¥plcæ¸
é¤ä¿¡å·å¤±è´¥"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return apiResponse.ErrorResponse("åå
¥plcè¿å
¥ä¿¡å·å¤±è´¥"); |
| | | return apiResponse.ErrorResponse($"agv对åºçç³è¯·é误ï¼å段ï¼agvstatusï¼ç³è¯·çå¼ï¼{agvUpdateRequest.agvstatus}"); |
| | | } |
| | | } |
| | | 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) |
| | | { |
| | |
| | | taskInfo1.taskType = taskType; |
| | | taskInfo1.invType = invType; |
| | | taskInfo1.psd = "akjfapjfpadaoif"; |
| | | |
| | | commandResult = HttpHelper.Post<CommandResult>(urlWMStaskreturn, taskInfo1, "ä»»å¡ç¶æåè°"); |
| | | |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸åé¦ä»»å¡å®æ", "ä»»å¡ä¿¡æ¯", $"ä»»å¡å·ï¼{taskId}", $"è°ååæ°ï¼{taskInfo1.ToJson()},è¿ååæ°ï¼{commandResult.ToJson()}"); |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸åé¦ä»»å¡å®æ", "ä»»å¡ä¿¡æ¯", $"ä»»å¡å·ï¼{taskId}", $"è°ååæ°ï¼{taskInfo1.ToJsonString()},è¿ååæ°ï¼{commandResult.ToJsonString()}"); |
| | | return commandResult; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("è°å䏿¸¸æ¥å£é误ï¼åå ï¼"+ex.Message); |
| | | commandResult.status = "error"; |
| | | commandResult.result = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | string resujos = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | commandResult.result = resujos.ToJsonString(); |
| | | |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸åé¦ä»»å¡å®æ", "ä»»å¡ä¿¡æ¯", $"ä»»å¡å·ï¼{taskId}", $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸åé¦ä»»å¡å®æ", "ä»»å¡ä¿¡æ¯", $"ä»»å¡å·ï¼{taskId}", $"éè¦ä¸ä¼ WMSä¿¡æ¯å
容ï¼{commandResult.ToJsonString()},WCSæ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | return commandResult; |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | commandResult.status = "error"; |
| | | commandResult.result = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | string resujos = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | commandResult.result = resujos.ToJsonString(); |
| | | |
| | | |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸è®¾å¤æ
éä¿¡æ¯", "è®¾å¤æ
éä¿¡æ¯", $"设å¤idï¼{devuuid}ï¼å¤±è´¥", $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | return commandResult; |
| | |
| | | catch (Exception ex) |
| | | { |
| | | commandResult.status = "error"; |
| | | commandResult.result = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | string resujos = $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"; |
| | | commandResult.result = resujos.ToJsonString(); |
| | | |
| | | WriteLog.Write_Log("忥ç»ä¸æ¸¸æåå°ä½ä¿¡æ¯", "ä¿¡æ¯å
容", $"é误信æ¯", $"WCSæ¥å£é误ï¼åå ï¼{ex.Message}"); |
| | | return commandResult; |
| | | } |