using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web.Http;
|
using IStation.Model.Api;
|
using IStation.ViewModel;
|
using AutoMapper;
|
using System.Text;
|
|
namespace IStation.WebApi.Controllers
|
{
|
/// <summary>
|
/// 大屏单站点(Bimface 本地加载(松花江用))
|
/// </summary>
|
[RoutePrefix("Demo/StationBimShj")]
|
public class Demo_StationBimShjController : ApiController
|
{
|
|
private class RecordBase1
|
{
|
public string RecordTime { get; set; }
|
public double RecordValue { get; set; }
|
}
|
|
private class RecordBase1ExSignalID : RecordBase1
|
{
|
public long SignalID { get; set; }
|
}
|
|
/// <summary>
|
/// 获取泵站主页信息
|
/// </summary>
|
/// <param name="StationID">泵站ID</param>
|
/// <returns></returns>
|
[Route("GetInitalInfo")]
|
[HttpGet]
|
public Result GetInitalInfo (long StationID)
|
{
|
StationID = 14;
|
string CacheKey = "LargeScreen.Demo.StationBimShj" + StationID;//缓存,就不能加载用户自定义的图层等信息,以后需要用异步加载
|
object objModel = System.Runtime.Caching.MemoryCache.Default.Get(CacheKey);
|
if (objModel != null)
|
{
|
Dictionary<string, object> dict2 = (Dictionary<string, object>)objModel;
|
return new Result_Object(dict2);
|
}
|
|
|
var stationBase = IStation.Service.StationBase.GetByStationID(StationID);
|
if (stationBase == null)
|
{
|
return new Result(IStation.Model.Api.Code.Error, "未找到对应泵站");
|
}
|
|
Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
//搜索BIM
|
//IStation.Service.BimFileMapperView bllBim = new IStation.Service.BimFileMapperView();
|
//var bimFileList = IStation.Service.BimFileMapperView.GetDetailByStationID(StationID);
|
//IStation.Model.BimFileMapperViewDetail defaultBimFile = null;
|
//if (bimFileList != null && bimFileList.Count > 0)
|
//{
|
// defaultBimFile = bimFileList.FirstOrDefault();
|
//}
|
//else
|
{
|
return new Result(IStation.Model.Api.Code.Alert, "未定义BIM模型") ;
|
}
|
//BIM映射ID
|
dict["BimFileMapperID"] = defaultBimFile.ID;
|
|
//摄像头
|
dict["Cameras"] = IStation.Service.CameraBase.GetAll();
|
|
|
//BIM
|
dict["BimfaceFileID"] = defaultBimFile.BimfaceID;
|
//与GetInitalInfo4Remote区别就是这里没有获取
|
//var token = IStation.BIM.BimFaceHelper.GetFileToken(defaultBimFile.BimfaceID.ToString());
|
//if (token != null)
|
//{
|
// dict["BimfaceViewToken"] = token.Token;
|
//}
|
List<IStation.Model.BimComponentMapper> listComponentMapping = null;//产品映射
|
|
#region BIM设置
|
//
|
IStation.Model.BimFileMapperSettings mapSettings = defaultBimFile.Settings;
|
IStation.Model.BimFileSettings fileSettings = defaultBimFile.FileSettings;
|
if (mapSettings != null)
|
listComponentMapping = mapSettings.ComponentMappers;
|
|
|
//var bimEmployeeSet = IStation.Service.BimEmployeeSet.GetByEmployeeAndMapperID(EmployeeID, defaultBimFile.ID);
|
//IStation.Model.BimEmployeeSettings employeeSettings = bimEmployeeSet == null ? null : bimEmployeeSet.Settings;
|
|
|
List<IStation.ViewModel.CommonBimLayer> bimLayers = new List<IStation.ViewModel.CommonBimLayer>();
|
//List<IStation.ViewModel.BimCamera> bimCameras = new List<ViewModel.BimCamera>();
|
List<IStation.ViewModel.BimWalkThrough> bimBimWalkThrough = new List<IStation.ViewModel.BimWalkThrough>();
|
|
if (fileSettings != null)
|
{
|
#region 图层
|
var allCustomComponentsLayers = fileSettings.CustomComponentsLayers;
|
if (allCustomComponentsLayers != null && allCustomComponentsLayers.Count > 0)
|
{
|
foreach (var layer in allCustomComponentsLayers)
|
{
|
IStation.ViewModel.CommonBimLayer bimLayer = new IStation.ViewModel.CommonBimLayer();
|
if (layer.ComponentIds == null || layer.ComponentIds.Count() == 0)
|
continue;
|
|
bimLayer.Name = layer.Name;
|
bimLayer.ID = layer.ID;
|
bimLayer.ComponentIds = layer.ComponentIds;
|
bimLayer.Type = 0;//表示 系统添加
|
bimLayer.IsDisp = true;
|
bimLayers.Add(bimLayer);
|
}
|
}
|
#endregion
|
|
#region 视图
|
//var viewBimCameras = fileSettings.CustomCameraStatus_3Ds;
|
//if (viewBimCameras != null && viewBimCameras.Count > 0)
|
//{
|
// foreach (var m in viewBimCameras)
|
// bimCameras.Add(new ViewModel.BimCamera(m));
|
//}
|
#endregion
|
|
#region 路径漫游
|
var customWalkThroughs = fileSettings.CustomWalkThroughs;
|
if (customWalkThroughs != null && customWalkThroughs.Count > 0)
|
{
|
foreach (var m in customWalkThroughs)
|
bimBimWalkThrough.Add(new IStation.ViewModel.BimWalkThrough(m));
|
}
|
#endregion
|
}
|
#region 暂时不要自定义的视图
|
//if (employeeSettings != null)
|
//{
|
// //
|
// //var allEmployeeComponentsLayers = employeeSettings.CustomComponentsLayers;
|
// //if (allEmployeeComponentsLayers != null)
|
// //{
|
// // foreach (var layer in allEmployeeComponentsLayers)
|
// // {
|
// // IStation.ViewModel.BimLayer bimLayer = new ViewModel.BimLayer();
|
// // if (layer.ComponentIds == null || layer.ComponentIds.Count() == 0)
|
// // continue;
|
|
// // bimLayer.Name = layer.Name;
|
// // bimLayer.ID = layer.ID;
|
// // bimLayer.ComponentIds = layer.ComponentIds;
|
// // bimLayer.Type = 1;//表示 员工添加
|
// // bimLayers.Add(bimLayer);
|
// // }
|
// //}
|
//}
|
#endregion
|
|
//
|
dict["LayerSettingGeneral"] = bimLayers;
|
|
if (fileSettings != null)
|
dict["FileSettingCamera"] = fileSettings.CustomCameraStatus_3Ds;
|
dict["FileSettingWalkThrough"] = bimBimWalkThrough;
|
|
//建筑物外墙
|
var layer_components_建筑物 = new List<string>() {"1345184", "1345372", "1345386", "1345400", "1345416", "1345430", "1345444", "1345458", "1345472", "1345490",
|
"1345549", "1345547", "1345545", "1345543", "1345541", "1345539", "1345537", "1345535", "1515102", "1516086", "1391996",
|
"1391995", "1391994", "1391993", "1391992", "1391991", "1391989", "1391649", "1391896", "1391903", "1391910", "1391917", "1391924", "1391931" };
|
IStation.ViewModel.SpecBimLayer bimLayer建筑物外墙 = new IStation.ViewModel.SpecBimLayer();
|
bimLayer建筑物外墙.IsDisp = true;
|
bimLayer建筑物外墙.ComponentIds = layer_components_建筑物;
|
|
dict["LayerSetting4Build"] = bimLayer建筑物外墙;
|
|
|
//if (fileSettings != null && fileSettings.CustomComponentsDivs string.IsNullOrEmpty(defaultBimFile.ViewSettingData))
|
//{
|
// IStation.Entity.BimFileMapping.ViewSettings bimViewSettings = null;
|
// bimViewSettings = IStation.Entity.BimFileMapping.ViewSettings.ToObject(defaultBimFile.ViewSettingData);
|
// dict["BimViewSettings"] = bimViewSettings;
|
//}
|
#endregion
|
|
|
|
#region 监控面板
|
//
|
var allProducts = IStation.Service.ProductBase.GetByStationID(StationID);
|
if (allProducts != null && mapSettings != null)
|
{
|
List<IStation.ViewModel.BimTipPanel> allMinitorPanel = new List<IStation.ViewModel.BimTipPanel>();
|
|
List<IStation.Model.BimMonitorPanelLayer> listMonitorPanelLayer = mapSettings.MonitorPanelLayers;
|
if (listMonitorPanelLayer != null)
|
{
|
//List<long> signalIDs = new List<long>();
|
foreach (var signalLoc in listMonitorPanelLayer)
|
{
|
foreach (var monitorPanel in signalLoc.MonitorPanels)
|
{
|
if (monitorPanel.LocationType == IStation.Model.BimMonitorPanel.eLocationType.机泵)
|
{
|
#region 机泵
|
IStation.ViewModel.BimTipPanel panel_minitor_view = new IStation.ViewModel.BimTipPanel();
|
panel_minitor_view.ProductID = monitorPanel.LocationObjectID;
|
panel_minitor_view.Name = monitorPanel.Name;
|
//(from x in allProducts where x.ID == monitorPanel.LocationObjectID select x.Name).FirstOrDefault();
|
panel_minitor_view.Posi = new IStation.ViewModel.BimPosi() { x = monitorPanel.WorldPostion.x, y = monitorPanel.WorldPostion.y, z = monitorPanel.WorldPostion.z };
|
panel_minitor_view.IsDispSignal = monitorPanel.ValuesVisible;
|
|
if (monitorPanel.ValuesVisible)
|
{
|
panel_minitor_view.RunStatus = 1;
|
panel_minitor_view.SignalList = new List<IStation.ViewModel.RecordBase>();
|
foreach (var measure_point_id in monitorPanel.MeasurePointIds)
|
{
|
var signal = IStation.Service.SignalInfoHelper.GetDefaultByPointID(measure_point_id);
|
if (signal == null)
|
continue;
|
|
panel_minitor_view.SignalList.Add(new IStation.ViewModel.RecordBase(signal));
|
}
|
}
|
|
|
allMinitorPanel.Add(panel_minitor_view);
|
#endregion
|
}
|
else if (monitorPanel.LocationType == IStation.Model.BimMonitorPanel.eLocationType.总管)
|
{
|
#region 总管
|
IStation.ViewModel.BimTipPanel panel_minitor_view = new IStation.ViewModel.BimTipPanel();
|
panel_minitor_view.ProductID = monitorPanel.LocationObjectID;
|
panel_minitor_view.Name = monitorPanel.Name;
|
//(from x in allProducts where x.ID == monitorPanel.LocationObjectID select x.Name).FirstOrDefault();
|
panel_minitor_view.Posi = new IStation.ViewModel.BimPosi() { x = monitorPanel.WorldPostion.x, y = monitorPanel.WorldPostion.y, z = monitorPanel.WorldPostion.z };
|
panel_minitor_view.IsDispSignal = monitorPanel.ValuesVisible;
|
|
if (monitorPanel.ValuesVisible)
|
{
|
panel_minitor_view.RunStatus = 1;
|
panel_minitor_view.SignalList = new List<IStation.ViewModel.RecordBase>();
|
foreach (var measure_point_id in monitorPanel.MeasurePointIds)
|
{
|
var signal = IStation.Service.SignalInfoHelper.GetDefaultByPointID(measure_point_id);
|
if (signal == null)
|
continue;
|
|
panel_minitor_view.SignalList.Add(new IStation.ViewModel.RecordBase(signal));
|
}
|
}
|
|
|
allMinitorPanel.Add(panel_minitor_view);
|
#endregion
|
}
|
}
|
|
}
|
|
//为了页面加载数据,初始化时不读取数据
|
//var records = IStation.SignalRecordHelper.GetLastRecordBySignalID(signalIDs, 120);
|
//if(records != null)
|
//{
|
// foreach(var panel in allMinitorPanel)
|
// {
|
// foreach(var s in panel.SignalList)
|
// {
|
// var r = (from x in records where x.SignalID == s.ID orderby x.RecordTime select x).LastOrDefault();
|
// if(r != null)
|
// {
|
// s.RecordValue = r.RecordValue.ToString();
|
// s.ReocrdTime = r.RecordTime;
|
// panel.RunStatus = 1;
|
// }
|
// }
|
// }
|
//}
|
}
|
|
dict["MinitorPanel"] = allMinitorPanel;
|
}
|
#endregion
|
|
|
|
|
|
|
|
#region 模型树
|
int pump_number = 0;
|
if (allProducts != null)
|
{
|
List<IStation.ViewModel.BimMenuTreeNodeGrp> productTreeList = new List<IStation.ViewModel.BimMenuTreeNodeGrp>();
|
|
IStation.ViewModel.BimMenuTreeNodeGrp grp泵站 = new BimMenuTreeNodeGrp();
|
grp泵站.NodeID = string.Format("S{0}", IStation.ObjectType.Station_泵站);
|
grp泵站.Name = "泵站";
|
grp泵站.ObjectType = IStation.ObjectType.Station_泵站;
|
grp泵站.Nodes = new List<BimMenuTreeNode>();
|
|
IStation.ViewModel.BimMenuTreeNode tree_node_station = new IStation.ViewModel.BimMenuTreeNode();
|
tree_node_station.NodeID = string.Format("S{0}child", StationID);
|
tree_node_station.Name = stationBase.Name;
|
tree_node_station.ObjectID = StationID;
|
tree_node_station.ObjectType = IStation.ObjectType.Station_泵站;
|
|
var all_station_signals = IStation.Service.SignalInfoHelper.GetOnlyByStationID(StationID);
|
if (all_station_signals != null && all_station_signals.Count > 0)
|
{
|
List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
|
foreach (var s in all_station_signals)
|
{
|
IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
|
vm_SignalList.Add(v);
|
}
|
|
tree_node_station.SignalList = vm_SignalList;
|
}
|
grp泵站.Nodes.Add(tree_node_station);
|
productTreeList.Add(grp泵站);
|
|
|
|
|
//
|
IStation.ViewModel.BimMenuTreeNodeGrp grp机组 = new BimMenuTreeNodeGrp();
|
grp机组.NodeID = string.Format("M{0}", IStation.ObjectType.Machine_机泵);
|
grp机组.Name = "机泵";
|
grp机组.ObjectType = IStation.ObjectType.Machine_机泵;
|
grp机组.Nodes = new List<BimMenuTreeNode>();
|
|
var pumpRunInfos = new Service.PumpRunInfoLog().GetByPumpSystemID((from x in allProducts select x.ID));
|
if (pumpRunInfos == null)
|
pumpRunInfos = new List<Model.PumpRunInfoLog>();
|
foreach (var product in allProducts)
|
{
|
//if (product.SubType == IStation.ObjectType.Equipment_泵)
|
//{
|
// continue;
|
//}
|
//else if (product.SubType == IStation.ObjectType.Equipment_电机)
|
//{
|
// continue;
|
//}
|
//else if (product.SubType == IStation.ObjectType.Machine_机泵组)
|
//{
|
// continue;
|
//}
|
if (product.SubType != IStation.ObjectType.Machine_机泵)
|
{//暂时只有机泵
|
continue;
|
}
|
pump_number++;
|
IStation.ViewModel.BimMenuTreeNode tree_node_product = new IStation.ViewModel.BimMenuTreeNode();
|
tree_node_product.NodeID = string.Format("P{0}", product.ID);
|
tree_node_product.Name = product.Name;
|
tree_node_product.ObjectID = product.ID;
|
tree_node_product.ObjectType = product.SubType;
|
|
if (listComponentMapping != null)
|
{
|
tree_node_product.BimID = (from x in listComponentMapping where x.BelongType == IStation.ObjectType.Product_资产 && x.BelongID == product.ID select x.ComponentID).FirstOrDefault();
|
}
|
|
var pumpRunInfo = (from x in pumpRunInfos where x.ObjectID == product.ID select x).FirstOrDefault();
|
if (pumpRunInfo != null)
|
{
|
tree_node_product.RunStatus = (int)pumpRunInfo.RunStatus;
|
}
|
|
|
List<long> productids = new List<long>();
|
productids.Add(product.ID);
|
var childProducts = IStation.Service.ProductBase.GetAllChildByProductID(product.ID);
|
if (childProducts != null && childProducts.Count() > 0)
|
{
|
productids.AddRange(from x in childProducts select x.ID);
|
}
|
|
var all_product_signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
|
if (all_product_signals != null && all_product_signals.Count > 0)
|
{
|
List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
|
foreach (var s in all_product_signals)
|
{
|
IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
|
vm_SignalList.Add(v);
|
}
|
|
tree_node_product.SignalList = vm_SignalList;
|
}
|
|
|
|
grp机组.Nodes.Add(tree_node_product);
|
}
|
|
productTreeList.Add(grp机组);
|
dict["ProductTree"] = productTreeList;
|
}
|
#endregion
|
|
|
//基本信息
|
double longitude = 0, latitude = 0;
|
var pointInfo = Model.Map.PointInfo.ToModel(stationBase.MapPosition);
|
if (pointInfo != null)
|
{
|
longitude = pointInfo.Longitude;
|
latitude = pointInfo.Latitude;
|
}
|
|
dict["BaseInfo"] = new { ID = StationID, Name = stationBase.Name, Address = stationBase.Address, Longitude = longitude, Latitude = latitude, PumpNumber = pump_number };
|
|
|
|
System.Runtime.Caching.MemoryCache.Default.Set(CacheKey, dict, DateTimeOffset.Now.AddMinutes(2.3));
|
|
return new Result_Model<Dictionary<string, object>>(dict) ;
|
}
|
/// <summary>
|
/// 获取产品属性信息
|
/// </summary>
|
/// <param name="ProductID">产品ID</param>
|
/// <param name="IsIncludeBaseInfo">是否包含基础信息</param>
|
/// <returns></returns>
|
[Route("GetProductPropList")]
|
[HttpGet]
|
public Result GetProductPropList(long ProductID, bool IsIncludeBaseInfo)
|
{
|
var equipment = IStation.Service.ProductBase.GetByProductID(ProductID);
|
if (equipment == null)
|
{
|
return new Result(IStation.Model.Api.Code.Error, "未检索到设备");
|
}
|
|
string manufacturerName = "";
|
if (equipment.ManufacturerID > 0)
|
{
|
manufacturerName = IStation.Service.Manufacture.GetManufactureNameByID(equipment.ManufacturerID);
|
}
|
Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
var ThumbRealImage = "";
|
if (!string.IsNullOrEmpty(equipment.RealImage))
|
{
|
string[] temp = equipment.RealImage.Split('.');
|
string ext = "." + temp[temp.Length - 1].ToLower();
|
ThumbRealImage = equipment.RealImage.Replace(ext, "_th" + ext);
|
}
|
|
|
List<IStation.ViewModel.ProductProp> listProp = new List<IStation.ViewModel.ProductProp>();
|
if (IsIncludeBaseInfo)
|
{
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "ID", PropValue = equipment.ID.ToString() });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "名称", PropValue = equipment.Name });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "编号", PropValue = equipment.NO });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "型号", PropValue = equipment.Code });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "规格", PropValue = equipment.Specification });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "材质", PropValue = equipment.Material });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "厂商名称", PropValue = manufacturerName });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "出厂编号", PropValue = equipment.ManufacturerNO });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "出厂日期", PropValue = equipment.ManufacturerDay });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "基本信息", PropName = "合同编号", PropValue = equipment.ContractNO });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = -1, GroupName = "基本信息", PropName = "ThumbRealImage", PropValue = ThumbRealImage });
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = -1, GroupName = "基本信息", PropName = "RealImage", PropValue = equipment.RealImage });
|
}
|
|
|
//机泵下的电机和泵额定参数
|
IStation.Model.RatedParas.Pump ratedParas泵 = null;
|
IStation.Model.RatedParas.Motor ratedParas电机 = null;
|
if (equipment.SubType == IStation.ObjectType.Machine_机泵)
|
{
|
var childs = IStation.Service.ProductBase.GetAllChildByProductID(equipment.ID);
|
if (childs != null && childs.Count > 1)
|
{
|
var pump = childs.Find(x => x.SubType == IStation.ObjectType.Equipment_泵);
|
if (pump != null && !string.IsNullOrEmpty(pump.RatedParas))
|
ratedParas泵 = Model.RatedParas.Pump.ToModel(pump.RatedParas);
|
var motor = childs.Find(x => x.SubType == IStation.ObjectType.Equipment_电机);
|
if (motor != null && !string.IsNullOrEmpty(motor.RatedParas))
|
ratedParas电机 = Model.RatedParas.Motor.ToModel(motor.RatedParas);
|
}
|
}
|
if (equipment.SubType == IStation.ObjectType.Equipment_泵 && !string.IsNullOrEmpty(equipment.RatedParas))
|
{
|
ratedParas泵 = Model.RatedParas.Pump.ToModel(equipment.RatedParas);
|
}
|
if (equipment.SubType == IStation.ObjectType.Equipment_电机 && !string.IsNullOrEmpty(equipment.RatedParas))
|
{
|
ratedParas电机 = Model.RatedParas.Motor.ToModel(equipment.RatedParas);
|
}
|
if (ratedParas泵 != null)
|
{
|
if (ratedParas泵.Q > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定流量", PropValue = ratedParas泵.Q.ToString() });
|
if (ratedParas泵.H > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定扬程", PropValue = ratedParas泵.H.ToString() });
|
if (ratedParas泵.NPSHr > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定汽蚀", PropValue = ratedParas泵.NPSHr.ToString() });
|
}
|
if (ratedParas电机 != null)
|
{
|
if (ratedParas电机.P > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "电机功率", PropValue = ratedParas电机.P.ToString() });
|
if (ratedParas电机.N > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "电机转速", PropValue = ratedParas电机.N.ToString() });
|
if (ratedParas电机.I > 0)
|
listProp.Add(new IStation.ViewModel.ProductProp() { ID = 0, GroupName = "额定参数", PropName = "额定电流", PropValue = ratedParas电机.I.ToString() });
|
}
|
|
//附加属性
|
var otherProViews = IStation.Service.ProductTypePropView.GetByProductTypeID(equipment.ProductTypeID);
|
if (otherProViews != null && otherProViews.Count > 0)
|
{
|
var dic = new Eventech.Model.LongAndStringDict1(equipment.PropsParas);
|
foreach (var prop in otherProViews)
|
{
|
listProp.Add(new IStation.ViewModel.ProductProp
|
{
|
ID = prop.ID,
|
PropName = prop.PropName,
|
GroupName = prop.GroupName,
|
PropValue = dic.ContainsKey(prop.ID) ? dic[prop.ID] : prop.DefaultValue
|
});
|
}
|
}
|
|
return new Result_Model<List<IStation.ViewModel.ProductProp>>(listProp);
|
}
|
|
/// <summary>
|
/// 获取产品属性信息
|
/// </summary>
|
/// <param name="ProductID">产品ID</param>
|
/// <param name="InIncludeChild">是否包含基础信息</param>
|
/// <returns></returns>
|
[Route("GetSignalListByProductID")]
|
[HttpGet]
|
public Result GetSignalListByProductID(long ProductID,bool InIncludeChild)
|
{
|
List<long> productids = new List<long>();
|
productids.Add(ProductID);
|
|
List<IStation.Model.MeasurePointSignalView > signals = null;
|
if (InIncludeChild)
|
{
|
var childProducts = IStation.Service.ProductBase.GetAllChildByProductID(ProductID);
|
if (childProducts != null && childProducts.Count() > 0)
|
{
|
productids.AddRange(from x in childProducts select x.ID);
|
}
|
|
signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
|
}
|
else
|
{
|
signals = IStation.Service.SignalInfoHelper.GetOnlyByProductID(productids);
|
}
|
//
|
|
if (signals == null || signals.Count() == 0)
|
{
|
return new Result(IStation.Model.Api.Code.Error, "未配置监控");
|
}
|
|
List<IStation.ViewModel.RecordBase> vm_SignalList = new List<IStation.ViewModel.RecordBase>();
|
|
foreach (var s in signals)
|
{
|
IStation.ViewModel.RecordBase v = new IStation.ViewModel.RecordBase(s);
|
|
vm_SignalList.Add(v);
|
}
|
|
return new Result_Model<List<IStation.ViewModel.RecordBase>>(vm_SignalList);
|
|
}
|
|
#region 多个SignalID的最近记录
|
/// <summary>
|
/// 多个SignalID的最近记录
|
/// </summary>
|
/// <param name="SignalID">信号ID</param>
|
/// <param name="Second">最近多少秒</param>
|
/// <returns></returns>
|
[Route("GetMultiSignalLastRecord")]
|
[HttpGet]
|
public Result GetMultiSignalLastRecord( string SignalID, int Second)
|
{
|
string[] SignalIDs1 = SignalID.Split(',');
|
if (SignalIDs1 == null || SignalIDs1.Count() == 0)
|
{
|
return new Result(IStation.Model.Api.Code.Error, "没有输入 SignalID 参数");
|
}
|
List<long> SignalIDs2 = new List<long>();
|
foreach (var id in SignalIDs1)
|
{
|
if (!string.IsNullOrEmpty(id))
|
SignalIDs2.Add(Convert.ToInt64(id));
|
}
|
var signal_array = IStation.Service.SignalInfoHelper.GetBySignalID(SignalIDs2);
|
|
if (Second < 1)
|
Second = 600;
|
//if (!string.IsNullOrEmpty(request["Second"]))
|
//{
|
// Second = Convert.ToInt32(request["Second"]);
|
//}
|
|
var vm_list = new List<RecordBase1ExSignalID>();
|
var records = new Service.Signal().GetLastGeneralRecord(signal_array.Select(x=>x.MeasurePointID));
|
|
// IStation.LogHelper.Info("StoreObjectID:" + String.Join(",", (from x in signal_array select x.StoreObjectID)));
|
if (records == null || records.Count() == 0)
|
{
|
return new Result_Model<List<RecordBase1ExSignalID>>(vm_list);
|
}
|
|
foreach (var r in records)
|
{
|
var signal = (from x in signal_array where x.MeasurePointID == r.ObjectId select x).FirstOrDefault();
|
if (signal == null)
|
continue;
|
|
RecordBase1ExSignalID vm = new RecordBase1ExSignalID();
|
vm.SignalID = signal.SignalID;
|
vm.RecordTime = r.DataTime.ToString("yyyy-MM-dd HH:mm:ss");
|
vm.RecordValue = GetDispValue(signal, r.DataValue);
|
if (Second > 0)
|
{
|
if ((DateTime.Now - r.DataTime).TotalSeconds < Second)
|
{
|
vm_list.Add(vm);
|
}
|
}
|
else
|
{
|
vm_list.Add(vm);
|
}
|
}
|
|
return new Result_Model<List<RecordBase1ExSignalID>>(vm_list);
|
}
|
private static double GetDispValue(IStation.Model.GeneralMonitorPointView signal, double minitorDataValue)
|
{
|
//// Math.Round(record.DataValue, signal.DecimalPlaces);
|
return Math.Round(minitorDataValue, 4);
|
}
|
#endregion
|
|
}
|
}
|