change -优化修改打卡判重逻辑

main
frankiecao 1 year ago
commit bee6757ae2

@ -100,30 +100,56 @@ namespace SlnMesnac.WPF.ViewModel
BaseStaffInfo user = baseStaffService.GetStaffInfoByCardId(cleanStr); BaseStaffInfo user = baseStaffService.GetStaffInfoByCardId(cleanStr);
if (user != null) if (user != null)
{ {
string attendanceType = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(user.StaffId)?.AttendanceType; RecordStaffAttendance recordStaffAttendance = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(user.StaffId);
if (attendanceType == "1") //下班卡 var createTime = recordStaffAttendance.CreateTime;
var nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
TimeSpan timeDiff = DateTime.Parse(nowTime) - DateTime.Parse(createTime);
if(timeDiff.TotalHours >= 10)//
{ {
if (attendanceType == status.ToString()) if (recordStaffAttendance.AttendanceType == "1") //下班卡
{ {
StatusText = "未打上班卡,请联系管理员!"; if (recordStaffAttendance.AttendanceType == status.ToString())
{
StatusText = "未打上班卡,请联系管理员!";
}
}
else if (recordStaffAttendance.AttendanceType == "0")
{
if (recordStaffAttendance.AttendanceType == status.ToString())
{
StatusText = "未打下班卡,请联系管理员!";
}
}
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
var list = _rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffAttendanceDataGrid.Clear();
list.ForEach(item => { RecordStaffAttendanceDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
if (recordStaffAttendance.AttendanceType != status.ToString())
{
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
var list = _rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffAttendanceDataGrid.Clear();
list.ForEach(item => { RecordStaffAttendanceDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
StatusText = "请勿重复打卡!";
} }
} }
else if (attendanceType == "0")
{
if (attendanceType == status.ToString())
{
StatusText = "未打下班卡,请联系管理员!";
}
}
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
var list = _rfidHandleBusniess.HandleAndInsertStaffAttendance(user,isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffAttendanceDataGrid.Clear();
list.ForEach(item => { RecordStaffAttendanceDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
} }
else else
{ {
@ -344,7 +370,7 @@ namespace SlnMesnac.WPF.ViewModel
{ {
for (int i = 0; i < uniqueStrings.Count; i++) for (int i = 0; i < uniqueStrings.Count; i++)
{ {
if (uniqueStrings[i] == str && (DateTime.Now - timestamps[i]).TotalMinutes < 1) if (uniqueStrings[i] == str && (DateTime.Now - timestamps[i]).TotalSeconds < 30)
{ {
return true; return true;
} }
@ -352,7 +378,6 @@ namespace SlnMesnac.WPF.ViewModel
return false; return false;
} }
//public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = "") public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{ {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

@ -37,11 +37,13 @@ namespace SlnMesnac.WPF.ViewModel
private IRecordStaffAttendanceService _recordStaffAttendanceService; private IRecordStaffAttendanceService _recordStaffAttendanceService;
private string StationCode; private string StationCode;
public static bool isComplete = true; public static bool isComplete = true;
private ProdPLanInfo pLanInfo;
/// <summary> /// <summary>
/// 按钮文字转换事件 /// 按钮文字转换事件
/// </summary> /// </summary>
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged = delegate { };
/// <summary> /// <summary>
/// 检索命令 /// 检索命令
/// </summary> /// </summary>
@ -76,6 +78,8 @@ namespace SlnMesnac.WPF.ViewModel
.SetBasePath(System.AppContext.BaseDirectory) .SetBasePath(System.AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfigurationRoot configuration = configurationBuilder.Build(); IConfigurationRoot configuration = configurationBuilder.Build();
pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "", "1").FirstOrDefault();
Refresh(pLanInfo);
// 从配置文件中获取ProductLineNameTextBlock的值 // 从配置文件中获取ProductLineNameTextBlock的值
stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"]; stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"];
StationCode = configuration.GetSection("AppConfig")["ProductLineCode"]; StationCode = configuration.GetSection("AppConfig")["ProductLineCode"];
@ -97,7 +101,7 @@ namespace SlnMesnac.WPF.ViewModel
} }
/// <summary> /// <summary>
/// 换班弹窗 /// 报工弹窗
/// </summary> /// </summary>
private void ProductionReport() private void ProductionReport()
{ {
@ -133,7 +137,7 @@ namespace SlnMesnac.WPF.ViewModel
// 将当前记录存为实体可以通过parameter获取当前记录的信息 // 将当前记录存为实体可以通过parameter获取当前记录的信息
string orderCode = _selectedRow.OrderCode.ToString(); string orderCode = _selectedRow.OrderCode.ToString();
string planCode = _selectedRow.PlanCode.ToString(); string planCode = _selectedRow.PlanCode.ToString();
ProdPLanInfo pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First(); pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First();
RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord(); RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
RecordStaffAttendance nextRecord = _recordStaffAttendanceService.GetLastestOffRecord(); RecordStaffAttendance nextRecord = _recordStaffAttendanceService.GetLastestOffRecord();
// 向detail表里插入一条数据 // 向detail表里插入一条数据
@ -162,7 +166,9 @@ namespace SlnMesnac.WPF.ViewModel
//刷新明细 //刷新明细
private void Refresh(ProdPLanInfo pLanInfo) private void Refresh(ProdPLanInfo pLanInfo)
{ {
ProdPlanDetail planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(pLanInfo.PlanCode); if(pLanInfo != null)
{
ProdPlanDetail planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(pLanInfo.PlanCode);
PlanCodeText = planDetail.PlanCode; PlanCodeText = planDetail.PlanCode;
OrderCodeText = pLanInfo.OrderCode; OrderCodeText = pLanInfo.OrderCode;
MaterialCodeText = planDetail.MaterialCode; MaterialCodeText = planDetail.MaterialCode;
@ -172,6 +178,7 @@ namespace SlnMesnac.WPF.ViewModel
ProdPLanDetailDataGrid.Clear(); ProdPLanDetailDataGrid.Clear();
ProdPLanDetailDataGrid.Add(planDetail); ProdPLanDetailDataGrid.Add(planDetail);
})); }));
}
} }
#region #region

@ -131,7 +131,9 @@ namespace SlnMesnac.WPF.ViewModel
double newAmountDouble = Convert.ToDouble(newAmount); double newAmountDouble = Convert.ToDouble(newAmount);
double result = currentAmountDouble + newAmountDouble; double result = currentAmountDouble + newAmountDouble;
planDetail.CompleteAmount = result.ToString(); planDetail.CompleteAmount = result.ToString();
planInfo.CompleteAmount = result.ToString();
_prodPlanDetailService.Update(planDetail); _prodPlanDetailService.Update(planDetail);
_prodPlanInfoService.Update(planInfo);
Refresh(); Refresh();
NewAmountText = null; NewAmountText = null;
HintText = "已提交!"; HintText = "已提交!";
@ -151,7 +153,7 @@ namespace SlnMesnac.WPF.ViewModel
} }
/// <summary> /// <summary>
/// 确认命令 /// 结束工单命令
/// </summary> /// </summary>
public ICommand EndPlanCommand { get; private set; } public ICommand EndPlanCommand { get; private set; }
private void EndPlan() private void EndPlan()

@ -94,7 +94,7 @@
<Border.Effect> <Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/> <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect> </Border.Effect>
<TextBlock Text="{Binding PlanAmountText}" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="{Binding PlanAmountText}" FontSize="20" FontWeight="Bold" Foreground="#1254AB" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border> </Border>
<Border Grid.Column="2"> <Border Grid.Column="2">
<TextBlock Text="完成数量" FontSize="20" FontWeight="Bold" Foreground="#1254AB" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="完成数量" FontSize="20" FontWeight="Bold" Foreground="#1254AB" VerticalAlignment="Center" HorizontalAlignment="Center"/>
@ -103,7 +103,7 @@
<Border.Effect> <Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/> <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect> </Border.Effect>
<TextBlock Text="{Binding CompleteAmountText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="{Binding CompleteAmountText}" FontSize="20" Foreground="#1254AB" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border> </Border>
</Grid> </Grid>
</Border> </Border>

Loading…
Cancel
Save