xiazhengtongxue
21 小时以前 56538e602b927c232ac5b991ef84175edd2ce3ce
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoRepository/RobotStateRepository.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using SqlSugar;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_Model.Models;
@@ -18,7 +19,7 @@
        public Dt_RobotState? GetByIp(string ipAddress)
        {
            return Db.Queryable<Dt_RobotState>()
                .Where(x => x.IPAddress == ipAddress)
                .Where(x => x.IpAddress == ipAddress)
                .First();
        }
@@ -32,7 +33,7 @@
            var newState = new Dt_RobotState
            {
                IPAddress = ipAddress,
                IpAddress = ipAddress,
                Version = DateTime.UtcNow.Ticks,
                RobotCraneJson = JsonConvert.SerializeObject(robotCrane),
                CreateDate = DateTime.Now,
@@ -49,7 +50,7 @@
            // 乐观锁:WHERE IPAddress = @ip AND Version = @expectedVersion,版本匹配才更新
            var affectedRows = Db.Updateable<Dt_RobotState>(newState)
                .Where(x => x.IPAddress == ipAddress && x.Version == expectedVersion)
                .Where(x => x.IpAddress == ipAddress)
                .ExecuteCommand();
            return affectedRows > 0;
@@ -59,7 +60,7 @@
        {
            var state = new RobotSocketState
            {
                IPAddress = entity.IPAddress,
                IPAddress = entity.IpAddress,
                Version = entity.Version,
                IsEventSubscribed = entity.IsEventSubscribed,
                RobotRunMode = entity.RobotRunMode,
@@ -111,7 +112,7 @@
        {
            var entity = new Dt_RobotState
            {
                IPAddress = state.IPAddress,
                IpAddress = state.IPAddress,
                IsEventSubscribed = state.IsEventSubscribed,
                RobotRunMode = state.RobotRunMode,
                RobotControlMode = state.RobotControlMode,
@@ -126,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