取消换电功能修改,rfid写入,手动新增换电记录修改

master
tq 2 months ago
parent 4dc6f56c89
commit b3b36d93e4

@ -126,7 +126,7 @@
/// <summary>
/// 换电电池
/// </summary>
public List<SwapOrderBatteryReq> batteryList { get; set; }
public List<SwapOrderBatteryReq>? batteryList { get; set; }
/// <summary>
/// 电费
@ -142,5 +142,32 @@
/// 总费用(所有的总费用)
/// </summary>
public decimal? TotalFee { get; set; }
/// <summary>
/// Desc:满电包soc
/// Default:
/// Nullable:True
/// </summary>
public decimal? UpBatterySoc { get; set; }
/// <summary>
/// 满电包电池标称能量
/// </summary>
public decimal? UpNominalEnergy { get; set; }
/// <summary>
/// Desc:亏电包soc
/// Default:
/// Nullable:True
/// </summary>
public decimal? DownBatterySoc { get; set; }
/// <summary>
/// 亏电池标称能量
/// </summary>
public decimal? DownNominalEnergy { get; set; }
}
}

@ -10,7 +10,6 @@ public class OperateModelReq
/// <summary>
/// 操作人员名称
/// </summary>
[Required]
public string? Operator { get; set; }
/// <summary>

@ -0,0 +1,15 @@
namespace Entity.Api.Req;
/// <summary>
/// rfid写入req
/// </summary>
public class RfidWriteReq
{ /// <summary>
/// 车牌号
/// </summary>
public string VehicleNo { get; set; }
/// <summary>
/// vin
/// </summary>
public string VehicleVin { get; set; }
}

@ -0,0 +1,37 @@
using SqlSugar;
namespace Entity.DbModel.Station;
/// <summary>
/// 换电失败原因配置表
/// </summary>
[SugarTable("swap_fail_reason_config")]
public class SwapFailReasonConfig : BaseModel
{
public SwapFailReasonConfig()
{
}
/// <summary>
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// Desc:异常原因
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "fail_reason")]
public string FailReason { get; set; }
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "remark")]
public string Remark { get; set; }
}

@ -149,5 +149,12 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "total_fee")]
public decimal? TotalFee { get; set; }
/// <summary>
/// Desc:备注
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(ColumnName = "remark")]
public string Remark { get; set; }
}
}

@ -0,0 +1,21 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
namespace Entity.Dto.Req;
public class PageSwapFailReasonConfigReq : QueryPageModel
{
public string? FailReason { get; set; }
}
public class AddSwapFailReasonConfigReq : SwapFailReasonConfig
{
}
public class UpdateSwapFailReasonConfigReq : AddSwapFailReasonConfigReq
{
}
public class DeleteSwapFailReasonConfigpReq : BaseIdReq
{
}

@ -0,0 +1,16 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using SqlSugar;
namespace Repository.Station;
[Scope("SingleInstance")]
public class SwapFailReasonConfigRepository : BaseRepository<SwapFailReasonConfig>
{
private static readonly ILog _log = LogManager.GetLogger(typeof(SwapFailReasonConfigRepository));
public SwapFailReasonConfigRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}

@ -16,6 +16,36 @@ public class RfidApi
Timeout = TimeSpan.FromSeconds(60)
};
public static async Task<bool> BeginWriteAsync(string vehicleNo, string vin)
{
if (string.IsNullOrWhiteSpace(vehicleNo) || string.IsNullOrWhiteSpace(vin))
{
Log.Error("Vehicle number or VIN cannot be null or empty.");
return false;
}
string requestPath = $"{BASE_URL}/Api/BeginWrite/{vehicleNo};{vin}";
Log.Info($"BeginWrite request to: {requestPath}");
try
{
string response = await _httpClient.GetStringAsync(requestPath);
return response.Equals("true", StringComparison.OrdinalIgnoreCase);
}
catch (HttpRequestException httpEx)
{
Log.Error($"HTTP request error during BeginWrite: {httpEx.Message}");
}
catch (Exception ex)
{
Log.Error($"Unexpected error during BeginWrite: {ex.Message}");
}
return false;
}
public static async Task<bool> BeginRead()
{
// var disConnect =await DisConnect();

@ -0,0 +1,64 @@
using Entity.DbModel.Station;
using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using log4net;
using Repository.Station;
using SqlSugar;
namespace Service.Station;
[Scope("SingleInstance")]
public class SwapFailReasonConfigService : BaseServices<SwapFailReasonConfig>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(SwapFailReasonConfigService));
private SwapFailReasonConfigRepository _swapFailReasonConfigRepository;
public SwapFailReasonConfigService(SwapFailReasonConfigRepository swapFailReasonConfigRepository)
{
_swapFailReasonConfigRepository = swapFailReasonConfigRepository;
BaseDal = swapFailReasonConfigRepository;
}
public async Task<PageResult<SwapFailReasonConfig>> Page(PageSwapFailReasonConfigReq input)
{
RefAsync<int> total = 0;
var items = await _swapFailReasonConfigRepository.QueryPageAsync(
entity => true,
false, entity => true,
false, entity => true,
input.FailReason != null, (u => input.FailReason != null && u.FailReason.Equals(input.FailReason)),
u => u.CreatedTime, input.PageNum, input.PageSize, total
);
return new PageResult<SwapFailReasonConfig>()
{
PageNum = input.PageNum,
PageSize = input.PageSize,
ToTal = total,
Rows = items,
};
}
public async Task<string> Add(AddSwapFailReasonConfigReq input)
{
SwapFailReasonConfig swapFailReasonConfig = await _swapFailReasonConfigRepository.InsertAsync(input);
return "新增id" + swapFailReasonConfig.Id;
}
public virtual async Task<bool> Update(UpdateSwapFailReasonConfigReq req)
{
return await _swapFailReasonConfigRepository.UpdateAsync(req);
}
public virtual async Task<bool> Delete(DeleteSwapFailReasonConfigpReq input)
{
var user = await _swapFailReasonConfigRepository.QueryByClauseAsync(u => u.Id == input.Id);
if (user == null)
throw new ArgumentException($"电池异常原因不存在");
return await _swapFailReasonConfigRepository.DeleteAsync(user);
}
}

@ -0,0 +1,45 @@
using Entity.Api.Req;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Charger.Client;
using Service.Execute.Api;
using Service.Execute.Model;
namespace WebStarter.Controllers;
/// <summary>
/// rfid读取
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class RfidController : ControllerBase
{
/// <summary>
/// rfid写
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("BeginWrite")]
public async Task<Result<bool>> BeginWrite([FromBody] RfidWriteReq req)
{
await RfidApi.BeginWriteAsync(req.VehicleNo,req.VehicleVin);
return Result<bool>.Success(true, "发送成功");
}
/// <summary>
/// 读rfid
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("ReadRfid")]
public async Task<Result<RfidReadModel>> ReadRfid()
{
// RfidReadModel? rfidReadModel = await RfidApi.ReadRfid();
RfidReadModel rfidReadModel = new RfidReadModel();
rfidReadModel.VelNo = "123";
rfidReadModel.VelVin = "123";
if (rfidReadModel != null) return Result<RfidReadModel>.Success(rfidReadModel, "读取成功");
return Result<RfidReadModel>.Fail();
}
}

@ -0,0 +1,97 @@
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;
/// <summary>
/// 换电异常原因配置
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class SwapFailReasonConfigController
{
private readonly SwapFailReasonConfigService _swapFailReasonConfigService;
/// <summary>
/// 换电异常原因配置
/// </summary>
/// <param name="swapFailReasonConfig"></param>
public SwapFailReasonConfigController(SwapFailReasonConfigService swapFailReasonConfig)
{
_swapFailReasonConfigService = swapFailReasonConfig;
}
/// <summary>
/// 换电异常原因配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<Result<PageResult<SwapFailReasonConfig>>> BatteryOpModelPageList(
[FromBody] PageSwapFailReasonConfigReq input)
{
return Result<PageResult<SwapFailReasonConfig>>.Success(await _swapFailReasonConfigService.Page(input));
}
/// <summary>
/// 获取异常原因列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("GetList")]
public async Task<Result<List<SwapFailReasonConfig>>> GetList()
{
return Result<List<SwapFailReasonConfig>>.Success(await _swapFailReasonConfigService.QueryAsync());
}
/// <summary>
/// 添加换电异常原因配置
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("add")]
public async Task<Result<string>> Add([FromBody] AddSwapFailReasonConfigReq input)
{
var data = await _swapFailReasonConfigService.Add(input);
return Result<string>.Success(data);
}
/// <summary>
/// 修改换电异常原因配置
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("update")]
public async Task<Result<bool>> Update([FromBody] UpdateSwapFailReasonConfigReq req)
{
var data = await _swapFailReasonConfigService.Update(req);
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>> Delete([FromBody] [Required] DeleteSwapFailReasonConfigpReq input)
{
var data = await _swapFailReasonConfigService.Delete(input);
if (data)
return Result<bool>.Success(data);
else
return Result<bool>.Fail(data);
}
}

