101 lines
3.1 KiB
C#
101 lines
3.1 KiB
C#
![]() |
using System;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using HT.Cloud.Code;
|
|||
|
using HT.Cloud.Domain.ChartsManage;
|
|||
|
using HT.Cloud.Service;
|
|||
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
using HT.Cloud.Service.ChartsManage;
|
|||
|
using HT.Cloud.Service.ReportManage;
|
|||
|
using Serenity.Services;
|
|||
|
|
|||
|
namespace HT.Cloud.Web.Areas.ChartsManage.Controllers
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 创 建:cdl
|
|||
|
/// 日 期:2023-02-23 11:10
|
|||
|
/// 描 述:历史趋势控制器类
|
|||
|
/// </summary>
|
|||
|
[Area("ChartsManage")]
|
|||
|
public class HistoryChartsController : BaseController
|
|||
|
{
|
|||
|
public HistoryChartsService _historyChartsService { get;set;}
|
|||
|
|
|||
|
[HttpGet]
|
|||
|
public async Task<ActionResult> GetAllSubsystemTag()
|
|||
|
{
|
|||
|
|
|||
|
var data = await _historyChartsService.GetAllSubsystemTag();
|
|||
|
return Content(data);
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public async Task<ActionResult> GetSubsystemAllTag(ChartSubsysytemName chartSubsysytemName)
|
|||
|
{
|
|||
|
var data = await _historyChartsService.GetSubsystemAllTag(chartSubsysytemName.SubsysytemName);
|
|||
|
return Content(data);
|
|||
|
}
|
|||
|
|
|||
|
[HttpPost]
|
|||
|
public async Task<ActionResult> GetChartsTagValue(Charts_Params charts_Params)
|
|||
|
{
|
|||
|
short TagID = short.Parse(charts_Params.TagID);
|
|||
|
var StartTime = Gettime(charts_Params.StartTime);
|
|||
|
var EndTime = Gettime(charts_Params.EndTime);
|
|||
|
var Interval =int.Parse(charts_Params.Interval);
|
|||
|
|
|||
|
var data = await _historyChartsService.GetChartsTagValue(TagID, StartTime, EndTime, Interval);
|
|||
|
return Content(data);
|
|||
|
}
|
|||
|
|
|||
|
public string Gettime(string longtime)
|
|||
|
{
|
|||
|
long jsTimeStamp = long.Parse(longtime);
|
|||
|
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
|
|||
|
DateTime dt = startTime.AddMilliseconds(jsTimeStamp);
|
|||
|
return (dt.ToString("yyyy/MM/dd HH:mm:ss"));
|
|||
|
}
|
|||
|
|
|||
|
public class SubAllTagReturn
|
|||
|
{
|
|||
|
//x.TagID, x.Description, x.Units
|
|||
|
public short TagID { get; set; }
|
|||
|
public string Description { get; set; }
|
|||
|
public string Units { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
public class SubsysytemNameList
|
|||
|
{
|
|||
|
public string Lable { get; set; }
|
|||
|
public string Value { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
public class ChartSubsysytemName
|
|||
|
{
|
|||
|
public string SubsysytemName { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
public class HDATETIMEVALUE
|
|||
|
{
|
|||
|
public String HDATETIME { get; set; }
|
|||
|
public decimal VALUE { get; set; }
|
|||
|
}
|
|||
|
public class ChartData
|
|||
|
{
|
|||
|
public decimal value { get; set; }
|
|||
|
public String name { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
public class Charts_Params
|
|||
|
{
|
|||
|
public string TagID { get; set; }
|
|||
|
public string StartTime { get; set; }
|
|||
|
public string EndTime { get; set; }
|
|||
|
public string Interval { get; set; }
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|