master
1 year ago
parent ea87f50cda
commit dbb1b23954

@ -110,8 +110,10 @@ namespace Khd.Core.Wcs
FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value); FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value);
fifthFloorAGV.StartPoint(); 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) catch (Exception ex)
{ {

@ -292,7 +292,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
//判断task表里没有该rfid的未完成的入库 //判断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 (task == null)
{ {
if (BigContainerCodes.Contains(RFID001Value)) if (BigContainerCodes.Contains(RFID001Value))

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

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

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

@ -1967,28 +1967,113 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </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"/> <TextBlock x:Name="OutOrder" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center"/>
</Border> </Border>
<TextBlock Text="扫描出库" Foreground="White" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="6"/> <Border BorderBrush="White" BorderThickness="2" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="5" Grid.RowSpan="2" Margin="20">
<Button Content="选择出库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Height="100" Width="300" Click="SelectOutBtn_Click"/> <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 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"/> <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"/> <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"> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="6">
<Image Source="..\Resources\cancel.png"/> <TextBlock Text="扫描料箱号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
</Button> <Grid>
<Button Click="barOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,130,0" Grid.Column="5" Grid.Row="3"> <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"/>
<Image Source="..\Resources\cancel.png"/> <Button Click="boxOutClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="0,0,0,0" Grid.Column="5" Grid.Row="2">
</Button> <Image Source="..\Resources\cancel.png"/>
<TextBlock Text="出库数量:" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/> </Button>
<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"/> </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 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"/>
<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" /> </StackPanel>
<Button Content="确认出库" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="OutRawBaseLocaltion_Click"/> <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="6">
<Button Content="背负式小车捡料完成" Grid.Row="6" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="btnBearConfirmBox_Click"/> <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> </Grid>
<!--<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0"> <!--<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10"> <StackPanel Margin="0,10,10,10">

@ -270,7 +270,7 @@ namespace Khd.Core.Wpf.Form
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
List<BaseEquip> baseEquips = dbContext.BaseEquip.Where(t => t.equipType == 10).ToList(); 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) while (true)
{ {
try try
@ -286,12 +286,61 @@ namespace Khd.Core.Wpf.Form
{ {
this.OutOrder.Text = "待出库单:\n" + list.Join("\n"); 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 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(); List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => ids.Contains(t.objid)).ToList();
foreach (var item in wcsTasks) foreach (var item in wcsTasks)
{ {
if (string.IsNullOrEmpty(item.taskCode)) item.IsDelete = 1;
{ dbContext.Update(item);
dbContext.Remove(item);
}
else
{
item.IsDelete = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { IsDelete = 1 });
}
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
GetTask(); GetTask();
@ -1098,6 +1139,7 @@ namespace Khd.Core.Wpf.Form
dbContext.Update(baseEquip); dbContext.Update(baseEquip);
var wcsCmd = dbContext.WcsTask var wcsCmd = dbContext.WcsTask
.Where(t => t.taskStatus == 6 || t.taskStatus == 3) .Where(t => t.taskStatus == 6 || t.taskStatus == 3)
.Where(t=>t.nextPointId== 10)
.FirstOrDefault(); .FirstOrDefault();
if (wcsCmd == null) if (wcsCmd == null)
{ {
@ -1105,14 +1147,19 @@ namespace Khd.Core.Wpf.Form
} }
else else
{ {
if (wcsCmd.taskType == 32)//领料
if (wcsCmd.taskStatus == 3)
{ {
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.Update(wcsCmd);
dbContext.SaveChanges(); dbContext.SaveChanges();

Loading…
Cancel
Save