change-修改人工叫料界面

master
liuwf 1 year ago
parent 4d54a86f48
commit babc9cfdbf

@ -1576,6 +1576,7 @@
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0"> <Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
@ -1586,8 +1587,25 @@
<Button Content="出选择料箱" HorizontalAlignment="Right" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="CallTrayBtn_Click"/> <Button Content="出选择料箱" HorizontalAlignment="Right" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="CallTrayBtn_Click"/>
</StackPanel> </StackPanel>
</Border> </Border>
<Border Grid.Row="1" Height="50" Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0"> <Border Grid.Row="1" Height="100" Background="#213269" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0">
<ItemsControl x:Name="itemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
<!-- 使项自动换行 -->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" Padding="5">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding palletInfoCode}" VerticalAlignment="Center"/>
<Button Content="删除" FontSize="15" Width="50" Background="LightSkyBlue" Foreground="Red" Margin="0,0,10,0" Click="DeleteButton_Click" Tag="{Binding}"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border> </Border>
<DataGrid <DataGrid
Style="{StaticResource DataGridStyle}" Style="{StaticResource DataGridStyle}"
@ -1746,7 +1764,7 @@
</Style> </Style>
</DataGrid.ColumnHeaderStyle> </DataGrid.ColumnHeaderStyle>
</DataGrid> </DataGrid>
<hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" /> <hc:Pagination x:Name="Pagination2" Grid.Row="3" Height="50" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Visibility="Collapsed" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5"> <TabItem Visibility="Collapsed" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
@ -1903,7 +1921,7 @@
</Style> </Style>
</DataGrid.ColumnHeaderStyle> </DataGrid.ColumnHeaderStyle>
</DataGrid> </DataGrid>
<hc:Pagination x:Name="Pagination3" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination3_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" /> <hc:Pagination x:Name="Pagination3" Grid.Row="3" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination3_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem x:Name="ScanInManager" Header="扫描入库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5"> <TabItem x:Name="ScanInManager" Header="扫描入库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">

