From 6da579a7fe90780633813d0dcbef0d81846973da Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Tue, 12 Nov 2024 13:24:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8E=A8=E5=AF=BC=E5=85=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=95=86=E5=93=81=E6=8E=92=E5=BA=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=9620241112?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/Goods/GoodsTechnologyImportDto.cs | 3 ++- .../DataBase/Services/GoodsService.cs | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs index ef3df1c..5f62c7f 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsTechnologyImportDto.cs @@ -68,7 +68,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods public class GoodsChooseDto { public string GoodsName { get; set; } - public bool IsSkip { get;set; } + public bool IsSkip { get; set; } + public int AllGoodCount { get; set; } } public class GoodsImportDto diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs index b0ed86d..a970f94 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs @@ -101,8 +101,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services GoodsTypeName = b.IsDeleted == 0 ? b.Name : "", Descritption = a.Descritption, IsDeleted = a.IsDeleted, - - // CreateAt = a.CreateAt, + CreateAt = a.CreateAt, GoodsUintId = a.GoodsUintId, ForeignKeyRe = a.ForeignKeyRe, Design = a.Design, @@ -111,6 +110,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services IsAttrubute = a.IsAttrubute, Goodstechnology = SqlFunc.Subqueryable().Where(p => p.GoodsId == a.Id).WhereIF(!string.IsNullOrWhiteSpace(dto.DeviceId), p => p.DeviceId == dto.DeviceId).ToList(), }).ToListAsync(); + res = res.OrderByDescending(t => t.CreateAt).ThenBy(t => t.Id).ToList(); if (!string.IsNullOrWhiteSpace(dto.DeviceId)) { var goodsId = await _db.Queryable().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, 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() + CreateAt = goodsList.FirstOrDefault(t => t.Id == a.GoodsId)?.CreateAt + }).OrderByDescending(g => g.CreateAt).ThenBy(g => g.GoodsId).ToList() }); } foreach (var item in classifyDataList) @@ -1751,17 +1751,28 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services { var result = new List(); var goodsList = await _db.Queryable().ToListAsync(); - if(Path.GetExtension(dto.File.FileName) == ".zip") + var tempList = await _db.Queryable().Where(t => !string.IsNullOrWhiteSpace(t.TemplatePath)).Select(t => t.TemplatePath).ToListAsync(); + var fileNames = new List(); + 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); foreach (var entry in archive.Entries) { 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])) result.Add(new GoodsChooseDto { 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 { GoodsName = sheetNameList[0], - IsSkip = false + IsSkip = false, + AllGoodCount = 1 }); } }