1 year ago
parent 3f1dacb272
commit f72c19ffed

@ -129,6 +129,10 @@
/// 五楼辅料移库
/// </summary>
public const int FiveAccessoryRemove = 102;
/// <summary>
/// 人工任务
/// </summary>
public const int PersonTask = 99;
/// <summary>
/// 获取任务名称
@ -168,6 +172,7 @@
FiveAccessoryStorage => "五楼辅料盘库",
ThirdTransitToSecond => "三楼接驳位转运空托盘到二楼",
FiveAccessoryRemove => "五楼辅料移库",
PersonTask=>"人工任务",
_ => "未知任务类型",
};
}

@ -16,7 +16,7 @@ namespace Khd.Core.Domain.Models
public long? MaterialId { get; set; }
[Column("location_code")]
public string LocationCode { get; set; }
[Column("material_batch")]
[Column("material_barcode")]
public string MaterialBatch { get; set; }
[Column("stock_type")]
public string StockType { get; set; }

@ -9,6 +9,7 @@ using Masuit.Tools;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using SixLabors.ImageSharp;
using System.Data;
using System.Drawing.Text;
@ -38,6 +39,11 @@ namespace Khd.Core.Wcs.Wcs
//createRemoveThread.Name = "CreateRemoveLogic";
//createRemoveThread.Start();
// 叫空托盘 3-2楼
var createEmtpyThread = new Thread(CreateEmptyLoic);
createEmtpyThread.IsBackground = true;
createEmtpyThread.Name = "CreateEmptyLoic";
createEmtpyThread.Start();
//背负式Agv返库任务
var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic);
createBearAgvReturnThread.IsBackground = true;
@ -92,6 +98,83 @@ namespace Khd.Core.Wcs.Wcs
_logger.Info("出库任务监听启动成功");
}
private void CreateEmptyLoic(object? obj)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 36);
while (true)
{
try
{
bool create = false;
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var ids = dbContext.BaseEquip.Where(t => t.equipType == 20).Select(t => t.objid).ToList();
bool hasTask = dbContext.WcsTask.Where(t => t.endPointId == 2 || ids.Contains(t.endPointId.Value)).Any();
if (!hasTask)
{
int thirdTray = dbContext.BaseEquip
.Where(t => t.equipType == 15)
.Where(t => t.emptyCount == SystemData.maxTray).Count();
List<BaseEquip> baseEquips = dbContext.BaseEquip.Where(t => t.useFlag == 1).Where(t => t.equipType == 20).ToList();
int emptyCount = baseEquips.Where(t => t.emptyCount == 0).Count();
int maxCount = baseEquips.Where(t => t.emptyCount == SystemData.maxTray).Count();
if (thirdTray > 0)
{
if (emptyCount > 2 && thirdTray >= 2)
{
create = true;
}
}
if (create)
{
var baseEquip = dbContext.BaseEquip.FirstOrDefault(t => t.equipType == 15 && t.emptyCount == SystemData.maxTray);//三楼三个周转区是否存在空托盘
if (baseEquip != null)//如果三楼有空托盘
{
BaseEquip ThirdLineEquip = dbContext.BaseEquip.First(t => t.objid == 3);//三楼接驳位
BaseEquip ThirdAgvEquip = StaticData.BaseEquip.First(t => t.objid == 9);//三楼叉车
if (ThirdLineEquip.equipStatus == 0)//三楼接驳位空闲
{
//生成3楼Agv出库任务
WcsTask wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
containerNo = null,
createBy = "WCS",
createTime = DateTime.Now,
floorNo = 2,
fromFloorNo = 3,
isEmpty = "1",
qty = SystemData.maxTray,
taskType = StaticTaskType.ThirdTransitToSecond,
currPointId = baseEquip.objid,
currPointNo = baseEquip.equipNo,
nextPointId = ThirdAgvEquip.objid,
nextPointNo = ThirdAgvEquip.equipNo,
endPointId = endEquip.objid,
endPointNo = endEquip.equipNo,
taskStatus = 0,
useFlag = 1,
};
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成3楼Agv出库任务成功:" + wcsTask.objid);
_logger.Info("二楼码垛输送线生成3楼Agv出库任务成功:" + wcsTask.objid);
}
}
}
}
}
catch
{
}
Thread.Sleep(1000 * 60);
}
}
/// <summary>
/// 主动移库
/// </summary>
@ -1119,16 +1202,17 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(RemoveTask);
dbContext.Add(wcsTaskLog);
#endregion
}
}
else if (fromBaseLocation != null && fromBaseLocation.locationStatus != "1")
{
//浅库位状态异常,找寻下一个可出库库存
continue;
}
else if (fromBaseLocation == null)//浅库位无信息
{
continue;
}
}
}
@ -1559,7 +1643,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
// break;
// break;
}
}
else
@ -2120,7 +2204,7 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip endStationCodeEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(endStationCodeEquip.endStationCode) && endStationCodeEquip.IsOut == 1)
{
if (item.endStationCode != endStationCodeEquip.endStationCode)
if (!endStationCodeEquip.endStationCode.Contains(item.endStationCode))
{
continue;
}
@ -2128,7 +2212,7 @@ namespace Khd.Core.Wcs.Wcs
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
if (!hasTask)
{
var orderList = rawOutStock.Where(t => t.endStationCode == endStationCodeEquip.endStationCode).ToList();
var orderList = rawOutStock.Where(t => endStationCodeEquip.endStationCode.Contains(t.endStationCode)).ToList();
List<WcsTask> tasks = new();
List<long?> canOut = orderList.Select(t => t.saleOrderId).ToList();
rawStock = rawStock.Where(t => canOut.Contains(t.saleOrderId)).OrderByDescending(t => t.saleOrderId).ToList();
@ -2333,7 +2417,8 @@ namespace Khd.Core.Wcs.Wcs
}
BaseEquip startStationEquip = StaticData.BaseEquip.First(t => t.objid == 21);
BaseEquip bearAgvEquip = StaticData.BaseEquip.First(t => t.objid == 10);
BaseEquip endStationEquip = StaticData.BaseEquip.First(t => t.equipNo == endStationCodeEquip.endStationCode);
var json = JsonConvert.DeserializeObject<List<string>>(endStationCodeEquip.endStationCode);
BaseEquip endStationEquip = StaticData.BaseEquip.First(t => t.equipNo == json.First());
hasTask = dbContext.WcsTask.Where(t => t.taskType == 32).Any();
if (!hasTask)
{
@ -2479,7 +2564,7 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.locRow == row)
.Where(t => t.locColumn == location.locColumn)
.Where(t => t.warehouseId == location.warehouseId).FirstOrDefault();
if ( wmsBaseLocation.locationStatus == "1")
if (wmsBaseLocation.locationStatus == "1")
{
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == wmsBaseLocation.locationCode);
if (wmsRawStock != null)
@ -2570,7 +2655,7 @@ namespace Khd.Core.Wcs.Wcs
else
{
// 可以出库
// continue;
// continue;
}
}
else if (wmsBaseLocation != null && wmsBaseLocation.locationStatus != "1")

