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.

770 lines
34 KiB
C#

using CentralControl.DBDAO;
using CommonFunc;
2 years ago
using CommonFunc.Tools;
using COSMO.IM.LanJu.Index;
2 years ago
using System;
using System.Collections.Generic;
2 years ago
using System.Data;
using System.Diagnostics;
2 years ago
using System.Linq;
using System.Reflection;
2 years ago
using System.Text;
2 years ago
using System.Threading.Tasks;
2 years ago
using System.Timers;
2 years ago
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
2 years ago
using XGL.Data.DBService;
using XGL.Models.Model.FoamingMac;
2 years ago
namespace XGL.Views
{
/// <summary>
/// LanJu_Operator.xaml 的交互逻辑
/// </summary>
public partial class LanJu_Operator : UserControl
{
2 years ago
FormingMachineService formingMachineService = new FormingMachineService();
DBService userDbWareHouse = new DBService();
2 years ago
public static LanJu_Operator lanJu_Operator;
Frame frame = new Frame() { Content = new Views.LanJu_InOut()};
2 years ago
string deviceCode = Utils.GetAppSetting("DeviceCode");
Timer timerDeciveState = new Timer();
string _workOrderCode = "";
2 years ago
public enum WindowID
{
frame
}
public LanJu_Operator()
{
InitializeComponent();
WindowChange(WindowID.frame);
2 years ago
}
2 years ago
public void WindowChange(WindowID windowID)
{
Window1.Content = frame;
}
List<string> sfcList = null;
2 years ago
private void InOut_Click(object sender, RoutedEventArgs e)
{
LanJu_InOut lanJu_InOut = new LanJu_InOut(_workOrderCode, deviceCode);
// 在主界面中的某个位置订阅事件
lanJu_InOut.ValueSelected += (sender1, args) =>
{
// 在这里处理从子窗口传回的值
sfcList = lanJu_InOut.SFCCodeList;
// 执行需要的操作
};
2 years ago
Window1.Content = new Frame
{
Content = lanJu_InOut
};
}
private void Complete_Click(object sender, RoutedEventArgs e)
{
LanJu_Complete lanJu_Complete = new LanJu_Complete();
Window1.Content = new Frame
{
Content = lanJu_Complete
};
}
private void DeviceItems_Click(object sender, RoutedEventArgs e)
{
LanJu_DeviceItems lanJu_DeviceItems = new LanJu_DeviceItems();
Window1.Content = new Frame
{
Content = lanJu_DeviceItems
};
}
private void Paused_Click(object sender, RoutedEventArgs e)
{
LanJu_Paused lanJu_Paused = new LanJu_Paused();
Window1.Content= new Frame
{
Content = lanJu_Paused
};
}
2 years ago
private void UCOperator_Loaded(object sender, RoutedEventArgs e)
{
timerDeciveState.Interval = Utils.GetAppSetting("GetDeviceStateInterval") == "" ? 15000 : Convert.ToInt32(Utils.GetAppSetting("GetDeviceStateInterval"));
timerDeciveState.Elapsed += TimerDeciveState_Elapsed;
timerDeciveState.Start();
GetWorkOrderInfo();
2 years ago
}
string isbaiye;
string plantime;
private void TimerDeciveState_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
if (Utils.isAnyBodyPerating) return;
List<FoamingMacModel> orderList = new List<FoamingMacModel>();
int currHour = DateTime.Now.Hour;
int currMinute = DateTime.Now.Minute;
//modelWareHouse = new List<WorkOrder>();
//userDbWareHouse = new DBService();
int shiftId = 0;
DataTable shiftlist = formingMachineService.GetShiftList();
string endTimeRecord = "";
string startTimeRecord = "";
foreach (DataRow shift in shiftlist.Rows)
{
string[] timeStart = shift["Shift_Start_Time"].ToString().Split(':');
string[] timeEnd = shift["Shift_End_Time"].ToString().Split(':');
// 创建两个不带日期的时间点
TimeSpan currTime = new TimeSpan(currHour, currMinute, 0); // 获取当前小时+分钟数
TimeSpan startTime = new TimeSpan(Convert.ToInt32(timeStart[0]), Convert.ToInt32(timeStart[1]), 0); // 表示9小时45分钟0秒
TimeSpan endTime = new TimeSpan(Convert.ToInt32(timeEnd[0]), Convert.ToInt32(timeEnd[1]), 0);
// 比较当前时间点和班次开始的时间点
int comparisonResultStart = TimeSpan.Compare(currTime, startTime);
// 比较当前时间点和班次结束的时间点
int comparisonResultEnd = TimeSpan.Compare(currTime, endTime);
//if (comparisonResultStart > 0) { Console.WriteLine("time1 大于 time2"); }
if (comparisonResultStart >= 0 && comparisonResultEnd < 0)
{
endTimeRecord = shift["Shift_Start_Time"].ToString();
startTimeRecord = shift["Shift_End_Time"].ToString();
shiftId = Convert.ToInt32(shift["shift_id"].ToString());
break;
}
else if (comparisonResultStart >= 0 || comparisonResultEnd < 0)
{
endTimeRecord = shift["Shift_Start_Time"].ToString();
startTimeRecord = shift["Shift_End_Time"].ToString();
shiftId = Convert.ToInt32(shift["shift_id"].ToString());
break;
}
//if (Convert.ToInt32(timeStart[0]) <= currHourWithDecimal && currHourWithDecimal < Convert.ToInt32(timeEnd[0]))
//{
// shiftId = shift.shiftId;
// break;
//}
//else if (currHourWithDecimal >= Convert.ToInt32(timeStart[0]) || currHourWithDecimal < Convert.ToInt32(timeEnd[0]))
//{
// shiftId = shift.shiftId;
// break;
//}
}
string[] endTimeReally = endTimeRecord.Split(':');
string[] startTimeReally = startTimeRecord.Split(':');
DateTime currShiftDate = DateTime.Now.Date;
TimeSpan currTimeNew = new TimeSpan(currHour, currMinute, 0); // 获取当前小时+分钟数
TimeSpan startTimeNew = new TimeSpan(Convert.ToInt32(startTimeReally[0]), Convert.ToInt32(startTimeReally[1]), 0); // 表示9小时45分钟0秒
TimeSpan endTimeNew = new TimeSpan(Convert.ToInt32(endTimeReally[0]), Convert.ToInt32(endTimeReally[1]), 0); // 表示9小时45分钟0秒
//计算白夜班工作日期用
int resultstart = TimeSpan.Compare(currTimeNew, startTimeNew);
// 比较当前时间点和班次结束的时间点
int resultEnd = TimeSpan.Compare(currTimeNew, endTimeNew);
//夜班、
if (resultstart < 0 && resultEnd < 0)
{
currShiftDate = DateTime.Now.Date.AddDays(-1);
}
//modelWareHouse = new List<WorkOrder>();
userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.ShiftCode);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
FoamingMacModel order = new FoamingMacModel();
order.workorder_id = i["workorder_id"].ToString();
order.workorder_code = i["workorder_code"].ToString();
order.product_name = i["product_name"].ToString();
order.product_code = i["product_code"].ToString();
order.car_num = Convert.ToInt32(i["car_num"].ToString());
order.plan_time = Convert.ToDateTime(i["plan_time"].ToString());
plantime=order.plan_time.ToString();
order.status = i["status"].ToString();
order.process_id = i["route_code"].ToString();
order.attr1 = i["attr1"].ToString();
order.shift_id = i["Shift_Desc"].ToString();
order.totalCount = i["totalCount"].ToString();
order.start_work_time = Convert.ToDateTime(i["start_work_time"].ToString());
order.end_work_time = Convert.ToDateTime(i["end_work_time"].ToString());
//if (isbaiye=="5")
//{
// order.isbai = "白班";
//}
//else if (isbaiye=="2")
//{
// order.isbai = "夜班";
//}
orderList.Add(order);
}
2 years ago
//foreach (var item in orderList)
//{
// string bumb = formingMachineService.getnumber(deviceCode, plantime, isbaiye);
// LogHelper.instance.log.Info($@"当前查询到当前机台{deviceCode}工作数量为{bumb}");
// item.totalCount = bumb;
//}
if (orderList != null)
{
//使用Dispatcher来在UI线程上更新UI
this.Dispatcher.Invoke(
new Action(() =>
{
this.dgWorkOrderInfo.ItemsSource = null;
this.dgWorkOrderInfo.ItemsSource = orderList;//dt.DefaultView;
dgWorkOrderInfo.SelectedIndex = 0;
}
),
System.Windows.Threading.DispatcherPriority.Render);
}
}
catch (Exception ex)
{
LogHelper.instance.log.Error("获取工单准备信息时发生异常:" + ex.Message);
}
}
2 years ago
private void GetWorkOrderInfo()
{
try
{
2 years ago
List<FoamingMacModel> orderList = new List<FoamingMacModel>();
2 years ago
int currHour = DateTime.Now.Hour;
int currMinute = DateTime.Now.Minute;
//modelWareHouse = new List<WorkOrder>();
//userDbWareHouse = new DBService();
int shiftId = 0;
DataTable shiftlist = formingMachineService.GetShiftList();
string endTimeRecord = "";
string startTimeRecord = "";
foreach (DataRow shift in shiftlist.Rows)
{
string[] timeStart = shift["Shift_Start_Time"].ToString().Split(':');
string[] timeEnd = shift["Shift_End_Time"].ToString().Split(':');
// 创建两个不带日期的时间点
TimeSpan currTime = new TimeSpan(currHour, currMinute, 0); // 获取当前小时+分钟数
TimeSpan startTime = new TimeSpan(Convert.ToInt32(timeStart[0]), Convert.ToInt32(timeStart[1]), 0); // 表示9小时45分钟0秒
TimeSpan endTime = new TimeSpan(Convert.ToInt32(timeEnd[0]), Convert.ToInt32(timeEnd[1]), 0);
// 比较当前时间点和班次开始的时间点
int comparisonResultStart = TimeSpan.Compare(currTime, startTime);
// 比较当前时间点和班次结束的时间点
int comparisonResultEnd = TimeSpan.Compare(currTime, endTime);
//if (comparisonResultStart > 0) { Console.WriteLine("time1 大于 time2"); }
if (comparisonResultStart >= 0 && comparisonResultEnd < 0)
{
endTimeRecord = shift["Shift_Start_Time"].ToString();
startTimeRecord = shift["Shift_End_Time"].ToString();
shiftId = Convert.ToInt32(shift["shift_id"].ToString());
break;
}
else if (comparisonResultStart >= 0 || comparisonResultEnd < 0)
{
endTimeRecord = shift["Shift_Start_Time"].ToString();
startTimeRecord = shift["Shift_End_Time"].ToString();
shiftId = Convert.ToInt32(shift["shift_id"].ToString());
break;
}
//if (Convert.ToInt32(timeStart[0]) <= currHourWithDecimal && currHourWithDecimal < Convert.ToInt32(timeEnd[0]))
//{
// shiftId = shift.shiftId;
// break;
//}
//else if (currHourWithDecimal >= Convert.ToInt32(timeStart[0]) || currHourWithDecimal < Convert.ToInt32(timeEnd[0]))
//{
// shiftId = shift.shiftId;
// break;
//}
}
string[] endTimeReally = endTimeRecord.Split(':');
string[] startTimeReally = startTimeRecord.Split(':');
DateTime currShiftDate = DateTime.Now.Date;
TimeSpan currTimeNew = new TimeSpan(currHour, currMinute, 0); // 获取当前小时+分钟数
TimeSpan startTimeNew = new TimeSpan(Convert.ToInt32(startTimeReally[0]), Convert.ToInt32(startTimeReally[1]), 0); // 表示9小时45分钟0秒
TimeSpan endTimeNew = new TimeSpan(Convert.ToInt32(endTimeReally[0]), Convert.ToInt32(endTimeReally[1]), 0); // 表示9小时45分钟0秒
//计算白夜班工作日期用
int resultstart = TimeSpan.Compare(currTimeNew, startTimeNew);
// 比较当前时间点和班次结束的时间点
int resultEnd = TimeSpan.Compare(currTimeNew, endTimeNew);
//夜班、
if (resultstart < 0 && resultEnd < 0)
{
currShiftDate = DateTime.Now.Date.AddDays(-1);
}
2 years ago
//modelWareHouse = new List<WorkOrder>();
2 years ago
userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.WorkDate);
2 years ago
if (dt == null) return;
foreach (DataRow i in dt.Rows)
2 years ago
{
FoamingMacModel order = new FoamingMacModel();
order.workorder_id = i["workorder_id"].ToString();
2 years ago
order.workorder_code = i["workorder_code"].ToString();
order.product_name = i["product_name"].ToString();
2 years ago
2 years ago
order.product_code = i["product_code"].ToString();
order.car_num = Convert.ToInt32(i["car_num"].ToString());
order.plan_time = Convert.ToDateTime(i["plan_time"].ToString());
2 years ago
order.status = i["status"].ToString();
order.process_id = i["route_code"].ToString();
2 years ago
order.attr1 = i["attr1"].ToString();
order.totalCount = i["totalCount"].ToString();
order.shift_id = i["Shift_Desc"].ToString();
if (i["start_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["start_work_time"].ToString()))
{
order.start_work_time = Convert.ToDateTime(i["start_work_time"].ToString());
}
if (i["end_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["end_work_time"].ToString()))
{
order.end_work_time = Convert.ToDateTime(i["end_work_time"].ToString());
}
2 years ago
orderList.Add(order);
2 years ago
2 years ago
}
2 years ago
this.dgWorkOrderInfo.ItemsSource = null;
2 years ago
this.dgWorkOrderInfo.ItemsSource = orderList;//dt.DefaultView;
2 years ago
}
catch (Exception ex)
{
LogHelper.instance.log.Error("获取工单准备信息时发生异常:" + ex.Message);
}
}
private void dgWorkOrderInfo_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = (e.Row.GetIndex() + 1).ToString();
}
2 years ago
private void btnPause_Click(object sender, RoutedEventArgs e)
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
2 years ago
if (selectedRow == null)
{
2 years ago
CustomMessageBox.Show("请选择你要暂停的工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
2 years ago
return;
}
2 years ago
CustomMessageBoxResult result = CustomMessageBox.Show("你确定要暂停该工单吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question);
//MessageBoxResult result = MessageBox.Show("你确定要暂停该工单吗?", "温馨提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == CustomMessageBoxResult.Cancel)
return;
2 years ago
var workordercode = selectedRow.workorder_code;
string currStatus = selectedRow.status;
if(currStatus!="w2")
{
2 years ago
CustomMessageBox.Show("只有活动中的工单才支持暂停!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
PauseOrderWin pauseOrderWin = new PauseOrderWin();
if (pauseOrderWin.ShowDialog() == true)
{
formingMachineService.UpdateWorkOrder(workordercode, "w4", pauseOrderWin.remark, pauseOrderWin.type, deviceCode);
GetWorkOrderInfo();
}
2 years ago
}
2 years ago
private void btnRecover_Click(object sender, RoutedEventArgs e)
2 years ago
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
if (selectedRow == null)
{
2 years ago
CustomMessageBox.Show("请选择你要恢复的工单!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
var workordercode = selectedRow.workorder_code;
string currStatus = selectedRow.status;
if (currStatus != "w4")
{
2 years ago
CustomMessageBox.Show("只有暂停中的工单才支持恢复!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
//MessageBoxResult result = MessageBox.Show("你确定要恢复该工单吗?", "温馨提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
//if (result == MessageBoxResult.No)
// return;
PauseOrderWin pauseOrderWin = new PauseOrderWin();
if (pauseOrderWin.ShowDialog() == true)
2 years ago
{
formingMachineService.UpdateWorkOrder(workordercode, "w2", pauseOrderWin.remark, pauseOrderWin.type, deviceCode);
GetWorkOrderInfo();
}
2 years ago
}
/// <summary>
/// 查看工艺
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Flow_Click(object sender, RoutedEventArgs e)
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
2 years ago
if (selectedRow == null) return;
var workordercode = selectedRow.workorder_code;
DataTable dt = userDbWareHouse.GetFlowInfo(workordercode);
FlowInfoWin flowInfoWin = new FlowInfoWin(dt);
flowInfoWin.ShowDialog();
}
/// <summary>
/// 查看物料
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Material_Click(object sender, RoutedEventArgs e)
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
2 years ago
if (selectedRow == null) return;
var processid = selectedRow.workorder_code;
DataTable dt = userDbWareHouse.GetMaterialInfo(processid);
LanJu_Material sopInfoWin = new LanJu_Material(dt);
sopInfoWin.ShowDialog();
}
/// <summary>
/// 查看SOP
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{
var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
2 years ago
if (selectedRow == null) return;
var workordercode = selectedRow.workorder_code;
DataTable dt = userDbWareHouse.GetSOPInfo(workordercode);
SopInfoWin sopInfoWin = new SopInfoWin(dt);
sopInfoWin.ShowDialog();
2 years ago
}
private void btnRefresh_Click(object sender, RoutedEventArgs e)
{
GetWorkOrderInfo();
2 years ago
LanJu_InOut lanJu_In = new LanJu_InOut(_workOrderCode, deviceCode);
lanJu_In.GetInOutRecordInfo();
2 years ago
}
private void btnComplete_Click(object sender, RoutedEventArgs e)
{
//if (dgWorkOrderInfo.SelectedItems.Count == 0)
//{
// CustomMessageBox.Show("请选择要完成的数据", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
// return;
//}
//string str = sfcList[0].ToString();
//var selectedRow = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
//ShouPeiWin shouPeiWin = new ShouPeiWin(selectedRow);
//shouPeiWin.ShowDialog();
//先获取当前机台解绑的条码
DBService userDbWareHouse = new DBService();
DataTable dt = formingMachineService.GetRfidInfo(deviceCode);
foreach (DataRow item in dt.Rows)
2 years ago
{
string newRfid = "";
DataTable dtNewRFID = formingMachineService.GetNewRFID();
if (dtNewRFID == null || dtNewRFID.Rows.Count == 0)
{
newRfid = "B" + DateTime.Now.ToString("yyyyMMdd") + "0001";
}
else
{
if (string.IsNullOrEmpty(dtNewRFID.Rows[0]["report_code"].ToString()))
{
newRfid = "B" + DateTime.Now.ToString("yyyyMMdd") + "0001";
}
else
{
2 years ago
newRfid = "B" + (Convert.ToInt64(dtNewRFID.Rows[0]["rfid"].ToString().TrimStart('B')) + 1).ToString();
}
}
string sqlInsertMesResult = $@"INSERT INTO [mes_material_transfer_result] (
[id],
[begin],
[beout],
[equipmentCode],
[OrderCode],
[sku],
[planID],
[rfid],
[now_process_id],
[status],
[create_time],
[rfid_status],
[taskcode],
[state],
[update_time],
[work_date],
[shift_id]
)
VALUES
(
'{CommonFunc.Common.GetUUID()}',
GetDate(),
GetDate(),
'{deviceCode}',
'{item["workorder_code"]}',
'{item["product_code"]}',
NULL,
'B{DateTime.Now.ToString("yyyyMMdd")}0001',
'af69d35181624b00848958c93c875818',
NULL,
GetDate(),
'2',
'0',
NULL,
GetDate(),
NULL,
NULL
);
";
2 years ago
}
}
private void btnCheckLog_Click(object sender, RoutedEventArgs e)
{
ViewLogWin viewLogWin = new ViewLogWin();
viewLogWin.ShowDialog();
}
2 years ago
private void btnViewPlcvalue_Click(object sender, RoutedEventArgs e)
{
ViewPlcInfoWin viewPlcWin = new ViewPlcInfoWin();
viewPlcWin.ShowDialog();
}
private void dgWorkOrderInfo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (dgWorkOrderInfo.SelectedItems.Count == 0)
{
return;
}
_workOrderCode = (dgWorkOrderInfo.SelectedItem as FoamingMacModel).workorder_code;
if ((dgWorkOrderInfo.SelectedItem as FoamingMacModel).start_work_time == DateTime.MinValue&&
(dgWorkOrderInfo.SelectedItem as FoamingMacModel).end_work_time == DateTime.MinValue)
{
start.Visibility = Visibility.Visible;
end.Visibility = Visibility.Collapsed;
}
else if((dgWorkOrderInfo.SelectedItem as FoamingMacModel).start_work_time != DateTime.MinValue &&
(dgWorkOrderInfo.SelectedItem as FoamingMacModel).end_work_time != DateTime.MinValue)
{
start.Visibility = Visibility.Collapsed;
end.Visibility = Visibility.Collapsed;
}
else
{
start.Visibility = Visibility.Collapsed;
end.Visibility = Visibility.Visible;
}
InOut_Click(null,null);
}
private void HFPlcvalue_Click(object sender, RoutedEventArgs e)
{
//HBLogWin HFPlcWin = new HBLogWin();
//HFPlcWin.ShowDialog();
HFstatus hFstatus = new HFstatus();
hFstatus.ShowDialog();
}
/// <summary>
/// 一键交接班
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnChangeShifts_Click(object sender, RoutedEventArgs e)
{
if (CustomMessageBox.Show("交接班后产量会计入下一班次,您确定要交接班吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning) == CustomMessageBoxResult.OK)
{
formingMachineService.ChangeShiftsInfo(deviceCode);
DBService.ModShiftTime("BC002", "07:30", "19:30", "BC001", "19:30", "07:30");
//因为程序多开受限制,先启动一个中间程序,再启动本程序
//设置要启动的应用程序名称和参数
string appName = "RestartApp.exe"; // 替换为你的目标控制台应用程序的名称
string appArguments = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;//sresu;// 替换为你的应用程序需要的参数
// 创建进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = appName,
Arguments = appArguments,
RedirectStandardOutput = false, // 可以选择是否重定向标准输出
UseShellExecute = false, // 必须设置为false以便在控制台中启动应用程序
CreateNoWindow = false // 设置为true以便在后台启动应用程序
};
// 创建并启动进程
Process process = new Process
{
StartInfo = startInfo
};
process.Start();
Environment.Exit(0);
}
2 years ago
}
private void btnMachineRepair_Click(object sender, RoutedEventArgs e)
{
2 years ago
//调用首件检验接口
string apiUrl = formingMachineService.GetInterfaceUrl("machineRepair");
var eqment = formingMachineService.GetReportCodeeqment(Utils.GetAppSetting("DeviceCode"));
MachineRepairWin machineRepairWin = new MachineRepairWin(apiUrl, formingMachineService.ConvertToFaultModelList(), eqment);
2 years ago
machineRepairWin.ShowDialog();
}
private void jilu_Click(object sender, RoutedEventArgs e)
{
ProductionData productionData = new ProductionData();
productionData.Show();
}
private void report_Click(object sender, RoutedEventArgs e)
{
new ReportForm().ShowDialog(); ;
}
private void start_Click(object sender, RoutedEventArgs e)
{
List<FoamingMacModel> orderList = new List<FoamingMacModel>();
var sele = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
if (sele != null)
{
var result = MessageBox.Show("确定要开始该工单吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
var aaa= formingMachineService.uporderstarttime(sele.workorder_id);
if (aaa>0)
{
start.Visibility = Visibility.Collapsed;
end.Visibility = Visibility.Visible;
MessageBox.Show("工单已开始");
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.WorkDate);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
FoamingMacModel order = new FoamingMacModel();
order.workorder_id = i["workorder_id"].ToString();
order.workorder_code = i["workorder_code"].ToString();
order.product_name = i["product_name"].ToString();
order.product_code = i["product_code"].ToString();
order.car_num = Convert.ToInt32(i["car_num"].ToString());
order.plan_time = Convert.ToDateTime(i["plan_time"].ToString());
order.status = i["status"].ToString();
order.process_id = i["route_code"].ToString();
order.attr1 = i["attr1"].ToString();
order.totalCount = i["totalCount"].ToString();
order.shift_id = i["Shift_Desc"].ToString();
if (i["start_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["start_work_time"].ToString()))
{
order.start_work_time = Convert.ToDateTime(i["start_work_time"].ToString());
}
if (i["end_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["end_work_time"].ToString()))
{
order.end_work_time = Convert.ToDateTime(i["end_work_time"].ToString());
}
orderList.Add(order);
}
this.dgWorkOrderInfo.ItemsSource = null;
this.dgWorkOrderInfo.ItemsSource = orderList;//dt.DefaultView;
}
else
{
MessageBox.Show("失败");
}
}
}
}
private void end_Click(object sender, RoutedEventArgs e)
{
List<FoamingMacModel> orderList = new List<FoamingMacModel>();
var sele = dgWorkOrderInfo.SelectedItem as FoamingMacModel;
if (sele != null)
{
var result = MessageBox.Show("确定要结束该工单吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
var aaa= formingMachineService.uporderendtime(sele.workorder_id);
if (aaa > 0)
{
start.Visibility = Visibility.Collapsed;
end.Visibility = Visibility.Collapsed;
MessageBox.Show("工单已结束");
DataTable dt = formingMachineService.GetFormingMachineInfo(deviceCode, LoginUser.WorkDate);
if (dt == null) return;
foreach (DataRow i in dt.Rows)
{
FoamingMacModel order = new FoamingMacModel();
order.workorder_id = i["workorder_id"].ToString();
order.workorder_code = i["workorder_code"].ToString();
order.product_name = i["product_name"].ToString();
order.product_code = i["product_code"].ToString();
order.car_num = Convert.ToInt32(i["car_num"].ToString());
order.plan_time = Convert.ToDateTime(i["plan_time"].ToString());
order.status = i["status"].ToString();
order.process_id = i["route_code"].ToString();
order.attr1 = i["attr1"].ToString();
order.totalCount = i["totalCount"].ToString();
order.shift_id = i["Shift_Desc"].ToString();
if (i["start_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["start_work_time"].ToString()))
{
order.start_work_time = Convert.ToDateTime(i["start_work_time"].ToString());
}
if (i["end_work_time"] != DBNull.Value && !string.IsNullOrEmpty(i["end_work_time"].ToString()))
{
order.end_work_time = Convert.ToDateTime(i["end_work_time"].ToString());
}
orderList.Add(order);
}
this.dgWorkOrderInfo.ItemsSource = null;
this.dgWorkOrderInfo.ItemsSource = orderList;//dt.DefaultView;
}
else
{
MessageBox.Show("失败");
}
}
}
}
2 years ago
}
}