master
1 year ago
parent ea87f50cda
commit dbb1b23954

@ -110,8 +110,10 @@ namespace Khd.Core.Wcs
FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value);
fifthFloorAGV.StartPoint();
//背负式Agv
var FifthFloorBearAgvEquip = StaticData.BaseEquip.Where(t => t.objid == 28).First();
FiveFloorBearAgv fiveFloorBearAgv = new(_host, FifthFloorBearAgvEquip.floorNo.Value);
fiveFloorBearAgv.StartPoint();
}
catch (Exception ex)
{

@ -292,7 +292,7 @@ namespace Khd.Core.Wcs.Wcs
{
//判断task表里没有该rfid的未完成的入库
//信息,未下发去向
var task = dbContext.WcsTask.Where(t => t.IsDelete == 0).Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault();
var task = dbContext.WcsTask.Where(t => t.IsDelete == 0||t.IsDelete==null).Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault();
if (task == null)
{
if (BigContainerCodes.Contains(RFID001Value))

@ -53,7 +53,7 @@ namespace Khd.Core.Wcs.Wcs
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask
.Where(t => t.IsDelete == 0 || t.IsDelete == null)
.Where(t => t.IsDelete == 0 || t.IsDelete == null)
.Where(t => t.nextPointId == agvID)
.OrderBy(t => t.createTime).ToList();

@ -174,6 +174,7 @@ namespace Khd.Core.Wcs.Wcs
equipmentNo = baseEquip.equipNo,
createBy = FloorNo + "楼CTU",
createTime = DateTime.Now,
ud3 = "1"//标记任务是出库任务转为入库任务
};
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.updateTime = DateTime.Now;
@ -439,8 +440,9 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(item);
lock (SystemData.outStockLock)
{
bool hasTask = dbContext.WcsTask.Where(t=>t.nextPointId==11&&t.taskType==30).Any();
if (!hasTask)//如果CTU当前任务数量很多取消预执行任务
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11 && t.taskType == 30).Any();
int taskCount = dbContext.WcsTask.Where(t => t.nextPointId == 11 && t.taskType == 29).Count();
if ((!hasTask && item.ud3 == "1") || (taskCount >= 6))//如果CTU当前任务数量很多取消预执行任务,或者出库的任务都生成了入库任务
{
ExecuteInTask(baseEquip);
}

@ -8,6 +8,7 @@ using Masuit.Tools;
using Masuit.Tools.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
namespace Khd.Core.Wcs.Wcs
@ -48,13 +49,14 @@ namespace Khd.Core.Wcs.Wcs
};
PlcHeartBeat31Thread.Start();//脉冲
var PlcHearBeat220Thread = new Thread(PlcHearBeat220Logic) {
var PlcHearBeat220Thread = new Thread(PlcHearBeat220Logic)
{
Name = "PlcHeartBeat220Thread",
IsBackground = true
};
PlcHearBeat220Thread.Start();
var deleteTaskThread=new Thread(DeleteTaskLogic)
var deleteTaskThread = new Thread(DeleteTaskLogic)
{
Name = "DeleteTaskThread",
IsBackground = true
@ -75,9 +77,9 @@ namespace Khd.Core.Wcs.Wcs
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.IsDelete == 1).ToList();
foreach (var item in wcsTasks)
{
if (!string.IsNullOrEmpty(item.taskCode))
BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == item.nextPointId);
if (!string.IsNullOrEmpty(item.taskCode) && !string.IsNullOrEmpty(agvEquip.serverIp))
{
BaseEquip agvEquip = StaticData.BaseEquip.First(t=>t.objid==item.nextPointId);
dbContext.WcsTask.Remove(item);
var cancelTask = new
{
@ -152,7 +154,7 @@ namespace Khd.Core.Wcs.Wcs
heartBeatCount = !heartBeatCount;
StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount, HeartBeat30.plcpointLength?.ToString());
}
catch
catch
{
try
{

@ -1967,28 +1967,113 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="2" Grid.RowSpan="2" Margin="20">
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="2" Grid.Column="4" Grid.RowSpan="2" Margin="20">
<TextBlock x:Name="OutOrder" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center"/>
</Border>
<TextBlock Text="扫描出库" Foreground="White" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="6"/>
<Button Content="选择出库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Height="100" Width="300" Click="SelectOutBtn_Click"/>
<Border BorderBrush="White" BorderThickness="2" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="5" Grid.RowSpan="2" Margin="20">
<DataGrid Background="Transparent"
CanUserAddRows="False"
AutoGenerateColumns="False"
CanUserSortColumns="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
x:Name="OutTaskNumber">
<DataGrid.Columns>
<DataGridTextColumn
Header="物料批次"
Binding="{Binding materialBatch}"
Width="5*"
/>
<DataGridTextColumn
Header="销售订单"
Binding="{Binding saleOrderId}"
Width="*"
/>
<DataGridTextColumn
Header="箱体携带数量"
Binding="{Binding thisOutAmount}"
Width="2*"
/>
<DataGridTextColumn
Header="申请数量"
Binding="{Binding outstockAmount}"
Width="2*"
/>
<DataGridTextColumn
Header="已出数量"
Binding="{Binding realOutstockAmount}"
Width="2*"
/>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<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="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="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
</Border>
<TextBlock Text="扫描出库" Grid.RowSpan="2" Foreground="White" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="6"/>
<TextBlock Text="待执行CTU任务数:" Visibility="Hidden" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="50"/>
<TextBlock x:Name="outTaskCount" Visibility="Hidden" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Button Content="执行CTU出库任务" Visibility="Hidden" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="2" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="ExecuteCtuTask_Click"/>
<TextBlock Text="扫描料箱号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="扫描条码号:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Button Click="boxOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
<Button Click="barOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="3">
<Image Source="..\Resources\cancel.png"/>
</Button>
<TextBlock Text="出库数量:" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBox" FontSize="50" LostFocus="txtOutBox_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3"/>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBarCode" FontSize="50" LostFocus="txtOutBarCode_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3"/>
<hc:TextBox x:Name="txtOutScan" IsReadOnly="True" FontSize="50" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="3" />
<Button Content="确认出库" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="OutRawBaseLocaltion_Click"/>
<Button Content="背负式小车捡料完成" Grid.Row="6" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="btnBearConfirmBox_Click"/>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="6">
<TextBlock Text="扫描料箱号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Grid>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBox" FontSize="50" LostFocus="txtOutBox_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3"/>
<Button Click="boxOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</Grid>
<Button Content="选择出库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="150,0,0,0" Height="100" Width="300" Click="SelectOutBtn_Click"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="6">
<TextBlock Text="扫描条码号:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Grid>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBarCode" FontSize="50" LostFocus="txtOutBarCode_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="3"/>
<Button Click="barOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,0,0" Grid.Column="5" Grid.Row="3">
<Image Source="..\Resources\cancel.png"/>
</Button>
</Grid>
<Button Content="确认出库" Grid.Column="4" Grid.Row="5" Grid.ColumnSpan="2" Width="400" Height="100" Margin="100,0,0,0" FontSize="35" Background="#346DFF" Foreground="White" Click="OutRawBaseLocaltion_Click"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="4" Grid.ColumnSpan="6">
<TextBlock Text="出库数量:" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Grid>
<hc:TextBox x:Name="txtOutScan" Margin="80,0,0,0" IsReadOnly="True" FontSize="50" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="3" />
</Grid>
<Button Content="背负式小车捡料完成" Grid.Column="4" Grid.Row="6" Grid.ColumnSpan="2" Width="400" Height="100" Margin="100,0,0,0" FontSize="35" Background="#346DFF" Foreground="White" Click="btnBearConfirmBox_Click"/>
</StackPanel>
</Grid>
<!--<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10">

@ -270,7 +270,7 @@ namespace Khd.Core.Wpf.Form
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
List<BaseEquip> baseEquips = dbContext.BaseEquip.Where(t => t.equipType == 10).ToList();
var endStationCodes = baseEquips.Select(t => t.endStationCode).ToList();
var endStationCodes = baseEquips.Select(t => t.agvPositionCode).ToList();
while (true)
{
try
@ -286,12 +286,61 @@ namespace Khd.Core.Wpf.Form
{
this.OutOrder.Text = "待出库单:\n" + list.Join("\n");
});
var baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(baseEquip.endStationCode))
{
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).ToList();
List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => containerNos.Contains(t.palletInfoCode)).ToList();
var thisOutList = wmsRawStocks.GroupBy(t => new { t.materialId, t.saleOrderId })
.Select(t =>new
{
materialId=t.Key.materialId,
saleOrderId=t.Key.saleOrderId,
thisOutAmount=t.Sum(x=>x.totalAmount)-t.Sum(x=>x.frozenAmount)
});
List<WmsRawOutstock> endStationCodeOutRaw = wmsRawOutstocks.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
var bill = endStationCodeOutRaw.GroupBy(t => new { t.materialId,t.materialBatch, t.saleOrderId })
.Select(t =>new
{
materialId=t.Key.materialId,
materialBatch=t.Key.materialBatch,
saleOrderId=t.Key.saleOrderId,
outstockAmount=t.Sum(x=>x.outstockAmount),
realOutstockAmount=t.Sum(x=>x.realOutstockAmount),
});
var orderNumber = from a in bill
from b in thisOutList
where a.materialId == b.materialId && a.saleOrderId == b.saleOrderId
select new
{
materialBatch=a.materialBatch,
saleOrderId=b.saleOrderId,
outstockAmount=a.outstockAmount,
realOutstockAmount=a.realOutstockAmount,
thisOutAmount=b.thisOutAmount
};
Dispatcher.Invoke(() =>
{
OutTaskNumber.ItemsSource = orderNumber;
OutTaskNumber.Items.Refresh();
});
}
else
{
Dispatcher.Invoke(() =>
{
OutTaskNumber.ItemsSource = null;
OutTaskNumber.Items.Refresh();
});
}
}
catch
{
}
Thread.Sleep(3000);
Thread.Sleep(1000);
}
}
@ -576,16 +625,8 @@ namespace Khd.Core.Wpf.Form
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => ids.Contains(t.objid)).ToList();
foreach (var item in wcsTasks)
{
if (string.IsNullOrEmpty(item.taskCode))
{
dbContext.Remove(item);
}
else
{
item.IsDelete = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { IsDelete = 1 });
}
item.IsDelete = 1;
dbContext.Update(item);
dbContext.SaveChanges();
}
GetTask();
@ -1098,6 +1139,7 @@ namespace Khd.Core.Wpf.Form
dbContext.Update(baseEquip);
var wcsCmd = dbContext.WcsTask
.Where(t => t.taskStatus == 6 || t.taskStatus == 3)
.Where(t=>t.nextPointId== 10)
.FirstOrDefault();
if (wcsCmd == null)
{
@ -1105,14 +1147,19 @@ namespace Khd.Core.Wpf.Form
}
else
{
if (wcsCmd.taskStatus == 3)
if (wcsCmd.taskType == 32)//领料
{
wcsCmd.taskStatus = 4;
if (wcsCmd.taskStatus == 3)
{
wcsCmd.taskStatus = 4;
}
}
else if (wcsCmd.taskStatus == 6)
else if (wcsCmd.taskType == 48)//返库
{
wcsCmd.taskStatus = 7;
if (wcsCmd.taskStatus == 6)
{
wcsCmd.taskStatus = 7;
}
}
dbContext.Update(wcsCmd);
dbContext.SaveChanges();

Loading…
Cancel
Save