master
liuwf 1 year ago
parent 24dbc80a04
commit c86803c4fd

@ -418,7 +418,7 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == StaticTaskType.FiveAccessoryIn)//入库任务
{
bool haveOut = taskList.Where(t => t.taskType == StaticTaskType.FiveAccessoryOut).Where(t => t.taskStatus != 6).Any();
bool haveOut = taskList.Where(t => item.taskType == StaticTaskType.FiveAccessoryOut || item.taskType == StaticTaskType.FiveAccessoryStorage || item.taskType == StaticTaskType.FiveAccessoryRemove).Where(t => t.taskStatus != 6).Any();
if (!haveOut && CtuWaitLogic())
{
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);

@ -2044,8 +2044,8 @@
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="开始盘点" Style="{StaticResource ButtonPrimary}" FontSize="15" Width="90" Height="55" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="结束盘点" Style="{StaticResource ButtonPrimary}" Margin="5 0 0 0" FontSize="15" Width="90" Height="55" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="{Binding StartContent}" Style="{StaticResource ButtonPrimary}" IsEnabled="{Binding StartEnable}" FontSize="15" Width="90" Height="55" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="结束盘点" Style="{StaticResource ButtonPrimary}" IsEnabled="{Binding EndEnable}" Margin="5 0 0 0" FontSize="15" Width="90" Height="55" Click="EndInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="详情" Style="{StaticResource ButtonPrimary}" Margin="5 0 0 0" FontSize="15" Width="90" Height="55" Click="OpenInventoryDetails" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</DataTemplate>

@ -2917,7 +2917,7 @@ namespace Khd.Core.Wpf.Form
}
//所有满足条件的需要盘库的库位
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.ContainerStatus == "1")
.Where(t => t.ContainerStatus == "1" && t.warehouseId==512)
.Where(t => t.locationStatus == "1")
.OrderBy(t => t.locRow)
.ThenBy(t => t.locColumn)
@ -3023,6 +3023,7 @@ namespace Khd.Core.Wpf.Form
RealAmount = rawItem.totalAmount,
InventoryCount = 0,
LocationCode = rawItem.locationCode,
MaterialBatch = rawItem.instockBatch,
StockId = 1,
StockType = "1",
MaterialId = rawItem.materialId,
@ -3065,12 +3066,41 @@ namespace Khd.Core.Wpf.Form
GetInvertoryData();
}
/// <summary>
/// 查看盘点详情界面
/// 结束盘点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OpenInventoryDetails(object sender, RoutedEventArgs e)
private void EndInventory(object sender, RoutedEventArgs e)
{
try
{
dynamic wmsInventoryCheck = this.InventoryMaterial.SelectedItem;
long inventoryCheckId = wmsInventoryCheck.InventoryCheckId;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var InventoryCheck = dbContext.WmsInventoryCheck
.Where(t => t.InventoryCheckId == inventoryCheckId).FirstOrDefault();
if (InventoryCheck.CheckStatus != "2")
{
InventoryCheck.CheckStatus = "2";
InventoryCheck.EndTime = DateTime.Now;
}
dbContext.WmsInventoryCheck.Update(InventoryCheck);
dbContext.SaveChanges();
GetInvertoryData();
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// 查看盘点详情界面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OpenInventoryDetails(object sender, RoutedEventArgs e)
{
dynamic wmsInventoryCheck = this.InventoryMaterial.SelectedItem;
long inventoryCheckId = wmsInventoryCheck.InventoryCheckId;
@ -3598,6 +3628,7 @@ namespace Khd.Core.Wpf.Form
BasePlcpoint basePlcpoint = SystemData.BasePlcpoints.First(t => t.plcpointNo == "canReceive");
SystemData.PlcDic[1].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
MsgText.Text = "一键收料发送成功";
HandyControl.Controls.MessageBox.Show("一键收料发送成功!");
}
catch (Exception ex)
{
@ -4328,6 +4359,10 @@ namespace Khd.Core.Wpf.Form
UpdateBy = t.UpdateBy,
UpdateTime = t.UpdateTime,
WarehouseId = t.WarehouseId,
StartContent = t.CheckStatus == "0" ? "开始盘点" : "继续盘点",
StartEnable = t.CheckStatus == "2" ? false : true,
EndEnable = t.CheckStatus == "2" ? false : true,
});
this.InventoryMaterial.Items.Refresh();

@ -33,8 +33,9 @@
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="请选择容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<ComboBox x:Name="ContainerCodeBox" IsEditable="True" DisplayMemberPath="containerNo" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />
<TextBlock Text="请扫描容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<!--<ComboBox x:Name="ContainerCodeBox" IsEditable="True" DisplayMemberPath="containerNo" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />-->
<hc:TextBox x:Name="txtInBox" hc:InfoElement.ShowClearButton="True" FontSize="20" TextChanged="txtInBox_TextChanged" Width="300" Background="White" HorizontalAlignment="Left" VerticalAlignment="Center" Height="50" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="4"/>
<Button x:Name="SearchBtn" Content="搜索" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="SearchBtn_Click"/>
<Button Content="编辑" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="EditBtn_Click"/>
</StackPanel>
@ -62,11 +63,13 @@
Visibility="Visible"
>
<DataGrid.Columns>
<DataGridTextColumn Header="库位号" Binding="{Binding LocationCode}" ElementStyle="{StaticResource dgCell}" Width="200*"/>
<DataGridTextColumn Header="料箱号" Binding="{Binding ContainerNo}" ElementStyle="{StaticResource dgCell}" Width="200*"/>
<DataGridTextColumn Header="物料编码" Binding="{Binding MaterialId}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTextColumn Header="库位号" Binding="{Binding LocationCode}" ElementStyle="{StaticResource dgCell}" Width="150*"/>
<!--<DataGridTextColumn Header="料箱号" Binding="{Binding ContainerNo}" ElementStyle="{StaticResource dgCell}" Width="200*"/>-->
<DataGridTextColumn Header="物料编码" Binding="{Binding MaterialId}" ElementStyle="{StaticResource dgCell}" Width="80*"/>
<DataGridTextColumn Header="物料条码" Binding="{Binding MaterialBatch}" ElementStyle="{StaticResource dgCell}" Width="180*"/>
<DataGridTextColumn Header="物料规格" Binding="{Binding MaterialSpec}" ElementStyle="{StaticResource dgCell}" Width="150*"/>
<DataGridTemplateColumn
Width="350*"
Width="250*"
CanUserSort="False"
Header="物料描述"
IsReadOnly="True" >
@ -76,12 +79,12 @@
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="库存数量" Binding="{Binding StockAmount}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTextColumn Header="实际数量" Binding="{Binding RealAmount}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTemplateColumn Header="操作">
<DataGridTextColumn Header="库存数量" Binding="{Binding StockAmount}" ElementStyle="{StaticResource dgCell}" Width="110*"/>
<DataGridTextColumn Header="实际数量" Binding="{Binding RealAmount}" ElementStyle="{StaticResource dgCell}" Width="110*"/>
<DataGridTemplateColumn Header="操作" Width="100*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="编辑" Foreground="White" Width="75" Background="#2196F3" Click="EditBtn_Click"/>
<Button Content="编辑" Foreground="White" Width="100" Background="#2196F3" Click="EditBtn_Click"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

@ -1,11 +1,17 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Wpf.Scan;
using Khd.Core.Wpf.TaskForm.Inventory;
using Masuit.Tools.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Khd.Core.Wpf.TaskForm
{
@ -14,30 +20,79 @@ namespace Khd.Core.Wpf.TaskForm
/// </summary>
public partial class InventoryTaskForm : Window
{
private readonly IHost _host;
public InventoryTaskForm(IHost host)
{
InitializeComponent();
_host = host;
Thread scanThread = new Thread(ScanMessage);
scanThread.IsBackground = true;
scanThread.Start();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
private void ScanMessage()
{
while (true)
{
try
{
if (SystemData.isUpdate)
{
if (!string.IsNullOrEmpty(SystemData.message))
{
Dispatcher.Invoke(() =>
{
var focusedElement = FocusManager.GetFocusedElement(this);
if (focusedElement is TextBox textBox)
{
textBox.Text = SystemData.message;
SystemData.isUpdate = false;
}
});
}
}
}
catch (Exception ex)
{
LogManager.Error(ex);
}
Thread.Sleep(500);
}
}
private void txtInBox_TextChanged(object sender, RoutedEventArgs e)
{
if(txtInBox.Text.Length == 15)
{
GetData(txtInBox.Text);
}
else
{
this.InventoryDataGrid.ItemsSource = null;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 100 && t.taskStatus == 6).ToList();
if (wcsTasks.Count > 0)
{
this.ContainerCodeBox.ItemsSource = wcsTasks.Distinct();
}
else
{
HandyControl.Controls.MessageBox.Show("未找到盘库已完成的小车任务!");
this.Close();
}
//if (wcsTasks.Count > 0)
//{
// this.ContainerCodeBox.ItemsSource = wcsTasks.Distinct();
//}
//else
//{
// HandyControl.Controls.MessageBox.Show("未找到盘库已完成的小车任务!");
// this.Close();
//}
}
catch
{
@ -45,19 +100,23 @@ namespace Khd.Core.Wpf.TaskForm
}
}
private void GetData()
private void GetData(string containerNo)
{
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTask = dbContext.WcsTask
.Where(t => t.taskType == 100)
.Where(t => t.containerNo == task.containerNo).FirstOrDefault();
.Where(t => t.containerNo == containerNo).FirstOrDefault();
if (wcsTask != null)
{
WmsInventoryCheck check = dbContext.WmsInventoryCheck.Where(x => x.CheckStatus == "1").FirstOrDefault();
if (check == null)
{
HandyControl.Controls.MessageBox.Show("当前无正在执行的盘库任务");
return;
}
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == wcsTask.orderId)
.Where(t => t.InventoryCheckId == check.InventoryCheckId)
.Where(t => t.LocationCode == wcsTask.currPointNo)
.Where(t => t.CheckStatus == "1")
.ToList();
@ -66,8 +125,10 @@ namespace Khd.Core.Wpf.TaskForm
this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.GroupBy(t => t.MaterialId).Select(t =>
new
{
ContainerNo = wcsTask.containerNo,
MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec,
//ContainerNo = wcsTask.containerNo,
MaterialBatch = t.FirstOrDefault(n => n.MaterialId == t.Key)?.MaterialBatch,
MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec,
MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialName,
StockAmount = t.Sum(n => n.StockAmount),
LocationCode = wcsTask.currPointNo,
MaterialId = t.Key,
@ -78,20 +139,51 @@ namespace Khd.Core.Wpf.TaskForm
{
HandyControl.Controls.MessageBox.Show("该料箱为空料箱");
}
}
}
else
{
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
HandyControl.Controls.MessageBox.Show("请扫描盘库任务里面的料箱");
}
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
GetData();
}
private void EditBtn_Click(object sender, RoutedEventArgs e)
{
//if (this.InventoryDataGrid.SelectedItem != null)
//{
// dynamic item = this.InventoryDataGrid.SelectedItem;
// long materialId = item.MaterialId;
// string containerNo = item.ContainerNo;
// string materialName = item.MaterialName;
// string locationCode = item.LocationCode;
// InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, materialId, containerNo, materialName, locationCode, this);
// this.Hide();
// editForm.ShowDialog();
// GetData();
//}
//else
//{
// if (this.ContainerCodeBox.SelectedItem is WcsTask task)
// {
// InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, task.containerNo, "", task.currPointNo, this);
// this.Hide();
// editForm.ShowDialog();
// GetData();
// }
// else
// {
// HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
// }
//}
}
private void Update_Click(object sender, RoutedEventArgs e)
{
if (this.InventoryDataGrid.SelectedItem != null)
{
@ -100,25 +192,10 @@ namespace Khd.Core.Wpf.TaskForm
string containerNo = item.ContainerNo;
string materialName = item.MaterialName;
string locationCode = item.LocationCode;
InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, materialId, containerNo, materialName, locationCode, this);
this.Hide();
editForm.ShowDialog();
GetData();
}
else
{
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, task.containerNo, "", task.currPointNo, this);
this.Hide();
editForm.ShowDialog();
GetData();
}
else
{
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
}
GetData(item.ContainerNo);
}
}
}
}