@ -2351,7 +2351,6 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="1" Grid.Column="4" Grid.RowSpan="2" Margin="20 0 0 0">
<StackPanel Orientation="Vertical" >
<TextBlock x:Name="OutOrder" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<TextBlock x:Name="thisOutEndStation" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,20,0,0"/>
</StackPanel>
@ -2369,15 +2368,24 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
<Border BorderBrush="White" BorderThickness="2" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="6" Grid.RowSpan="2" Margin="20">
<DataGrid Background="Transparent"
CanUserAddRows="False"
AutoGenerateColumns="False"
CanUserSortColumns="False"
Height="auto"
GridLinesVisibility="Horizontal"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
<DataGrid Style="{StaticResource DataGridStyle}"
Grid.Row="2" AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
CanUserAddRows="False"
GridLinesVisibility="All"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
Height="auto"
HeadersVisibility="Column"
IsReadOnly="True"
LoadingRow="dgData_LoadingRow"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
VerticalAlignment="Top"
x:Name="OutTaskNumber" >
<DataGrid.Columns>
<DataGridTextColumn
@ -2412,6 +2420,12 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
ElementStyle="{StaticResource dgCell}"
Width="*"
/>
<DataGridTextColumn
Header="目的地"
Binding="{Binding EndStationCodes}"
Width="*"
ElementStyle="{StaticResource dgCell}"
/>
<DataGridTextColumn
Header="是否出完"
Binding="{Binding isSendOver}"
@ -2433,7 +2447,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
@ -2441,25 +2455,25 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="Auto" />
</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="Transparent" />
<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="Transparent" />
<Setter Property="BorderBrush" Value="#172540" />
<Setter Property="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
@ -2766,7 +2780,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</TabItem>
<TabItem x:Name="PlcManager" Header="PLC信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="80" Margin="5">
<StackPanel x:Name="splPlcMessage" Height="1060" Width="1729" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Width="1750">
<StackPanel x:Name="PlcMessage" Orientation="Horizontal" Width="1750">
<StackPanel Orientation="Vertical" Margin="20,5,0,0">
<StackPanel Orientation="Horizontal" Margin="0">
<Image
@ -2788,7 +2802,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</Button>-->
</StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="700" Height="550" Margin="0,5,0,0">
<Grid>
<Grid x:Name="JBW">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="2*"/>
@ -2836,7 +2850,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</Border>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="700" Height="350" Margin="0,30,0,0">
<Grid>
<Grid x:Name="UXX">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
@ -2871,7 +2885,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="二楼小包出入口" Foreground="White" FontSize="35" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Grid Grid.Row="1">
<Grid Grid.Row="1" x:Name="XBRK">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
@ -2912,7 +2926,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
</Grid>
</Border>
<Border BorderBrush="White" Grid.Row="0" BorderThickness="2" CornerRadius="10" Margin="5">
<Grid>
<Grid x:Name="TSJ">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
@ -2946,7 +2960,7 @@ FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignmen
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="三楼翻转机" Foreground="White" FontSize="35" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Grid Grid.Row="1">
<Grid Grid.Row="1" x:Name="FZJ">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>

