diff --git a/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 b/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2
index 337b8f7..8d504d8 100644
Binary files a/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 and b/PVDEMCS/.vs/PVDEMCS/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/PVDEMCS/.vs/PVDEMCS/v17/.suo b/PVDEMCS/.vs/PVDEMCS/v17/.suo
index 1f312e2..1263ec6 100644
Binary files a/PVDEMCS/.vs/PVDEMCS/v17/.suo and b/PVDEMCS/.vs/PVDEMCS/v17/.suo differ
diff --git a/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs b/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
index 15cc11b..20feb91 100644
--- a/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
+++ b/PVDEMCS/PVDEMCS/Controllers/EquipmentRecordController.cs
@@ -126,6 +126,34 @@ namespace PVDEMCS.Controllers
return result;
}
+ ///
+ /// 获取设备状态记录统计分页列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ /// 当前页
+ /// 页大小
+ [HttpGet]
+ public Result> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, int page, int size = 20)
+ {
+ var result = _equipmentRecordService.GetEquipmentRecordTotalPageList(equipmentName, equipmentCode, equipmentType, page, size);
+ return result;
+ }
+
+ ///
+ /// 获取设备状态记录统计列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ [HttpGet]
+ public Result> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType)
+ {
+ var result = _equipmentRecordService.GetEquipmentRecordTotalList(equipmentName, equipmentCode, equipmentType);
+ return result;
+ }
+
///
/// 获取设备总览
///
@@ -207,6 +235,28 @@ namespace PVDEMCS.Controllers
return new Result>(alarmList);
}
+ ///
+ /// 获取设备状态记录月统计
+ ///
+ ///
+ [HttpGet]
+ public Result> GetEquipmentRecordStateMonthTotal()
+ {
+ var result = _equipmentRecordService.GetEquipmentRecordStateMonthTotal();
+ return result;
+ }
+
+ ///
+ /// 获取设备记录开炉次数月统计
+ ///
+ ///
+ [HttpGet]
+ public Result> GetEquipmentRecordFurnaceMonthTotal()
+ {
+ var result = _equipmentRecordService.GetEquipmentRecordFurnaceMonthTotal();
+ return result;
+ }
+
#endregion
}
diff --git a/PVDEMCS/PVDEMCS/Services/IEquipmentRecordService.cs b/PVDEMCS/PVDEMCS/Services/IEquipmentRecordService.cs
index dba9901..4f05728 100644
--- a/PVDEMCS/PVDEMCS/Services/IEquipmentRecordService.cs
+++ b/PVDEMCS/PVDEMCS/Services/IEquipmentRecordService.cs
@@ -80,6 +80,36 @@ namespace PVDEMCS.Services
/// 结束时间
Result> GetEquipmentRecordDayTotalList(string equipmentName, string equipmentCode, string equipmentType, DateTime begTime, DateTime endTime);
+ ///
+ /// 获取设备状态记录统计分页列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ /// 当前页
+ /// 页大小
+ Result> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, int page, int size);
+
+ ///
+ /// 获取设备状态记录统计列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ Result> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType);
+
+ ///
+ /// 获取设备状态记录月统计
+ ///
+ ///
+ Result> GetEquipmentRecordStateMonthTotal();
+
+ ///
+ /// 获取设备记录开炉次数月统计
+ ///
+ ///
+ Result> GetEquipmentRecordFurnaceMonthTotal();
+
#endregion
}
}
diff --git a/PVDEMCS/PVDEMCS/Services/Impl/EquipmentRecordService.cs b/PVDEMCS/PVDEMCS/Services/Impl/EquipmentRecordService.cs
index 4b4830d..fca796d 100644
--- a/PVDEMCS/PVDEMCS/Services/Impl/EquipmentRecordService.cs
+++ b/PVDEMCS/PVDEMCS/Services/Impl/EquipmentRecordService.cs
@@ -61,7 +61,6 @@ namespace PVDEMCS.Services.Impl
///
/// 设备Id
/// 设备状态,运行:Run,待机:Stop,报警:Alarm
- /// 设备Id
///
public Result AddUpdateEquipmentRecord(string equipmentId, string state, DateTime dateTime)
{
@@ -114,6 +113,52 @@ namespace PVDEMCS.Services.Impl
return result;
}
+ ///
+ /// 获取设备状态记录统计分页列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ /// 当前页
+ /// 页大小
+ public Result> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, int page, int size)
+ {
+ var result = this._equipmentRecordRepository.GetEquipmentRecordTotalPageList(equipmentName, equipmentCode, equipmentType, page, size);
+ return result;
+ }
+
+ ///
+ /// 获取设备状态记录统计列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ public Result> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType)
+ {
+ var result = this._equipmentRecordRepository.GetEquipmentRecordTotalList(equipmentName, equipmentCode, equipmentType);
+ return result;
+ }
+
+ ///
+ /// 获取设备状态记录月统计
+ ///
+ ///
+ public Result> GetEquipmentRecordStateMonthTotal()
+ {
+ var result = this._equipmentRecordRepository.GetEquipmentRecordStateMonthTotal();
+ return result;
+ }
+
+ ///
+ /// 获取设备记录开炉次数月统计
+ ///
+ ///
+ public Result> GetEquipmentRecordFurnaceMonthTotal()
+ {
+ var result = this._equipmentRecordRepository.GetEquipmentRecordFurnaceMonthTotal();
+ return result;
+ }
+
#endregion
}
}
diff --git a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordDayTotal.cs b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordDayTotal.cs
index 5fd740f..f35abad 100644
--- a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordDayTotal.cs
+++ b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordDayTotal.cs
@@ -8,50 +8,8 @@ namespace PVDEMCS.Services.Models;
/// 设备状态记录日统计
///
///
-public partial class EquipmentRecordDayTotal
+public partial class EquipmentRecordDayTotal: EquipmentRecordTotal
{
- public string Id { get; set; }
-
- ///
- /// 设备Id
- ///
- public string EquipmentId { get; set; }
-
- ///
- /// 设备编码
- ///
- public string EquipmentCode { get; set; }
-
- ///
- /// 设备名称
- ///
- public string EquipmentName { get; set; }
-
- ///
- /// 设备类型:Ionbond,Balzers,Cemecon
- ///
- public string EquipmentType { get; set; }
-
- ///
- /// 开炉次数
- ///
- public int FurnaceNum { get; set; }
-
- ///
- /// 总运行时长
- ///
- public decimal TotalRunningTime { get; set; }
-
- ///
- /// 总报警时长
- ///
- public decimal TotalAlarmTime { get; set; }
-
- ///
- /// 总待机时长
- ///
- public decimal TotalStopTime { get; set; }
-
///
/// 日期
///
diff --git a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordFurnaceMonthTotal.cs b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordFurnaceMonthTotal.cs
index 5c064c1..4fa973e 100644
--- a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordFurnaceMonthTotal.cs
+++ b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordFurnaceMonthTotal.cs
@@ -18,6 +18,6 @@
///
/// 日期
///
- public DateTime? TotalMonth { get; set; }
+ public string TotalMonth { get; set; }
}
}
diff --git a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordStateMonthTotal.cs b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordStateMonthTotal.cs
index 9eaea42..30382d4 100644
--- a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordStateMonthTotal.cs
+++ b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordStateMonthTotal.cs
@@ -23,6 +23,6 @@
///
/// 日期
///
- public DateTime? TotalMonth { get; set; }
+ public string TotalMonth { get; set; }
}
}
diff --git a/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordTotal.cs b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordTotal.cs
new file mode 100644
index 0000000..23b541a
--- /dev/null
+++ b/PVDEMCS/PVDEMCS/Services/Models/EquipmentRecordTotal.cs
@@ -0,0 +1,56 @@
+
+using System;
+using System.Collections.Generic;
+
+namespace PVDEMCS.Services.Models;
+
+///
+/// 设备状态记录统计
+///
+///
+public partial class EquipmentRecordTotal
+{
+ public string Id { get; set; }
+
+ ///
+ /// 设备Id
+ ///
+ public string EquipmentId { get; set; }
+
+ ///
+ /// 设备编码
+ ///
+ public string EquipmentCode { get; set; }
+
+ ///
+ /// 设备名称
+ ///
+ public string EquipmentName { get; set; }
+
+ ///
+ /// 设备类型:Ionbond,Balzers,Cemecon
+ ///
+ public string EquipmentType { get; set; }
+
+ ///
+ /// 开炉次数
+ ///
+ public int FurnaceNum { get; set; }
+
+ ///
+ /// 总运行时长
+ ///
+ public decimal TotalRunningTime { get; set; }
+
+ ///
+ /// 总报警时长
+ ///
+ public decimal TotalAlarmTime { get; set; }
+
+ ///
+ /// 总待机时长
+ ///
+ public decimal TotalStopTime { get; set; }
+
+
+}
\ No newline at end of file
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EFContext.cs b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EFContext.cs
index e5e4602..046cc46 100644
--- a/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EFContext.cs
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EFContext.cs
@@ -30,6 +30,8 @@ public partial class EFContext : DbContext
public virtual DbSet EquipmentRecords { get; set; }
+ public virtual DbSet EquipmentRecordDayTotals { get; set; }
+
public virtual DbSet EquipmentRecordTotals { get; set; }
public virtual DbSet SysConfigs { get; set; }
@@ -129,18 +131,18 @@ public partial class EFContext : DbContext
entity.Property(e => e.CreateAt).HasComment("创建时间");
entity.Property(e => e.CreateBy).HasComment("创建者");
entity.Property(e => e.EndTime).HasComment("设备名称");
- entity.Property(e => e.EquipmentId).HasComment("设备类型:Ionbond,Balzers,Cemecon");
+ entity.Property(e => e.EquipmentId).HasComment("设备id");
entity.Property(e => e.StartTime).HasComment("设备编码");
entity.Property(e => e.State).HasComment("设备状态,1:运行,2:待机,3:报警");
entity.Property(e => e.UpdateAt).HasComment("修改时间");
entity.Property(e => e.UpdateBy).HasComment("修改者");
});
- modelBuilder.Entity(entity =>
+ modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
- entity.ToTable("equipment_record_total", tb => tb.HasComment("设备状态记录日统计\r\n"));
+ entity.ToTable("equipment_record_day_total", tb => tb.HasComment("设备状态记录日统计\r\n"));
entity.Property(e => e.CreateAt).HasComment("创建时间");
entity.Property(e => e.CreateBy).HasComment("创建者");
@@ -154,6 +156,23 @@ public partial class EFContext : DbContext
entity.Property(e => e.UpdateBy).HasComment("修改者");
});
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id).HasName("PRIMARY");
+
+ entity.ToTable("equipment_record_total", tb => tb.HasComment("设备状态记录统计\r\n"));
+
+ entity.Property(e => e.CreateAt).HasComment("创建时间");
+ entity.Property(e => e.CreateBy).HasComment("创建者");
+ entity.Property(e => e.EquipmentId).HasComment("设备Id");
+ entity.Property(e => e.FurnaceNum).HasComment("开炉次数");
+ entity.Property(e => e.TotalAlarmTime).HasComment("总报警时长");
+ entity.Property(e => e.TotalStopTime).HasComment("总待机时长");
+ entity.Property(e => e.TotalRunningTime).HasComment("总运行时长");
+ entity.Property(e => e.UpdateAt).HasComment("修改时间");
+ entity.Property(e => e.UpdateBy).HasComment("修改者");
+ });
+
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("PRIMARY");
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordDayTotalEntity.cs b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordDayTotalEntity.cs
new file mode 100644
index 0000000..85a7c0c
--- /dev/null
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordDayTotalEntity.cs
@@ -0,0 +1,60 @@
+// This file has been auto generated by EF Core Power Tools.
+#nullable disable
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using PVDEMCS.Services.Repositories.Entities.BaseEntity;
+
+namespace PVDEMCS.Services.Repositories.Entities;
+
+
+///
+/// 设备状态记录日统计
+///
+///
+[Table("equipment_record_day_total")]
+public partial class EquipmentRecordDayTotalEntity : CUBaseEntity
+{
+ ///
+ /// 设备Id
+ ///
+ [Required]
+ [Column("equipment_id")]
+ [StringLength(32)]
+ public string EquipmentId { get; set; }
+
+ ///
+ /// 开炉次数
+ ///
+ [Column("furnace_num")]
+ public int FurnaceNum { get; set; }
+
+ ///
+ /// 总运行时长
+ ///
+ [Column("total_running_time")]
+ [Precision(32, 2)]
+ public decimal TotalRunningTime { get; set; }
+
+ ///
+ /// 总报警时长
+ ///
+ [Column("total_alarm_time")]
+ [Precision(32, 2)]
+ public decimal TotalAlarmTime { get; set; }
+
+ ///
+ /// 总待机时长
+ ///
+ [Column("total_stop_time")]
+ [Precision(32, 2)]
+ public decimal TotalStopTime { get; set; }
+ ///
+ /// 日期
+ ///
+ [Column("total_day", TypeName = "datetime")]
+ public DateTime? TotalDay { get; set; }
+
+}
\ No newline at end of file
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordTotalEntity.cs b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordTotalEntity.cs
index ce35b5f..53d9dc9 100644
--- a/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordTotalEntity.cs
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/Entities/EquipmentRecordTotalEntity.cs
@@ -53,10 +53,4 @@ public partial class EquipmentRecordTotalEntity : CUBaseEntity
[Precision(32, 2)]
public decimal TotalStopTime { get; set; }
- ///
- /// 日期
- ///
- [Column("total_day", TypeName = "datetime")]
- public DateTime? TotalDay { get; set; }
-
}
\ No newline at end of file
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/IEquipmentRecordRepository.cs b/PVDEMCS/PVDEMCS/Services/Repositories/IEquipmentRecordRepository.cs
index 8fdc435..b89e8f7 100644
--- a/PVDEMCS/PVDEMCS/Services/Repositories/IEquipmentRecordRepository.cs
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/IEquipmentRecordRepository.cs
@@ -5,6 +5,7 @@ using PVDEMCS.Common;
using PVDEMCS.Common.DI;
using PVDEMCS.Services.Models;
using PVDEMCS.Services.Repositories.Entities;
+using Microsoft.EntityFrameworkCore;
namespace PVDEMCS.Services.Repositories
{
@@ -74,7 +75,7 @@ namespace PVDEMCS.Services.Repositories
Result> GetEquipmentRecordDayTotalPageList(string equipmentName, string equipmentCode, string equipmentType, DateTime begTime, DateTime endTime, int page, int size);
///
- /// 获取设备状态记录统计列表
+ /// 获取设备状态记录日统计列表
///
/// 设备名称
/// 设备编号
@@ -83,7 +84,35 @@ namespace PVDEMCS.Services.Repositories
/// 结束时间
Result> GetEquipmentRecordDayTotalList(string equipmentName, string equipmentCode, string equipmentType, DateTime begTime, DateTime endTime);
-
+ ///
+ /// 获取设备状态记录统计分页列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ /// 当前页
+ /// 页大小
+ Result> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, int page, int size);
+
+ ///
+ /// 获取设备状态记录统计列表
+ ///
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ Result> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType);
+
+ ///
+ /// 获取设备状态记录月统计
+ ///
+ ///
+ Result> GetEquipmentRecordStateMonthTotal();
+
+ ///
+ /// 获取设备记录开炉次数月统计
+ ///
+ ///
+ Result> GetEquipmentRecordFurnaceMonthTotal();
#endregion
}
diff --git a/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs b/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
index 40b781a..73ad16f 100644
--- a/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
+++ b/PVDEMCS/PVDEMCS/Services/Repositories/Impl/EquipmentRecordRepository.cs
@@ -1,11 +1,13 @@
using AngleSharp.Css.Values;
using Masuit.Tools;
using Masuit.Tools.Models;
+using Microsoft.EntityFrameworkCore;
using PVDEMCS.Common;
using PVDEMCS.Common.Constant;
using PVDEMCS.Common.DI;
using PVDEMCS.Services.Models;
using PVDEMCS.Services.Repositories.Entities;
+using System.Text.RegularExpressions;
namespace PVDEMCS.Services.Repositories.Impl
{
@@ -195,7 +197,7 @@ namespace PVDEMCS.Services.Repositories.Impl
}
//
var furnaceList = (from q in query
- join e in context.EquipmentInfos.Where(f=>!f.IsDelete) on q.EquipmentId equals e.Id
+ join e in context.EquipmentInfos.Where(f => !f.IsDelete) on q.EquipmentId equals e.Id
where q.State == EquipmentState.Run
select new
{
@@ -244,7 +246,7 @@ namespace PVDEMCS.Services.Repositories.Impl
}
}
//记录统计时间
- var list = context.EquipmentRecordTotals.Where(f => f.TotalDay == begDate).ToList();
+ var list = context.EquipmentRecordDayTotals.Where(f => f.TotalDay == begDate).ToList();
//有记录
foreach (var item in list)
{
@@ -274,7 +276,7 @@ namespace PVDEMCS.Services.Repositories.Impl
foreach (var equipmentId in notRecords.Select(f => f.EquipmentId).Distinct())
{
var records = total.Where(f => f.EquipmentId == equipmentId).ToList();
- var item = new EquipmentRecordTotalEntity
+ var item = new EquipmentRecordDayTotalEntity
{
EquipmentId = equipmentId,
TotalDay = begDate
@@ -298,7 +300,7 @@ namespace PVDEMCS.Services.Repositories.Impl
}
item.Create();
}
- context.EquipmentRecordTotals.Add(item);
+ context.EquipmentRecordDayTotals.Add(item);
}
context.SaveChanges();
@@ -318,7 +320,7 @@ namespace PVDEMCS.Services.Repositories.Impl
#region 设备记录统计
///
- /// 获取设备状态记录统计分页列表
+ /// 获取设备状态记录日统计分页列表
///
/// 设备名称
/// 设备编号
@@ -331,7 +333,7 @@ namespace PVDEMCS.Services.Repositories.Impl
{
using (var context = new EFContext())
{
- var query = QueryEquipmentRecordTotal(equipmentName, equipmentCode, equipmentType, begTime, endTime, context);
+ var query = QueryEquipmentRecordDayTotal(equipmentName, equipmentCode, equipmentType, begTime, endTime, context);
var pageList = query.OrderByDescending(f => f.EquipmentCode).ToPagedList(page, size);
@@ -340,7 +342,7 @@ namespace PVDEMCS.Services.Repositories.Impl
}
///
- /// 获取设备状态记录统计列表
+ /// 获取设备状态记录日统计列表
///
/// 设备名称
/// 设备编号
@@ -351,7 +353,7 @@ namespace PVDEMCS.Services.Repositories.Impl
{
using (var context = new EFContext())
{
- var query = QueryEquipmentRecordTotal(equipmentName, equipmentCode, equipmentType, begTime, endTime, context);
+ var query = QueryEquipmentRecordDayTotal(equipmentName, equipmentCode, equipmentType, begTime, endTime, context);
var pageList = query.OrderByDescending(f => f.EquipmentCode).ToList();
@@ -359,32 +361,83 @@ namespace PVDEMCS.Services.Repositories.Impl
}
}
+ private IQueryable QueryEquipmentRecordDayTotal(string equipmentName, string equipmentCode, string equipmentType, DateTime begTime, DateTime endTime, EFContext context)
+ {
+ var query = from recordTotal in context.EquipmentRecordDayTotals
+ join equipment in context.EquipmentInfos.Where(f => !f.IsDelete) on recordTotal.EquipmentId equals equipment.Id
+ select new EquipmentRecordDayTotal
+ {
+ Id = recordTotal.Id,
+ EquipmentName = equipment.EquipmentName,
+ EquipmentCode = equipment.EquipmentCode,
+ EquipmentType = equipment.EquipmentType,
+ FurnaceNum = recordTotal.FurnaceNum,
+ TotalAlarmTime = recordTotal.TotalAlarmTime,
+ TotalStopTime = recordTotal.TotalStopTime,
+ TotalRunningTime = recordTotal.TotalRunningTime,
+ TotalDay = recordTotal.TotalDay,
+ };
+
+ if (!equipmentName.IsNullOrEmpty())
+ {
+ query = query.Where(f => f.EquipmentName.StartsWith(equipmentName));
+ }
+ if (!equipmentCode.IsNullOrEmpty())
+ {
+ query = query.Where(f => f.EquipmentCode.StartsWith(equipmentCode));
+ }
+ if (!equipmentType.IsNullOrEmpty())
+ {
+ query = query.Where(f => f.EquipmentType == equipmentType);
+ }
+ query = query.Where(f => f.TotalDay >= begTime && f.TotalDay <= endTime);
+
+ return query;
+ }
+
///
- /// 获取设备状态记录月统计
+ /// 获取设备状态记录统计分页列表
///
- ///
- public Result> GetEquipmentRecordStateMonthTotal()
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ /// 当前页
+ /// 页大小
+ public Result> GetEquipmentRecordTotalPageList(string equipmentName, string equipmentCode, string equipmentType, int page, int size)
{
using (var context = new EFContext())
- { }
+ {
+ var query = QueryEquipmentRecordTotal(equipmentName, equipmentCode, equipmentType, context);
+
+ var pageList = query.OrderByDescending(f => f.EquipmentCode).ToPagedList(page, size);
- return null;
+ return new Result>(pageList);
+ }
}
///
- /// 获取设备记录开炉次数月统计
+ /// 获取设备状态记录统计列表
///
- ///
- public Result> GetEquipmentRecordFurnaceMonthTotal()
+ /// 设备名称
+ /// 设备编号
+ /// 设备类型
+ public Result> GetEquipmentRecordTotalList(string equipmentName, string equipmentCode, string equipmentType)
{
- return null;
+ using (var context = new EFContext())
+ {
+ var query = QueryEquipmentRecordTotal(equipmentName, equipmentCode, equipmentType, context);
+
+ var pageList = query.OrderByDescending(f => f.EquipmentCode).ToList();
+
+ return new Result>(pageList);
+ }
}
- private IQueryable QueryEquipmentRecordTotal(string equipmentName, string equipmentCode, string equipmentType, DateTime begTime, DateTime endTime, EFContext context)
+ private IQueryable QueryEquipmentRecordTotal(string equipmentName, string equipmentCode, string equipmentType, EFContext context)
{
- var query = from recordTotal in context.EquipmentRecordTotals
+ var query = from recordTotal in context.EquipmentRecordDayTotals
join equipment in context.EquipmentInfos.Where(f => !f.IsDelete) on recordTotal.EquipmentId equals equipment.Id
- select new EquipmentRecordDayTotal
+ select new EquipmentRecordTotal
{
Id = recordTotal.Id,
EquipmentName = equipment.EquipmentName,
@@ -394,7 +447,6 @@ namespace PVDEMCS.Services.Repositories.Impl
TotalAlarmTime = recordTotal.TotalAlarmTime,
TotalStopTime = recordTotal.TotalStopTime,
TotalRunningTime = recordTotal.TotalRunningTime,
- TotalDay = recordTotal.TotalDay,
};
if (!equipmentName.IsNullOrEmpty())
@@ -409,11 +461,74 @@ namespace PVDEMCS.Services.Repositories.Impl
{
query = query.Where(f => f.EquipmentType == equipmentType);
}
- query = query.Where(f => f.TotalDay >= begTime && f.TotalDay <= endTime);
return query;
}
+ ///
+ /// 获取设备状态记录月统计
+ ///
+ ///
+ public Result> GetEquipmentRecordStateMonthTotal()
+ {
+ //获取今年第一天和最后一天
+ var begDate = DateTime.Now.ToString("yyyy-01-01");
+ var endDate = DateTime.Parse(begDate).AddYears(1).AddSeconds(-1).ToString("yyyy-01-01");
+ using (var context = new EFContext())
+ {
+ var list = context.Database.SqlQuery(@$"SELECT
+ SUM(total_running_time) AS TotalRunningTime,
+ SUM(total_alarm_time) AS TotalAlarmTime,
+ SUM(total_stop_time) AS TotalStopTime,
+ MONTH(total_day) AS TotalMonth
+ FROM
+
+ equipment_record_total
+ WHERE
+
+ total_day >= '{begDate}'
+
+ AND total_day <= '{endDate}'
+ GROUP BY
+ TotalMonth").ToList();
+
+ return new Result>(list);
+ }
+
+ }
+
+ ///
+ /// 获取设备记录开炉次数月统计
+ ///
+ ///
+ public Result> GetEquipmentRecordFurnaceMonthTotal()
+ {
+ //获取今年第一天和最后一天
+ var begDate = DateTime.Now.ToString("yyyy-01-01");
+ var endDate = DateTime.Parse(begDate).AddYears(1).AddSeconds(-1).ToString("yyyy-01-01");
+ using (var context = new EFContext())
+ {
+ var list = context.Database.SqlQuery(@$"SELECT
+ SUM( furnace_num ) AS FurnaceNum,
+ equipment_info.equipment_type AS EquipmentType,
+ MONTH ( total_day ) AS TotalMonth
+ FROM
+ equipment_record_total
+ JOIN equipment_info ON equipment_record_total.equipment_id = equipment_info.id
+ WHERE
+ total_day >= '{begDate}'
+ AND total_day <= '{endDate}'
+ GROUP BY
+ TotalMonth,
+ EquipmentType").ToList();
+
+ return new Result>(list);
+ }
+ }
+
+
+
+
#endregion
}
}
diff --git a/SQL/pvdemcs.sql b/SQL/pvdemcs.sql
index a5bee8b..9493a7a 100644
--- a/SQL/pvdemcs.sql
+++ b/SQL/pvdemcs.sql
@@ -11,7 +11,7 @@
Target Server Version : 80034
File Encoding : 65001
- Date: 30/10/2023 00:17:45
+ Date: 01/11/2023 15:24:59
*/
SET NAMES utf8mb4;
@@ -40,10 +40,6 @@ CREATE TABLE `device_info` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'PLC控制器' ROW_FORMAT = DYNAMIC;
--- ----------------------------
--- Records of device_info
--- ----------------------------
-
-- ----------------------------
-- Table structure for device_point
-- ----------------------------
@@ -69,10 +65,6 @@ CREATE TABLE `device_point` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'PLC点位' ROW_FORMAT = DYNAMIC;
--- ----------------------------
--- Records of device_point
--- ----------------------------
-
-- ----------------------------
-- Table structure for equipment_info
-- ----------------------------
@@ -94,10 +86,6 @@ CREATE TABLE `equipment_info` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备信息' ROW_FORMAT = Dynamic;
--- ----------------------------
--- Records of equipment_info
--- ----------------------------
-
-- ----------------------------
-- Table structure for equipment_record
-- ----------------------------
@@ -116,8 +104,23 @@ CREATE TABLE `equipment_record` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备状态记录明显' ROW_FORMAT = Dynamic;
-- ----------------------------
--- Records of equipment_record
+-- Table structure for equipment_record_day_total
-- ----------------------------
+DROP TABLE IF EXISTS `equipment_record_day_total`;
+CREATE TABLE `equipment_record_day_total` (
+ `id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
+ `equipment_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备Id',
+ `furnace_num` int NOT NULL COMMENT '开炉次数',
+ `total_running_time` decimal(32, 2) NOT NULL COMMENT '总运行时长',
+ `total_alarm_time` decimal(32, 2) NOT NULL COMMENT '总报警时长',
+ `total_stop_time` decimal(32, 2) NOT NULL COMMENT '总待机时长',
+ `total_day` datetime NULL DEFAULT NULL COMMENT '日期',
+ `create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建者',
+ `create_at` datetime NULL DEFAULT NULL COMMENT '创建时间',
+ `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '修改者',
+ `update_at` datetime NULL DEFAULT NULL COMMENT '修改时间',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备状态记录日统计\r\n' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for equipment_record_total
@@ -130,17 +133,12 @@ CREATE TABLE `equipment_record_total` (
`total_running_time` decimal(32, 2) NOT NULL COMMENT '总运行时长',
`total_alarm_time` decimal(32, 2) NOT NULL COMMENT '总报警时长',
`total_stop_time` decimal(32, 2) NOT NULL COMMENT '总待机时长',
- `total_day` datetime NULL DEFAULT NULL COMMENT '日期',
`create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建者',
`create_at` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '修改者',
`update_at` datetime NULL DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备状态记录日统计\r\n' ROW_FORMAT = Dynamic;
-
--- ----------------------------
--- Records of equipment_record_total
--- ----------------------------
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '设备状态记录统计\r\n' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for sys_config
@@ -161,11 +159,7 @@ CREATE TABLE `sys_config` (
`delete_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '删除者',
`delete_at` datetime NULL DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 120 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '参数配置表' ROW_FORMAT = DYNAMIC;
-
--- ----------------------------
--- Records of sys_config
--- ----------------------------
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '参数配置表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Table structure for sys_user
@@ -194,10 +188,6 @@ CREATE TABLE `sys_user` (
`delete_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '删除者',
`delete_at` datetime NULL DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
-
--- ----------------------------
--- Records of sys_user
--- ----------------------------
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户信息表' ROW_FORMAT = DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;