xinjiang/SGGL/BLL/API/HSSE/APIHazardRealTimeService.cs

75 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public class APIHazardRealTimeService
{
#region
/// <summary>
/// 保存
/// </summary>
/// <param name="newDetail"></param>
public static string SaveHazardRealTime(Model.Hazard_RealTimeItem newDetail)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
Model.Hazard_RealTimeDevice realTimeDevice = db.Hazard_RealTimeDevice.FirstOrDefault(x => x.BitNum == newDetail.BitNum);
if (realTimeDevice == null)
{
realTimeDevice = new Model.Hazard_RealTimeDevice();
realTimeDevice.ID = Guid.NewGuid().ToString();
realTimeDevice.UnitId = newDetail.UnitId;
realTimeDevice.UnitName = newDetail.UnitName;
realTimeDevice.HazardName = newDetail.HazardName;
realTimeDevice.HazardLevel = newDetail.HazardLevel;
realTimeDevice.DeviceCode = newDetail.DeviceCode;
realTimeDevice.DeviceName = newDetail.DeviceName;
realTimeDevice.DeviceType = newDetail.DeviceType;
realTimeDevice.SphereType = newDetail.SphereType;
realTimeDevice.TemperatureType = newDetail.TemperatureType;
realTimeDevice.DesignTemperantureMax = newDetail.DesignTemperantureMax;
realTimeDevice.DesignTemperantureMin = newDetail.DesignTemperantureMin;
realTimeDevice.PressureType = newDetail.PressureType;
realTimeDevice.DesignPressure = newDetail.DesignPressure;
realTimeDevice.DesignPressureMax = newDetail.DesignPressureMax;
realTimeDevice.Medium = newDetail.Medium;
realTimeDevice.MediumForm = newDetail.MediumForm;
realTimeDevice.MediumLevelMax = newDetail.MediumLevelMax;
realTimeDevice.Reserves = newDetail.Reserves;
realTimeDevice.StandardCode = newDetail.StandardCode;
realTimeDevice.StandardName = newDetail.StandardName;
realTimeDevice.StandardType = newDetail.StandardType;
realTimeDevice.StandardDes = newDetail.StandardDes;
realTimeDevice.MeasurementUnit = newDetail.MeasurementUnit;
realTimeDevice.MeterMax = newDetail.MeterMax;
realTimeDevice.MeterMin = newDetail.MeterMin;
realTimeDevice.ThresholdLow1 = newDetail.ThresholdLow1;
realTimeDevice.ThresholdLow2 = newDetail.ThresholdLow2;
realTimeDevice.ThresholdMax1 = newDetail.ThresholdMax1;
realTimeDevice.ThresholdMax2 = newDetail.ThresholdMax2;
realTimeDevice.BitNum = newDetail.BitNum;
realTimeDevice.DateTime = DateTime.Now;
realTimeDevice.ProjectId = newDetail.ProjectId;
db.Hazard_RealTimeDevice.InsertOnSubmit(realTimeDevice);
}
Model.Hazard_RealTimeValue realTimeValue = new Model.Hazard_RealTimeValue();
realTimeValue.ID = Guid.NewGuid().ToString();
realTimeValue.Value = newDetail.Value;
realTimeValue.BitNum = newDetail.BitNum;
realTimeValue.DateTime = newDetail.DateTime;
db.Hazard_RealTimeValue.InsertOnSubmit(realTimeValue);
db.SubmitChanges();
return realTimeValue.ID;
}
}
#endregion
}
}