日志记录

zw
rszn 5 months ago
parent dd5ec66a50
commit 71dc3f3979

@ -12,32 +12,32 @@ public class ManualOperationRecord : BaseModel
/// Desc:id
/// Default:
/// Nullable:False
/// </summary>
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
public int Id { get; set; }
/// <summary>
/// 换电订单
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "swap_order_sn")]
[SugarColumn( ColumnName = "swap_order_sn")]
public string? SwapOrderSn { get; set; }
/// <summary>
/// 原因
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "reason")]
[SugarColumn( ColumnName = "reason")]
public string? Reason { get; set; }
/// <summary>
/// 操作类型 1人工确认成功;2人工确认失败
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "type")]
[SugarColumn( ColumnName = "type")]
public int Type { get; set; }
/// <summary>
/// 操作人员
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "operator")]
[SugarColumn( ColumnName = "operator")]
public string? Operator { get; set; }
}
}

@ -19,52 +19,52 @@ public class MoveBinRecord : BaseModel
/// <summary>
/// in_bin_no
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "in_bin_no")]
[SugarColumn( ColumnName = "in_bin_no")]
public string? InBinNo { get; set; }
/// <summary>
/// in_battery_no
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "in_battery_no")]
[SugarColumn( ColumnName = "in_battery_no")]
public string? InBatteryNo { get; set; }
/// <summary>
/// in_battery_soc
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "in_battery_soc")]
[SugarColumn( ColumnName = "in_battery_soc")]
public string? InBatterySoc { get; set; }
/// <summary>
/// in_bin_no
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "up_bin_no")]
[SugarColumn( ColumnName = "up_bin_no")]
public string? UpBinNo { get; set; }
/// <summary>
/// in_battery_no
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "up_battery_no")]
[SugarColumn(ColumnName = "up_battery_no")]
public string? UpBatteryNo { get; set; }
/// <summary>
/// in_battery_soc
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "up_battery_soc")]
[SugarColumn( ColumnName = "up_battery_soc")]
public string? UpBatterySoc { get; set; }
/// <summary>
/// 狀態 0初始化 1進行中 2成功 3失敗
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "status")]
[SugarColumn( ColumnName = "status")]
public int Status { get; set; }
/// <summary>
/// 类型 0自动 1:手动
/// </summary>
[SugarColumn(IsPrimaryKey = true, ColumnName = "type")]
[SugarColumn( ColumnName = "type")]
public int Type { get; set; }
}

@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.115" />
</ItemGroup>

@ -2,6 +2,8 @@ using Entity.Constant;
using Entity.DbModel.Station;
using Entity.Dto;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Newtonsoft.Json;
using SqlSugar;
namespace Repository.Station;
@ -9,6 +11,7 @@ namespace Repository.Station;
[Scope("SingleInstance")]
public class BinInfoRepository : BaseRepository<BinInfo>
{
private static readonly ILog _log = LogManager.GetLogger(typeof(BinInfoRepository));
public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
@ -21,6 +24,7 @@ public class BinInfoRepository : BaseRepository<BinInfo>
/// <returns></returns>
public SelectPackDto SelectPack(int swapSoc, int swapFinishChargeTime, string upMoveNo)
{
_log.Info($"BinInfoRepository SelectPack swapSoc={swapSoc}, swapFinishChargeTime={swapFinishChargeTime},upMoveNo={upMoveNo}");
SelectPackDto selectPackDto = new()
{
SuccessFlag = false,
@ -29,22 +33,25 @@ public class BinInfoRepository : BaseRepository<BinInfo>
QueryListByClause(i => i.CanSwapFlag == 1 &&
i.Exists == 1 && i.Status == 1 && i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock,
"in_time asc");
_log.Info($"BinInfoRepository SelectPack list1={JsonConvert.SerializeObject(list)}");
// BinInfo? cacheBinBattery = ChooseCacheBinBattery(swapSoc);
if (list.Count <= 0)
{
_log.Info($"list1 return");
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.NoBattery;
return selectPackDto;
}
list = list.OrderBy(i => i.CacheBinFlag).ToList();
_log.Info($"BinInfoRepository SelectPack list2={JsonConvert.SerializeObject(list)}");
if (!string.IsNullOrWhiteSpace(upMoveNo))
{
list = list.Where(i => !upMoveNo.Equals(i.No) && (i.No != "" || i.No != "-1")).ToList();
_log.Info($"BinInfoRepository SelectPack list3={JsonConvert.SerializeObject(list)},upMoveNo={upMoveNo}");
}
list = list.Where(i => i.ChargeStatus == 2 || i.ChargeStatus == 4).ToList();
@ -55,7 +62,7 @@ public class BinInfoRepository : BaseRepository<BinInfo>
}
list = list.Where(i => i.Soc != null && i.Soc >= swapSoc).ToList();
list = list.Where(i => i.Soc != null &&i.Soc >= swapSoc).ToList();
if (list.Count <= 0)
{
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc;

@ -1,10 +1,14 @@
using Autofac;
using AutoMapper;
using Common.Util;
using Entity.Constant;
using Entity.DbModel.Station;
using Entity.Dto;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using NewLife.Serialization;
using Newtonsoft.Json;
using Repository.Station;
using Service.Execute.Api;
using Service.Execute.Model;
@ -18,6 +22,7 @@ namespace Service.Execute.Utils;
[Scope("SingleInstance")]
public class CommonMgr
{
private static readonly ILog _log = LogManager.GetLogger(typeof(CommonMgr));
public SwapOrderStepService _swapOrderStepService { get; set; }
public SwapOrderRepository _swapOrderRepository { get; set; }
@ -125,13 +130,14 @@ public class CommonMgr
{
SwapOrderBatteryInfo orderBatteryInfo = new SwapOrderBatteryInfo();
UpBin(orderBatteryInfo);
_log.Info($"UpBin orderBatteryInfo={JsonConvert.SerializeObject(orderBatteryInfo)}");
if (orderBatteryInfo.CanSwap != InfoEnum.SelectBinStatusInfo.Success)
{
return orderBatteryInfo;
}
InBin(orderBatteryInfo, machine);
_log.Info($"InBin orderBatteryInfo={JsonConvert.SerializeObject(orderBatteryInfo)}");
return orderBatteryInfo;
}
@ -168,27 +174,28 @@ public class CommonMgr
{
SelectPackDto selectPack =
_binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime,
queryMoveBinNo()[0]);
QueryMoveBinNo()[0]);
orderBatteryInfo.UpBinInfo = selectPack.BinInfo;
orderBatteryInfo.CanSwap = selectPack.Info;
}
private List<string> queryMoveBinNo()
private List<string> QueryMoveBinNo()
{
string moveUp = "";
string moveIn = "";
//当前有移仓任务
if (PlcMgr.PlcClient.ReadTaskNo() == 2)
if (PlcMgr.PlcClient?.ReadTaskNo() == 2)
{
MoveBinRecord queryByClause = MoveBinRecordRepository.QueryByClause(i => i.Status == 0 || i.Status == 1,
i => i.CreatedTime,
OrderByType.Desc);
if (queryByClause != null)
{
moveUp = queryByClause.UpBinNo;
moveIn = queryByClause.InBinNo;
moveUp = queryByClause?.UpBinNo;
moveIn = queryByClause?.InBinNo;
}
}
@ -216,7 +223,7 @@ public class CommonMgr
return;
}
var value = queryMoveBinNo()[1];
var value = QueryMoveBinNo()[1];
if (!string.IsNullOrWhiteSpace(value))
{
list = list.Where(i => i.No != value).ToList();

Loading…
Cancel
Save