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

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

@ -39,6 +39,6 @@ namespace LanShengInterface
/// <returns></returns> /// <returns></returns>
Task<DeviceErrorReport> GetDeviceErrorReport(DeviceErrorReport report); 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); return Task.FromResult(result);
} }
public async Task<IEnumerable<DeviceError>> GetErrorList() { public async Task<IEnumerable<DeviceError>> GetErrorList(string search) {
return await Db.Queryable<DeviceError>() var _Query = Db.Queryable<DeviceError>()
.WhereIF(!string.IsNullOrWhiteSpace(search), x => x.ErrCode!.Contains(search) || x.ErrMsg!.Contains(search))
.Distinct()
.Select(x => new DeviceError .Select(x => new DeviceError
{ {
ErrCode = x.ErrCode, ErrCode = x.ErrCode,
ErrMsg = x.ErrMsg ErrMsg = x.ErrMsg
}).Distinct() })
.SplitTable(DateTime.Now.AddYears(-1), DateTime.Now) .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 #endregion
} }

Loading…
Cancel
Save