From b07472f884708a6bfdf63d999004bbf0bb5f00a8 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期一, 17 十一月 2025 17:12:57 +0800
Subject: [PATCH] 新增分单功能、二维码打印及物料供应商管理页面

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs |   80 +++++++++++++++++++++++++++++++++++----
 1 files changed, 71 insertions(+), 9 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
index 5eb0c40..6f50975 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/StockInfoService.cs"
@@ -23,6 +23,7 @@
 using WIDESEA_DTO.Stock;
 using WIDESEA_DTO.WMS;
 using WIDESEA_IOrderRepository;
+using WIDESEA_IOrderServices;
 using WIDESEA_Model.Models;
 using WIDESEA_Model.Models.Order;
 using WIDESEA_OrderRepository;
@@ -35,11 +36,13 @@
 {
     private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
     private readonly IDt_InboundOrderRepository _inboundOrderRepository;
+    private readonly IDt_InboundOrderService _inboundOrderService;
     private readonly IUnitOfWorkManage _unitOfWorkManage;
     private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
     private readonly IDt_TaskService _taskService;
     private readonly ILocationInfoRepository _locationRepository;
     private readonly IDt_TaskRepository _taskRepository;
+    private readonly IDt_Task_HtyRepository _task_HtyRepository;
     private readonly IDt_OrderOutDetailsRepository _outDetailsRepository;
 
     public StockInfoService(IStockInfoRepository BaseDal,
@@ -50,7 +53,9 @@
                                 IDt_TaskService taskService,
                                 ILocationInfoRepository locationRepository,
                                 IDt_TaskRepository taskRepository,
-                                IDt_OrderOutDetailsRepository outDetailsRepository) : base(BaseDal)
+                                IDt_OrderOutDetailsRepository outDetailsRepository,
+                                IDt_Task_HtyRepository task_HtyRepository,
+                                IDt_InboundOrderService inboundOrderService) : base(BaseDal)
     {
         _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository;
         _inboundOrderRepository = inboundOrderRepository;
@@ -60,6 +65,8 @@
         _locationRepository = locationRepository;
         _taskRepository = taskRepository;
         _outDetailsRepository = outDetailsRepository;
+        _task_HtyRepository = task_HtyRepository;
+        _inboundOrderService = inboundOrderService;
     }
     #region 鏂规硶閲嶅啓
     /// <summary>
