Sfoglia il codice sorgente

生成交货单修改

Pengxy 1 anno fa
parent
commit
b0e90c4615

+ 10 - 2
MicroServices/Business/Business.Application/ReplenishmentManagement/ReplenishmentAppService.cs

@@ -6865,6 +6865,11 @@ namespace Business.Replenishment
             List<PurOrdMaster> purOrdMasters = _PurOrdMaster.Select(p => p.Domain == domain && purOrds.Contains(p.PurOrd)).ToList();
             //获取占用可用PO明细的交货单
             List<srm_polist_ds> dbPolistds = _srmpolistds.Select(p => purOrds.Contains(p.ponumber) && p.isactive == 1).ToList();
+            //获取已完成的送货单子表数据
+            var purOrdNos = purOrds.JoinAsString("','");
+            var itemnumNos = itemnums.JoinAsString("','");
+            string sql = $"select  b.id,[po_billline],[jhdbh],isnull([shzt],'待收') shzt,[jhdhh] ,b.sh_material_code,b.sh_material_name,b.po_bill,b.sh_delivery_quantity from scm_shd a  left join scm_shdzb b on a.id=b.glid where po_bill in ('{purOrdNos}') and sh_material_code in ('{itemnumNos}') and jhdbh!='' and shzt='完成'";
+            var Endshdzbs = _businessDbContext.scm_shdzbDto.FromSqlRaw(sql).ToList();
 
             //过滤PO、DO:
             //1、PO只有采购组为110,160的采购订单能使用
@@ -7012,11 +7017,14 @@ namespace Business.Replenishment
                     sumRestQty = pchPurDtls.Sum(p => p.QtyOrded) - pchShds.Sum(p=>p.sh_delivery_quantity);
                     //交货单占用数量:交货单的剩余需要采购数量
                     var pchDbOccupys = curDbOccupys.Where(p => pchPurDtls.Select(m => m.PurOrd).Contains(p.ponumber)).ToList();
-                    sumDbOccupy = pchDbOccupys.Where(p=>p.status.ToUpper() == "C").Sum(p=>p.sentqty) + pchDbOccupys.Where(p => p.status.ToUpper() != "C").Sum(p => p.schedqty);
+                    //未关闭交货单需求数量和交货数量两者取最大值,避免交货单需求数量小于送货数量
+                    sumDbOccupy = pchDbOccupys.Where(p=>p.status.ToUpper() == "C").Sum(p=>p.sentqty) + pchDbOccupys.Where(p => p.status.ToUpper() != "C").Sum(p => (p.schedqty>= p.sentqty? p.schedqty: p.sentqty));
                     //本次计算交货单占用数量:本次计算交货单的需求数量
                     sumCurOccupy = curCalcOccupys.Where(p => pchPurDtls.Select(m => m.PurOrd).Contains(p.ponumber)).Sum(p => p.schedqty);
+                    //交货单已关闭,但已交数量和送货单送货数量不一致
+                    var shTotal= Endshdzbs.Where(p => pchDbOccupys.Where(m=>m.status.ToUpper() == "C" && m.sentqty==0).Select(m => m.dsnum).Contains(p.jhdbh)).Sum(p => p.sh_delivery_quantity);
                     //剩余可用数量
-                    restQty = sumRestQty - sumDbOccupy - sumCurOccupy;
+                    restQty = sumRestQty - sumDbOccupy - sumCurOccupy- shTotal;
                     restQty = restQty < 0 ? 0 : restQty;
                     if (restQty < needQty)
                     {

+ 65 - 0
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/scm_shdzbDto.cs

@@ -0,0 +1,65 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Domain
+{
+    /// <summary>
+    /// 收货单子表状态
+    /// </summary>
+    [Comment("收货单子表状态")]
+    [Keyless]
+    public class scm_shdzbDto
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Comment("主键")]
+        public long id { get; set; }
+
+        /// <summary>
+        /// 物料编码
+        /// </summary>
+        [Comment("物料编码")]
+        public string sh_material_code { get; set; }
+
+        /// <summary>
+        /// 采购单号
+        /// </summary>
+        [Comment("采购单号")]
+        public string po_bill { get; set; }
+
+        /// <summary>
+        /// 采购单行号
+        /// </summary>
+        [Comment("采购单行号")]
+        public string po_billline { get; set; }
+
+        /// <summary>
+        /// 送货数量
+        /// </summary>
+        [Comment("送货数量")]
+        public decimal sh_delivery_quantity { get; set; }
+
+        /// <summary>
+        /// 交货单号
+        /// </summary>
+        [Comment("交货单号")]
+        public string jhdbh { get; set; }
+
+        /// <summary>
+        /// 交货单行号
+        /// </summary>
+        [Comment("交货单行号")]
+        public string jhdhh { get; set; }
+
+        /// <summary>
+        /// 收货状态
+        /// </summary>
+        [Comment("收货状态")]
+        public string shzt { get; set; }
+    }
+}

+ 5 - 0
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/DOP/BusinessDbContext.cs

@@ -55,6 +55,11 @@ namespace Business.EntityFrameworkCore
         public DbSet<scm_shdzb> scm_shdzb { get; set; }
 
         /// <summary>
+        /// 冞億等赽桶袨怓
+        /// </summary>
+        public DbSet<scm_shdzbDto> scm_shdzbDto { get; set; }
+
+        /// <summary>
         /// 蝠億等祑都暮翹
         /// </summary>
         public DbSet<DeliveryExceptionMaster> DeliveryExceptionMaster { get; set; }

+ 13 - 0
MicroServices/Business/Business.Host/.config/dotnet-tools.json

@@ -0,0 +1,13 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "dotnet-ef": {
+      "version": "8.0.7",
+      "commands": [
+        "dotnet-ef"
+      ],
+      "rollForward": false
+    }
+  }
+}

+ 9 - 8
MicroServices/Business/Business.Host/Properties/launchSettings.json

@@ -1,12 +1,4 @@
 {
-  "iisSettings": {
-    "windowsAuthentication": false,
-    "anonymousAuthentication": true,
-    "iisExpress": {
-      "applicationUrl": "http://localhost:51186",
-      "sslPort": 0
-    }
-  },
   "profiles": {
     "IIS Express": {
       "commandName": "IISExpress",
@@ -16,10 +8,19 @@
     },
     "Business.Host": {
       "commandName": "Project",
+      "launchBrowser": true,
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       },
       "applicationUrl": "http://localhost:51186"
     }
+  },
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:51186",
+      "sslPort": 0
+    }
   }
 }