diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs
index 5377c86..758d657 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs
@@ -69,5 +69,16 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device
{
return await _deviceService.GetDeviceTechnology(dto);
}
+
+ ///
+ /// 上传设备日志
+ ///
+ ///
+ ///
+ [HttpPost("/api/ExternalPlatform/Device/uploadDeviceLog")]
+ public async Task> UploadDeviceLog([FromForm] DeviceLogDto dto)
+ {
+ return await _deviceService.UploadDeviceLog(dto);
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceLogDto.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceLogDto.cs
new file mode 100644
index 0000000..7989dba
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceLogDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs
index 2b89596..dbc0f50 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs
@@ -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.Manage.Application.AExternalPlatform.BaseDto;
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.Goods.Dtos;
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
{
+ private AliyunOssClient _aliyunOssClient;
+ private readonly ICheckServices _checkServices;
private string BaseServerUrl = App.GetConfig("baseurl");
+ public DeviceService(ICheckServices checkServices, AliyunOssClient aliyunOssClient)
+ {
+ _checkServices = checkServices;
+ _aliyunOssClient = aliyunOssClient;
+ }
+
///
/// 分页查询
///
@@ -194,5 +204,47 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
}
return result;
}
+
+ #region 日志接口
+ ///
+ /// 上传设备日志
+ ///
+ ///
+ ///
+ public async Task> UploadDeviceLog(DeviceLogDto dto)
+ {
+ try
+ {
+ SqlSugarDb.Db.Ado.BeginTran();
+ var errorList = new List();
+ var successList = new List();
+ var logAddList = new List();
+ 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
}
}
diff --git a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs
index b8cbbe1..a419aca 100644
--- a/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs
+++ b/BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs
@@ -45,5 +45,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
///
///
Task> GetDeviceTechnology(DeviceTechnogolyRequestDto dto);
+
+ ///
+ /// 上传设备日志
+ ///
+ ///
+ ///
+ Task> UploadDeviceLog(DeviceLogDto dto);
}
}
diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs
index d1d80e0..8de8801 100644
--- a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs
@@ -31,6 +31,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos
public string GoodsName { get; set; }
+ public DateTime? CreateAt { get; set; }
+
public string ImgUrl { get; set; }
}
diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
index 06939c7..b0ed86d 100644
--- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
@@ -228,20 +228,22 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
var goodsIds = await _db.Queryable().Where(t => t.DeviceId == device.Id).Select(a => a.GoodsId).Distinct().ToListAsync();
var goodsList = await _db.Queryable().ToListAsync();
var classifyRelationList = await _db.Queryable().ToListAsync();
- var classifyList = await _db.Queryable().ToListAsync();
+ var classifyList = await _db.Queryable().OrderByDescending(t => t.CreateAt).ToListAsync();
var classifyDataList = new List();
foreach (var classify in classifyList)
{
-
classifyDataList.Add(new GoodsClassifyResultDto
{
GoodsClassifyId = classify.Id,
GoodsClassifyName = classify.Name,
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)
diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs
index 749896a..50327eb 100644
--- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs
+++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs
@@ -477,6 +477,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
var s = sf[i].AsQueryable().ToList().GroupBy(x => x.DeviceId).ToList();
for (int t = 0; t < s.Count; t++)
{
+ var ss = s[t].AsQueryable();
GoodsTechnologyActionListView item = new()
{
DeviceId = s[t].Key,
diff --git a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
index d8b65fa..8fa8370 100644
--- a/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
+++ b/BPA.SAAS.Manage.Application/Device/DeviceServices.cs
@@ -104,5 +104,16 @@ namespace BPA.SAAS.Manage.Application.Device
{
return await _deviceService.GetDeviceInfoByDeviceId(autoKey);
}
+
+ ///
+ /// 分页查询设备日志
+ ///
+ ///
+ ///
+ [HttpPost("/api/device/getDeviceLogPage")]
+ public async Task GetDeviceLogPage(DeviceLogQueryDto dto)
+ {
+ return await _deviceService.GetDeviceLogPage(dto);
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogDto.cs
new file mode 100644
index 0000000..8d81ec2
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogQueryDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogQueryDto.cs
new file mode 100644
index 0000000..d4b94f1
--- /dev/null
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogQueryDto.cs
@@ -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; }
+ }
+}
diff --git a/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs b/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
index bc80fe3..4fe1597 100644
--- a/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
@@ -22,5 +22,6 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
Task AddDeviceTypeAsync(DeviceTypeBaseDto inputDto);
Task> GetDeviceTypeList();
Task GetDeviceInfoByDeviceId(string autoKey);
+ Task GetDeviceLogPage(DeviceLogQueryDto dto);
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
index 24f7005..0fe428d 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
@@ -270,5 +270,45 @@ namespace BPA.SAAS.Manage.Application.Device.Services
data.StopName = stopInfo.FirstOrDefault(a => a.Id == data.StopId)?.Name;
return data;
}
+
+
+ ///
+ /// 分页查询设备日志
+ ///
+ ///
+ ///
+ public async Task GetDeviceLogPage(DeviceLogQueryDto dto)
+ {
+ var conModels = new List();
+ 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 total = 0;
+ var companyList = await _db.Queryable().ToListAsync();
+ var res = await _db.Queryable().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;
+ }
}
}
diff --git a/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs b/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
index 1daac94..dbd7e6c 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
@@ -72,23 +72,22 @@ namespace BPA.SAAS.Manage.Application.Device.Services
///
public async Task> GetTechnologyList(string deviceId)
{
- var device= _db.Queryable().Where(x=>x.Id== deviceId).First();
+ var device = _db.Queryable().Where(x => x.Id == deviceId).First();
if (device == null) return new List();
- var data = await _db.Queryable().Where(x=>x.DeviceVersionId== device.ProductVersionId).Select(a => new TechnologyView
+ var data = await _db.Queryable().Where(x => x.DeviceVersionId == device.ProductVersionId).Select(a => new TechnologyView
{
Id = a.Id,
Name = a.Name,
DeviceVersionId = a.DeviceVersionId,
CreateAt = a.CreateAt,
- }).OrderBy(a => a.CreateAt, OrderByType.Desc)
+ }).OrderBy(a => a.CreateAt, OrderByType.Desc)
.Mapper(x =>
{
//var TechnologyInfo1 = _db.Queryable().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
- var TechnologyInfo = _db.Queryable().Where(d => d.TechnologyId == x.Id).ToList();
+ var TechnologyInfo = _db.Queryable().Where(d => d.TechnologyId == x.Id).OrderBy(d => d.Sort).ToList();
x.TechnologyActionInfo = TechnologyInfo;
})
.ToListAsync();
-
return data;
}
public async Task> GetTechnologyList_alm(string deviceId)
@@ -104,7 +103,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
.Mapper(x =>
{
//var TechnologyInfo1 = _db.Queryable().Where(p => p.DeviceVersionId == x.DeviceVersionId).Select(f => new TechnologyInfo() { Id = f.Id, Name = f.Name, DeviceVersionId = f.DeviceVersionId }).ToList();
- var TechnologyInfo = _db.Queryable().Where(d => d.TechnologyId == x.Id).ToList();
+ var TechnologyInfo = _db.Queryable().Where(d => d.TechnologyId == x.Id).OrderBy(d => d.Sort).ToList();
x.TechnologyActionInfo = TechnologyInfo;
})
.ToListAsync();
diff --git a/BPA.SAAS.Manage.Core/Device/BPA_DeviceLog.cs b/BPA.SAAS.Manage.Core/Device/BPA_DeviceLog.cs
new file mode 100644
index 0000000..ae46629
--- /dev/null
+++ b/BPA.SAAS.Manage.Core/Device/BPA_DeviceLog.cs
@@ -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
+{
+ ///
+ /// 设备日志表
+ ///
+ public class BPA_DeviceLog : IGroupId
+ {
+ public string Id { get; set; }
+ ///
+ /// 文件名称
+ ///
+ public string FileName { get; set; }
+ ///
+ /// 文件路径
+ ///
+ public string FileUrl { get; set; }
+ public DateTime CreateAt { get; set; }
+ public string CreateBy { get; set; }
+ ///
+ /// 加盟商id
+ ///
+ public string GroupId { get; set; }
+ }
+}