|
|
|
@ -6,6 +6,7 @@ using Common.Util;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using Entity.Constant;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using Entity.Dto;
|
|
|
|
|
using Entity.Dto.Req;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
@ -42,6 +43,40 @@ public class MonitorService
|
|
|
|
|
|
|
|
|
|
public SwapOrderBatteryRepository _SwapOrderBatteryRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
public CommonMgr _CommonMgr { get; set; }
|
|
|
|
|
|
|
|
|
|
//可选仓位
|
|
|
|
|
public List<List<BinInfo>> CanSelectPackBin()
|
|
|
|
|
{
|
|
|
|
|
//出仓位
|
|
|
|
|
SelectPackDto selectPackDtoUpBin = BinInfoRepository.SelectPack(StaticStationInfo.SwapSoc,
|
|
|
|
|
StaticStationInfo.SwapFinishChargeTime,
|
|
|
|
|
"");
|
|
|
|
|
//入仓位
|
|
|
|
|
SelectPackDto selectPackInBin = BinInfoRepository.SelectPackInBin();
|
|
|
|
|
|
|
|
|
|
return new List<List<BinInfo>>()
|
|
|
|
|
{
|
|
|
|
|
selectPackDtoUpBin.CanSwapBinInfo, selectPackInBin.CanSwapBinInfo
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//手动选包
|
|
|
|
|
public Result<bool> SelectPackManual(int upBinId, int inBinId)
|
|
|
|
|
{
|
|
|
|
|
var upBin = BinInfoRepository.QueryById(upBinId);
|
|
|
|
|
var inBin = BinInfoRepository.QueryById(inBinId);
|
|
|
|
|
|
|
|
|
|
if (StationSoftMgr.SwappingStateMachine?.SwapOrderBatteryInfo == null)
|
|
|
|
|
{
|
|
|
|
|
StationSoftMgr.SwappingStateMachine!.SwapOrderBatteryInfo = new SwapOrderBatteryInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StationSoftMgr.SwappingStateMachine!.SwapOrderBatteryInfo.InBinInfo = inBin;
|
|
|
|
|
StationSoftMgr.SwappingStateMachine!.SwapOrderBatteryInfo.UpBinInfo = upBin;
|
|
|
|
|
return Result<bool>.Success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DisplayName("获取移仓分页")]
|
|
|
|
|
public async Task<PageResult<MoveBinRecord>> Page(PageMoveBinRecordReq input)
|
|
|
|
@ -71,6 +106,7 @@ public class MonitorService
|
|
|
|
|
|
|
|
|
|
return "新增id:" + moveBinRecord.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> Update(UpdateMoveBinRecordReq Req)
|
|
|
|
|
{
|
|
|
|
|
return await MoveBinRecordRepository.UpdateAsync(Req);
|
|
|
|
@ -84,6 +120,7 @@ public class MonitorService
|
|
|
|
|
throw new ArgumentException($"不存在");
|
|
|
|
|
return await MoveBinRecordRepository.DeleteAsync(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result<SwapMonitorScreenResp> GetSwapMonitorData()
|
|
|
|
|
{
|
|
|
|
|
var configBinInfo =
|
|
|
|
@ -104,7 +141,7 @@ public class MonitorService
|
|
|
|
|
List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1);
|
|
|
|
|
|
|
|
|
|
var plcSwapModel = new PlcSwapModelResp();
|
|
|
|
|
if(ClientMgr.PlcClient!=null)
|
|
|
|
|
if (ClientMgr.PlcClient != null)
|
|
|
|
|
{
|
|
|
|
|
plcSwapModel.ModelState = ClientMgr.PlcClient.Auto ? 1010 : 1000;
|
|
|
|
|
plcSwapModel.ControlModel = ClientMgr.PlcClient.Remote ? 1010 : 1000;
|
|
|
|
@ -115,30 +152,31 @@ public class MonitorService
|
|
|
|
|
monitorScreenResp.StateInfo = stateInfoList;
|
|
|
|
|
monitorScreenResp.VehicleInfo = new SwapVehicleResp();
|
|
|
|
|
monitorScreenResp.VehicleInfo.OrderNo = StationSoftMgr.SwappingStateMachine.SwapOrder != null
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.SwapOrder.Sn
|
|
|
|
|
: null;
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.SwapOrder.Sn
|
|
|
|
|
: null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac
|
|
|
|
|
: null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus?.LockStatus : null;
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac
|
|
|
|
|
: null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.LockStatus =
|
|
|
|
|
tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus?.LockStatus : null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus?.Keys : null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo
|
|
|
|
|
: null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin
|
|
|
|
|
: null;
|
|
|
|
|
? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin
|
|
|
|
|
: null;
|
|
|
|
|
monitorScreenResp.VehicleInfo.Break = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Break;
|
|
|
|
|
monitorScreenResp.VehicleInfo.Gear = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Gear;
|
|
|
|
|
monitorScreenResp.BatteryInfo = new();
|
|
|
|
|
monitorScreenResp.BatteryInfo.BatteryTotalCount = binInfos.Count;
|
|
|
|
|
monitorScreenResp.BatteryInfo.UsingSwapBatteryCount = binInfos.Select(i => i.ChargeStatus == 2 &&
|
|
|
|
|
i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock &&
|
|
|
|
|
i.Soc > StaticStationInfo.SwapSoc &&
|
|
|
|
|
new TimeSpan(DateTime.Now.Ticks -
|
|
|
|
|
i.LastChargeFinishTime.ToDateTime().Ticks)
|
|
|
|
|
.TotalMinutes >
|
|
|
|
|
StaticStationInfo.SwapFinishChargeTime).Count();
|
|
|
|
|
i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock &&
|
|
|
|
|
i.Soc > StaticStationInfo.SwapSoc &&
|
|
|
|
|
new TimeSpan(DateTime.Now.Ticks -
|
|
|
|
|
i.LastChargeFinishTime.ToDateTime().Ticks)
|
|
|
|
|
.TotalMinutes >
|
|
|
|
|
StaticStationInfo.SwapFinishChargeTime).Count();
|
|
|
|
|
|
|
|
|
|
if (monitorScreenResp.VehicleInfo.OrderNo != null)
|
|
|
|
|
{
|
|
|
|
@ -149,11 +187,14 @@ public class MonitorService
|
|
|
|
|
monitorScreenResp.VehicleInfo.DownBatteryBinNo = queryByClauseAsync.DownBatteryBinNo;
|
|
|
|
|
monitorScreenResp.VehicleInfo.UpBatteryBinNo = queryByClauseAsync.UpBatteryBinNo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monitorScreenResp.DeviceLogs = StationSoftMgr.DeviceLogs;
|
|
|
|
|
|
|
|
|
|
monitorScreenResp.RadarResp = new()
|
|
|
|
|
{
|
|
|
|
|
CarStatus = PadarMgr._PadarClient?.CarState
|
|
|
|
|
};
|
|
|
|
|
return Result<SwapMonitorScreenResp>.Success(monitorScreenResp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -187,10 +228,10 @@ public class MonitorService
|
|
|
|
|
DeviceStateResp resp = new()
|
|
|
|
|
{
|
|
|
|
|
BoxConnectFlag = isConnected,
|
|
|
|
|
// CloudConnectFlag = CloudClientMgr.CloudClient == null ? false : CloudClientMgr.CloudClient.Connected,
|
|
|
|
|
// CloudConnectFlag = CloudClientMgr.CloudClient == null ? false : CloudClientMgr.CloudClient.Connected,
|
|
|
|
|
PlcConnectFlag = ClientMgr.PlcClient != null && ClientMgr.PlcClient!.Connected,
|
|
|
|
|
RfidConnectFlag = StationSoftMgr.SwappingStateMachine!.RfidConnectFlag,
|
|
|
|
|
RadarConnectFlag =PadarMgr._PadarClient != null && PadarMgr._PadarClient!.Connected
|
|
|
|
|
RadarConnectFlag = PadarMgr._PadarClient != null && PadarMgr._PadarClient!.Connected
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Result<DeviceStateResp>.Success(resp);
|
|
|
|
@ -262,14 +303,13 @@ public class MonitorService
|
|
|
|
|
Type = type,
|
|
|
|
|
CreatedTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
moveBinRecord= MoveBinRecordRepository.Insert(moveBinRecord);
|
|
|
|
|
moveBinRecord = MoveBinRecordRepository.Insert(moveBinRecord);
|
|
|
|
|
|
|
|
|
|
//发送移仓任务
|
|
|
|
|
MoveCommandReq MoveCommandReq = new MoveCommandReq((byte)removeBinNo,(byte)putBinNo);
|
|
|
|
|
MoveCommandReq MoveCommandReq = new MoveCommandReq((byte)removeBinNo, (byte)putBinNo);
|
|
|
|
|
PlcServer PlcServer = new PlcServer();
|
|
|
|
|
PlcServer.SendMoveCommandReq(MoveCommandReq);
|
|
|
|
|
//TODO::判断任务是否执行
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|