1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using AutoMapper;
- using HandyControl.Data;
- using LogoForceTestApp.Modules.MainModule.Models;
- using Prism.Commands;
- using Prism.Mvvm;
- using Repository;
- using Repository.Entiies;
- using Serilog;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace LogoForceTestApp.Modules.MainModule.ViewModels
- {
- internal class QualityTracingViewModel : BindableBase
- {
- public List<Information> InfNew { get; set; }
- private readonly IMapper _mapper;
- private readonly List<Information> _infNew;
- public int PageIndex { get; set; } = 1;
- public int MaxCount { get; set; } = 1;
- public int PageCount { get; set; } = 20;
- public DateTime SelectedStartDate { get; set; }
- public DateTime SelectedEndDate { get; set; }
- public DelegateCommand<FunctionEventArgs<int>> PageUpdatedCmd => new(PageUpdated);
- private readonly IRepository repository;
- public string OperatorCode { get; set; }
- public DelegateCommand QueryCommand { get; set; }
- public QualityTracingViewModel(IMapper mapper, IRepository repository)
- {
- SelectedStartDate = DateTime.Today;
- SelectedEndDate = DateTime.Today;
- InfNew = new List<Information>();
- _infNew=new List<Information>();
- _mapper = mapper;
-
- //
- QueryCommand = new DelegateCommand(query);
- this.repository = repository;
- }
-
- /// <summary>
- /// 页码改变
- /// </summary>
- private void PageUpdated(FunctionEventArgs<int> info)
- {
- InfNew = _infNew.Skip((info.Info - 1) * PageCount).Take(PageCount).Reverse().ToList();
- }
- public int GeneralTime { get; set; }
- public int AllNumber { get; set; }
- private void query()
- {
- if (SelectedEndDate < SelectedStartDate || SelectedStartDate == default)
- {
- MessageBox.Show("请选择正确的日期", "提示");
- return;
- }
- _infNew.Clear();
- var endTime = SelectedEndDate.AddDays(1);
- var list = repository.GetAllQuery<Information>(c => c.OperatorCode == OperatorCode && c.CreateTime >= SelectedStartDate&& c.CreateTime <= endTime);
- //var list = repository.GetAllQuery<Information>(c => c.OperatorCode == OperatorCode && c.CreateTime >= DateTime.Today);
- GeneralTime = list.Sum(c => c.SpendTime);//个人生产总时间
- AllNumber = list.Count();//个人生产总量
- list.Reverse();
- var dtos = _mapper.Map<List<Information>>(list);
- _infNew.AddRange(dtos);
- InfNew = _infNew.Take(PageCount).ToList();
- MaxCount =_infNew.Count / PageCount + 1;
- }
-
- }
-
- }
|