@ -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 )