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.
191 lines
6.0 KiB
C#
191 lines
6.0 KiB
C#
using ConsoleApp;
|
|
using GalaSoft.MvvmLight.Command;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SlnMesnac.Model.domain;
|
|
using SlnMesnac.Repository.service;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Input;
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
{
|
|
public class HandOverViewModel : INotifyPropertyChanged
|
|
{
|
|
private IBaseStaffService _baseStaffService;
|
|
private ProdPlanInfoService _prodPlanInfoService;
|
|
private ProdPlanDetailService _prodPlanDetailService;
|
|
private ProdPLanInfo planInfo;
|
|
private ProdPlanDetail planDetail;
|
|
private int times;
|
|
|
|
/// <summary>
|
|
/// 按钮文字转换事件
|
|
/// </summary>
|
|
public event PropertyChangedEventHandler PropertyChanged = delegate { };
|
|
|
|
|
|
public HandOverViewModel()
|
|
{
|
|
_prodPlanDetailService = App.ServiceProvider.GetService<ProdPlanDetailService>();
|
|
_prodPlanInfoService = App.ServiceProvider.GetService<ProdPlanInfoService>();
|
|
planInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "", "1").FirstOrDefault();
|
|
HandoverCommand = new RelayCommand(Handover);
|
|
Init();
|
|
_baseStaffService = App.ServiceProvider.GetService<IBaseStaffService>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
private void Init()
|
|
{
|
|
planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
|
|
PlanAmountText = planDetail.PlanAmount.ToString();
|
|
CompleteAmountText = planDetail.CompleteAmount.ToString();
|
|
var hidUtils = EmployeeLoginViewModel.hidUtils;
|
|
// hidUtils.Initial();
|
|
hidUtils.StartScan();
|
|
hidUtils.pushReceiveDataEvent += (bytes, str) =>
|
|
{
|
|
if (times < 2)//打卡超过2次无效
|
|
{
|
|
str = str.ToString().Replace(" ", "");
|
|
BaseStaffInfo user = _baseStaffService.GetStaffInfoByCardId(str);
|
|
if (user != null)
|
|
{
|
|
string staffType = user.StaffType;
|
|
if (staffType == "1")//判断是否为班长
|
|
{
|
|
//显示记录
|
|
StaffIdText = user.StaffId;
|
|
StaffNameText = user.StaffName;
|
|
StaffTypeText = user.StaffType;
|
|
TeamCodeText = user.TeamCode;
|
|
//数量+1
|
|
times++;
|
|
}
|
|
else
|
|
{
|
|
HintText = "打卡人员非班长,打卡无效!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HintText = "没有匹配的员工,打卡失败!";
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#region
|
|
|
|
/// <summary>
|
|
/// 计划数量Text
|
|
/// </summary>
|
|
private string planAmountText;
|
|
public string PlanAmountText
|
|
{
|
|
get { return planAmountText; }
|
|
set { planAmountText = value; OnPropertyChanged("PlanAmountText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 完成数量Text
|
|
/// </summary>
|
|
private string completeAmountText;
|
|
public string CompleteAmountText
|
|
{
|
|
get { return completeAmountText; }
|
|
set { completeAmountText = value; OnPropertyChanged("CompleteAmountText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 员工id
|
|
/// </summary>
|
|
private string staffIdText;
|
|
public string StaffIdText
|
|
{
|
|
get { return staffIdText; }
|
|
set { staffIdText = value; OnPropertyChanged("StaffIdText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 员工名称
|
|
/// </summary>
|
|
private string staffNameText;
|
|
public string StaffNameText
|
|
{
|
|
get { return staffNameText; }
|
|
set { staffNameText = value; OnPropertyChanged("StaffNameText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 员工类型
|
|
/// </summary>
|
|
private string staffTypeText;
|
|
public string StaffTypeText
|
|
{
|
|
get { return staffTypeText; }
|
|
set { staffTypeText = value; OnPropertyChanged("StaffTypeText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 班组编号
|
|
/// </summary>
|
|
private string teamCodeText;
|
|
public string TeamCodeText
|
|
{
|
|
get { return teamCodeText; }
|
|
set { teamCodeText = value; OnPropertyChanged("TeamCodeText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提示信息
|
|
/// </summary>
|
|
private string hintText;
|
|
public string HintText
|
|
{
|
|
get { return hintText; }
|
|
set { hintText = value; OnPropertyChanged("HintText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 信息
|
|
/// </summary>
|
|
private string messageText;
|
|
public string MessageText
|
|
{
|
|
get { return messageText; }
|
|
set { messageText = value; OnPropertyChanged("MessageText"); }
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 确认交班
|
|
/// </summary>
|
|
public ICommand HandoverCommand { get; private set; }
|
|
private void Handover()
|
|
{
|
|
//判断两个班长是否都已打卡
|
|
if(times == 2)
|
|
{
|
|
//在工单明细插入一条,记录两个班长
|
|
}
|
|
else
|
|
{
|
|
HintText = "有人未打卡,请检查!";
|
|
}
|
|
}
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|