@ -18,6 +18,7 @@ using Microsoft.Extensions.Hosting;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.IO.Ports; using System.IO.Ports;
@ -60,6 +61,20 @@ namespace Khd.Core.Wpf.Form
private int pageCount = 15; private int pageCount = 15;
private object updateLock = new object(); private object updateLock = new object();
private ObservableCollection<SelectItemModel> itemsControlItems;
//人工叫料选中类
public class SelectItemModel
{
//料箱位置id
public long baseLocationId { get; set; }
//托盘号
public string palletInfoCode { get; set; }
}
private void ScanMessage() private void ScanMessage()
{ {
while (true) while (true)
@ -107,6 +122,10 @@ namespace Khd.Core.Wpf.Form
{ {
try try
{ {
itemsControlItems = new ObservableCollection<SelectItemModel>();
itemsControl.ItemsSource = itemsControlItems;
//连接PLC //连接PLC
Task.Run(() => Task.Run(() =>
{ {
@ -1312,17 +1331,69 @@ namespace Khd.Core.Wpf.Form
/// <param name="e"></param> /// <param name="e"></param>
private void CheckPersonBox_Click(object sender, RoutedEventArgs e) private void CheckPersonBox_Click(object sender, RoutedEventArgs e)
{ {
if (sender is CheckBox checkbox) if (sender is CheckBox checkbox)
{ {
dynamic Currentselected = PersonCallMaterial.SelectedItem; dynamic Currentselected = PersonCallMaterial.SelectedItem;
if (checkbox.IsChecked != null && checkbox.IsChecked.Value) if (checkbox.IsChecked != null && checkbox.IsChecked.Value)
{ {
if(itemsControlItems!=null && itemsControlItems.Count >= 6)
{
MessageBox.Show("最多只能选择6个");
checkbox.IsChecked = false;
return;
}
CallSelectedItem.Add(Currentselected.baseLocationId); CallSelectedItem.Add(Currentselected.baseLocationId);
// 添加选中项
string selectedItem = Currentselected.palletInfoCode;
bool isIn = itemsControlItems.Any(t => t.baseLocationId == Currentselected.baseLocationId);
if (!isIn)
{
itemsControlItems.Add(new SelectItemModel {
baseLocationId = Currentselected.baseLocationId,
palletInfoCode = Currentselected.palletInfoCode
});
}
} }
else else
{ {
CallSelectedItem.Remove(Currentselected.baseLocationId); CallSelectedItem.Remove(Currentselected.baseLocationId);
// 删除选中项
SelectItemModel model = itemsControlItems.FirstOrDefault(x => x.baseLocationId == Currentselected.baseLocationId);
if (model != null)
{
itemsControlItems.Remove(model);
}
} }
}
}
/// <summary>
/// 删除选中的值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
// 获取点击按钮的实例
Button button = sender as Button;
// 从按钮的 Tag 属性中获取当前数据项
SelectItemModel itemToRemove = button.Tag as SelectItemModel;
if (itemToRemove != null)
{
// 从集合中移除数据项
itemsControlItems.Remove(itemToRemove);
} }
} }
/// <summary> /// <summary>
@ -2018,6 +2089,8 @@ namespace Khd.Core.Wpf.Form
/// <param name="e"></param> /// <param name="e"></param>
private void SelectButton_Click(object sender, RoutedEventArgs e) private void SelectButton_Click(object sender, RoutedEventArgs e)
{ {
CallSelectedItem.Clear(); CallSelectedItem.Clear();
GetPersonCallMaterialData(); GetPersonCallMaterialData();
} }
@ -2026,6 +2099,8 @@ namespace Khd.Core.Wpf.Form
/// </summary> /// </summary>
private void GetPersonCallMaterialData() private void GetPersonCallMaterialData()
{ {
try try
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
@ -2078,6 +2153,7 @@ namespace Khd.Core.Wpf.Form
if (string.IsNullOrEmpty(MaterialName.Text)) if (string.IsNullOrEmpty(MaterialName.Text))
{ {
materialInfos = dbContext.MesBaseMaterialInfo.ToList(); materialInfos = dbContext.MesBaseMaterialInfo.ToList();
} }
var bill = from a in wmsBaseLocations var bill = from a in wmsBaseLocations
from b in groupWmsRawStock from b in groupWmsRawStock
@ -2114,6 +2190,10 @@ namespace Khd.Core.Wpf.Form
materialSpec = string.Join("\n", t.Select(x => x.materialSpec[..(x.materialSpec.Length > 20 ? 20 : x.materialSpec.Length)])), materialSpec = string.Join("\n", t.Select(x => x.materialSpec[..(x.materialSpec.Length > 20 ? 20 : x.materialSpec.Length)])),
materialSpecSrc = string.Join("\n", t.Select(x => x.materialSpec)) materialSpecSrc = string.Join("\n", t.Select(x => x.materialSpec))
}).ToList(); }).ToList();
bills = bills.OrderBy(t => t.palletInfoCode).ThenBy(t => t.materialId).ToList(); bills = bills.OrderBy(t => t.palletInfoCode).ThenBy(t => t.materialId).ToList();
PersonCallMaterial.ItemsSource = bills.Skip((this.Pagination2.PageIndex - 1) * this.pageCount).Take(this.pageCount); PersonCallMaterial.ItemsSource = bills.Skip((this.Pagination2.PageIndex - 1) * this.pageCount).Take(this.pageCount);
int sum = bills.Count(); int sum = bills.Count();
@ -2390,7 +2470,12 @@ namespace Khd.Core.Wpf.Form
{ {
BaseEquip ctuEquip = SystemData.BaseEquip.First(t => t.objid == 11); BaseEquip ctuEquip = SystemData.BaseEquip.First(t => t.objid == 11);
BaseEquip endEquip = SystemData.BaseEquip.First(t => t.objid == 20); BaseEquip endEquip = SystemData.BaseEquip.First(t => t.objid == 20);
if (CallSelectedItem.Count == 0) //if (CallSelectedItem.Count == 0)
//{ 替换
// MessageBox.Show("请选择料箱!");
// return;
//}
if (itemsControlItems.Count == 0)
{ {
MessageBox.Show("请选择料箱!"); MessageBox.Show("请选择料箱!");
return; return;
@ -2404,7 +2489,12 @@ namespace Khd.Core.Wpf.Form
// MessageBox.Show($"当前CTU只能有6个任务,当前任务数{taskCount}"); // MessageBox.Show($"当前CTU只能有6个任务,当前任务数{taskCount}");
// return; // return;
//} //}
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1").Where(t => CallSelectedItem.Contains(t.locationId)).ToList();
//替换 var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1").Where(t => CallSelectedItem.Contains(t.locationId)).ToList();
List<long> idList = itemsControlItems.Select(x => x.baseLocationId).ToList();
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1").Where(t => idList.Contains(t.locationId)).ToList();
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("确认出库:"); stringBuilder.AppendLine("确认出库:");
foreach (var item in wmsBaseLocation) foreach (var item in wmsBaseLocation)

@ -5,8 +5,10 @@
//khd //khd
"DefaultConnection": "server=172.16.12.100;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khdrkjy2024...;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True" "DefaultConnection": "server=172.16.12.100;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khdrkjy2024...;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
//"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=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=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8mb4';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
//"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True" //"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
}, },
"PlcConfigs": [ "PlcConfigs": [
{ {
"IP": "192.168.2.30", "IP": "192.168.2.30",

Loading…
Cancel
Save