parent
2a6f3b5623
commit
92f3b60bf0
@ -0,0 +1,29 @@
|
||||
namespace Entity.Api.Req;
|
||||
|
||||
public class AddEquipAlarmInfoReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备类型编码
|
||||
/// </summary>
|
||||
public int EquipTypeCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string EquipCode { get; set; }
|
||||
/// <summary>
|
||||
/// 报警编码
|
||||
/// </summary>
|
||||
public string ErrorCode { get; set; }
|
||||
/// <summary>
|
||||
/// 报警等级
|
||||
/// </summary>
|
||||
public string ErrorLevel { get; set; }
|
||||
/// <summary>
|
||||
/// 报警描述
|
||||
/// </summary>
|
||||
public string ErrorMsg { get; set; }
|
||||
/// <summary>
|
||||
/// 处理方法
|
||||
/// </summary>
|
||||
public string ProcessMethod { get; set; }
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Entity.DbModel.Station;
|
||||
|
||||
/// <summary>
|
||||
/// 系统运行时故障记录
|
||||
/// </summary>
|
||||
[SugarTable("sys_running_falut")]
|
||||
public class SysRunningFault: BaseModel
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 故障描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fault_describe")]
|
||||
public string? FaultDescribe { get; set; }
|
||||
/// <summary>
|
||||
/// 故障发生时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "falust_happen_time")]
|
||||
public DateTime? FalustHappenTime { get; set; }
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System.Linq.Expressions;
|
||||
using Entity.DbModel.Station;
|
||||
using HybirdFrameworkCore.Autofac.Attribute;
|
||||
using HybirdFrameworkCore.Entity;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace Repository.Station;
|
||||
|
||||
[Scope("SingleInstance")]
|
||||
public class SysRunningFaultRepository: BaseRepository<SysRunningFault>
|
||||
{
|
||||
public SysRunningFaultRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
using Entity.Api.Req;
|
||||
using Entity.Constant;
|
||||
using Entity.DbModel.Station;
|
||||
using HybirdFrameworkCore.Autofac.Attribute;
|
||||
using HybirdFrameworkCore.Entity;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
|
||||
using Repository.Station;
|
||||
|
||||
namespace Service.Station;
|
||||
|
||||
[Scope("SingleInstance")]
|
||||
public class EquipAlarmDefineService : BaseServices<EquipAlarmDefine>
|
||||
{
|
||||
EquipAlarmDefineRepository _equipAlarmDefineRepository;
|
||||
|
||||
public EquipAlarmDefineService(EquipAlarmDefineRepository dal)
|
||||
{
|
||||
_equipAlarmDefineRepository = dal;
|
||||
BaseDal = dal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加设备报警基础信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<string>> NewAddEquipAlarm(AddEquipAlarmInfoReq req)
|
||||
{
|
||||
var queryByClauseAsync = _equipAlarmDefineRepository.QueryByClauseAsync(
|
||||
i => i.EquipCode == req.EquipCode && i.ErrorCode == req.ErrorCode);
|
||||
var isExist = queryByClauseAsync.Result;
|
||||
if (isExist != null)
|
||||
{
|
||||
return Result<string>.Fail("已存在同名或同编码设备报警基础信息");
|
||||
}
|
||||
|
||||
_equipAlarmDefineRepository.InsertAsync(new EquipAlarmDefine()
|
||||
{
|
||||
EquipTypeCode = req.EquipTypeCode,
|
||||
EquipCode = req.EquipCode,
|
||||
ErrorCode = req.ErrorCode,
|
||||
ErrorLevel = req.ErrorLevel,
|
||||
ErrorMsg = req.ErrorMsg,
|
||||
ProcessMethod = req.ProcessMethod
|
||||
});
|
||||
return Result<string>.Success(req.EquipCode + "成功添加" + req.ErrorCode + "设备报警基础信息");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模糊查询
|
||||
/// </summary>
|
||||
/// <param name="keyValue">查询关键字</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Result<PageResult<EquipAlarmDefine>>> VagueQueryResult(int pageSize, string keyValue)
|
||||
{
|
||||
PageResult<EquipAlarmDefine> result = new PageResult<EquipAlarmDefine>();
|
||||
|
||||
var queryListByClauseAsync =
|
||||
_equipAlarmDefineRepository.QueryListByClauseAsync(!string.IsNullOrEmpty(keyValue)
|
||||
? i => i.ErrorMsg.Contains(keyValue)
|
||||
: null);
|
||||
var result1 = queryListByClauseAsync.Result;
|
||||
if (result1.Count > 0)
|
||||
{
|
||||
result.PageNum = result1.Count / pageSize;
|
||||
result.ToTal = result1.Count;
|
||||
result.Rows = result1;
|
||||
result.PageSize = pageSize;
|
||||
return Result<PageResult<EquipAlarmDefine>>.Success(result);
|
||||
}
|
||||
|
||||
return Result<PageResult<EquipAlarmDefine>>.Fail(result);
|
||||
}
|
||||
|
||||
public async Task<List<EquipAlarmDefine>> QueryAllEquipAlarm()
|
||||
{
|
||||
return await _equipAlarmDefineRepository.QueryListByClauseAsync(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
using Entity.Ammeter;
|
||||
using Entity.DbModel;
|
||||
using Entity.DbModel.Station;
|
||||
using HybirdFrameworkCore.Autofac.Attribute;
|
||||
using Repository.Ammeter;
|
||||
using Repository.Station;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Entity.Dto.Req;
|
||||
using Entity.Dto.Resp;
|
||||
using HybirdFrameworkCore.Entity;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Service.Station;
|
||||
|
||||
[Scope("SingleInstance")]
|
||||
public class SysRunningFaultService : BaseServices<SysRunningFault>
|
||||
{
|
||||
private SysRunningFaultRepository _sysRunningFaultRep;
|
||||
public SysRunningFaultService(SysRunningFaultRepository sysRunningFaultRep)
|
||||
{
|
||||
_sysRunningFaultRep = sysRunningFaultRep;
|
||||
this.BaseDal = sysRunningFaultRep;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取系统运行时故障信息
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PageResult<SysRunningFault>> Page(int pageSize)
|
||||
{
|
||||
PageResult<SysRunningFault> pageResult = new PageResult<SysRunningFault>();
|
||||
List<SysRunningFault> sysRunningFaultList = await _sysRunningFaultRep.QueryListByClauseAsync(i=>i.FaultDescribe!="");
|
||||
if (sysRunningFaultList.Count > 0)
|
||||
{
|
||||
pageResult.PageNum = sysRunningFaultList.Count/pageSize+1;
|
||||
pageResult.ToTal = sysRunningFaultList.Count;
|
||||
pageResult.Rows = sysRunningFaultList;
|
||||
}
|
||||
else
|
||||
{
|
||||
pageResult.PageNum = 0;
|
||||
pageResult.ToTal = 0;
|
||||
}
|
||||
pageResult.PageSize = pageSize;
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using Entity.DbModel.Station;
|
||||
using Entity.Dto.Req;
|
||||
using Entity.Dto.Resp;
|
||||
using HybirdFrameworkCore.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Service.Station;
|
||||
|
||||
namespace WebStarter.Controllers.Test;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class SysRunningFaultController
|
||||
{
|
||||
private readonly SysRunningFaultService _sysRunningFaultService;
|
||||
|
||||
public SysRunningFaultController(SysRunningFaultService sysRunningFaultService)
|
||||
{
|
||||
_sysRunningFaultService = sysRunningFaultService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询系统设备运行时故障
|
||||
/// </summary>
|
||||
/// <param name="inputPage">每页显示多少条</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("page")]
|
||||
public async Task<Result<PageResult<SysRunningFault>>> Page(int inputPage)
|
||||
{
|
||||
return Result<PageResult<SysRunningFault>>.Success(await _sysRunningFaultService.Page(inputPage));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue