change -修改执行明细方法

main
启龙 曹 10 months ago
commit f86e164dad

@ -13,16 +13,20 @@ namespace SlnMesnac.Business.business
private ProdPlanInfoService _prodPlanInfoService;
private ProdPlanExecuteUserService _prodPlanExecuteUserService;
private ProdOrderInfoService _prodOrderInfoService;
private ProdPlanDetailService _prodPlanDetailService;
private IRecordStaffRealTimeService _recordStaffRealTimeService;
private List<ProdPLanInfo> prodPlanInfos;
public DatabaseHandleBusniess(ProdPlanInfoService prodPlanInfoService, ProdOrderInfoService prodOrderInfoService, ProdPlanExecuteUserService prodPlanExecuteUserService,IRecordStaffRealTimeService recordStaffRealTimeService)
public DatabaseHandleBusniess(ProdPlanInfoService prodPlanInfoService, ProdOrderInfoService prodOrderInfoService,
ProdPlanExecuteUserService prodPlanExecuteUserService, IRecordStaffRealTimeService recordStaffRealTimeService,
ProdPlanDetailService prodPlanDetailService)
{
_prodPlanInfoService = prodPlanInfoService;
_prodOrderInfoService = prodOrderInfoService;
prodPlanInfos = _prodPlanInfoService.GetRecordStaffAttendances();
_prodPlanExecuteUserService = prodPlanExecuteUserService;
_recordStaffRealTimeService = recordStaffRealTimeService;
_prodPlanDetailService = prodPlanDetailService;
}
/// <summary>
@ -43,21 +47,24 @@ namespace SlnMesnac.Business.business
public void AddNewPlanInfo(string? orderCode,string? stationCode,string? deviceCode,string? processCode,string? importFlag)
{
var orderInfo = GetProdOrderInfoByOrderCode(orderCode);
string randomString = GenerateRandomString(14);
_prodPlanInfoService.Insert(new ProdPLanInfo()
if (orderInfo != null)
{
PlanCode = orderCode + randomString,
OrderCode = orderCode,
MaterialCode = orderInfo.MaterialCode,
MaterialName = orderInfo.MaterialName,
StationCode = stationCode,
DeviceCode = deviceCode,
PlanAmount = orderInfo.OrderAmount,
CompleteAmount = orderInfo.CompleteAmount,
PlanStatus = "4",
ProcessCode = processCode,
ImportFlag = importFlag
});
string randomString = GenerateRandomString(14);
_prodPlanInfoService.Insert(new ProdPLanInfo()
{
PlanCode = orderCode + randomString,
OrderCode = orderCode,
MaterialCode = orderInfo.MaterialCode,
MaterialName = orderInfo.MaterialName,
StationCode = stationCode,
DeviceCode = deviceCode,
PlanAmount = orderInfo.OrderAmount,
CompleteAmount = orderInfo.CompleteAmount,
PlanStatus = "4",
ProcessCode = processCode,
ImportFlag = importFlag
});
}
}
/// <summary>
@ -111,13 +118,14 @@ namespace SlnMesnac.Business.business
PlanBeginDate = prodPlanInfo.BeginTime,
PlanEndDate = prodPlanInfo.EndTime,
CreatedBy = prodPlanInfo.CreatedBy,
CreatedTime = prodPlanInfo.CreatedTime,
CreatedTime = prodPlanDetail.BeginTime,
UpdatedBy = prodPlanInfo.UpdatedBy,
UpdatedTime = prodPlanInfo.UpdatedTime,
BatchNumber = prodPlanDetail.BatchNumber
};
_prodPlanExecuteUserService.Insert(prodPlanExecuteUser);
}
_prodPlanExecuteUserService.Insert(prodPlanExecuteUser);
}
_prodPlanDetailService.DeleteByPlanCodeBatchNumber(prodPlanDetail.PlanCode, 0);
}
/// <summary>
@ -130,6 +138,20 @@ namespace SlnMesnac.Business.business
return list;
}
/// <summary>
/// 查询本条工单是否完成
/// </summary>
/// <param name="orderCode"></param>
/// <param name="stationCode"></param>
/// <param name="deviceCode"></param>
/// <param name="processCode"></param>
/// <param name="v"></param>
/// <returns></returns>
public ProdPLanInfo SelectPlanStatus(string orderCode, string stationCode, string deviceCode, string processCode, string v)
{
return _prodPlanInfoService.GetPlanInfoByConditions(orderCode,"","", stationCode,"0").FirstOrDefault();
}
///// <summary>
///// 查询所有计划工位
///// </summary>

@ -25,12 +25,13 @@ namespace SlnMesnac.Business.business
private string teamMembers = null;
private List<string> members = new List<string>();
public static string stationCode = "";
public static List<string> stationList;
public RfidHandleBusniess(IRecordStaffAttendanceService recordStaffAttendanceService, IRecordStaffCommuteService recordStaffCommuteService, IRecordStaffRealTimeService recordStaffRealTimeService)
{
this._recordStaffAttendanceService = recordStaffAttendanceService;
this._recordStaffCommuteService = recordStaffCommuteService;
this._recordStaffRealTimeService = recordStaffRealTimeService;
this._recordStaffRealTimeService = recordStaffRealTimeService;
}
@ -94,6 +95,7 @@ namespace SlnMesnac.Business.business
/// <returns></returns>
public string SpliceTeamMember()
{
teamMembers = "";
//RecordStaffAttendance recordStaffAttendance = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(baseStaffInfo.StaffId,stationCode);
List<RecordStaffRealTime> recordStaffRealTimeList = _recordStaffRealTimeService.GetRecordStaffRealTime(stationCode);
//string type = recordStaffAttendance.AttendanceType;
@ -119,29 +121,32 @@ namespace SlnMesnac.Business.business
/// </summary>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public List<RecordStaffRealTime> HandleAndInsertStaffRealTime(BaseStaffInfo staff,int isCheckOn)
public List<RecordStaffRealTime> HandleAndInsertStaffRealTime(BaseStaffInfo?staff,int isCheckOn)
{
if (isCheckOn == 0)
if (staff != null)
{
RecordStaffRealTime recordStaffRealTime = new RecordStaffRealTime
if (isCheckOn == 0)
{
StaffId = staff.StaffId,
AttendanceType = isCheckOn.ToString(),
TeamCode = staff.TeamCode,
Remark = staff.Remark,
CreateBy = staff.StaffName,
CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
StationCode = stationCode
};
_recordStaffRealTimeService.Insert(recordStaffRealTime);
}
else if(isCheckOn == 1 || isCheckOn == 2)
{
var realTime = _recordStaffRealTimeService.Query(recordStaffRealTime => recordStaffRealTime.StaffId == staff.StaffId
&& recordStaffRealTime.StationCode == stationCode
&& recordStaffRealTime.AttendanceType == "0").FirstOrDefault();
_recordStaffRealTimeService.Delete(realTime);
}
RecordStaffRealTime recordStaffRealTime = new RecordStaffRealTime
{
StaffId = staff.StaffId,
AttendanceType = isCheckOn.ToString(),
TeamCode = staff.TeamCode,
Remark = staff.Remark,
CreateBy = staff.StaffName,
CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
StationCode = stationCode
};
_recordStaffRealTimeService.Insert(recordStaffRealTime);
}
else if (isCheckOn == 1 || isCheckOn == 2)
{
var realTime = _recordStaffRealTimeService.Query(recordStaffRealTime => recordStaffRealTime.StaffId == staff.StaffId
&& recordStaffRealTime.StationCode == stationCode
&& recordStaffRealTime.AttendanceType == "0").FirstOrDefault();
_recordStaffRealTimeService.Delete(realTime);
}
}
return _recordStaffRealTimeService.GetRecordStaffRealTime(stationCode);
}
}

