diff --git a/src/Khd.Core.Wpf/Form/FormBoardT.xaml b/src/Khd.Core.Wpf/Form/FormBoardT.xaml index 3bceed6..4af8d49 100644 --- a/src/Khd.Core.Wpf/Form/FormBoardT.xaml +++ b/src/Khd.Core.Wpf/Form/FormBoardT.xaml @@ -343,7 +343,7 @@ - + @@ -394,7 +394,7 @@ > - - - - - - + @@ -697,7 +697,7 @@ - + - - - + + + + + + + + + + + + + + + @@ -1418,8 +1518,8 @@ - + - - + + diff --git a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs index 61667e6..24af9d7 100644 --- a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs +++ b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs @@ -1,5 +1,6 @@ using Khd.Core.Domain.Models; using Khd.Core.EntityFramework; +using Khd.Core.Plc.S7.Types; using Masuit.Tools.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -22,6 +23,9 @@ using Thrift.Server; using Thrift.Transport; using ThriftService; using Z.EntityFramework.Plus; +using Jc.SnowId; +using Masuit.Tools; +using System.Windows.Input; namespace Khd.Core.Wpf.Form { @@ -40,11 +44,17 @@ namespace Khd.Core.Wpf.Form private int UpState;//对应上件站点的状态,0为良好 1为损坏 List basePlcpoints = new List(); object timerjilu; - public class selectOrderData + public class barcodeinfo { - public string Id { get; set; } - public string orderCode { get; set; } + public string barcode { get; set; } + public long? materialId { get; set; } + + public decimal? qty { get; set; } } + + public List barcodeLsit = new List(); + + private string selectedId; //FormShowSelect formSelect; // public static int WeekNo = CommonHelper.WeekOfYear(DateTime.Now, new System.Globalization.CultureInfo("zh-CN")); @@ -62,7 +72,7 @@ namespace Khd.Core.Wpf.Form { try { - LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;"); + //LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;"); //设置显示任务栏 if (WindowState == WindowState.Normal) { @@ -115,148 +125,6 @@ namespace Khd.Core.Wpf.Form } } /// - /// 刷新日期 - /// - private void SetTime() - { - new Thread(() => - { - while (true) - { - try - { - Dispatcher.Invoke(new Action(delegate - { - LabDate.Content = DateTime.Now.ToString("yyyy年MM月dd日"); - LabTime.Content = DateTime.Now.ToString("HH:mm:ss"); - })); - } - catch (Exception ex) - { - } - finally - { - Thread.Sleep(1000); - } - } - }).Start(); - } - public void UpMessage(object sender, EventArgs e) - { - MoHuChaXunWuLiaoName_SelectionChanged(timerjilu, null); - } - /// - /// WCS通讯方法 - /// - public void StartThriftServer() - { - try - { - int point = Convert.ToInt32(ThriftConfig.JiesShouDuanKou); - WcsServer wcsServer = new WcsServer(); - //wcsServer.SendCarEvent += SendCar; - // wcsServer.helloEvent += hello; - WcsThrift.Processor processor = new WcsThrift.Processor(wcsServer); - TServerTransport serverTransport = new TServerSocket(point); - TServer server = new TSimpleServer(processor, serverTransport); - server.Serve(); - } - catch (Exception ex) - { - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - //设置图片为未到位 - - })); - LogManager.Error(ex); - } - - } - public string hello(string name) - { - //Console.WriteLine($"hello {name}"); - //return $"ServerResponse receive from client name:{name}"; - try - { - if (!string.IsNullOrWhiteSpace(name)) - { - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - //设置图片为已到位、显示挂具号 - - })); - } - else - { - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - - })); - } - } - catch (Exception ex) - { - LogManager.Info($"客户端接收服务端推送的小车信息方法报错 >>> {ex.Message}"); - } - return ""; - } - - /// - /// 发车方法 - /// - /// - /// - /// 物料号 - /// 三轮车辆长度 - public void SendCar(List carlist, string prodCode, string bunber, string ordercodeid) - { - TTransport transport = new TSocket(ThriftConfig.ThriftIpAddress, ThriftConfig.TuiSongDuankou); - try - { - //Console.WriteLine($"hello carlist[0]:{carlist.FirstOrDefault()}|order_code:{order_code}|amount:{amount}"); - //return $"ServerResponse receive from client order_code:{order_code}"; - transport.Open(); - TProtocol protocol = new TBinaryProtocol(transport); - WcsThrift.Client client = new WcsThrift.Client(protocol); - // var ret = client.SendCar(carlist, prodCode, bunber, ordercodeid); - if ("1" == "1")//与服务端交互成功发车时 - { - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - //发车成功提示反馈 - this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Green); - this.lba_ThrifTtitle.Text = "发车成功!"; - - })); - } - - else//与服务端交互失败时 - { - - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Red); - this.lba_ThrifTtitle.Text = $"Thrift交互失败!"; - - })); - } - } - catch (Exception ex) - { - LogManager.Info($"发车方法报错 >>> {ex.Message}"); - } - finally - { - transport.Close(); - transport.Dispose(); - } - } - /// /// 显示序号事件 /// /// @@ -281,132 +149,100 @@ namespace Khd.Core.Wpf.Form } public int i = 0; /// - /// 电气机柜信息面板定时器调用方法 + /// 查询任务 /// /// /// - private void PLCmessage(object sender, EventArgs e) + private void btnGetTask_Click(object sender, RoutedEventArgs e) { - try + GetTask(); + } + private void GetTask() + { + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + var equipCode = lba_ThrifTtitle1.Text; + var palletNo = lba_ThrifTtitle2.Text; + var data = dbContext.WcsTask.Where(t => t.useFlag == 1 && t.containerNo.Contains(palletNo) && t.equipmentNo.Contains(equipCode)).ToList(); + this.LoadMaterial0.ItemsSource = null; + this.LoadMaterial0.ItemsSource = data; + this.LoadMaterial0.Items.Refresh(); + if (data.Count == 0) { - if (i == 1000) - { - i = 0; - } - foreach (var item in basePlcpoints) - { - //通过名称找到TextBox - TextBox FoundTextBox = (TextBox)FindName(item.plcpointNo); - if (FoundTextBox == null) - { - continue; - } - string value = i.ToString(); - //string value = _plc.Read(item.plcpointAddress).ToString(); - //if (value.IsNullOrEmpty()) - //{ - // continue; - //} - //if (FoundTextBox.IsFocused == true) - //{ - // continue; - //} - FoundTextBox.Text = value; - i++; - LogManager.Info(i.ToString()); - } - - - } - catch (Exception ex) - { - LogManager.Info($"电气机柜信息面板定时器调用方法报错 >>> {ex.Message}"); + MessageBox.Show("未查询到数据"); } } - /// - /// PLC读取方法封装 - /// - /// plc地址位 - /// plc数据类型(int类型默认为1) - /// plc地址位长度(string类型默认为2) - /// 载具号文本输入框 - /// 载具到位文本输入框 - /// PLC车辆状态文本输入框 - /// 载具去向文本输入框 - /// WCS处理状态文本输入框 - private void ReadPlcData(string plcAddress, int plcDataType, string plcValueLength, - TextBox textBoxXcid, TextBox textBoxGjdw, TextBox textBoxClzt, - TextBox textBoxXcqx, TextBox textBoxWcsclzt) - { - try - { - // 载具号 - ReadAndSetText(plcAddress, textBoxXcid); - - // 载具到位 - //DQXX.plcpointAddress = $"DB4.DBW{GetOffset(plcAddress, 0)}"; - string gjdw = $"DB4.DBW{GetOffset(plcAddress, 0)}"; - ReadAndSetText(gjdw, textBoxGjdw); - - // PLC处理状态 - //DQXX.plcpointAddress = $"DB4.DBW{GetOffset(plcAddress, 2)}"; - string plcclzt = $"DB4.DBW{GetOffset(plcAddress, 2)}"; - ReadAndSetText(plcclzt, textBoxClzt); - - // 小车去向 - //DQXX.plcpointAddress = $"DB5.DBW{GetOffset(plcAddress, 0)}"; - string xcqx = $"DB5.DBW{GetOffset(plcAddress, 0)}"; - ReadAndSetText(xcqx, textBoxXcqx, textBoxXcqx.IsFocused); - - // WCS处理完成 - //DQXX.plcpointAddress = $"DB5.DBW{GetOffset(plcAddress, 2)}"; - string wcsclzt = $"DB5.DBW{GetOffset(plcAddress, 2)}"; - ReadAndSetText(wcsclzt, textBoxWcsclzt, textBoxWcsclzt.IsFocused); - //-------------------------------------------------------------------------以下为方法内部嵌套方法 - //嵌套方法1 - void ReadAndSetText(string dw, TextBox textBox, bool checkFocus = false) - { - string value = _plc.Read(dw).ToString(); - if (value != null && (!checkFocus || !textBox.IsFocused)) - { - textBox.Text = value; - } - } - //嵌套方法2 - int GetOffset(string PlcAddress, int baseOffset) - { - int result = int.Parse(PlcAddress.Substring(4, 1)) * 4 + baseOffset; - return result; - } - - } - catch (Exception ex) - { - LogManager.Info($"PLC读取方法封装报错 >>> {ex.Message}"); - } - - } - - /// - /// 订单导入按钮点击事件 + /// 删除任务 /// /// /// - private void btn_dingdandaoru_Click(object sender, RoutedEventArgs e) + private void btnDelTask_Click(object sender, RoutedEventArgs e) { - try + if (LoadMaterial0.SelectedIndex == -1) { - Application.Current.Dispatcher.Invoke(new Action( - delegate - { - // 设置 EPPlus 许可上下文 - ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "Excel Files|*.xls;*.xlsx"; - if (openFileDialog.ShowDialog() == true) - { - FileInfo fileInfo = new FileInfo(openFileDialog.FileName); + MessageBox.Show("请选择要删除的任务!"); + } + else + { + var Currentselected = LoadMaterial0.SelectedItem as WcsTask; + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + Currentselected.useFlag = 0; + dbContext.WcsTask.Update(Currentselected); + dbContext.SaveChanges(); + GetTask(); + } + } + /// + /// 完成任务 + /// + /// + /// + private void btnFinishTask_Click(object sender, RoutedEventArgs e) + { + if (LoadMaterial0.SelectedIndex == -1) + { + MessageBox.Show("请选择要完成的任务!"); + } + else + { + var Currentselected = LoadMaterial0.SelectedItem as WcsTask; + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + Currentselected.taskStatus = 5; + dbContext.WcsTask.Update(Currentselected); + dbContext.SaveChanges(); + GetTask(); + } + } + /// + /// 查询设备信息 + /// + /// + /// + private void btnGetEquip_Click(object sender, RoutedEventArgs e) + { + + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + var equipCode = lba_ThrifTtitle3.Text; + var data = dbContext.BaseEquip.Where(t => t.useFlag == 1 && t.equipNo.Contains(equipCode)).ToList(); + this.LoadMaterial3.ItemsSource = null; + this.LoadMaterial3.ItemsSource = data; + this.LoadMaterial3.Items.Refresh(); + if (data.Count == 0) + { + MessageBox.Show("未查询到数据"); + } + } + /// + /// 查询库存信息 + /// + /// + /// + private void btnGetStocK_Click(object sender, RoutedEventArgs e) + { using (ExcelPackage package = new ExcelPackage(fileInfo)) { @@ -422,12 +258,12 @@ namespace Khd.Core.Wpf.Form // 映射数据库字段,这里需要根据你的实际需求进行调整 var columnMappings = new Dictionary { - // 添加映射 - {columnHeaders[0],"production_sequence"}, - {columnHeaders[1],"line_code"}, - {columnHeaders[3],"prod_code"}, - {columnHeaders[4],"Quantity"}, - {columnHeaders[5],"order_code"} + // 添加映射 + {columnHeaders[0],"production_sequence"}, + {columnHeaders[1],"line_code"}, + {columnHeaders[3],"prod_code"}, + {columnHeaders[4],"Quantity"}, + {columnHeaders[5],"order_code"} }; int ordernum = 0; // 获取实际的行数和列数 @@ -486,158 +322,255 @@ namespace Khd.Core.Wpf.Form } catch (Exception ex) { - MessageBox.Show($"订单导入失败 >>> {ex.Message}", "订单导入操作提示!"); - LogManager.Info($"按钮订单导入事件报错 >>> {ex.Message}"); + MessageBox.Show("未查询到数据"); } } /// - /// 接收到载具号后,清空残留信息 + /// 删除指令 /// /// /// - private void CarNo_TextChanged(object sender, TextChangedEventArgs e) + private void btnDelCmd_Click(object sender, RoutedEventArgs e) { - //if (!string.IsNullOrWhiteSpace(this.tBoxMessage.Text) && this.tBoxMessage.Text.Length == 17) - //{ - // //清空缓存信息 - // this.CarNo.Clear(); - // this.tBoxMessage.Clear(); - // this.lba_ThrifTtitle.Text = string.Empty; - //} - } - /// - /// 订单清空按钮 - /// - /// - /// - private void btn_ClearOrder_Click(object sender, RoutedEventArgs e) - { - try + if (LoadMaterial.SelectedIndex == -1) { - var data = this.LoadMaterial.ItemsSource; - if (data == null) - { - MessageBox.Show($"当前订单信息为空,无需清空操作!", "订单手动清空提示!"); - return; - } - if (MessageBox.Show("确认是否清空当前预存订单?", - "订单手动清空提示", - MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) - { - using var scope = _host.Services.CreateScope(); - using var dbContext = scope.ServiceProvider.GetRequiredService(); - string sqlQuery = @"INSERT INTO - base_production_order_split_bak - (id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence) - SELECT - id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence - FROM base_production_order_split;"; - string sqlDelete = @"Delete - FROM - base_production_order_split;"; - var ret = dbContext.Database.ExecuteSqlRaw(sqlQuery); - dbContext.Database.ExecuteSqlRaw(sqlDelete); - string zhandianText = ThriftConfig.UpSite == "k46" ? "K46" : "K48"; - string saveLog = ret == 0 ? "清空后备份任务SQL执行失败!" : "清空后备份任务SQL语句执行成功!"; - if (ret != 0) MessageBox.Show($"{ret}条订单清空完毕!", "订单清空提示!"); - LogManager.Info($"手动清空任务日志记录 >>> 站点:{zhandianText}{saveLog}"); - this.LoadMaterial.ItemsSource = null; - //LoadMaterial_GetMessage(""); - } - } - catch (Exception ex) - { - LogManager.Info($"手动清空任务方法报错 >>> {ex.Message}"); - } - } - - private void Button_Click_1(object sender, RoutedEventArgs e) - { - try - { - // - } - catch (Exception ex) - { - MessageBox.Show("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex); - LogManager.Info("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex); - } - } - /// - /// 选择事件 - /// - /// - /// - private void MoHuChaXunWuLiaoName_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - timerjilu = sender; - ComboBox comboBox = (ComboBox)sender; - var shangjiandian = comboBox.SelectedItem; - string numberPart = Regex.Match(shangjiandian.ToString(), @"\d+").Value; - try - { - using var scope = _host.Services.CreateScope(); - using var dbContext = scope.ServiceProvider.GetRequiredService(); - // - } - catch (Exception ex) - { - MessageBox.Show("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex); - LogManager.Info("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex); - } - } - /// - /// 删除物料 - /// - /// - /// - private void Button_Click_2(object sender, RoutedEventArgs e) - { - if (LoadMaterial0.SelectedIndex == -1) - { - MessageBox.Show("请选择要删除的物料!"); + MessageBox.Show("请选择要删除的指令!"); } else { - var quere = MessageBox.Show("确定删除吗", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Asterisk); - // - + var Currentselected = LoadMaterial.SelectedItem as WcsCmd; + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + Currentselected.useFlag = 0; + dbContext.WcsCmd.Update(Currentselected); + dbContext.SaveChanges(); + GetWcsCmd(); } } /// - /// 刷新产线 + /// 重发指令 /// /// /// - private void Button_Click_3(object sender, RoutedEventArgs e) + private void btnReSendCmd_Click(object sender, RoutedEventArgs e) { - // + if (LoadMaterial.SelectedIndex == -1) + { + MessageBox.Show("请选择要重发的指令!"); + } + else + { + var Currentselected = LoadMaterial.SelectedItem as WcsCmd; + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + Currentselected.sendFlag = 0; + dbContext.WcsCmd.Update(Currentselected); + dbContext.SaveChanges(); + GetWcsCmd(); + } } /// - /// 物料选择事件 + /// 呼叫料箱 /// /// /// - private void shangjianwuliaocombox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - // - - } - - private void orderselect_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - } - - private void Button_Click(object sender, RoutedEventArgs e) + private void btnCallBox_Click(object sender, RoutedEventArgs e) { using var scope = _host.Services.CreateScope(); using var dbContext = scope.ServiceProvider.GetRequiredService(); - var data = dbContext.WcsTask.Where(t => t.useFlag == 0).ToList(); - this.LoadMaterial0.ItemsSource = null; - this.LoadMaterial0.ItemsSource = data; - this.LoadMaterial0.Items.Refresh(); - //MessageBox.Show("查询"); + + if (int.TryParse(txtNum.Text, out int num)) + { + //目的地 + var endEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault(); + //所有辅料库位 + var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t=> t.warehouseId== 5).ToList(); //五楼辅料库 + //有库存的库位 + var wmsStock = dbContext.WcsStock.Where(t => t.useFlag == 1).Select(t=>t.locationCode).ToList(); + var EmptyBox = wmsBaseLocation.Where(t => !t.locationCode.Contains(wmsStock)).ToList(); + + for (int i = 0; i < num; i++) + { + var wcsTask = new WcsTask() + { + objid = Global.SnowId.NextId(), + startPointId = EmptyBox[i].locationId, + startPointNo = EmptyBox[i].agvPositionCode, + currPointId = EmptyBox[i].locationId, + currPointNo = EmptyBox[i].agvPositionCode, + nextPointId = endEquip.objid, + nextPointNo = endEquip.equipNo, + endPointId = endEquip.objid, + endPointNo = endEquip.equipNo, + taskType = 13, + taskStatus = 0, + floorNo = 5, + containerNo = EmptyBox[i].containerCode, + equipmentNo = endEquip.equipNo, + createBy = "5楼呼叫料箱任务", + createTime = System.DateTime.Now, + }; + dbContext.Add(wcsTask); + dbContext.SaveChanges(); + } + } + else + { + MessageBox.Show("请输入有效的数字"); + } } + + /// + /// 料箱扫描 + /// + /// + /// + private void txtBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + txtBarCode.Focus(); + } + } + /// + /// 条码扫描 + /// + /// + /// + private void txtBarCode_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + var mesInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == txtBarCode.Text).FirstOrDefault(); + if (mesInfo == null) + { + MessageBox.Show("请扫描正确的条码"); + return; + } + barcodeinfo barcodeinfo = new barcodeinfo(); + barcodeinfo.barcode=txtBarCode.Text; + barcodeinfo.materialId = mesInfo.materialId; + barcodeinfo.qty = mesInfo.amount; + barcodeLsit.Add(barcodeinfo); + txtBarCode.SelectAll(); + txtBarCode.Focus(); + txtScan.Text = $"已扫描{barcodeLsit.Count}个"; + } + } + /// + /// 确认 + /// + /// + /// + private void btnConfirmBox_Click(object sender, RoutedEventArgs e) + { + var box = txtBox.Text; + if (string.IsNullOrEmpty(box)) + { + MessageBox.Show("容器号不能为空!"); + return; + } + if (barcodeLsit.Count==0) + { + MessageBox.Show("未扫描条码!"); + return; + } + using var scope = _host.Services.CreateScope(); + using var dbContext = scope.ServiceProvider.GetRequiredService(); + if (cbxType.Text == "入库") + { + //写入wms_raw_instock + var wmsRawInstock = new WmsRawInstock() + { + rawInstockId = Global.SnowId.NextId(), + warehouseId = 5, + operationType = "3", + instockType = "9", + materialId = barcodeLsit.FirstOrDefault().materialId, + palletInfoCode = txtBox.Text, + instockAmount = barcodeLsit.Sum(t=>t.qty), + executeStatus="0", + applyBy="扫描入库", + applyDate=System.DateTime.Now + }; + dbContext.WmsRawInstock.Add(wmsRawInstock); + dbContext.SaveChanges(); + var startEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault(); + var warehouse = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == 5).FirstOrDefault(); + //写入wcs任务 + var wcsTask = new WcsTask() + { + objid = Global.SnowId.NextId(), + startPointId = startEquip.objid, + startPointNo = startEquip.agvPositionCode, + currPointId = startEquip.objid, + currPointNo = startEquip.agvPositionCode, + nextPointId = warehouse.warehouseId, + nextPointNo = warehouse.warehouseCode, + endPointId = warehouse.warehouseId, + endPointNo = warehouse.warehouseCode, + taskType = 4, + taskStatus = 0, + floorNo = 5, + containerNo = txtBox.Text, + equipmentNo = startEquip.equipNo, + createBy = "5楼入库任务", + createTime = System.DateTime.Now, + }; + dbContext.Add(wcsTask); + dbContext.SaveChanges(); + } + if (cbxType.Text == "出库") + { + //从料箱里拿出来 + } + if (cbxType.Text == "回库") + { + //写入wms_raw_instock + var wmsRawInstock = new WmsRawInstock() + { + rawInstockId = Global.SnowId.NextId(), + warehouseId = 5, + operationType = "3", + instockType = "9", + materialId = barcodeLsit.FirstOrDefault().materialId, + palletInfoCode = txtBox.Text, + instockAmount = barcodeLsit.Sum(t => t.qty), + executeStatus = "0", + applyBy = "扫描回库", + applyDate = System.DateTime.Now + }; + dbContext.WmsRawInstock.Add(wmsRawInstock); + dbContext.SaveChanges(); + var startEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault(); + var warehouse = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == 5).FirstOrDefault(); + //写入wcs任务 + var wcsTask = new WcsTask() + { + objid = Global.SnowId.NextId(), + startPointId = startEquip.objid, + startPointNo = startEquip.agvPositionCode, + currPointId = startEquip.objid, + currPointNo = startEquip.agvPositionCode, + nextPointId = warehouse.warehouseId, + nextPointNo = warehouse.warehouseCode, + endPointId = warehouse.warehouseId, + endPointNo = warehouse.warehouseCode, + taskType = 4, + taskStatus = 0, + floorNo = 5, + containerNo = txtBox.Text, + equipmentNo = startEquip.equipNo, + createBy = "5楼回库任务", + createTime = System.DateTime.Now, + }; + dbContext.Add(wcsTask); + dbContext.SaveChanges(); + } + } + } diff --git a/src/Khd.Core.Wpf/Global/PlcConfig.cs b/src/Khd.Core.Wpf/Global/PlcConfig.cs index af9dcdf..7d63cd7 100644 --- a/src/Khd.Core.Wpf/Global/PlcConfig.cs +++ b/src/Khd.Core.Wpf/Global/PlcConfig.cs @@ -1,4 +1,6 @@ -namespace Khd.Core.Wpf +using Jc.SnowId; + +namespace Khd.Core.Wpf { public static class PlcConfig { @@ -31,4 +33,9 @@ /// public static int UpFlagNum { get; set; } } + public static class Global + { + public static JcSnowId SnowId = new JcSnowId(); +} + } diff --git a/src/Khd.Core.Wpf/Khd.Core.Wpf.csproj b/src/Khd.Core.Wpf/Khd.Core.Wpf.csproj index 4d6bbb3..69c62cc 100644 --- a/src/Khd.Core.Wpf/Khd.Core.Wpf.csproj +++ b/src/Khd.Core.Wpf/Khd.Core.Wpf.csproj @@ -140,6 +140,7 @@ + @@ -472,4 +473,5 @@ PreserveNewest + diff --git a/src/Khd.Core.Wpf/LoginPage.xaml.cs b/src/Khd.Core.Wpf/LoginPage.xaml.cs index 7c1c618..884cbd9 100644 --- a/src/Khd.Core.Wpf/LoginPage.xaml.cs +++ b/src/Khd.Core.Wpf/LoginPage.xaml.cs @@ -21,13 +21,8 @@ namespace Khd.Core.Wpf { InitializeComponent(); this.Hide(); - //IHost host = CreateHostBuilder(null).Build(); - //_host = host; - //FormBoard mainWindow = new FormBoard(_host); - //mainWindow.Show(); // 通过进程名称查找进程 bool ret; - string upsite = ThriftConfig.UpSite == "k48" ? "K48" : "K46"; System.Threading.Mutex mutex = new System.Threading.Mutex(true, $"Khd.Core.Wpf", out ret); if (ret) { @@ -79,8 +74,6 @@ namespace Khd.Core.Wpf Host.CreateDefaultBuilder(args) .ConfigureServices((_, services) => { - //services.AddDbContext(options => - // options.UseSqlServer(ConnectionStrings.ConnectionString)); services.AddDbContext(options => options.UseMySql(ConnectionStrings.ConnectionString, new MySqlServerVersion(new Version(8, 0, 31)))); }); diff --git a/src/Khd.Core.Wpf/appsettings.json b/src/Khd.Core.Wpf/appsettings.json index ea9158a..f3f558f 100644 --- a/src/Khd.Core.Wpf/appsettings.json +++ b/src/Khd.Core.Wpf/appsettings.json @@ -4,8 +4,7 @@ //"DefaultConnection": "server=106.12.13.113;port=3306;database=khd_jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True" //khd服务器 "DefaultConnection": "server=106.12.13.113;port=3336;database=khd_jyhb;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True" - //雅迪数据库 - //"DefaultConnection": "server=localhost;port=3306;database=khd_suspension_chain;uid=root;pwd=123456;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True" + }, "PlcConfig": { "IP": "127.0.0.1",