电能统计接口修改,换电订单增加换电类型

master
tq 6 months ago
parent e98a740405
commit 40f23e6c74

@ -147,5 +147,12 @@ namespace Entity.DbModel.Station
/// </summary> /// </summary>
[SugarColumn(ColumnName = "cloud_sn")] [SugarColumn(ColumnName = "cloud_sn")]
public string? CloudSn { get; set; } public string? CloudSn { get; set; }
/// <summary>
/// Desc:换电类型:;0手动换电;1自动换电
/// Default:0
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "swap_type")]
public int? SwapType { get; set; }
} }
} }

@ -0,0 +1,30 @@
using Entity.DbModel.Station;
namespace Entity.Dto.Req
{
public class BatteryOpModelReq : BaseIdReq
{
}
public class PageBatteryOpReq : BasePageReq
{
/// <summary>
/// Desc:模型id
/// Default:
/// Nullable:True
/// </summary>
public int? ModelId { get; set; }
}
public class AddBatteryOpReq : BatteryOpModel
{
}
public class UpdateBatteryOpReq : AddBatteryOpReq
{
}
public class DeleteBatteryOpReq : BaseIdReq
{
}
}

@ -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<BatteryOpModel>
{
private BatteryOpModelRepository _batteryOpModelRepository;
public BatteryOpModelService(BatteryOpModelRepository dal)
{
_batteryOpModelRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 电池运营模型分页列表 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[DisplayName("获取电池运营模型分页列表")]
public async Task<SqlSugarPagedList<BatteryOpModel>> Page(PageBatteryOpReq input)
{
RefAsync<int> 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);
}
/// <summary>
/// 增加电池运营模型 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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;
}
/// <summary>
/// 更新电池运营模型 🔖
/// </summary>
/// <returns></returns>
public virtual async Task<bool> UpdateBatteryOpModel(UpdateBatteryOpReq batteryOpReq)
{
return await _batteryOpModelRepository.UpdateAsync(batteryOpReq);
}
/// <summary>
/// 删除电池运营模型 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<bool> DeleteBatteryOpModel(DeleteBatteryOpReq input)
{
var user = await _batteryOpModelRepository.QueryByClauseAsync(u => u.Id == input.Id);
if (user == null)
throw new ArgumentException($"电池运营模型不存在");
return await _batteryOpModelRepository.DeleteAsync(user);
}
}

@ -4,6 +4,7 @@ using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Service.Ammeter; using Service.Ammeter;
using Service.Station; using Service.Station;
using SqlSugar;
namespace WebStarter.Controllers.Ammeter namespace WebStarter.Controllers.Ammeter
{ {
@ -44,20 +45,35 @@ namespace WebStarter.Controllers.Ammeter
/// <summary> /// <summary>
/// 统计分析/电能表累计值信息 /// 统计分析/电能表累计值信息
/// </summary> /// </summary>
[HttpGet("TEgEmeterTotalEnergyValue/{Code}")] [HttpGet("/TEgEmeterTotalEnergyValue/{Code}")]
public async Task<Result<List<EmeterMinutesEnergy>>> GetNewEmeterMinutesEnergy(string Code) public async Task<Result<List<EmeterMinutesEnergy>>> GetNewEmeterMinutesEnergy(string Code)
{ {
return Result<List<EmeterMinutesEnergy>>.Success(await _emeterMinutesEnergyService.SqlQueryable( var query = @"
"SELECT t1.* \r\n" + SELECT t1.*
"FROM " +"( \r\n SELECT code, MAX(time) AS latest_time \r\n " + FROM
"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;")); 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<SugarParameter>
{
new SugarParameter("@Code", Code)
};
var result = await Task.Run(() => _emeterMinutesEnergyService.SqlQuery(query, parameters));
return Result<List<EmeterMinutesEnergy>>.Success(result);
} }
/// <summary> /// <summary>
/// 删除电能表累计值信息 /// 删除电能表累计值信息
/// </summary> /// </summary>
[HttpGet("TEgEmeterTotalEnergyValue/{id}")] [HttpGet("delete/TEgEmeterTotalEnergyValue/{id}")]
public Result<bool> DeleteOneEmeterMinutesEnergy(long id) public Result<bool> DeleteOneEmeterMinutesEnergy(long id)
{ {
return Result<bool>.Success(_emeterMinutesEnergyService.DeleteById(id)); return Result<bool>.Success(_emeterMinutesEnergyService.DeleteById(id));

@ -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;
/// <summary>
/// 电池运营模型
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class BatteryOpModelController
{
private readonly BatteryOpModelService _batteryOpModelService;
public BatteryOpModelController(BatteryOpModelService batteryOpModelService)
{
_batteryOpModelService = batteryOpModelService;
}
/// <summary>
/// 获取电池运营模型分页列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<SqlSugarPagedList<BatteryOpModel>> BatteryOpModelPageList([FromBody] PageBatteryOpReq input)
{
return await _batteryOpModelService.Page(input);
}
/// <summary>
/// 增加电池运营模型
/// </summary>
/// <param name ="input"></param >
/// <returns></returns >
[HttpPost]
[Route("add")]
public async Task<Result<string>> AddBatteryOpModel([FromBody] AddBatteryOpReq input)
{
var data = await _batteryOpModelService.AddBatteryOpModel(input);
return Result<string>.Success(data);
}
/// <summary>
/// 更新电池运营模型
/// </summary>
/// <param name="batteryOp"></param>
/// <returns></returns>
[HttpPost]
[Route("update")]
public async Task<Result<bool>> UpdateBatteryOpModel([FromBody] UpdateBatteryOpReq batteryOpReq)
{
var data = await _batteryOpModelService.UpdateBatteryOpModel(batteryOpReq);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
/// <summary>
/// 删除电池运营模型
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("delete")]
public async Task<Result<bool>> DeleteBatteryOpModel([FromBody][Required] DeleteBatteryOpReq input)
{
var data = await _batteryOpModelService.DeleteBatteryOpModel(input);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
}

@ -2,4 +2,5 @@
alter table bin_info add column cache_bin_flag int(1) DEFAULT 0 COMMENT "0不是 1:是" ; 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 equip_info ADD auto_charge INT DEFAULT 0 COMMENT "0-手动;1-自动充电" ;
-- 添加换电类型
ALTER TABLE swap_order ADD swap_type INT DEFAULT 0 COMMENT "换电类型:;0手动换电;1自动换电" ;

Loading…
Cancel
Save