@ -39,12 +39,12 @@
<TextBox x:Name="SearchTxt" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" />
<Button x:Name="SearchButton" Foreground="White" Background="Blue" Content="搜 索" FontSize="20" Margin="20 0 25 0" Height="50" Width="100" Click="SearchButton_Click"/>
<TextBlock Text="选中物料" Foreground="White" FontSize="25" Margin="0 0 25 0" VerticalAlignment="Center"/>
<!--<TextBlock Text="选中物料" Foreground="White" FontSize="25" Margin="0 0 25 0" VerticalAlignment="Center"/>
<TextBox x:Name="SelectMaterialId" Width="50" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" IsReadOnly="True"/>
<TextBox x:Name="SelectMaterialName" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" IsReadOnly="True"/>
<TextBox x:Name="SelectMaterialName" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" IsReadOnly="True"/>-->
<Button x:Name="ClearButton" Foreground="White" Background="Blue" Content="清除" FontSize="20" Margin="20 0 25 0" Height="50" Width="100" Click="ClearButton_Click" />
<!--<Button x:Name="ClearButton" Foreground="White" Background="Blue" Content="清除" FontSize="20" Margin="20 0 25 0" Height="50" Width="100" Click="ClearButton_Click" />-->
<Button x:Name="CreateInventoryTask" Foreground="White" Background="DarkGreen" Content="创建盘库任务" FontSize="20" Margin="200 0 25 0" Height="50" Width="200" Click="CreateInventoryTask_Click" />

@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Wpf.dto;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -106,15 +107,7 @@ namespace Khd.Core.Wpf.WindowPage
public string materialSpec { get; set; }
}
private void ClearButton_Click(object sender, RoutedEventArgs e)
{
// 如果没有选中项则清空TextBox的内容
SelectMaterialId.Text = string.Empty;
SelectMaterialName.Text = string.Empty;
SearchTxt.Text = string.Empty;
Init();
}
private void CreateInventoryTask_Click(object sender, RoutedEventArgs e)
{
@ -128,7 +121,7 @@ namespace Khd.Core.Wpf.WindowPage
int locationCount = 0;
if(itemsControlItems.Count == 0)
{
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1").Count();
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1" && t.locationStatus=="1").Count();
}
else
{
@ -150,6 +143,7 @@ namespace Khd.Core.Wpf.WindowPage
{
Orders.ForEach(t =>
{
t.EndTime = DateTime.Now;
t.CheckStatus = "2";
});
dbContext.UpdateRange(Orders);

Loading…
Cancel
Save