From 53e8aef5935d12a5edd704398f3c649a650c4015 Mon Sep 17 00:00:00 2001
From: tq <1916474859@qq,com>
Date: Tue, 2 Jul 2024 18:23:55 +0800
Subject: [PATCH] job
---
Entity/Ammeter/EmeterDayEnergy.cs | 6 +-
Entity/Ammeter/EmeterEnergy.cs | 2 +-
Entity/Ammeter/EmeterHourEnergy.cs | 7 +-
Entity/Ammeter/EmeterMinutesEnergy.cs | 3 +
Entity/Dto/Req/MoveBinRecordReq.cs | 38 ++++
Service/MyJob/CountDayOrderJob.cs | 103 +++++++++++
Service/MyJob/EmeterDayJob.cs | 113 ++++++++++++
Service/MyJob/EmeterHourJob.cs | 96 +++++++++++
Service/MyJob/EmeterMinuteJob.cs | 7 +-
Service/MyTask/CountDayOrderTask.cs | 163 ------------------
Service/Station/MonitorService.cs | 45 +++++
.../Controllers/MoveBinRecordController.cs | 62 +++++++
WebStarter/Program.cs | 3 +
WebStarter/appsettings.dev.json | 3 +
WebStarter/appsettings.prod.json | 3 +
15 files changed, 483 insertions(+), 171 deletions(-)
create mode 100644 Entity/Dto/Req/MoveBinRecordReq.cs
create mode 100644 Service/MyJob/CountDayOrderJob.cs
create mode 100644 Service/MyJob/EmeterDayJob.cs
create mode 100644 Service/MyJob/EmeterHourJob.cs
delete mode 100644 Service/MyTask/CountDayOrderTask.cs
create mode 100644 WebStarter/Controllers/MoveBinRecordController.cs
diff --git a/Entity/Ammeter/EmeterDayEnergy.cs b/Entity/Ammeter/EmeterDayEnergy.cs
index b5c9be2..4778796 100644
--- a/Entity/Ammeter/EmeterDayEnergy.cs
+++ b/Entity/Ammeter/EmeterDayEnergy.cs
@@ -31,7 +31,7 @@ namespace Entity.Ammeter
///
/// 时间
///
- [SugarColumn(ColumnName = "st")]
+ [SugarColumn(ColumnName = "time")]
public string Time { get; set; }
///
@@ -44,5 +44,9 @@ namespace Entity.Ammeter
///
[SugarColumn(ColumnName = "type")]
public int Type { get; set; }
+
+ [SugarColumn(ColumnName = "upload_flag")]
+
+ public int UploadFlag { get; set; }
}
}
\ No newline at end of file
diff --git a/Entity/Ammeter/EmeterEnergy.cs b/Entity/Ammeter/EmeterEnergy.cs
index b72b39c..7a787e0 100644
--- a/Entity/Ammeter/EmeterEnergy.cs
+++ b/Entity/Ammeter/EmeterEnergy.cs
@@ -21,7 +21,7 @@ public class EmeterEnergy
/// 电表当前读数
///
[SugarColumn(ColumnName = "value")]
- public virtual string Value { get; set; }
+ public virtual float Value { get; set; }
///
/// 充电机上报时间
diff --git a/Entity/Ammeter/EmeterHourEnergy.cs b/Entity/Ammeter/EmeterHourEnergy.cs
index 0b4e5b0..dd36f3a 100644
--- a/Entity/Ammeter/EmeterHourEnergy.cs
+++ b/Entity/Ammeter/EmeterHourEnergy.cs
@@ -31,8 +31,8 @@ namespace Entity.Ammeter
///
/// 时间
///
- [SugarColumn(ColumnName = "st")]
- public float Time { get; set; }
+ [SugarColumn(ColumnName = "time")]
+ public string Time { get; set; }
///
/// 实时值(取末端)
@@ -44,5 +44,8 @@ namespace Entity.Ammeter
///
[SugarColumn(ColumnName = "type")]
public int Type { get; set; }
+ [SugarColumn(ColumnName = "upload_flag")]
+
+ public int UploadFlag { get; set; }
}
}
diff --git a/Entity/Ammeter/EmeterMinutesEnergy.cs b/Entity/Ammeter/EmeterMinutesEnergy.cs
index 7d79fdc..5c4223d 100644
--- a/Entity/Ammeter/EmeterMinutesEnergy.cs
+++ b/Entity/Ammeter/EmeterMinutesEnergy.cs
@@ -45,6 +45,9 @@ namespace Entity.Ammeter
///
[SugarColumn(ColumnName = "type")]
public int Type { get; set; }
+ [SugarColumn(ColumnName = "upload_flag")]
+
+ public int UploadFlag { get; set; }
}
diff --git a/Entity/Dto/Req/MoveBinRecordReq.cs b/Entity/Dto/Req/MoveBinRecordReq.cs
new file mode 100644
index 0000000..971cbdf
--- /dev/null
+++ b/Entity/Dto/Req/MoveBinRecordReq.cs
@@ -0,0 +1,38 @@
+using Entity.DbModel.Station;
+using HybirdFrameworkCore.Entity;
+
+namespace Entity.Dto.Req;
+
+public class MoveBinRecordReq: BaseIdReq
+{
+
+}
+public class PageMoveBinRecordReq : QueryPageModel
+{
+ ///
+ /// in_bin_no
+ ///
+ public string? UpBinNo { get; set; }
+
+ ///
+ /// in_battery_no
+ ///
+ public string? UpBatteryNo { get; set; }
+
+ ///
+ /// in_battery_soc
+ ///
+ public string? UpBatterySoc { get; set; }
+}
+
+public class AddMoveBinRecordReq : MoveBinRecord
+{
+}
+
+public class UpdateMoveBinRecordReq : AddMoveBinRecordReq
+{
+}
+
+public class DeleteMoveBinRecordReq : BaseIdReq
+{
+}
\ No newline at end of file
diff --git a/Service/MyJob/CountDayOrderJob.cs b/Service/MyJob/CountDayOrderJob.cs
new file mode 100644
index 0000000..784399e
--- /dev/null
+++ b/Service/MyJob/CountDayOrderJob.cs
@@ -0,0 +1,103 @@
+using Autofac;
+using Entity.DbModel.Station;
+using HybirdFrameworkCore.Autofac;
+using HybirdFrameworkCore.Autofac.Attribute;
+using HybirdFrameworkCore.Job;
+using log4net;
+using Service.Init;
+using Service.Station;
+
+namespace Service.Job;
+
+[Scope]
+public class CountDayOrderJob : AbstractCronJob
+{
+ private static readonly ILog Log = LogManager.GetLogger(typeof(CountDayOrderJob));
+
+ public readonly ChargeOrderService _ChargeOrderService=AppInfo.Container.Resolve();
+
+ public readonly SwapOrderService _SwapOrderService=AppInfo.Container.Resolve();
+ public readonly ExStationDayRunResultService _ExStationDayRunResultService=AppInfo.Container.Resolve();
+
+
+ protected override Task Handle()
+ {
+ // 获取 ChargeOrder 和 SwapOrder 列表
+ List orders = _ChargeOrderService.DayChargeOrder();
+ List daySwapOrder = _SwapOrderService.DaySwapOrder();
+
+ // 创建 ExchangeStationDayRunResult 实例
+ ExchangeStationDayRunResult dayCount = new ExchangeStationDayRunResult();
+
+ // 计算平均充电时间(分钟)
+ double avgMinutes = orders
+ .Where(order => order.StartTime.HasValue && order.EndTime.HasValue)
+ .Select(order => (order.EndTime.Value - order.StartTime.Value).TotalMinutes)
+ .DefaultIfEmpty(0.0)
+ .Average();
+
+
+ // 计算平均换电时间(分钟)
+ double avgRepTime = daySwapOrder
+ .Where(order => order.SwapBeginTime.HasValue && order.SwapEndTime.HasValue)
+ .Select(order => (order.SwapEndTime.Value - order.SwapBeginTime.Value).TotalMinutes)
+ .DefaultIfEmpty(0.0)
+ .Average();
+
+ // 找到最早的换电时间
+ SwapOrder firstSwapOrder = daySwapOrder
+ .Where(order => order.SwapBeginTime.HasValue)
+ .OrderBy(order => order.SwapBeginTime)
+ .FirstOrDefault();
+
+ // 找到最晚的换电时间
+ SwapOrder lastSwapOrder = daySwapOrder
+ .Where(order => order.SwapEndTime.HasValue)
+ .OrderByDescending(order => order.SwapEndTime)
+ .FirstOrDefault();
+
+ // 统计充电次数
+ int chgCount = orders
+ .Where(order => !string.IsNullOrEmpty(order.Sn))
+ .Select(order => order.Sn)
+ .Distinct()
+ .Count();
+ // 统计换电次数
+ int totalSwapCount = daySwapOrder
+ .Where(order => !string.IsNullOrEmpty(order.Sn))
+ .Select(order => order.Sn)
+ .Distinct()
+ .Count();
+
+ // 计算总共换电多少分钟
+ double totalMinutes = daySwapOrder
+ .Where(order => order.SwapBeginTime.HasValue && order.SwapEndTime.HasValue)
+ .Sum(order => (order.SwapEndTime.Value - order.SwapBeginTime.Value).TotalMinutes);
+ // 赋值
+
+ dayCount.AvgChgTime = avgMinutes.ToString("F2");
+ dayCount.AvgRepTime = avgRepTime.ToString("F2");
+ dayCount.SwapDate = DateTime.Now.AddDays(-1).ToString();
+
+
+ dayCount.FristSwapTime = firstSwapOrder?.SwapBeginTime?.ToString() ?? null;
+ dayCount.StopTime = lastSwapOrder?.SwapEndTime?.ToString() ?? null;
+ dayCount.ChgCount = chgCount;
+ dayCount.ToltalSwapCount = totalSwapCount;
+ dayCount.ToltalSwapAllTime = Math.Round(totalMinutes, 2);
+
+ dayCount.State = StaticStationInfo.StationStatus;
+ _ExStationDayRunResultService.Insert(dayCount);
+ return Task.CompletedTask;
+ }
+
+ protected override string Key()
+ {
+ return "CountDayOrderJob";
+ }
+
+ protected override string Cron()
+ {
+ return "0 0 1 * * ?";
+ }
+}
\ No newline at end of file
diff --git a/Service/MyJob/EmeterDayJob.cs b/Service/MyJob/EmeterDayJob.cs
new file mode 100644
index 0000000..275891f
--- /dev/null
+++ b/Service/MyJob/EmeterDayJob.cs
@@ -0,0 +1,113 @@
+using Autofac;
+using Entity.Ammeter;
+using HybirdFrameworkCore.Autofac;
+using HybirdFrameworkCore.Autofac.Attribute;
+using HybirdFrameworkCore.Job;
+using log4net;
+using Repository.Ammeter;
+
+namespace Service.Job;
+
+[Scope]
+public class EmeterDayJob: AbstractCronJob
+{
+
+ private static readonly ILog Log = LogManager.GetLogger(typeof(EmeterDayJob));
+ public readonly EmeterEnergyRepository _EmeterEnergyRepository=AppInfo.Container.Resolve();
+
+ public readonly EmeterEnergyChangeRepository _EmeterEnergyChangeRepository=AppInfo.Container.Resolve();
+
+ public readonly EmeterDayEnergyRepository _EmeterDayEnergyRepository=AppInfo.Container.Resolve();
+
+ protected override Task Handle()
+ {
+ var now = DateTime.Now;
+ Log.Info($"EmeterMinuteJob execute time={now}");
+ //查询1天前的数据
+ string dateTime = now.AddDays(-1).ToString("yyyy-MM-dd");
+
+ List emeterEnergies = _EmeterEnergyRepository.QueryListByClause(i =>
+ dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd")), "upload_time desc");
+
+ List emeterEnergiesChange = _EmeterEnergyChangeRepository.QueryListByClause(i =>
+ dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd")), "upload_time desc");
+
+ if (emeterEnergies.Count > 0)
+ {
+ Dictionary> dictionary =
+ emeterEnergies.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
+ List list = new List();
+ foreach (var keyValuePair in dictionary)
+ {
+ EmeterDayEnergy emitterDayEnergy = new EmeterDayEnergy();
+ emitterDayEnergy.Code = keyValuePair.Key;
+ emitterDayEnergy.Time = dateTime;
+ emitterDayEnergy.Type = 1;
+
+ EmeterEnergy? maxValue = keyValuePair.Value.MaxBy(x => x.Value);
+
+ EmeterEnergy? minValue = keyValuePair.Value.MinBy(x => x.Value);
+
+ if (maxValue != null)
+ {
+ emitterDayEnergy.RealTimeValue = maxValue.Value;
+ }
+
+ if (maxValue != null && minValue != null)
+ {
+ emitterDayEnergy.Value = maxValue.Value - minValue.Value;
+ }
+
+ list.Add(emitterDayEnergy);
+ }
+
+ _EmeterDayEnergyRepository.Insert(list);
+ }
+
+ if (emeterEnergiesChange.Count > 0)
+ {
+ Dictionary> dictionaryChange =
+ emeterEnergiesChange.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
+ List list = new List();
+
+ foreach (var keyValuePair in dictionaryChange)
+ {
+ EmeterDayEnergy emitterDayEnergy = new EmeterDayEnergy();
+ emitterDayEnergy.Code = keyValuePair.Key;
+ emitterDayEnergy.Time = dateTime;
+ emitterDayEnergy.Type = 2;
+
+ EmeterEnergyChange? maxValue = keyValuePair.Value.MaxBy(x => x.Value);
+
+ EmeterEnergyChange? minValue = keyValuePair.Value.MinBy(x => x.Value);
+
+ if (maxValue != null)
+ {
+ emitterDayEnergy.RealTimeValue = maxValue.Value;
+ }
+
+ if (maxValue != null && minValue != null)
+ {
+ emitterDayEnergy.Value = maxValue.Value - minValue.Value;
+ }
+
+ list.Add(emitterDayEnergy);
+ }
+
+ _EmeterDayEnergyRepository.Insert(list);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ protected override string Key()
+ {
+ return "EmeterDayJob";
+ }
+
+ // 每天凌晨1点执行
+ protected override string Cron()
+ {
+ return "0 0 1 * * ?";
+ }
+}
\ No newline at end of file
diff --git a/Service/MyJob/EmeterHourJob.cs b/Service/MyJob/EmeterHourJob.cs
new file mode 100644
index 0000000..34acbc9
--- /dev/null
+++ b/Service/MyJob/EmeterHourJob.cs
@@ -0,0 +1,96 @@
+using Autofac;
+using Entity.Ammeter;
+using HybirdFrameworkCore.Autofac;
+using HybirdFrameworkCore.Autofac.Attribute;
+using HybirdFrameworkCore.Job;
+using log4net;
+using Repository.Ammeter;
+using SqlSugar;
+
+namespace Service.Job;
+
+[Scope]
+public class EmeterHourJob : AbstractCronJob
+{
+ private static readonly ILog Log = LogManager.GetLogger(typeof(EmeterHourJob));
+
+
+ public readonly EmeterEnergyRepository _EmeterEnergyRepository=AppInfo.Container.Resolve();
+
+ public readonly EmeterEnergyChangeRepository _EmeterEnergyChangeRepository=AppInfo.Container.Resolve();
+
+ public readonly EmeterHourEnergyRepository _EmeterHourEnergy=AppInfo.Container.Resolve();
+
+
+ protected override Task Handle()
+ {
+ var now = DateTime.Now;
+ Log.Info($"EmeterMinuteJob execute time={now}");
+ //查询上一小时的数据
+ string dateTime = now.AddHours(-1).ToString("yyyy-MM-dd HH");
+
+ List emeterEnergies = _EmeterEnergyRepository.QueryListByClause(i =>
+ dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH")), "upload_time desc");
+
+ List emeterEnergiesChange = _EmeterEnergyChangeRepository.QueryListByClause(i =>
+ dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH")), "upload_time desc");
+
+ List db = new List();
+ if (emeterEnergies.Count > 0)
+ {
+ Dictionary> dictionary =
+ emeterEnergies.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
+
+ foreach (var keyValuePair in dictionary)
+ {
+ EmeterHourEnergy emeterMinutesEnergy = new EmeterHourEnergy();
+ emeterMinutesEnergy.Code = keyValuePair.Key;
+ emeterMinutesEnergy.Time = dateTime;
+ emeterMinutesEnergy.Type = 1;
+ var value = keyValuePair.Value;
+ var orderByDescending = value.OrderByDescending(i => i.UploadTime).ToList();
+ emeterMinutesEnergy.RealTimeValue = orderByDescending[0].Value;
+ emeterMinutesEnergy.Value = orderByDescending[0].Value -
+ orderByDescending[^1].Value;
+ db.Add(emeterMinutesEnergy);
+ }
+ }
+
+ if (emeterEnergiesChange.Count > 0)
+ {
+ Dictionary> dictionaryChange =
+ emeterEnergiesChange.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
+
+ foreach (var keyValuePair in dictionaryChange)
+ {
+ EmeterHourEnergy emeterMinutesEnergy = new EmeterHourEnergy();
+ emeterMinutesEnergy.Code = keyValuePair.Key;
+ emeterMinutesEnergy.Time = dateTime;
+ emeterMinutesEnergy.Type = 1;
+ var value = keyValuePair.Value;
+ var orderByDescending = value.OrderByDescending(i => i.UploadTime).ToList();
+ emeterMinutesEnergy.RealTimeValue = orderByDescending[0].Value;
+ emeterMinutesEnergy.Value = orderByDescending[0].Value -
+ orderByDescending[^1].Value;
+ db.Add(emeterMinutesEnergy);
+ }
+ }
+
+ if (db.Count > 0)
+ {
+ _EmeterHourEnergy.Insert(db);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ protected override string Key()
+ {
+ return "EmeterHourJob";
+ }
+
+ protected override string Cron()
+ {
+ return "0 30 * * * ?";
+ }
+}
\ No newline at end of file
diff --git a/Service/MyJob/EmeterMinuteJob.cs b/Service/MyJob/EmeterMinuteJob.cs
index 5f007d7..fad5732 100644
--- a/Service/MyJob/EmeterMinuteJob.cs
+++ b/Service/MyJob/EmeterMinuteJob.cs
@@ -54,9 +54,9 @@ public class EmeterMinuteJob : AbstractCronJob
emeterMinutesEnergy.Type = 1;
var value = keyValuePair.Value;
var orderByDescending = value.OrderByDescending(i => i.UploadTime).ToList();
- emeterMinutesEnergy.RealTimeValue = float.Parse(orderByDescending[0].Value);
- emeterMinutesEnergy.Value = float.Parse(orderByDescending[0].Value) -
- float.Parse(orderByDescending[^1].Value);
+ emeterMinutesEnergy.RealTimeValue = orderByDescending[0].Value;
+ emeterMinutesEnergy.Value = orderByDescending[0].Value -
+ orderByDescending[^1].Value;
db.Add(emeterMinutesEnergy);
}
}
@@ -98,7 +98,6 @@ public class EmeterMinuteJob : AbstractCronJob
protected override string Cron()
{
- //return "0 0/1 * * * ?";
return "0 * * * * ? *";
}
}
\ No newline at end of file
diff --git a/Service/MyTask/CountDayOrderTask.cs b/Service/MyTask/CountDayOrderTask.cs
deleted file mode 100644
index 9172aaf..0000000
--- a/Service/MyTask/CountDayOrderTask.cs
+++ /dev/null
@@ -1,163 +0,0 @@
-using Entity.Constant;
-using Entity.DbModel.Station;
-using HybirdFrameworkCore.Autofac.Attribute;
-using HybirdFrameworkCore.AutoTask;
-using log4net;
-using Service.Init;
-using Service.Station;
-
-namespace Service.MyTask;
-
-///
-/// 统计每日运行
-///
-[Scope]
-public class CountDayOrderTask : ITask
-{
- private static readonly ILog Log = LogManager.GetLogger(typeof(CountDayOrderTask));
- private volatile bool _stop;
- private Timer _timer;
-
- public ChargeOrderService _ChargeOrderService { get; set; }
-
- public SwapOrderService _SwapOrderService { get; set; }
- public ExStationDayRunResultService _ExStationDayRunResultService { get; set; }
-
- public string Name()
- {
- return "CountDayOrderTask";
- }
-
- public int Interval()
- {
- return 1000 * 10;
- }
-
- public void Handle()
- {
- // 统计每日运行
- return;
- // CountOrder();
- }
-
-
-
- public bool Stoped()
- {
- return _stop;
-
- }
-
- public void Stop()
- {
- _stop = true;
- _timer?.Change(Timeout.Infinite, Timeout.Infinite);
-
- }
-
- public void ResetStop()
- {
- _stop = false;
- ScheduleNextRun();
-
- }
- public CountDayOrderTask()
- {
- ScheduleNextRun();
- }
-
- private void ScheduleNextRun()
- {
- if (_stop)
- {
- return;
- }
-
- DateTime now = DateTime.Now;
- DateTime nextRun = new DateTime(now.Year, now.Month, now.Day, 19, 21, 0);
- if (now > nextRun)
- {
- nextRun = nextRun.AddDays(1);
- }
-
- TimeSpan timeToGo = nextRun - now;
- _timer = new Timer(x =>
- {
- if (!_stop)
- {
- CountOrder();
- ScheduleNextRun();
- }
- }, null, timeToGo, Timeout.InfiniteTimeSpan);
- }
-
- public void CountOrder()
- {
- // 获取 ChargeOrder 和 SwapOrder 列表
- List orders = _ChargeOrderService.DayChargeOrder();
- List daySwapOrder = _SwapOrderService.DaySwapOrder();
-
- // 创建 ExchangeStationDayRunResult 实例
- ExchangeStationDayRunResult dayCount = new ExchangeStationDayRunResult();
-
- // 计算平均充电时间(分钟)
- double avgMinutes = orders
- .Where(order => order.StartTime.HasValue && order.EndTime.HasValue)
- .Select(order => (order.EndTime.Value - order.StartTime.Value).TotalMinutes)
- .DefaultIfEmpty(0.0)
- .Average();
-
-
- // 计算平均换电时间(分钟)
- double avgRepTime = daySwapOrder
- .Where(order => order.SwapBeginTime.HasValue && order.SwapEndTime.HasValue)
- .Select(order => (order.SwapEndTime.Value - order.SwapBeginTime.Value).TotalMinutes)
- .DefaultIfEmpty(0.0)
- .Average();
-
- // 找到最早的换电时间
- SwapOrder firstSwapOrder = daySwapOrder
- .Where(order => order.SwapBeginTime.HasValue)
- .OrderBy(order => order.SwapBeginTime)
- .FirstOrDefault();
-
- // 找到最晚的换电时间
- SwapOrder lastSwapOrder = daySwapOrder
- .Where(order => order.SwapEndTime.HasValue)
- .OrderByDescending(order => order.SwapEndTime)
- .FirstOrDefault();
-
- // 统计充电次数
- int chgCount = orders
- .Where(order => !string.IsNullOrEmpty(order.Sn))
- .Select(order => order.Sn)
- .Distinct()
- .Count();
- // 统计换电次数
- int totalSwapCount = daySwapOrder
- .Where(order => !string.IsNullOrEmpty(order.Sn))
- .Select(order => order.Sn)
- .Distinct()
- .Count();
-
- // 计算总共换电多少分钟
- double totalMinutes = daySwapOrder
- .Where(order => order.SwapBeginTime.HasValue && order.SwapEndTime.HasValue)
- .Sum(order => (order.SwapEndTime.Value - order.SwapBeginTime.Value).TotalMinutes);
- // 赋值
-
- dayCount.AvgChgTime = avgMinutes.ToString("F2");
- dayCount.AvgRepTime = avgRepTime.ToString("F2");
- dayCount.SwapDate = DateTime.Now.AddDays(-1).ToString();
-
-
- dayCount.FristSwapTime = firstSwapOrder?.SwapBeginTime?.ToString() ?? null;
- dayCount.StopTime = lastSwapOrder?.SwapEndTime?.ToString() ?? null;
- dayCount.ChgCount = chgCount;
- dayCount.ToltalSwapCount = totalSwapCount;
- dayCount.ToltalSwapAllTime = Math.Round(totalMinutes, 2);
-
- dayCount.State = StaticStationInfo.StationStatus;
- _ExStationDayRunResultService.Insert(dayCount);
- }
-}
\ No newline at end of file
diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs
index 3979a93..f81a193 100644
--- a/Service/Station/MonitorService.cs
+++ b/Service/Station/MonitorService.cs
@@ -1,8 +1,10 @@
+using System.ComponentModel;
using AutoMapper;
using Common.Util;
using Entity.Api.Resp;
using Entity.Constant;
using Entity.DbModel.Station;
+using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using log4net;
@@ -16,6 +18,7 @@ using Service.Execute.Model;
using Service.Init;
using Service.Mgr;
using Service.Plc.Client;
+using SqlSugar;
namespace Service.Station;
@@ -29,7 +32,49 @@ public class MonitorService
public PlcTaskMgr PlcTaskMgr { get; set; }
public MoveBinRecordRepository MoveBinRecordRepository { get; set; }
+
+
+ [DisplayName("获取移仓分页")]
+ public async Task> Page(PageMoveBinRecordReq input)
+ {
+ RefAsync total = 0;
+
+ var items = await MoveBinRecordRepository.QueryPageAsync(
+ entity => true,
+ !string.IsNullOrWhiteSpace(input.UpBatterySoc), u => u.UpBatterySoc.Equals(input.UpBatterySoc.Trim()),
+ !string.IsNullOrWhiteSpace(input.UpBinNo), u => u.UpBinNo.Equals(input.UpBinNo.Trim()),
+ !string.IsNullOrWhiteSpace(input.UpBatteryNo), u => u.UpBatteryNo.Equals(input.UpBatteryNo.Trim()),
+ u => u.CreatedTime, input.PageNum, input.PageSize, total);
+ return new PageResult()
+ {
+ PageNum = input.PageNum,
+ PageSize = input.PageSize,
+ ToTal = total,
+ Rows = items,
+ };
+ }
+
+ public async Task Add(AddMoveBinRecordReq input)
+ {
+ string result = "";
+ MoveBinRecord moveBinRecord = await MoveBinRecordRepository.InsertAsync(input);
+
+ return "新增id:" + moveBinRecord.Id;
+ }
+ public virtual async Task Update(UpdateMoveBinRecordReq Req)
+ {
+ return await MoveBinRecordRepository.UpdateAsync(Req);
+ }
+
+
+ public virtual async Task Delete(DeleteMoveBinRecordReq input)
+ {
+ var user = await MoveBinRecordRepository.QueryByClauseAsync(u => u.Id == input.Id);
+ if (user == null)
+ throw new ArgumentException($"不存在");
+ return await MoveBinRecordRepository.DeleteAsync(user);
+ }
public Result GetSwapMonitorData()
{
var configBinInfo =
diff --git a/WebStarter/Controllers/MoveBinRecordController.cs b/WebStarter/Controllers/MoveBinRecordController.cs
new file mode 100644
index 0000000..61d9466
--- /dev/null
+++ b/WebStarter/Controllers/MoveBinRecordController.cs
@@ -0,0 +1,62 @@
+using System.ComponentModel.DataAnnotations;
+using Entity.DbModel.Station;
+using Entity.Dto.Req;
+using HybirdFrameworkCore.Entity;
+using Microsoft.AspNetCore.Mvc;
+using Service.Station;
+
+namespace WebStarter.Controllers;
+
+///
+/// 电池移仓
+///
+[ApiController]
+[Route("api/[controller]")]
+public class MoveBinRecordController
+{
+ private readonly MonitorService _monitorService;
+
+ public MoveBinRecordController(MonitorService monitorService)
+ {
+ _monitorService = monitorService;
+ }
+
+ [HttpPost]
+ [Route("page")]
+ public async Task>> page([FromBody] PageMoveBinRecordReq input)
+ {
+ return Result>.Success(await _monitorService.Page(input));
+ }
+
+
+ [HttpPost]
+ [Route("add")]
+ public async Task> Add([FromBody] AddMoveBinRecordReq input)
+ {
+ var data = await _monitorService.Add(input);
+ return Result.Success(data);
+ }
+
+ [HttpPost]
+ [Route("update")]
+ public async Task> Update([FromBody] UpdateMoveBinRecordReq req)
+ {
+ var data = await _monitorService.Update(req);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+
+
+ [HttpPost]
+ [Route("delete")]
+ public async Task> Delete([FromBody] [Required] DeleteMoveBinRecordReq input)
+ {
+ var data = await _monitorService.Delete(input);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs
index fb46159..499ab70 100644
--- a/WebStarter/Program.cs
+++ b/WebStarter/Program.cs
@@ -6,6 +6,7 @@ using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Entity;
+using HybirdFrameworkCore.Job;
using HybirdFrameworkCore.Redis;
using log4net;
using Mapster;
@@ -166,5 +167,7 @@ if (AppSettingsHelper.GetBool("swap", "enable"))
TaskInit.Init();
+QuartzSchedulerFactory.Init();
+app.Lifetime.ApplicationStopping.Register(QuartzSchedulerFactory.Shutdown);
app.Run();
diff --git a/WebStarter/appsettings.dev.json b/WebStarter/appsettings.dev.json
index bbb1727..060d827 100644
--- a/WebStarter/appsettings.dev.json
+++ b/WebStarter/appsettings.dev.json
@@ -92,5 +92,8 @@
"Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs",
"Dest": "D:\\zip",
"Days": 7
+ },
+ "Job": {
+ "Enabled": true
}
}
diff --git a/WebStarter/appsettings.prod.json b/WebStarter/appsettings.prod.json
index 4e9adea..c187389 100644
--- a/WebStarter/appsettings.prod.json
+++ b/WebStarter/appsettings.prod.json
@@ -126,5 +126,8 @@
"Src": "D:\\RiderProjects\\hn_back_charger\\WebStarter\\bin\\Debug\\net6.0\\logs",
"Dest": "D:\\zip",
"Days": 7
+ },
+ "Job": {
+ "Enabled": true
}
}