|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.IdentityModel.Protocols;
|
|
|
|
|
using NVelocity.Util.Introspection;
|
|
|
|
|
using SlnMesnac.Business;
|
|
|
|
@ -30,6 +31,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class ExecuteViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<ExecuteViewModel> _logger;
|
|
|
|
|
public ObservableCollection<string> OrderCodeComboBoxItems { get; set; }
|
|
|
|
|
public ObservableCollection<string> PlanCodeComboBoxItems { get; set; }
|
|
|
|
|
public ObservableCollection<string> MaterialNameComboBoxItems { get; set; }
|
|
|
|
@ -44,6 +46,9 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
private string DeviceCode;
|
|
|
|
|
private string ProcessCode;
|
|
|
|
|
public static bool isComplete = true;
|
|
|
|
|
public static string theStartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//记录每个明细的开始时间
|
|
|
|
|
public static int stations = 0;
|
|
|
|
|
private string theOrderCode = "";
|
|
|
|
|
private ProdPLanInfo pLanInfo;
|
|
|
|
|
private ProdPLanInfo haveInfo;
|
|
|
|
|
private SerialPortBusiness _serialPortBusiness;
|
|
|
|
@ -135,7 +140,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
public string StationTextBox
|
|
|
|
|
{
|
|
|
|
|
get { return stationTextBlock; }
|
|
|
|
|
set { stationTextBlock = value; new PropertyChangedEventArgs(nameof(StationTextBox)); }
|
|
|
|
|
set { stationTextBlock = value; OnPropertyChanged("StationTextBox"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -194,11 +199,11 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 原料Text
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string materialCodeText;
|
|
|
|
|
public string MaterialCodeText
|
|
|
|
|
private string materialNameText;
|
|
|
|
|
public string MaterialNameText
|
|
|
|
|
{
|
|
|
|
|
get { return materialCodeText; }
|
|
|
|
|
set { materialCodeText = value; OnPropertyChanged("MaterialCodeText"); }
|
|
|
|
|
get { return materialNameText; }
|
|
|
|
|
set { materialNameText = value; OnPropertyChanged("MaterialNameText"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -224,6 +229,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
|
|
|
|
|
public ExecuteViewModel()
|
|
|
|
|
{
|
|
|
|
|
_logger = App.ServiceProvider.GetService<ILogger<ExecuteViewModel>>();
|
|
|
|
|
_prodPlanInfoService = App.ServiceProvider.GetService<ProdPlanInfoService>();
|
|
|
|
|
_prodPlanDetailService = App.ServiceProvider.GetService<ProdPlanDetailService>();
|
|
|
|
|
_recordStaffAttendanceService = App.ServiceProvider.GetService<IRecordStaffAttendanceService>();
|
|
|
|
@ -246,6 +252,10 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
//};
|
|
|
|
|
//StationList = ConvertStringToList(StationCodes);
|
|
|
|
|
//RfidHandleBusniess.stationCode = StationCodes;
|
|
|
|
|
EmployeeLoginViewModel.TransmitStationNameAction += stationName =>
|
|
|
|
|
{
|
|
|
|
|
updateStationName(stationName);
|
|
|
|
|
};
|
|
|
|
|
DeviceCode = configuration.GetSection("AppConfig")["DeviceCode"];
|
|
|
|
|
ProcessCode = configuration.GetSection("AppConfig")["ProcessCode"];
|
|
|
|
|
HandoverCommand = new RelayCommand(Handover);
|
|
|
|
@ -259,6 +269,9 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
MainWindowViewModel.TransferOrderCodeEvent += HandleOrderCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否有计划正在执行
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void havePlanOnDuty()
|
|
|
|
|
{
|
|
|
|
|
haveInfo = _prodPlanInfoService.GetPlanInfoByConditions("", "", "", "", "1").FirstOrDefault();
|
|
|
|
@ -271,6 +284,15 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新工位名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stationName"></param>
|
|
|
|
|
private void updateStationName(string stationName)
|
|
|
|
|
{
|
|
|
|
|
StationTextBox = EmployeeLoginViewModel.stationName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换班弹窗
|
|
|
|
|
/// </summary>
|
|
|
|
@ -299,6 +321,10 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
reportWin.ShowDialog();//窗体出现后禁止后面的用户控件
|
|
|
|
|
Refresh(pLanInfo);
|
|
|
|
|
ShowTeamMember();
|
|
|
|
|
if (stations >= 3)
|
|
|
|
|
{
|
|
|
|
|
_databaseHandleBusniess.UpdateOrderInfoStatus(theOrderCode, "2");
|
|
|
|
|
}
|
|
|
|
|
MainWindowViewModel.wins = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -364,10 +390,13 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void HandleOrderCode(string orderCode)
|
|
|
|
|
{
|
|
|
|
|
theOrderCode = orderCode;
|
|
|
|
|
if (isComplete)
|
|
|
|
|
{
|
|
|
|
|
if (isSearch == 1)
|
|
|
|
|
{
|
|
|
|
|
//更新当前工单状态
|
|
|
|
|
_databaseHandleBusniess.UpdateOrderInfoStatus(orderCode,"1");
|
|
|
|
|
//判断当前工位的工单编号是否存在
|
|
|
|
|
var plan = _prodPlanInfoService.GetProdPLanInfoByOrderCode(RfidHandleBusniess.stationCode, orderCode);
|
|
|
|
|
if (plan == null)//不存在,就在生产工单表中新增一条当前工位的订单,且执行状态改为4,重新检索,并高亮这条工单,执行按钮可用
|
|
|
|
@ -393,10 +422,10 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
}
|
|
|
|
|
Search();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请先检索工单!");
|
|
|
|
|
}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// MessageBox.Show("请先检索工单!");
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -414,13 +443,15 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
if(EmployeeLoginViewModel.isOnDuty == true)
|
|
|
|
|
{
|
|
|
|
|
if (isComplete)//判断是否完成,未完成不能执行其他工单
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 将当前记录存为实体,可以通过parameter获取当前记录的信息
|
|
|
|
|
string orderCode = _selectedRow.OrderCode.ToString();
|
|
|
|
|
string planCode = _selectedRow.PlanCode.ToString();
|
|
|
|
|
pLanInfo = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(orderCode, planCode, "", "", "0").First();
|
|
|
|
|
RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
|
|
|
|
|
BaseStaffInfo staffInfo = _baseStaffService.GetMonitorByTeamCode(currentRecord.TeamCode);
|
|
|
|
|
//RecordStaffAttendance currentRecord = _recordStaffAttendanceService.GetLastestOnRecord();
|
|
|
|
|
//BaseStaffInfo staffInfo = _baseStaffService.GetMonitorByTeamCode(currentRecord.TeamCode);
|
|
|
|
|
RecordStaffAttendance nextRecord = _recordStaffAttendanceService.GetLastestOffRecord();
|
|
|
|
|
// 向detail表里插入一条数据
|
|
|
|
|
ProdPlanDetail prodPlanDetail = new ProdPlanDetail
|
|
|
|
@ -430,12 +461,12 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
PlanAmount = pLanInfo.PlanAmount,
|
|
|
|
|
CompleteAmount = pLanInfo.CompleteAmount,
|
|
|
|
|
BeginTime = DateTime.Now.ToString(),
|
|
|
|
|
CurrentStaffId = staffInfo.StaffId
|
|
|
|
|
//CurrentStaffId = staffInfo.StaffId
|
|
|
|
|
//NextStaffId = nextRecord.StaffId,
|
|
|
|
|
};
|
|
|
|
|
_prodPlanDetailService.Insert(prodPlanDetail);
|
|
|
|
|
//按钮文字变成执行中并锁定,其他的订单执行按钮也禁用
|
|
|
|
|
pLanInfo.BeginTime = DateTime.Now.ToString();
|
|
|
|
|
//pLanInfo.BeginTime = DateTime.Now.ToString();
|
|
|
|
|
pLanInfo.PlanStatus = "1";
|
|
|
|
|
_prodPlanInfoService.Update(pLanInfo);
|
|
|
|
|
Search();
|
|
|
|
@ -443,6 +474,11 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
Refresh(pLanInfo);
|
|
|
|
|
isComplete = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError("执行异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请先完成当前工单!");
|
|
|
|
@ -461,7 +497,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
var planDetail = planDetails.FirstOrDefault();
|
|
|
|
|
PlanCodeText = planDetail.PlanCode;
|
|
|
|
|
OrderCodeText = pLanInfo.OrderCode;
|
|
|
|
|
MaterialCodeText = planDetail.MaterialCode;
|
|
|
|
|
MaterialNameText = pLanInfo.MaterialName;
|
|
|
|
|
StationCodeText = pLanInfo.StationCode;
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
|
|
|
{
|
|
|
|
|