From f423e1277f91427f0a767bd1224c1260dcb73086 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 20 四月 2026 22:47:54 +0800
Subject: [PATCH] feat: 添加空箱入库功能及相关优化
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs | 44 ++++++++++++++++++--------------------------
1 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
index d282af4..66e8fe1 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using SqlSugar;
using WIDESEAWCS_Core.BaseRepository;
-using WIDESEAWCS_Core.UnitOfWork;
+using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_Model.Models;
@@ -10,20 +10,15 @@
/// <summary>
/// 鏈烘鎵嬬姸鎬� SqlSugar 浠撳偍瀹炵幇
/// </summary>
- public class RobotStateRepository : IUnitOfWork, IRobotStateRepository
+ public class RobotStateRepository : RepositoryBase<Dt_RobotState>, IRobotStateRepository
{
- private readonly IUnitOfWorkManage _unitOfWork;
- private readonly SqlSugarClient _db;
-
- public RobotStateRepository(IUnitOfWorkManage unitOfWork)
+ public RobotStateRepository(IUnitOfWorkManage unitOfWork) : base(unitOfWork)
{
- _unitOfWork = unitOfWork;
- _db = unitOfWork.GetDbClient();
}
public Dt_RobotState? GetByIp(string ipAddress)
{
- return _db.Queryable<Dt_RobotState>()
+ return Db.Queryable<Dt_RobotState>()
.Where(x => x.IPAddress == ipAddress)
.First();
}
@@ -39,22 +34,23 @@
var newState = new Dt_RobotState
{
IPAddress = ipAddress,
+ Version = DateTime.UtcNow.Ticks,
RobotCraneJson = JsonConvert.SerializeObject(robotCrane),
- CreateTime = DateTime.Now,
- UpdateTime = DateTime.Now
+ CreateDate = DateTime.Now,
+ ModifyDate = DateTime.Now
};
- _db.Insertable(newState).ExecuteCommand();
+ Db.Insertable(newState).ExecuteCommand();
return newState;
}
- public bool TryUpdate(string ipAddress, Dt_RobotState newState, byte[] expectedRowVersion)
+ public bool TryUpdate(string ipAddress, Dt_RobotState newState, long expectedVersion)
{
- newState.UpdateTime = DateTime.Now;
+ newState.ModifyDate = DateTime.Now;
- var affectedRows = _db.Updateable<Dt_RobotState>(newState)
+ // 涔愯閿侊細WHERE IPAddress = @ip AND Version = @expectedVersion锛岀増鏈尮閰嶆墠鏇存柊
+ var affectedRows = Db.Updateable<Dt_RobotState>(newState)
.Where(x => x.IPAddress == ipAddress)
- .WhereRowVersion(x => x.RowVersion, expectedRowVersion)
.ExecuteCommand();
return affectedRows > 0;
@@ -65,7 +61,7 @@
var state = new RobotSocketState
{
IPAddress = entity.IPAddress,
- Version = BitConverter.ToInt64(entity.RowVersion.Length >= 8 ? entity.RowVersion.Take(8).ToArray() : new byte[8], 0),
+ Version = entity.Version,
IsEventSubscribed = entity.IsEventSubscribed,
RobotRunMode = entity.RobotRunMode,
RobotControlMode = entity.RobotControlMode,
@@ -131,7 +127,11 @@
CurrentBatchIndex = state.CurrentBatchIndex,
ChangePalletPhase = state.ChangePalletPhase,
IsScanNG = state.IsScanNG,
- BatteryArrived = state.BatteryArrived
+ BatteryArrived = state.BatteryArrived,
+ CellBarcodeJson = state.CellBarcode.ToJson(),
+ LastPickPositionsJson = state.LastPickPositions.ToJson(),
+ CurrentTaskJson = state.CurrentTask.ToJson(),
+ LastPutPositionsJson = state.LastPutPositions.ToJson(),
};
// 搴忓垪鍖栧鏉傚璞′负 JSON
@@ -162,13 +162,5 @@
return entity;
}
-
- public SqlSugarClient GetDbClient() => _db;
-
- public void BeginTran() => _unitOfWork.BeginTran();
-
- public void CommitTran() => _unitOfWork.CommitTran();
-
- public void RollbackTran() => _unitOfWork.RollbackTran();
}
}
--
Gitblit v1.9.3