@ -47,10 +47,26 @@ namespace SlnMesnac.Repository.service.Impl
return result;
}
public ProdPlanDetail GetPlanDetailsByPlanCode(string planCode)
public List<ProdPlanDetail> GetPlanDetailsByPlanCode(string planCode)
{
ProdPlanDetail prodPlanDetail = _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(planCode),x=>x.PlanCode == planCode).OrderByDescending(x => x.ObjId).First();
return prodPlanDetail;
List<ProdPlanDetail> prodPlanDetails = _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(planCode),x=>x.PlanCode == planCode).OrderByDescending(x => x.ObjId).ToList();
return prodPlanDetails;
}
public bool DeleteByPlanCodeBatchNumber(string planCode, int number)
{
bool result = false;
try
{
//_rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(planCode), x => x.PlanCode == planCode && x.BatchNumber == number).OrderByDescending(x => x.ObjId).First();
ProdPlanDetail temp = _rep.AsQueryable().Where(x => x.PlanCode == planCode && x.BatchNumber == number).OrderByDescending(x => x.ObjId).First();
result = _rep.Delete(temp);
}
catch (Exception ex)
{
_logger.LogError($"根据计划编号删锅数为0的数据异常{ex.Message}");
}
return result;
}
}
}

@ -13,6 +13,6 @@ namespace SlnMesnac.Repository.service.Impl
public ProdPlanExecuteUserServiceImpl(Repository<ProdPlanExecuteUser> repository, ILogger<ProdPlanExecuteUserServiceImpl> logger) : base(repository)
{
_logger = logger;
}
}
}
}

