设备列表增加,订单导出优化

master
tq 5 months ago
parent 50290b82d7
commit b07f198b23

@ -0,0 +1,47 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
namespace Entity.Dto.Req;
///<summary>
///设备信息表
///</summary>
public class EquipInfoReq
{
}
public class PageEquipInfoReq : QueryPageModel
{
/// <summary>
/// Desc:设备编码
/// Default:
/// Nullable:True
/// </summary>
public string? Code { get; set; }
/// <summary>
/// Desc:设备名称
/// Default:
/// Nullable:True
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Desc:设备状态;0-未知1-正常2-报警3-停用
/// Default:
/// Nullable:True
/// </summary>
public int? Status { get; set; }
}
public class AddEquipInfoReq : EquipInfo
{
}
public class UpdateEquipInfoReq : AddEquipInfoReq
{
}
public class DeleteEquipInfoReq : BaseIdReq
{
}

@ -0,0 +1,47 @@
using Entity.DbModel.Station;
using HybirdFrameworkCore.Entity;
namespace Entity.Dto.Req;
///<summary>
///设备通信信息表
///</summary>
public class EquipNetInfoReq
{
}
public class PageEquipNetInfoReq : QueryPageModel
{
/// <summary>
/// Desc:设备编码
/// Default:
/// Nullable:True
/// </summary>
public string? Code { get; set; }
/// <summary>
/// Desc:连接地址
/// Default:
/// Nullable:True
/// </summary>
public string? NetAddr { get; set; }
/// <summary>
/// Desc:连接端口
/// Default:
/// Nullable:True
/// </summary>
public string? NetPort { get; set; }
}
public class AddEquipNetInfoReq : EquipNetInfo
{
}
public class UpdateEquipNetInfoReq : AddEquipNetInfoReq
{
}
public class DeleteEquipNetInfoReq : BaseIdReq
{
}

@ -46,7 +46,8 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[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; }
/// <summary>
@ -54,7 +55,8 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[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; }
/// <summary>
@ -62,7 +64,8 @@ public class SwapOrderDto
/// Default:
/// Nullable:True
/// </summary>
[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; }
/// <summary>
@ -131,9 +134,7 @@ public class SwapOrderDto
}
// [ExporterHeader(DisplayName = "上传云平台状态", IsBold = true)]
[ExporterHeader(IsIgnore = true)]
public int? CloudReportStatus { get; set; }
[ExporterHeader(IsIgnore = true)] public int? CloudReportStatus { get; set; }
/// <summary>
@ -160,6 +161,7 @@ public class SwapOrderDto
};
}
}
/// <summary>
/// Desc:换电类型:;1自动换电;2手动换电
/// Default:0
@ -169,7 +171,6 @@ public class SwapOrderDto
public int? SwapWay { get; set; }
/// <summary>
/// Desc:亏电包soc
/// Default:
@ -178,6 +179,7 @@ public class SwapOrderDto
[ExporterHeader(DisplayName = "亏电包soc", IsBold = true)]
public decimal? DownBatterySoc { get; set; }
/// <summary>
/// Desc:亏电包真实soc
/// Default:
@ -195,4 +197,40 @@ public class SwapOrderDto
[ExporterHeader(DisplayName = "亏电包上次换电结算时soc", IsBold = true)]
public decimal? DownBatteryLastSoc { get; set; }
/// <summary>
/// Desc:亏电包编码
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "亏电包编码", IsBold = true)]
public string? DownBatteryNo { get; set; }
/// <summary>
/// Desc:满电包编码
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "满电包编码", IsBold = true)]
public string? UpBatteryNo { get; set; }
/// <summary>
/// Desc:满电包soc
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "满电包soc", IsBold = true)]
public decimal? UpBatterySoc { get; set; }
/// <summary>
/// Desc:满电包真实soc
/// Default:
/// Nullable:True
/// </summary>
[ExporterHeader(DisplayName = "满电包真实soc", IsBold = true)]
public decimal? UpBatteryRealSoc { get; set; }
}

