From 3946fe3c23ff022b7e1d27c2a29041496ef6d529 Mon Sep 17 00:00:00 2001
From: payne <bzrlw2012@163.com>
Date: 周五, 26 4月 2024 10:10:43 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/iWare_RawMaterialWarehouse
---
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsPlace/WmsPlaceService.cs | 218 ++++++++++++++---------------------------------------
1 files changed, 59 insertions(+), 159 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 5d775ee..1239e93 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>
@@ -55,16 +57,7 @@
.Where(!string.IsNullOrEmpty(input.PlaceAlias), u => u.PlaceAlias == input.PlaceAlias)
.Where(input.PlaceType != null, u => u.PlaceType == input.PlaceType)
.Where(!string.IsNullOrEmpty(input.PlaceTypeName), u => u.PlaceTypeName == input.PlaceTypeName)
- .Where(!string.IsNullOrEmpty(input.StockUnit), u => u.StockUnit == input.StockUnit)
.Where(input.PlaceStatus != null, u => u.PlaceStatus == input.PlaceStatus)
- .Where(input.IsSrmPlace != null, u => u.IsSrmPlace == input.IsSrmPlace)
- .Where(!string.IsNullOrEmpty(input.SrmPlaceNo), u => u.SrmPlaceNo == input.SrmPlaceNo)
- .Where(input.IsRgvPlace != null, u => u.IsRgvPlace == input.IsRgvPlace)
- .Where(!string.IsNullOrEmpty(input.RgvPlaceNo), u => u.RgvPlaceNo == input.RgvPlaceNo)
- .Where(input.IsAgvPlace != null, u => u.IsAgvPlace == input.IsAgvPlace)
- .Where(!string.IsNullOrEmpty(input.AgvPlaceNo), u => u.AgvPlaceNo == input.AgvPlaceNo)
- .Where(input.IsTransPlace != null, u => u.IsTransPlace == input.IsTransPlace)
- .Where(!string.IsNullOrEmpty(input.TransPlaceNo), u => u.TransPlaceNo == input.TransPlaceNo)
.Where(input.IsActivateWCS != null, u => u.IsActivateWCS == input.IsActivateWCS)
.Where(!string.IsNullOrEmpty(input.Environment), u => u.Environment == input.Environment)
.Where(!string.IsNullOrEmpty(input.AreaCode), u => u.AreaCode == input.AreaCode)
@@ -109,16 +102,7 @@
var pPlaceAlias = input.PlaceAlias?.Trim() ?? "";
var pPlaceType = input.PlaceType;
var pPlaceTypeName = input.PlaceTypeName?.Trim() ?? "";
- var pStockUnit = input.StockUnit?.Trim() ?? "";
var pPlaceStatus = input.PlaceStatus;
- var pIsSrmPlace = input.IsSrmPlace;
- var pSrmPlaceNo = input.SrmPlaceNo?.Trim() ?? "";
- var pIsRgvPlace = input.IsRgvPlace;
- var pRgvPlaceNo = input.RgvPlaceNo?.Trim() ?? "";
- var pIsAgvPlace = input.IsAgvPlace;
- var pAgvPlaceNo = input.AgvPlaceNo?.Trim() ?? "";
- var pIsTransPlace = input.IsTransPlace;
- var pTransPlaceNo = input.TransPlaceNo?.Trim() ?? "";
var pIsActivateWCS = input.IsActivateWCS;
var pEnvironment = input.Environment?.Trim() ?? "";
var pAreaCode = input.AreaCode?.Trim() ?? "";
@@ -150,16 +134,7 @@
.Where(!string.IsNullOrEmpty(pPlaceAlias), u => u.PlaceAlias == pPlaceAlias)
.Where(pPlaceType != null, u => u.PlaceType == pPlaceType)
.Where(!string.IsNullOrEmpty(pPlaceTypeName), u => u.PlaceTypeName == pPlaceTypeName)
- .Where(!string.IsNullOrEmpty(pStockUnit), u => u.StockUnit == pStockUnit)
.Where(pPlaceStatus != null, u => u.PlaceStatus == pPlaceStatus)
- .Where(pIsSrmPlace != null, u => u.IsSrmPlace == pIsSrmPlace)
- .Where(!string.IsNullOrEmpty(pSrmPlaceNo), u => u.SrmPlaceNo == pSrmPlaceNo)
- .Where(pIsRgvPlace != null, u => u.IsRgvPlace == pIsRgvPlace)
- .Where(!string.IsNullOrEmpty(pRgvPlaceNo), u => u.RgvPlaceNo == pRgvPlaceNo)
- .Where(pIsAgvPlace != null, u => u.IsAgvPlace == pIsAgvPlace)
- .Where(!string.IsNullOrEmpty(pAgvPlaceNo), u => u.AgvPlaceNo == pAgvPlaceNo)
- .Where(pIsTransPlace != null, u => u.IsTransPlace == pIsTransPlace)
- .Where(!string.IsNullOrEmpty(pTransPlaceNo), u => u.TransPlaceNo == pTransPlaceNo)
.Where(pIsActivateWCS != null, u => u.IsActivateWCS == pIsActivateWCS)
.Where(!string.IsNullOrEmpty(pEnvironment), u => u.Environment == pEnvironment)
.Where(!string.IsNullOrEmpty(pAreaCode), u => u.AreaCode == pAreaCode)
@@ -224,7 +199,19 @@
public async Task Add(AddWmsPlaceInput input)
{
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);
wmsPlace.CreatedUserId = wmsPlace.UpdatedUserId = SysHelper.GetUserId();
@@ -258,6 +245,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);
@@ -326,7 +326,6 @@
var _PlaceAlias = "";//搴撲綅鍒悕
var _PlaceType = "";//搴撲綅绫诲瀷
var _PlaceTypeName = "";//搴撲綅绫诲瀷鍚嶇О
- var _StockUnit = "";//瀛樻斁鍗曚綅
var _PlaceStatus = "";//搴撲綅灞炴��
var _IsSrmPlace = "";//鏄惁鍫嗗灈鏈哄簱浣�
var _SrmPlaceNo = "";//鍫嗗灈鏈哄簱浣嶅彿
@@ -357,7 +356,6 @@
var _OutSequence = "";//鍑哄簱椤哄簭
var _IsVirtually = "";//鏄惁铏氭嫙
var _IsDisabled = "";//鏄惁绂佺敤
- var _Id = "";//Id涓婚敭
#endregion
@@ -366,21 +364,12 @@
_PlaceName = row["搴撲綅鍚嶇О"]?.ToString() ;
_PlaceAlias = row["搴撲綅鍒悕"]?.ToString() ;
_PlaceType = row["搴撲綅绫诲瀷"]?.ToString() ;
- _PlaceTypeName = row["搴撲綅绫诲瀷鍚嶇О"]?.ToString() ;
- _StockUnit = row["瀛樻斁鍗曚綅"]?.ToString() ;
_PlaceStatus = row["搴撲綅灞炴��"]?.ToString() ;
- _IsSrmPlace = row["鏄惁鍫嗗灈鏈哄簱浣�"]?.ToString() ;
- _SrmPlaceNo = row["鍫嗗灈鏈哄簱浣嶅彿"]?.ToString() ;
- _IsRgvPlace = row["鏄惁RGV搴撲綅"]?.ToString() ;
- _RgvPlaceNo = row["RGV搴撲綅鍙�"]?.ToString() ;
- _IsAgvPlace = row["鏄惁AGV搴撲綅"]?.ToString() ;
- _AgvPlaceNo = row["AGV搴撲綅鍙�"]?.ToString() ;
- _IsTransPlace = row["鏄惁杈撻�佺嚎搴撲綅"]?.ToString() ;
- _TransPlaceNo = row["杈撻�佺嚎搴撲綅鍙�"]?.ToString() ;
+
_IsActivateWCS = row["鏄惁婵�娲讳笌浠诲姟璋冨害"]?.ToString() ;
_Environment = row["搴撳瓨鐜"]?.ToString() ;
_AreaCode = row["搴撳尯缂栧彿"]?.ToString() ;
- _AreaId = row["鎵�鍦ㄥ簱鍖�"]?.ToString() ;
+ //_AreaId = row["鎵�鍦ㄥ簱鍖�"]?.ToString() ;
_AreaName = row["搴撳尯鍚嶇О"]?.ToString() ;
_VerificationCode = row["妫�楠岀爜"]?.ToString() ;
_RowNo = row["鎺�"]?.ToString() ;
@@ -398,7 +387,6 @@
_OutSequence = row["鍑哄簱椤哄簭"]?.ToString() ;
_IsVirtually = row["鏄惁铏氭嫙"]?.ToString() ;
_IsDisabled = row["鏄惁绂佺敤"]?.ToString() ;
- _Id = row["Id涓婚敭"]?.ToString() ;
#endregion
@@ -435,112 +423,49 @@
if(!string.IsNullOrEmpty(_PlaceType))
{
- if (!int.TryParse(_PlaceType, out int outPlaceType)&&!string.IsNullOrEmpty(_PlaceType))
+ Admin.NET.Core.PlaceTypeEnum enumPlaceType = default(Admin.NET.Core.PlaceTypeEnum);
+
+ if(!Enum.TryParse<Admin.NET.Core.PlaceTypeEnum>(_PlaceType, out enumPlaceType)&&!string.IsNullOrEmpty(_PlaceType))
{
- throw Oops.Oh($"绗瑊index}琛孾搴撲綅绫诲瀷]{_PlaceType}鍊间笉姝g‘锛�");
- }
- if (outPlaceType <= 0&&!string.IsNullOrEmpty(_PlaceType))
- {
- throw Oops.Oh($"绗瑊index}琛孾搴撲綅绫诲瀷]{_PlaceType}鍊间笉鑳藉皬浜庣瓑浜�0锛�");
+ throw Oops.Oh($"绗瑊index}琛孾搴撲綅绫诲瀷]{_PlaceType}鍊间笉姝g‘锛�");
}
else
{
- addItem.PlaceType = outPlaceType;
+ addItem.PlaceType = enumPlaceType;
}
+ }
+
+ if (string.IsNullOrEmpty(_PlaceTypeName))
+ {
+ throw Oops.Oh($"绗瑊index}琛孾搴撲綅绫诲瀷鍚嶇О]{_PlaceTypeName}涓嶈兘涓虹┖锛�");
}
+
if(!string.IsNullOrEmpty(_PlaceTypeName))
{
addItem.PlaceTypeName = (string)_PlaceTypeName;
}
- if(!string.IsNullOrEmpty(_StockUnit))
+
+ if (string.IsNullOrEmpty(_PlaceStatus))
{
- addItem.StockUnit = (string)_StockUnit;
- }
+ throw Oops.Oh($"绗瑊index}琛孾搴撲綅灞炴�{_PlaceStatus}涓嶈兘涓虹┖锛�");
+ }
+
if(!string.IsNullOrEmpty(_PlaceStatus))
{
- if (!int.TryParse(_PlaceStatus, out int outPlaceStatus)&&!string.IsNullOrEmpty(_PlaceStatus))
+ Admin.NET.Core.PlaceStatusEnum enumPlaceStatus = default(Admin.NET.Core.PlaceStatusEnum);
+
+ if(!Enum.TryParse<Admin.NET.Core.PlaceStatusEnum>(_PlaceStatus, out enumPlaceStatus)&&!string.IsNullOrEmpty(_PlaceStatus))
{
- throw Oops.Oh($"绗瑊index}琛孾搴撲綅灞炴�{_PlaceStatus}鍊间笉姝g‘锛�");
- }
- if (outPlaceStatus <= 0&&!string.IsNullOrEmpty(_PlaceStatus))
- {
- throw Oops.Oh($"绗瑊index}琛孾搴撲綅灞炴�{_PlaceStatus}鍊间笉鑳藉皬浜庣瓑浜�0锛�");
+ throw Oops.Oh($"绗瑊index}琛孾搴撲綅灞炴�{_PlaceStatus}鍊间笉姝g‘锛�");
}
else
{
- addItem.PlaceStatus = outPlaceStatus;
+ addItem.PlaceStatus = enumPlaceStatus;
}
- }
- if(!string.IsNullOrEmpty(_IsSrmPlace))
- {
- if(!_IsSrmPlace.Equals("鏄�") && !_IsSrmPlace.Equals("鍚�"))
- {
- throw Oops.Oh($"绗瑊index}琛孾鏄惁鍫嗗灈鏈哄簱浣峕{_IsSrmPlace}鍊间笉姝g‘锛�");
- }
- else
- {
- bool outIsSrmPlace = _IsSrmPlace.Equals("鏄�") ? true : false;
- addItem.IsSrmPlace = outIsSrmPlace;
- }
- }
-
- if(!string.IsNullOrEmpty(_SrmPlaceNo))
- {
- addItem.SrmPlaceNo = (string)_SrmPlaceNo;
}
- if(!string.IsNullOrEmpty(_IsRgvPlace))
- {
- if(!_IsRgvPlace.Equals("鏄�") && !_IsRgvPlace.Equals("鍚�"))
- {
- throw Oops.Oh($"绗瑊index}琛孾鏄惁RGV搴撲綅]{_IsRgvPlace}鍊间笉姝g‘锛�");
- }
- else
- {
- bool outIsRgvPlace = _IsRgvPlace.Equals("鏄�") ? true : false;
- addItem.IsRgvPlace = outIsRgvPlace;
- }
- }
-
- if(!string.IsNullOrEmpty(_RgvPlaceNo))
- {
- addItem.RgvPlaceNo = (string)_RgvPlaceNo;
- }
- if(!string.IsNullOrEmpty(_IsAgvPlace))
- {
- if(!_IsAgvPlace.Equals("鏄�") && !_IsAgvPlace.Equals("鍚�"))
- {
- throw Oops.Oh($"绗瑊index}琛孾鏄惁AGV搴撲綅]{_IsAgvPlace}鍊间笉姝g‘锛�");
- }
- else
- {
- bool outIsAgvPlace = _IsAgvPlace.Equals("鏄�") ? true : false;
- addItem.IsAgvPlace = outIsAgvPlace;
- }
- }
-
- if(!string.IsNullOrEmpty(_AgvPlaceNo))
- {
- addItem.AgvPlaceNo = (string)_AgvPlaceNo;
- }
- if(!string.IsNullOrEmpty(_IsTransPlace))
- {
- if(!_IsTransPlace.Equals("鏄�") && !_IsTransPlace.Equals("鍚�"))
- {
- throw Oops.Oh($"绗瑊index}琛孾鏄惁杈撻�佺嚎搴撲綅]{_IsTransPlace}鍊间笉姝g‘锛�");
- }
- else
- {
- bool outIsTransPlace = _IsTransPlace.Equals("鏄�") ? true : false;
- addItem.IsTransPlace = outIsTransPlace;
- }
- }
-
- if(!string.IsNullOrEmpty(_TransPlaceNo))
- {
- addItem.TransPlaceNo = (string)_TransPlaceNo;
- }
+
if(!string.IsNullOrEmpty(_IsActivateWCS))
{
if(!_IsActivateWCS.Equals("鏄�") && !_IsActivateWCS.Equals("鍚�"))
@@ -562,22 +487,13 @@
{
addItem.AreaCode = (string)_AreaCode;
}
- if(!string.IsNullOrEmpty(_AreaId))
- {
- if (!long.TryParse(_AreaId, out long outAreaId)&&!string.IsNullOrEmpty(_AreaId))
- {
- throw Oops.Oh($"绗瑊index}琛孾鎵�鍦ㄥ簱鍖篯{_AreaId}鍊间笉姝g‘锛�");
- }
- if (outAreaId <= 0&&!string.IsNullOrEmpty(_AreaId))
- {
- throw Oops.Oh($"绗瑊index}琛孾鎵�鍦ㄥ簱鍖篯{_AreaId}鍊间笉鑳藉皬浜庣瓑浜�0锛�");
- }
- else
- {
- addItem.AreaId = outAreaId;
- }
+ if (string.IsNullOrEmpty(_AreaId))
+ {
+ throw Oops.Oh($"绗瑊index}琛孾鎵�鍦ㄥ簱鍖篯{_AreaId}涓嶈兘涓虹┖锛�");
}
+
+
if(!string.IsNullOrEmpty(_AreaName))
{
addItem.AreaName = (string)_AreaName;
@@ -783,23 +699,7 @@
addItem.IsDisabled = outIsDisabled;
}
}
-
- if(!string.IsNullOrEmpty(_Id))
- {
- if (!long.TryParse(_Id, out long outId)&&!string.IsNullOrEmpty(_Id))
- {
- throw Oops.Oh($"绗瑊index}琛孾Id涓婚敭]{_Id}鍊间笉姝g‘锛�");
- }
- if (outId <= 0&&!string.IsNullOrEmpty(_Id))
- {
- throw Oops.Oh($"绗瑊index}琛孾Id涓婚敭]{_Id}鍊间笉鑳藉皬浜庣瓑浜�0锛�");
- }
- else
- {
- addItem.Id = outId;
- }
-
- }
+
#endregion
--
Gitblit v1.9.3