@ -39,6 +39,26 @@ namespace SlnMesnac.Repository.service.Impl
return planInfoList;
}
/// <summary>
/// 通过订单编号、工单编号、物料码获取工单信息
/// </summary>
/// <param name="orderCode"></param>
/// <param name="planCode"></param>
/// <param name="materialCode"></param>
/// <returns></returns>
public List<ProdPLanInfo> GetPlanInfoByConditions(string? orderCode, string? planCode, string? materialCode, string? stationCode, string? planStatus)
{
List<ProdPLanInfo> recordStaffAttendances = new List<ProdPLanInfo>();
List<ProdPLanInfo> planInfoList = _rep.AsQueryable().WhereIF(!string.IsNullOrEmpty(orderCode), x => x.OrderCode == orderCode)
.WhereIF(!string.IsNullOrEmpty(planCode), x => x.PlanCode == planCode)
.WhereIF(!string.IsNullOrEmpty(materialCode), x => x.MaterialCode == materialCode)
.WhereIF(!string.IsNullOrEmpty(stationCode), x => x.StationCode == stationCode)
.WhereIF(!string.IsNullOrEmpty(planStatus), x => x.PlanStatus == planStatus || x.PlanStatus == "4")
.OrderByDescending(x => x.ObjId)
.ToList();
return planInfoList;
}
public List<ProdPLanInfo> GetRecordStaffAttendances()
{
List<ProdPLanInfo> pLanInfos = null;
@ -64,8 +84,8 @@ namespace SlnMesnac.Repository.service.Impl
{
ProdPLanInfo prodPLan = new ProdPLanInfo();
try
{
prodPLan = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode);
{//只显示未执行的
prodPLan = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode && x.PlanStatus == "0" || x.PlanStatus == "4");
}
catch (Exception ex)
{
@ -88,7 +108,7 @@ namespace SlnMesnac.Repository.service.Impl
bool result = false;
try
{
var planInfo = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode && x.DeviceCode == deviceCode && x.ProcessCode == processCode);
var planInfo = _rep.GetFirst(x => x.OrderCode == orderCode && x.StationCode == stationCode && x.DeviceCode == deviceCode && x.ProcessCode == processCode && x.PlanStatus == "0");
if (planInfo != null)
{
planInfo.PlanStatus = status;

@ -27,6 +27,14 @@ namespace SlnMesnac.Repository.service
/// <param name="orderCode"></param>
/// <param name="planCode"></param>
/// <returns></returns>
ProdPlanDetail GetPlanDetailsByPlanCode(string planCode);
List<ProdPlanDetail> GetPlanDetailsByPlanCode(string planCode);
/// <summary>
/// 根据工单号删除锅数为0的明细
/// </summary>
/// <param name="planCode"></param>
/// <param name="v"></param>
/// <returns></returns>
bool DeleteByPlanCodeBatchNumber(string planCode, int number);
}
}

@ -6,7 +6,8 @@ using System.Text;
namespace SlnMesnac.Repository.service
{
public interface ProdPlanExecuteUserService: IBaseService<ProdPlanExecuteUser>
public interface ProdPlanExecuteUserService : IBaseService<ProdPlanExecuteUser>
{
}
}

@ -19,7 +19,13 @@ namespace SlnMesnac.Repository.service
/// </summary>
/// <returns></returns>
List<ProdPLanInfo> GetRecordStaffAttendancesByConditions(string orderCode,string planCode,string materialCode, string stationCode, string planStatus);
/// <summary>
/// 根据订单编号、工单编号、物料名称获取工单信息
/// </summary>
/// <returns></returns>
List<ProdPLanInfo> GetPlanInfoByConditions(string orderCode, string planCode, string materialCode, string stationCode, string planStatus);
/// <summary>
/// 根据工单编号获取此工单
/// </summary>

@ -80,31 +80,46 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0">
<TextBlock Text="人员工号" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,20,0"/>
<TextBlock Text="选择工位" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,20,0"/>
</Border>
<Border Grid.Column="1" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="0,0,80,0">
<Border.Effect>
<!--<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<TextBlock Text="{Binding StaffIdText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border.Effect>-->
<!--<TextBlock Text="{Binding StationName}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>-->
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<ComboBox
x:Name="StationComboBox"
ItemsSource="{Binding StationList}"
SelectedItem="{Binding SelectedItem}" Width="160" Height="32" FontSize="15" HorizontalAlignment="Left"/>
<Button x:Name="ConfirmButton" Style="{StaticResource BUTTON_AGREE}" Content="确认" Command="{Binding ConfirmCommand}" Background="#009999" BorderBrush="#FF36B5C1" Width="65" Height="35" FontSize="15" Margin="10,0,0,0"/>
</StackPanel>
</Border>
<Border Grid.Column="2">
<TextBlock Text="打卡状态" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,20,0"/>
<TextBlock Text="人员工号" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,20,0"/>
</Border>
<Border Grid.Column="3" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="0,0,80,0">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<TextBlock Text="{Binding CheckStatus}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="{Binding StaffIdText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="4">
<TextBlock Text="{Binding StatusText}" FontSize="25" Foreground="Red" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="打卡状态" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,20,0"/>
</Border>
<Border Grid.Column="5" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" Margin="0,0,80,0">
<Border.Effect>
<DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
</Border.Effect>
<TextBlock Text="{Binding CheckStatus}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Border>
@ -112,18 +127,20 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="6*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0">
<TextBlock Text="打卡类型" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1">
<Button Content="{Binding CheckInButtonText}" x:Name="On" Command="{Binding CheckInCommand}" Style="{StaticResource BUTTON_AGREE}" IsEnabled="{Binding IsCheckInButtonEnabled}" FontSize="15" FontWeight="Bold" Background="{Binding CheckInButtonColor}" BorderBrush="#FF36B5C1" Margin="40,10,40,10" Click="On_Click"/>
<StackPanel Orientation="Horizontal">
<Button Content="{Binding CheckInButtonText}" x:Name="On" Command="{Binding CheckInCommand}" Style="{StaticResource BUTTON_AGREE}" IsEnabled="{Binding IsCheckInButtonEnabled}" FontSize="15" FontWeight="Bold" Width="200" Background="{Binding CheckInButtonColor}" HorizontalAlignment="Left" BorderBrush="#FF36B5C1" Margin="40,10,40,10" Click="On_Click"/>
<Button Content="{Binding CheckOutButtonText}" x:Name="Off" Command="{Binding CheckOutCommand}" Style="{StaticResource BUTTON_AGREE}" IsEnabled="{Binding IsCheckOutButtonEnabled}" FontSize="15" FontWeight="Bold" Width="200" Background="{Binding CheckOutButtonColor}" HorizontalAlignment="Left" BorderBrush="#FF36B5C1" Margin="20,10,20,10"/>
</StackPanel>
</Border>
<Border Grid.Column="2">
<Button Content="{Binding CheckOutButtonText}" x:Name="Off" Command="{Binding CheckOutCommand}" Style="{StaticResource BUTTON_AGREE}" IsEnabled="{Binding IsCheckOutButtonEnabled}" FontSize="15" FontWeight="Bold" Background="{Binding CheckOutButtonColor}" BorderBrush="#FF36B5C1" Margin="40,10,40,10"/>
<TextBlock Text="{Binding StatusText}" FontSize="25" Foreground="Red" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Border>
@ -154,7 +171,7 @@
<DataGridTextColumn Binding="{Binding StaffId}" Header="员工ID" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CreateBy}" Header="员工姓名" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding date,StringFormat=\{0:yyyy-MM-dd\}}" Header="工单编号" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<!--<DataGridTextColumn Binding="{Binding AttendanceType}" Header="打卡类型" Width="3*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding CreateTime}" Header="打卡时间" Width="3*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<!--<DataGridTextColumn Binding="{Binding hualway}" Header="性别" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<!--<DataGridTextColumn Binding="{Binding baggageTagCode}" Header="卡号" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<!--<DataGridTextColumn Binding="{Binding TeamCode}" Header="班组编号" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->

@ -123,12 +123,13 @@
<Border Grid.Row="0" Grid.Column="5">
<TextBox Text="{Binding MaterialNameTextBox}" Height="30" Width="180" FontSize="15" Foreground="White" HorizontalAlignment="Left"/>
</Border>
<Border Grid.Row="1" Grid.Column="0">
<!--<Border Grid.Row="1" Grid.Column="0">
<TextBlock Text="工位:" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="1" Grid.Column="1">
<TextBlock Text="{Binding StationTextBox}" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Border>
--><!--<ComboBox x:Name="StationComboBox" ItemsSource="{Binding StationList}" SelectedItem="{Binding Station}" Width="180" Height="30" FontSize="15" HorizontalAlignment="Left"/>--><!--
</Border>-->
<Border Grid.Row="1" Grid.Column="5">
<Button Content="检索工单" x:Name="Select" Command="{Binding SearchCommand}" CommandParameter="{Binding Name,ElementName=Select}" Style="{StaticResource BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" Margin="20,5,20,5"/>
</Border>
@ -306,7 +307,7 @@
</DataGridTemplateColumn>
<!--<DataGridTextColumn Binding="{Binding baggageTagCode}" Header="序号" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>-->
<DataGridTextColumn Binding="{Binding PlanAmount}" Header="计划数量" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成数量" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding CompleteAmount}" Header="新增数量" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
<DataGridTextColumn Binding="{Binding BeginTime, StringFormat=\{0:yyy-MM-dd HH:mm:ss\}}" Header="实际开始时间" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
</DataGrid.Columns>
</DataGrid>
@ -321,7 +322,7 @@
<Button Content="生产报工" x:Name="ProductionReport" Command="{Binding ProductionReportCommand}" Style="{StaticResource BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" Margin="40,14,40,14"/>
</Border>
<Border Grid.Column="1">
<Button Content="换班交接" x:Name="Handover" Command="{Binding HandoverCommand}" Style="{StaticResource BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" Margin="40,14,40,14" Click="ChangeShifts_Click"/>
<!--<Button Content="换班交接" x:Name="Handover" Command="{Binding HandoverCommand}" Style="{StaticResource BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" Margin="40,14,40,14" Click="ChangeShifts_Click"/>-->
</Border>
</Grid>
</Border>

@ -2,6 +2,7 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HslCommunication;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.Business.business;
@ -41,13 +42,17 @@ namespace SlnMesnac.WPF.ViewModel
private string _checkInButtonColor;
private string _checkOutButtonColor = "#009999";
private int isCheckOn = 0;
private bool isUse = false;
private bool isUse = false;//是否正在使用打卡机
private bool isSelectedStationCode = false;//是否已选择工位,上班打卡前选择,下班时恢复
private int status = 0;//0是上班1是下班
private string StationCodes;
public static string stationCode = "";
public static string stationName = "";
public static HidUtils hidUtils;
public static bool isOnDuty = false;//是否有班组当班
private List<string> uniqueStrings = new List<string>();
private List<DateTime> timestamps = new List<DateTime>();
private BaseStaffInfo user;
//private BaseStaffInfo user;
/// <summary>
/// 按钮文字转换事件
@ -59,10 +64,12 @@ namespace SlnMesnac.WPF.ViewModel
/// 上班命令
/// </summary>
public ICommand CheckInCommand { get; private set; }
/// <summary>
/// 下班命令
/// </summary>
public ICommand CheckOutCommand { get; private set; }
/// <summary>
/// 结束命令
/// </summary>
@ -74,180 +81,12 @@ namespace SlnMesnac.WPF.ViewModel
public ICommand RemoveCommand { get; private set; }
/// <summary>
///
/// 确认命令
/// </summary>
/// <param name="staffInfo"></param>
public delegate void TransmitUser();
public static event TransmitUser TransmitUserDelegateEvent;
public ICommand ConfirmCommand { get; private set; }
public static Action<String>? _transmitToRemoveConfigAction;
#endregion
public EmployeeLoginViewModel()
{
hidUtils = new HidUtils();
CheckInCommand = new RelayCommand(CheckIn);
CheckOutCommand = new RelayCommand(CheckOut);
RemoveCommand = new RelayCommand<string>(Remove);
OverCommand = new RelayCommand(Over);
baseStaffService = App.ServiceProvider.GetService<IBaseStaffService>();
_recordStaffAttendanceService = App.ServiceProvider.GetService<IRecordStaffAttendanceService>();
_recordStaffCommuteService = App.ServiceProvider.GetService<IRecordStaffCommuteService>();
_rfidHandleBusniess = App.ServiceProvider.GetService<RfidHandleBusniess>();
//_rfidHandleBusniess.InstructionInfoDataGridEvent += RefreshRfidInfo;
IsCheckInButtonEnabled = "True";
IsCheckOutButtonEnabled = "True";
CheckInButtonColor = "#009999";
CheckOutButtonColor = "#009999";
Init();
}
/// <summary>
/// 主动移除
/// </summary>
private void Remove(string staffId)
{
MainWindowViewModel.wins = 2;
if (isUse == false)
{
var removeConfirmWin = new RemoveConfirmWin();
removeConfirmWin.Owner = Application.Current.MainWindow;
removeConfirmWin.WindowStartupLocation = WindowStartupLocation.CenterOwner;
removeConfirmWin.ShowDialog();
if (RemoveConfirmViewModel.times == 1)
{
var theUser = baseStaffService.GetStaffInfoByStaffId(staffId);
_rfidHandleBusniess.HandleAndInsertStaffAttendance(theUser, 2);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(theUser, 2);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
}
EmployeeLoginViewModel._transmitToRemoveConfigAction -= _transmitToRemoveConfigAction;
}
else
{
MessageBox.Show("正在打卡不能强退!");
}
}
private void Init()
{
hidUtils.Initial();
hidUtils.pushReceiveDataEvent += (bytes, str) =>
{
if (MainWindowViewModel.wins == 1)
{
string cleanStr = str.ToString().Replace(" ", "");
StatusText = StaffIdText = CheckStatus = null;
if (!IsDuplicate(cleanStr))//过滤重复str
{
uniqueStrings.Add(cleanStr);
timestamps.Add(DateTime.Now);
// Additional logic for processing the unique string goes here
if (isUse)
{
user = baseStaffService.GetStaffInfoByCardId(cleanStr);
if (user != null)
{
RecordStaffAttendance recordStaffAttendance = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(user.StaffId, RfidHandleBusniess.stationCode);
if (recordStaffAttendance != null)
{
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 (recordStaffAttendance.AttendanceType == "1") //下班卡
{
if (recordStaffAttendance.AttendanceType == status.ToString() || recordStaffAttendance.AttendanceType == "2")
{
StatusText = "未打上班卡,请联系管理员!";
}
}
else if (recordStaffAttendance.AttendanceType == "0")
{
if (recordStaffAttendance.AttendanceType == status.ToString())
{
StatusText = "未打下班卡,请联系管理员!";
}
}
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(user, isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
if (recordStaffAttendance.AttendanceType != status.ToString())
{
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(user, isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
StatusText = "请勿重复打卡!";
}
}
}
else
{
StaffIdText = user.StaffId;
CheckStatus = "打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(user, isCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
}
else
{
StaffIdText = "未配置";
CheckStatus = "没有匹配的员工,打卡失败!";
}
}
}
else
{
StaffIdText = "已打卡,请勿重复!";
}
}
else if (MainWindowViewModel.wins == 2)
{
_transmitToRemoveConfigAction(str);
}
else if (MainWindowViewModel.wins == 3)
{
}
};
}
public HidUtils getHidUtil()
{
return hidUtils;
}
#endregion
#region 绑定参数
/// <summary>
@ -372,35 +211,272 @@ namespace SlnMesnac.WPF.ViewModel
set { recordStaffRealTimeDataGrid = value; OnPropertyChanged("RecordStaffRealTimeDataGrid"); }
}
/// <summary>
/// 工位列表
/// </summary>
private List<string> stationList;
public List<string> StationList
{
get { return stationList; }
set { stationList = value; OnPropertyChanged("StationList"); }
}
/// <summary>
/// 选中工位
/// </summary>
private string selectedItem;
public string SelectedItem
{
get { return selectedItem; }
set
{
selectedItem = value;
OnPropertyChanged(nameof(SelectedItem));
}
}
#endregion
#region 定义委托
public static Action<String>? TransmitStationNameAction;
/// <summary>
///
/// </summary>
/// <param name="staffInfo"></param>
public delegate void TransmitUser();
public static event TransmitUser TransmitUserDelegateEvent;
public static Action<String>? _transmitToRemoveConfigAction;
#endregion
public EmployeeLoginViewModel()
{
hidUtils = new HidUtils();
CheckInCommand = new RelayCommand(CheckIn);
CheckOutCommand = new RelayCommand(CheckOut);
RemoveCommand = new RelayCommand<string>(Remove);
OverCommand = new RelayCommand(Over);
ConfirmCommand = new RelayCommand(Confirm);
baseStaffService = App.ServiceProvider.GetService<IBaseStaffService>();
_recordStaffAttendanceService = App.ServiceProvider.GetService<IRecordStaffAttendanceService>();
_recordStaffCommuteService = App.ServiceProvider.GetService<IRecordStaffCommuteService>();
_rfidHandleBusniess = App.ServiceProvider.GetService<RfidHandleBusniess>();
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.SetBasePath(System.AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfigurationRoot configuration = configurationBuilder.Build();
//_rfidHandleBusniess.InstructionInfoDataGridEvent += RefreshRfidInfo;
StationCodes = configuration.GetSection("AppConfig")["StationCode"];
List<string> stationCodeList = ConvertStringToList(StationCodes);
StationList = stationCodeList;
RfidHandleBusniess.stationList = GetStationCodes(stationCodeList);
IsCheckInButtonEnabled = "True";
IsCheckOutButtonEnabled = "True";
CheckInButtonColor = "#009999";
CheckOutButtonColor = "#009999";
Init();
}
/// <summary>
/// 确认
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void Confirm()
{
if (!isOnDuty)
{
//stationCode = SelectedItem;
var result = ExtractStrings(SelectedItem);
RfidHandleBusniess.stationCode = result.Item1;
stationName = result.Item2;
isSelectedStationCode = true;
MessageBox.Show("已确认工位:" + stationName);
}
else
{
MessageBox.Show("已上班不能再选择工位!");
}
}
/// <summary>
/// 主动移除
/// </summary>
private void Remove(string staffId)
{
MainWindowViewModel.wins = 2;
if (isUse == false)
{
var removeConfirmWin = new RemoveConfirmWin();
removeConfirmWin.Owner = Application.Current.MainWindow;
removeConfirmWin.WindowStartupLocation = WindowStartupLocation.CenterOwner;
removeConfirmWin.ShowDialog();
if (RemoveConfirmViewModel.times == 1)
{
var theUser = baseStaffService.GetStaffInfoByStaffId(staffId);
_rfidHandleBusniess.HandleAndInsertStaffAttendance(theUser, 2);
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(theUser, 2);
if (list.Count>=0)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
}
if(list.Count == 0)
{
isOnDuty = false;
isSelectedStationCode = false;
}
}
TransmitUserDelegateEvent?.Invoke();
EmployeeLoginViewModel._transmitToRemoveConfigAction -= _transmitToRemoveConfigAction;
}
else
{
MessageBox.Show("正在打卡不能强退!");
}
}
private void Init()
{
hidUtils.Initial();
hidUtils.pushReceiveDataEvent += (bytes, str) =>
{
if (MainWindowViewModel.wins == 1)
{
string cleanStr = str.ToString().Replace(" ", "");
StatusText = StaffIdText = CheckStatus = null;
if (!IsDuplicate(cleanStr))//过滤重复str
{
uniqueStrings.Add(cleanStr);
timestamps.Add(DateTime.Now);
// Additional logic for processing the unique string goes here
if (isUse)
{
var user = baseStaffService.GetStaffInfoByCardId(cleanStr);
if (user != null)
{
RecordStaffAttendance recordStaffAttendance = _recordStaffAttendanceService.GetRecordStaffAttendanceByStaffId(user.StaffId, RfidHandleBusniess.stationCode);
if (recordStaffAttendance != null)
{
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 (recordStaffAttendance.AttendanceType == "1") //下班卡
{
if (recordStaffAttendance.AttendanceType == status.ToString() || recordStaffAttendance.AttendanceType == "2")
{
StatusText = "未打上班卡,请联系管理员!";
}
}
else if (recordStaffAttendance.AttendanceType == "0")
{
if (recordStaffAttendance.AttendanceType == status.ToString())
{
StatusText = "未打下班卡,请联系管理员!";
}
}
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
ShowStaffAttendances(user, isCheckOn);
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
if (recordStaffAttendance.AttendanceType != status.ToString())
{
StaffIdText = user.StaffId;
CheckStatus = user.StaffName + " " + user.TeamCode + " 打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
ShowStaffAttendances(user, isCheckOn);
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
else
{
StatusText = "请勿重复打卡!";
}
}
}
else
{
StaffIdText = user.StaffId;
CheckStatus = "打卡成功!";
_rfidHandleBusniess.HandleAndInsertStaffAttendance(user, isCheckOn);
ShowStaffAttendances(user, isCheckOn);
_rfidHandleBusniess.HandleStaffCommute(user, isCheckOn);
}
}
else
{
StaffIdText = "未配置";
CheckStatus = "没有匹配的员工,打卡失败!";
}
}
}
else
{
StaffIdText = "已打卡,请勿重复!";
}
}
else if (MainWindowViewModel.wins == 2)
{
_transmitToRemoveConfigAction(str);
MainWindowViewModel.wins = 1;
}
else if (MainWindowViewModel.wins == 3)
{
}
};
}
public HidUtils getHidUtil()
{
return hidUtils;
}
/// <summary>
/// 上班打卡事件
/// </summary>
private void CheckIn()
{
isOnDuty = true;
if (CheckInButtonText == "上班打卡")
if (isSelectedStationCode)
{
// 执行上班打卡逻辑
isCheckOn = 0;
status = 0;
isUse = true;
CheckInButtonText = "结束打卡";
IsCheckOutButtonEnabled = "False"; // Disable CheckOutButton
CheckOutButtonColor = "Gray";
hidUtils.StartScan();
isOnDuty = true;
if (CheckInButtonText == "上班打卡")
{
// 执行上班打卡逻辑
isCheckOn = 0;
status = 0;
isUse = true;
CheckInButtonText = "结束打卡";
IsCheckOutButtonEnabled = "False"; // Disable CheckOutButton
CheckOutButtonColor = "Gray";
hidUtils.StartScan();
}
else
{
// 执行结束打卡逻辑
CheckInButtonText = "上班打卡";
IsCheckOutButtonEnabled = "True"; // Enable CheckOutButton
CheckOutButtonColor = "#009999";
TransmitUserDelegateEvent?.Invoke();
hidUtils.StopScan();
ShowStaffAttendances(null, isCheckOn);
isCheckOn = 1;
isUse = false;
}
}
else
{
// 执行结束打卡逻辑
CheckInButtonText = "上班打卡";
IsCheckOutButtonEnabled = "True"; // Enable CheckOutButton
CheckOutButtonColor = "#009999";
TransmitUserDelegateEvent?.Invoke();
hidUtils.StopScan();
isCheckOn = 1;
isUse = false;
MessageBox.Show("请先选择工位!");
}
}
@ -427,8 +503,11 @@ namespace SlnMesnac.WPF.ViewModel
CheckOutButtonText = "下班打卡";
IsCheckInButtonEnabled = "True"; // Enable CheckInButton
CheckInButtonColor = "#009999";
TransmitUserDelegateEvent?.Invoke();
hidUtils.StopScan();
ShowStaffAttendances(null, isCheckOn);
isCheckOn = 0;
isSelectedStationCode = false;
isUse = false;
}
}
@ -460,6 +539,61 @@ namespace SlnMesnac.WPF.ViewModel
return false;
}
/// <summary>
/// 显示人员登录信息
/// </summary>
/// <param name="theUser"></param>
/// <param name="theIsCheckOn"></param>
private void ShowStaffAttendances(BaseStaffInfo? theUser, int theIsCheckOn)
{
var list = _rfidHandleBusniess.HandleAndInsertStaffRealTime(theUser, theIsCheckOn);
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
RecordStaffRealTimeDataGrid.Clear();
list.ForEach(item => { RecordStaffRealTimeDataGrid.Add(item); });
}));
}
/// <summary>
/// 将字符串转换为列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private List<string> ConvertStringToList(string input)
{
// 使用逗号分隔字符串并转换为列表
List<string> list = new List<string>(input.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
return list;
}
/// <summary>
/// 提取字符串中的数字和描述
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public (string, string) ExtractStrings(string input)
{
// 根据 '-' 分隔字符串
var parts = input.Split('-');
// 返回元组,包含数字和描述
return (parts[0], parts.Length > 1 ? parts[1] : string.Empty);
}
/// <summary>
/// 提取工位编码列表
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public List<string> GetStationCodes(List<string> list)
{
List<string> stationCodes = new List<string>();
foreach (var item in list)
{
stationCodes.Add(ExtractStrings(item).Item1);
}
return stationCodes;
}
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components.Forms;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Protocols;
using NVelocity.Util.Introspection;
using SlnMesnac.Business;
using SlnMesnac.Business.business;
using SlnMesnac.Model.domain;
@ -39,11 +40,12 @@ namespace SlnMesnac.WPF.ViewModel
private ProdPlanDetailService _prodPlanDetailService;
private IRecordStaffAttendanceService _recordStaffAttendanceService;
private IBaseStaffService _baseStaffService;
private string StationCode;
//private string StationCode;
private string DeviceCode;
private string ProcessCode;
public static bool isComplete = true;
private ProdPLanInfo pLanInfo;
private ProdPLanInfo haveInfo;
private SerialPortBusiness _serialPortBusiness;
private string executeText = "待执行";
private int isSearch = 0;
@ -199,6 +201,16 @@ namespace SlnMesnac.WPF.ViewModel
set { materialCodeText = value; OnPropertyChanged("MaterialCodeText"); }
}
/// <summary>
/// 工位列表
/// </summary>
private List<string> stationList;
public List<string> StationList
{
get { return stationList; }
set { stationList = value; OnPropertyChanged("StationList");}
}
/// <summary>
/// 订单
/// </summary>
@ -225,10 +237,15 @@ namespace SlnMesnac.WPF.ViewModel
IConfigurationRoot configuration = configurationBuilder.Build();
pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "", "1").FirstOrDefault();
Refresh(pLanInfo);
havePlanOnDuty();
// 从配置文件中获取ProductLineNameTextBlock的值
stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"];
StationCode = configuration.GetSection("AppConfig")["StationCode"];
RfidHandleBusniess.stationCode = StationCode;
//stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"];
//StationCodes = configuration.GetSection("AppConfig")["StationCode"];
//EmployeeLoginViewModel.TransmitStationNameAction += info => {
// stationTextBlock = info;
//};
//StationList = ConvertStringToList(StationCodes);
//RfidHandleBusniess.stationCode = StationCodes;
DeviceCode = configuration.GetSection("AppConfig")["DeviceCode"];
ProcessCode = configuration.GetSection("AppConfig")["ProcessCode"];
HandoverCommand = new RelayCommand(Handover);
@ -242,6 +259,18 @@ namespace SlnMesnac.WPF.ViewModel
MainWindowViewModel.TransferOrderCodeEvent += HandleOrderCode;
}
private void havePlanOnDuty()
{
haveInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault();
if (haveInfo != null)
{
isComplete = false;
}else
{
isComplete = true;
}
}
/// <summary>
/// 换班弹窗
/// </summary>
@ -258,11 +287,29 @@ namespace SlnMesnac.WPF.ViewModel
/// </summary>
private void ProductionReport()
{
MainWindowViewModel.wins = 3;
var reportWin = new ProductionReportWin();
reportWin.Owner = Application.Current.MainWindow; // 设置父窗口为当前主窗口
reportWin.WindowStartupLocation = WindowStartupLocation.CenterScreen; // 让窗体出现在屏幕中央
reportWin.ShowDialog();//窗体出现后禁止后面的用户控件
if (RfidHandleBusniess.stationCode != "")
{
pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", RfidHandleBusniess.stationCode, "1").FirstOrDefault();
if (pLanInfo != null)
{
MainWindowViewModel.wins = 3;
var reportWin = new ProductionReportWin();
reportWin.Owner = Application.Current.MainWindow; // 设置父窗口为当前主窗口
reportWin.WindowStartupLocation = WindowStartupLocation.CenterScreen; // 让窗体出现在屏幕中央
reportWin.ShowDialog();//窗体出现后禁止后面的用户控件
Refresh(pLanInfo);
ShowTeamMember();
MainWindowViewModel.wins = 1;
}
else
{
MessageBox.Show("没有待执行或执行中的工单!");
}
}
else
{
MessageBox.Show("未选择工位没有班组上班!");
}
}
/// <summary>
@ -295,7 +342,7 @@ namespace SlnMesnac.WPF.ViewModel
//在这里执行其他操作可以通过InputText获取用户输入的信息
//Console.WriteLine("用户输入的信息:" + OrderCodeTextBox + PlanCodeTextBox + MaterialCodeTextBox);
//ProductLineNameTextBlock = ConfigurationManager.AppSettings["ProductLineNameTextBlock"];
List<ProdPLanInfo> list = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(OrderCodeTextBox, PlanCodeTextBox, MaterialCodeTextBox, StationCode, "0");
List<ProdPLanInfo> list = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(OrderCodeTextBox, PlanCodeTextBox, MaterialCodeTextBox, RfidHandleBusniess.stationCode, "0");
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
ProdPLanInfoDataGrid.Clear();
@ -322,14 +369,27 @@ namespace SlnMesnac.WPF.ViewModel
if (isSearch == 1)
{
//判断当前工位的工单编号是否存在
var plan = _prodPlanInfoService.GetProdPLanInfoByOrderCode(StationCode, orderCode);
var plan = _prodPlanInfoService.GetProdPLanInfoByOrderCode(RfidHandleBusniess.stationCode, orderCode);
if (plan == null)//不存在就在生产工单表中新增一条当前工位的订单且执行状态改为4,重新检索,并高亮这条工单,执行按钮可用
{
_databaseHandleBusniess.AddNewPlanInfo(orderCode,StationCode,DeviceCode,ProcessCode,"0");
foreach(var item in RfidHandleBusniess.stationList)
{
//现扫描一个订单码,同时插入三张(出布包胶成型)工单表
_databaseHandleBusniess.AddNewPlanInfo(orderCode, item , DeviceCode, ProcessCode, "0");
}
}
else//存在将本条数据的执行状态改为4高亮这条工单执行按钮可用
{
_databaseHandleBusniess.UpdatePlanStatus(orderCode,StationCode,DeviceCode,ProcessCode,"4");
//判断这条工单状态是否为待执行或未执行
//var info = _databaseHandleBusniess.SelectPlanStatus(orderCode, RfidHandleBusniess.stationCode, DeviceCode, ProcessCode, "0");
if (plan.PlanStatus != "2")
{
_databaseHandleBusniess.UpdatePlanStatus(orderCode, RfidHandleBusniess.stationCode, DeviceCode, ProcessCode, "4");
}
else
{
MessageBox.Show("此工单已完成");
}
}
Search();
}
@ -395,9 +455,10 @@ namespace SlnMesnac.WPF.ViewModel
{
if(pLanInfo != null)
{
ProdPlanDetail planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(pLanInfo.PlanCode);
if (planDetail != null)
List<ProdPlanDetail> planDetails = _prodPlanDetailService.GetPlanDetailsByPlanCode(pLanInfo.PlanCode);
if (planDetails.Count != 0)
{
var planDetail = planDetails.FirstOrDefault();
PlanCodeText = planDetail.PlanCode;
OrderCodeText = pLanInfo.OrderCode;
MaterialCodeText = planDetail.MaterialCode;
@ -405,10 +466,22 @@ namespace SlnMesnac.WPF.ViewModel
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
{
ProdPLanDetailDataGrid.Clear();
ProdPLanDetailDataGrid.Add(planDetail);
planDetails.ForEach(item => { ProdPLanDetailDataGrid.Add(item); });
//ProdPLanDetailDataGrid.Add(planDetail);
}));
}
}
}
}
//else
//{
// PlanCodeText = "";
// OrderCodeText = "";
// MaterialCodeText = "";
// StationCodeText = "";
// System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
// {
// ProdPLanDetailDataGrid.Clear();
// }));
//}
}
/// <summary>
@ -420,6 +493,18 @@ namespace SlnMesnac.WPF.ViewModel
TeamMember = _RfidHandleBusniess.SpliceTeamMember();
}
/// <summary>
/// 将字符串转换为列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private List<string> ConvertStringToList(string input)
{
// 使用逗号分隔字符串并转换为列表
List<string> list = new List<string>(input.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
return list;
}
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

@ -54,7 +54,7 @@ namespace SlnMesnac.WPF.ViewModel
{
if(planInfo != null)
{
planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
//planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
//_recordStaffAttendanceService.GetLastestOffRecord();
//PlanAmountText = planDetail.PlanAmount.ToString();
//CompleteAmountText = planDetail.CompleteAmount.ToString();

@ -23,6 +23,10 @@ namespace SlnMesnac.WPF.ViewModel
private DatabaseHandleBusniess _databaseHandleBusniess;
private ProdPLanInfo planInfo;
private ProdPlanDetail planDetail;
private double complateRate;
private double currentAmountDouble;
private double newAmountDouble;
private double result;
#region
/// <summary>
@ -42,12 +46,22 @@ namespace SlnMesnac.WPF.ViewModel
_databaseHandleBusniess = App.ServiceProvider.GetService<DatabaseHandleBusniess>();
ConfirmCommand = new RelayCommand(Confirm);
EndPlanCommand = new RelayCommand(EndPlan);
ContinueCommand = new RelayCommand(Continue);
EndButtonColor = "Red";
Init();
}
private void Init()
{
planInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions("", "", "", "","1").FirstOrDefault();
planInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", RfidHandleBusniess.stationCode, "1").FirstOrDefault();
if (planInfo != null)
{
complateRate = GetComplateRate(Convert.ToDouble(planInfo.CompleteAmount), planInfo.PlanAmount);
if (complateRate > 0.9)
{
EndButtonColor = "#FF11B514";
}
}
Refresh();
}
@ -55,8 +69,8 @@ namespace SlnMesnac.WPF.ViewModel
{
if (planInfo != null)
{
planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode);
PlanAmountText = planDetail.PlanAmount.ToString();
planDetail = _prodPlanDetailService.GetPlanDetailsByPlanCode(planInfo.PlanCode).FirstOrDefault();
PlanAmountText = planInfo.PlanAmount.ToString();
CompleteAmountText = planInfo.CompleteAmount.ToString();
}
else
@ -105,8 +119,23 @@ namespace SlnMesnac.WPF.ViewModel
get { return hintText; }
set { hintText = value; OnPropertyChanged("HintText"); }
}
/// <summary>
/// 结束按钮颜色
/// </summary>
private string endButtonColor;
public string EndButtonColor
{
get { return endButtonColor;}
set { endButtonColor = value; OnPropertyChanged("EndButtonColor"); }
}
#endregion
/// <summary>
/// 继续
/// </summary>
public ICommand ContinueCommand { get; set; }
/// <summary>
/// 确认命令
/// </summary>
@ -133,11 +162,13 @@ namespace SlnMesnac.WPF.ViewModel
if (isNum)
{
//将新增产量加到实际产量中
double currentAmountDouble = Convert.ToDouble(planInfo.CompleteAmount);
double newAmountDouble = Convert.ToDouble(newAmount);
double result = currentAmountDouble + newAmountDouble;
currentAmountDouble = Convert.ToDouble(planInfo.CompleteAmount);
newAmountDouble = Convert.ToDouble(newAmount);
result = currentAmountDouble + newAmountDouble;
//planDetail = new ProdPlanDetail();
planDetail.CompleteAmount = newAmountDouble.ToString();
planInfo.CompleteAmount = result.ToString();
planDetail.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
planDetail.BatchNumber += 1;
planInfo.PlanStatus = "4";
//保存工单的执行人员
@ -150,6 +181,11 @@ namespace SlnMesnac.WPF.ViewModel
HintText = "已提交!";
RefreshDelegateEvent?.Invoke(planInfo);
ExecuteViewModel.isComplete = true;
complateRate = GetComplateRate(result, PlanAmountText);
if (complateRate > 0.9)
{
EndButtonColor = "#FF11B514";
}
}
else
{
@ -161,7 +197,11 @@ namespace SlnMesnac.WPF.ViewModel
{
HintText = "不能为空!";
}
}
}
else
{
HintText = "没有班组当班,无法执行此操作!";
}
}
/// <summary>
@ -171,33 +211,63 @@ namespace SlnMesnac.WPF.ViewModel
private void EndPlan()
{
//判断工单实际产量与目标产量的差距,满足才能执行结束
if(EmployeeLoginViewModel.isOnDuty == true)//是否有班组当班,无当班时操作无效
if (complateRate > 0.9)
{
if (planDetail != null && planInfo != null)
if (EmployeeLoginViewModel.isOnDuty == true)//是否有班组当班,无当班时操作无效
{
planDetail.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
_prodPlanDetailService.Insert(planDetail);
planInfo.PlanStatus = "2";
planInfo.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
double planAmountDouble = Convert.ToDouble(planDetail.PlanAmount);
double completeAmountDouble = Convert.ToDouble(planDetail.CompleteAmount);
if (planAmountDouble == completeAmountDouble)
if (planDetail != null && planInfo != null)
{
planInfo.CompFlag = "0";//正常完成
//planDetail.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//_prodPlanDetailService.Insert(planDetail);
planInfo.PlanStatus = "2";
planInfo.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
double planAmountDouble = Convert.ToDouble(planDetail.PlanAmount);
double completeAmountDouble = Convert.ToDouble(planDetail.CompleteAmount);
if (planAmountDouble == completeAmountDouble)
{
planInfo.CompFlag = "0";//正常完成
}
else if (planAmountDouble > completeAmountDouble)
{
planInfo.CompFlag = "1";//不足目标产量降级处理
}
else
{
planInfo.CompFlag = "2";//超额完成
}
_prodPlanInfoService.Update(planInfo);
}
else if (planAmountDouble > completeAmountDouble)
{
planInfo.CompFlag = "1";//不足目标产量降级处理
}
else
{
planInfo.CompFlag = "2";//超额完成
}
_prodPlanInfoService.Update(planInfo);
//关闭窗口
Application.Current.Windows.OfType<ProductionReportWin>().First().Close();
}
//关闭窗口
Application.Current.Windows.OfType<ProductionReportWin>().First().Close();
}
}
else
{
MessageBox.Show("完成产量与计划数量差距过大!");
}
}
/// <summary>
/// 继续执行
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void Continue()
{
//关闭窗口
Application.Current.Windows.OfType<ProductionReportWin>().First().Close();
}
/// <summary>
/// 获取完成率
/// </summary>
/// <param name="complateAmount"></param>
/// <param name="planAmount"></param>
/// <returns></returns>
private double GetComplateRate(double complateAmount, string planAmount)
{
double plan = Convert.ToDouble(planAmount);
return complateAmount / plan;
}
public void OnPropertyChanged([CallerMemberName] string propertyName = "")

