You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.5 KiB
C#
85 lines
3.5 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using SlnMesnac.Model.domain;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SlnMesnac.Repository.service.Impl
|
|
{
|
|
public class LogoIdentifyImpl : ILogoIdentifyService
|
|
{
|
|
private readonly ILogger<LogoIdentify> _logger;
|
|
|
|
private readonly Repository<LogoIdentify> _rep;
|
|
|
|
public LogoIdentifyImpl(ILogger<LogoIdentify> logger, Repository<LogoIdentify> rep)
|
|
{
|
|
_logger = logger;
|
|
_rep = rep;
|
|
}
|
|
|
|
public async Task<List<LogoIdentify>> GetAllRecordAsync()
|
|
{
|
|
|
|
//List<LogoIdentify> list = null;
|
|
//list = await _rep.GetListAsync(x => x.RecordTime >= DateTime.Now.AddDays(-3));
|
|
//return list;
|
|
|
|
List<LogoIdentify> list = null;
|
|
list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-3) });
|
|
return list;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 时间段条件查询
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task<List<LogoIdentify>> QueryAllByTime(string time1, string time2)
|
|
{
|
|
try
|
|
{
|
|
List<LogoIdentify> list = null;
|
|
if(time1 == null && time2 == null){
|
|
list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Now.AddDays(-1) });
|
|
}
|
|
else if (time1 == null)
|
|
{
|
|
list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME <= @RecordTime ", new { RecordTime = DateTime.Parse(time2) });
|
|
// list = _rep.GetList().Where(x => x.RecordTime <= DateTime.Parse(time2)).ToList();
|
|
}else if (time2 == null)
|
|
{
|
|
list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime ", new { RecordTime = DateTime.Parse(time1) });
|
|
// list = _rep.GetList().Where(x => x.RecordTime >= DateTime.Parse(time1)).ToList();
|
|
}
|
|
else
|
|
{
|
|
list = await _rep.Context.Ado.SqlQueryAsync<LogoIdentify>("select ID,PRODUCT_CODE,MATERIAL_TYPE,IS_CHECKED,RESULT,RECORD_TIME,MATERIAL_NAME from LOGO_IDENTIFY where RECORD_TIME >= @RecordTime1 AND RECORD_TIME <= @RecordTime2 ", new { RecordTime1 = DateTime.Parse(time1), RecordTime2 = DateTime.Parse(time2) });
|
|
// list = _rep.GetList().Where(x=>x.RecordTime >= DateTime.Parse(time1) && x.RecordTime <= DateTime.Parse(time2)).ToList();
|
|
}
|
|
return list;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError("时间段条件查询QueryAllByTime()出现异常:" + ex);
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool InsertRecord(LogoIdentify ocrRecord)
|
|
{
|
|
return _rep.Insert(ocrRecord);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|