| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.Util; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_WMSServer.Controllers.BigGreen |
| | | { |
| | |
| | | public class BigScreenController : ControllerBase |
| | | { |
| | | private readonly IBigGreenService _bigGreenService; |
| | | public BigScreenController(IBigGreenService bigGreenService) |
| | | private readonly HttpClientHelper _httpClientHelper; |
| | | private readonly IRepository<Dt_LocationInfo> _locationInfoRepository; |
| | | |
| | | public BigScreenController(IBigGreenService bigGreenService, HttpClientHelper httpClientHelper, IRepository<Dt_LocationInfo> locationInfoRepository) |
| | | { |
| | | _bigGreenService = bigGreenService; |
| | | _httpClientHelper = httpClientHelper; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | } |
| | | |
| | | [HttpGet, Route("GetBigGreenData"),AllowAnonymous] |
| | | [HttpGet, Route("GetBigGreenData"), AllowAnonymous] |
| | | public WebResponseContent GetBigGreenData() |
| | | { |
| | | return _bigGreenService.GetBigGreenData(); |
| | | } |
| | | [HttpGet, Route("Test"), AllowAnonymous] |
| | | public WebResponseContent Test() |
| | | { |
| | | string url = "http://172.21.98.57:9046/location/query"; |
| | | HttpResponseResult<Dictionary<string, object>> result = _httpClientHelper.Post<Dictionary<string, object>>(url, "{\"locationCodes\":[],\"containerCode\":\"\",\"locationTypeCodes\":[\"LT_SHELF_STORAGE\"]}"); |
| | | |
| | | if (result.Data.TryGetValue("data", out object? data)) |
| | | { |
| | | if (JsonConvert.DeserializeObject<Dictionary<string, object>>(data.Serialize())?.TryGetValue("locations", out object? locations) ?? false) |
| | | { |
| | | List<Dictionary<string, object>>? keyValuePairs = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(locations.Serialize()); |
| | | if (keyValuePairs != null) |
| | | { |
| | | List<string> list = keyValuePairs.Select(x => x["locationCode"].ToString() ?? "").ToList(); |
| | | |
| | | List<string> locationCodes = _locationInfoRepository.QueryData().Select(x => x.LocationCode).ToList(); |
| | | |
| | | List<string> notContainLocations = list.Where(x => !locationCodes.Contains(x)).ToList(); |
| | | |
| | | return WebResponseContent.Instance.OK(data: notContainLocations); |
| | | } |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(); |
| | | |
| | | } |
| | | } |
| | | } |