@ -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<List<EquipInfo>> EquipInfoQueryPageAsync(
bool isWhere1, Expression<Func<EquipInfo, bool>> expression1,
bool isWhere2, Expression<Func<EquipInfo, bool>> expression2,
bool isWhere3, Expression<Func<EquipInfo, bool>> expression3,
int pageNumber, int pageSize, RefAsync<int> totalNumber,
PageEquipInfoReq input, bool blUseNoLock = false)
{
var page = await DbBaseClient
.Queryable<EquipInfo>()
.WhereIF(isWhere1, expression1)
.WhereIF(isWhere2, expression2)
.WhereIF(isWhere3, expression3)
.OrderBuilder(input)
.WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber);
return page;
}
}
}

@ -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<EquipNetInfo>
{
public EquipNetInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
public async Task<List<EquipNetInfo>> EquipNetInfoQueryPageAsync(
bool isWhere1, Expression<Func<EquipNetInfo, bool>> expression1,
bool isWhere2, Expression<Func<EquipNetInfo, bool>> expression2,
bool isWhere3, Expression<Func<EquipNetInfo, bool>> expression3,
int pageNumber, int pageSize, RefAsync<int> totalNumber,
PageEquipNetInfoReq input, bool blUseNoLock = false)
{
var page = await DbBaseClient
.Queryable<EquipNetInfo>()
.WhereIF(isWhere1, expression1)
.WhereIF(isWhere2, expression2)
.WhereIF(isWhere3, expression3)
.OrderBuilder(input)
.WithNoLockOrNot(blUseNoLock)
.ToPageListAsync(pageNumber, pageSize, totalNumber);
return page;
}
}

@ -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<EquipInfo>
{
EquipInfoRepository _equipInfoRepository;
public EquipInfoService(EquipInfoRepository service)
{
_equipInfoRepository = service;
this.BaseDal = service;
}
/// <summary>
/// 获取设备信息分页 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageResult<EquipInfo>> Page(PageEquipInfoReq input)
{
RefAsync<int> 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<EquipInfo>()
{
PageNum = input.PageNum,
PageSize = input.PageSize,
ToTal = total,
Rows = items,
};
}
/// <summary>
/// 增加设备信息🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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<EquipInfo>());
if (insertAsync.Id > 0)
result = "增加设备信息";
return result;
}
/// <summary>
/// 更新设备信息🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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<EquipInfo>();
int updateResult = await _equipInfoRepository.UpdateAsync(config, true);
if (updateResult > 0)
result = "更新设备信息成功";
return result;
}
/// <summary>
/// 删除设备信息 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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;
}
}
}

@ -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<EquipNetInfo>
{
EquipNetInfoRepository _equipNetInfoRepository;
public EquipNetInfoService(EquipNetInfoRepository service)
{
_equipNetInfoRepository = service;
}
/// <summary>
/// 获取设备通信信息分页 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageResult<EquipNetInfo>> Page(PageEquipNetInfoReq input)
{
RefAsync<int> 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<EquipNetInfo>()
{
PageNum = input.PageNum,
PageSize = input.PageSize,
ToTal = total,
Rows = items,
};
}
/// <summary>
/// 增加设备通信信息🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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<EquipNetInfo>());
if (insertAsync.Id > 0)
result = "增加设备信息成功";
return result;
}
/// <summary>
/// 更新设备通信信息🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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<EquipNetInfo>();
int updateResult = await _equipNetInfoRepository.UpdateAsync(config, true);
if (updateResult > 0)
result = "更新设备通信信息成功";
return result;
}
/// <summary>
/// 删除设备通信信息 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<string> 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;
}
}

