change-盘库未完成版本

master
liuwf 1 year ago
parent fb4d45335b
commit 0e2078537d

@ -2206,7 +2206,7 @@ namespace Khd.Core.Wcs.Wcs
tasks.Add(wcsTask);
location.locationStatus = "6";
location.updateBy = "WCS";
location.ContainerStatus = "2";
// location.ContainerStatus = "2";
location.updateTime = DateTime.Now;
dbContext.Update(location);
dbContext.Update(stock);

@ -532,7 +532,7 @@ namespace Khd.Core.Wcs.Wcs
{
_logger.Info("五楼CTU线程完成任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼CTU线程完成任务" + item.currPointNo + "," + item.endPointNo);
if (item.taskType == StaticTaskType.FiveAccessoryOut)//出库任务
if (item.taskType == StaticTaskType.FiveAccessoryOut || item.taskType == StaticTaskType.FiveAccessoryStorage || item.taskType == StaticTaskType.FiveAccessoryRemove)//出库任务
{
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.taskCode == item.objid.ToString());
if (wmsRawOutstockDetail != null)

@ -2903,30 +2903,41 @@ namespace Khd.Core.Wpf.Form
hasTask = dbContext.WcsTaskManual.Where(t => t.taskType == 100).Any();
if (!hasTask)
{
List<string>? locationCodeList = null;
if (InventoryCheck.MaterialId != null)
{
// 盘点某个型号的物料库存的库位
// List<string> locationCodeList = dbContext.WmsRawStock.Where(t => t.warehouseId == 512 && t.materialId == InventoryCheck.MaterialId).Select(x=>x.locationCode).ToList();
locationCodeList = dbContext.WmsRawStock.Where(t => t.warehouseId == 512 && t.materialId == InventoryCheck.MaterialId ).Select(x=>x.locationCode).ToList();
}
//所有满足条件的需要盘库的库位
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.ContainerStatus == "1")
.Where(t => t.locationStatus == "1")
.OrderBy(t => t.locRow)
.ThenBy(t => t.locColumn)
.ToList();
if(locationCodeList != null && locationCodeList.Count > 0)
{
wmsBaseLocations = wmsBaseLocations.Where(x=>locationCodeList.Contains(x.locationCode)).ToList();
}
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == InventoryCheck.InventoryCheckId).ToList();
// 已经盘点过的库位
List<string> locationCodes = wmsInventoryCheckDetails.Select(t => t.LocationCode).Distinct().ToList();
wmsBaseLocations.RemoveAll(t => locationCodes.Contains(t.locationCode));
if (wmsBaseLocations.Count > 0)
{
List<string> locations = wmsBaseLocations.Select(t => t.locationCode).ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.warehouseId == 512).ToList();
var wmsRawStock = wmsRawStocks
.Where(t => locations.Contains(t.locationCode)).ToList();
List<string> codes = wmsRawStock.Select(t => t.locationCode).Distinct().ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.warehouseId == 512)
.Where(t => locations.Contains(t.locationCode))
.WhereIf(InventoryCheck.MaterialId!=null,t => t.materialId == InventoryCheck.MaterialId).ToList();
// 过滤后需要满足条件的有库存的库位
List<string> codes = wmsRawStocks.Select(t => t.locationCode).Distinct().ToList();
var bill = from a in wmsBaseLocations
from b in codes
where a.locationCode == b
@ -2937,7 +2948,8 @@ namespace Khd.Core.Wpf.Form
{
WmsBaseLocation startBaseLocation = item.a;
startBaseLocation.locationStatus = "6";
startBaseLocation.ContainerStatus = "2";
//startBaseLocation.ContainerStatus = "2";
addList.Add(new WcsTaskManual()
{
objid = Global.SnowId.NextId(),
@ -2959,37 +2971,37 @@ namespace Khd.Core.Wpf.Form
});
dbContext.Update(startBaseLocation);
}
for (int i = addList.Count + 1; i <= 6; i++)
{
List<long?> list = addList.Select(t => t.currPointId).ToList();
WmsBaseLocation? startBaseLocation = wmsBaseLocations.Where(t => !list.Contains(t.locationId)).FirstOrDefault();
if (startBaseLocation != null)
{
startBaseLocation.locationStatus = "6";
startBaseLocation.ContainerStatus = "2";
addList.Add(new WcsTaskManual()
{
objid = Global.SnowId.NextId(),
taskType = 100,
orderId = InventoryCheck.InventoryCheckId,
containerNo = startBaseLocation.containerCode,
currPointId = startBaseLocation.locationId,
currPointNo = startBaseLocation.locationCode,
nextPointId = agvEquip.objid,
nextPointNo = agvEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
createTime = DateTime.Now,
ud1 = startBaseLocation.locColumn,
taskStatus = 0,
remark = "CTU盘点任务",
floorNo = 5,
fromFloorNo = 5,
useFlag = 1,
});
dbContext.Update(startBaseLocation);
}
}
//for (int i = addList.Count + 1; i <= 6; i++)
//{
// List<long?> list = addList.Select(t => t.currPointId).ToList();
// WmsBaseLocation? startBaseLocation = wmsBaseLocations.Where(t => !list.Contains(t.locationId)).FirstOrDefault();
// if (startBaseLocation != null)
// {
// startBaseLocation.locationStatus = "6";
// startBaseLocation.ContainerStatus = "2";
// addList.Add(new WcsTaskManual()
// {
// objid = Global.SnowId.NextId(),
// taskType = 100,
// orderId = InventoryCheck.InventoryCheckId,
// containerNo = startBaseLocation.containerCode,
// currPointId = startBaseLocation.locationId,
// currPointNo = startBaseLocation.locationCode,
// nextPointId = agvEquip.objid,
// nextPointNo = agvEquip.equipNo,
// endPointId = lineEquip.objid,
// endPointNo = lineEquip.equipNo,
// createTime = DateTime.Now,
// ud1 = startBaseLocation.locColumn,
// taskStatus = 0,
// remark = "CTU盘点任务",
// floorNo = 5,
// fromFloorNo = 5,
// useFlag = 1,
// });
// dbContext.Update(startBaseLocation);
// }
//}
List<WmsInventoryCheckDetail> addCheckDetail = new List<WmsInventoryCheckDetail>();
foreach (var item in addList)
{
@ -4281,6 +4293,9 @@ namespace Khd.Core.Wpf.Form
/// <param name="e"></param>
private void AddInventoryButton_Click(object sender, RoutedEventArgs e)
{
InventoryMaterialWindow window = new InventoryMaterialWindow(_host);
window.ShowDialog();
return;
try
{
using var scope = _host.Services.CreateScope();

@ -478,6 +478,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="WindowPage\InventoryMaterialWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

@ -0,0 +1,149 @@
<Window x:Class="Khd.Core.Wpf.WindowPage.InventoryMaterialWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Khd.Core.Wpf.WindowPage"
mc:Ignorable="d"
Title="选择盘库型号" Height="600" Width="1500" WindowStartupLocation="CenterScreen" Background="#172557">
<Window.Resources>
<ResourceDictionary>
<Style x:Key="dgCell" TargetType="TextBlock" BasedOn="{x:Null}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<ResourceDictionary.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
<ResourceDictionary Source="/CSS/SearchBtnClass.xaml" />
<ResourceDictionary Source="/CSS/SearchTextClass.xaml" />
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<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"/>
<TextBox x:Name="SelectMaterialId" Width="50" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" />
<TextBox x:Name="SelectMaterialName" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<DataGrid SelectionChanged="StockDataGrid_SelectionChanged"
Style="{StaticResource DataGridStyle}"
Grid.Row="2" AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
Background="#172557"
CanUserAddRows="False"
GridLinesVisibility="None"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
Height="auto"
HeadersVisibility="Column"
IsReadOnly="True"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
VerticalAlignment="Top"
x:Name="StockDataGrid">
<DataGrid.Columns>
<DataGridTextColumn
Width="200*"
Binding="{Binding materialId}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料ID"
IsReadOnly="True" />
<DataGridTextColumn
Width="200*"
Binding="{Binding materialCode}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料编码"
IsReadOnly="True" />
<DataGridTemplateColumn
Width="280*"
CanUserSort="False"
Header="物料名称"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialName}" ToolTip="{Binding materialNameSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="300*"
CanUserSort="False"
Header="物料规格"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialSpec}" ToolTip="{Binding materialSpecSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#172560" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="BorderBrush" Value="#172540" />
<Setter Property="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
</Grid>
</Grid>
</Window>

@ -0,0 +1,112 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace Khd.Core.Wpf.WindowPage
{
/// <summary>
/// StockWindow.xaml 的交互逻辑
/// </summary>
public partial class InventoryMaterialWindow : Window
{
private IHost host = null;
public InventoryMaterialWindow(IHost _host)
{
host = _host;
InitializeComponent();
Init();
}
public async Task Init()
{
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//var location = await dbContext.WmsBaseLocation.Where(x => x.locationId == locationId).FirstOrDefaultAsync();
var stockList = await dbContext.WmsRawStock.Where(x => x.warehouseId ==512).ToListAsync();
if(stockList != null && stockList.Count > 0)
{
// 获取所有库存物料 ID
var materialIds = stockList.Select(stock => stock.materialId).Distinct().ToList();
var materialInfos = await dbContext.MesBaseMaterialInfo
.Where(material => materialIds.Contains(material.MaterialId))
.ToListAsync();
// 将库存物料信息和物料详细信息合并
var stockDetails = materialInfos.Select(material => new StockItem
{
materialId = material.MaterialId.ToString(),
materialCode = material.MaterialCode,
materialName = material.MaterialName,
materialSpec = material.MaterialSpec,
}).ToList();
StockDataGrid.ItemsSource = stockDetails;
}
}
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
string searchStr = SearchTxt.Text;
if (string.IsNullOrEmpty(searchStr))
{
Init();
}
else
{
var target = StockDataGrid.ItemsSource.Cast<dynamic>().Where(x => x.materialCode.Contains(searchStr) || x.materialName.Contains(searchStr) || x.materialSpec.Contains(searchStr)).ToList();
StockDataGrid.ItemsSource = target;
}
}
private void StockDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// 获取选中的项假设它是某种类型如StockItem
var selectedItem = StockDataGrid.SelectedItem as StockItem; // StockItem是你的数据项类型
if (selectedItem != null)
{
// 更新TextBox的内容为选中项的属性值
SelectMaterialId.Text = selectedItem.materialId.ToString(); // 假设MaterialId是一个属性
SelectMaterialName.Text = selectedItem.materialName; // 假设MaterialName是一个属性
}
else
{
// 如果没有选中项则清空TextBox的内容
SelectMaterialId.Text = string.Empty;
SelectMaterialName.Text = string.Empty;
}
}
public class StockItem
{
public string materialId { get; set; }
public string materialCode { get; set; }
public string materialName { get; set; }
public string materialSpec { get; set; }
}
}
}
Loading…
Cancel
Save