| | |
| | | return WebResponseContent.Instance.Error(e.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢æ¡ä»¶è´§ä½ |
| | | /// </summary> |
| | | /// <param name="row"></param> |
| | | /// <param name="warehouseId"></param> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetLocationStatus")] |
| | | public WebResponseContent GetLocationStatus(int row, int warehouseId = 0) |
| | | { |
| | | List<int> layers; |
| | | if (warehouseId == 0) |
| | | { |
| | | layers = _repository.QueryData(x => x.Row == row).Select(x => x.Layer).Distinct().ToList(); |
| | | } |
| | | else |
| | | { |
| | | layers = _repository.QueryData(x => x.Row == row && x.WarehouseId == warehouseId).Select(x => x.Layer).Distinct().ToList(); |
| | | } |
| | | |
| | | List<object> listObj = new List<object>(); |
| | | foreach (var item in layers) |
| | | { |
| | | object locationObj; |
| | | if (warehouseId == 0) |
| | | { |
| | | locationObj = _repository.QueryData(x => x.Row == row && x.Layer == item) |
| | | .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(); |
| | | } |
| | | else |
| | | { |
| | | locationObj = _repository.QueryData(x => x.Row == row && x.Layer == item && x.WarehouseId == warehouseId) |
| | | .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(); |
| | | } |
| | | |
| | | object obj = new { layer = item, locationObj }; |
| | | listObj.Add(obj); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK("æå", listObj); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢å
¨é¨è´§ä½ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost, HttpGet, Route("GetRow")] |
| | | public WebResponseContent GetRow() |
| | | { |
| | | List<int> listRow = _repository.QueryData().Select(x => x.Row).Distinct().ToList(); |
| | | return WebResponseContent.Instance.OK("æå", listRow); |
| | | } |
| | | |
| | | /// <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}"); |
| | | } |
| | | } |
| | | } |
| | | } |