master
1 year ago
parent e29b760cd2
commit 914fc7d33c

@ -163,8 +163,7 @@ namespace Khd.Core.Application
if (baseEquip != null)
{
var wcsTask = _dbContext.WcsTask
.Where(t => t.taskType == 32 || t.taskType == 48)
.Where(t => t.nextPointId == baseEquip.objid || t.currPointId == baseEquip.objid)
.Where(t => (t.taskType == 32 || t.taskType == 48)&&(t.endPointId == baseEquip.objid || t.currPointId == baseEquip.objid))
.FirstOrDefault();
if (wcsTask != null)
{

@ -608,7 +608,7 @@ namespace Khd.Core.Wcs.Wcs
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
bool task = dbContext.WcsTask.Where(t => t.nextPointId == 28 && t.taskStatus <= 5).Any();
bool task = dbContext.WcsTask.Where(t => t.nextPointId == 28 && t.useFlag == 1 && t.taskStatus <= 5).Any();
if (!task)
{
var wmsProductInstock = dbContext.WmsProductInstock
@ -1690,9 +1690,10 @@ namespace Khd.Core.Wcs.Wcs
decimal? needNumber = order.TotalAmount - order.realOutstockAmount;
foreach (var task in tasks)
{
WmsRawStock wmsRawStock = rawStock.Where(t => t.palletInfoCode == task.containerNo).First();
needNumber -= wmsRawStock.totalAmount - wmsRawStock.frozenAmount;
WmsBaseLocation wmsBaseLocation = AllWmsBaseLocations.Where(t => t.locationCode == wmsRawStock.locationCode).First();
var wmsRawStock = rawStock.Where(t => t.palletInfoCode == task.containerNo && t.materialId == order.MaterialId && t.saleOrderId == order.SaleOrderId).ToList();
decimal? total = wmsRawStock.Sum(t => t.totalAmount - t.frozenAmount);
needNumber -= total;
WmsBaseLocation wmsBaseLocation = AllWmsBaseLocations.Where(t => t.locationCode == task.currPointNo).First();
index = wmsBaseLocation.locRow;
}
if (needNumber <= 0)

@ -423,10 +423,11 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskStatus == 5)
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
if (item.taskType == 66)//移库
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
using var dbContextTransaction = dbContext.Database.BeginTransaction();
try
{
@ -470,6 +471,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 38)//出库
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
var wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(t => t.productOutstockId == item.orderId&&t.executeStatus == "1" && t.locationCode == item.currPointNo);
var wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == item.orderId);
if (wmsProductOutstockDetail != null && wmsProductOutstock != null)
@ -509,6 +512,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 33)//原材料到背板安装
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
WmsRawOutstock? wmsRawOutstock = dbContext.WmsRawOutstock.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
if (wmsRawOutstock != null)
{
@ -535,6 +540,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 34)//半成品入库
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = item.containerNo;
@ -592,6 +599,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 46)//该任务结束后立刻生成一个新的返库任务但是是否使用标志未0等待mes通知
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
var wmsRawOutStock = dbContext.WmsRawOutstock.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
if (wmsRawOutStock != null && wmsRawOutstockDetail != null)
@ -658,6 +667,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 28)//柜体拆分到原材料
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = item.containerNo;
@ -703,6 +714,8 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 47)
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = item.containerNo;

