52 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			52 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using LinqToDB;
							 | 
						|||
| 
								 | 
							
								using log4net;
							 | 
						|||
| 
								 | 
							
								using MasaBlazorApp3.DataAccess.Dao;
							 | 
						|||
| 
								 | 
							
								using MasaBlazorApp3.Pojo;
							 | 
						|||
| 
								 | 
							
								using MasaBlazorApp3.Pojo.Config;
							 | 
						|||
| 
								 | 
							
								using MasaBlazorApp3.Port;
							 | 
						|||
| 
								 | 
							
								using Microsoft.Extensions.Options;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Data.Common;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Text;
							 | 
						|||
| 
								 | 
							
								using System.Threading.Tasks;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace MasaBlazorApp3.DataAccess.Impl
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public class HkcChangeShiftsDao: IHkcChangeShiftsDao
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        private readonly AppDataConnection _connection;
							 | 
						|||
| 
								 | 
							
								        private readonly SettingConfig _setting;
							 | 
						|||
| 
								 | 
							
								        private readonly ILog logger = LogManager.GetLogger(typeof(HkcChangeShifts));
							 | 
						|||
| 
								 | 
							
								        private readonly PortUtil _portUtil;
							 | 
						|||
| 
								 | 
							
								        public HkcChangeShiftsDao(AppDataConnection connection, IOptions<SettingConfig> setting, PortUtil portUtil)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            _connection = connection;
							 | 
						|||
| 
								 | 
							
								            _setting = setting.Value;
							 | 
						|||
| 
								 | 
							
								            _portUtil = portUtil;
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        public async Task<PageData<HkcChangeShifts>> GetChangeShiftRecordAsync(DateTime start, DateTime end, int? take, int? skip)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var query = _connection.HkcChangeShifts.AsQueryable().Where(it => it.MachineId.Equals(_setting.machineId));
							 | 
						|||
| 
								 | 
							
								            if (start != null && start != DateTime.MinValue)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                query = query.Where(mr => mr.optDate > start);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (end != null && end != DateTime.MinValue)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                query = query.Where(mr => mr.optDate < end);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            int pagedData = await query.CountAsync();
							 | 
						|||
| 
								 | 
							
								            List<HkcChangeShifts> Records = await query
							 | 
						|||
| 
								 | 
							
								                .OrderByDescending(mr => mr.optDate)
							 | 
						|||
| 
								 | 
							
								                .Skip((int)skip)
							 | 
						|||
| 
								 | 
							
								                .Take((int)take)
							 | 
						|||
| 
								 | 
							
								                .ToListAsync();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            return new PageData<HkcChangeShifts>() { Desserts = Records, TotalDesserts = pagedData };
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |