Browse Source

后厨导入优化,商品排序优化20241112

kitchenmanage
gwbvipvip 1 month ago
parent
commit
6da579a7fe
2 changed files with 21 additions and 8 deletions
  1. +2
    -1
      BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs
  2. +19
    -7
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs

+ 2
- 1
BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs View File

@@ -68,7 +68,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods
public class GoodsChooseDto public class GoodsChooseDto
{ {
public string GoodsName { get; set; } public string GoodsName { get; set; }
public bool IsSkip { get;set; }
public bool IsSkip { get; set; }
public int AllGoodCount { get; set; }
} }


public class GoodsImportDto public class GoodsImportDto


+ 19
- 7
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs View File

@@ -101,8 +101,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
GoodsTypeName = b.IsDeleted == 0 ? b.Name : "", GoodsTypeName = b.IsDeleted == 0 ? b.Name : "",
Descritption = a.Descritption, Descritption = a.Descritption,
IsDeleted = a.IsDeleted, IsDeleted = a.IsDeleted,

// CreateAt = a.CreateAt,
CreateAt = a.CreateAt,
GoodsUintId = a.GoodsUintId, GoodsUintId = a.GoodsUintId,
ForeignKeyRe = a.ForeignKeyRe, ForeignKeyRe = a.ForeignKeyRe,
Design = a.Design, Design = a.Design,
@@ -111,6 +110,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
IsAttrubute = a.IsAttrubute, IsAttrubute = a.IsAttrubute,
Goodstechnology = SqlFunc.Subqueryable<BPA_GoodsTechnologyAction>().Where(p => p.GoodsId == a.Id).WhereIF(!string.IsNullOrWhiteSpace(dto.DeviceId), p => p.DeviceId == dto.DeviceId).ToList(), Goodstechnology = SqlFunc.Subqueryable<BPA_GoodsTechnologyAction>().Where(p => p.GoodsId == a.Id).WhereIF(!string.IsNullOrWhiteSpace(dto.DeviceId), p => p.DeviceId == dto.DeviceId).ToList(),
}).ToListAsync(); }).ToListAsync();
res = res.OrderByDescending(t => t.CreateAt).ThenBy(t => t.Id).ToList();
if (!string.IsNullOrWhiteSpace(dto.DeviceId)) if (!string.IsNullOrWhiteSpace(dto.DeviceId))
{ {
var goodsId = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => t.DeviceId == dto.DeviceId).Select(q => q.GoodsId).Distinct().ToListAsync(); var goodsId = await _db.Queryable<BPA_GoodsTechnologyAction>().Where(t => t.DeviceId == dto.DeviceId).Select(q => q.GoodsId).Distinct().ToListAsync();
@@ -242,8 +242,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
GoodsId = a.GoodsId, GoodsId = a.GoodsId,
GoodsName = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.Name, GoodsName = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.Name,
ImgUrl = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.ImgUrl, ImgUrl = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.ImgUrl,
CreateAt = goodsList.FirstOrDefault(t=>t.Id == a.GoodsId)?.CreateAt
}).OrderByDescending(g => g.CreateAt).ToList()
CreateAt = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.CreateAt
}).OrderByDescending(g => g.CreateAt).ThenBy(g => g.GoodsId).ToList()
}); });
} }
foreach (var item in classifyDataList) foreach (var item in classifyDataList)
@@ -1751,17 +1751,28 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
{ {
var result = new List<GoodsChooseDto>(); var result = new List<GoodsChooseDto>();
var goodsList = await _db.Queryable<BPA_GoodsInfo>().ToListAsync(); var goodsList = await _db.Queryable<BPA_GoodsInfo>().ToListAsync();
if(Path.GetExtension(dto.File.FileName) == ".zip")
var tempList = await _db.Queryable<BPA_TechnologyExportRecode>().Where(t => !string.IsNullOrWhiteSpace(t.TemplatePath)).Select(t => t.TemplatePath).ToListAsync();
var fileNames = new List<string>();
foreach (var temp in tempList)
{
var uri = new Uri(temp);
string fileName = Path.GetFileName(uri.LocalPath);
fileNames.Add(fileName);
}
if (Path.GetExtension(dto.File.FileName) == ".zip")
{ {
using var archive = new ZipArchive(dto.File.OpenReadStream(), ZipArchiveMode.Read); using var archive = new ZipArchive(dto.File.OpenReadStream(), ZipArchiveMode.Read);
foreach (var entry in archive.Entries) foreach (var entry in archive.Entries)
{ {
var sheetNameList = GetSheetNameList(entry.Open()); var sheetNameList = GetSheetNameList(entry.Open());
var fileNameList = archive.Entries.Select(a => a.Name).ToList();
var intersectingFiles = fileNames.Intersect(fileNameList);
if (goodsList.Any(t => t.Name == sheetNameList[0])) if (goodsList.Any(t => t.Name == sheetNameList[0]))
result.Add(new GoodsChooseDto result.Add(new GoodsChooseDto
{ {
GoodsName = sheetNameList[0], GoodsName = sheetNameList[0],
IsSkip = false
IsSkip = false,
AllGoodCount = intersectingFiles.Any() ? fileNameList.Count() - 1 : fileNameList.Count()
}); });
} }
} }
@@ -1775,7 +1786,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services
result.Add(new GoodsChooseDto result.Add(new GoodsChooseDto
{ {
GoodsName = sheetNameList[0], GoodsName = sheetNameList[0],
IsSkip = false
IsSkip = false,
AllGoodCount = 1
}); });
} }
} }


Loading…
Cancel
Save