diff --git a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs index 3fa83b9..7c9d430 100644 --- a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs +++ b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs @@ -39,6 +39,11 @@ namespace BPA.SAAS.Manage.Application.Device { return await _deviceService.GetDeviceList(); } + [HttpGet("/api/device/getdevicebystoplist")] + public async Task> GetDeviceByStopList(string stopId) + { + return await _deviceService.GetDeviceByStopList(stopId); + } /// /// 添加 /// diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs index 9cc7eeb..62f3be4 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs @@ -23,7 +23,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services { public class DeviceService: IDeviceService, ITransient { - private string BaseServerUrl=App.GetConfig("baseurl"); + StoreServers storeServer = new(); ISqlSugarClient _db; public DeviceService(ISqlSugarClient db) { @@ -36,14 +36,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services /// public async Task GetDeviceInfoPage(DeviceQueryInputDto inputDto) { - var getStoreurl = BaseServerUrl + "api/goodsattribute/getstorelist_alm";//获取商品属性 - var responseGoodsAttribute = await getStoreurl.SetHeaders(new - { - groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value - }).SetHttpMethod(HttpMethod.Get).GetAsStringAsync(); - var resStore = JsonConvert.DeserializeObject(responseGoodsAttribute); - if (resStore.statusCode != "200") throw Oops.Oh("获取场景数据失败"); - var dataStore = JsonConvert.DeserializeObject>(resStore.data.ToString()); + var dataStore =await storeServer.GetStop(); RefAsync total =0; var data = await _db.Queryable((a, b) => new JoinQueryInfos(JoinType.Left, a.ProductId == b.Id)) @@ -63,7 +56,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services { var Vesion = _db.Queryable().Where(c => c.Id == x.ProductVersionId).First(); x.ProductVersionName = Vesion?.Vesion; - x.StopName= dataStore?.Where(f=>f.Id==x.StopId).First()?.Name; + x.StopName= dataStore?.Where(f=>f.Id==x.StopId).FirstOrDefault()?.Name; }) .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); return new PageUtil() diff --git a/BPA.SAAS.Manage.Application/StoreServers.cs b/BPA.SAAS.Manage.Application/StoreServers.cs new file mode 100644 index 0000000..b30259c --- /dev/null +++ b/BPA.SAAS.Manage.Application/StoreServers.cs @@ -0,0 +1,36 @@ +using BPA.SAAS.Manage.Application.Device.Dtos.Device; +using BPA.SAAS.Manage.Comm.Const; +using BPA.SAAS.Manage.Core.Base; +using Furion.RemoteRequest.Extensions; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.SAAS.Manage.Application +{ + [ApiDescriptionSettings("Stop", Tag = "获取场景")] + public class StoreServers: IDynamicApiController + { + public StoreServers() + { + + } + private string BaseServerUrl = App.GetConfig("baseurl"); + [HttpGet("/api/stop/getstop")] + public async Task> GetStop() + { + var getStoreurl = BaseServerUrl + "api/store/getstorelist_alm";//获取商品属性 + var responseGoodsAttribute = await getStoreurl.SetHeaders(new + { + groupId = App.User?.FindFirst(ClaimConst.GroupId)?.Value + }).SetHttpMethod(HttpMethod.Get).GetAsStringAsync(); + var resStore = JsonConvert.DeserializeObject(responseGoodsAttribute); + if (resStore?.statusCode != "200") throw Oops.Oh("获取场景数据失败"); + var dataStore = JsonConvert.DeserializeObject>(resStore.data.ToString()); + return dataStore; + } + } +} diff --git a/BPA.SAAS.Manage.Web.Core/Startup.cs b/BPA.SAAS.Manage.Web.Core/Startup.cs index 9f63800..c7678b8 100644 --- a/BPA.SAAS.Manage.Web.Core/Startup.cs +++ b/BPA.SAAS.Manage.Web.Core/Startup.cs @@ -65,6 +65,7 @@ namespace BPA.SAAS.Manage.Web.Core }); }); services.AddCorsAccessor(); + services.AddRemoteRequest(); services.AddSqlsugarSetup(App.Configuration); services.AddControllers() .AddInjectWithUnifyResult();