|
@@ -100,24 +100,24 @@ namespace WingDeviceService.Service
|
|
|
//检查设备编码不为空
|
|
|
if (string.IsNullOrWhiteSpace(request.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
if (userCodes == null || userCodes.Count <= 0)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserCodeEmptyError, "Required parameter:UserCodes cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserCodeEmptyError, "Required parameter:UserCodes cannot be empty");
|
|
|
}
|
|
|
//查询设备对象
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(deviceCode);
|
|
|
if (deviceDb == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
foreach (var userCode in userCodes)
|
|
|
{
|
|
|
var existUser = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (existUser == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -144,7 +144,7 @@ namespace WingDeviceService.Service
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
|
|
|
if (deviceDb == null || deviceDb.DeviceCode != request.DeviceCode)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
//根据机构编号查询机构名称
|
|
|
var organizationName = "";
|
|
@@ -198,7 +198,7 @@ namespace WingDeviceService.Service
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(request.ShortCode);
|
|
|
if (deviceDb == null || deviceDb.ShortCode != request.ShortCode)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
return await MapToExtendDTO(deviceDb);
|
|
|
}
|
|
@@ -216,18 +216,18 @@ namespace WingDeviceService.Service
|
|
|
//检查设备编码不为空
|
|
|
if (string.IsNullOrWhiteSpace(request.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
//用户编码集合检查
|
|
|
if (userCodes == null || userCodes.Count <= 0)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserCodeEmptyError, "Required parameter:UserCodes cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserCodeEmptyError, "Required parameter:UserCodes cannot be empty");
|
|
|
}
|
|
|
//查询设备对象
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(deviceCode);
|
|
|
if (deviceDb == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
var updateUsers = new List<TableDataItem<UserPasswordDTO>>();
|
|
|
foreach (var userCode in userCodes)
|
|
@@ -316,12 +316,12 @@ namespace WingDeviceService.Service
|
|
|
var userInfoDO = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (userInfoDO == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
}
|
|
|
//查询用户的医院是否存在
|
|
|
if (string.IsNullOrWhiteSpace(userInfoDO.OrganizationCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
}
|
|
|
var deviceInfoDOList = new List<DeviceInfoDTO>();
|
|
|
if (!userInfoDO.IsDirector)
|
|
@@ -383,7 +383,7 @@ namespace WingDeviceService.Service
|
|
|
var userInfoDO = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (userInfoDO == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
}
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(request.ShortCode);
|
|
|
if (deviceDb == null)
|
|
@@ -392,7 +392,7 @@ namespace WingDeviceService.Service
|
|
|
}
|
|
|
if (userInfoDO.BindDevices != null && userInfoDO.BindDevices.Contains(deviceDb.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.HasAddedDevice, "The device has been Added");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.HasAddedDevice, "The device has been Added");
|
|
|
}
|
|
|
try
|
|
|
{
|
|
@@ -609,13 +609,13 @@ namespace WingDeviceService.Service
|
|
|
var userInfoDO = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (userInfoDO == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
}
|
|
|
var result = new List<SelectItemDTO>();
|
|
|
//查询用户的医院是否存在
|
|
|
if (string.IsNullOrEmpty(userInfoDO.OrganizationCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
}
|
|
|
//查询用户绑定的设备
|
|
|
if (userInfoDO.BindDevices == null || userInfoDO.BindDevices.Count <= 0)
|
|
@@ -645,7 +645,7 @@ namespace WingDeviceService.Service
|
|
|
var deviceInfo = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(deviceCode);
|
|
|
if (deviceInfo == null || string.IsNullOrWhiteSpace(deviceInfo.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
var org = new OrganizationDTO();
|
|
|
if (!string.IsNullOrWhiteSpace(deviceInfo.OrganizationCode))
|
|
@@ -676,32 +676,32 @@ namespace WingDeviceService.Service
|
|
|
var userCode = await ValidateTokenAsync(request.Token);
|
|
|
if (string.IsNullOrEmpty(shortCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UniqueCodeIsEmpty, "UniqueCode is empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UniqueCodeIsEmpty, "UniqueCode is empty");
|
|
|
}
|
|
|
var device = await _deviceInfoDBServiceProxy.FindDeviceInfoByShortCodeAsync(shortCode);
|
|
|
if (device == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
var oldOrg = await _organizationDBService.GetOrganizationDetailAsync(new GetOrganizationDBRequest { OrganizationCode = device.OrganizationCode });
|
|
|
if (oldOrg == null || string.IsNullOrWhiteSpace(oldOrg.OrganizationCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
}
|
|
|
//用户
|
|
|
var userDTO = await _userServiceProxy.FindUserByCodeAsync(userCode);
|
|
|
if (userDTO == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.UserNotExistError, "User does not exist");
|
|
|
}
|
|
|
if (!userDTO.IsDirector)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NotOrgAdmin, "not org admin");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NotOrgAdmin, "not org admin");
|
|
|
}
|
|
|
var org = await _organizationDBService.GetOrganizationDetailAsync(new GetOrganizationDBRequest { OrganizationCode = userDTO.OrganizationCode });
|
|
|
if (org == null || string.IsNullOrWhiteSpace(org.OrganizationCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.OrganizationNotExist, "Org does not exist");
|
|
|
}
|
|
|
#endregion
|
|
|
try
|
|
@@ -829,13 +829,13 @@ namespace WingDeviceService.Service
|
|
|
//检查设备编码不为空
|
|
|
if (string.IsNullOrWhiteSpace(request.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
//查询设备对象
|
|
|
var deviceDb = await _deviceInfoDBServiceProxy.FindDeviceInfoByCodeAsync(request.DeviceCode);
|
|
|
if (deviceDb == null)
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.NoExistDevice, "Device does not exist");
|
|
|
}
|
|
|
var userListResult = await _userServiceProxy.GetUsersByDeviceAsync(request.DeviceCode);
|
|
|
if (userListResult != null && userListResult.Count > 0)
|
|
@@ -856,7 +856,7 @@ namespace WingDeviceService.Service
|
|
|
//检查设备编码不为空
|
|
|
if (string.IsNullOrWhiteSpace(request.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
return await _diagnosisModuleService.GetDeviceDiagnosisModulesAsync(new GetDeviceDiagnosisModulesDBRequest { DeviceCode = request.DeviceCode });
|
|
|
}
|
|
@@ -873,11 +873,11 @@ namespace WingDeviceService.Service
|
|
|
//检查设备编码不为空
|
|
|
if (string.IsNullOrWhiteSpace(request.DeviceCode))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceCodeIsEmpty, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
if (string.IsNullOrWhiteSpace(request.DiagnosisModule))
|
|
|
{
|
|
|
- throw new CustomerRpcCodeException(CustomerRpcCode.DeviceAIDiagnosisModule, "Required parameter:DeviceCode cannot be empty");
|
|
|
+ ThrowCustomerException(CustomerRpcCode.DeviceAIDiagnosisModule, "Required parameter:DeviceCode cannot be empty");
|
|
|
}
|
|
|
var result = await _diagnosisModuleService.UpdateDeviceDiagnosisModuleStateAsync(new UpdateDeviceDiagnosisModuleStateDBRequest
|
|
|
{
|
|
@@ -888,6 +888,16 @@ namespace WingDeviceService.Service
|
|
|
CacheMaintenance.Instance.Get<IDeviceInfosManager>().Remove(request.DeviceCode);
|
|
|
return result;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 通用异常处理方法
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="customerRpcCodeEnum">异常标识码</param>
|
|
|
+ /// <param name="msg">异常信息</param>
|
|
|
+ /// <param name="internalMessage">内部异常信息,非必填</param>
|
|
|
+ private void ThrowCustomerException(CustomerRpcCode customerRpcCodeEnum, string msg, string internalMessage = null)
|
|
|
+ {
|
|
|
+ ThrowRpcException((int)customerRpcCodeEnum, msg, internalMessage);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|