From 2640679b2823cd68d74e255442cce1634aac773c Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 10 十二月 2025 12:40:03 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/BaiBuLiKu
---
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 100 insertions(+), 13 deletions(-)
diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
index 3f05072..5757f64 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
+++ b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs
@@ -1,4 +1,6 @@
锘縰sing AngleSharp.Dom;
+using Magicodes.ExporterAndImporter.Core;
+using Magicodes.ExporterAndImporter.Excel;
using Mapster;
using Masuit.Tools;
using SqlSugar;
@@ -10,6 +12,8 @@
using WIDESEA_Cache;
using WIDESEA_Common;
using WIDESEA_Core;
+using WIDESEA_IStorageBasicService;
+using WIDESEA_Model.Models.BasicModel;
namespace WIDESEA_StorageBasicService;
@@ -18,10 +22,12 @@
private readonly ISimpleCacheService _simpleCacheService;
private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
- public StockInfoService(IStockInfoRepository BaseDal, ISimpleCacheService simpleCacheService, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository) : base(BaseDal)
+ private readonly IStockInfoDetailRepository _IStockInfoDetailRepository;
+ public StockInfoService(IStockInfoRepository BaseDal, ISimpleCacheService simpleCacheService, ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, IStockInfoDetailRepository stockInfoDetailService) : base(BaseDal)
{
_simpleCacheService = simpleCacheService;
_locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
+ _IStockInfoDetailRepository = stockInfoDetailService;
}
/// <summary>
@@ -60,6 +66,7 @@
Expression<Func<DtStockInfo, bool>> locationStatus = null;
Expression<Func<DtStockInfo, bool>> roadwayNo = null;
+ Expression<Func<DtStockInfo, bool>> materielCode = null;
foreach (var item in searchParametersList)
{
if (item.Name.Contains("locationStatus"))
@@ -70,20 +77,23 @@
{
roadwayNo = x => x.LocationInfo.RoadwayNo.Contains(item.Value);
}
+ else if (item.Name.Contains("materielCode"))
+ {
+ materielCode = x => x.StockInfoDetails.Any(d => d.MaterielCode.Contains(item.Value));
+ }
}
-
- var data = BaseDal.Db.Queryable<DtStockInfo>().IncludesAllFirstLayer().WhereIF(!wheres.IsNullOrEmpty(), wheres).WhereIF(locationStatus != null, locationStatus).WhereIF(roadwayNo != null, roadwayNo).OrderBy(orderByModels).ToPageList(options.Page, options.Rows, ref totalCount);
+ //.IncludesAllFirstLayer()
+ var data = BaseDal.Db.Queryable<DtStockInfo>()
+ .Includes(x => x.StockInfoDetails)
+ .Includes(x => x.LocationInfo)
+ .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ .WhereIF(locationStatus != null, locationStatus)
+ .WhereIF(roadwayNo != null, roadwayNo)
+ .WhereIF(materielCode != null, materielCode)
+ .OrderBy(orderByModels)
+ .ToPageList(options.Page, options.Rows, ref totalCount);
new PageGridData<DtStockInfo>(totalCount, data);
return new PageGridData<DtStockInfo>(totalCount, data);
- //var data = base.GetPageData(options);
- //foreach (var item in data.Rows)
- //{
- // if (item.IsFull)
- // item.Remark = item.StockInfoDetails.Count().ToString();
- // else
- // item.Remark = "0";
- //}
- //return data;
}
/// <summary>
@@ -115,7 +125,14 @@
_locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.ManualOperation, 0);
}
- _simpleCacheService.HashDel<DtStockInfo>(CacheConst.Cache_DtStockInfo, stocks.ToArray());
+ //_simpleCacheService.HashDel<DtStockInfo>(CacheConst.Cache_DtStockInfo, stocks.ToArray());
+ //var hty = BaseDal.Db.InsertNav(stockInfos)
+ // .Include(x => x.StockInfoDetails)
+ // .ExecuteCommand();
+
+ //var locationd = SqlSugarHelper.DbWMS.Updateable(locationInfos).ExecuteCommandHasChange();
+ //return base.DeleteData(keys);
+
var hty = BaseDal.Db.InsertNav(stockInfos)
.Include(x => x.StockInfoDetails)
.ExecuteCommand();
@@ -140,4 +157,74 @@
.ToDictionary(x => x.Key, x => x.Count());
return result;
}
+ public override WebResponseContent Export(PageDataOptions options)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ // 1. 鏋勫缓涓昏〃鏌ヨ鏉′欢鍜屾帓搴�
+ string wheres = ValidatePageOptions(options);
+ Dictionary<string, OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+
+ // 2. 鏌ヨ涓昏〃鏁版嵁
+ List<DtStockInfo> mainList = BaseDal.QueryData(wheres, orderbyDic);
+ if (!mainList.Any())
+ {
+ return WebResponseContent.Instance.OK("鏃犳暟鎹彲瀵煎嚭");
+ }
+
+ // 3. 鎵归噺鏌ヨ瀛愯〃鏁版嵁锛堥�氳繃涓昏〃Id鍏宠仈锛�
+ var mainIds = mainList.Select(m => m.Id).Distinct().ToList();
+ List<DtStockInfoDetail> detailList = _IStockInfoDetailRepository.Db
+ .Queryable<DtStockInfoDetail>()
+ .Where(d => mainIds.Contains(d.StockId))
+ .ToList();
+
+ // 4. 鍏宠仈涓昏〃鍜屽瓙琛ㄦ暟鎹紙鍙彇瀛愯〃绗竴鏉★級
+ var exportData = new List<PalletWithDetailExportModel>();
+ foreach (var main in mainList)
+ {
+ // 鍙彇褰撳墠涓昏〃鏁版嵁鍏宠仈鐨勫瓙琛ㄧ涓�鏉★紙鍙�氳繃OrderBy鎸囧畾鎺掑簭锛岀‘淇濆彇鍒版兂瑕佺殑绗竴鏉★級
+ var firstDetail = detailList
+ .Where(d => d.StockId == main.Id)
+ .OrderBy(d => d.Id) // 鍙�夛細鎸夊瓙琛↖d鎺掑簭锛岀‘淇濈粨鏋滅ǔ瀹氾紙鍙浛鎹负鍏朵粬瀛楁锛�
+ .FirstOrDefault();
+
+ var exportModel = new PalletWithDetailExportModel
+ {
+ Id = main.Id,
+ PalletCode = main.PalletCode,
+ LocationCode = main.LocationCode,
+ IsFull = main.IsFull,
+ Remark = main.Remark,
+ Creater = main.Creater,
+ CreateDate = main.CreateDate,
+ OutboundTime = (DateTime)main.OutboundTime,
+ // 鏈夊瓙琛ㄦ暟鎹垯鍙栫涓�鏉$殑鐗╂枡缂栫爜锛屾棤鍒欎负绌�
+ MaterielCode = firstDetail?.MaterielCode ?? ""
+ };
+ exportData.Add(exportModel);
+ }
+
+ // 5. 瀵煎嚭鏁版嵁锛堥�昏緫涓嶅彉锛�
+ string savePath = AppDomain.CurrentDomain.BaseDirectory + "ExcelExport";
+ IExporter exporter = new ExcelExporter();
+ byte[] data = exporter.ExportAsByteArray(exportData).Result;
+
+ string fileName = "鎵樼洏鍙婄墿鏂欑紪鐮佹暟鎹�.xlsx";
+ FileHelper.WriteFile(savePath, fileName, data);
+
+ content = WebResponseContent.Instance.OK(data: Path.Combine(savePath, fileName));
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ return content;
+ }
+
+ //public override WebResponseContent UpdateData(DtStockInfo entity)
+ //{
+ // return base.UpdateData(entity);
+ //}
}
\ No newline at end of file
--
Gitblit v1.9.3