Browse Source

后厨优化接口相关排序和工艺保存bug处理20241111

kitchenmanage
gwbvipvip 1 month ago
parent
commit
e6298f7961
14 changed files with 217 additions and 13 deletions
  1. +11
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs
  2. +13
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceLogDto.cs
  3. +53
    -1
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs
  4. +7
    -0
      BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs
  5. +2
    -0
      BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs
  6. +8
    -6
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs
  7. +1
    -0
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs
  8. +11
    -0
      BPA.SAAS.Manage.Application/Device/DeviceServices.cs
  9. +18
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogDto.cs
  10. +16
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogQueryDto.cs
  11. +1
    -0
      BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs
  12. +40
    -0
      BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs
  13. +5
    -6
      BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs
  14. +31
    -0
      BPA.SAAS.Manage.Core/Device/BPA_DeviceLog.cs

+ 11
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/DeviceServices.cs View File

@@ -69,5 +69,16 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device
{
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);
}
}
}

+ 13
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Dtos/DeviceLogDto.cs View File

@@ -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; }
}
}

+ 53
- 1
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/DeviceService.cs View File

@@ -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<string>("baseurl");
public DeviceService(ICheckServices checkServices, AliyunOssClient aliyunOssClient)
{
_checkServices = checkServices;
_aliyunOssClient = aliyunOssClient;
}

/// <summary>
/// 分页查询
/// </summary>
@@ -194,5 +204,47 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
}
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
}
}

+ 7
- 0
BPA.SAAS.Manage.Application/AExternalPlatform/Service/Device/Services/IDeviceService.cs View File

@@ -45,5 +45,12 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Device.Services
/// <param name="dto"></param>
/// <returns></returns>
Task<List<DeviceTechnogolyDateDto>> GetDeviceTechnology(DeviceTechnogolyRequestDto dto);

/// <summary>
/// 上传设备日志
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
Task<List<ResponseMessageDto>> UploadDeviceLog(DeviceLogDto dto);
}
}

+ 2
- 0
BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsResultDto.cs View File

@@ -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; }
}



+ 8
- 6
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs View File

@@ -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 goodsList = await _db.Queryable<BPA_GoodsInfo>().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>();
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)


+ 1
- 0
BPA.SAAS.Manage.Application/DataBase/Services/GoodsTechnologyService.cs View File

@@ -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,


+ 11
- 0
BPA.SAAS.Manage.Application/Device/DeviceServices.cs View File

@@ -104,5 +104,16 @@ namespace BPA.SAAS.Manage.Application.Device
{
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);
}
}
}

+ 18
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogDto.cs View File

@@ -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; }
}
}

+ 16
- 0
BPA.SAAS.Manage.Application/Device/Dtos/Device/DeviceLogQueryDto.cs View File

@@ -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; }
}
}

+ 1
- 0
BPA.SAAS.Manage.Application/Device/Interface/IDeviceService.cs View File

@@ -22,5 +22,6 @@ namespace BPA.SAAS.Manage.Application.Device.Interface
Task<bool> AddDeviceTypeAsync(DeviceTypeBaseDto inputDto);
Task<List<ListSelectQuery>> GetDeviceTypeList();
Task<DeviceInfoQueryDto> GetDeviceInfoByDeviceId(string autoKey);
Task<PageUtil> GetDeviceLogPage(DeviceLogQueryDto dto);
}
}

+ 40
- 0
BPA.SAAS.Manage.Application/Device/Services/DeviceService.cs View File

@@ -270,5 +270,45 @@ namespace BPA.SAAS.Manage.Application.Device.Services
data.StopName = stopInfo.FirstOrDefault(a => a.Id == data.StopId)?.Name;
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;
}
}
}

+ 5
- 6
BPA.SAAS.Manage.Application/Device/Services/TechnologyService.cs View File

@@ -72,23 +72,22 @@ namespace BPA.SAAS.Manage.Application.Device.Services
/// <returns></returns>
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>();
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,
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<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;
})
.ToListAsync();

return data;
}
public async Task<List<TechnologyView>> GetTechnologyList_alm(string deviceId)
@@ -104,7 +103,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
.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 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;
})
.ToListAsync();


+ 31
- 0
BPA.SAAS.Manage.Core/Device/BPA_DeviceLog.cs View File

@@ -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; }
}
}

Loading…
Cancel
Save