186 lines
7.4 KiB
C#
186 lines
7.4 KiB
C#
![]() |
using Abp.Authorization;
|
|||
|
using Abp.Domain.Repositories;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using ToolLibrary.LogHelper;
|
|||
|
using YunDa.ISAS.Application.Core;
|
|||
|
using YunDa.ISAS.Application.Core.Configuration;
|
|||
|
using YunDa.ISAS.Application.Core.Session;
|
|||
|
using YunDa.ISAS.Application.Core.SwaggerHelper;
|
|||
|
using YunDa.ISAS.DataTransferObject;
|
|||
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.ProtectionDeviceInfoDto.SearchCondition;
|
|||
|
using YunDa.SOMS.DataTransferObject.GeneralInformation.SecondaryCircuitDto;
|
|||
|
using YunDa.SOMS.Entities.GeneralInformation;
|
|||
|
|
|||
|
namespace YunDa.ISAS.Application.GeneralInformation.SecondaryCircuitInfo
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 二次回路逻辑表达式类
|
|||
|
/// </summary>
|
|||
|
public class SecondaryCircuitLogicExpressionAppService : ISASAppServiceBase, ISecondaryCircuitLogicExpressionAppService
|
|||
|
{
|
|||
|
private readonly IRepository<SecondaryCircuit, Guid> _secondaryCircuitRepository;
|
|||
|
private readonly IRepository<SecondaryCircuitLogicExpression, Guid> _secondaryCircuitLogicExpressionRepository;
|
|||
|
|
|||
|
|
|||
|
public SecondaryCircuitLogicExpressionAppService(ISessionAppService sessionAppService,
|
|||
|
IRepository<SecondaryCircuitLogicExpression, Guid> secondaryCircuitLogicExpressionRepository,
|
|||
|
IRepository<SecondaryCircuit, Guid> secondaryCircuitRepository,
|
|||
|
IAppServiceConfiguration appServiceConfiguration) : base(sessionAppService, appServiceConfiguration)
|
|||
|
{
|
|||
|
_secondaryCircuitLogicExpressionRepository = secondaryCircuitLogicExpressionRepository;
|
|||
|
_secondaryCircuitRepository = secondaryCircuitRepository;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 添加或者修改二次回路的逻辑表达式
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
[ShowApi]
|
|||
|
[AbpAllowAnonymous]
|
|||
|
public async Task<RequestResult<SecondaryCircuitLogicExpressionOutput>> CreateOrUpdateAsync(EditSecondaryCircuitLogicExpressionInput input)
|
|||
|
{
|
|||
|
RequestResult<SecondaryCircuitLogicExpressionOutput> result = new RequestResult<SecondaryCircuitLogicExpressionOutput>();
|
|||
|
try
|
|||
|
{
|
|||
|
SecondaryCircuitLogicExpression entity;
|
|||
|
if (input.Id.HasValue)
|
|||
|
{
|
|||
|
// 更新逻辑
|
|||
|
entity = await _secondaryCircuitLogicExpressionRepository.FirstOrDefaultAsync(input.Id.Value);
|
|||
|
if (entity == null)
|
|||
|
{
|
|||
|
result.Message = "未找到该逻辑表达式记录";
|
|||
|
result.Flag = false;
|
|||
|
return result;
|
|||
|
}
|
|||
|
ObjectMapper.Map(input, entity);
|
|||
|
entity.LastModificationTime = DateTime.Now;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 新建逻辑
|
|||
|
entity = ObjectMapper.Map<SecondaryCircuitLogicExpression>(input);
|
|||
|
entity.CreationTime = DateTime.Now;
|
|||
|
await _secondaryCircuitLogicExpressionRepository.InsertAsync(entity);
|
|||
|
}
|
|||
|
|
|||
|
result.ResultData = null;// ObjectMapper.Map<SecondaryCircuitLogicExpressionOutput>(entity);
|
|||
|
result.Flag = true;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
result.Message = ex.Message;
|
|||
|
result.Flag = false;
|
|||
|
Log4Helper.Error(this.GetType(), "CreateOrUpdate逻辑表达式", ex);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
[ShowApi]
|
|||
|
[AbpAllowAnonymous]
|
|||
|
public async Task<RequestEasyResult> DeleteByIdAsync(Guid id)
|
|||
|
{
|
|||
|
RequestEasyResult result = new RequestEasyResult();
|
|||
|
try
|
|||
|
{
|
|||
|
await _secondaryCircuitLogicExpressionRepository.DeleteAsync(id);
|
|||
|
result.Flag = true;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
result.Message = ex.Message;
|
|||
|
result.Flag = false;
|
|||
|
Log4Helper.Error(this.GetType(), "DeleteById逻辑表达式", ex);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 删除逻辑表达式
|
|||
|
/// </summary>
|
|||
|
/// <param name="ids"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
[ShowApi]
|
|||
|
[AbpAllowAnonymous]
|
|||
|
public async Task<RequestEasyResult> DeleteByIdsAsync(List<Guid> ids)
|
|||
|
{
|
|||
|
RequestEasyResult result = new RequestEasyResult();
|
|||
|
try
|
|||
|
{
|
|||
|
foreach (var id in ids)
|
|||
|
{
|
|||
|
await _secondaryCircuitLogicExpressionRepository.DeleteAsync(id);
|
|||
|
}
|
|||
|
result.Flag = true;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
result.Message = ex.Message;
|
|||
|
result.Flag = false;
|
|||
|
Log4Helper.Error(this.GetType(), "DeleteByIds逻辑表达式", ex);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 查询逻辑表达式
|
|||
|
/// </summary>
|
|||
|
/// <param name="searchCondition"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
[ShowApi]
|
|||
|
[AbpAllowAnonymous]
|
|||
|
public RequestPageResult<SecondaryCircuitLogicExpressionOutput> FindDatas(PageSearchCondition<SecondaryCircuitLogicExpressionSearchConditionInput> searchCondition)
|
|||
|
{
|
|||
|
RequestPageResult<SecondaryCircuitLogicExpressionOutput> result = new RequestPageResult<SecondaryCircuitLogicExpressionOutput>();
|
|||
|
try
|
|||
|
{
|
|||
|
var query = _secondaryCircuitLogicExpressionRepository.GetAllIncluding(x => x.TelemeteringConfiguration, x => x.TelesignalisationConfiguration);
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(searchCondition.SearchCondition.Name))
|
|||
|
{
|
|||
|
query = query.Where(x => x.Name.Contains(searchCondition.SearchCondition.Name));
|
|||
|
}
|
|||
|
if (searchCondition.SearchCondition.SecondaryCircuitId.HasValue)
|
|||
|
{
|
|||
|
query = query.Where(x => x.SecondaryCircuitId == searchCondition.SearchCondition.SecondaryCircuitId.Value);
|
|||
|
}
|
|||
|
if (searchCondition.SearchCondition.IsOnlyActive.HasValue)
|
|||
|
{
|
|||
|
query = query.Where(x => x.IsActive == searchCondition.SearchCondition.IsOnlyActive.Value);
|
|||
|
}
|
|||
|
|
|||
|
result.TotalCount = query.Count();
|
|||
|
|
|||
|
var data = new List<SecondaryCircuitLogicExpression>();
|
|||
|
if (searchCondition.PageSize > 0)
|
|||
|
{
|
|||
|
data = query.Skip((searchCondition.PageIndex - 1) * searchCondition.PageSize)
|
|||
|
.Take(searchCondition.PageSize)
|
|||
|
.ToList();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
data = query.ToList();
|
|||
|
}
|
|||
|
result.ResultData = ObjectMapper.Map<List<SecondaryCircuitLogicExpressionOutput>>(data);
|
|||
|
result.Flag = true;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
result.Message = ex.Message;
|
|||
|
result.Flag = false;
|
|||
|
Log4Helper.Error(this.GetType(), "FindDatas逻辑表达式", ex);
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|