xiaoguo 1 year ago
commit 3b21493d0b

@ -59,5 +59,11 @@ namespace GuideScreen.Common.Repositories
/// </summary>
/// <returns></returns>
IDictionary<string, decimal> WaterMonthTotal();
/// <summary>
/// 获取总用水量
/// </summary>
/// <returns></returns>
decimal WaterTotal();
}
}

@ -312,5 +312,19 @@ namespace GuideScreen.Common.Repositories.Impl
return retValues;
}
/// <summary>
/// 获取总用水量
/// </summary>
/// <returns></returns>
public decimal WaterTotal()
{
using (var context = GSDBContext.GetDbContext())
{
var val = context.PLCDeviceRecordDayEntities.Where(f => f.PointName == PLCPointNameByEnergyMonitoring.WaterConsumption).Sum(f=>f.RecordValue);
return val;
}
}
}
}

@ -92,5 +92,11 @@ namespace GuideScreen.Common.Services
/// </summary>
/// <returns></returns>
IDictionary<string, decimal> WaterMonthTotal();
/// <summary>
/// 获取总用水量
/// </summary>
/// <returns></returns>
decimal WaterTotal();
}
}

@ -224,5 +224,16 @@ namespace GuideScreen.Common.Services.Impl
return ret;
}
/// <summary>
/// 获取总用水量
/// </summary>
/// <returns></returns>
public decimal WaterTotal()
{
var ret = this.deviceRecordRepository.WaterTotal();
return ret;
}
}
}

@ -18,13 +18,13 @@ namespace GuideScreen.Common.Services.Impl
internal class PLCPointService : IPLCPointService
{
private IPLCPointRepository plcPointRepository;
private IPLCMonitorService pLCMonitorService;
private IPLCMonitorService plcMonitorService;
public PLCPointService(IPLCPointRepository plcPointRepository, IPLCMonitorService pLCMonitorService)
{
this.plcPointRepository = plcPointRepository;
this.pLCMonitorService = pLCMonitorService;
this.plcMonitorService = pLCMonitorService;
}
/// <summary>
@ -54,6 +54,18 @@ namespace GuideScreen.Common.Services.Impl
public List<PLCPointModel> GetControllerTimeParametersList()
{
var list = plcPointRepository.GetPLCPointList(PLCDeviceNames.SetControllerTimeParameters, "", 0, 0);
var points = plcMonitorService.Points;
if (points != null && points.Count > 0)
{
foreach (var c in list.Content)
{
var point = points.Where(f => f.Address == c.PointAddress).FirstOrDefault();
if (point != null)
{
c.PointValue = point.ObjectValue?.ToString();
}
}
}
return list.Content;
}
@ -76,9 +88,9 @@ namespace GuideScreen.Common.Services.Impl
{
var entity = plcPointRepository.GetPLCPointDetail(id);
var model = ModelTools.PubClone<PLCPointEntity, PLCPointModel>.Trans(entity);
if (model != null && pLCMonitorService.IsRun)
if (model != null && plcMonitorService.IsRun)
{
model.PointValue = pLCMonitorService.ReadValue(model.PointAddress, Type.GetType(model.PointDataType))?.ToString();
model.PointValue = plcMonitorService.ReadValue(model.PointAddress, Type.GetType(model.PointDataType))?.ToString();
}
return model;
}
@ -91,9 +103,9 @@ namespace GuideScreen.Common.Services.Impl
{
var entity = ModelTools.PubClone<PLCPointModel, PLCPointEntity>.Trans(model);
plcPointRepository.UpdatePLCPoint(entity);
if (model != null && pLCMonitorService.IsRun)
if (model != null && plcMonitorService.IsRun)
{
model.PointValue = pLCMonitorService.WriteValue(model.PointAddress, Type.GetType(model.PointDataType), model.PointValue)?.ToString();
model.PointValue = plcMonitorService.WriteValue(model.PointAddress, Type.GetType(model.PointDataType), model.PointValue)?.ToString();
}
}
}

