@@ -69,5 +69,16 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device | |||||
{ | { | ||||
return await _deviceService.GetDeviceTechnology(dto); | return await _deviceService.GetDeviceTechnology(dto); | ||||
} | } | ||||
/// <summary> | |||||
/// 上传设备日志 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
[HttpPost("/api/ExternalPlatform/Device/uploadDeviceLog")] | |||||
public async Task<List<ResponseMessageDto>> UploadDeviceLog([FromForm] DeviceLogDto dto) | |||||
{ | |||||
return await _deviceService.UploadDeviceLog(dto); | |||||
} | |||||
} | } | ||||
} | } |
@@ -0,0 +1,13 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos | |||||
{ | |||||
public class DeviceLogDto | |||||
{ | |||||
public IFormFile FormFile { get; set; } | |||||
} | |||||
} |
@@ -1,7 +1,9 @@ | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.Aliyun.OSS; | |||||
using BPA.KitChen.GroupMeal.SqlSugar; | |||||
using BPA.SAAS.KitChenManage.Core; | using BPA.SAAS.KitChenManage.Core; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | using BPA.SAAS.Manage.Application.AExternalPlatform.Enum; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Dtos; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; | using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute; | ||||
@@ -26,7 +28,15 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||||
{ | { | ||||
public class DeviceService: IDeviceService, ITransient | public class DeviceService: IDeviceService, ITransient | ||||
{ | { | ||||
private AliyunOssClient _aliyunOssClient; | |||||
private readonly ICheckServices _checkServices; | |||||
private string BaseServerUrl = App.GetConfig<string>("baseurl"); | private string BaseServerUrl = App.GetConfig<string>("baseurl"); | ||||
public DeviceService(ICheckServices checkServices, AliyunOssClient aliyunOssClient) | |||||
{ | |||||
_checkServices = checkServices; | |||||
_aliyunOssClient = aliyunOssClient; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 分页查询 | /// 分页查询 | ||||
/// </summary> | /// </summary> | ||||
@@ -194,5 +204,47 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
#region 日志接口 | |||||
/// <summary> | |||||
/// 上传设备日志 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
public async Task<List<ResponseMessageDto>> UploadDeviceLog(DeviceLogDto dto) | |||||
{ | |||||
try | |||||
{ | |||||
SqlSugarDb.Db.Ado.BeginTran(); | |||||
var errorList = new List<ResponseMessageDto>(); | |||||
var successList = new List<ResponseMessageDto>(); | |||||
var logAddList = new List<BPA_DeviceLog>(); | |||||
var userId = await _checkServices.GetUserId(App.HttpContext.Request.Headers["key"].ToString()); | |||||
var aliyunHost = "https://bpa.oss-cn-chengdu.aliyuncs.com/"; | |||||
var data = await _aliyunOssClient.UpFileAsync(dto.FormFile); | |||||
var log = new BPA_DeviceLog | |||||
{ | |||||
Id = Guid.NewGuid().ToString(), | |||||
FileName = dto.FormFile.FileName, | |||||
FileUrl = aliyunHost + data, | |||||
CreateAt = DateTime.Now, | |||||
CreateBy = userId | |||||
}; | |||||
logAddList.Add(log); | |||||
successList.Add(new ResponseMessageDto { Code = 30000, Message = "设备日志上传成功", Id = log.Id, Name = log.FileName }); | |||||
if (errorList.Count > 0) | |||||
return errorList; | |||||
if (logAddList.Count > 0) | |||||
await SqlSugarDb.Db.Insertable(logAddList).ExecuteCommandAsync(); | |||||
SqlSugarDb.Db.Ado.CommitTran(); | |||||
return successList; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
SqlSugarDb.Db.Ado.RollbackTran(); | |||||
throw Oops.Oh(e.Message); | |||||
} | |||||
} | |||||
#endregion | |||||
} | } | ||||
} | } |
@@ -45,5 +45,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services | |||||
/// <param name="dto"></param> | /// <param name="dto"></param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<List<DeviceTechnogolyDateDto>> GetDeviceTechnology(DeviceTechnogolyRequestDto dto); | Task<List<DeviceTechnogolyDateDto>> GetDeviceTechnology(DeviceTechnogolyRequestDto dto); | ||||
/// <summary> | |||||
/// 上传设备日志 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
Task<List<ResponseMessageDto>> UploadDeviceLog(DeviceLogDto dto); | |||||
} | } | ||||
} | } |
@@ -31,6 +31,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos | |||||
public string GoodsName { get; set; } | public string GoodsName { get; set; } | ||||
public DateTime? CreateAt { get; set; } | |||||
public string ImgUrl { get; set; } | public string ImgUrl { get; set; } | ||||
} | } | ||||
@@ -228,20 +228,22 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
var goodsIds = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => t.DeviceId == device.Id).Select(a => a.GoodsId).Distinct().ToListAsync(); | var goodsIds = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => t.DeviceId == device.Id).Select(a => a.GoodsId).Distinct().ToListAsync(); | ||||
var goodsList = await _db.Queryable<BPA_GoodsInfo>().ToListAsync(); | var goodsList = await _db.Queryable<BPA_GoodsInfo>().ToListAsync(); | ||||
var classifyRelationList = await _db.Queryable<BPA_GoodsClassifyRelation>().ToListAsync(); | var classifyRelationList = await _db.Queryable<BPA_GoodsClassifyRelation>().ToListAsync(); | ||||
var classifyList = await _db.Queryable<BPA_GoodsClassify>().ToListAsync(); | |||||
var classifyList = await _db.Queryable<BPA_GoodsClassify>().OrderByDescending(t => t.CreateAt).ToListAsync(); | |||||
var classifyDataList = new List<GoodsClassifyResultDto>(); | var classifyDataList = new List<GoodsClassifyResultDto>(); | ||||
foreach (var classify in classifyList) | foreach (var classify in classifyList) | ||||
{ | { | ||||
classifyDataList.Add(new GoodsClassifyResultDto | classifyDataList.Add(new GoodsClassifyResultDto | ||||
{ | { | ||||
GoodsClassifyId = classify.Id, | GoodsClassifyId = classify.Id, | ||||
GoodsClassifyName = classify.Name, | GoodsClassifyName = classify.Name, | ||||
GoodsList = classifyRelationList.Where(t => t.ClassifyId == classify.Id) | GoodsList = classifyRelationList.Where(t => t.ClassifyId == classify.Id) | ||||
.Select(a => new GoodsDataResultDto { | |||||
GoodsId = a.GoodsId, | |||||
GoodsName = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.Name, | |||||
ImgUrl = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.ImgUrl }).ToList() | |||||
.Select(a => new GoodsDataResultDto | |||||
{ | |||||
GoodsId = a.GoodsId, | |||||
GoodsName = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.Name, | |||||
ImgUrl = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.ImgUrl, | |||||
CreateAt = goodsList.FirstOrDefault(t=>t.Id == a.GoodsId)?.CreateAt | |||||
}).OrderByDescending(g => g.CreateAt).ToList() | |||||
}); | }); | ||||
} | } | ||||
foreach (var item in classifyDataList) | foreach (var item in classifyDataList) | ||||
@@ -477,6 +477,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
var s = sf[i].AsQueryable().ToList().GroupBy(x => x.DeviceId).ToList(); | var s = sf[i].AsQueryable().ToList().GroupBy(x => x.DeviceId).ToList(); | ||||
for (int t = 0; t < s.Count; t++) | for (int t = 0; t < s.Count; t++) | ||||
{ | { | ||||
var ss = s[t].AsQueryable(); | |||||
GoodsTechnologyActionListView item = new() | GoodsTechnologyActionListView item = new() | ||||
{ | { | ||||
DeviceId = s[t].Key, | DeviceId = s[t].Key, | ||||
@@ -104,5 +104,16 @@ namespace BPA.SAAS.Manage.Application.Device | |||||
{ | { | ||||
return await _deviceService.GetDeviceInfoByDeviceId(autoKey); | return await _deviceService.GetDeviceInfoByDeviceId(autoKey); | ||||
} | } | ||||
/// <summary> | |||||
/// 分页查询设备日志 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
[HttpPost("/api/device/getDeviceLogPage")] | |||||
public async Task<PageUtil> GetDeviceLogPage(DeviceLogQueryDto dto) | |||||
{ | |||||
return await _deviceService.GetDeviceLogPage(dto); | |||||
} | |||||
} | } | ||||
} | } |
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.Device.Dtos.Device | |||||
{ | |||||
public class DeviceLogDto | |||||
{ | |||||
public string Id { get; set; } | |||||
public string FileName { get; set; } | |||||
public string FileUrl { get; set; } | |||||
public string GroupId { get; set; } | |||||
public string CompanyName { get; set; } | |||||
public DateTime CreateAt { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
using BPA.SAAS.Manage.Core.Base; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.Device.Dtos.Device | |||||
{ | |||||
public class DeviceLogQueryDto : PageInputBase | |||||
{ | |||||
public string FileName { get; set; } | |||||
public DateTime? StartTime { get; set; } | |||||
public DateTime? EndTime { get; set; } | |||||
} | |||||
} |
@@ -22,5 +22,6 @@ namespace BPA.SAAS.Manage.Application.Device.Interface | |||||
Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto); | Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto); | ||||
Task<List<ListSelectQuery>> GetDeviceTypeList(); | Task<List<ListSelectQuery>> GetDeviceTypeList(); | ||||
Task<DeviceInfoQueryDto> GetDeviceInfoByDeviceId(string autoKey); | Task<DeviceInfoQueryDto> GetDeviceInfoByDeviceId(string autoKey); | ||||
Task<PageUtil> GetDeviceLogPage(DeviceLogQueryDto dto); | |||||
} | } | ||||
} | } |
@@ -270,5 +270,45 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
data.StopName = stopInfo.FirstOrDefault(a => a.Id == data.StopId)?.Name; | data.StopName = stopInfo.FirstOrDefault(a => a.Id == data.StopId)?.Name; | ||||
return data; | return data; | ||||
} | } | ||||
/// <summary> | |||||
/// 分页查询设备日志 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
public async Task<PageUtil> GetDeviceLogPage(DeviceLogQueryDto dto) | |||||
{ | |||||
var conModels = new List<IConditionalModel>(); | |||||
if (!string.IsNullOrWhiteSpace(dto.FileName)) | |||||
conModels.Add(new ConditionalModel() { FieldName = "FileName", ConditionalType = ConditionalType.Like, FieldValue = dto.FileName }); | |||||
if (dto.StartTime.HasValue) | |||||
conModels.Add(new ConditionalModel() { FieldName = "CreateAt", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = dto.StartTime.ToString() }); | |||||
if (dto.EndTime.HasValue) | |||||
conModels.Add(new ConditionalModel() { FieldName = "CreateAt", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = dto.EndTime.ToString() }); | |||||
RefAsync<int> total = 0; | |||||
var companyList = await _db.Queryable<BPA_Company>().ToListAsync(); | |||||
var res = await _db.Queryable<BPA_DeviceLog>().Where(conModels) | |||||
.OrderByDescending(t => t.CreateAt) | |||||
.Select(a => new DeviceLogDto | |||||
{ | |||||
Id = a.Id, | |||||
FileName = a.FileName, | |||||
FileUrl = a.FileUrl, | |||||
CreateAt = a.CreateAt, | |||||
GroupId = a.GroupId, | |||||
}).Mapper(i => | |||||
{ | |||||
var company = companyList.FirstOrDefault(t => t.Id == i.GroupId); | |||||
if (company != null) | |||||
i.CompanyName = company.Name; | |||||
}).ToPageListAsync(dto.Current, dto.PageSize, total); | |||||
var util = new PageUtil | |||||
{ | |||||
Total = total, | |||||
Data = res | |||||
}; | |||||
return util; | |||||
} | |||||
} | } | ||||
} | } |
@@ -72,23 +72,22 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<List<TechnologyView>> GetTechnologyList(string deviceId) | public async Task<List<TechnologyView>> GetTechnologyList(string deviceId) | ||||
{ | { | ||||
var device= _db.Queryable<BPA_DeviceInfo>().Where(x=>x.Id== deviceId).First(); | |||||
var device = _db.Queryable<BPA_DeviceInfo>().Where(x => x.Id == deviceId).First(); | |||||
if (device == null) return new List<TechnologyView>(); | if (device == null) return new List<TechnologyView>(); | ||||
var data = await _db.Queryable<BPA_Technology>().Where(x=>x.DeviceVersionId== device.ProductVersionId).Select(a => new TechnologyView | |||||
var data = await _db.Queryable<BPA_Technology>().Where(x => x.DeviceVersionId == device.ProductVersionId).Select(a => new TechnologyView | |||||
{ | { | ||||
Id = a.Id, | Id = a.Id, | ||||
Name = a.Name, | Name = a.Name, | ||||
DeviceVersionId = a.DeviceVersionId, | DeviceVersionId = a.DeviceVersionId, | ||||
CreateAt = a.CreateAt, | CreateAt = a.CreateAt, | ||||
}).OrderBy(a => a.CreateAt, OrderByType.Desc) | |||||
}).OrderBy(a => a.CreateAt, OrderByType.Desc) | |||||
.Mapper(x => | .Mapper(x => | ||||
{ | { | ||||
//var TechnologyInfo1 = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList(); | //var TechnologyInfo1 = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList(); | ||||
var TechnologyInfo = _db.Queryable<BPA_TechnologyAction>().Where(d => d.TechnologyId == x.Id).ToList(); | |||||
var TechnologyInfo = _db.Queryable<BPA_TechnologyAction>().Where(d => d.TechnologyId == x.Id).OrderBy(d => d.Sort).ToList(); | |||||
x.TechnologyActionInfo = TechnologyInfo; | x.TechnologyActionInfo = TechnologyInfo; | ||||
}) | }) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
return data; | return data; | ||||
} | } | ||||
public async Task<List<TechnologyView>> GetTechnologyList_alm(string deviceId) | public async Task<List<TechnologyView>> GetTechnologyList_alm(string deviceId) | ||||
@@ -104,7 +103,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
.Mapper(x => | .Mapper(x => | ||||
{ | { | ||||
//var TechnologyInfo1 = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList(); | //var TechnologyInfo1 = _db.Queryable<BPA_Technology>().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList(); | ||||
var TechnologyInfo = _db.Queryable<BPA_TechnologyAction>().Where(d => d.TechnologyId == x.Id).ToList(); | |||||
var TechnologyInfo = _db.Queryable<BPA_TechnologyAction>().Where(d => d.TechnologyId == x.Id).OrderBy(d => d.Sort).ToList(); | |||||
x.TechnologyActionInfo = TechnologyInfo; | x.TechnologyActionInfo = TechnologyInfo; | ||||
}) | }) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
@@ -0,0 +1,31 @@ | |||||
using BPA.SAAS.Manage.Core.Base; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Core.Device | |||||
{ | |||||
/// <summary> | |||||
/// 设备日志表 | |||||
/// </summary> | |||||
public class BPA_DeviceLog : IGroupId | |||||
{ | |||||
public string Id { get; set; } | |||||
/// <summary> | |||||
/// 文件名称 | |||||
/// </summary> | |||||
public string FileName { get; set; } | |||||
/// <summary> | |||||
/// 文件路径 | |||||
/// </summary> | |||||
public string FileUrl { get; set; } | |||||
public DateTime CreateAt { get; set; } | |||||
public string CreateBy { get; set; } | |||||
/// <summary> | |||||
/// 加盟商id | |||||
/// </summary> | |||||
public string GroupId { get; set; } | |||||
} | |||||
} |