main
潘建东 11 months ago
parent b2ce7590ce
commit 26eacdec70

@ -103,11 +103,11 @@ namespace LanShengAPI.Controllers
[HttpGet("DeviceErrorList")]
public async Task<ActionResult> DeviceErrorList()
public async Task<ActionResult> DeviceErrorList([FromQuery] string search = "")
{
try
{
return Ok(await DeviceService.GetErrorList());
return Ok(await DeviceService.GetErrorList(search));
}
catch (BadRequestException ex)
{

@ -39,6 +39,6 @@ namespace LanShengInterface
/// <returns></returns>
Task<DeviceErrorReport> GetDeviceErrorReport(DeviceErrorReport report);
Task<IEnumerable<DeviceError>> GetErrorList();
Task<IEnumerable<DeviceError>> GetErrorList(string search);
}
}

@ -1423,15 +1423,24 @@ namespace LanShengService
return Task.FromResult(result);
}
public async Task<IEnumerable<DeviceError>> GetErrorList() {
return await Db.Queryable<DeviceError>()
public async Task<IEnumerable<DeviceError>> GetErrorList(string search) {
var _Query = Db.Queryable<DeviceError>()
.WhereIF(!string.IsNullOrWhiteSpace(search), x => x.ErrCode!.Contains(search) || x.ErrMsg!.Contains(search))
.Distinct()
.Select(x => new DeviceError
{
ErrCode = x.ErrCode,
ErrMsg = x.ErrMsg
}).Distinct()
})
.SplitTable(DateTime.Now.AddYears(-1), DateTime.Now)
.ToListAsync();
.Distinct()
.Select(x => new DeviceError
{
ErrCode = x.ErrCode,
ErrMsg = x.ErrMsg
});
var _Sql = _Query.ToSqlString();
return await _Query.ToListAsync();
}
#endregion
}

Loading…
Cancel
Save