@ -164,7 +164,7 @@ namespace Khd.Core.Wpf.Form
plc = new Plc.S7.Plc(plcConfig.CpuType, plcConfig.IP, plcConfig.Port, plcConfig.Rack, plcConfig.Slot);
try
{
plc.Open();
plc.OpenAsync();
}
catch (Exception ex)
{
@ -545,7 +545,12 @@ namespace Khd.Core.Wpf.Form
.ToList();
List<string> list = wmsRawOutstocks.Select(t => t.endStationCode).ToList();
List<long?> orderIds = wmsRawOutstocks.Select(t => t.rawOutstockId).ToList();
var endStations = wmsRawOutstocks.Select(t => new
{
orderId=t.saleOrderId,
t.materialId,
t.endStationCode
});
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
string nowStationCode = baseEquip.endStationCode;
if (!string.IsNullOrEmpty(nowStationCode))
@ -574,7 +579,7 @@ namespace Khd.Core.Wpf.Form
{
#region 待测试
//找出本工位的申请单
List<WmsRawOutstock> RawOutstocks = wmsRawOutstocks.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
List<WmsRawOutstock> RawOutstocks = wmsRawOutstocks.Where(t => baseEquip.endStationCode.Contains(t.endStationCode)).ToList();
// 根据 materialId 分组,并计算 outstockAmount 和 realOutstockAmount 的总和
var targetRawOutstocks = RawOutstocks
@ -620,7 +625,8 @@ namespace Khd.Core.Wpf.Form
PalletDetails = string.Join("\n", palletMaterialSummary
.Where(pallet => pallet.MaterialId == order.materialId)
.Select(pallet => $"托盘{pallet.PalletInfoCode}数量{string.Format("{0:0.00}", pallet.canUseAmount)}")
)
),
EndStationCodes =string.Join(",",endStations.Where(t => t.materialId == order.materialId && t.orderId == order.saleOrderId).Select(t => t.endStationCode).ToList())
}).ToList();
List<long?> materialIds = RawOutstocks.Select(t => t.materialId).ToList();
@ -638,7 +644,8 @@ namespace Khd.Core.Wpf.Form
outstockAmount = string.Format("{0:0.00}", r.RequestedAmount),
realOutstockAmount = string.Format("{0:0.00}", r.RealOutstockAmount),
isSendOver = r.RequestedAmount <= r.RealOutstockAmount ? "已出完" : "未出完",
thisOutAmount = r.PalletDetails
thisOutAmount = r.PalletDetails,
EndStationCodes=r.EndStationCodes
};
#endregion
@ -1550,14 +1557,27 @@ namespace Khd.Core.Wpf.Form
MessageBoxResult messageBoxResult1 = HandyControl.Controls.MessageBox.Show("是否需要背负式小车返回?", "提示信息", MessageBoxButton.YesNoCancel, MessageBoxImage.Information);
if (messageBoxResult1 == MessageBoxResult.Yes)
{
WcsTask wcsTask = CoreMapper.Map<WcsTask>(wcsCmd);
wcsTask.taskStatus = 0;
wcsTask.createTime = DateTime.Now;
wcsTask.useFlag = 1;
wcsTask.objid = Global.SnowId.NextId();
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(wcsTask);
BaseEquip baseEquip = dbContext.BaseEquip.Where(t => t.objid == 10).First();
List<string>? list = JsonConvert.DeserializeObject<List<string>>(baseEquip.endStationCode);
new SelectOutRawForm(_host,"",3,list).ShowDialog();
if (string.IsNullOrEmpty(SelectOutRawForm.StationCode))
{
return;
}
else
{
BaseEquip endEquip = dbContext.BaseEquip.First(t => t.equipNo == SelectOutRawForm.StationCode);
WcsTask wcsTask = CoreMapper.Map<WcsTask>(wcsCmd);
wcsTask.taskStatus = 0;
wcsTask.createTime = DateTime.Now;
wcsTask.useFlag = 1;
wcsTask.objid = Global.SnowId.NextId();
wcsTask.endPointId = endEquip.objid;
wcsTask.endPointNo = endEquip.equipNo;
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(wcsTask);
}
}
else
{
@ -1835,7 +1855,73 @@ namespace Khd.Core.Wpf.Form
TextBlock? textBlock = null;
Dispatcher.Invoke(() =>
{
textBlock = this.FindName(item.plcpointNo) as TextBlock;
foreach(var ch in this.UXX.Children)
{
if(ch is TextBlock tb)
{
if(tb.Name == item.plcpointNo)
{
textBlock = tb;
break;
}
}
}
if(textBlock == null)
{
foreach (var ch in this.TSJ.Children)
{
if (ch is TextBlock tb)
{
if (tb.Name == item.plcpointNo)
{
textBlock = tb;
break;
}
}
}
}
if (textBlock == null)
{
foreach (var ch in this.XBRK.Children)
{
if (ch is TextBlock tb)
{
if (tb.Name == item.plcpointNo)
{
textBlock = tb;
break;
}
}
}
}
if (textBlock == null)
{
foreach (var ch in this.JBW.Children)
{
if (ch is TextBlock tb)
{
if (tb.Name == item.plcpointNo)
{
textBlock = tb;
break;
}
}
}
}
if (textBlock == null)
{
foreach (var ch in this.FZJ.Children)
{
if (ch is TextBlock tb)
{
if (tb.Name == item.plcpointNo)
{
textBlock = tb;
break;
}
}
}
}
});
if (textBlock != null)
{
@ -1877,7 +1963,7 @@ namespace Khd.Core.Wpf.Form
}
catch
{
points.RemoveAll(t => t.definefield3 == ex.Message);
}
}
}

@ -480,7 +480,7 @@
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

@ -9,6 +9,24 @@
WindowStartupLocation="CenterScreen"
Background="#333333"
Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Visibility" Value="Collapsed"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform ScaleX="2" ScaleY="2" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -23,6 +41,14 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" x:Name="startStationLabel" Grid.Row="0" Grid.ColumnSpan="5">
<CheckBox Content="ZP_01" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Content="ZP_02" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Content="ZP_03" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Content="ZP_04" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Content="ZP_05" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
<CheckBox Content="ZP_06" Style="{StaticResource CheckBoxStyle}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>
</StackPanel>
<TextBlock Text="出库终点" Foreground="White" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
<ComboBox x:Name="endStationCode" FontSize="30" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300" Height="75"/>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="5">

@ -1,9 +1,12 @@
using Khd.Core.EntityFramework;
using Masuit.Tools;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace Khd.Core.Wpf.TaskForm
{
@ -15,12 +18,16 @@ namespace Khd.Core.Wpf.TaskForm
private readonly IHost _host;
private readonly string _ud3;
private readonly int _isOut;
public SelectOutRawForm(IHost host, string ud3, int isOut)
private List<string> _endStationCodes = new List<string>();
public static string StationCode = "";
public List<string> _list;
public SelectOutRawForm(IHost host, string ud3, int isOut, List<string> list = null)
{
InitializeComponent();
_host = host;
_ud3 = ud3;
_isOut = isOut;
this._list = list;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
@ -36,10 +43,23 @@ namespace Khd.Core.Wpf.TaskForm
}
else
{
if (_isOut == 3)
{
StationCode = this.endStationCode.SelectedItem.ToString();
}
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = dbContext.BaseEquip.Where(t => t.objid == 10).First();
baseEquip.endStationCode = this.endStationCode.SelectedItem.ToString();
if (_isOut == 1)
{
_endStationCodes.Remove(this.endStationCode.SelectedItem.ToString());
_endStationCodes.Insert(0, this.endStationCode.SelectedItem.ToString());
baseEquip.endStationCode = _endStationCodes.ToJsonString();
}
else
{
baseEquip.endStationCode = this.endStationCode.SelectedItem.ToString();
}
baseEquip.ud3 = _ud3;
baseEquip.IsOut = _isOut;
dbContext.BaseEquip.Update(baseEquip);
@ -50,25 +70,100 @@ namespace Khd.Core.Wpf.TaskForm
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<string> endStationCodes = SystemData.BaseEquip.Where(t => t.equipType == 10).Select(t => t.agvPositionCode).ToList();
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var hasTask = dbContext.WcsTask.Where(t => (t.nextPointId == 11 && t.taskType == 30) || t.nextPointId == 10).Any();
if (!hasTask)
if (_isOut == 3)
{
var wmsRawOutstocks = dbContext.WmsRawOutstock
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.outstockAmount > t.realOutstockAmount)
.ToList();
List<string> list = wmsRawOutstocks.Select(t => t.endStationCode).Distinct().ToList();
this.endStationCode.ItemsSource = list;
if (_list == null || _list.Count() == 0)
{
return;
}
this.endStationCode.ItemsSource = _list;
foreach (var item in startStationLabel.Children)
{
if (item is CheckBox cb)
{
cb.Visibility = _list.Contains(cb.Content.ToString()) ? Visibility.Visible : Visibility.Collapsed;
}
}
if (_list.Count == 0)
{
StationCode = _list.First();
return;
}
}
else
{
MessageBox.Show("您有未完成的出库任务,请先完成后再进行此操作!");
this.Close();
List<string> endStationCodes = SystemData.BaseEquip.Where(t => t.equipType == 10).Select(t => t.agvPositionCode).ToList();
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var hasTask = dbContext.WcsTask.Where(t => (t.nextPointId == 11 && t.taskType == 30) || t.nextPointId == 10).Any();
if (!hasTask)
{
List<string> list = endStationCodes;
if (_isOut == 1)
{
var wmsRawOutstocks = dbContext.WmsRawOutstock
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.outstockAmount > t.realOutstockAmount)
.ToList();
list = wmsRawOutstocks.Select(t => t.endStationCode).Distinct().ToList();
}
else
{
var wmsRawInstocks = dbContext.WmsRawReturn
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.planAmount > t.returnAmount)
.ToList();
list = wmsRawInstocks.Select(t => t.endStationCode).Distinct().ToList();
}
if (_isOut == 1)
{
foreach (var item in startStationLabel.Children)
{
if (item is CheckBox cb)
{
cb.Visibility = list.Contains(cb.Content.ToString()) ? Visibility.Visible : Visibility.Collapsed;
}
}
}
else
{
this.endStationCode.ItemsSource = list;
}
}
else
{
MessageBox.Show("您有未完成的出库任务,请先完成后再进行此操作!");
this.Close();
}
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
if (sender is CheckBox cb)
{
if (cb.IsChecked.Value)
{
_endStationCodes.Add(cb.Content.ToString());
}
else
{
_endStationCodes.Remove(cb.Content.ToString());
}
}
this.endStationCode.ItemsSource = _endStationCodes.OrderBy(t => t);
this.endStationCode.Items.Refresh();
if (_endStationCodes.Count >= 1)
{
this.endStationCode.SelectedIndex = 0;
}
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
}
}
}

@ -55,16 +55,16 @@
"库存信息",
"辅料库位",
"库位状态",
"废料区管理",
"人工叫料",
"盘库任务",
"扫描入库",
"扫描退库",
"扫描出库",
"辅料移库",
//"废料区管理",
//"一楼接驳位",
//"PLC信息",
//"Agv信息",
"PLC信息",
"Agv信息",
//"权限控制"
]

@ -20,12 +20,11 @@ namespace Khd.Core.Wpf.myConverter
new Dictionary<int?,string>(){
{-1,"人工创建" },
{0,"未下发" },
{1,"已下发" },
{2,"任务开始" },
{3,"已到起始地" },
{4,"起始地继续任务" },
{5,"已到目的地" },
{6,"任务结束" },
{1,"前往起始地" },
{2,"入库中" },
{3,"前往目的地" },
{4,"出库中" },
{5,"任务结束" },
}
},
{

Loading…
Cancel
Save