|
|
|
|
using Entity.Api.Req;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using Entity.Base;
|
|
|
|
|
using Entity.DbModel.System.SysBaseObject;
|
|
|
|
|
using Entity.Dto.Req;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using NewLife.Reflection;
|
|
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using Qiniu.Storage;
|
|
|
|
|
using Service.Mgr;
|
|
|
|
|
using Service.Station;
|
|
|
|
|
using Service.System;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Service.Init;
|
|
|
|
|
|
|
|
|
|
namespace WebStarter.Controllers.System
|
|
|
|
|
{
|
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class SysConfigController
|
|
|
|
|
{
|
|
|
|
|
private readonly SysConfigService _sysConfigService;
|
|
|
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
|
|
|
|
|
|
public SysConfigController(SysConfigService sysConfigService, IWebHostEnvironment webHostEnvironment)
|
|
|
|
|
{
|
|
|
|
|
_sysConfigService = sysConfigService;
|
|
|
|
|
_webHostEnvironment = webHostEnvironment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("page")]
|
|
|
|
|
public async Task<SqlSugarPagedList<SysConfig>> Page(PageConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
return await _sysConfigService.Page(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("list")]
|
|
|
|
|
public async Task<List<SysConfig>> GetList()
|
|
|
|
|
{
|
|
|
|
|
return await _sysConfigService.GetList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("detail")]
|
|
|
|
|
public async Task<SysConfig> GetDetail([FromQuery] ConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
return await _sysConfigService.GetDetail(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("groupList")]
|
|
|
|
|
public async Task<List<string>> GetGroupList()
|
|
|
|
|
{
|
|
|
|
|
return await _sysConfigService.GetGroupList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("add")]
|
|
|
|
|
public async Task Add(AddConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
await _sysConfigService.AddConfig(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("update")]
|
|
|
|
|
public async Task Update(UpdateConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
await _sysConfigService.UpdateConfig(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("delete")]
|
|
|
|
|
public async Task Delete(DeleteConfigReq input)
|
|
|
|
|
{
|
|
|
|
|
await _sysConfigService.DeleteConfig(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("batchDelete")]
|
|
|
|
|
public async Task BatchDelete(List<long> input)
|
|
|
|
|
{
|
|
|
|
|
await _sysConfigService.BatchDeleteConfig(input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返回 站点基础信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("StationBaseInfo")]
|
|
|
|
|
public async Task<Result<StationBaseInfoResp>> StationBaseInfo()
|
|
|
|
|
{
|
|
|
|
|
StationBaseInfoResp stationBaseInfoResp = new StationBaseInfoResp();
|
|
|
|
|
List<SysConfig> sysConfigs = await _sysConfigService.GetGroupList("Station");
|
|
|
|
|
foreach (var item in sysConfigs)
|
|
|
|
|
{
|
|
|
|
|
switch (item.Code)
|
|
|
|
|
{
|
|
|
|
|
case "StationNo": stationBaseInfoResp.StationNo = item.Value; break;
|
|
|
|
|
case "StationName": stationBaseInfoResp.StationName = item.Value; break;
|
|
|
|
|
case "StationType": stationBaseInfoResp.StationType = item.Value; break;
|
|
|
|
|
case "StationSn": stationBaseInfoResp.StationSn = item.Value; break;
|
|
|
|
|
case "StationLocation": stationBaseInfoResp.StationLocation = item.Value; break;
|
|
|
|
|
case "Longitude": stationBaseInfoResp.Longitude = item.Value; break;
|
|
|
|
|
case "Latitude": stationBaseInfoResp.Latitude = item.Value; break;
|
|
|
|
|
case "AreaCode": stationBaseInfoResp.AreaCode = item.Value; break;
|
|
|
|
|
case "AreaName": stationBaseInfoResp.AreaName = item.Value; break;
|
|
|
|
|
case "Operatetionstime": stationBaseInfoResp.Operatetionstime = item.Value; break;
|
|
|
|
|
case "Sevstatus": stationBaseInfoResp.Sevstatus = Convert.ToSByte(item.Value); break;
|
|
|
|
|
case "Operatetionetime": stationBaseInfoResp.Operatetionetime = item.Value; break;
|
|
|
|
|
case "StationStatus": stationBaseInfoResp.StationStatus = StaticStationInfo.StationStatus; break;
|
|
|
|
|
case "LaunchTime": stationBaseInfoResp.LaunchTime = item.Value; break;
|
|
|
|
|
case "ContactWay": stationBaseInfoResp.ContactWay = item.Value; break;
|
|
|
|
|
case "Principal": stationBaseInfoResp.Principal = item.Value; break;
|
|
|
|
|
case "StationCompany": stationBaseInfoResp.StationCompany = item.Value; break;
|
|
|
|
|
case "SocialCreditCode": stationBaseInfoResp.SocialCreditCode = item.Value; break;
|
|
|
|
|
case "StationSftVer": stationBaseInfoResp.StationSftVer = item.Value; break;
|
|
|
|
|
case "SupplierCode": stationBaseInfoResp.SupplierCode = item.Value; break;
|
|
|
|
|
case "StationVersion": stationBaseInfoResp.StationVersion = item.Value; break;
|
|
|
|
|
case "HardwareVersion": stationBaseInfoResp.HardwareVersion = Convert.ToSByte(item.Value); break;
|
|
|
|
|
case "Cover": stationBaseInfoResp.Cover = item.Value; break;
|
|
|
|
|
case "Faultlevel": stationBaseInfoResp.Faultlevel = Convert.ToInt32(item.Value); break;
|
|
|
|
|
case "LockType": stationBaseInfoResp.LockType = Convert.ToSByte(item.Value); break;
|
|
|
|
|
case "AccessType": stationBaseInfoResp.AccessType = Convert.ToSByte(item.Value); break;
|
|
|
|
|
case "RiseType": stationBaseInfoResp.RiseType = Convert.ToSByte(item.Value); break;
|
|
|
|
|
case "ModifyTime": stationBaseInfoResp.ModifyTime = item.Value; break;
|
|
|
|
|
case "DistributionCapacity": stationBaseInfoResp.DistributionCapacity = Convert.ToInt32(item.Value); break;
|
|
|
|
|
case "TotalPower": stationBaseInfoResp.TotalPower = Convert.ToInt32(item.Value); break;
|
|
|
|
|
case "StationProvince": stationBaseInfoResp.StationProvince = item.Value; break;
|
|
|
|
|
case "StationCity": stationBaseInfoResp.StationCity = item.Value; break;
|
|
|
|
|
case "OrganizationId": stationBaseInfoResp.OrganizationId = Convert.ToInt32(item.Value); break;
|
|
|
|
|
case "StationMac": stationBaseInfoResp.StationMac = item.Value; break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Result<StationBaseInfoResp>.Success(stationBaseInfoResp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 站点编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("StationInfoEditor")]
|
|
|
|
|
public Result<bool> StationInfoEditor([FromBody] StationBaseInfoReq listStationBaseInfoReq)
|
|
|
|
|
{
|
|
|
|
|
bool setResult = false;
|
|
|
|
|
|
|
|
|
|
PropertyInfo[] props = typeof(StationBaseInfoReq).GetProperties();
|
|
|
|
|
|
|
|
|
|
foreach (PropertyInfo fieldInfo in props)
|
|
|
|
|
{
|
|
|
|
|
string newConstConfigInfo = "Station" + "." + fieldInfo.Name;
|
|
|
|
|
object getContent = fieldInfo.GetValue(listStationBaseInfoReq);
|
|
|
|
|
|
|
|
|
|
if (fieldInfo.Name == "ModifyTime")
|
|
|
|
|
{
|
|
|
|
|
if (getContent == null)
|
|
|
|
|
{
|
|
|
|
|
setResult = _sysConfigService.Set(newConstConfigInfo, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
setResult = _sysConfigService.Set(newConstConfigInfo, getContent);
|
|
|
|
|
}
|
|
|
|
|
if (getContent != null)
|
|
|
|
|
setResult = _sysConfigService.Set(newConstConfigInfo, getContent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return Result<bool>.Success(setResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 系统基础配置 上传图片
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("ImgUpLoad")]
|
|
|
|
|
public async Task<Result<SysFile>> ImgUpLoad([Required] IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
SysFile sysFile = await _sysConfigService.UploadAvatar(file, _webHostEnvironment.WebRootPath);
|
|
|
|
|
if (sysFile != null)
|
|
|
|
|
return Result<SysFile>.Success(sysFile);
|
|
|
|
|
else
|
|
|
|
|
return Result<SysFile>.Fail();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|