From 71dc3f39799cc8459f728aa40bee7c709552aa7d Mon Sep 17 00:00:00 2001
From: rszn <645583145@qq.com>
Date: Sun, 30 Jun 2024 22:14:05 +0800
Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DbModel/Station/ManualOperationRecord.cs | 12 +++++------
Entity/DbModel/Station/MoveBinRecord.cs | 16 +++++++-------
Repository/Repository.csproj | 1 +
Repository/Station/BinInfoRepository.cs | 13 +++++++++---
Service/Execute/Mgr/CommonMgr.cs | 21 ++++++++++++-------
5 files changed, 39 insertions(+), 24 deletions(-)
diff --git a/Entity/DbModel/Station/ManualOperationRecord.cs b/Entity/DbModel/Station/ManualOperationRecord.cs
index 5570b20..bfbdf26 100644
--- a/Entity/DbModel/Station/ManualOperationRecord.cs
+++ b/Entity/DbModel/Station/ManualOperationRecord.cs
@@ -12,32 +12,32 @@ public class ManualOperationRecord : BaseModel
/// Desc:id
/// Default:
/// Nullable:False
- ///
+ ///
[SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
public int Id { get; set; }
///
/// 换电订单
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "swap_order_sn")]
+ [SugarColumn( ColumnName = "swap_order_sn")]
public string? SwapOrderSn { get; set; }
///
/// 原因
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "reason")]
+ [SugarColumn( ColumnName = "reason")]
public string? Reason { get; set; }
///
/// 操作类型 : 1人工确认成功;2人工确认失败
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "type")]
+ [SugarColumn( ColumnName = "type")]
public int Type { get; set; }
///
/// 操作人员
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "operator")]
+ [SugarColumn( ColumnName = "operator")]
public string? Operator { get; set; }
-}
\ No newline at end of file
+}
diff --git a/Entity/DbModel/Station/MoveBinRecord.cs b/Entity/DbModel/Station/MoveBinRecord.cs
index 301d650..efec7a3 100644
--- a/Entity/DbModel/Station/MoveBinRecord.cs
+++ b/Entity/DbModel/Station/MoveBinRecord.cs
@@ -19,52 +19,52 @@ public class MoveBinRecord : BaseModel
///
/// in_bin_no
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "in_bin_no")]
+ [SugarColumn( ColumnName = "in_bin_no")]
public string? InBinNo { get; set; }
///
/// in_battery_no
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "in_battery_no")]
+ [SugarColumn( ColumnName = "in_battery_no")]
public string? InBatteryNo { get; set; }
///
/// in_battery_soc
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "in_battery_soc")]
+ [SugarColumn( ColumnName = "in_battery_soc")]
public string? InBatterySoc { get; set; }
///
/// in_bin_no
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "up_bin_no")]
+ [SugarColumn( ColumnName = "up_bin_no")]
public string? UpBinNo { get; set; }
///
/// in_battery_no
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "up_battery_no")]
+ [SugarColumn(ColumnName = "up_battery_no")]
public string? UpBatteryNo { get; set; }
///
/// in_battery_soc
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "up_battery_soc")]
+ [SugarColumn( ColumnName = "up_battery_soc")]
public string? UpBatterySoc { get; set; }
///
/// 狀態 0:初始化 1:進行中 2:成功 3:失敗
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "status")]
+ [SugarColumn( ColumnName = "status")]
public int Status { get; set; }
///
/// 类型 0:自动 1:手动
///
- [SugarColumn(IsPrimaryKey = true, ColumnName = "type")]
+ [SugarColumn( ColumnName = "type")]
public int Type { get; set; }
}
diff --git a/Repository/Repository.csproj b/Repository/Repository.csproj
index 21979fd..e47b41c 100644
--- a/Repository/Repository.csproj
+++ b/Repository/Repository.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs
index 6c6b2fa..7a7f0b0 100644
--- a/Repository/Station/BinInfoRepository.cs
+++ b/Repository/Station/BinInfoRepository.cs
@@ -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
{
+ private static readonly ILog _log = LogManager.GetLogger(typeof(BinInfoRepository));
public BinInfoRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
@@ -21,6 +24,7 @@ public class BinInfoRepository : BaseRepository
///
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
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
}
- 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;
diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs
index 938b535..1b0f518 100644
--- a/Service/Execute/Mgr/CommonMgr.cs
+++ b/Service/Execute/Mgr/CommonMgr.cs
@@ -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 queryMoveBinNo()
+ private List 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();