102 lines
3.6 KiB
C#
102 lines
3.6 KiB
C#
using FrontendWebApi.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Routing;
|
|
using Microsoft.Extensions.Logging;
|
|
using NPOI.SS.Formula.Functions;
|
|
using Repository.BackendRepository.Interface;
|
|
using Repository.FrontendRepository.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlTypes;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using System.Text;
|
|
|
|
namespace FrontendWebApi.ApiControllers
|
|
{
|
|
public class DashboardController : MyBaseApiController<GraphManageController>
|
|
{
|
|
private readonly IBackendRepository backendRepository;
|
|
private readonly IFrontendRepository frontendRepository;
|
|
|
|
public DashboardController(IBackendRepository backendRepository, IFrontendRepository frontendRepository)
|
|
{
|
|
this.backendRepository = backendRepository;
|
|
this.frontendRepository = frontendRepository;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<ApiResult<WorkOrderGraph>>> DashAlert()
|
|
{
|
|
ApiResult<WorkOrderGraph> apiResult = new ApiResult<WorkOrderGraph>();
|
|
try
|
|
{
|
|
var sqlString = $@"select ";
|
|
|
|
//apiResult.Data = ;
|
|
apiResult.Code = "0000";
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
apiResult.Code = "9999";
|
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
|
return Ok(apiResult);
|
|
}
|
|
return Ok(apiResult);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("api/AlarmCard")]
|
|
public async Task<ActionResult<ApiResult<List<VAlarmRecord>>>> AlarmCard()
|
|
{
|
|
ApiResult<List<VAlarmRecord>> apiResult = new ApiResult<List<VAlarmRecord>>();
|
|
try
|
|
{
|
|
var sqlString = $@"select * from v_alarm where isOpen = 1";
|
|
var result = await backendRepository.GetAllAsync<VAlarmRecord>(sqlString);
|
|
|
|
apiResult.Data = result;
|
|
apiResult.Code = "0000";
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
apiResult.Code = "9999";
|
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
|
return Ok(apiResult);
|
|
}
|
|
return Ok(apiResult);
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("api/Dashboard/GetTotalElec")]
|
|
public async Task<ActionResult<ApiResult<List<TotalElec>>>> GetTotalElec()
|
|
{
|
|
ApiResult<List<TotalElec>> apiResult = new ApiResult<List<TotalElec>>();
|
|
try
|
|
{
|
|
var sqlString = $@"SELECT
|
|
system_key AS 'building_tag',
|
|
system_value AS 'device_number',
|
|
system_remark AS 'remark'
|
|
FROM variable
|
|
WHERE
|
|
system_type = 'dashboard_total_elec'
|
|
AND deleted = '0'";
|
|
var ess = await backendRepository.GetAllAsync<TotalElec>(sqlString);
|
|
|
|
apiResult.Code = "0000";
|
|
apiResult.Data = ess;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
apiResult.Code = "9999";
|
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
|
return Ok(apiResult);
|
|
}
|
|
return Ok(apiResult);
|
|
}
|
|
}
|
|
}
|