ibms-dome/FrontendWebApi/ApiControllers/EnergeManageController.cs

52 lines
2.0 KiB
C#
Raw Normal View History

using FrontendWebApi.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
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;
namespace FrontendWebApi.ApiControllers
{
public class EnergeManageController : MyBaseApiController<EnergeManageController>
{
private readonly IBackendRepository backendRepository;
private readonly IFrontendRepository frontendRepository;
public EnergeManageController(IBackendRepository backendRepository, IFrontendRepository frontendRepository)
{
this.backendRepository = backendRepository;
this.frontendRepository = frontendRepository;
}
[HttpPost]
[Route("api/Energe/GetElecBySubSysTag")]
public async Task<ActionResult<ApiResult<List<ElecSubSystem>>>> GetElecBySubSysTag()
{
ApiResult<List<ElecSubSystem>> apiResult = new ApiResult<List<ElecSubSystem>>();
try
{
var sqlString = $@"SELECT system_key as MainSubTag ,system_value as system_device_tag,system_priority as priority, system_remark FROM variable
where system_type = 'meter_for_subsystem' and deleted = '0'";
var ess = await backendRepository.GetAllAsync<ElecSubSystem>(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);
}
}
}