diff --git a/Entity/DbModel/Station/SwapOrder.cs b/Entity/DbModel/Station/SwapOrder.cs
index 2810476..ed10166 100644
--- a/Entity/DbModel/Station/SwapOrder.cs
+++ b/Entity/DbModel/Station/SwapOrder.cs
@@ -147,5 +147,12 @@ namespace Entity.DbModel.Station
///
[SugarColumn(ColumnName = "cloud_sn")]
public string? CloudSn { get; set; }
+ ///
+ /// Desc:换电类型:;0手动换电;1自动换电
+ /// Default:0
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "swap_type")]
+ public int? SwapType { get; set; }
}
}
\ No newline at end of file
diff --git a/Entity/Dto/Req/BatteryOpModelReq.cs b/Entity/Dto/Req/BatteryOpModelReq.cs
new file mode 100644
index 0000000..3803776
--- /dev/null
+++ b/Entity/Dto/Req/BatteryOpModelReq.cs
@@ -0,0 +1,30 @@
+using Entity.DbModel.Station;
+
+namespace Entity.Dto.Req
+{
+ public class BatteryOpModelReq : BaseIdReq
+ {
+ }
+
+ public class PageBatteryOpReq : BasePageReq
+ {
+ ///
+ /// Desc:模型id
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? ModelId { get; set; }
+ }
+
+ public class AddBatteryOpReq : BatteryOpModel
+ {
+ }
+
+ public class UpdateBatteryOpReq : AddBatteryOpReq
+ {
+ }
+
+ public class DeleteBatteryOpReq : BaseIdReq
+ {
+ }
+}
\ No newline at end of file
diff --git a/Service/Station/BatteryOpModelService.cs b/Service/Station/BatteryOpModelService.cs
new file mode 100644
index 0000000..a16c86b
--- /dev/null
+++ b/Service/Station/BatteryOpModelService.cs
@@ -0,0 +1,80 @@
+using System.ComponentModel;
+using Entity.Base;
+using Entity.DbModel.Station;
+using Entity.DbModel.System;
+using Entity.Dto.Req;
+using HybirdFrameworkCore.Autofac.Attribute;
+using Repository.Station;
+using SqlSugar;
+
+namespace Service.Station;
+
+[Scope("SingleInstance")]
+public class BatteryOpModelService : BaseServices
+{
+ private BatteryOpModelRepository _batteryOpModelRepository;
+
+ public BatteryOpModelService(BatteryOpModelRepository dal)
+ {
+ _batteryOpModelRepository = dal;
+ BaseDal = dal;
+ }
+
+ ///
+ /// 电池运营模型分页列表 🔖
+ ///
+ ///
+ ///
+ [DisplayName("获取电池运营模型分页列表")]
+ public async Task> Page(PageBatteryOpReq input)
+ {
+ RefAsync total = 0;
+ var items = await _batteryOpModelRepository.QueryPageAsync(
+ entity => true,
+ false, entity => true,
+ false, entity => true,
+ input.ModelId != null, (u => input.ModelId != null && u.ModelId.Equals(input.ModelId.Value)),
+ u => u.CreatedTime, input.Page, input.PageSize, total
+ );
+ return SqlSugarPagedExtensions.CreateSqlSugarPagedList(items, total, input.Page, input.PageSize);
+ }
+
+ ///
+ /// 增加电池运营模型 🔖
+ ///
+ ///
+ ///
+ public async Task AddBatteryOpModel(AddBatteryOpReq input)
+ {
+ string result = "";
+ var isExist = await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == input.ModelId);
+ if (isExist != null)
+ return result = "模型id已存在";
+ await _batteryOpModelRepository.InsertAsync(input);
+ BatteryOpModel batteryOpModel =
+ await _batteryOpModelRepository.QueryByClauseAsync(u => u.ModelId == input.ModelId);
+ return result = "新增id:" + batteryOpModel.Id;
+ }
+
+ ///
+ /// 更新电池运营模型 🔖
+ ///
+ ///
+ public virtual async Task UpdateBatteryOpModel(UpdateBatteryOpReq batteryOpReq)
+ {
+ return await _batteryOpModelRepository.UpdateAsync(batteryOpReq);
+ }
+
+ ///
+ /// 删除电池运营模型 🔖
+ ///
+ ///
+ ///
+ public virtual async Task DeleteBatteryOpModel(DeleteBatteryOpReq input)
+ {
+ var user = await _batteryOpModelRepository.QueryByClauseAsync(u => u.Id == input.Id);
+ if (user == null)
+ throw new ArgumentException($"电池运营模型不存在");
+ return await _batteryOpModelRepository.DeleteAsync(user);
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/Ammeter/AmmeterController.cs b/WebStarter/Controllers/Ammeter/AmmeterController.cs
index 4a1a883..cae730e 100644
--- a/WebStarter/Controllers/Ammeter/AmmeterController.cs
+++ b/WebStarter/Controllers/Ammeter/AmmeterController.cs
@@ -4,6 +4,7 @@ using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Ammeter;
using Service.Station;
+using SqlSugar;
namespace WebStarter.Controllers.Ammeter
{
@@ -44,20 +45,35 @@ namespace WebStarter.Controllers.Ammeter
///
/// 统计分析/电能表累计值信息
///
- [HttpGet("TEgEmeterTotalEnergyValue/{Code}")]
+ [HttpGet("/TEgEmeterTotalEnergyValue/{Code}")]
public async Task>> GetNewEmeterMinutesEnergy(string Code)
{
- return Result>.Success(await _emeterMinutesEnergyService.SqlQueryable(
- "SELECT t1.* \r\n" +
- "FROM " +"( \r\n SELECT code, MAX(time) AS latest_time \r\n " +
- "FROM emeter_minutes_energy \r\n"+" Where code==" + Code+"+ GROUP BY code \r\n) " +
- "AS latest_records \r\nJOIN emeter_minutes_energy t1 ON latest_records.code = t1.code AND latest_records.latest_time = t1.time;"));
+ var query = @"
+ SELECT t1.*
+ FROM
+ (
+ SELECT code, MAX(time) AS latest_time
+ FROM emeter_minutes_energy
+ WHERE code = @Code
+ GROUP BY code
+ ) AS latest_records
+ JOIN emeter_minutes_energy t1
+ ON latest_records.code = t1.code
+ AND latest_records.latest_time = t1.time;";
+
+ var parameters = new List
+ {
+ new SugarParameter("@Code", Code)
+ };
+ var result = await Task.Run(() => _emeterMinutesEnergyService.SqlQuery(query, parameters));
+
+ return Result>.Success(result);
}
///
/// 删除电能表累计值信息
///
- [HttpGet("TEgEmeterTotalEnergyValue/{id}")]
+ [HttpGet("delete/TEgEmeterTotalEnergyValue/{id}")]
public Result DeleteOneEmeterMinutesEnergy(long id)
{
return Result.Success(_emeterMinutesEnergyService.DeleteById(id));
diff --git a/WebStarter/Controllers/System/BatteryOpModelController.cs b/WebStarter/Controllers/System/BatteryOpModelController.cs
new file mode 100644
index 0000000..963b697
--- /dev/null
+++ b/WebStarter/Controllers/System/BatteryOpModelController.cs
@@ -0,0 +1,81 @@
+using System.ComponentModel.DataAnnotations;
+using Entity.Base;
+using Entity.DbModel.Station;
+using Entity.DbModel.System;
+using Entity.Dto.Req;
+using HybirdFrameworkCore.Entity;
+using Microsoft.AspNetCore.Mvc;
+using Service.Station;
+
+namespace WebStarter.Controllers.System;
+
+///
+/// 电池运营模型
+///
+[ApiController]
+[Route("api/[controller]")]
+public class BatteryOpModelController
+{
+ private readonly BatteryOpModelService _batteryOpModelService;
+
+ public BatteryOpModelController(BatteryOpModelService batteryOpModelService)
+ {
+ _batteryOpModelService = batteryOpModelService;
+ }
+
+ ///
+ /// 获取电池运营模型分页列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("page")]
+ public async Task> BatteryOpModelPageList([FromBody] PageBatteryOpReq input)
+ {
+ return await _batteryOpModelService.Page(input);
+ }
+
+ ///
+ /// 增加电池运营模型
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("add")]
+ public async Task> AddBatteryOpModel([FromBody] AddBatteryOpReq input)
+ {
+ var data = await _batteryOpModelService.AddBatteryOpModel(input);
+ return Result.Success(data);
+ }
+
+ ///
+ /// 更新电池运营模型
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("update")]
+ public async Task> UpdateBatteryOpModel([FromBody] UpdateBatteryOpReq batteryOpReq)
+ {
+ var data = await _batteryOpModelService.UpdateBatteryOpModel(batteryOpReq);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+ ///
+ /// 删除电池运营模型
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("delete")]
+ public async Task> DeleteBatteryOpModel([FromBody][Required] DeleteBatteryOpReq input)
+ {
+ var data = await _batteryOpModelService.DeleteBatteryOpModel(input);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/db/lxw0527.sql b/WebStarter/db/lxw0527.sql
index 9af8554..4e55d7c 100644
--- a/WebStarter/db/lxw0527.sql
+++ b/WebStarter/db/lxw0527.sql
@@ -2,4 +2,5 @@
alter table bin_info add column cache_bin_flag int(1) DEFAULT 0 COMMENT "0:不是 1:是" ;
-- 添加充电模式控制
ALTER TABLE equip_info ADD auto_charge INT DEFAULT 0 COMMENT "0-手动;1-自动充电" ;
-
+-- 添加换电类型
+ALTER TABLE swap_order ADD swap_type INT DEFAULT 0 COMMENT "换电类型:;0手动换电;1自动换电" ;