From ed9b0c0b150e295e9a5db053882019a3a64ec299 Mon Sep 17 00:00:00 2001
From: payne <bzrlw2012@163.com>
Date: 周四, 25 4月 2024 19:02:49 +0800
Subject: [PATCH] 库位页面修改

---
 iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs
index ea3153d..5ff149b 100644
--- a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs
+++ b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs
@@ -27,18 +27,20 @@
         private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep;
         private readonly ISysExcelTemplateService _sysExcelTemplateService;
         private readonly static object _lock = new();
-
+        private readonly IRepository<WmsArea, MasterDbContextLocator> _wmsAreaRep;
         public WmsPlaceService(
             IRepository<WmsPlace,MasterDbContextLocator> wmsPlaceRep
             ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep
             ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep
             ,ISysExcelTemplateService sysExcelTemplateService
+            , IRepository<WmsArea, MasterDbContextLocator> wmsAreaRep
         )
         {
             _wmsPlaceRep = wmsPlaceRep;
          _sysDictTypeRep = sysDictTypeRep;
          _sysDictDataRep = sysDictDataRep;
          _sysExcelTemplateService = sysExcelTemplateService;
+            _wmsAreaRep = wmsAreaRep;
         }
 
         /// <summary>
@@ -197,7 +199,21 @@
         public async Task Add(AddWmsPlaceInput input)
         {
             var wmsPlace = input.Adapt<WmsPlace>();
-                        //楠岃瘉
+            wmsPlace.PlaceCode =await SerialUtil.GetSerial(EnumSerialType.搴撲綅缂栧彿);
+
+            var area = (await _wmsAreaRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.AreaId&&u.IsDeleted==false)).Adapt<WmsAreaOutput>();
+            if (area == null)
+            {
+                throw Oops.Oh($"搴撳尯涓嶅瓨鍦�");
+            }
+            if (area.IsDisabled==true)
+            {
+                throw Oops.Oh($"搴撳尯宸茬鐢�");
+            }
+            wmsPlace.AreaName= area.AreaName;
+            wmsPlace.AreaCode= area.AreaCode;
+            wmsPlace.PlaceTypeName = wmsPlace.PlaceType.ToString();
+            //楠岃瘉
             await CheckExisit(wmsPlace);
 
             wmsPlace.CreatedUserId = wmsPlace.UpdatedUserId = SysHelper.GetUserId();
@@ -231,6 +247,19 @@
             if (!isExist) throw Oops.Oh(ErrorCode.D1002);
 
             var wmsPlace = input.Adapt<WmsPlace>();
+
+            var area = (await _wmsAreaRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.AreaId && u.IsDeleted == false)).Adapt<WmsAreaOutput>();
+            if (area == null)
+            {
+                throw Oops.Oh($"搴撳尯涓嶅瓨鍦�");
+            }
+            if (area.IsDisabled == true)
+            {
+                throw Oops.Oh($"搴撳尯宸茬鐢�");
+            }
+            wmsPlace.AreaName = area.AreaName;
+            wmsPlace.AreaCode = area.AreaCode;
+            wmsPlace.PlaceTypeName = wmsPlace.PlaceType.ToString();
             //楠岃瘉
             await CheckExisit(wmsPlace,true);
 

--
Gitblit v1.9.3