diff --git a/Entity/Dto/Req/EquipInfoReq.cs b/Entity/Dto/Req/EquipInfoReq.cs new file mode 100644 index 0000000..82e18b7 --- /dev/null +++ b/Entity/Dto/Req/EquipInfoReq.cs @@ -0,0 +1,47 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Entity; + +namespace Entity.Dto.Req; + +/// +///设备信息表 +/// +public class EquipInfoReq +{ +} + +public class PageEquipInfoReq : QueryPageModel +{ + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + public string? Code { get; set; } + + /// + /// Desc:设备名称 + /// Default: + /// Nullable:True + /// + public string? Name { get; set; } + + /// + /// Desc:设备状态;0-未知;1-正常;2-报警;3-停用 + /// Default: + /// Nullable:True + /// + public int? Status { get; set; } +} + +public class AddEquipInfoReq : EquipInfo +{ +} + +public class UpdateEquipInfoReq : AddEquipInfoReq +{ +} + +public class DeleteEquipInfoReq : BaseIdReq +{ +} \ No newline at end of file diff --git a/Entity/Dto/Req/EquipNetInfoReq.cs b/Entity/Dto/Req/EquipNetInfoReq.cs new file mode 100644 index 0000000..ac75ef4 --- /dev/null +++ b/Entity/Dto/Req/EquipNetInfoReq.cs @@ -0,0 +1,47 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Entity; + +namespace Entity.Dto.Req; + +/// +///设备通信信息表 +/// +public class EquipNetInfoReq +{ +} + +public class PageEquipNetInfoReq : QueryPageModel +{ + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + public string? Code { get; set; } + + /// + /// Desc:连接地址 + /// Default: + /// Nullable:True + /// + public string? NetAddr { get; set; } + + /// + /// Desc:连接端口 + /// Default: + /// Nullable:True + /// + public string? NetPort { get; set; } +} + +public class AddEquipNetInfoReq : EquipNetInfo +{ +} + +public class UpdateEquipNetInfoReq : AddEquipNetInfoReq +{ +} + +public class DeleteEquipNetInfoReq : BaseIdReq +{ +} \ No newline at end of file diff --git a/Entity/Dto/SwapOrderDto.cs b/Entity/Dto/SwapOrderDto.cs index 692c23e..e2d25b7 100644 --- a/Entity/Dto/SwapOrderDto.cs +++ b/Entity/Dto/SwapOrderDto.cs @@ -46,7 +46,8 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [ExporterHeader(DisplayName = "车辆进场时间", IsBold = true,Width = 30, Format = "yyyy-MM-dd HH:mm:ss", AutoCenterColumn = true)] + [ExporterHeader(DisplayName = "车辆进场时间", IsBold = true, Width = 30, Format = "yyyy-MM-dd HH:mm:ss", + AutoCenterColumn = true)] public DateTime? VehicleEnterTime { get; set; } /// @@ -54,7 +55,8 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [ExporterHeader(DisplayName = "车辆离场时间", IsBold = true,Width = 30, Format = "yyyy-MM-dd HH:mm:ss", AutoCenterColumn = true)] + [ExporterHeader(DisplayName = "车辆离场时间", IsBold = true, Width = 30, Format = "yyyy-MM-dd HH:mm:ss", + AutoCenterColumn = true)] public DateTime? VehicleLeaveTime { get; set; } /// @@ -62,7 +64,8 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [ExporterHeader(DisplayName = "换电开始时间", IsBold = true,Width = 30, Format = "yyyy-MM-dd HH:mm:ss", AutoCenterColumn = true)] + [ExporterHeader(DisplayName = "换电开始时间", IsBold = true, Width = 30, Format = "yyyy-MM-dd HH:mm:ss", + AutoCenterColumn = true)] public DateTime? SwapBeginTime { get; set; } /// @@ -70,18 +73,18 @@ public class SwapOrderDto /// Default: /// Nullable:True /// - [ExporterHeader(DisplayName = "换电结束时间",Width = 30, Format = "yyyy-MM-dd HH:mm:ss", AutoCenterColumn = true)] + [ExporterHeader(DisplayName = "换电结束时间", Width = 30, Format = "yyyy-MM-dd HH:mm:ss", AutoCenterColumn = true)] public DateTime? SwapEndTime { get; set; } - + /// /// Desc:换电结果;0-未知;1-成功;2-失败 /// Default:0 /// Nullable:True /// [ExporterHeader(DisplayName = "换电结果", IsBold = true)] - public string SwapResultDisplay - { - get + public string SwapResultDisplay + { + get { return SwapResult switch { @@ -92,7 +95,7 @@ public class SwapOrderDto }; } } - + /// /// Desc:换电结果;0-未知;1-成功;2-失败 /// Default:0 @@ -110,7 +113,7 @@ public class SwapOrderDto [ExporterHeader(DisplayName = "失败原因", IsBold = true)] public string FailReason { get; set; } - + /// /// Desc:上传云平台状态;0-未上传;1-已上传 /// Default:0 @@ -129,11 +132,9 @@ public class SwapOrderDto }; } } - - // [ExporterHeader(DisplayName = "上传云平台状态", IsBold = true)] - [ExporterHeader(IsIgnore = true)] - public int? CloudReportStatus { get; set; } + // [ExporterHeader(DisplayName = "上传云平台状态", IsBold = true)] + [ExporterHeader(IsIgnore = true)] public int? CloudReportStatus { get; set; } /// @@ -141,7 +142,7 @@ public class SwapOrderDto /// [ExporterHeader(DisplayName = "云平台订单号", IsBold = true)] public string? CloudSn { get; set; } - + /// /// Desc:换电类型:;1自动换电;2手动换电 /// Default:0 @@ -160,6 +161,7 @@ public class SwapOrderDto }; } } + /// /// Desc:换电类型:;1自动换电;2手动换电 /// Default:0 @@ -167,9 +169,8 @@ public class SwapOrderDto /// [ExporterHeader(IsIgnore = true)] public int? SwapWay { get; set; } - - - + + /// /// Desc:亏电包soc /// Default: @@ -178,6 +179,7 @@ public class SwapOrderDto [ExporterHeader(DisplayName = "亏电包soc", IsBold = true)] public decimal? DownBatterySoc { get; set; } + /// /// Desc:亏电包真实soc /// Default: @@ -195,4 +197,40 @@ public class SwapOrderDto [ExporterHeader(DisplayName = "亏电包上次换电结算时soc", IsBold = true)] public decimal? DownBatteryLastSoc { get; set; } + + /// + /// Desc:亏电包编码 + /// Default: + /// Nullable:True + /// + [ExporterHeader(DisplayName = "亏电包编码", IsBold = true)] + + public string? DownBatteryNo { get; set; } + + /// + /// Desc:满电包编码 + /// Default: + /// Nullable:True + /// + [ExporterHeader(DisplayName = "满电包编码", IsBold = true)] + + public string? UpBatteryNo { get; set; } + + /// + /// Desc:满电包soc + /// Default: + /// Nullable:True + /// + [ExporterHeader(DisplayName = "满电包soc", IsBold = true)] + + public decimal? UpBatterySoc { get; set; } + + /// + /// Desc:满电包真实soc + /// Default: + /// Nullable:True + /// + [ExporterHeader(DisplayName = "满电包真实soc", IsBold = true)] + + public decimal? UpBatteryRealSoc { get; set; } } \ No newline at end of file diff --git a/Repository/Station/EquipInfoRepository.cs b/Repository/Station/EquipInfoRepository.cs index 740054b..8502be6 100644 --- a/Repository/Station/EquipInfoRepository.cs +++ b/Repository/Station/EquipInfoRepository.cs @@ -5,8 +5,10 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; +using Entity.Dto.Req; namespace Repository.Station { @@ -16,5 +18,23 @@ namespace Repository.Station public EquipInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) { } + + public async Task> EquipInfoQueryPageAsync( + bool isWhere1, Expression> expression1, + bool isWhere2, Expression> expression2, + bool isWhere3, Expression> expression3, + int pageNumber, int pageSize, RefAsync totalNumber, + PageEquipInfoReq input, bool blUseNoLock = false) + { + var page = await DbBaseClient + .Queryable() + .WhereIF(isWhere1, expression1) + .WhereIF(isWhere2, expression2) + .WhereIF(isWhere3, expression3) + .OrderBuilder(input) + .WithNoLockOrNot(blUseNoLock) + .ToPageListAsync(pageNumber, pageSize, totalNumber); + return page; + } } -} +} \ No newline at end of file diff --git a/Repository/Station/EquipNetInfoRepository.cs b/Repository/Station/EquipNetInfoRepository.cs new file mode 100644 index 0000000..6388812 --- /dev/null +++ b/Repository/Station/EquipNetInfoRepository.cs @@ -0,0 +1,33 @@ +using System.Linq.Expressions; +using Entity.DbModel.Station; +using Entity.Dto.Req; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Station; + +[Scope("SingleInstance")] +public class EquipNetInfoRepository : BaseRepository +{ + public EquipNetInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } + + public async Task> EquipNetInfoQueryPageAsync( + bool isWhere1, Expression> expression1, + bool isWhere2, Expression> expression2, + bool isWhere3, Expression> expression3, + int pageNumber, int pageSize, RefAsync totalNumber, + PageEquipNetInfoReq input, bool blUseNoLock = false) + { + var page = await DbBaseClient + .Queryable() + .WhereIF(isWhere1, expression1) + .WhereIF(isWhere2, expression2) + .WhereIF(isWhere3, expression3) + .OrderBuilder(input) + .WithNoLockOrNot(blUseNoLock) + .ToPageListAsync(pageNumber, pageSize, totalNumber); + return page; + } +} \ No newline at end of file diff --git a/Service/Station/EquipInfoService.cs b/Service/Station/EquipInfoService.cs index ec5f9e8..22a40f9 100644 --- a/Service/Station/EquipInfoService.cs +++ b/Service/Station/EquipInfoService.cs @@ -9,15 +9,96 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Entity.Dto.Req; +using HybirdFrameworkCore.Entity; +using Mapster; +using SqlSugar; namespace Service.Station { [Scope("SingleInstance")] public class EquipInfoService : BaseServices { + EquipInfoRepository _equipInfoRepository; + public EquipInfoService(EquipInfoRepository service) { + _equipInfoRepository = service; this.BaseDal = service; } + + /// + /// 获取设备信息分页 🔖 + /// + /// + /// + public async Task> Page(PageEquipInfoReq input) + { + RefAsync total = 0; + var items = await _equipInfoRepository.EquipInfoQueryPageAsync( + !string.IsNullOrEmpty(input.Name), u => u.Name.Contains(input.Name), + !string.IsNullOrEmpty(input.Code), u => u.Code.Contains(input.Code), + input.Status.HasValue, u => u.Status == input.Status, + input.PageNum, input.PageSize, total, input); + return new PageResult() + { + PageNum = input.PageNum, + PageSize = input.PageSize, + ToTal = total, + Rows = items, + }; + } + + /// + /// 增加设备信息🔖 + /// + /// + /// + public async Task AddEquipInfo(AddEquipInfoReq input) + { + string result = ""; + var isExist = + await _equipInfoRepository.QueryByClauseAsync(u => u.Name == input.Name || u.Code == input.Code); + if (isExist != null) + result = "已存在同名或同编码设备信息"; + EquipInfo insertAsync = await _equipInfoRepository.InsertAsync(input.Adapt()); + if (insertAsync.Id > 0) + result = "增加设备信息"; + return result; + } + + /// + /// 更新设备信息🔖 + /// + /// + /// + public async Task UpdateEquipInfo(UpdateEquipInfoReq input) + { + string result = ""; + var isExist = await _equipInfoRepository.QueryByClauseAsync(u => + (u.Name == input.Name || u.Code == input.Code) && u.Id != input.Id); + if (isExist != null) + result = "已存在同名或同编码设备信息"; + var config = input.Adapt(); + int updateResult = await _equipInfoRepository.UpdateAsync(config, true); + if (updateResult > 0) + result = "更新设备信息成功"; + return result; + } + + /// + /// 删除设备信息 🔖 + /// + /// + /// + public async Task DeleteEquipInfo(DeleteEquipInfoReq input) + { + string result = ""; + var config = await _equipInfoRepository.QueryByClauseAsync(u => u.Id == input.Id); + bool deleteResult = await _equipInfoRepository.DeleteAsync(config); + if (deleteResult) + result = "删除设备信息成功"; + return result; + } } -} +} \ No newline at end of file diff --git a/Service/Station/EquipNetInfoService.cs b/Service/Station/EquipNetInfoService.cs new file mode 100644 index 0000000..843c0e3 --- /dev/null +++ b/Service/Station/EquipNetInfoService.cs @@ -0,0 +1,94 @@ +using Entity.DbModel.Station; +using Entity.Dto.Req; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using Mapster; +using Repository.Station; +using SqlSugar; + +namespace Service.Station; + +[Scope("SingleInstance")] +public class EquipNetInfoService : BaseServices +{ + EquipNetInfoRepository _equipNetInfoRepository; + + public EquipNetInfoService(EquipNetInfoRepository service) + { + _equipNetInfoRepository = service; + } + + /// + /// 获取设备通信信息分页 🔖 + /// + /// + /// + public async Task> Page(PageEquipNetInfoReq input) + { + RefAsync total = 0; + var items = await _equipNetInfoRepository.EquipNetInfoQueryPageAsync( + !string.IsNullOrEmpty(input.Code), u => u.Code.Contains(input.Code), + !string.IsNullOrEmpty(input.NetAddr), u => u.NetAddr.Contains(input.NetAddr), + !string.IsNullOrEmpty(input.NetPort), u => u.NetPort.Equals(input.NetPort), + input.PageNum, input.PageSize, total, input); + return new PageResult() + { + PageNum = input.PageNum, + PageSize = input.PageSize, + ToTal = total, + Rows = items, + }; + } + + /// + /// 增加设备通信信息🔖 + /// + /// + /// + public async Task AddEquipNetInfo(AddEquipNetInfoReq input) + { + string result = ""; + var isExist = + await _equipNetInfoRepository.QueryByClauseAsync(u => u.Code == input.Code); + if (isExist != null) + result = "已存在同编码设备信息"; + EquipNetInfo insertAsync = await _equipNetInfoRepository.InsertAsync(input.Adapt()); + if (insertAsync.Id > 0) + result = "增加设备信息成功"; + return result; + } + + /// + /// 更新设备通信信息🔖 + /// + /// + /// + public async Task UpdateEquipNetInfo(UpdateEquipNetInfoReq input) + { + string result = ""; + var isExist = await _equipNetInfoRepository.QueryByClauseAsync(u => + (u.Code == input.Code) && u.Id != input.Id); + if (isExist != null) + result = "已存在同编码设备通信信息"; + var config = input.Adapt(); + int updateResult = await _equipNetInfoRepository.UpdateAsync(config, true); + if (updateResult > 0) + result = "更新设备通信信息成功"; + return result; + } + + /// + /// 删除设备通信信息 🔖 + /// + /// + /// + public async Task DeleteEquipNetInfo(DeleteEquipNetInfoReq input) + { + string result = ""; + var config = await _equipNetInfoRepository.QueryByClauseAsync(u => u.Id == input.Id); + bool deleteResult = await _equipNetInfoRepository.DeleteAsync(config); + if (deleteResult) + result = "成功删除设备通信"; + return result; + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/EquipInfoController.cs b/WebStarter/Controllers/EquipInfoController.cs new file mode 100644 index 0000000..f51df52 --- /dev/null +++ b/WebStarter/Controllers/EquipInfoController.cs @@ -0,0 +1,71 @@ +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 EquipInfoController +{ + private readonly EquipInfoService _equipInfoService; + + /// + /// 设备信息表 + /// + /// + public EquipInfoController(EquipInfoService equipInfoService) + { + _equipInfoService = equipInfoService; + } + + /// + /// 设备信息分页列表 + /// + /// + /// + [HttpPost] + [Route("page")] + public async Task>> Page(PageEquipInfoReq input) + { + return Result>.Success(await _equipInfoService.Page(input)); + } + + /// + /// 设备信息增加 + /// + /// + [HttpPost] + [Route("add")] + public async Task Add(AddEquipInfoReq input) + { + await _equipInfoService.AddEquipInfo(input); + } + + /// + /// 设备信息修改 + /// + /// + [HttpPost] + [Route("update")] + public async Task Update(UpdateEquipInfoReq input) + { + await _equipInfoService.UpdateEquipInfo(input); + } + + /// + /// 设备信息修改删除 + /// + /// + [HttpPost] + [Route("delete")] + public async Task Delete(DeleteEquipInfoReq input) + { + await _equipInfoService.DeleteEquipInfo(input); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/EquipNetInfoController.cs b/WebStarter/Controllers/EquipNetInfoController.cs new file mode 100644 index 0000000..a73e4fe --- /dev/null +++ b/WebStarter/Controllers/EquipNetInfoController.cs @@ -0,0 +1,71 @@ +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 EquipNetInfoController +{ + private readonly EquipNetInfoService _equipNetInfoService; + + /// + /// 设备通信信息表 + /// + /// + public EquipNetInfoController(EquipNetInfoService equipNetInfoService) + { + _equipNetInfoService = equipNetInfoService; + } + + /// + /// 设备通信分页列表 + /// + /// + /// + [HttpPost] + [Route("page")] + public async Task>> Page(PageEquipNetInfoReq input) + { + return Result>.Success(await _equipNetInfoService.Page(input)); + } + + /// + /// 设备通信增加 + /// + /// + [HttpPost] + [Route("add")] + public async Task Add(AddEquipNetInfoReq input) + { + await _equipNetInfoService.AddEquipNetInfo(input); + } + + /// + /// 设备通信修改 + /// + /// + [HttpPost] + [Route("update")] + public async Task Update(UpdateEquipNetInfoReq input) + { + await _equipNetInfoService.UpdateEquipNetInfo(input); + } + + /// + /// 设备通信修改删除 + /// + /// + [HttpPost] + [Route("delete")] + public async Task Delete(DeleteEquipNetInfoReq input) + { + await _equipNetInfoService.DeleteEquipNetInfo(input); + } +} \ No newline at end of file diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs index d4c9e3a..800d6f7 100644 --- a/WebStarter/Controllers/SwapOrderController.cs +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -46,10 +46,12 @@ public class SwapOrderController : ControllerBase //电池不要了 ////查询订单电池数据 - List< SwapOrderBattery> batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); + List batteryList = + swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); //映射 - var config = new MapperConfiguration(cfg => cfg.CreateMap ().ReverseMap()); + var config = + new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapper = config.CreateMapper(); List swapOrderBattery = mapper.Map>(batteryList); @@ -58,7 +60,8 @@ public class SwapOrderController : ControllerBase for (int i = 0; i < swapOrderResp.Rows.Count; i++) { swapOrderResp.Rows[i].BatteryList = new List(); - swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery.Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); + swapOrderResp.Rows[i].BatteryList.AddRange(swapOrderBattery + .Where(battery => battery.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); } //查询订单步序数据 @@ -160,7 +163,7 @@ public class SwapOrderController : ControllerBase bool orderUpdated = swapOrderService.Update(swapOrder); bool batteriesUpdated = true; - if ( req.batteryList.Any()) + if (req.batteryList.Any()) { // 绑定订单 List swapOrderBatteries = mapper.Map>(req.batteryList); @@ -194,15 +197,15 @@ public class SwapOrderController : ControllerBase { if (swapOrderService.DeleteByIds(ids)) { - return Result.Success(true,"删除成功"); + return Result.Success(true, "删除成功"); } else { return Result.Fail("删除失败"); } } - - + + /// /// 换电订单导出 /// @@ -244,6 +247,10 @@ public class SwapOrderController : ControllerBase dto.DownBatterySoc = swapOrderBatteryResp.DownBatterySoc; dto.DownBatteryRealSoc = swapOrderBatteryResp.DownBatteryRealSoc; dto.DownBatteryLastSoc = swapOrderBatteryResp.DownBatteryLastSoc; + dto.DownBatteryNo = swapOrderBatteryResp.DownBatteryNo; + dto.UpBatteryNo = swapOrderBatteryResp.UpBatteryNo; + dto.UpBatterySoc = swapOrderBatteryResp.UpBatterySoc; + dto.UpBatteryRealSoc = swapOrderBatteryResp.UpBatteryRealSoc; } } @@ -252,14 +259,14 @@ public class SwapOrderController : ControllerBase return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "换电订单.xlsx" }; } + /// /// 换电订单上报云端 /// /// [HttpGet("UploadCloud/{id}")] - public Result UploadCloud(int id) + public Result UploadCloud(int id) { - return swapOrderService.UploadCloud(id); } -} +} \ No newline at end of file