@ -56,7 +56,7 @@ namespace GuideScreen.UI
option.YAxis.Scale = true;
option.XAxis.Name = "月份";
//option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
option.YAxis.Name = "使用次数";
//option.YAxis.Name = "使用次数";
//数据显示小数位数
series.DecimalPlaces = 0;
@ -92,7 +92,7 @@ namespace GuideScreen.UI
option.YAxis.Scale = true;
option.XAxis.Name = "月份";
//option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
option.YAxis.Name = "使用次数";
//option.YAxis.Name = "使用次数";
//数据显示小数位数
series.DecimalPlaces = 0;
@ -128,7 +128,7 @@ namespace GuideScreen.UI
option.YAxis.Scale = true;
option.XAxis.Name = "月份";
//option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
option.YAxis.Name = "使用次数";
//option.YAxis.Name = "使用次数";
//数据显示小数位数
series.DecimalPlaces = 0;

@ -175,7 +175,7 @@ namespace GuideScreen.Common.Services.Impl
/// <summary>
/// 添加点位记录
/// </summary>
private void AdddeviceRecord(PLCPoint e)
public void AdddeviceRecord(PLCPoint e)
{
switch (e.Device)
{
@ -243,5 +243,14 @@ namespace GuideScreen.Common.Services.Impl
return 0;
}
/// <summary>
/// 获取总用水量
/// </summary>
/// <returns></returns>
public decimal GetWaterTotal()
{
var value = deviceRecordService.WaterTotal();
return value;
}
}
}

@ -599,7 +599,7 @@ namespace GuideScreen.UI
//
this.lblEnvirTempl.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold);
this.lblEnvirTempl.ForeColor = System.Drawing.Color.White;
this.lblEnvirTempl.Location = new System.Drawing.Point(110, 81);
this.lblEnvirTempl.Location = new System.Drawing.Point(110, 84);
this.lblEnvirTempl.Name = "lblEnvirTempl";
this.lblEnvirTempl.Size = new System.Drawing.Size(75, 30);
this.lblEnvirTempl.Style = Sunny.UI.UIStyle.Custom;
@ -613,7 +613,7 @@ namespace GuideScreen.UI
//
this.lblAmmoniaGas.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold);
this.lblAmmoniaGas.ForeColor = System.Drawing.Color.White;
this.lblAmmoniaGas.Location = new System.Drawing.Point(245, 162);
this.lblAmmoniaGas.Location = new System.Drawing.Point(245, 163);
this.lblAmmoniaGas.Name = "lblAmmoniaGas";
this.lblAmmoniaGas.Size = new System.Drawing.Size(34, 32);
this.lblAmmoniaGas.Style = Sunny.UI.UIStyle.Custom;
@ -641,7 +641,7 @@ namespace GuideScreen.UI
//
this.uiLabel27.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Bold);
this.uiLabel27.ForeColor = System.Drawing.Color.White;
this.uiLabel27.Location = new System.Drawing.Point(242, 82);
this.uiLabel27.Location = new System.Drawing.Point(242, 84);
this.uiLabel27.Name = "uiLabel27";
this.uiLabel27.Size = new System.Drawing.Size(34, 33);
this.uiLabel27.Style = Sunny.UI.UIStyle.Custom;
@ -1282,12 +1282,12 @@ namespace GuideScreen.UI
this.chartPassengerFlowTotal.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chartPassengerFlowTotal.ForeColor = System.Drawing.Color.Silver;
this.chartPassengerFlowTotal.LegendFont = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chartPassengerFlowTotal.Location = new System.Drawing.Point(612, 635);
this.chartPassengerFlowTotal.Location = new System.Drawing.Point(612, 644);
this.chartPassengerFlowTotal.Margin = new System.Windows.Forms.Padding(0);
this.chartPassengerFlowTotal.MinimumSize = new System.Drawing.Size(1, 1);
this.chartPassengerFlowTotal.Name = "chartPassengerFlowTotal";
this.chartPassengerFlowTotal.RectColor = System.Drawing.Color.Empty;
this.chartPassengerFlowTotal.Size = new System.Drawing.Size(621, 280);
this.chartPassengerFlowTotal.Size = new System.Drawing.Size(621, 268);
this.chartPassengerFlowTotal.Style = Sunny.UI.UIStyle.Custom;
this.chartPassengerFlowTotal.StyleCustomMode = true;
this.chartPassengerFlowTotal.SubFont = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
@ -1652,12 +1652,12 @@ namespace GuideScreen.UI
this.chartPassengerFlow.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chartPassengerFlow.ForeColor = System.Drawing.Color.Silver;
this.chartPassengerFlow.LegendFont = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chartPassengerFlow.Location = new System.Drawing.Point(-29, 632);
this.chartPassengerFlow.Location = new System.Drawing.Point(-29, 641);
this.chartPassengerFlow.Margin = new System.Windows.Forms.Padding(0);
this.chartPassengerFlow.MinimumSize = new System.Drawing.Size(1, 1);
this.chartPassengerFlow.Name = "chartPassengerFlow";
this.chartPassengerFlow.RectColor = System.Drawing.Color.Empty;
this.chartPassengerFlow.Size = new System.Drawing.Size(667, 286);
this.chartPassengerFlow.Size = new System.Drawing.Size(667, 274);
this.chartPassengerFlow.Style = Sunny.UI.UIStyle.Custom;
this.chartPassengerFlow.StyleCustomMode = true;
this.chartPassengerFlow.SubFont = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
@ -1678,25 +1678,25 @@ namespace GuideScreen.UI
this.toolStripMenuChart,
this.toolStripMenuIClose});
this.contextMenuStrip.Name = "contextMenuStrip";
this.contextMenuStrip.Size = new System.Drawing.Size(139, 76);
this.contextMenuStrip.Size = new System.Drawing.Size(125, 70);
this.contextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip1_ItemClicked);
//
// ToolStripMenuBackAdmin
//
this.ToolStripMenuBackAdmin.Name = "ToolStripMenuBackAdmin";
this.ToolStripMenuBackAdmin.Size = new System.Drawing.Size(138, 24);
this.ToolStripMenuBackAdmin.Size = new System.Drawing.Size(124, 22);
this.ToolStripMenuBackAdmin.Text = "后台管理";
//
// toolStripMenuChart
//
this.toolStripMenuChart.Name = "toolStripMenuChart";
this.toolStripMenuChart.Size = new System.Drawing.Size(138, 24);
this.toolStripMenuChart.Size = new System.Drawing.Size(124, 22);
this.toolStripMenuChart.Text = "报表";
//
// toolStripMenuIClose
//
this.toolStripMenuIClose.Name = "toolStripMenuIClose";
this.toolStripMenuIClose.Size = new System.Drawing.Size(138, 24);
this.toolStripMenuIClose.Size = new System.Drawing.Size(124, 22);
this.toolStripMenuIClose.Text = "关闭";
//
// uiPanel3