@ -7,6 +7,7 @@ using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Repository.Station;
using Service.Execute;
using Service.Execute.Api;
using Service.Execute.Model;
@ -26,11 +27,13 @@ public class SwapMonitorController : ControllerBase
private readonly MonitorService _swapMonitorService;
private readonly BinInfoService _binInfoService;
private readonly IStringLocalizer<SwapMonitorController> _localizer;
public readonly SwapOrderRepository _swapOrderRepository;
public SwapMonitorController(MonitorService swapMonitorService, BinInfoService binInfoService)
public SwapMonitorController(MonitorService swapMonitorService, BinInfoService binInfoService,SwapOrderRepository swapOrderRepository)
{
_swapMonitorService = swapMonitorService;
_binInfoService = binInfoService;
_swapOrderRepository = swapOrderRepository;
}
@ -181,6 +184,15 @@ public class SwapMonitorController : ControllerBase
}
else
{
SwapOrder? swapOrder = StationSoftMgr.SwappingStateMachine.SwapOrder;
if (swapOrder!=null)
{
if (req.Reason != null)
{
swapOrder.Remark = req.Reason;
_swapOrderRepository.Update(swapOrder);
}
}
Task.Run(StationSoftMgr.SwappingStateMachineCancel);
}

@ -265,21 +265,19 @@ public class SwapOrderController : ControllerBase
swapOrder.CloudReportStatus = 0;
SwapOrder order = await swapOrderService.InsertAsync(swapOrder);
bool batteriesInserted = true;
if (req.batteryList.Any())
{
// 绑定订单
List<SwapOrderBattery> swapOrderBatteries = mapper.Map<List<SwapOrderBattery>>(req.batteryList);
foreach (var swapOrderBattery in swapOrderBatteries)
{
swapOrderBattery.SwapOrderSn = swapOrder.Sn;
}
batteriesInserted = await swapOrderBatteryService.InsertAsync(swapOrderBatteries);
}
// 绑定电池
var swapOrderBattery = new SwapOrderBattery
{
SwapOrderSn = swapOrder.Sn,
UpBatterySoc = req.UpBatterySoc,
UpNominalEnergy = req.UpNominalEnergy,
DownBatterySoc = req.DownBatterySoc,
DownNominalEnergy = req.DownNominalEnergy,
SettleAnAccountFlag = 0
};
SwapOrderBattery swapOrderBatteryResult = await swapOrderBatteryService.InsertAsync(swapOrderBattery);
if (order != null && batteriesInserted)
if (order != null && swapOrderBatteryResult !=null)
{
// 提交
transactionScope.Complete();

@ -0,0 +1,39 @@
/*
Navicat Premium Dump SQL
Source Server : 180.76.133.253
Source Server Type : MySQL
Source Server Version : 80039 (8.0.39-0ubuntu0.22.04.1)
Source Host : 180.76.133.253:16306
Source Schema : eaxing_dev
Target Server Type : MySQL
Target Server Version : 80039 (8.0.39-0ubuntu0.22.04.1)
File Encoding : 65001
Date: 28/09/2024 10:06:28
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for swap_fail_reason_config
-- ----------------------------
DROP TABLE IF EXISTS `swap_fail_reason_config`;
CREATE TABLE `swap_fail_reason_config` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'id',
`fail_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '失败原因',
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
`created_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人',
`created_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人',
`updated_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '失败原因配置表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
ALTER TABLE swap_order
ADD COLUMN remark VARCHAR(255) DEFAULT NULL COMMENT '备注';
Loading…
Cancel
Save