@@ -1,4 +1,5 @@
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute;
using BPA.SAAS.Manage.Application.Device.Dtos.Device;
using BPA.SAAS.Manage.Application.Device.Interface;
using BPA.SAAS.Manage.Comm.Const;
using BPA.SAAS.Manage.Comm.Enum;
@@ -10,6 +11,8 @@ using BPA.SAAS.Manage.Core.Org;
using BPA.SAAS.Manage.Core.Product;
using BPA.SAAS.Manage.Core.system;
using Dm;
using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,6 +23,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
public class DeviceService: IDeviceService, ITransient
{
private string BaseServerUrl=App.GetConfig<string>("baseurl");
ISqlSugarClient _db;
public DeviceService(ISqlSugarClient db)
{
@@ -32,10 +36,18 @@ namespace BPA.SAAS.Manage.Application.Device.Services
/// <returns></returns>
public async Task<PageUtil> 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<ResponDataBase>(responseGoodsAttribute);
if (resStore.statusCode != "200") throw Oops.Oh("获取场景数据失败");
var dataStore = JsonConvert.DeserializeObject<List<StoreDto>>(resStore.data.ToString());
RefAsync<int> total =0;
var data = await _db.Queryable<BPA_DeviceInfo, BPA_Product>((a, b) => new JoinQueryInfos(JoinType.Left, a.ProductId == b.Id))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.StoreId), (a, b) => a.OrgId == inputDto.StoreId)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.StoreId), (a, b) => a.Stop Id == inputDto.StoreId)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceName), (a, b) => a.DeviceName.Contains(inputDto.DeviceName))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceTypeId), (a, b) => a.DeviceTypeId == inputDto.DeviceTypeId)
.OrderBy((a, b) => a.CreateAt, OrderByType.Desc)
@@ -44,12 +56,14 @@ namespace BPA.SAAS.Manage.Application.Device.Services
Id = a.Id.SelectAll(),
ProductName=b.Name,
ProductCode=b.Code,
StopId=a.StopId,
ProductVersionName = ""
})
.Mapper(x =>
{
var Vesion = _db.Queryable<BPA_ProductVesion>().Where(c => c.Id == x.ProductVersionId).First();
x.ProductVersionName = Vesion?.Vesion;
x.StopName= dataStore?.Where(f=>f.Id==x.StopId).First()?.Name;
})
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
return new PageUtil()
@@ -123,7 +137,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
x.DeviceName,
x.DeviceTypeId,
x.Org Id,
x.Stop Id,
x.ProductId,
x.ProductCode,
x.Status,