From d1feb3ca73935d14dfa5d96548d682e875aa2443 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期二, 13 五月 2025 14:22:34 +0800
Subject: [PATCH] 预警更新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs |   72 ++++++++++++++++++++++++++++++++---
 1 files changed, 65 insertions(+), 7 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
index 8d1ef05..a608a7f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
@@ -7,9 +7,11 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using System.Dynamic;
 using System.Globalization;
 using System.Linq;
 using System.Linq.Expressions;
+using System.Reflection;
 using System.Reflection.Metadata;
 using System.Text;
 using System.Threading.Tasks;
@@ -73,6 +75,39 @@
             _invokeERPService = invokeERPService;
             _warehouseService = warehouseService;
             _palletTypeInfoRepository = palletTypeInfoRepository;
+        }
+        public override object GetDetailPage(PageDataOptions pageData)
+        {
+            Type t = typeof(Dt_InboundOrder);
+
+            if (pageData.Value == null) return new PageGridData<object>(total: 0, null);
+            string keyName = t.GetKeyName();
+            ////鐢熸垚鏌ヨ鏉′欢
+            //Expression<Func<TEntity, bool>> whereExpression = keyName.CreateExpression<TEntity>(pageData.Value, LinqExpressionType.Equal);
+            int totalCount = 0;
+            PropertyInfo propertyInfo = t.GetProperties().FirstOrDefault(x => x.GetCustomAttribute<Navigate>() != null);
+            if (propertyInfo != null)
+            {
+                Type detailType = propertyInfo.PropertyType.GetGenericArguments()[0];
+                Navigate navigate = propertyInfo.GetCustomAttribute<Navigate>();
+                List<Dt_InboundOrderDetail> list = BaseDal.Db.Queryable<Dt_InboundOrderDetail>().Where(navigate.GetName(), "=", pageData.Value).ToPageList(pageData.Page, pageData.Rows, ref totalCount);
+                decimal sum = 0;
+                list.ForEach(x =>
+                {
+                    sum += Convert.ToDecimal(x.OrderQuantity);
+                });
+                PageGridData<Dt_InboundOrderDetail> pageGridData = new PageGridData<Dt_InboundOrderDetail>()
+                {
+                    Total= totalCount,
+                    Rows=list,
+                    Summary=new
+                    {
+                        OrderQuantity = Math.Round(sum, 3),
+                    }
+                };
+                return pageGridData;
+            }
+            return new PageGridData<object>(total: 0, null);
         }
         /// <summary>
         /// 鍏朵粬鍏ュ簱鍗曟帴鏀�(璋冩嫈鍏ヤ粨,瀹緵鍥炴敹,鐗╂枡閿�鍞��璐�)
@@ -240,11 +275,11 @@
                 List<Dt_InboundOrder> dt_ReceiveOrders = new List<Dt_InboundOrder>();
                 if (string.IsNullOrEmpty(orderNo))
                 {
-                    dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5);
+                    dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderStatus < InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x=>x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10);
                 }
                 else
                 {
-                    dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 5);
+                    dt_ReceiveOrders = Db.Queryable<Dt_InboundOrder>().Where(x => (x.InboundOrderNo.Contains(orderNo)) && x.OrderStatus < InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).Includes(x => x.Details).OrderByDescending(x => x.CreateDate).ToPageList(pageNo, 10);
                 }
 
                 content.OK(data: dt_ReceiveOrders);
@@ -829,6 +864,10 @@
                     stockInfoDetails.Add(stockInfoDetail);
 
                     notGroupDetail.ReceiptQuantity += model.Quantity;
+                    if (notGroupDetail.ReceiptQuantity>notGroupDetail.OrderQuantity)
+                    {
+                        return WebResponseContent.Instance.Error($"缁勭洏鏁伴噺婧㈠嚭{notGroupDetail.ReceiptQuantity - notGroupDetail.OrderQuantity}");
+                    }
                     if (notGroupDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
                     {
                         notGroupDetail.OrderDetailStatus = OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
@@ -1292,6 +1331,8 @@
             try
             {
                 List<ERPProItemsItem> proItemsItems = new List<ERPProItemsItem>();
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseId==mesProInOrder.WarehouseId);
+                string batchNoRemark = "";
                 foreach (var item in mesProInOrder.Details)
                 {
                     ERPProItemsItem proItemsItem = new ERPProItemsItem()
@@ -1299,7 +1340,7 @@
                         PartNum = item.ProductCode,
                         Rev=item.ProductVersion,
                         DateCode=item.DateCode,
-                        BatchNumber= item.BagNo,
+                        BatchNumber= item.ProductCode,
                         XLocation=item.XSite,
                         Xqty=item.XQty,
                         QtySet=item.SETQty,
@@ -1315,6 +1356,7 @@
                             }
                         }
                     };
+                    batchNoRemark += item.BagNo + ",";
                     proItemsItems.Add(proItemsItem);
                 }
                 ERPProInboundModel proInboundModel = new ERPProInboundModel()
@@ -1324,13 +1366,20 @@
                     CreatorCode = "GSWMS",
                     CompanyCode = "HATC",
                     FactoryCode = "HA02",
-                    WarehouseCode = "HA71",
-                    LocationCode = "HA71",
+                    WarehouseCode = warehouse.WarehouseCode,
+                    LocationCode = warehouse.WarehouseCode,
                     StockDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                     StockFormType= "Production",
-                    StockFormItems= proItemsItems
+                    StockFormItems= proItemsItems,
+                    Remark=batchNoRemark
                 };
-                _invokeERPService.InvokeProInApi(proInboundModel);
+                string response = _invokeERPService.InvokeProInApi(proInboundModel);
+                ErpRequestContent requestContent = response.DeserializeObject<ErpRequestContent>();
+                if (requestContent.res != 1)
+                {
+                    return content.Error($"{requestContent.Data}");
+                }
+                content.OK();
             }
             catch (Exception ex)
             {
@@ -1521,6 +1570,15 @@
                 }
                 return palletTypeInfo.PalletType;
             }
+            else if (warehouse.WarehouseCode == WarehouseEnum.HA58.ObjToString())
+            {
+                Dt_PalletTypeInfo palletTypeInfo = _palletTypeInfoRepository.QueryFirst(x => x.CodeStartStr == palletCode.Substring(0, 2));
+                if (palletTypeInfo == null)
+                {
+                    throw new Exception($"鎵樼洏鍙烽敊璇�");
+                }
+                return palletTypeInfo.PalletType;
+            }
             return -1;
         }
         /// <summary>

--
Gitblit v1.9.3