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