using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using Opsoft.NetCore.O3App.Domain; using Opsoft.NetCore.O3App.Domain.UnitOfWork.Energy.IServices; using Opsoft.NetCore.O3App.Shared; using Opsoft.NetCore.O3App.WebApi.Models; using System.Collections.Generic; using System.Threading.Tasks; namespace Opsoft.NetCore.O3App.WebApi.Controllers.Energy { public class ElectricityController : BaseApiController { private readonly IElectricityService _ElectricityService; public ElectricityController(IMapper mapper, ILogger logger, IElectricityService ElectricityService) : base(mapper, logger) { _ElectricityService = ElectricityService; } public IActionResult Index() { return View(); } [HttpGet] public async Task> getTreeList(int eType) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getTreeList(eType); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getElectricityOverView([FromQuery] string id) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getElectricityOverView(id); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getUnitByPointNbr([FromQuery] string PointNbr) // { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getUnitByPointNbr(PointNbr); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getWaterOverView([FromQuery] string id) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getWaterOverView(id); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getGasOverView([FromQuery] string id) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getGasOverView(id); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getElectList([FromQuery] string id, [FromQuery] string startdate, [FromQuery] string enddate ) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getElectList(id, startdate, enddate); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getHistoryData([FromQuery] string boxNbr) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getHistoryData(boxNbr); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getWaterList([FromQuery] string id, [FromQuery] string startdate, [FromQuery] string enddate) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getWaterList(id, startdate, enddate); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } [HttpGet] public async Task> getGasList([FromQuery] string id, [FromQuery] string startdate, [FromQuery] string enddate) { return await TryProcess(async input => { RetMessage retMsg = await _ElectricityService.getGasList(id, startdate, enddate); if (retMsg == null || retMsg.Status == 0) { throw new O3AppException(retMsg.Message); } else { return retMsg.Data["data"]; } }, LoginInfo); } } }