@ -161,6 +161,9 @@ namespace GuideScreen.UI
//获取天气信息
await GetWeather();
//总用水量
lblWaterMeter.Text = plcController.GetWaterTotal().ToString();
}
catch (Exception ex)
{
@ -325,7 +328,8 @@ namespace GuideScreen.UI
// ToileUseChartTotal();
//SetDayWarterAndelEctricity();
//计算用水量
SetDayWarterAndelEctricity();
}
#endregion 厕所是否有人
@ -517,12 +521,12 @@ namespace GuideScreen.UI
case PLCPointNameByEnergyMonitoring.WaterConsumption:
//总用水量
var waterValue = e.GetValue<float>();//* 0.001f;
lblWaterMeter.Text = Convert.ToInt32(waterValue).ToString();
//var waterValue = e.GetValue<float>();//* 0.001f;
//lblWaterMeter.Text = Convert.ToInt32(waterValue).ToString();
//今日用水量
var str1 = Convert.ToInt32(plcController.GetTodayWarterConsumption(waterValue)).ToString();
//str1 = str1.Aggregate(string.Empty, (c, i) => c + i + " ");
lblDayWarter.Text = $"今日用水量 {str1} 吨 ";
//var str1 = Convert.ToInt32(plcController.GetTodayWarterConsumption(waterValue)).ToString();
////str1 = str1.Aggregate(string.Empty, (c, i) => c + i + " ");
//lblDayWarter.Text = $"今日用水量 {str1} 吨 ";
break;
#endregion 能耗监控
@ -705,7 +709,7 @@ namespace GuideScreen.UI
option.ToolTip.Visible = true;
option.YAxis.Scale = true;
option.XAxis.Name = "厕位";
option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
//option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
//option.YAxis.Name = "使用次数";
//数据显示小数位数
@ -742,7 +746,7 @@ namespace GuideScreen.UI
option.ToolTip.Visible = true;
option.YAxis.Scale = true;
option.XAxis.Name = "厕位";
option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
//option.XAxis.AxisLabel.Angle = 60;//(0° ~ 90°)
//option.YAxis.Name = "使用次数";
//数据显示小数位数
@ -779,6 +783,12 @@ namespace GuideScreen.UI
chartVacuum.SetOption(option);
}
//真空度过期
if (vacuumIndex > 1000)
{
vacuumIndex = 0;
chartVacuum.Option.Clear();
}
vacuumIndex++;
chartVacuum.Option.AddData("vacuumLine", vacuumIndex, -value);
chartVacuum.Refresh();
@ -788,22 +798,27 @@ namespace GuideScreen.UI
#endregion 图表相关
/// <summary>
/// 模拟今日用水量
/// 计算用水量
/// </summary>
//private void SetDayWarterAndelEctricity()
//{
// var count = toilets.Values.Sum();
// var value1 = count;
// if (value1 == 0)
// {
// value1 = 1;
// }
// //模拟计算
// var dayStr = Math.Round(value1 * 0.0085, 2).ToString().Aggregate(string.Empty, (c, i) => c + i + " ");
// lblDayWarter.Text = $"今日用水量 {dayStr} 吨 ";
// var dayStr1 = Math.Round(value1 * 0.0038, 2).ToString().Aggregate(string.Empty, (c, i) => c + i + " ");
// lblElectricQuantity.Text = $"今日耗电量 {dayStr1} 千瓦时 ";
//}
private void SetDayWarterAndelEctricity()
{
var count = toilets.Values.Sum();
//每用次1.6升水
var value = Math.Round(count * 0.0016, 2);
var dayStr = value.ToString().Aggregate(string.Empty, (c, i) => c + i + " ");
lblDayWarter.Text = $"今日用水量 {dayStr} 吨 ";
plcController.AdddeviceRecord(new PLCPoint
{
Device = PLCDeviceNames.EnergyMonitoring,
Name = PLCPointNameByEnergyMonitoring.WaterConsumption,
Note = "用水量",
DataType = typeof(float),
ObjectValue = value,
});
//总用水量
lblWaterMeter.Text = plcController.GetWaterTotal().ToString();
}
#region Timer
@ -821,27 +836,12 @@ namespace GuideScreen.UI
lblTime.Text = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
//星期
lblweek.Text = DateTime.Today.ToString("dddd", new System.Globalization.CultureInfo("zh-CN"));
//每一分钟,环境监控 NH3H2S 模拟改变(加随机数)
//if (dateTime.Second == 59)
//{
// var enviHydrogenSulfide = 0.09 + (rd.Next(6, 8) / 100f); //e.GetValue<float>();
// lblEnviHydrogenSulfide.Text = Math.Round(enviHydrogenSulfide, 2).ToString() + " PPM";
// processEnviHydrogenSulfide.Value = Convert.ToInt32(enviHydrogenSulfide * 100);
// var ammoniaGas = 0.01 + (rd.Next(1, 3) / 100f);//e.GetValue<float>();
// lblEnviAmmoniaGas.Text = Math.Round(ammoniaGas, 2).ToString() + " PPM";
// processEnviAmmoniaGas.Value = Convert.ToInt32(ammoniaGas * 100);
//}
//零点以后更新的数据
if (dateTime.ToString("HH:mm:ss") == zeroTime)
{
//更新厕位使用情况
toilets = plcController.ToiletPositionRecordTotalByToday();
ToileUseChartByDay();
//真空度过期时间
vacuumIndex = 0;
chartVacuum.Option.Clear();
}
}

Loading…
Cancel
Save