diff --git a/Entity/Api/Req/AddSwapOrderReq.cs b/Entity/Api/Req/AddSwapOrderReq.cs
index b61e089..67d3d74 100644
--- a/Entity/Api/Req/AddSwapOrderReq.cs
+++ b/Entity/Api/Req/AddSwapOrderReq.cs
@@ -126,7 +126,7 @@
///
/// 换电电池
///
- public List batteryList { get; set; }
+ public List? batteryList { get; set; }
///
/// 电费
@@ -142,5 +142,32 @@
/// 总费用(所有的总费用)
///
public decimal? TotalFee { get; set; }
+
+
+ ///
+ /// Desc:满电包soc
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? UpBatterySoc { get; set; }
+
+ ///
+ /// 满电包电池标称能量
+ ///
+ public decimal? UpNominalEnergy { get; set; }
+
+
+ ///
+ /// Desc:亏电包soc
+ /// Default:
+ /// Nullable:True
+ ///
+ public decimal? DownBatterySoc { get; set; }
+
+
+ ///
+ /// 亏电池标称能量
+ ///
+ public decimal? DownNominalEnergy { get; set; }
}
}
diff --git a/Entity/Api/Req/OperateModelReq.cs b/Entity/Api/Req/OperateModelReq.cs
index 0267ef5..9e91771 100644
--- a/Entity/Api/Req/OperateModelReq.cs
+++ b/Entity/Api/Req/OperateModelReq.cs
@@ -10,7 +10,6 @@ public class OperateModelReq
///
/// 操作人员名称
///
- [Required]
public string? Operator { get; set; }
///
diff --git a/Entity/Api/Req/RfidWriteReq.cs b/Entity/Api/Req/RfidWriteReq.cs
new file mode 100644
index 0000000..a921548
--- /dev/null
+++ b/Entity/Api/Req/RfidWriteReq.cs
@@ -0,0 +1,15 @@
+namespace Entity.Api.Req;
+
+///
+/// rfid写入req
+///
+public class RfidWriteReq
+{ ///
+ /// 车牌号
+ ///
+ public string VehicleNo { get; set; }
+ ///
+ /// vin
+ ///
+ public string VehicleVin { get; set; }
+}
\ No newline at end of file
diff --git a/Entity/DbModel/Station/SwapFailReasonConfig.cs b/Entity/DbModel/Station/SwapFailReasonConfig.cs
new file mode 100644
index 0000000..eb9b88e
--- /dev/null
+++ b/Entity/DbModel/Station/SwapFailReasonConfig.cs
@@ -0,0 +1,37 @@
+using SqlSugar;
+
+namespace Entity.DbModel.Station;
+
+///
+/// 换电失败原因配置表
+///
+[SugarTable("swap_fail_reason_config")]
+public class SwapFailReasonConfig : BaseModel
+{
+ public SwapFailReasonConfig()
+ {
+ }
+ ///
+ /// Desc:id
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
+ public int Id { get; set; }
+
+ ///
+ /// Desc:异常原因
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "fail_reason")]
+ public string FailReason { get; set; }
+
+ ///
+ /// Desc:备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public string Remark { get; set; }
+}
\ No newline at end of file
diff --git a/Entity/DbModel/Station/SwapOrder.cs b/Entity/DbModel/Station/SwapOrder.cs
index e441260..b3157d9 100644
--- a/Entity/DbModel/Station/SwapOrder.cs
+++ b/Entity/DbModel/Station/SwapOrder.cs
@@ -149,5 +149,12 @@ namespace Entity.DbModel.Station
[SugarColumn(ColumnName = "total_fee")]
public decimal? TotalFee { get; set; }
+ ///
+ /// Desc:备注
+ /// Default:
+ /// Nullable:True
+ ///
+ [SugarColumn(ColumnName = "remark")]
+ public string Remark { get; set; }
}
}
\ No newline at end of file
diff --git a/Entity/Dto/Req/PageSwapFailReasonConfigReq.cs b/Entity/Dto/Req/PageSwapFailReasonConfigReq.cs
new file mode 100644
index 0000000..5f8cdf5
--- /dev/null
+++ b/Entity/Dto/Req/PageSwapFailReasonConfigReq.cs
@@ -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
+{
+}
\ No newline at end of file
diff --git a/Repository/Station/SwapFailReasonConfigRepository.cs b/Repository/Station/SwapFailReasonConfigRepository.cs
new file mode 100644
index 0000000..26eddf0
--- /dev/null
+++ b/Repository/Station/SwapFailReasonConfigRepository.cs
@@ -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
+{
+ private static readonly ILog _log = LogManager.GetLogger(typeof(SwapFailReasonConfigRepository));
+
+ public SwapFailReasonConfigRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
+ {
+ }
+}
\ No newline at end of file
diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs
index c84c8cf..983f8a7 100644
--- a/Service/Execute/Api/RfidApi.cs
+++ b/Service/Execute/Api/RfidApi.cs
@@ -16,6 +16,36 @@ public class RfidApi
Timeout = TimeSpan.FromSeconds(60)
};
+ public static async Task 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 BeginRead()
{
// var disConnect =await DisConnect();
diff --git a/Service/Station/SwapFailReasonConfigService.cs b/Service/Station/SwapFailReasonConfigService.cs
new file mode 100644
index 0000000..c211515
--- /dev/null
+++ b/Service/Station/SwapFailReasonConfigService.cs
@@ -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
+{
+ private static readonly ILog Log = LogManager.GetLogger(typeof(SwapFailReasonConfigService));
+
+ private SwapFailReasonConfigRepository _swapFailReasonConfigRepository;
+
+
+ public SwapFailReasonConfigService(SwapFailReasonConfigRepository swapFailReasonConfigRepository)
+ {
+ _swapFailReasonConfigRepository = swapFailReasonConfigRepository;
+ BaseDal = swapFailReasonConfigRepository;
+ }
+
+ public async Task> Page(PageSwapFailReasonConfigReq input)
+ {
+ RefAsync 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()
+ {
+ PageNum = input.PageNum,
+ PageSize = input.PageSize,
+ ToTal = total,
+ Rows = items,
+ };
+ }
+
+
+ public async Task Add(AddSwapFailReasonConfigReq input)
+ {
+ SwapFailReasonConfig swapFailReasonConfig = await _swapFailReasonConfigRepository.InsertAsync(input);
+ return "新增id:" + swapFailReasonConfig.Id;
+ }
+
+ public virtual async Task Update(UpdateSwapFailReasonConfigReq req)
+ {
+ return await _swapFailReasonConfigRepository.UpdateAsync(req);
+ }
+
+
+ public virtual async Task Delete(DeleteSwapFailReasonConfigpReq input)
+ {
+ var user = await _swapFailReasonConfigRepository.QueryByClauseAsync(u => u.Id == input.Id);
+ if (user == null)
+ throw new ArgumentException($"电池异常原因不存在");
+ return await _swapFailReasonConfigRepository.DeleteAsync(user);
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/RfidController.cs b/WebStarter/Controllers/RfidController.cs
new file mode 100644
index 0000000..19a0d48
--- /dev/null
+++ b/WebStarter/Controllers/RfidController.cs
@@ -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;
+
+///
+/// rfid读取
+///
+[ApiController]
+[Route("api/[controller]")]
+public class RfidController : ControllerBase
+{
+
+ ///
+ /// rfid写
+ ///
+ ///
+ [HttpPost]
+ [Route("BeginWrite")]
+ public async Task> BeginWrite([FromBody] RfidWriteReq req)
+ {
+ await RfidApi.BeginWriteAsync(req.VehicleNo,req.VehicleVin);
+ return Result.Success(true, "发送成功");
+ }
+
+ ///
+ /// 读rfid
+ ///
+ ///
+ [HttpPost]
+ [Route("ReadRfid")]
+ public async Task> ReadRfid()
+ {
+ // RfidReadModel? rfidReadModel = await RfidApi.ReadRfid();
+ RfidReadModel rfidReadModel = new RfidReadModel();
+ rfidReadModel.VelNo = "123";
+ rfidReadModel.VelVin = "123";
+ if (rfidReadModel != null) return Result.Success(rfidReadModel, "读取成功");
+ return Result.Fail();
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/SwapFailReasonConfigController.cs b/WebStarter/Controllers/SwapFailReasonConfigController.cs
new file mode 100644
index 0000000..ab12ce8
--- /dev/null
+++ b/WebStarter/Controllers/SwapFailReasonConfigController.cs
@@ -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;
+
+///
+/// 换电异常原因配置
+///
+[ApiController]
+[Route("api/[controller]")]
+public class SwapFailReasonConfigController
+{
+ private readonly SwapFailReasonConfigService _swapFailReasonConfigService;
+
+ ///
+ /// 换电异常原因配置
+ ///
+ ///
+ public SwapFailReasonConfigController(SwapFailReasonConfigService swapFailReasonConfig)
+ {
+ _swapFailReasonConfigService = swapFailReasonConfig;
+ }
+
+ ///
+ /// 换电异常原因配置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("page")]
+ public async Task>> BatteryOpModelPageList(
+ [FromBody] PageSwapFailReasonConfigReq input)
+ {
+ return Result>.Success(await _swapFailReasonConfigService.Page(input));
+ }
+
+ ///
+ /// 获取异常原因列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("GetList")]
+ public async Task>> GetList()
+ {
+ return Result>.Success(await _swapFailReasonConfigService.QueryAsync());
+ }
+
+ ///
+ /// 添加换电异常原因配置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("add")]
+ public async Task> Add([FromBody] AddSwapFailReasonConfigReq input)
+ {
+ var data = await _swapFailReasonConfigService.Add(input);
+ return Result.Success(data);
+ }
+
+ ///
+ /// 修改换电异常原因配置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("update")]
+ public async Task> Update([FromBody] UpdateSwapFailReasonConfigReq req)
+ {
+ var data = await _swapFailReasonConfigService.Update(req);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+
+ ///
+ /// 删除换电异常原因配置
+ ///
+ ///
+ ///
+ [HttpPost]
+ [Route("delete")]
+ public async Task> Delete([FromBody] [Required] DeleteSwapFailReasonConfigpReq input)
+ {
+ var data = await _swapFailReasonConfigService.Delete(input);
+ if (data)
+ return Result.Success(data);
+ else
+ return Result.Fail(data);
+ }
+}
\ No newline at end of file
diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs
index cfb484b..b8112c0 100644
--- a/WebStarter/Controllers/SwapMonitorController.cs
+++ b/WebStarter/Controllers/SwapMonitorController.cs
@@ -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 _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);
}
diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs
index 79480d9..4669200 100644
--- a/WebStarter/Controllers/SwapOrderController.cs
+++ b/WebStarter/Controllers/SwapOrderController.cs
@@ -265,21 +265,19 @@ public class SwapOrderController : ControllerBase
swapOrder.CloudReportStatus = 0;
SwapOrder order = await swapOrderService.InsertAsync(swapOrder);
- bool batteriesInserted = true;
-
- if (req.batteryList.Any())
+ // 绑定电池
+ var swapOrderBattery = new SwapOrderBattery
{
- // 绑定订单
- List swapOrderBatteries = mapper.Map>(req.batteryList);
- foreach (var swapOrderBattery in swapOrderBatteries)
- {
- swapOrderBattery.SwapOrderSn = swapOrder.Sn;
- }
-
- batteriesInserted = await swapOrderBatteryService.InsertAsync(swapOrderBatteries);
- }
+ 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();
diff --git a/WebStarter/db/0928新增异常原因配置表.sql b/WebStarter/db/0928新增异常原因配置表.sql
new file mode 100644
index 0000000..8a5be5c
--- /dev/null
+++ b/WebStarter/db/0928新增异常原因配置表.sql
@@ -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 '备注';
+