@ -127,7 +127,6 @@ namespace Khd.Core.Wpf.Form
/// <param name="e"></param>
private void FormBoard_Loaded ( object sender , RoutedEventArgs e )
{
CheckVersion ( ) ;
InitializeData ( 1 ) ;
this . WareHouseId . ItemsSource = new List < string >
{
@ -135,6 +134,10 @@ namespace Khd.Core.Wpf.Form
} ;
this . WarehourseId . Items . Refresh ( ) ;
this . WareHouseId . SelectedIndex = 0 ;
if ( SystemData . NeedLogin )
{
//对MenuList重新赋值
}
foreach ( var item in this . TabControl . Items )
{
if ( item is TabItem tabItem )
@ -151,6 +154,7 @@ namespace Khd.Core.Wpf.Form
}
}
QueryPositionCombox . SelectedIndex = 0 ; // 设置默认选择为 "南侧"
try
{
itemsControlItems = new ObservableCollection < SelectItemModel > ( ) ;
@ -334,13 +338,12 @@ namespace Khd.Core.Wpf.Form
HandyControl . Controls . MessageBox . Error ( ex . Message ) ;
}
}
/// <summary>
/// 检查版本
/// </summary>
p rivate void CheckVersion ( )
p ublic static void CheckVersion ( )
{
try
{
@ -461,7 +464,7 @@ namespace Khd.Core.Wpf.Form
List < WmsRawReturn > wmsRawReturns = dbContext . WmsRawReturn . Where ( t = > endStationCodes . Contains ( t . endStationCode ) )
. Where ( t = > t . auditStatus = = "1" )
. Where ( t = > t . executeStatus = = "0" | | t . executeStatus = = "1" )
. Where ( t = > t . returnAmount > t . pla nAmount)
. Where ( t = > t . planAmount > t . retur nAmount)
. ToList ( ) ;
List < string > list = wmsRawReturns . Select ( t = > t . endStationCode ) . ToList ( ) ;
List < long? > orderIds = wmsRawReturns . Select ( t = > t . rawReturnId ) . ToList ( ) ;
@ -719,6 +722,7 @@ namespace Khd.Core.Wpf.Form
this . OutTaskNumber . Items . Refresh ( ) ;
} ) ;
}
GetTask ( ) ;
}
catch
{
@ -821,7 +825,7 @@ namespace Khd.Core.Wpf.Form
this . OneOut . IsEnabled = true ;
this . SomeOut . IsEnabled = true ;
}
this . EmptyEquip . ItemsSource = SystemData . BaseEquip . Where ( t = > t . equipType = = 20 | | t . equipType = = 21 | | t . equipType = = 19) . Select (
this . EmptyEquip . ItemsSource = SystemData . BaseEquip . Where ( t = > t . equipType = = 20 | | t . equipType = = 19) . Select (
t = > new BaseEquip
{
objid = t . objid ,
@ -831,10 +835,11 @@ namespace Khd.Core.Wpf.Form
ud3 = t . ud3 = = "0" ? "空" : t . ud3 = = "1" ? "托盘" : t . ud3 = = "2" ? "废料" : "未知" ,
equipNo = t . equipNo ,
floorNo = t . floorNo ,
containerNo = t . containerNo
containerNo = t . containerNo ,
}
) . OrderBy ( t = > t . equipNo ) ;
this . EmptyEquip . Items . Refresh ( ) ;
GetTask ( ) ;
} ) ;
}
}
@ -947,38 +952,37 @@ namespace Khd.Core.Wpf.Form
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
var equipCode = lba_ThrifTtitle1 . Text ;
var palletNo = lba_ThrifTtitle2 . Text ;
long? nextPointId = 0 ;
if ( this . EquipListSelectDy . SelectedItem is BaseEquip baseEquip )
Dispatcher . Invoke ( ( ) = >
{
nextPointId = baseEquip . objid ;
}
var data = dbContext . WcsTask
. WhereIf ( nextPointId ! = 0 , t = > t . nextPointId = = nextPointId )
. Where ( t = > t . IsDelete ! = 1 )
. Where ( t = > t . containerNo . Contains ( palletNo ) & & t . equipmentNo . Contains ( equipCode ) ) . ToList ( ) ;
List < taskModel > taskModel = CoreMapper . Map < List < taskModel > > ( data ) ;
SelectedItem . Clear ( ) ;
foreach ( var item in taskModel )
{
SelectedItem . Add ( item . objid , false ) ;
if ( item . nextPointId = = 6 )
var equipCode = lba_ThrifTtitle1 . Text ;
var palletNo = lba_ThrifTtitle2 . Text ;
long? nextPointId = 0 ;
if ( this . EquipListSelectDy . SelectedItem is BaseEquip baseEquip )
{
item. isShow = Visibility . Visible ;
nextPointId = baseEquip . objid ;
}
else
var data = dbContext . WcsTask
. WhereIf ( nextPointId ! = 0 , t = > t . nextPointId = = nextPointId )
. Where ( t = > t . IsDelete ! = 1 )
. Where ( t = > t . containerNo . Contains ( palletNo ) & & t . equipmentNo . Contains ( equipCode ) ) . ToList ( ) ;
List < taskModel > taskModel = CoreMapper . Map < List < taskModel > > ( data ) ;
SelectedItem . Clear ( ) ;
foreach ( var item in taskModel )
{
item . isShow = Visibility . Collapsed ;
SelectedItem . Add ( item . objid , false ) ;
if ( item . nextPointId = = 6 )
{
item . isShow = Visibility . Visible ;
}
else
{
item . isShow = Visibility . Collapsed ;
}
}
}
this . LoadMaterial0 . ItemsSource = null ;
this . LoadMaterial0 . ItemsSource = taskModel ;
this . LoadMaterial0 . Items . Refresh ( ) ;
//if (data.Count == 0)
//{
// HandyControl.Controls.MessageBox.Show("未查询到数据");
//}
this . LoadMaterial0 . ItemsSource = null ;
this . LoadMaterial0 . ItemsSource = taskModel ;
this . LoadMaterial0 . Items . Refresh ( ) ;
} ) ;
}
/// <summary>
/// 删除任务
@ -1488,6 +1492,17 @@ namespace Khd.Core.Wpf.Form
{
if ( HandyControl . Controls . MessageBox . Show ( "是否确认关闭程序" , "提示信息" , MessageBoxButton . YesNo , MessageBoxImage . Information ) = = MessageBoxResult . Yes )
{
System . Diagnostics . Process p = new System . Diagnostics . Process ( ) ;
p . StartInfo . FileName = "cmd.exe" ;
p . StartInfo . UseShellExecute = false ; //是否使用操作系统shell启动
p . StartInfo . RedirectStandardInput = true ; //接受来自调用程序的输入信息
p . StartInfo . RedirectStandardOutput = true ; //由调用程序获取输出信息
p . StartInfo . RedirectStandardError = true ; //重定向标准错误输出
p . StartInfo . CreateNoWindow = true ; //不显示程序窗口
p . Start ( ) ; //启动程序
//向cmd窗口发送输入信息
p . StandardInput . WriteLine ( "taskkill /f /im Khd.Core.Wpf" + "&exit" ) ;
Application . Current . Shutdown ( ) ;
System . Environment . Exit ( System . Environment . ExitCode ) ;
}
@ -2256,43 +2271,58 @@ namespace Khd.Core.Wpf.Form
{
try
{
if ( ! string . IsNullOrEmpty ( txt I nBox. Text ) & & ! string . IsNullOrEmpty ( txt I nBarCode. Text ) )
if ( ! string . IsNullOrEmpty ( txt Retur nBox. Text ) & & ! string . IsNullOrEmpty ( txt Retur nBarCode. Text ) )
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
WmsRawReturn ? wmsRawReturn = dbContext . WmsRawReturn . Where ( t = > t . executeStatus = = "1" ) . FirstOrDefault ( ) ;
if ( wmsRawReturn = = null )
BaseEquip baseEquip = SystemData . BaseEquip . First ( t = > t . objid = = 10 ) ;
WcsTask ? task = dbContext . WcsTask . Where ( t = > t . nextPointId = = baseEquip . objid ) . FirstOrDefault ( ) ;
if ( task = = null )
{
HandyControl. Controls . MessageBox . Show ( "未查询到退库任务!" ) ;
txtReturnbox. Text = ( "未查询到退库任务!" ) ;
return ;
}
var material = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = txtInBarCode . Text ) ;
var container = dbContext . WmsBaseLocation . FirstOrDefault ( t = > t . containerCode = = txtInBox . Text & & t . warehouseId = = 512 ) ;
var material = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = txtReturnBarCode . Text ) ;
if ( material = = null )
{
txtReturnbox . Text = ( "未查询到该条码内容!" ) ;
txtReturnBarCode . Text = string . Empty ;
txtReturnBarCode . Focus ( ) ;
return ;
}
WmsRawReturn ? wmsRawReturn = dbContext . WmsRawReturn
. Where ( t = > t . rawReturnId = = task . orderId ) . FirstOrDefault ( ) ;
if ( wmsRawReturn = = null )
{
txtReturnbox . Text = ( "未查询到退库任务!" ) ;
return ;
}
var container = dbContext . WmsBaseLocation . FirstOrDefault ( t = > t . containerCode = = txtReturnBox . Text & & t . warehouseId = = 512 ) ;
List < WmsRawStock > wmsRawStocks = dbContext . WmsRawStock
. Where ( t = > txtInBarCode . Text = = t . instockBatch )
. Where ( t = > txt Retur nBarCode. Text = = t . instockBatch )
. Where ( t = > t . warehouseFloor = = 5 & & t . warehouseId = = 512 ) . ToList ( ) ;
if ( wmsRawStocks . Count > 0 & & material . batchFlag ! = "1" )
{
HandyControl . Controls . MessageBox . Info ( $"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}" ) ;
txtInBarCode . Text = string . Empty ;
txtInScan . Text = string . Empty ;
txtReturnbox. Text = ( $"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}" ) ;
txt Retur nBarCode. Text = string . Empty ;
txt ReturnBox . Text = string . Empty ;
return ;
}
if ( container = = null )
{
HandyControl . Controls . MessageBox . Error ( "未查询到该容器!" ) ;
txtInBox . Text = string . Empty ;
txtReturnbox. Text = ( "未查询到该容器!" ) ;
txt Retur nBox. Text = string . Empty ;
return ;
}
if ( material = = null )
decimal amount = 0 ;
try
{
HandyControl . Controls . MessageBox . Error ( "未查询到该条码内容!" ) ;
txtInBarCode . Text = string . Empty ;
txtInScan . Text = string . Empty ;
return ;
amount = decimal . Parse ( txtReturnScan . Text ) ;
}
catch
{
txtReturnbox . Text = ( "请输入正确的数量" ) ;
}
decimal amount = decimal . Parse ( txtInScan . Text ) ;
wmsRawReturn . returnAmount + = amount ;
if ( wmsRawReturn . returnAmount > = wmsRawReturn . planAmount )
{
@ -2353,20 +2383,20 @@ namespace Khd.Core.Wpf.Form
}
dbContext . SaveChanges ( ) ;
HandyControl. Controls . MessageBox . Success ( "入 库成功!") ;
txt I nBarCode. Text = string . Empty ;
txt InScan . Text = string . Empty ;
txt I nBarCode. Focus ( ) ;
txtReturnbox. Text = ( "退 库成功!") ;
txt Retur nBarCode. Text = string . Empty ;
txt ReturnBox . Text = string . Empty ;
txt Retur nBarCode. Focus ( ) ;
}
else
{
HandyControl. Controls . MessageBox . Info ( "请先扫描容器号和条码!" ) ;
txtReturnbox. Text = ( "请先扫描容器号和条码!" ) ;
}
}
catch ( Exception ex )
{
LogManager . Error ( ex ) ;
HandyControl. Controls . MessageBox . Error ( "入库失败" ) ;
txtReturnbox. Text = ( "入库失败" ) ;
}
}
/// <summary>
@ -2511,6 +2541,7 @@ namespace Khd.Core.Wpf.Form
{
try
{
txtReturnbox . Text = "" ;
string barCode = txtReturnBarCode . Text ;
if ( barCode . Length < 19 ) return ;
@ -2533,14 +2564,15 @@ namespace Khd.Core.Wpf.Form
{
txtReturnBarCode . Text = string . Empty ;
txtReturnScan . Text = string . Empty ;
txtReturnbox . Text = "未查询到该条码绑定的物料信息!" ;
txtReturnBarCode . Focus ( ) ;
}
else
{
txtReturnScan . Text = ( material . batchFlag = = "1" ) ? "" : "1.00" ;
this . returnGG . Text = mesBaseMaterialInfo . MaterialSpec ;
this . returnMaterialName . Text = mesBaseMaterialInfo . MaterialName ;
if ( mesBaseMaterialInfo . BatchFlag = = "0" )
{
txtReturnScan . IsReadOnly = true ;
@ -2712,10 +2744,19 @@ namespace Khd.Core.Wpf.Form
var mesBaseBarcodeInfo = dbContext . MesBaseBarcodeInfo . FirstOrDefault ( t = > t . barcodeInfo = = txtOutBarCode . Text ) ;
if ( mesBaseBarcodeInfo ! = null )
{
var list = JsonConvert . DeserializeObject < List < string > > ( baseEquip . endStationCode ) ;
var wmsRawOutstocks = dbContext . WmsRawOutstock
. Where ( t = > t . materialId = = mesBaseBarcodeInfo . materialId & & t . realOutstockAmount < t . outstockAmount & & t . saleOrderId = = ( mesBaseBarcodeInfo . saleOrderId = = null ? 0 : mesBaseBarcodeInfo . saleOrderId ) & & baseEquip . endStationCode . Contains ( t . endStationCode ) )
. ToList ( ) ;
var wmsRawOutstocks = new List < WmsRawOutstock > ( ) ;
List < string > list = new List < string > ( ) ;
try
{
list = JsonConvert . DeserializeObject < List < string > > ( baseEquip . endStationCode ) ;
wmsRawOutstocks = dbContext . WmsRawOutstock
. Where ( t = > t . materialId = = mesBaseBarcodeInfo . materialId & & t . realOutstockAmount < t . outstockAmount & & t . saleOrderId = = ( mesBaseBarcodeInfo . saleOrderId = = null ? 0 : mesBaseBarcodeInfo . saleOrderId ) & & baseEquip . endStationCode . Contains ( t . endStationCode ) )
. ToList ( ) ;
}
catch
{
}
if ( wmsRawOutstocks . Count > 0 )
{
int index = 0 ;
@ -2782,7 +2823,8 @@ namespace Khd.Core.Wpf.Form
outstockPerson = "WCS" ,
outstockTime = DateTime . Now ,
outstockWay = "2" ,
materialProductionDate = mesBaseBarcodeInfo . productionDate
materialProductionDate = mesBaseBarcodeInfo . productionDate ,
Tips = this . remarks . Text
} ;
dbContext . Add ( wmsProductOutstockDetail ) ;
dbContext . Update ( item ) ;
@ -2874,6 +2916,13 @@ namespace Khd.Core.Wpf.Form
return ;
}
}
scanOutMsg . Text = "出库成功!" ;
txtOutScan . Text = string . Empty ;
txtOutBarCode . Text = string . Empty ;
outMaterialSpecTxt . Text = string . Empty ;
outMaterialNameTxt . Text = string . Empty ;
txtOutBox . Text = string . Empty ;
txtOutBox . Focus ( ) ;
}
}
else
@ -4366,7 +4415,7 @@ namespace Khd.Core.Wpf.Form
}
else
{
var endEquip = dbContext . BaseEquip . FirstOrDefault ( t = > t . equipType = = 20 & & t . equipStatus = = 0 & & t . emptyCount = = 0 ) ;
var endEquip = dbContext . BaseEquip . FirstOrDefault ( t = > t . equipType = = 20 & & t . equipStatus = = 0 & & t . emptyCount = = 0 & & t . useFlag = = 1 ) ;
if ( endEquip = = null )
{
HandyControl . Controls . MessageBox . Show ( "没有空箱库位!" ) ;
@ -4420,7 +4469,7 @@ namespace Khd.Core.Wpf.Form
}
else
{
var startEquip = dbContext . BaseEquip . FirstOrDefault ( t = > t . equipType = = 20 & & t . equipStatus = = 1 & & t . emptyCount = = 1 ) ;
var startEquip = dbContext . BaseEquip . FirstOrDefault ( t = > t . equipType = = 20 & & t . equipStatus = = 1 & & t . emptyCount = = 1 & & t . useFlag = = 1 ) ;
if ( startEquip = = null )
{
BaseEquip firstEmptyEquip = dbContext . BaseEquip . First ( t = > t . objid = = 40 ) ;
@ -5319,6 +5368,9 @@ namespace Khd.Core.Wpf.Form
{
try
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
var baseEquips = dbContext . BaseEquip . Where ( t = > t . equipType = = 20 ) . OrderBy ( t = > t . agvPositionCode ) . ToList ( ) ;
foreach ( var item in this . LocaltionGrid . Children )
{
if ( item is Grid grid )
@ -5332,6 +5384,15 @@ namespace Khd.Core.Wpf.Form
{
button . Background = string . IsNullOrEmpty ( location . containerCode ) ? new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#4789AE" ) ) : new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#75F76D" ) ) ;
}
else
{
BaseEquip ? baseEquip = baseEquips . Where ( t = > t . agvPositionCode = = button . Name ) . FirstOrDefault ( ) ;
if ( baseEquip ! = null )
{
button . Content = baseEquip . agvPositionCode + $"({baseEquip.emptyCount})" ;
button . Background = baseEquip . emptyCount > 0 ? new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#75F76D" ) ) : new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#4789AE" ) ) ;
}
}
}
}
}
@ -5386,6 +5447,19 @@ namespace Khd.Core.Wpf.Form
{
return ;
}
List < BaseEquip > baseEquips = new List < BaseEquip > ( ) ;
if ( wmsBaseLocations . First ( ) . warehouseFloor = = 2 )
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
baseEquips = dbContext . BaseEquip . Where ( t = > t . equipType = = 20 ) . OrderBy ( t = > t . agvPositionCode ) . ToList ( ) ;
}
else if ( wmsBaseLocations . First ( ) . warehouseFloor = = 3 )
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
baseEquips = dbContext . BaseEquip . Where ( t = > t . equipType = = 15 ) . OrderBy ( t = > t . agvPositionCode ) . ToList ( ) ;
}
Dispatcher . Invoke ( ( ) = >
{
this . LocaltionGrid . Children . Clear ( ) ;
@ -5393,6 +5467,7 @@ namespace Khd.Core.Wpf.Form
this . LocaltionGrid . ColumnDefinitions . Clear ( ) ;
List < long > list = wmsBaseLocations . Select ( t = > t . warehouseId ) . Distinct ( ) . ToList ( ) ;
int? column = 0 ;
for ( var i = 0 ; i < list . Count ; i + + )
{
this . LocaltionGrid . RowDefinitions . Add ( new RowDefinition ( ) { Height = new GridLength ( 1.0 , GridUnitType . Star ) } ) ;
@ -5400,7 +5475,11 @@ namespace Khd.Core.Wpf.Form
List < WmsBaseLocation > locations = wmsBaseLocations . Where ( t = > t . warehouseId = = list [ i ] ) . ToList ( ) ;
var row = locations . Max ( t = > t . locRow ) ;
column = locations . Max ( t = > t . locColumn ) ;
if ( list [ 0 ] = = 231 & & i = = 0 )
{
grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = new GridLength ( 1.0 , GridUnitType . Star ) } ) ;
grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = new GridLength ( 1.0 , GridUnitType . Star ) } ) ;
}
for ( var j = 0 ; j < row ; j + + )
{
grid . RowDefinitions . Add ( new RowDefinition ( ) { Height = new GridLength ( 1.0 , GridUnitType . Star ) } ) ;
@ -5423,7 +5502,51 @@ namespace Khd.Core.Wpf.Form
} ;
button . Click + = OnLocationButton_Click ;
Grid . SetColumn ( button , location . locColumn . Value - 1 ) ;
Grid . SetRow ( button , - ( location . locRow . Value - row . Value ) ) ;
if ( list [ 0 ] = = 231 )
{
Grid . SetRow ( button , - ( location . locRow . Value - row . Value ) + 2 ) ;
for ( var k = 0 ; k < 8 ; k + + )
{
var button2 = new Button ( )
{
Content = baseEquips [ k ] . agvPositionCode + $"({baseEquips[k].emptyCount})" ,
Name = baseEquips [ k ] . agvPositionCode ,
Width = 100 ,
Height = 50 ,
FontSize = 15 ,
Margin = new Thickness ( 2 ) ,
Background = baseEquips [ k ] . emptyCount > 0 ? new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#75F76D" ) ) : new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#4789AE" ) ) ,
} ;
Grid . SetColumn ( button2 , k % 4 * 2 + 1 ) ;
Grid . SetRow ( button2 , - ( ( k / 4 ) - 1 ) ) ;
Grid . SetColumnSpan ( button2 , 2 ) ;
grid . Children . Add ( button2 ) ;
}
}
else
{
Grid . SetRow ( button , - ( location . locRow . Value - row . Value ) ) ;
if ( list [ 0 ] = = 311 )
{
for ( var k = 0 ; k < 3 ; k + + )
{
var button2 = new Button ( )
{
Content = baseEquips [ k ] . agvPositionCode + $"({baseEquips[k].emptyCount})" ,
Name = baseEquips [ k ] . agvPositionCode ,
Width = 100 ,
Height = 50 ,
FontSize = 15 ,
Margin = new Thickness ( 2 ) ,
Background = baseEquips [ k ] . emptyCount > 0 ? new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#75F76D" ) ) : new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#4789AE" ) ) ,
} ;
Grid . SetColumn ( button2 , k % 4 * 2 + 17 ) ;
Grid . SetRow ( button2 , - ( ( k / 4 ) - 1 ) ) ;
Grid . SetColumnSpan ( button2 , 2 ) ;
grid . Children . Add ( button2 ) ;
}
}
}
grid . Children . Add ( button ) ;
}
Grid . SetRow ( grid , i ) ;
@ -5520,6 +5643,7 @@ namespace Khd.Core.Wpf.Form
dbContext . SaveChanges ( ) ;
}
}
}
}