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.
1003 lines
36 KiB
C#
1003 lines
36 KiB
C#
using CommonFunc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
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.Shapes;
|
|
using System.Windows.Threading;
|
|
using XGL.Data;
|
|
using XGL.Models;
|
|
using XGL.UControl;
|
|
using Thrift.Protocol;
|
|
using Thrift.Server;
|
|
using Thrift.Transport;
|
|
using CentralControl.BaseData;
|
|
using CentralControl.DBDAO;
|
|
using XGL.Thrift;
|
|
using System.Threading;
|
|
namespace XGL.FormItem
|
|
{
|
|
/// <summary>
|
|
/// FormHandUp.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class FormHandUp : Window
|
|
{
|
|
|
|
FormShowSelect formSelect;
|
|
public static int WeekNo = CommonHelper.WeekOfYear(DateTime.Now, new System.Globalization.CultureInfo("zh-CN"));
|
|
private FormLocator formLocator;
|
|
// private object refrushState{get;set;}
|
|
private DateTime LastDBTime;
|
|
// private int lastindex = 0;
|
|
List<LineCatchArea> listCatchAreas = new List<LineCatchArea>();
|
|
List<CarRealInfo> listCarreals = new List<CarRealInfo>();
|
|
|
|
FormUpLineBoard uplineBoard = null;
|
|
FormLogin loginForm = null;
|
|
/// <summary>
|
|
/// 时间刷新
|
|
/// </summary>
|
|
private DispatcherTimer dispatcherTimer;
|
|
|
|
|
|
Thread ThreadBeginLeave;
|
|
/// <summary>
|
|
/// UI数据刷新
|
|
/// </summary>
|
|
private DispatcherTimer RefreshUITimer;
|
|
/// <summary>
|
|
/// 上件区小车列表
|
|
/// </summary>
|
|
ObservableCollection<basedata_carrealinfoModel> Cars = new ObservableCollection<basedata_carrealinfoModel>();
|
|
public FormHandUp()
|
|
{
|
|
// refrushState = true;
|
|
InitializeComponent();
|
|
LastDBTime = new DateTime();
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
dispatcherTimer = new DispatcherTimer();
|
|
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000);
|
|
dispatcherTimer.Tick += DispatcherTimer_Tick;
|
|
dispatcherTimer.IsEnabled = true;
|
|
dispatcherTimer.Start();
|
|
|
|
RefreshUITimer = new DispatcherTimer();
|
|
RefreshUITimer.Interval = TimeSpan.FromSeconds(1);
|
|
RefreshUITimer.Tick += RefreshUITimer_Tick;
|
|
RefreshUITimer.IsEnabled = true;
|
|
RefreshUITimer.Start();
|
|
txtTime.Content = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
|
|
|
|
|
|
this.lblWeekDay.Content = WeekNo.ToString();
|
|
string lineno = System.Configuration.ConfigurationManager.AppSettings["LineId"];
|
|
if (lineno != "1")
|
|
{
|
|
this.rdoRunModel0.Visibility = Visibility.Hidden;
|
|
this.rdoRunModel1.Visibility = Visibility.Hidden;
|
|
this.rdoRunModel2.Visibility = Visibility.Hidden;
|
|
}
|
|
else
|
|
{
|
|
List<NodeSetting> listnode = DBService.GetNodeSettingList("", new List<LineCatchArea>());
|
|
NodeSetting node = listnode.FirstOrDefault(t => t.NodeNo == "1001");
|
|
if (node != null)
|
|
{
|
|
if (node.IsClearCar == 1)
|
|
{
|
|
rdoRunModel1.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
//this.rdoRunModel1.IsChecked = true;
|
|
}
|
|
else if (node.IsClearCar == 2)
|
|
{
|
|
rdoRunModel2.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
//this.rdoRunModel2.IsChecked = true;
|
|
}
|
|
else
|
|
{
|
|
rdoRunModel0.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
// this.rdoRunModel0.IsChecked = true;
|
|
}
|
|
}
|
|
}
|
|
//UpdateLocatorCarDB();
|
|
|
|
//BindPlan();
|
|
//BindProductDesc();
|
|
////BindKC();
|
|
//BindModelLocatorList();
|
|
//BindLocatorViewList();
|
|
|
|
LastDBTime = new DateTime();
|
|
|
|
uplineBoard = new FormUpLineBoard();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageBox.Show("系统错误:" + ex.Message);
|
|
lblMessage.Content = "系统错误:" + ex.Message;
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 绑定左侧库位图形列表
|
|
/// </summary>
|
|
private void BindLocatorViewList()
|
|
{
|
|
|
|
// refrushState = false;
|
|
try
|
|
{
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
|
|
|
|
LeftLocatorInfo.Children.Clear();
|
|
RightLocatorInfo.Children.Clear();
|
|
|
|
lblemptycarnum.Content = this.listCarreals.Count(t => t.MaterialNo == "");
|
|
|
|
List<UCStorageNew> liststorage = new List<UCStorageNew>();
|
|
foreach (var area in this.listCatchAreas)
|
|
{
|
|
|
|
var list1 = this.listCarreals.Where(t => t.LocatorId == area.Id).ToList();
|
|
List<CarInfo> list = new List<CarInfo>();
|
|
foreach (var realcar in list1)
|
|
{
|
|
CarInfo car = new CarInfo();
|
|
car.LineAreaId = realcar.LocatorId;
|
|
car.CarNo = realcar.CarNo;
|
|
car.IsOutLocator = realcar.IsOutLocator;
|
|
car.IsPreOut = realcar.IsProOutLocator;
|
|
car.MaterialBarNo = realcar.MaterialBarNo;
|
|
car.MaterialNo = realcar.MaterialNo.Trim();
|
|
list.Add(car);
|
|
}
|
|
|
|
|
|
if (area.LineNo == "1")
|
|
{
|
|
UCStorageNewx locator = new UCStorageNewx();
|
|
locator.LocatorId = area.Id;
|
|
locator.TotalNum = area.MaxNumber;
|
|
locator.StorageNm = area.AreaNm;
|
|
locator.AreaType = area.LineNo;
|
|
locator.StorageTypeNm = area.MaterialNm;// area.AreaStorageType == 0 ? "混合库" : "单型库";
|
|
locator.ProductCar = list;
|
|
locator.SetCarLocatorEvent += CarSetting;
|
|
locator.SetLocatorMaterialEvent += SetLocatorMaterial;
|
|
// liststorage.Add(locator);
|
|
LeftLocatorInfo.Children.Add(locator);
|
|
}
|
|
else
|
|
{
|
|
UCStorageNew locator = new UCStorageNew();
|
|
locator.LocatorId = area.Id;
|
|
locator.TotalNum = area.MaxNumber;
|
|
locator.StorageNm = area.AreaNm;
|
|
locator.AreaType = area.LineNo;
|
|
locator.StorageTypeNm = area.MaterialNm; // area.AreaStorageType == 0 ? "混合库" : "单型库";
|
|
locator.ProductCar = list;
|
|
locator.SetCarLocatorEvent += CarSetting;
|
|
locator.SetLocatorMaterialEvent += SetLocatorMaterial;
|
|
//liststorage.Add(locator);
|
|
RightLocatorInfo.Children.Add(locator);
|
|
}
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
//lvStorages.ItemsSource = liststorage;
|
|
//lvStorages.Items.Refresh();
|
|
|
|
}
|
|
|
|
private void UpdateLocatorCarDB()
|
|
{
|
|
this.listCatchAreas = DBService.GetLineCatchAreaList(" and areatype=4");
|
|
this.listCarreals = DBService.getCarInfoList("", null);
|
|
|
|
}
|
|
private string SetLocatorMaterial(int locatorid)
|
|
{
|
|
|
|
if (formSelect != null)
|
|
{
|
|
formSelect.Close();
|
|
formSelect = null;
|
|
}
|
|
formSelect = new FormShowSelect(2, FormHandUp.WeekNo, locatorid);
|
|
formSelect.optLocatorEvent += SetLocatorMaterial;
|
|
formSelect.Show();
|
|
return "";
|
|
}
|
|
|
|
private void SetLocatorMaterial(int locatorid, string val)
|
|
{
|
|
|
|
TTransport transport = new TSocket(Common.ThriftConfigIp, 7915);
|
|
TProtocol protocol = new TBinaryProtocol(transport);
|
|
ThriftService.Client client = new ThriftService.Client(protocol);
|
|
transport.Open();
|
|
string ret = client.OperateLocatorMaterial(locatorid, val);
|
|
if (ret == "")
|
|
{
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
MessageBox.Show("修改成功");
|
|
this.formSelect.Close();
|
|
this.formSelect = null;
|
|
|
|
LastDBTime = new DateTime();
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
MessageBox.Show(ret);
|
|
}));
|
|
}
|
|
transport.Close();
|
|
transport.Dispose();
|
|
transport = null;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定型号库位
|
|
/// </summary>
|
|
private void CheckDBandPLCState()
|
|
{
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
try
|
|
{
|
|
bool state = DBService.GetDBTime("");
|
|
if (state)
|
|
{
|
|
serverDBState.Fill = new SolidColorBrush(Colors.Green);
|
|
}
|
|
else
|
|
{
|
|
serverDBState.Fill = new SolidColorBrush(Colors.Red);
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
serverDBState.Fill = new SolidColorBrush(Colors.Red);
|
|
}
|
|
}));
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
///// 绑定型号库位
|
|
///// </summary>
|
|
//private void BindModelLocatorList()
|
|
//{
|
|
// List<CarInfo> listCar = new List<CarInfo>();
|
|
// Application.Current.Dispatcher.Invoke(new Action(
|
|
// delegate
|
|
// {
|
|
|
|
|
|
// leftmodelLocator.Children.Clear();
|
|
// rightmodelLocator.Children.Clear();
|
|
// modelLocator.Children.Clear();
|
|
|
|
// foreach (var realcar in listCarreals)
|
|
// {
|
|
// CarInfo car = new CarInfo();
|
|
// car.LineAreaId = realcar.LocatorId;
|
|
// car.CarNo = realcar.CarNo;
|
|
// car.CarNo = realcar.CarNo;
|
|
// car.MaterialBarNo = realcar.MaterialBarNo;
|
|
// car.IsOutLocator = realcar.IsOutLocator;
|
|
// car.MaterialNo = realcar.MaterialNo.Trim();
|
|
// listCar.Add(car);
|
|
// }
|
|
|
|
|
|
// List<UCStorage> liststorage = new List<UCStorage>();
|
|
// foreach (var area in listCatchAreas)
|
|
// {
|
|
|
|
// UCStorage locator = new UCStorage();
|
|
// locator.StorageNm = area.AreaNm;
|
|
// locator.AreaType = area.LineNo;
|
|
// var list1 = listCar.Where(t => t.LineAreaId == area.Id).ToList();
|
|
// locator.ProductCar = list1;
|
|
// locator.TotalNum = area.MaxNumber;
|
|
// locator.SetCarLocatorEvent += CarSetting;
|
|
// liststorage.Add(locator);
|
|
|
|
// if (locator.AreaType == "1")
|
|
// {
|
|
// leftmodelLocator.Children.Add(locator);
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// rightmodelLocator.Children.Add(locator);
|
|
// }
|
|
// }
|
|
|
|
|
|
// var list = from car in listCar group car by car.MaterialBarNo into materialno select materialno;
|
|
// foreach (var car in list)
|
|
// {
|
|
// Button btn = new Button();
|
|
// btn.Background = new SolidColorBrush(Colors.Gray);
|
|
// btn.Foreground = new SolidColorBrush(Colors.White);
|
|
// btn.Width = 100;
|
|
// btn.Height = 40;
|
|
// btn.FontSize = 16;
|
|
// btn.Content = car.Key.Trim() == "" ? "空车" : car.Key;
|
|
// btn.Tag = car.Key;
|
|
// btn.Margin = new Thickness(10);
|
|
// btn.Click += Btn_Click; ;
|
|
// modelLocator.Children.Add(btn);
|
|
// }
|
|
|
|
// }));
|
|
|
|
|
|
// //lvStorages.ItemsSource = liststorage;
|
|
// //lvStorages.Items.Refresh();
|
|
|
|
//}
|
|
|
|
private void Btn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button button = sender as Button;
|
|
button.Background = new SolidColorBrush(Colors.Blue);
|
|
|
|
|
|
MessageBox.Show(button.Tag.ToString());
|
|
}
|
|
|
|
|
|
|
|
private string CarSetting(string carno)
|
|
{
|
|
|
|
if (CommonHelper.UserName == "")
|
|
{
|
|
loginForm = new FormLogin();
|
|
loginForm.loginWindow += LoginWindow;
|
|
loginForm.Show();
|
|
return "";
|
|
}
|
|
|
|
if (CommonHelper.UserName != "")
|
|
{
|
|
if (formLocator != null)
|
|
{
|
|
formLocator.Close();
|
|
formLocator = null;
|
|
}
|
|
|
|
List<CarRealInfo> carlist = DBService.getCarInfoList("", this.listCatchAreas);
|
|
var car = carlist.FirstOrDefault(t => t.CarNo == carno);
|
|
if (car != null)
|
|
{
|
|
formLocator = new FormLocator(car);
|
|
formLocator.optCarEvent += CarSetting;
|
|
formLocator.Show();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("无法找到小车" + carno);
|
|
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
private string CarSetting(CarRealInfo car)
|
|
{
|
|
try
|
|
{
|
|
|
|
TTransport transport = new TSocket(Common.ThriftConfigIp, 7915);
|
|
TProtocol protocol = new TBinaryProtocol(transport);
|
|
ThriftService.Client client = new ThriftService.Client(protocol);
|
|
transport.Open();
|
|
string msg = client.SetCarInfo(car.CarNo, car.MaterialNo, car.MaterialBarNo, car.LocatorId.ToString(), car.IsProOutLocator.ToString(), car.OptDt.ToString());
|
|
transport.Close();
|
|
LastDBTime = DateTime.Now;
|
|
return msg;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
|
|
|
|
private string CarRunModelSetting(int type)
|
|
{
|
|
try
|
|
{
|
|
|
|
TTransport transport = new TSocket(Common.ThriftConfigIp, 7911);
|
|
TProtocol protocol = new TBinaryProtocol(transport);
|
|
ThriftService.Client client = new ThriftService.Client(protocol);
|
|
transport.Open();
|
|
string msg = client.OperateUploadPoint("", type);
|
|
transport.Close();
|
|
LastDBTime = DateTime.Now;
|
|
return msg;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
private void RefreshUITimer_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (LastDBTime <= DateTime.Now.AddSeconds(-30))
|
|
{
|
|
CheckDBandPLCState();
|
|
LastDBTime = DateTime.Now;
|
|
// BindPlan();
|
|
BindProductDesc();
|
|
// BindKC();
|
|
|
|
UpdateLocatorCarDB();
|
|
// BindModelLocatorList();
|
|
BindLocatorViewList();
|
|
|
|
BindOutingLocatorCars();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonFunc.Logger logger = new CommonFunc.Logger();
|
|
logger.Error("系统刷新数据上件点异常:" + ex.Message + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
|
|
private void BindOutingLocatorCars()
|
|
{
|
|
|
|
|
|
|
|
// refrushState = false;
|
|
try
|
|
{
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
List<CarRealInfo> list = DBService.getOutCarInfo();
|
|
this.gridOutCar.ItemsSource = list;
|
|
this.gridOutCar.Items.Refresh();
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(" 获取出库队列 " + method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
private void GridMaterial_LoadingRow(object sender, DataGridRowEventArgs e)
|
|
{
|
|
e.Row.Header = e.Row.GetIndex() + 1;
|
|
|
|
}
|
|
private void DispatcherTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
txtTime.Content = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
|
|
if (CommonHelper.UserName != "" && CommonHelper.LoginDt < DateTime.Now.AddMinutes(-5))
|
|
{
|
|
CommonHelper.UserName = "";
|
|
}
|
|
}
|
|
|
|
private void btnExit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (MessageBox.Show("是否确认关闭当前窗口", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Environment.Exit(System.Environment.ExitCode);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
private void btnProdDesc_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
///检查库内可入数量
|
|
// AutoClosedMsgBox.Show("最大库存量已满", "提示", 2000);
|
|
// return;
|
|
|
|
if (lvCars.SelectedIndex == -1)
|
|
{
|
|
AutoClosedMsgBox.Show("请先选择小车", "提示", 2000);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//var control = lvCars.SelectedItem as UControl.UCCar;
|
|
basedata_carrealinfoModel model = lvCars.SelectedItem as basedata_carrealinfoModel;
|
|
var button = sender as Button;
|
|
model.CarNo = button.CommandParameter.ToString();
|
|
model.ProductCode = button.Content.ToString();
|
|
lvCars.Items.Refresh();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
//private void BindPlan()
|
|
//{
|
|
// try
|
|
// {
|
|
// using (basedata_orderplanDb orderplanDb = new basedata_orderplanDb())
|
|
// {
|
|
// int week = CommonHelper.WeekOfYear(DateTime.Now, new System.Globalization.CultureInfo("zh-CN"));
|
|
// List<vbasedata_orderplanModel> models = orderplanDb.GetVList(" PlanWeek = " + week).OrderBy(t => t.PlanState).OrderBy(t => t.PlanDate).ToList();
|
|
// gridPlan.ItemsSource = models;
|
|
// gridPlan.Items.Refresh();
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
// Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
// }
|
|
|
|
//}
|
|
|
|
private void BindProductDesc()
|
|
{
|
|
try
|
|
{
|
|
using (basedata_orderplanDb orderplanDb = new basedata_orderplanDb())
|
|
{
|
|
|
|
DataSet ds = orderplanDb.GetData(WeekNo.ToString());
|
|
productDesc.ItemsSource = ds.Tables[0].DefaultView;
|
|
productDesc.Items.Refresh();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Cars.Add(new basedata_carrealinfoModel());
|
|
lvCars.ItemsSource = Cars;
|
|
lvCars.Items.Refresh();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
private void btnDel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Cars.RemoveAt(0);
|
|
lvCars.ItemsSource = Cars;
|
|
lvCars.Items.Refresh();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 小车离开上线点
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnLeave_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
btnLeave.IsEnabled = false;
|
|
btnLeave.Content = "发车中...";
|
|
lblMessage.Content = "";
|
|
List<string> carlist = new List<string>();
|
|
foreach (var car in this.lvCars.Items)
|
|
{
|
|
var carinfo = car as basedata_carrealinfoModel;
|
|
|
|
if (!string.IsNullOrEmpty(carinfo.CarNo))
|
|
{
|
|
string carStr = carinfo.ProductCode.Trim() + "*" + carinfo.CarNo + "*";
|
|
if (Convert.ToBoolean(rdoTwo.IsChecked))
|
|
{
|
|
carStr += "2";
|
|
}
|
|
else if (Convert.ToBoolean(rdoThree.IsChecked))
|
|
{
|
|
carStr += "3";
|
|
}
|
|
else if (Convert.ToBoolean(rdoFour.IsChecked))
|
|
{
|
|
carStr += "4";
|
|
}
|
|
else
|
|
{
|
|
carStr += "1";
|
|
}
|
|
carlist.Add(carStr);
|
|
}
|
|
else
|
|
{
|
|
//MessageBox.Show("请选择物料号");
|
|
lblMessage.Content = "请选择物料号";
|
|
btnLeave.IsEnabled = true;
|
|
btnLeave.Content = "发车";
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
ThreadBeginLeave = new Thread(new ParameterizedThreadStart(LeaveCar));
|
|
ThreadBeginLeave.Start(carlist);
|
|
}
|
|
|
|
private void LeaveCar(object obj)
|
|
{
|
|
|
|
try
|
|
{
|
|
List<string> carlist = obj as List<string>;
|
|
if (carlist.Count > 0)
|
|
{
|
|
|
|
|
|
TTransport transport = new TSocket(Common.ThriftConfigIp, Convert.ToInt32(Common.ThriftConfigPort));
|
|
TProtocol protocol = new TBinaryProtocol(transport);
|
|
ThriftService.Client client = new ThriftService.Client(protocol);
|
|
transport.Open();
|
|
string ret = client.DischargeCar(carlist);
|
|
if (ret == "")
|
|
{
|
|
foreach (var car in this.lvCars.Items)
|
|
{
|
|
var carinfo = car as basedata_carrealinfoModel;
|
|
carinfo.ProductCode = "";
|
|
carinfo.CarNo = "";
|
|
}
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
lvCars.ItemsSource = Cars;
|
|
lvCars.Items.Refresh();
|
|
btnLeave.IsEnabled = true;
|
|
btnLeave.Content = "发车";
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
lblMessage.Content = ret;
|
|
//MessageBox.Show(ret);
|
|
btnLeave.IsEnabled = true;
|
|
btnLeave.Content = "发车";
|
|
}));
|
|
|
|
}
|
|
transport.Close();
|
|
}
|
|
else
|
|
{
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
//MessageBox.Show("请为小车绑定物料信息");
|
|
lblMessage.Content = "请为小车绑定物料信息";
|
|
btnLeave.IsEnabled = true;
|
|
btnLeave.Content = "发车";
|
|
}));
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Application.Current.Dispatcher.Invoke(new Action(
|
|
delegate
|
|
{
|
|
//MessageBox.Show("请为小车绑定物料信息");
|
|
lblMessage.Content = "服务器连接不上,请重试";
|
|
btnLeave.IsEnabled = true;
|
|
btnLeave.Content = "发车";
|
|
}));
|
|
|
|
MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
}
|
|
|
|
}
|
|
///// <summary>
|
|
/////
|
|
///// </summary>
|
|
//private void BindKC()
|
|
//{
|
|
// try
|
|
// {
|
|
// using (basedata_carrealinfoDb carrealinfoDb = new basedata_carrealinfoDb())
|
|
// {
|
|
// DataSet ds = carrealinfoDb.GetDataCount(" AreaType>=4");
|
|
|
|
// if (ds.Tables[0].Rows.Count > 0)
|
|
// {
|
|
// DataTable dataTable = ds.Tables[0];
|
|
// dataTable.Columns.Add("Index", typeof(int));
|
|
// int Index = 0;
|
|
// foreach (DataRow row in dataTable.Rows)
|
|
// {
|
|
// Index++;
|
|
// row["Index"] = Index;
|
|
// }
|
|
// DataView dataView = dataTable.DefaultView;
|
|
// //gridEmergency.ItemsSource = dataView;
|
|
// //gridEmergency.Items.Refresh();
|
|
// }
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MethodInfo method = (MethodInfo)MethodBase.GetCurrentMethod();
|
|
// Common.Log.Error(method.DeclaringType.FullName + "-" + method.Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
//TabControl controlTab = sender as TabControl;
|
|
//if (lastindex != controlTab.SelectedIndex)
|
|
//{
|
|
|
|
// if (controlTab.Name != "tabLocator")
|
|
// {
|
|
// if (controlTab.SelectedIndex == 0)
|
|
// {
|
|
|
|
// BindProductDesc();
|
|
|
|
// }
|
|
// else if (controlTab.SelectedIndex == 1)
|
|
// {
|
|
// BindPlan();
|
|
// }
|
|
// else if (controlTab.SelectedIndex == 2)
|
|
// {
|
|
// UpdateLocatorCarDB();
|
|
// BindModelLocatorList();
|
|
// }
|
|
// else if (controlTab.SelectedIndex == 3)
|
|
// {
|
|
// UpdateLocatorCarDB();
|
|
// BindLocatorViewList();
|
|
// }
|
|
// else if (controlTab.SelectedIndex == 4)
|
|
// {
|
|
|
|
// }
|
|
// lastindex = controlTab.SelectedIndex;
|
|
// e.Handled = true;
|
|
// LastDBTime = new DateTime();
|
|
// }
|
|
//}
|
|
LastDBTime = new DateTime();
|
|
}
|
|
|
|
private void BtnClearCar_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DBService.GetClearMaterial("");
|
|
LastDBTime = new DateTime();
|
|
|
|
}
|
|
|
|
private void RdoRunModel2_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
if (CommonHelper.UserName == "")
|
|
{
|
|
loginForm = new FormLogin();
|
|
loginForm.loginWindow += LoginWindow;
|
|
loginForm.Show();
|
|
return;
|
|
}
|
|
|
|
if (CommonHelper.UserName != "")
|
|
{
|
|
CarRunModelSetting(2);
|
|
rdoRunModel2.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
rdoRunModel1.Background = new SolidColorBrush(Colors.Silver);
|
|
rdoRunModel0.Background = new SolidColorBrush(Colors.Silver);
|
|
}
|
|
}
|
|
private string LoginWindow(string loginnm, string pwd)
|
|
{
|
|
CommonHelper.UserName = loginnm;
|
|
CommonHelper.LoginDt = DateTime.Now;
|
|
return "";
|
|
}
|
|
|
|
private void RdoRunModel1_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
if (CommonHelper.UserName == "")
|
|
{
|
|
loginForm = new FormLogin();
|
|
loginForm.loginWindow += LoginWindow;
|
|
loginForm.Show();
|
|
return;
|
|
}
|
|
|
|
if (CommonHelper.UserName != "")
|
|
{
|
|
CarRunModelSetting(1);
|
|
rdoRunModel1.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
rdoRunModel2.Background = new SolidColorBrush(Colors.Silver);
|
|
rdoRunModel0.Background = new SolidColorBrush(Colors.Silver);
|
|
}
|
|
|
|
}
|
|
|
|
private void RdoRunModel0_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
if (CommonHelper.UserName == "")
|
|
{
|
|
loginForm = new FormLogin();
|
|
loginForm.loginWindow += LoginWindow;
|
|
loginForm.Show();
|
|
return;
|
|
}
|
|
|
|
if (CommonHelper.UserName != "")
|
|
{
|
|
CarRunModelSetting(0);
|
|
rdoRunModel0.Background = new SolidColorBrush(Color.FromRgb(0x1f, 0xb0, 0x8e));
|
|
rdoRunModel1.Background = new SolidColorBrush(Colors.Silver);
|
|
rdoRunModel2.Background = new SolidColorBrush(Colors.Silver);
|
|
}
|
|
|
|
}
|
|
|
|
private void BtnAdd_Copy_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void BtnLastWeek_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
FormHandUp.WeekNo -= 1;
|
|
lblWeekDay.Content = FormHandUp.WeekNo.ToString();
|
|
LastDBTime = new DateTime();
|
|
}
|
|
|
|
private void BtnNextWeek_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
FormHandUp.WeekNo += 1;
|
|
lblWeekDay.Content = FormHandUp.WeekNo.ToString();
|
|
LastDBTime = new DateTime();
|
|
}
|
|
|
|
private void BtnSearchCar_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
List<CarRealInfo> list = DBService.getCurrCarInfo(txtCarNo.Text);
|
|
if(list.Count<=0)
|
|
{
|
|
MessageBox.Show("无法找到相关信息");
|
|
return;
|
|
}
|
|
this.gridCarReal.ItemsSource = list;
|
|
this.gridCarReal.Items.Refresh();
|
|
}
|
|
|
|
//private void TabLocator_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
//{
|
|
// TabControl controlTab = sender as TabControl;
|
|
// if (controlTab.Name == "tabLocator")
|
|
// {
|
|
// if (controlTab.SelectedIndex == 0)
|
|
// {
|
|
|
|
// UpdateLocatorCarDB();
|
|
// BindLocatorViewList();
|
|
|
|
// }
|
|
// else if (controlTab.SelectedIndex == 1)
|
|
// {
|
|
// UpdateLocatorCarDB();
|
|
// BindLocatorViewList();
|
|
// }
|
|
// e.Handled = true;
|
|
// LastDBTime = new DateTime();
|
|
// }
|
|
//}
|
|
}
|
|
}
|