更新亏电电池包和风扇开关状态

master
CZ 2 months ago
parent 729521f336
commit f3d321e544

@ -34,21 +34,39 @@ public class FanChangeTask : ITask
return 1000 * 3; return 1000 * 3;
} }
/// <para>0无状态</para>
/// <para>1000已全部打开</para> /// 1000打开右侧关闭左侧
/// <para>1010已全部关闭</para> /// 1001打开左侧关闭右侧
/// 1002全部打开
/// 1003全部关闭
public void Handle() public void Handle()
{ {
try try
{ {
int count = _binInfoRepository.GetCount(i => i.ChargeStatus == 1); int countL = _binInfoRepository.GetCount(i =>
if (count > 0) i.ChargeStatus == 1 && Convert.ToInt32(i.No) >= 1 && Convert.ToInt32(i.No) <= 8);
int countR = _binInfoRepository.GetCount(i =>
i.ChargeStatus == 1 && Convert.ToInt32(i.No) >= 11 && Convert.ToInt32(i.No) <= 18);
if (countL > 0 && countR <= 0)
{
if (PlcMgr.ExhaustFanStatusRadar() != 1000)
PlcMgr.AirBlowerControl(1000);
}
else if (countL <= 0 && countR > 0)
{
if (PlcMgr.ExhaustFanStatusRadar() != 1001)
PlcMgr.AirBlowerControl(1001);
}
else if (countL > 0 && countR > 0)
{ {
PlcMgr.AirBlowerControl(1000); if (PlcMgr.ExhaustFanStatusRadar() != 1002)
PlcMgr.AirBlowerControl(1002);
} }
else else
{ {
PlcMgr.AirBlowerControl(1010); if (PlcMgr.ExhaustFanStatusRadar() != 1003)
PlcMgr.AirBlowerControl(1003);
} }
} }
catch (Exception e) catch (Exception e)

@ -42,18 +42,56 @@ public class UpdateDownBatteryInfoTask : ITask
/// </summary> /// </summary>
public void Handle() public void Handle()
{ {
#region 更新换下电池 #region 更新换下电池
var listSwapOrderBattery =
_swapOrderBatteryRepository.QueryListByClause(i => i.DownBatteryNo == "-1" && i.DownBatterySoc == -1);
if (listSwapOrderBattery.Count > 0)
{
string SwapOrderSn = listSwapOrderBattery[listSwapOrderBattery.Count - 1].SwapOrderSn;
//查询两个仓位
var SwapOrderBatteryInfo1 = listSwapOrderBattery[listSwapOrderBattery.Count - 1];
var SwapOrderBatteryInfo2 = listSwapOrderBattery[listSwapOrderBattery.Count - 2];
var lstBinInfo = _BinInfoRepository.QueryListByClause(i => i.Exists == 1
&&
(i.No == SwapOrderBatteryInfo1.DownBatteryBinNo
.ToString() ||
i.No == SwapOrderBatteryInfo2.DownBatteryBinNo
.ToString())
&& i.Soc > 0
/*&& !string.IsNullOrEmpty(i.BatteryNo)*/
&&i.BatteryNo!="-1");
if (lstBinInfo.Count >= 2) //有换电电池包编码需要更新
{
var BinInfo0 = lstBinInfo.Where(i => i.No == SwapOrderBatteryInfo1.DownBatteryBinNo.ToString()).ToList()[0];
var BinInfo1 = lstBinInfo.Where(i => i.No == SwapOrderBatteryInfo2.DownBatteryBinNo.ToString()).ToList()[0];
_swapOrderBatteryRepository.Update(i =>new SwapOrderBattery()
{
DownBatterySoc = BinInfo0.Soc,
DownBatteryNo = BinInfo0.BatteryNo
},
i => i.SwapOrderSn.ToString() == SwapOrderBatteryInfo1.SwapOrderSn
&&i.DownBatteryBinNo==SwapOrderBatteryInfo1.DownBatteryBinNo);
_swapOrderBatteryRepository.Update(i => new SwapOrderBattery()
{
DownBatterySoc = BinInfo1.Soc,
DownBatteryNo = BinInfo1.BatteryNo
}, i => i.SwapOrderSn.ToString() == SwapOrderBatteryInfo2.SwapOrderSn&&i.DownBatteryBinNo==SwapOrderBatteryInfo2.DownBatteryBinNo);
}
}
#endregion #endregion
try /*try
{ {
List<SwapOrderBattery> batterys = List<SwapOrderBattery> batterys =
_swapOrderBatteryRepository.QueryListByClause( _swapOrderBatteryRepository.QueryListByClause(
i => (i.DownBatteryNo == null || i.DownBatterySoc<0) && i.DownBatteryBinNo != null); i => (i.DownBatteryNo == null || i.DownBatterySoc < 0) && i.DownBatteryBinNo != null);
if (batterys.Count <= 0) if (batterys.Count <= 0)
@ -75,7 +113,8 @@ public class UpdateDownBatteryInfoTask : ITask
{ {
continue; continue;
} }
if (info.Soc == null || info.Soc <=0)
if (info.Soc == null || info.Soc <= 0)
{ {
continue; continue;
} }
@ -96,7 +135,7 @@ public class UpdateDownBatteryInfoTask : ITask
catch (Exception e) catch (Exception e)
{ {
Log.Error($" UpdateDownBatteryInfoTask err e={e}"); Log.Error($" UpdateDownBatteryInfoTask err e={e}");
} }*/
} }
public bool Stoped() public bool Stoped()

@ -446,4 +446,22 @@ public class PlcMgr
return false; return false;
} }
} }
/// <summary>
/// 1000右侧打开左侧关闭
/// 1001右侧关闭左侧打开
/// 1002两侧全部打开
/// 1003两侧全部关闭
/// </summary>
/// <returns></returns>
public static ushort ExhaustFanStatusRadar()
{
if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds)
{
return PlcToHostData.ExhaustFanStatus.Value;
}
else
{
return 0;
}
}
} }

@ -52,8 +52,10 @@ namespace Service.Plc.Msg
/// <summary> /// <summary>
/// 排风扇状态 /// 排风扇状态
/// <para>0无状态</para> /// <para>0无状态</para>
/// <para>1000已全部打开</para> /// <para>1000右侧打开左侧关闭</para>
/// <para>1010已全部关闭</para> /// <para>1001右侧关闭左侧打开</para>
/// <para>1002两侧全部打开</para>
/// <para>1003两侧全部关闭</para>
/// </summary> /// </summary>
public ModbusProperty<ushort> ExhaustFanStatus { get; set; } = new(40209); public ModbusProperty<ushort> ExhaustFanStatus { get; set; } = new(40209);
/// <summary> /// <summary>

Loading…
Cancel
Save