You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.5 KiB

using AutoMapper;
6 months ago
using Entity.Api.Req;
using Entity.DbModel.Station;
using Entity.Dto;
6 months ago
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Utils;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc;
6 months ago
using Repository.Station;
using SqlSugar;
6 months ago
namespace Service.Station;
[Scope]
public class EquipAlarmRecordService : BaseServices<EquipAlarmRecord>
{
public EquipAlarmProcessRecordRepository ProcessRecordRepository { get; set; }
public EquipAlarmRecordService(EquipAlarmRecordRepository dal)
{
BaseDal = dal;
}
/// <summary>
/// 查询未处理报警列表
/// </summary>
/// <param name="typeCode">设备类型:-1-查询全部0-充电机1-电表2-水冷机3-plc<</param>
/// <param name="equipCode">设备编码</param>
/// <returns></returns>
public Result<PageResult<EquipAlarmRecord>> QueryEquipAlarmPage(QueryAlarmReq req)
{
int totalCount = 0;
int reqTypeCode = req.TypeCode;
var equipCode = req.EquipCode;
var errorLevel = req.ErrorLevel;
List<EquipAlarmRecord> list = BaseDal.Queryable()
.WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode)
6 months ago
.WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode)
.WhereIF(ObjUtils.IsNotNullOrWhiteSpace(errorLevel), it => it.ErrorLevel == errorLevel)
4 months ago
.WhereIF(req.StartTime.HasValue && req.ProcessTime.HasValue,
it => it.StartTime >= req.StartTime && it.StartTime <= req.ProcessTime)
.OrderBy(it => it.CreatedTime, OrderByType.Desc)
6 months ago
.ToPageList(req.PageNum, req.PageSize, ref totalCount);
PageResult<EquipAlarmRecord> result = new PageResult<EquipAlarmRecord>()
{
PageNum = req.PageNum,
PageSize = req.PageSize,
ToTal = totalCount,
Rows = list
};
return Result<PageResult<EquipAlarmRecord>>.Success(result);
}
6 months ago
/// <summary>
/// 查询已处理报警列表
/// </summary>
/// <param name="typeCode">设备类型:-1-查询全部0-充电机1-电表2-水冷机3-plc</param>
/// <param name="equipCode">设备编码</param>
/// <returns></returns>
public Result<PageResult<EquipAlarmProcessRecord>> QueryEquipAlarmProcessPage(QueryAlarmReq req)
{
int totalCount = 0;
int reqTypeCode = req.TypeCode;
var equipCode = req.EquipCode;
var errorLevel = req.ErrorLevel;
List<EquipAlarmProcessRecord> list = ProcessRecordRepository.Queryable()
.WhereIF(reqTypeCode != -1, it => it.EquipTypeCode == reqTypeCode)
6 months ago
.WhereIF(ObjUtils.IsNotNullOrWhiteSpace(equipCode), it => it.EquipCode == equipCode)
.WhereIF(ObjUtils.IsNotNullOrWhiteSpace(errorLevel), it => it.ErrorLevel == errorLevel)
.WhereIF(req.StartTime.HasValue && req.ProcessTime.HasValue,
it => it.StartTime >= req.StartTime && it.ProcessTime <= req.ProcessTime)
.OrderBy(it => it.CreatedTime, OrderByType.Desc)
6 months ago
.ToPageList(req.PageNum, req.PageSize, ref totalCount);
PageResult<EquipAlarmProcessRecord> result = new PageResult<EquipAlarmProcessRecord>()
{
PageNum = req.PageNum,
PageSize = req.PageSize,
ToTal = totalCount,
Rows = list
};
return Result<PageResult<EquipAlarmProcessRecord>>.Success(result);
}
6 months ago
}