@ -427,12 +427,12 @@ namespace Khd.Core.Wcs.Wcs
{
new()
{
positionCode = wmsBaseLocation.agvPositionCode,
positionCode = startEquip.agvPositionCode ,
type = "05"//设备
},
new()
{
positionCode = startEquip.agvPositionCode,
positionCode = wmsBaseLocation.agvPositionCode,
type = "05"//库位
},
},
@ -470,45 +470,45 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
else if (item.taskType == 100)//盘库
{
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == item.endPointId);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
var agvTask = new RequestAGVTaskDto
{
reqCode = StaticData.SnowId.NextId().ToString(),
positionCodePath = new List<Position>
{
new()
{
positionCode =wmsBaseLocation.agvPositionCode,
type = "05"
},
new()
{
positionCode =endEquip.agvPositionCode,
type = "00"
},
},
ctnrTyp = "1",
taskTyp = "F504"
};
string message = JsonConvert.SerializeObject(agvTask);
string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
var reponseMessage = JsonConvert.DeserializeObject<ReponseMessage>(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
dbContext.SaveChanges();
}
else
{
_logger.Info("CTU下发出库任务失败" + reponseMessage?.message);
}
}
//else if (item.taskType == 100)//盘库
//{
// BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == item.endPointId);
// WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
// var agvTask = new RequestAGVTaskDto
// {
// reqCode = StaticData.SnowId.NextId().ToString(),
// positionCodePath = new List<Position>
// {
// new()
// {
// positionCode =wmsBaseLocation.agvPositionCode,
// type = "05"
// },
// new()
// {
// positionCode =endEquip.agvPositionCode,
// type = "00"
// },
// },
// ctnrTyp = "1",
// taskTyp = "F504"
// };
// string message = JsonConvert.SerializeObject(agvTask);
// string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
// var reponseMessage = JsonConvert.DeserializeObject<ReponseMessage>(result);
// if (reponseMessage != null && reponseMessage.code == "0")
// {
// item.taskCode = reponseMessage.data;
// item.taskStatus = 1;
// dbContext.Update(item);
// dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
// dbContext.SaveChanges();
// }
// else
// {
// _logger.Info("CTU下发出库任务失败" + reponseMessage?.message);
// }
//}
}
else
{

@ -1746,7 +1746,7 @@
<hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid>
</TabItem>
<TabItem x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem Visibility="Collapsed" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@ -1942,100 +1942,6 @@
<Button Content="一键收料" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="callPlc_Click"/>
<Button Content="执行CTU入库任务" Visibility="Hidden" Click="btnCtuInConfirmBox_Click" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White"/>
</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">
<TextBlock
Width="152"
Height="37"
Text="业务类型 :"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBlock x:Name="cbxType" Margin="0,20,400,0" Width="180" Height="50" Text="入库" />
<TextBlock
Width="152"
Height="36"
Text="料箱 :"
FontSize="25" Margin="0,30,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtBox" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,15,400,0" KeyDown="txtBox_KeyDown"/>
<TextBlock
Width="152"
Height="39"
Text="条码:"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtBarCode" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,20,400,0" TextChanged="txtBarCode_KeyDown"/>
<Button Content="清除料箱条码" FontSize="25" Margin="400,-180,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearRFID_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="清除条码" FontSize="25" Margin="400,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearBarCode_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock
Width="152"
Height="42"
Text="已扫描数量:"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtScan" Style="{StaticResource XingHaoBianMaYangShi}" IsReadOnly="True"
Width="180" Height="50" Margin="0,10,400,0" IsEnabled="False" />
<Button Content="确认" FontSize="25" Margin="150,30,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="132" Click="btnConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="背负式小车捡料完成" FontSize="25" Margin="50,50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnBearConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="执行小车入库任务" FontSize="25" Margin="500,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnCtuInConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
</Border>-->
</StackPanel>
</StackPanel>
</StackPanel>
@ -2062,6 +1968,9 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="2" 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"/>
<TextBlock Text="待执行CTU任务数:" Visibility="Hidden" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="50"/>

@ -147,6 +147,11 @@ namespace Khd.Core.Wpf.Form
};
RefreshPlcThread.Start();
Thread OutOrderThread = new Thread(OutOrderTimer)
{
IsBackground = true
};
OutOrderThread.Start();
//Thread ddjThread = new Thread(ddjTimer);
//ddjThread.Start();
@ -260,6 +265,36 @@ namespace Khd.Core.Wpf.Form
}
}
private void OutOrderTimer(object? obj)
{
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();
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
List<WmsRawOutstock> wmsRawOutstocks = dbContext.WmsRawOutstock.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.auditStatus == "1")
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => t.outstockAmount > t.realOutstockAmount)
.ToList();
List<string> list = wmsRawOutstocks.Select(t => t.endStationCode).ToList();
Dispatcher.Invoke(() =>
{
this.OutOrder.Text = "待出库单:\n" + list.Join("\n");
});
}
catch
{
}
Thread.Sleep(3000);
}
}
Dictionary<string, string> agvDic = new Dictionary<string, string>
{
{"6011","五楼潜伏" },
@ -1080,8 +1115,8 @@ namespace Khd.Core.Wpf.Form
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
baseEquip.endStationCode = string.Empty;
dbContext.Update(baseEquip);
var wcsCmd = dbContext.WcsCmd
.Where(t => t.cmdStatus == 6 || t.cmdStatus == 3)
var wcsCmd = dbContext.WcsTask
.Where(t => t.taskStatus == 6 || t.taskStatus == 3)
.FirstOrDefault();
if (wcsCmd == null)
{
@ -1089,28 +1124,17 @@ namespace Khd.Core.Wpf.Form
}
else
{
WcsTask? wcsTask = dbContext.WcsTask.FirstOrDefault(t => t.objid == wcsCmd.taskId && t.nextPointId == 10);
if (wcsTask == null)
{
MessageBox.Show("未查询到当前有背负式Agv由装配区到捡料区任务");
return;
}
if (wcsCmd.cmdStatus == 3)
if (wcsCmd.taskStatus == 3)
{
wcsCmd.cmdStatus = 4;
wcsTask.taskStatus = 4;
wcsCmd.taskStatus = 4;
}
else if (wcsCmd.cmdStatus == 6)
else if (wcsCmd.taskStatus == 6)
{
wcsCmd.cmdStatus = 7;
wcsTask.taskStatus = 7;
wcsCmd.taskStatus = 7;
}
dbContext.Update(wcsCmd);
dbContext.Update(wcsTask);
dbContext.SaveChanges();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 7 });
dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.taskId).Update(t => new WcsTaskLog { taskStatus = 7 });
MessageBox.Show("背负式Agv任务确认完成成功");
}
}

@ -16,14 +16,14 @@
"Slot": 1,
"Code": 0
},
//{
// "IP": "192.168.2.31",
// "Port": 102, //102
// "CpuType": 40,
// "Rack": 0,
// "Slot": 1,
// "Code": 1
//},
{
"IP": "192.168.2.31",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 1
},
{
"IP": "192.168.2.220",
"Port": 102, //102

Loading…
Cancel
Save