| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using System.IO; |
| | | using System.Text; |
| | | using WIDESEA_External.Model; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseController; |
| | |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Tasks.DBNames; |
| | | |
| | |
| | | } |
| | | |
| | | [HttpPost, Route("ReceiveTask"), AllowAnonymous] |
| | | public WebResponseContent ReceiveWMSTask([FromBody] WMSTaskDTO taskDTO) |
| | | public WMSReceiveTaskContent ReceiveWMSTask([FromBody] WMSTaskDTO taskDTO) |
| | | { |
| | | return Service.ReceiveWMSTask(taskDTO); |
| | | } |
| | |
| | | { |
| | | return Service.RollbackTaskStatusToLast(taskNum); |
| | | } |
| | | private static object lock_containerFlow = new object(); |
| | | /// <summary> |
| | | /// 容卿µå¨æ¥å£ |
| | | /// </summary> |
| | |
| | | [HttpPost, HttpGet, Route("ContainerFlow"), AllowAnonymous] |
| | | public WebResponseContent ContainerFlow([FromBody] ContainerFlowDTO containerFlowDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | lock (lock_containerFlow) |
| | | { |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x=>x.PickStationCode==containerFlowDTO.SlotCode) ?? throw new Exception($"{containerFlowDTO.SlotCode}æ£éä½ç½®ä¸åå¨"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |
| | | if (device == null) |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.PickStationCode == containerFlowDTO.SlotCode) ?? throw new Exception($"{containerFlowDTO.SlotCode}æ£éä½ç½®ä¸åå¨"); |
| | | IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode); |
| | | if (device == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°å¯¹åºè®¾å¤{stationManger.StationDeviceCode}"); |
| | | } |
| | | if (stationManger.StationDeviceCode == "CL1" || stationManger.StationDeviceCode == "CL2") |
| | | { |
| | | OtherDevice commonConveyorLine = (OtherDevice)device; |
| | | byte[] bytesPick = commonConveyorLine.Communicator.Read("2", 5); |
| | | string PickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", ""); |
| | | if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"ä¼ å
¥æç®±ç {containerFlowDTO.ContainerCode}ï¼è¾éæç®±ç {PickBarCode}æ°æ®é误"); |
| | | //if (containerFlowDTO.Direction == "100") |
| | | //{ |
| | | // WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode); |
| | | // if (!responseContent.Status) throw new Exception(responseContent.Message); |
| | | //} |
| | | WriteLog.Write_Log("䏿容卿µå¨å
¥åºæ¥å£", "ä»»å¡ä¿¡æ¯", $"è¿åè¾é线{stationManger.PickStationCode}", $"è¿åç»è¾é线çä»»å¡ä¿¡æ¯ï¼{containerFlowDTO.ToJson()}"); |
| | | commonConveyorLine.Communicator.Write("22", (containerFlowDTO.Direction == "100" ? new byte[] { 1, 0 } : new byte[] { 2, 0 })); |
| | | } |
| | | else |
| | | { |
| | | |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim(); |
| | | |
| | | if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"ä¼ å
¥æç®±ç {containerFlowDTO.ContainerCode}ï¼è¾éæç®±ç {PickBarCode}æ°æ®é误"); |
| | | |
| | | if (containerFlowDTO.Direction == "100") |
| | | { |
| | | short W_PickToHode = commonConveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.W_PickToHode, stationManger.StationCode); |
| | | if (W_PickToHode == 300) |
| | | { |
| | | WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode); |
| | | if (!responseContent.Status) throw new Exception(responseContent.Message); |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"ä¼ å
¥æç®±ç {containerFlowDTO.ContainerCode}ï¼è¾éæç¶æï¼{W_PickToHode}ï¼ä¸æ»¡è¶³å
¥åºæ¡ä»¶"); |
| | | } |
| | | } |
| | | WriteLog.Write_Log("äºæå®¹å¨æµå¨å
¥åºæ¥å£", "ä»»å¡ä¿¡æ¯", $"è¿åè¾é线{stationManger.PickStationCode}", $"è¿åç»è¾é线çä»»å¡ä¿¡æ¯ï¼{containerFlowDTO.ToJson()}"); |
| | | commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode); |
| | | } |
| | | content.OK(); |
| | | } |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim(); |
| | | if (containerFlowDTO.ContainerCode!= PickBarCode) throw new Exception($"ä¼ å
¥æç®±ç {containerFlowDTO.ContainerCode}ï¼è¾éæç®±ç {PickBarCode}æ°æ®é误"); |
| | | if (containerFlowDTO.Direction=="100") |
| | | catch (Exception ex) |
| | | { |
| | | WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode); |
| | | if (!responseContent.Status) throw new Exception(responseContent.Message); |
| | | content.Error(ex.Message); |
| | | } |
| | | commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode,(short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode); |
| | | content.OK(); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// æç§å¢åå§å |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("InitLight"), AllowAnonymous] |
| | | public WebResponseContent InitLight() |
| | | { |
| | | return Service.InitLight(); |
| | | } |
| | | /// <summary> |
| | | /// æç§å¢ç»æä½ä¸ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("EndLight"), AllowAnonymous] |
| | | public WebResponseContent EndLight() |
| | | { |
| | | return Service.EndLight(); |
| | | } |
| | | /// <summary> |
| | | /// æç§å¢äº®ç¯ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("SendLight"), AllowAnonymous] |
| | | public WebResponseContent SendLight([FromBody] TaskSendLight taskSendLight) |
| | | { |
| | | return Service.SendLight(taskSendLight); |
| | | } |
| | | /// <summary> |
| | | /// ç³è¯·å
¥åº |
| | |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("RecWMSTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent RecWMSTaskCompleted(int taskNum) |
| | | [HttpPost, HttpGet, Route("RecTaskCompleted"), AllowAnonymous] |
| | | public WebResponseContent RecTaskCompleted(int taskNum) |
| | | { |
| | | return Service.TaskCompleted(taskNum); |
| | | } |
| | | /// <summary> |
| | | /// 人工æå¨åæ¶æå®ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡ç¼å·</param> |
| | | /// <returns>æä½ç»æ</returns> |
| | | [HttpPost, HttpGet, Route("ManualTaskCancellation"), AllowAnonymous] |
| | | public WebResponseContent ManualTaskCancellation(int taskNum) |
| | | { |
| | | return Service.ManualTaskCancellation(taskNum); |
| | | } |
| | | /// WMSä»»å¡åæ¶åæ¥ |
| | | /// </summary> |
| | | /// <param name="taskCancels"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("CancelTask"), AllowAnonymous] |
| | | public WebResponseContent CancelTask([FromBody] List<TaskCancel> taskCancels) |
| | | { |
| | | return Service.TaskCancel(taskCancels); ; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æä»»å¡å¼å¸¸900ä¿®æ¹ä¸ºAGVæ§è¡ä¸300 |
| | | /// </summary> |
| | | /// <param name="taskNum"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("ResetAllExceptionTask"), AllowAnonymous] |
| | | public WebResponseContent ResetAllExceptionTask(int taskNum) |
| | | { |
| | | return Service.ResetAllExceptionTask(taskNum); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WMSå¼å¸¸æ¢å¤ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("WmsRecovery"), AllowAnonymous] |
| | | public WebResponseContent WmsRecovery() |
| | | { |
| | | return Service.WmsRecovery(); |
| | | } |
| | | } |
| | | } |