@ -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;
/// <summary>
/// 设备信息表
/// </summary>
[ApiController]
[Route("api/[controller]")]
public class EquipInfoController
{
private readonly EquipInfoService _equipInfoService;
/// <summary>
/// 设备信息表
/// </summary>
/// <param name="equipInfoService"></param>
public EquipInfoController(EquipInfoService equipInfoService)
{
_equipInfoService = equipInfoService;
}
/// <summary>
/// 设备信息分页列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<Result<PageResult<EquipInfo>>> Page(PageEquipInfoReq input)
{
return Result<PageResult<EquipInfo>>.Success(await _equipInfoService.Page(input));
}
/// <summary>
/// 设备信息增加
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("add")]
public async Task Add(AddEquipInfoReq input)
{
await _equipInfoService.AddEquipInfo(input);
}
/// <summary>
/// 设备信息修改
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("update")]
public async Task Update(UpdateEquipInfoReq input)
{
await _equipInfoService.UpdateEquipInfo(input);
}
/// <summary>
/// 设备信息修改删除
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("delete")]
public async Task Delete(DeleteEquipInfoReq input)
{
await _equipInfoService.DeleteEquipInfo(input);
}
}

@ -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;
///<summary>
///设备通信信息表
///</summary>
[ApiController]
[Route("api/[controller]")]
public class EquipNetInfoController
{
private readonly EquipNetInfoService _equipNetInfoService;
/// <summary>
/// 设备通信信息表
/// </summary>
/// <param name="equipNetInfoService"></param>
public EquipNetInfoController(EquipNetInfoService equipNetInfoService)
{
_equipNetInfoService = equipNetInfoService;
}
/// <summary>
/// 设备通信分页列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("page")]
public async Task<Result<PageResult<EquipNetInfo>>> Page(PageEquipNetInfoReq input)
{
return Result<PageResult<EquipNetInfo>>.Success(await _equipNetInfoService.Page(input));
}
/// <summary>
/// 设备通信增加
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("add")]
public async Task Add(AddEquipNetInfoReq input)
{
await _equipNetInfoService.AddEquipNetInfo(input);
}
/// <summary>
/// 设备通信修改
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("update")]
public async Task Update(UpdateEquipNetInfoReq input)
{
await _equipNetInfoService.UpdateEquipNetInfo(input);
}
/// <summary>
/// 设备通信修改删除
/// </summary>
/// <param name="input"></param>
[HttpPost]
[Route("delete")]
public async Task Delete(DeleteEquipNetInfoReq input)
{
await _equipNetInfoService.DeleteEquipNetInfo(input);
}
}

@ -46,10 +46,12 @@ public class SwapOrderController : ControllerBase
//电池不要了
////查询订单电池数据
List< SwapOrderBattery> batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
List<SwapOrderBattery> batteryList =
swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn));
//映射
var config = new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp,SwapOrderBattery > ().ReverseMap());
var config =
new MapperConfiguration(cfg => cfg.CreateMap<SwapOrderBatteryResp, SwapOrderBattery>().ReverseMap());
IMapper mapper = config.CreateMapper();
List<SwapOrderBatteryResp> swapOrderBattery = mapper.Map<List<SwapOrderBatteryResp>>(batteryList);
@ -58,7 +60,8 @@ public class SwapOrderController : ControllerBase
for (int i = 0; i < swapOrderResp.Rows.Count; i++)
{
swapOrderResp.Rows[i].BatteryList = new List<SwapOrderBatteryResp>();
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());
}
//查询订单步序数据
@ -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,6 +259,7 @@ public class SwapOrderController : ControllerBase
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
{ FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "换电订单.xlsx" };
}
/// <summary>
/// 换电订单上报云端
/// </summary>
@ -259,7 +267,6 @@ public class SwapOrderController : ControllerBase
[HttpGet("UploadCloud/{id}")]
public Result<bool> UploadCloud(int id)
{
return swapOrderService.UploadCloud(id);
}
}
Loading…
Cancel
Save