186 lines
6.2 KiB
C#
Executable File
186 lines
6.2 KiB
C#
Executable File
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<ElectricityController>
|
|
{
|
|
private readonly IElectricityService _ElectricityService;
|
|
public ElectricityController(IMapper mapper, ILogger<ElectricityController> logger, IElectricityService ElectricityService)
|
|
: base(mapper, logger)
|
|
{
|
|
_ElectricityService = ElectricityService;
|
|
}
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
[HttpGet]
|
|
public async Task<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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<BaseResponse<object>> 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);
|
|
}
|
|
|
|
}
|
|
}
|