From 1d4168d7ce939178c08ab991b4a107940bad0f58 Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Wed, 2 Aug 2023 13:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=BF=9D=E5=AD=98=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackingSystem/ServiceProjectService.cs | 10 ++++++---- .../TrackingSystem/StatusSkuBaseService.cs | 12 +++++++----- .../TrackingSystem/StatusTriggerBaseService.cs | 18 ++++++++++++++---- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs index 1bb66cf7..39fcd9b4 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceProjectService.cs @@ -62,7 +62,7 @@ namespace Myshipping.Application catch (Exception ex) { result.succ = false; - result.msg = $"保存服务项目异常,原因:{ex.Message}"; + result.msg = $"保存服务项目失败,原因:{ex.Message}"; } return result; @@ -103,7 +103,9 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(info.ServiceProjectCode)) { - if (_serviceProjectBaseInfoRepository.AsQueryable().Any(a => a.SERVICE_PROJECT_CODE.Equals(info.ServiceProjectCode) && a.PK_ID != info.PKId)) + string pkId = !string.IsNullOrWhiteSpace(info.PKId) ? info.PKId : string.Empty; + + if (_serviceProjectBaseInfoRepository.AsQueryable().Any(a => a.SERVICE_PROJECT_CODE.Equals(info.ServiceProjectCode) && a.PK_ID != pkId)) { _logger.LogInformation($"服务项目代码已存在不能重复保存"); @@ -207,13 +209,13 @@ namespace Myshipping.Application var id = await InnerSave(info,true); result.succ = true; - result.msg = "保存成功"; + result.msg = "保存并启用成功"; result.ext = id; } catch (Exception ex) { result.succ = false; - result.msg = $"保存并启用服务项目异常,原因:{ex.Message}"; + result.msg = $"保存并启用服务项目失败,原因:{ex.Message}"; } return result; diff --git a/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs b/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs index d366631f..7e3e767c 100644 --- a/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/StatusSkuBaseService.cs @@ -60,7 +60,7 @@ namespace Myshipping.Application catch (Exception ex) { result.succ = false; - result.msg = $"保存服务项目异常,原因:{ex.Message}"; + result.msg = $"保存服务状态失败,原因:{ex.Message}"; } return result; @@ -101,7 +101,9 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(info.StatusSKUCode)) { - if (_statusSkuBaseInfoRepository.AsQueryable().Any(a => a.STATUS_SKU_CODE.Equals(info.StatusSKUCode) && a.PK_ID != info.PKId)) + string pkId = !string.IsNullOrWhiteSpace(info.PKId) ? info.PKId : string.Empty; + + if (_statusSkuBaseInfoRepository.AsQueryable().Any(a => a.STATUS_SKU_CODE.Equals(info.StatusSKUCode) && a.PK_ID != pkId)) { _logger.LogInformation($"状态代码已存在不能重复保存"); @@ -217,13 +219,13 @@ namespace Myshipping.Application var id = await InnerSave(info, true); result.succ = true; - result.msg = "执行成功"; + result.msg = "保存并启用成功"; result.ext = id; } catch (Exception ex) { result.succ = false; - result.msg = $"保存并启用状态异常,原因:{ex.Message}"; + result.msg = $"保存并启用状态失败,原因:{ex.Message}"; } return result; @@ -313,7 +315,7 @@ namespace Myshipping.Application catch (Exception ex) { result.succ = false; - result.msg = $"执行状态异常,原因:{ex.Message}"; + result.msg = $"执行失败,原因:{ex.Message}"; } return result; diff --git a/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs index 0a1f277f..5530fec3 100644 --- a/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs +++ b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs @@ -62,7 +62,7 @@ namespace Myshipping.Application catch (Exception ex) { result.succ = false; - result.msg = $"保存触发器异常,原因:{ex.Message}"; + result.msg = $"保存触发器失败,原因:{ex.Message}"; } return result; @@ -83,13 +83,13 @@ namespace Myshipping.Application var id = await InnerSave(info, true); result.succ = true; - result.msg = "保存成功"; + result.msg = "保存并启用成功"; result.ext = id; } catch (Exception ex) { result.succ = false; - result.msg = $"保存触发器异常,原因:{ex.Message}"; + result.msg = $"保存并启用触发器失败,原因:{ex.Message}"; } return result; @@ -109,6 +109,11 @@ namespace Myshipping.Application if (isSetEnable) { + if (string.IsNullOrWhiteSpace(entity.STATUS_TRIGGER_CODE) || string.IsNullOrWhiteSpace(entity.STATUS_TRIGGER_NAME)) + { + throw Oops.Oh($"触发器代码或名称不能为空", typeof(InvalidOperationException)); + } + entity.IS_ENABLE = 1; } @@ -119,7 +124,9 @@ namespace Myshipping.Application if (string.IsNullOrWhiteSpace(info.StatusTriggerCode)) { - if (_statusTriggerBaseInfoRepository.AsQueryable().Any(a => a.STATUS_TRIGGER_CODE.Equals(info.StatusTriggerCode) && a.PK_ID != info.PKId)) + string pkId = !string.IsNullOrWhiteSpace(info.PKId) ? info.PKId : string.Empty; + + if (_statusTriggerBaseInfoRepository.AsQueryable().Any(a => a.STATUS_TRIGGER_CODE.Equals(info.StatusTriggerCode) && a.PK_ID != pkId)) { _logger.LogInformation($"服务流程触发器代码已存在不能重复保存"); @@ -356,6 +363,9 @@ namespace Myshipping.Application if (opTypeEnum == OperateTypeEnum.SetEnable) { + if (string.IsNullOrWhiteSpace(model.STATUS_TRIGGER_CODE) || string.IsNullOrWhiteSpace(model.STATUS_TRIGGER_NAME)) + throw Oops.Oh($"触发器代码或名称不能为空", typeof(InvalidOperationException)); + model.IS_ENABLE = 1; await _statusTriggerBaseInfoRepository.AsUpdateable(model).UpdateColumns(it => new