| | |
| | | using HslCommunication.WebSocket; |
| | | using HslCommunication.WebSocket; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | |
| | | /// <param name="palletType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("AssignLocation"), AllowAnonymous] |
| | | public Dt_LocationInfo? AssignLocation(string roadwayNo, int palletType, int warehouseId, int heightType) |
| | | public Dt_LocationInfo? AssignLocation(string roadwayNo, int palletType, int warehouseId) |
| | | { |
| | | return Service.AssignLocation(roadwayNo, palletType, warehouseId, heightType: heightType); |
| | | return Service.AssignLocation(roadwayNo, palletType, warehouseId); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return WebResponseContent.Instance.Error(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢æ¡ä»¶è´§ä½ |
| | | /// </summary> |
| | | /// <param name="roadwayNo"></param> |
| | | /// <param name="warehouseId"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetLocationStatus")] |
| | | public WebResponseContent GetLocationStatus(string roadwayNo, int warehouseId = 0) |
| | | { |
| | | // å®ä¹è¿åæ°æ®ç»æ |
| | | var result = new |
| | | { |
| | | row1 = new List<object>(), // å··é第1æï¼ä¸é¢ï¼ |
| | | row2 = new List<object>() // å··é第2æï¼è¥¿é¢ï¼ |
| | | }; |
| | | |
| | | // æ¥è¯¢å··é䏿æè´§ä½ |
| | | var locations = _repository.QueryData(x => x.RoadwayNo == roadwayNo); |
| | | |
| | | // è·åææå±ï¼æä»é«å°ä½æåº |
| | | var layers = locations.Select(x => x.Layer).Distinct().OrderByDescending(x => x).ToList(); |
| | | |
| | | // å¤çæ¯ä¸å± |
| | | foreach (var layer in layers) |
| | | { |
| | | // è·åå½åå±çè´§ä½ |
| | | var layerLocations = locations.Where(x => x.Layer == layer); |
| | | |
| | | // 第1ææ°æ®ï¼ä¸é¢ï¼ |
| | | var row1Locations = layerLocations.Where(x => x.Row == 1) |
| | | .OrderBy(x => x.Columns) |
| | | .Select(x => new |
| | | { |
| | | layer = x.Layer.ToString().PadLeft(2, '0'), |
| | | row = x.Row.ToString().PadLeft(2, '0'), |
| | | column = x.Columns.ToString().PadLeft(2, '0'), |
| | | locationCode = x.LocationCode, |
| | | location_lock = x.LocationStatus |
| | | }).ToList(); |
| | | |
| | | // 第2ææ°æ®ï¼è¥¿é¢ï¼ |
| | | var row2Locations = layerLocations.Where(x => x.Row == 2) |
| | | .OrderBy(x => x.Columns) |
| | | .Select(x => new |
| | | { |
| | | layer = x.Layer.ToString().PadLeft(2, '0'), |
| | | row = x.Row.ToString().PadLeft(2, '0'), |
| | | column = x.Columns.ToString().PadLeft(2, '0'), |
| | | locationCode = x.LocationCode, |
| | | location_lock = x.LocationStatus |
| | | }).ToList(); |
| | | |
| | | // æ·»å å°ç»æä¸ |
| | | result.row1.Add(new { layer, locationObj = row1Locations }); |
| | | result.row2.Add(new { layer, locationObj = row2Locations }); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK("æå", result); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢å
¨é¨å··é |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetRow")] |
| | | public WebResponseContent GetRow() |
| | | { |
| | | // ä¿æå
¼å®¹æ§æ¥å£ï¼è¿åå··éå表 |
| | | List<string> roadwayList = _repository.QueryData().Select(x => x.RoadwayNo).Distinct().ToList(); |
| | | return WebResponseContent.Instance.OK("æå", roadwayList); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢å
¨é¨å··é |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetRoadway")] |
| | | public WebResponseContent GetRoadway() |
| | | { |
| | | List<string> roadwayList = _repository.QueryData().Select(x => x.RoadwayNo).Distinct().ToList(); |
| | | return WebResponseContent.Instance.OK("æå", roadwayList); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢è´§ä½RFID |
| | | /// </summary> |
| | | /// <param name="requestData"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, Route("GetRfid")] |
| | | public WebResponseContent GetRfid([FromBody] dynamic requestData) |
| | | { |
| | | try |
| | | { |
| | | if (requestData == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("è¯·æ±æ°æ®ä¸ºç©º"); |
| | | } |
| | | |
| | | // æ£æ¥locationCodesåæ®µæ¯å¦åå¨ä¸ä¸ä¸ºnullï¼å
¼å®¹locationCodeï¼ |
| | | if (requestData.locationCodes == null && requestData.locationCode == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("è´§ä½ç¼å·æ°ç»ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // 转æ¢ä¸ºstring[]ï¼ä¼å
使ç¨locationCodes |
| | | string[] locationCode = null; |
| | | var locationCodeField = requestData.locationCodes ?? requestData.locationCode; |
| | | if (locationCodeField is Newtonsoft.Json.Linq.JArray) |
| | | { |
| | | locationCode = ((Newtonsoft.Json.Linq.JArray)locationCodeField).ToObject<string[]>(); |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error("è´§ä½ç¼å·å¿
é¡»æ¯æ°ç»æ ¼å¼"); |
| | | } |
| | | |
| | | // æ£æ¥warehouseIdåæ®µæ¯å¦åå¨ |
| | | int warehouseId = 0; |
| | | if (requestData.warehouseId != null) |
| | | { |
| | | warehouseId = Convert.ToInt32(requestData.warehouseId); |
| | | } |
| | | |
| | | return Service.GetRfid(locationCode, warehouseId); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error($"åæ°è§£æå¤±è´¥: {ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | } |