diff --git a/Entity/Api/Resp/DeviceStateResp.cs b/Entity/Api/Resp/DeviceStateResp.cs index 4747c85..28065b2 100644 --- a/Entity/Api/Resp/DeviceStateResp.cs +++ b/Entity/Api/Resp/DeviceStateResp.cs @@ -18,4 +18,15 @@ public class DeviceStateResp /// Plc连接状态 /// public bool PlcConnectFlag{ get; set; } + + + /// + /// rfid连接状态 + /// + public bool RfidConnectFlag { get; set; } + + /// + /// 雷达连接状态 + /// + public bool RadarConnectFlag { get; set; } } \ No newline at end of file diff --git a/Entity/Api/Resp/SwapDeviceLog.cs b/Entity/Api/Resp/SwapDeviceLog.cs new file mode 100644 index 0000000..089c762 --- /dev/null +++ b/Entity/Api/Resp/SwapDeviceLog.cs @@ -0,0 +1,38 @@ +namespace Service.Execute.Model; + + + +/** + * 换电设备通讯日志 + */ +public class SwapDeviceLog +{ + + /// + /// 1:雷达 2:rfid 3:tbox 4:plc + /// + public int Device { get; set; } + /// + /// 描述 + /// + public String desc { get; set; } + /// + /// 数据 + /// + public String Data { get; set; } + + + /// + /// 发生时间 + /// + public DateTime Time { get; set; } + + /// + /// 类型 1:发送 2:接受 + /// /// + public int Type { get; set; } + + + +} + diff --git a/Entity/Api/Resp/SwapMonitorScreenResp.cs b/Entity/Api/Resp/SwapMonitorScreenResp.cs index 5fa6714..d8b8204 100644 --- a/Entity/Api/Resp/SwapMonitorScreenResp.cs +++ b/Entity/Api/Resp/SwapMonitorScreenResp.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Service.Execute.Model; namespace Entity.Api.Resp; @@ -26,4 +27,9 @@ public class SwapMonitorScreenResp /// 电池数据 /// public BinBatteryResp? BatteryInfo { get; set; } + + /// + /// 换电设备业务日志 + /// + public Dictionary> DeviceLogs { get; set; } } \ No newline at end of file diff --git a/Entity/Api/Resp/SwapOrderResp.cs b/Entity/Api/Resp/SwapOrderResp.cs index c082a83..b36617f 100644 --- a/Entity/Api/Resp/SwapOrderResp.cs +++ b/Entity/Api/Resp/SwapOrderResp.cs @@ -174,5 +174,11 @@ namespace Entity.Api.Resp /// public int? TotalFee { get; set; } + /// + /// 手动操作 + /// + /// + public string? ManualStep { get; set; } + } } \ No newline at end of file diff --git a/Entity/Api/Resp/SwapOrderStepResp.cs b/Entity/Api/Resp/SwapOrderStepResp.cs index 617716b..11329c5 100644 --- a/Entity/Api/Resp/SwapOrderStepResp.cs +++ b/Entity/Api/Resp/SwapOrderStepResp.cs @@ -7,69 +7,90 @@ namespace Entity.Api.Resp /// public partial class SwapOrderStepResp { - - /// - /// Desc:id - /// Default: - /// Nullable:False - /// - public int Id {get;set;} + /// + /// Desc:id + /// Default: + /// Nullable:False + /// + public int Id { get; set; } - /// - /// Desc:换电订单编号 - /// Default: - /// Nullable:True - /// - public string SwapOrderSn {get;set;} + /// + /// Desc:换电订单编号 + /// Default: + /// Nullable:True + /// + public string SwapOrderSn { get; set; } - /// - /// Desc:步序;0-未知;1-空闲;200-rfid扫描;300-云平台验证; - /// Default: - /// Nullable:True - /// - public int? Step {get;set;} + /// + /// Desc:步序;0-未知;1-空闲;200-rfid扫描;300-云平台验证; + /// Default: + /// Nullable:True + /// + public int? Step { get; set; } - /// - /// Desc:步序名称 - /// Default: - /// Nullable:True - /// - public string StepName {get;set;} + /// + /// Desc:步序名称 + /// Default: + /// Nullable:True + /// + public string StepName { get; set; } - /// - /// Desc:创建人 - /// Default: - /// Nullable:True - /// - public string CreatedBy {get;set;} + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + public string CreatedBy { get; set; } - /// - /// Desc:创建时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - public DateTime? CreatedTime {get;set;} + /// + /// Desc:创建时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + public DateTime? CreatedTime { get; set; } - /// - /// Desc:更新人 - /// Default: - /// Nullable:True - /// - public string UpdatedBy {get;set;} + /// + /// Desc:更新人 + /// Default: + /// Nullable:True + /// + public string UpdatedBy { get; set; } - /// - /// Desc:更新时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - public DateTime? UpdatedTime {get;set;} - - /// - /// Desc:排序 - /// Default: - /// Nullable:True - /// - public int Sort { get; set; } + /// + /// Desc:更新时间 + /// Default:CURRENT_TIMESTAMP + /// Nullable:True + /// + public DateTime? UpdatedTime { get; set; } + /// + /// Desc:排序 + /// Default: + /// Nullable:True + /// + public int Sort { get; set; } + + /// + /// Desc:步骤类型 + /// Default: 1:自动 2:手动 + /// Nullable:True + /// + + public int? StepType { get; set; } + + /// + /// Desc:参数 + /// Default: + /// Nullable:True + /// + public string? Param { get; set; } + + /// + /// Desc:描述 + /// Default: + /// Nullable:True + /// + + public string? StepDesc { get; set; } } -} +} \ No newline at end of file diff --git a/Entity/Constant/StationConstant.cs b/Entity/Constant/StationConstant.cs index fa1ea4e..a696d54 100644 --- a/Entity/Constant/StationConstant.cs +++ b/Entity/Constant/StationConstant.cs @@ -5,6 +5,26 @@ namespace Entity.Constant; public class StationConstant { + + + + /// + /// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业 + /// + public enum DeviceCode + { + + [Description("雷达")] + Radar=1, + [Description("Rfid")] + Rfid, + [Description("Tbox")] + Tbox, + [Description("Plc")] + Plc, + + + } /// /// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业 /// diff --git a/Entity/Constant/SwapConstant.cs b/Entity/Constant/SwapConstant.cs new file mode 100644 index 0000000..9eefd26 --- /dev/null +++ b/Entity/Constant/SwapConstant.cs @@ -0,0 +1,98 @@ +using System.ComponentModel; +using System.Reflection; + +namespace Entity.Constant; + +public class SwapConstant +{ + /// + /// 通讯类型 + /// + public enum CommunicationType + { + + [Description("发送")] + Send=1, + [Description("接受")] + Receive, + + } + + /// + /// 步骤类型 + /// + public enum StepType + { + + [Description("自动")] + AUTO=1, + [Description("手动")] + MANUAL, + + } + + /// + /// 换电plc 通讯 + /// + public enum PlcProtocol + { + + [Description("初始化")] + Init, + [Description("下发启动换电")] + StartSwap, + + } + + /// + /// 雷达 通讯 + /// + public enum RadarProtocol + { + + [Description("开启雷达")] + Open, + [Description("关闭雷达")] + Close, + [Description("车辆状态")] + CarStatus, + + } + + /// + /// Rfid 通讯 + /// + public enum RfidProtocol + { + + [Description("连接Rfid")] + Connect, + [Description("开始读")] + BeginRead, + [Description("读取Rfid数据")] + ReadRfidData, + [Description("停止读Rfid")] + StopRead, + [Description("断开连接")] + DisConnect, + + } + + + /// + /// Tbox 通讯 + /// + public enum TboxProtocol + { + + [Description("心跳数据")] + Heart, + [Description("加锁")] + Lock, + [Description("解锁")] + UnLock, + + + } + +} \ No newline at end of file diff --git a/Entity/DbModel/Station/SwapOrderStep.cs b/Entity/DbModel/Station/SwapOrderStep.cs index 385a8bd..df80b53 100644 --- a/Entity/DbModel/Station/SwapOrderStep.cs +++ b/Entity/DbModel/Station/SwapOrderStep.cs @@ -1,5 +1,4 @@ - -using SqlSugar; +using SqlSugar; namespace Entity.DbModel.Station { @@ -36,8 +35,6 @@ namespace Entity.DbModel.Station [SugarColumn(ColumnName = "step_name")] public string? StepName { get; set; } - - /// /// Desc:排序 @@ -46,5 +43,27 @@ namespace Entity.DbModel.Station /// [SugarColumn(ColumnName = "sort")] public int Sort { get; set; } + + /// + /// Desc:步骤类型 + /// Default: 1:自动 2:手动 + /// Nullable:True + /// + [SugarColumn(ColumnName = "step_type")] + public int? StepType { get; set; } + /// + /// Desc:参数 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "param")] public string? Param { get; set; } + + /// + /// Desc:描述 + /// Default: + /// Nullable:True + /// + [SugarColumn(ColumnName = "step_desc")] + public string? StepDesc { get; set; } } } \ No newline at end of file diff --git a/Service/Execute/Api/PlcApi.cs b/Service/Execute/Api/PlcApi.cs index ea204f3..10e787e 100644 --- a/Service/Execute/Api/PlcApi.cs +++ b/Service/Execute/Api/PlcApi.cs @@ -1,3 +1,4 @@ +using Entity.Constant; using log4net; using Service.Charger.Client; using Service.Mgr; @@ -54,6 +55,11 @@ public class PlcApi /// public static bool StartSwapping(string inBinNo, string outBinNo) { + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Plc,SwapConstant.PlcProtocol.StartSwap, + + $"出仓位:{outBinNo},入仓位:{inBinNo}" ,(int)SwapConstant.CommunicationType.Send); + Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}"); ClientMgr.PlcClient?.SendStartBatterySwapReq(Convert.ToByte(outBinNo), Convert.ToByte(inBinNo)); diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs index 4c37a81..c84c8cf 100644 --- a/Service/Execute/Api/RfidApi.cs +++ b/Service/Execute/Api/RfidApi.cs @@ -1,3 +1,4 @@ +using Entity.Constant; using log4net; using Newtonsoft.Json; using Service.Execute.Model; @@ -32,8 +33,16 @@ public class RfidApi string url = BASE_URL + "/Api/BeginRead"; try { + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.BeginRead, + + null,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); Log.Info($"BeginRead resp = {s}"); + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.BeginRead, + + s,(int)SwapConstant.CommunicationType.Receive); + return bool.Parse(s); } catch (Exception e) @@ -49,7 +58,15 @@ public class RfidApi string url = BASE_URL + "/Api/StopRead"; try { + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.StopRead, + + null,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.ReadRfidData, + + s,(int)SwapConstant.CommunicationType.Receive); + Log.Info($"StopRead resp = {s}"); return bool.Parse(s); } @@ -68,8 +85,15 @@ public class RfidApi string url = BASE_URL + "/Api/Close"; try { + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.DisConnect, + + null,(int)SwapConstant.CommunicationType.Send); string s = await _httpClient.GetStringAsync(url); Log.Info($"DisConnect resp={s}"); + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.DisConnect, + + s,(int)SwapConstant.CommunicationType.Receive); return bool.Parse(s); } catch (Exception e) @@ -81,14 +105,24 @@ public class RfidApi public static async Task Connect() { - var disConnect = await DisConnect(); + // var disConnect = await DisConnect(); Log.Info("RfidApi Connect"); string url = BASE_URL + "/Api/Open"; try { + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.Connect, + + null,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); + Log.Info($"Connect resp={s}"); + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.Connect, + + s,(int)SwapConstant.CommunicationType.Receive); + return bool.Parse(s); } catch (Exception e) @@ -102,14 +136,23 @@ public class RfidApi { Log.Info("RfidApi ReadRfid"); - string readUrl = BASE_URL + "/Api/BeginRead"; + // string readUrl = BASE_URL + "/Api/BeginRead"; string url = BASE_URL + "/Api/ReadRfidData"; Log.Info($"url={url}"); try { - var vBeginRead = await _httpClient.GetStringAsync(readUrl); + // var vBeginRead = await _httpClient.GetStringAsync(readUrl); + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.ReadRfidData, + + null,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); Log.Info($"ReadRfid resp={s}"); + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Rfid,SwapConstant.RfidProtocol.ReadRfidData, + + s,(int)SwapConstant.CommunicationType.Receive); + if (s != String.Empty) { RfidReadModel? model = JsonConvert.DeserializeObject(s); diff --git a/Service/Execute/Api/TboxApi.cs b/Service/Execute/Api/TboxApi.cs index 9c6f8fe..73cd018 100644 --- a/Service/Execute/Api/TboxApi.cs +++ b/Service/Execute/Api/TboxApi.cs @@ -1,3 +1,4 @@ +using Entity.Constant; using log4net; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -33,9 +34,15 @@ public class TBoxApi string url = BASE_URL + StaticStationInfo.TboxUrlCarInfo + carNo; try { + + string s = await _httpClient.GetStringAsync(url); Log.Info($"TBoxApi GetCarInfo resp = {s}"); + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Tbox,SwapConstant.TboxProtocol.Heart, + + s,(int)SwapConstant.CommunicationType.Receive); + TboxCarInfoModel tboxCarInfoModel = null; if (!String.IsNullOrWhiteSpace(s)) @@ -137,8 +144,14 @@ public class TBoxApi string url = BASE_URL + StaticStationInfo.TboxUrlUnLock + carNo; try { + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Tbox,SwapConstant.TboxProtocol.UnLock, + + carNo ,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); - + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Tbox,SwapConstant.TboxProtocol.Lock, + + s ,(int)SwapConstant.CommunicationType.Receive); Log.Info($"UnLockCar resp = {s}"); return bool.Parse(s); @@ -233,9 +246,14 @@ public class TBoxApi Log.Info("LockCar"); string url = BASE_URL +StaticStationInfo.TboxUrlLock + carNo; try - { + { StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Tbox,SwapConstant.TboxProtocol.Lock, + + carNo ,(int)SwapConstant.CommunicationType.Send); + string s = await _httpClient.GetStringAsync(url); - + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Tbox,SwapConstant.TboxProtocol.Lock, + + s ,(int)SwapConstant.CommunicationType.Receive); Log.Info($"LockCar resp = {s}"); return bool.Parse(s); diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs index 66d36f3..fe8cfd4 100644 --- a/Service/Execute/Mgr/CommonMgr.cs +++ b/Service/Execute/Mgr/CommonMgr.cs @@ -36,7 +36,8 @@ public class CommonMgr /// /// 新增小步状态 /// - public void InsertStep(InfoEnum.BusinessSwappingStep step, SwappingStateMachine machine) + public void InsertStep(InfoEnum.BusinessSwappingStep step, SwappingStateMachine machine, + string desc="" ,string param=null,int type=(int)SwapConstant.StepType.AUTO) { var stepModel = new StepModel { @@ -53,7 +54,8 @@ public class CommonMgr if (machine.SwapOrder != null) { if (!string.IsNullOrEmpty(machine.SwapOrder.Sn)) - _swapOrderStepService.InsertSwapStepForSwapMain(step, machine.StepSort++, machine.SwapOrder.Sn); + _swapOrderStepService.InsertSwapStepForSwapMain(step, machine.StepSort++, machine.SwapOrder.Sn, + desc,param,type); } diff --git a/Service/Execute/Model/StepModel.cs b/Service/Execute/Model/StepModel.cs index 105042e..5900cd7 100644 --- a/Service/Execute/Model/StepModel.cs +++ b/Service/Execute/Model/StepModel.cs @@ -25,4 +25,5 @@ public class StepModel /// 0:初始化 1:执行完成 /// public int Status{ get; set; } -} \ No newline at end of file + + } \ No newline at end of file diff --git a/Service/Execute/StationSoftMgr.cs b/Service/Execute/StationSoftMgr.cs index a759535..e7179cd 100644 --- a/Service/Execute/StationSoftMgr.cs +++ b/Service/Execute/StationSoftMgr.cs @@ -1,5 +1,7 @@  +using Entity.Constant; using HybirdFrameworkCore.Configuration; +using Service.Execute.Model; namespace Service.Execute { @@ -11,6 +13,20 @@ namespace Service.Execute public static readonly SwappingStateMachine SwappingStateMachine = SwappingStateMachine.GetInstance(); + public static Dictionary> DeviceLogs = new () + { + + [(int)StationConstant.DeviceCode.Radar] = new (), + [(int)StationConstant.DeviceCode.Rfid] = new (), + [(int)StationConstant.DeviceCode.Tbox] = new (), + [(int)StationConstant.DeviceCode.Plc] = new(), + + }; + + + + + public static readonly string addr1 = AppSettingsHelper.GetContent("SoundAddr", "Address1"); #region 换电流程 @@ -39,5 +55,51 @@ namespace Service.Execute } #endregion 换电流程启动 + + #region 设备业务数据日志 + + + public static void PutDeviceLog(int key, Enum @enum,string data,int type) + { + + SwapDeviceLog deviceLog = BuildDeviceLog(@enum, data,key, type); + + DeviceLogs.TryGetValue(key, out var value); + + if (value == null) + { + List list = new List() { deviceLog }; + DeviceLogs[key] = list; + } + else + { + value.Add(deviceLog); + + if (value.Count > 10) + { + var swapDeviceLogs = value.OrderByDescending(i => i.Time).ToList(); + + var deviceLogs = swapDeviceLogs.Take(10).ToList(); + value = deviceLogs.OrderBy(i => i.Time).ToList(); + } + + DeviceLogs[key] = value; + } + } + + public static SwapDeviceLog BuildDeviceLog(Enum @enum,string data,int device,int type) + { + return new() + { + Time = DateTime.Now, + desc = BaseEnumExtensions.GetDescription(@enum), + Data = data, + Device = device, + Type = type + + }; + } + + #endregion } } diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 3e23782..dfb3447 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -4,6 +4,7 @@ using Entity.Constant; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using log4net; +using Newtonsoft.Json; using Service.Execute.Api; using Service.Execute.Model; using Service.Execute.Model.Tbox; @@ -65,7 +66,9 @@ public class CarCtrlState : IState machine.VelUnlockFlag = true; _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, - machine); + machine,param: $"unlock: {unLock} ; heartMsg: {JsonConvert.SerializeObject(resultHeartBeatMsg)}",type: + machine.ManualConfirmCarUnlockFlag? (int)SwapConstant.StepType.MANUAL : + (int)SwapConstant.StepType.AUTO); SoundClient = AppInfo.Container.Resolve(); SoundClient.SoundPlay(SoundEnum.music93); diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 2f3e8ac..c8ce9a4 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -16,6 +16,9 @@ using Service.Led; using Service.Padar.Client; using Service.RealTime; using Service.Sound.SoundClient; +using Service.Station; +using System.Runtime.CompilerServices; +using Newtonsoft.Json; namespace Service.Execute.Step; @@ -52,6 +55,7 @@ public class CarPrepareState : IState { return SwappingStateMachine.ReturnWithInvokeErr(checkTBoxConnect, ExceptionReason.None); } + //车辆本地验证 InvokeStatus checkTBoxVelLocal = CheckTBoxVelLocalFlag(machine); @@ -59,6 +63,7 @@ public class CarPrepareState : IState { return SwappingStateMachine.ReturnWithInvokeErr(checkTBoxVelLocal, ExceptionReason.None); } + machine.ExceptionReason = ExceptionReason.None; @@ -75,14 +80,9 @@ public class CarPrepareState : IState { return SwappingStateMachine.ReturnWithInvokeErr(selectPack, ExceptionReason.StopChargingError); } + _CommonMgr.SaveSwapBattery(machine); - - //车辆到位 - InvokeStatus carInPosition = CarInPosition(machine); - if (carInPosition != InvokeStatus.Done) - { - return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None); - } + ////调整车辆 var adjustCarByRadar = AdjustCarByRadar(machine); @@ -91,6 +91,15 @@ public class CarPrepareState : IState return SwappingStateMachine.ReturnWithInvokeErr(adjustCarByRadar, ExceptionReason.None); } + //车辆到位 + InvokeStatus carInPosition = CarInPosition(machine); + if (carInPosition != InvokeStatus.Done) + { + return SwappingStateMachine.ReturnWithInvokeErr(carInPosition, ExceptionReason.None); + } + + + @@ -142,7 +151,7 @@ public class CarPrepareState : IState { machine.VehiclesInPlaceFlag = true; _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CarInPositionFlag, - machine); + machine,param:JsonConvert.SerializeObject(tboxCarInfoModel)); } }, () => { @@ -396,7 +405,7 @@ public class CarPrepareState : IState //选包成功 _CommonMgr.LockBinAndUpdateAmt(orderBatteryInfo); machine.SwapOrderBatteryInfo = orderBatteryInfo; - _CommonMgr.SaveSwapBattery(machine); + machine.SelectPackFlag = true; } }, () => diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index ee5b566..0a12ac3 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -6,6 +6,7 @@ using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using log4net; +using Newtonsoft.Json; using Repository.Station; using Service.Charger.Client; using Service.Execute.Api; @@ -115,29 +116,7 @@ public class DoSwappingState : IState //} - public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) - { - - return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, - () => - { - //新增小步 - _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RadarOutFlag, - machine); - var carState = PadarMgr._PadarClient?.CarState; - return carState.HasValue && (carState.Value == 1 || carState.Value == 2 || carState.Value == 3 || carState.Value == 4 || carState.Value == 5); - }, - () => - { - switch (PadarMgr._PadarClient?.CarState) - { - case 6: - _log.Info("车辆未驶离"); - break; - - } - }); - } + /// /// 下发plc启动换电 @@ -157,7 +136,9 @@ public class DoSwappingState : IState machine.SwapOrderBatteryInfo.UpBinInfo.No); _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.DistributeSelectPackFlag, - machine); + machine,param: $"InBin:{JsonConvert.SerializeObject(machine.SwapOrderBatteryInfo.InBinInfo)};" + + $"UpBin: {JsonConvert.SerializeObject(machine.SwapOrderBatteryInfo.UpBinInfo)}"); + _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StartSwappingFlag, machine); diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index a388629..d9fcbca 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -198,11 +198,16 @@ public class StationReadyState : IState public InvokeStatus AdjustCarByRadar(SwappingStateMachine machine) { int che = 0; - return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, + return Invoker.Invoke("adjust Radar", 1000, 20, machine.IsCanceled, () => { LedClient.SendMsgByKey(InfoEnum.SwapInfo.InfoCarInPosition.GetLed()); + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Radar,SwapConstant.RadarProtocol.CarStatus, + + null,(int)SwapConstant.CommunicationType.Receive); + if (PadarMgr._PadarClient?.CarState == 6) { LedClient.SendMsgByKey(InfoEnum.SwapInfo.diparkir.GetLed()); @@ -252,19 +257,26 @@ public class StationReadyState : IState return Invoker.Invoke(" BeginRead read rfid", 1000, 20, machine.IsCanceled, () => machine.BeginRfidReadFlag, () => { - // Task open = RfidApi.Connect(); - Task beginRead = RfidApi.BeginRead(); - beginRead.Wait(); - if (!beginRead.Result) - { - _log.Info("begin read rfid error"); - } - else - { - machine.ExceptionReason = ExceptionReason.None; - _log.Info("begin read done"); - machine.BeginRfidReadFlag = true; - } + Task open = RfidApi.Connect(); + + if (open.Result) + { + machine.RfidConnectFlag = true; + Task beginRead = RfidApi.BeginRead(); + beginRead.Wait(); + if (!beginRead.Result) + { + _log.Info("begin read rfid error"); + } + else + { + machine.ExceptionReason = ExceptionReason.None; + _log.Info("begin read done"); + machine.BeginRfidReadFlag = true; + } + } + + }, () => { machine.LedTool.WriteProgramContent(InfoEnum.SwapInfo.ErrorReadRfid.GetLed()); @@ -329,11 +341,12 @@ public class StationReadyState : IState machine.SwapOrder = _CommonMgr.SaveOrder(BuildOrder(machine.RfidReadModel)); //新增小步 _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag, - machine); + machine,param:JsonConvert.SerializeObject(machine.RfidReadModel)); - //RfidApi.StopRead(); + RfidApi.StopRead(); _log.Info("stop read rfid"); - // RfidApi.DisConnect(); + RfidApi.DisConnect(); + machine.RfidConnectFlag = false; machine.RfidReadFlag = true; } }, () => @@ -365,7 +378,8 @@ public class StationReadyState : IState machine.SwapOrder = _CommonMgr.SaveOrder(BuildOrder(machine.RfidReadModel)); //新增小步 _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.RfidReadFlag, - machine); + machine,"手动填写车辆vin",JsonConvert.SerializeObject(machine.RfidReadModel), + (int)SwapConstant.StepType.MANUAL); _log.Info("stop Wait Vin Prepare"); diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index 4221771..30c7e38 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -4,6 +4,7 @@ using Entity.Constant; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Configuration; using log4net; +using Newtonsoft.Json; using Service.Execute.Api; using Service.Execute.Model.Tbox; using Service.Execute.SwapException; @@ -198,7 +199,10 @@ public class SwapDoneState : IState if (carInfo.Result?.CarStatus?.LockStatus == 2 || machine.ManualConfirmCarLockFlag) { _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, - machine); + machine,param: $"lock: {unLock} ; heartMsg: {JsonConvert.SerializeObject(carInfo.Result)}",type: + machine.ManualConfirmCarLockFlag? (int)SwapConstant.StepType.MANUAL : + (int)SwapConstant.StepType.AUTO); + //_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelLockFlag, // machine); var SoundClient = AppInfo.Container.Resolve(); diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs index 95eaff3..109ab87 100644 --- a/Service/Execute/SwappingStateMachine.cs +++ b/Service/Execute/SwappingStateMachine.cs @@ -23,6 +23,8 @@ public class SwappingStateMachine : IDisposable private static readonly ILog Log = LogManager.GetLogger(typeof(SwappingStateMachine)); private static readonly SwappingStateMachine SwappingMachine = new SwappingStateMachine(); + + private BinInfoRepository BinInfoRepository { get; set; } private SwapAmtOrderRepository AmtOrderRepository { get; set; } @@ -70,12 +72,16 @@ public class SwappingStateMachine : IDisposable public ConcurrentDictionary StepModel = new ConcurrentDictionary - (); + (); + + #region 小步状态 //雷达检测/车辆进入 public bool RadarInFlag = false; + public bool RfidConnectFlag = false; + //开始读rf public bool BeginRfidReadFlag = false; @@ -253,10 +259,8 @@ public class SwappingStateMachine : IDisposable public void Reset() { - - Log.Info("reset data"); - + /*if (PlcMgr.PlcClient?.ReadTaskNo() == 1) { PlcMgr.PlcClient?.ExChangeTaskNo(0); @@ -338,9 +342,7 @@ public class SwappingStateMachine : IDisposable Array values = Enum.GetValues(typeof(InfoEnum.BusinessSwappingStep)); foreach (var value in values) { - - - StepModel[value.ToInt()+""] = new StepModel() + StepModel[value.ToInt() + ""] = new StepModel() { StepNo = (int)value, Status = 0, @@ -363,7 +365,7 @@ public class SwappingStateMachine : IDisposable { RadarInFlag = false; - + RfidConnectFlag = false; BeginRfidReadFlag = false; @@ -437,22 +439,20 @@ public class SwappingStateMachine : IDisposable //关于仓库锁定相关重置 private void ResetOrderAmtStatus() { - - - // SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.ErrorTBoxConn); LedClient.SendMsgByKey(InfoEnum.SwapInfo.WelcomeInfo.GetLed()); BinInfoRepository.Update(it => new BinInfo { AmtLock = 0 }, - it => it.AmtLock == 1); + it => it.AmtLock == 1); //仓库解锁 if (SwapOrderBatteryInfo != null) { if (SwapOrderBatteryInfo?.UpBinInfo != null) ; { - BinInfoRepository.Update(i=>i.AmtLock==(int)InfoEnum.AmtBatLockStatus.UnLock,i=>i.Id==SwapOrderBatteryInfo.UpBinInfo.Id); + BinInfoRepository.Update(i => i.AmtLock == (int)InfoEnum.AmtBatLockStatus.UnLock, + i => i.Id == SwapOrderBatteryInfo.UpBinInfo.Id); } } @@ -479,6 +479,8 @@ public class SwappingStateMachine : IDisposable CancelFlag = true; Thread.Sleep(2000); } + + } public enum SwappingState @@ -493,4 +495,4 @@ public enum SwappingState Exception, Canceled, ManualSucc, -} +} \ No newline at end of file diff --git a/Service/Padar/Client/PadarClient.cs b/Service/Padar/Client/PadarClient.cs index 03ae3c4..2d019db 100644 --- a/Service/Padar/Client/PadarClient.cs +++ b/Service/Padar/Client/PadarClient.cs @@ -1,7 +1,11 @@ +using Entity.Constant; +using HslCommunication.Enthernet; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Entity; using HybirdFrameworkDriver.TcpClient; using log4net; +using Service.Execute; +using Service.Execute.Model; using Decoder = Service.Padar.Codec.Decoder; using Encoder = Service.Padar.Codec.Encoder; @@ -10,10 +14,12 @@ namespace Service.Padar.Client; [Scope] public class PadarClient : TcpClient { + private readonly String DEVICE_CODE = "radar"; + /// /// 0-雷达不工作;1-无车;2-无电池,3-角度偏移过大;4-车辆靠后;5-车辆靠前;6-车辆到位 /// - public byte CarState =new byte(); + public byte CarState = new byte(); public static readonly byte[] StartChar = { 0xFE, 0x68 }; @@ -28,7 +34,7 @@ public class PadarClient : TcpClient Log.Info($"padar connect succeed"); return Connected; } - + public override ILog Logger() { return Log; @@ -50,6 +56,12 @@ public class PadarClient : TcpClient serialNum++; sendBytes[3] = byte3; this.Channel.WriteAndFlushAsync(sendBytes); + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Radar, + byte3 == 0 ? SwapConstant.RadarProtocol.Close : SwapConstant.RadarProtocol.Open, + sendBytes.ToString(), (int)SwapConstant.CommunicationType.Send); + + return Result.Success(); } } \ No newline at end of file diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index 9ef0621..9b679bd 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -1,4 +1,6 @@ -using Autofac; +using System.Text.Json.Nodes; +using Autofac; +using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; @@ -6,11 +8,13 @@ using HybirdFrameworkCore.Entity; using HybirdFrameworkDriver.Session; using HybirdFrameworkDriver.TcpClient; using log4net; +using Newtonsoft.Json; using Repository.Station; using Service.Charger.Client; using Service.Charger.Codec; using Service.Charger.Handler; using Service.Charger.Msg.Host.Req; +using Service.Execute; namespace Service.Charger.Server; @@ -70,6 +74,11 @@ public class PlcClient : TcpClient InitializeCommandReq req = new InitializeCommandReq(); this.Channel.WriteAndFlushAsync(req); + + StationSoftMgr.PutDeviceLog((int)StationConstant.DeviceCode.Plc,SwapConstant.PlcProtocol.Init, + + JsonConvert.SerializeObject(req),(int)SwapConstant.CommunicationType.Send); + return Result.Success(); } diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs index b85280f..ac7bab1 100644 --- a/Service/Station/MonitorService.cs +++ b/Service/Station/MonitorService.cs @@ -23,6 +23,7 @@ using Service.Execute.Model; using Service.Execute.Utils; using Service.Init; using Service.Mgr; +using Service.Padar.Client; using SqlSugar; namespace Service.Station; @@ -145,43 +146,9 @@ public class MonitorService monitorScreenResp.VehicleInfo.DownBatteryBinNo = queryByClauseAsync.DownBatteryBinNo; monitorScreenResp.VehicleInfo.UpBatteryBinNo = queryByClauseAsync.UpBatteryBinNo; } - //SwapMonitorScreenResp monitorScreenResp = new() - //{ - - // PlcSwapModel = plcSwapModel, - // StateInfo = stateInfoList, - // VehicleInfo = new SwapVehicleResp() - // { - // OrderNo = StationSoftMgr.SwappingStateMachine.SwapOrder != null - // ? StationSoftMgr.SwappingStateMachine.SwapOrder.Sn - // : null, - // VelMac = StationSoftMgr.SwappingStateMachine.RfidReadModel != null - // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelMac - // : null, - // LockStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.LockStatus : null, - // KeyStatus = tboxCarInfoModel != null ? tboxCarInfoModel.CarStatus.Keys : null, - // VelNo = StationSoftMgr.SwappingStateMachine.RfidReadModel != null - // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo - // : null, - // VelVin = StationSoftMgr.SwappingStateMachine.RfidReadModel != null - // ? StationSoftMgr.SwappingStateMachine.RfidReadModel.VelVin - // : null, - // Break = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Break, - // Gear = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel?.CarStatus?.Gear, - // }, - // BatteryInfo = new() - // { - // BatteryTotalCount = binInfos.Count, - // 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() - // } - //}; - + + + monitorScreenResp.DeviceLogs = StationSoftMgr.DeviceLogs; return Result.Success(monitorScreenResp); } @@ -217,7 +184,9 @@ public class MonitorService { BoxConnectFlag = isConnected, // CloudConnectFlag = CloudClientMgr.CloudClient == null ? false : CloudClientMgr.CloudClient.Connected, - PlcConnectFlag = ClientMgr.PlcClient != null && ClientMgr.PlcClient.Connected + PlcConnectFlag = ClientMgr.PlcClient != null && ClientMgr.PlcClient!.Connected, + RfidConnectFlag = StationSoftMgr.SwappingStateMachine!.RfidConnectFlag, + RadarConnectFlag =PadarMgr._PadarClient != null && PadarMgr._PadarClient!.Connected }; return Result.Success(resp); diff --git a/Service/Station/SwapOrderStepService.cs b/Service/Station/SwapOrderStepService.cs index 7a7110e..6f05454 100644 --- a/Service/Station/SwapOrderStepService.cs +++ b/Service/Station/SwapOrderStepService.cs @@ -7,6 +7,8 @@ using Repository.Station; using SqlSugar; using System.Linq.Expressions; using Entity.Constant; +using HybirdFrameworkCore.Utils; +using Quartz.Util; namespace Service.Station; @@ -90,7 +92,8 @@ public class SwapOrderStepService : BaseServices /// /// 换电小步新增---换电主流程 /// - public void InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep step, int sort, String swapOrderSn) + public void InsertSwapStepForSwapMain(InfoEnum.BusinessSwappingStep step, int sort, String swapOrderSn, + string desc="" ,string param=null,int type=(int)SwapConstant.StepType.AUTO) { SwapOrderStep swapOrderStep = new () { @@ -98,6 +101,9 @@ public class SwapOrderStepService : BaseServices Step = (int)step, Sort = sort, SwapOrderSn = swapOrderSn, + StepType = type, + Param = param, + StepDesc = ObjUtils.IsNullOrWhiteSpace(desc)?BaseEnumExtensions.GetDescription(step):desc, }; _swapOrderStepRepository.Insert(swapOrderStep); } diff --git a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs index e903cec..11a771b 100644 --- a/WebStarter/Controllers/BasicConfig/BaseConfigController.cs +++ b/WebStarter/Controllers/BasicConfig/BaseConfigController.cs @@ -161,7 +161,7 @@ namespace WebStarter.Controllers.BasicConfig /// - /// 提交换电策略设置 + /// /// /// /// diff --git a/WebStarter/Controllers/SwapOrderController.cs b/WebStarter/Controllers/SwapOrderController.cs index 287818f..0507cb0 100644 --- a/WebStarter/Controllers/SwapOrderController.cs +++ b/WebStarter/Controllers/SwapOrderController.cs @@ -3,6 +3,7 @@ using System.Transactions; using AutoMapper; using Entity.Api.Req; using Entity.Api.Resp; +using Entity.Constant; using Entity.DbModel.Station; using Entity.Dto; using HybirdFrameworkCore.Entity; @@ -23,7 +24,6 @@ namespace WebStarter.Controllers; [Route("api/[controller]")] public class SwapOrderController : ControllerBase { - private static readonly ILog Log = LogManager.GetLogger(typeof(SwapOrderController)); private readonly SwapOrderService swapOrderService; private readonly SwapOrderBatteryService swapOrderBatteryService; @@ -33,8 +33,9 @@ public class SwapOrderController : ControllerBase private readonly BaseVehicleRepository _baseVehicleRepository; public SwapOrderController(SwapOrderService swapOrderService, SwapOrderBatteryService swapOrderBatteryService, - SwapOrderStepService swapOrderStepService,SwapOrderReportCloudRepository swapOrderReportCloudRepository,BaseVehicleRepository baseVehicleRepository - ) + SwapOrderStepService swapOrderStepService, SwapOrderReportCloudRepository swapOrderReportCloudRepository, + BaseVehicleRepository baseVehicleRepository + ) { this.swapOrderService = swapOrderService; this.swapOrderBatteryService = swapOrderBatteryService; @@ -51,17 +52,18 @@ public class SwapOrderController : ControllerBase public async Task>> QueryPage([FromBody] QuerySwapOrderPageReq req) { Log.Info($"SwapOrderController QueryPage req={req}"); - - if (!string.IsNullOrEmpty(req.DownBatteryNo)||!string.IsNullOrEmpty(req.UpBatteryNo)) + + if (!string.IsNullOrEmpty(req.DownBatteryNo) || !string.IsNullOrEmpty(req.UpBatteryNo)) { var result = BatteryCodeList(req); return Result>.Success(result); } + Log.Info($"查询换电订单 SwapOrderController start QueryPage swapOrderService.QuerySwapOrder req={req}"); var swapOrderResp = swapOrderService.QuerySwapOrder(req); Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}"); PackageSwapOrder(swapOrderResp); - + List? list = swapOrderResp.Rows; List vehicleNoList = list?.Select(resp => resp.VehicleNo).ToList() ?? new List(); // 查询车辆的部门 @@ -74,16 +76,17 @@ public class SwapOrderController : ControllerBase foreach (var swapOrder in list) { var matchingVehicle = vehicleList.FirstOrDefault(v => v.VehicleNo == swapOrder.VehicleNo); - + if (matchingVehicle != null) { swapOrder.Company = matchingVehicle.Company; swapOrder.Departments = matchingVehicle.Departments; } } + return Result>.Success(swapOrderResp); } - + /// /// app查询换电订单 /// @@ -93,11 +96,11 @@ public class SwapOrderController : ControllerBase public async Task>> AppSwapOrder([FromBody] QuerySwapOrderPageReq req) { Log.Info($"SwapOrderController QueryPage req={req}"); - + Log.Info($"查询换电订单 SwapOrderController start QueryPage swapOrderService.QuerySwapOrder req={req}"); var swapOrderResp = swapOrderService.AppQuerySwapOrder(req); Log.Info($"查询换电订单 SwapOrderController end QueryPage swapOrderService.QuerySwapOrder req={req}"); - + PackageSwapOrder(swapOrderResp); return Result>.Success(swapOrderResp); } @@ -106,31 +109,28 @@ public class SwapOrderController : ControllerBase { //获取所有订单号 var orderSns = swapOrderResp.Rows.Select(row => row.Sn).ToList(); - Log.Info($"查询上报云平台次数 SwapOrderController start QueryPage swapOrderService.QueryReportCloudNumBySn req={orderSns}"); //查询上报云平台次数 //Dictionary queryReportCloudNumBySn = swapOrderService.QueryReportCloudNumBySn(orderSns); - - Log.Info($"查询上报云平台次数 SwapOrderController end QueryPage swapOrderService.QueryReportCloudNumBySn req={orderSns}"); - Log.Info($"查询订单电池数据 SwapOrderController start QueryPage swapOrderBatteryService.QueryListByClause req={orderSns}"); + ////查询订单电池数据 List batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); - Log.Info($"查询订单电池数据 SwapOrderController end QueryPage swapOrderBatteryService.QueryListByClause req={orderSns}"); //映射 var config = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapper = config.CreateMapper(); - + List swapOrderBattery = mapper.Map>(batteryList); - - Log.Info($"查询公里数 SwapOrderController start QueryPage swapOrderReportCloudRepository.QueryListByClause req={orderSns}"); - List swapOrderReportClouds = swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); - Log.Info($"查询公里数 SwapOrderController end QueryPage swapOrderReportCloudRepository.QueryListByClause req={orderSns}"); + + List swapOrderReportClouds = + swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); + + //将电池数据添加到换电订单数据中 foreach (var row in swapOrderResp.Rows) { row.BatteryList = swapOrderBattery.Where(battery => battery.SwapOrderSn == row.Sn).ToList(); - + var matchingReport = swapOrderReportClouds.FirstOrDefault(r => r.SwapOrderSn == row.Sn); if (matchingReport != null) @@ -141,44 +141,48 @@ public class SwapOrderController : ControllerBase } } } - Log.Info($"查询订单步序数据 SwapOrderController start QueryPage swapOrderStepService.QueryListByClause req={orderSns}"); + //查询订单步序数据 var stepList = swapOrderStepService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); - Log.Info($"查询订单步序数据 SwapOrderController end QueryPage swapOrderStepService.QueryListByClause req={orderSns}"); stepList = stepList.OrderBy(s => s.Sort).ToList(); - + //映射 var config2 = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapper2 = config2.CreateMapper(); List swapOrderStep = mapper2.Map>(stepList); - - + + //将步序数据添加到换电订单数据中 for (int i = 0; i < swapOrderResp.Rows.Count; i++) { swapOrderResp.Rows[i].StepList = new List(); + var swapOrderStepResps = swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList(); swapOrderResp.Rows[i].StepList - .AddRange(swapOrderStep.Where(step => step.SwapOrderSn == swapOrderResp.Rows[i].Sn).ToList()); + .AddRange(swapOrderStepResps); + + ; + swapOrderResp.Rows[i].ManualStep = String.Join(",", + swapOrderStepResps.Where(i => i.StepType == (int)SwapConstant.StepType.MANUAL).Select(i => i.StepDesc) + .ToList()); } } private PageResult BatteryCodeList(QuerySwapOrderPageReq req) { PageResult batteryCodeList = swapOrderBatteryService.QuerySwapOrderBatteryList(req); - + var batteryOrderSn = batteryCodeList.Rows.Select(row => row.SwapOrderSn).ToList(); - + List swapOrderRespList = swapOrderService.QueryListByClause(u => batteryOrderSn.Contains(u.Sn)); //获取所有订单号 var orderSns = swapOrderRespList.Select(row => row.Sn).ToList(); - ////查询订单电池数据 List batteryList = swapOrderBatteryService.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); - + var config = new MapperConfiguration(cfg => { cfg.CreateMap().ReverseMap(); @@ -186,12 +190,13 @@ public class SwapOrderController : ControllerBase }); //映射 IMapper mapper = config.CreateMapper(); - + List swapOrderBattery = mapper.Map>(batteryList); - + List swapOrderResp = mapper.Map>(swapOrderRespList); - - List swapOrderReportClouds = swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); + + List swapOrderReportClouds = + swapOrderReportCloudRepository.QueryListByClause(u => orderSns.Contains(u.SwapOrderSn)); //将电池数据添加到换电订单数据中 @@ -496,7 +501,6 @@ public class SwapOrderController : ControllerBase // 将电池数据添加到换电订单数据中 for (int i = 0; i < list.Count; i++) { - if (language == "en") { SwapLoseOrderDto2 dto = list2[i]; @@ -507,7 +511,6 @@ public class SwapOrderController : ControllerBase { dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo; dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo; - } } else @@ -519,7 +522,6 @@ public class SwapOrderController : ControllerBase { dto.DownBatteryBinNo = swapOrderBatteryResp.DownBatteryBinNo; dto.UpBatteryBinNo = swapOrderBatteryResp.UpBatteryBinNo; - } } } @@ -536,6 +538,4 @@ public class SwapOrderController : ControllerBase }; } } - - } \ No newline at end of file diff --git a/WebStarter/db/换电订单新增计费字段.sql b/WebStarter/db/换电订单新增计费字段.sql index ce272ff..62a7f68 100644 --- a/WebStarter/db/换电订单新增计费字段.sql +++ b/WebStarter/db/换电订单新增计费字段.sql @@ -4,6 +4,12 @@ ADD COLUMN append_total_fee INT COMMENT '附加费', ADD COLUMN total_fee INT COMMENT '总费用(所有的总费用)'; +ALTER TABLE swap_order_step + ADD COLUMN step_type INT COMMENT '步骤类型(1:自动 2:手动)', +ADD COLUMN step_desc varchar(255) COMMENT '描述', +ADD COLUMN param text COMMENT '参数'; + + ALTER TABLE swap_order_battery ADD COLUMN nominal_energy DECIMAL(24, 2) COMMENT '电池标称能量';