@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SlnMesnac.WPF.Views"
WindowStartupLocation="CenterOwner" Background="Transparent" ResizeMode="NoResize" FontWeight="ExtraLight"
WindowStartupLocation="CenterOwner" Background="White" ResizeMode="NoResize" FontWeight="ExtraLight"
mc:Ignorable="d"
Title="ProductionReportWin" Height="450" Width="800">
<WindowChrome.WindowChrome>
@ -132,7 +132,7 @@
</Grid>
</Border>
<Border Grid.Row="1">
<Button Content="提交" Command="{Binding ConfirmCommand}" FontSize="20" Foreground="White" Height="50" Width="120" Style="{StaticResource BUTTON_AGREE}" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,20,0"></Button>
<Button Content="提交" Command="{Binding ConfirmCommand}" FontSize="20" Foreground="White" Height="50" Width="110" Style="{StaticResource BUTTON_AGREE}" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,29,0"></Button>
</Border>
</Grid>
</Border>
@ -150,10 +150,10 @@
<TextBlock Text="{Binding HintText}" FontSize="20" Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Column="1">
<Grid/>
<Button Content="继续执行" x:Name="Continue" Command="{Binding ContinueCommand}" CommandParameter="{Binding Name,ElementName=Select}" Style="{StaticResource BUTTON_AGREE}" FontSize="20" FontWeight="Bold" Height="50" Width="110" Background="#FF11B514" BorderBrush="#FF36B5C1" Margin="70,14,0,14"/>
</Border>
<Border Grid.Column="2">
<Button Content="结束工单" x:Name="Handover" Command="{Binding EndPlanCommand}" CommandParameter="{Binding Name,ElementName=Select}" Style="{StaticResource BUTTON_AGREE}" FontSize="20" FontWeight="Bold" Background="#FFDC870B" BorderBrush="#FFDC870B" Margin="40,14,40,14"/>
<Button Content="结束工单" x:Name="Handover" Command="{Binding EndPlanCommand}" CommandParameter="{Binding Name,ElementName=Select}" Style="{StaticResource BUTTON_AGREE}" FontSize="20" FontWeight="Bold" Height="50" Width="110" Background="{Binding EndButtonColor}" BorderBrush="{Binding EndButtonColor}" Margin="40,14,10,14"/>
</Border>
</Grid>
</Border>

@ -62,7 +62,7 @@
"stopBits": 1,
"parity": 0,
"redisConfig": "175.27.215.92:6379,password=redis@2023",
"StationCode": "1020",
"StationCode": "1012-压延一出布,1013-压延一成型,1014-压延一包胶",
"DeviceCode": "XMGR0004",
"ProcessCode": "1002",
"ProductLineName": "压延一工位"

Loading…
Cancel
Save