日志记录

master
rszn 5 months ago
parent dd5ec66a50
commit 71dc3f3979

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

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

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

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

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

Loading…
Cancel
Save