@@ -445,6 +452,7 @@
         {
             var stocks = await _stockInfoDetailRepository.QueryDataAsync(x => true);
             var orderdetail = SqlSugarHelper.DbWMS.Queryable<Dt_OrderOutDetails_Hty>().Where(x => true).ToList();
+            var task = _taskRepository.QueryData(x => true).ToList();
 
             // 鑾峰彇UTC褰撳墠鏃堕棿
             DateTime utcNow = DateTime.UtcNow;
@@ -453,17 +461,33 @@
             DateTime firstDayOfMonth = new DateTime(utcNow.Year, utcNow.Month, 1);
             DateTime lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddSeconds(-1);
 
+            // 璁$畻涓婃湀鏃堕棿鑼冨洿
+            DateTime firstDayOfLastMonth = new DateTime(utcNow.Year, utcNow.Month, 1).AddMonths(-1);
+            DateTime lastDayOfLastMonth = firstDayOfLastMonth.AddMonths(1).AddSeconds(-1);
+
             // 璁$畻褰撳ぉ鏃堕棿鑼冨洿
             DateTime todayStart = utcNow.Date;
             DateTime todayEnd = todayStart.AddDays(1).AddTicks(-1);
+
+            // 璁$畻鏄ㄦ棩鏃堕棿鑼冨洿
+            DateTime startOfPreviousDay = utcNow.AddDays(-1).Date;  // 鍓嶄竴澶╃殑 00:00:00
+            DateTime endOfPreviousDay = startOfPreviousDay.AddDays(1).AddSeconds(-1);
 
             // 鏌ヨ褰撴湀鏁版嵁
             var currentMonthInStocks = stocks.Where(x => x.CreateDate >= firstDayOfMonth && x.CreateDate <= lastDayOfMonth).Sum(x => x.Quantity);
             var currentMonthOutStocks = orderdetail.Where(x => x.CreateDate >= firstDayOfMonth && x.CreateDate <= lastDayOfMonth).Sum(x => x.OutboundQuantity);
 
-            // 鏌ヨ褰撴棩鏁版嵁
+            //鏌ヨ涓婃湀鏁版嵁
+            var currentMonthInStocksLastMonth = stocks.Where(x => x.CreateDate >= firstDayOfLastMonth && x.CreateDate <= lastDayOfLastMonth).Sum(x => x.Quantity);
+            var currentMonthOutStocksLastMonth = orderdetail.Where(x => x.CreateDate >= firstDayOfLastMonth && x.CreateDate <= lastDayOfLastMonth).Sum(x => x.OutboundQuantity);
+
+            // 鏌ヨ浠婃棩鏁版嵁
             var currentDayInStocks = stocks.Where(x => x.CreateDate >= todayStart && x.CreateDate <= todayEnd).Sum(x => x.Quantity);
             var currentDayOutStocks = orderdetail.Where(x => x.CreateDate >= todayStart && x.CreateDate <= todayEnd).Sum(x => x.OutboundQuantity);
+
+            // 鏌ヨ鏄ㄥぉ鏃ユ暟鎹�
+            var currentDayInStocksLast = stocks.Where(x => x.CreateDate >= startOfPreviousDay && x.CreateDate <= endOfPreviousDay).Sum(x => x.Quantity);
+            var currentDayOutStocksLast = orderdetail.Where(x => x.CreateDate >= startOfPreviousDay && x.CreateDate <= endOfPreviousDay).Sum(x => x.OutboundQuantity);
 
             // 鐢熸垚鏈�杩�7澶╃殑鍑哄叆搴撴暟鎹�
             var last7Days = Enumerable.Range(0, 7)
@@ -479,7 +503,7 @@
             var inboundData = last7Days.Select(date => new
             {
                 Date = date.ToString("MM-dd"),
-                Value = stocks.Where(x => x.CreateDate.Date == date).Sum(x => x.Quantity)
+                Value = stocks.Where(x => x.CreateDate.Date == date).Sum(x => x.Quantity),
             }).ToList();
 
             var outboundData = last7Days.Select(date => new
@@ -500,19 +524,23 @@
                 metrics = new List<object>{
                 new {
                     name = "浠婃棩杩涘簱閲�",
-                    value = currentDayInStocks
+                    value = currentDayInStocks,
+                    compare =currentDayInStocks-currentDayInStocksLast,
                 },
                 new {
                     name = "浠婃棩鍑哄簱閲�",
-                    value = currentDayOutStocks
+                    value = currentDayOutStocks,
+                    compare =currentDayOutStocks-currentDayOutStocksLast,
                 },
                 new {
                     name = "鏈湀杩涘簱閲�",
-                    value = currentMonthInStocks
+                    value = currentMonthInStocks,
+                    compare =currentMonthInStocks-currentMonthInStocksLastMonth,
                 },
                 new {
                     name = "鏈湀鍑哄簱閲�",
-                    value = currentMonthOutStocks
+                    value = currentMonthOutStocks,
+                    compare = currentMonthOutStocks - currentMonthOutStocksLastMonth,
                 },
                 new {
                     name = "搴撳瓨鎬婚噺",
@@ -534,9 +562,19 @@
                     dates = MonthSumData.Select(x => x.Date).ToArray(),
                     inValue = MonthSumData.Select(x => x.InValue).ToArray(),
                     outValue = MonthSumData.Select(x => x.OutValue).ToArray(),
-                }
+                },
+                newTask = task.Select(x => new
+                {
+                    x.PalletCode,
+                    x.Roadway,
+                    x.SourceAddress,
+                    x.TargetAddress,
+                    x.ErrorMessage,
+                    x.CreateDate,
+                    TaskType = EnumHelper.GetDescriptionFromEnums(x.TaskType, typeof(TaskOutboundTypeEnum), typeof(TaskInboundTypeEnum), typeof(TaskAcrossFloorTypeEnum), typeof(TaskRelocationTypeEnum), typeof(TaskAGVCarryTypeEnum)),
+                    TaskState = EnumHelper.GetDescriptionFromEnums(x.TaskState, typeof(TaskInStatusEnum), typeof(TaskOutStatusEnum), typeof(TaskAcrossFloorStatusEnum), typeof(TaskRelocationStatusEnum), typeof(TaskAGVCarryStatusEnum))
+                }).ToList()
             };
-
             return content.OK(data: obj);
         }
         catch (Exception ex)
@@ -544,6 +582,30 @@
             return content.Error("绯荤粺閿欒锛岃鑱旂郴绠$悊鍛�");
         }
     }
+    #endregion
+
+    #region 鎵撳嵃搴撳瓨鍗曚釜鐗╂枡浜岀淮鐮�
+    public async Task<WebResponseContent> PrintOrder(object[] key)
+    {
+        WebResponseContent content = new WebResponseContent();
+        try
+        {
+            List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>();
+            foreach (var item in key)
+            {
+                var order = _inboundOrderRepository.QueryFirst(x => x.OrderNo == item.ToString());
+                if (order != null)
+                {
+                    inboundOrders.Add(order);
+                }
+            }
+            return _inboundOrderService.PrintInbound(inboundOrders); ; 
+        }
+        catch (Exception ex)
+        {
+            return content.Error("鏈煡閿欒锛岃鑱旂郴绠$悊鍛�");
+        }
+    }
 
     #endregion
 }
\ No newline at end of file

--
Gitblit v1.9.3