| | |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO; |
| | | using WIDESEAWCS_DTO.Agv; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGV浠诲姟璇锋眰 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("WorkRequest"), AllowAnonymous] |
| | | public AgvTaskReqContent WorkRequest([FromBody] AgvTaskRequestDTO agvTaskRequestDTO) |
| | | { |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | //鑾峰彇浠诲姟 |
| | | Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"鏈壘鍒版枡绠眥agvTaskRequestDTO.ContainerCode}浠诲姟"); |
| | | //鑾峰彇绔欏彴 |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"鏈壘鍒皗agvTaskRequestDTO.PositionId}绔欏彴浣嶇疆"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}"); |
| | | |
| | | OtherDevice commonConveyorLine = (OtherDevice)device; |
| | | |
| | | if (stationManger.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | short IsPut = commonConveyorLine.Communicator.Read<short>("0"); |
| | | if (IsPut != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}绂佹鏀剧"); |
| | | } |
| | | else |
| | | { |
| | | short IsTake = commonConveyorLine.Communicator.Read<short>("11"); |
| | | if (IsTake != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}绂佹鍙栫"); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// AGV浣滀笟瀹屾垚 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("WorkFinish"), AllowAnonymous] |
| | | public AgvTaskReqContent WorkFinish([FromBody] AgvTaskRequestDTO agvTaskRequestDTO) |
| | | { |
| | | AgvTaskReqContent content = new AgvTaskReqContent(); |
| | | try |
| | | { |
| | | //鑾峰彇绔欏彴 |
| | | Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"鏈壘鍒皗agvTaskRequestDTO.PositionId}绔欏彴浣嶇疆"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"鏈壘鍒板搴旇澶噞stationManger.StationDeviceCode}"); |
| | | |
| | | OtherDevice commonConveyorLine = (OtherDevice)device; |
| | | |
| | | if (stationManger.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) |
| | | { |
| | | commonConveyorLine.Communicator.Write("21", new byte[] { 1, 0 }); |
| | | } |
| | | else |
| | | { |
| | | commonConveyorLine.Communicator.Write("23", new byte[] { 1, 0 }); |
| | | } |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |