|
|
|
@ -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;
|
|
|
|
@ -38,18 +39,52 @@ public class MonitorService
|
|
|
|
|
public PlcTaskMgr PlcTaskMgr { get; set; }
|
|
|
|
|
|
|
|
|
|
public MoveBinRecordRepository MoveBinRecordRepository { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
RefAsync<int> total = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var items = await MoveBinRecordRepository.QueryPageAsync(
|
|
|
|
|
entity => true,
|
|
|
|
|
entity => true,
|
|
|
|
|
!string.IsNullOrWhiteSpace(input.UpBatterySoc), u => u.UpBatterySoc.Equals(input.UpBatterySoc.Trim()),
|
|
|
|
|
!string.IsNullOrWhiteSpace(input.UpBinNo), u => u.UpBinNo.Equals(input.UpBinNo.Trim()),
|
|
|
|
|
!string.IsNullOrWhiteSpace(input.UpBatteryNo), u => u.UpBatteryNo.Equals(input.UpBatteryNo.Trim()),
|
|
|
|
@ -62,21 +97,22 @@ public class MonitorService
|
|
|
|
|
Rows = items,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string> Add(AddMoveBinRecordReq input)
|
|
|
|
|
{
|
|
|
|
|
string result = "";
|
|
|
|
|
|
|
|
|
|
MoveBinRecord moveBinRecord = await MoveBinRecordRepository.InsertAsync(input);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "新增id:" + moveBinRecord.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> Update(UpdateMoveBinRecordReq Req)
|
|
|
|
|
{
|
|
|
|
|
return await MoveBinRecordRepository.UpdateAsync(Req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<bool> Delete(DeleteMoveBinRecordReq input)
|
|
|
|
|
{
|
|
|
|
|
var user = await MoveBinRecordRepository.QueryByClauseAsync(u => u.Id == input.Id);
|
|
|
|
@ -84,27 +120,28 @@ public class MonitorService
|
|
|
|
|
throw new ArgumentException($"不存在");
|
|
|
|
|
return await MoveBinRecordRepository.DeleteAsync(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result<SwapMonitorScreenResp> GetSwapMonitorData()
|
|
|
|
|
{
|
|
|
|
|
var configBinInfo =
|
|
|
|
|
new MapperConfiguration(cfg => cfg.CreateMap<StepModel, SwappingStateInfoResp>().ReverseMap());
|
|
|
|
|
IMapper mapperBinInfo = configBinInfo.CreateMapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SwappingStateInfoResp> stateInfoList = new List<SwappingStateInfoResp>();
|
|
|
|
|
ConcurrentDictionary<string, StepModel> dictionary = StationSoftMgr.SwappingStateMachine.StepModel;
|
|
|
|
|
stateInfoList = dictionary.Values
|
|
|
|
|
.OrderBy(model => model.StepNo)
|
|
|
|
|
.Select(model => mapperBinInfo.Map<SwappingStateInfoResp>(model))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tboxCarInfoModel = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel;
|
|
|
|
|
|
|
|
|
|
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.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)
|
|
|
|
|
{
|
|
|
|
@ -296,4 +336,4 @@ public class MonitorService
|
|
|
|
|
|
|
|
|
|
return Result<List<BinInfoResp>>.Success(mapperBinInfo.Map<List<BinInfoResp>>(queryListByClause));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|