1.获取全部机台信息

master
zhangxy 5 months ago
parent 0c16278d53
commit 67464a41f8

@ -341,24 +341,24 @@ namespace Application
///pad获取所有机台库存列表信息
/// </summary>
/// <returns></returns>
//public PadResponse GetAllMachineInfos()
//{
// PadResponse padResponse = new PadResponse();
// try
// {
// List<WmsMachineInfo> list = sqlSugarClient.Queryable<WmsMachineInfo>().Where(x => !string.IsNullOrEmpty(x.MachineCode)).ToList();
// padResponse.code = "200";
// padResponse.message = "成功";
// padResponse.data = list;
// }
// catch (Exception ex)
// {
// _logger.Error(ex.Message);
// padResponse.code = "301";
// padResponse.message = "失败:" + ex.Message;
// }
// return padResponse;
//}
public PadResponse GetAllMachineInfos()
{
PadResponse padResponse = new PadResponse();
try
{
List<WmsMachineInfo> list = sqlSugarClient.Queryable<WmsMachineInfo>().Where(x => !string.IsNullOrEmpty(x.MachineCode)).ToList();
padResponse.code = "200";
padResponse.message = "成功";
padResponse.data = list;
}
catch (Exception ex)
{
_logger.Error(ex.Message);
padResponse.code = "301";
padResponse.message = "失败:" + ex.Message;
}
return padResponse;
}
/// <summary>
///指定机台优先级接口:加急/不加急

@ -11,6 +11,7 @@ using SlnMesnac.WCS.Library;
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using TouchSocket.Sockets;
namespace SlnMesnac.WCS.WCS
{
@ -258,19 +259,79 @@ namespace SlnMesnac.WCS.WCS
//workShop3Plc.writeBoolByAddress(StaticData.GetPlcAddress("3#机台校验失败提示"), false);
endLocation.LocationStatus = 0;
endLocation.ContainerCode = task.PalletInfoCode;
sqlSugarClient.AsTenant().BeginTran();
try
#region 尝试入库
int retrytime = 0;
bool successflag = false;
while (retrytime <= 3)
{
sqlSugarClient.Updateable(endLocation).ExecuteCommand();
sqlSugarClient.Deleteable(task).ExecuteCommand();
sqlSugarClient.AsTenant().CommitTran();
_logger.Agv($"Agv:{task.NextPointNo};完成{task.TaskName},起点:{task.CurrPointNo},终点:{task.EndPointNo}");
sqlSugarClient.AsTenant().BeginTran();
try
{
int LocationAffectedrow = sqlSugarClient.Updateable(endLocation).ExecuteCommand();
int DeleteAffectedrow = sqlSugarClient.Deleteable(task).ExecuteCommand();
sqlSugarClient.AsTenant().CommitTran();
if (LocationAffectedrow > 0 && DeleteAffectedrow > 0)
{
_logger.Agv($"Agv:{task.NextPointNo};完成{task.TaskName},起点:{task.CurrPointNo},终点:{task.EndPointNo}");
retrytime = 4;
successflag = true;
}
else
{
retrytime += 1;
}
}
catch (Exception ex)
{
retrytime += 1;
sqlSugarClient.AsTenant().RollbackTran();
_logger.Error("SupplyEmptyPalletTaskHandlerAsync提交事务异常:" + ex.Message);
_logger.Error($"正在进行第{retrytime}次重试......");
}
}
catch (Exception ex)
if (successflag!= true)
{
sqlSugarClient.AsTenant().RollbackTran();
_logger.Error("SupplyEmptyPalletTaskHandlerAsync提交事务异常:" + ex.Message);
workShop3Plc.writeBoolByAddress("DB100.DBX120.0", true);
try
{
_logger.Error($"多次重试失败,正在上锁问题库位......");
endLocation.LocationStatus = 1;
sqlSugarClient.AsTenant().BeginTran();
sqlSugarClient.Updateable(endLocation).ExecuteCommand();
sqlSugarClient.AsTenant().CommitTran();
}
catch (Exception ex) {
_logger.Error($"上锁失败,正在重试......");
sqlSugarClient.AsTenant().RollbackTran();
Thread Lockthread = new Thread(new ThreadStart(delegate ()
{
bool Lockflag = false;
while (!Lockflag)
{
try
{
endLocation.LocationStatus = 1;
sqlSugarClient.AsTenant().BeginTran();
sqlSugarClient.Updateable(endLocation).ExecuteCommand();
sqlSugarClient.AsTenant().CommitTran();
Lockflag = true;
}
catch
{
sqlSugarClient.AsTenant().RollbackTran();
Thread.Sleep(1000);
}
}
}));
Lockthread.Start();
}
}
retrytime = 0;
successflag = false;
#endregion
}
}
}

@ -0,0 +1,53 @@
<Window x:Class="SlnMesnac.WPF.Page.MannulResignBoxWindow"
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:SlnMesnac.WPF.Page"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
Title="CreateMoveWindow" Height="450" Width="800" Background="#062241" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*" />
<RowDefinition Height="0.6*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="手动入库" Foreground="White" FontSize="25" HorizontalAlignment="Center" />
<!-- 中间部分:两个 ComboBox -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 起点 ComboBox -->
<ComboBox x:Name="StartComboBox" Foreground="LimeGreen"
Grid.Column="0"
Margin="20"
FontSize="20"
VerticalAlignment="Center"
materialDesign:HintAssist.Hint="选择库位" />
<!-- 终点 ComboBox -->
<TextBox x:Name="BoxTextbox" Foreground="LimeGreen"
Grid.Column="1"
Margin="20"
FontSize="20"
VerticalAlignment="Center"
materialDesign:HintAssist.Hint="在此输入箱子编号如SHS000000030" />
</Grid>
<!-- 底部:确认按钮 -->
<Button x:Name="ConfirmButton"
Grid.Row="2"
Content="确认"
Width="200"
Height="50"
FontSize="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="ConfirmButton_Click" />
</Grid>
</Window>

@ -0,0 +1,110 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Model.domain;
using SlnMesnac.Model.dto.taskType;
using SlnMesnac.Plc;
using SlnMesnac.WPF.Library;
using SqlSugar;
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.Shapes;
using SlnMesnac.Business.@base;
using TouchSocket.Core;
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
namespace SlnMesnac.WPF.Page
{
/// <summary>
/// CreateMoveWindow.xaml 的交互逻辑
/// </summary>
public partial class MannulResignBoxWindow : Window
{
private ISqlSugarClient? SqlSugarClient;
public readonly PlcAbsractFactory workShop3Plc;
public MannulResignBoxWindow()
{
InitializeComponent();
SqlSugarClient = App.ServiceProvider.GetService<ISqlSugarClient>();
//BaseBusiness NewBase = new BaseBusiness(App.ServiceProvider);
//workShop3Plc = NewBase.GetPlcByKey("workShop3Plc");
LoadLocations(); // 初始化 ComboBox 选项
}
// 加载地点选项3001-3024
private void LoadLocations()
{
for (int i = 301; i <= 312; i++)
{
this.StartComboBox.Items.Add(i.ToString() + "A");
this.StartComboBox.Items.Add(i.ToString() + "B");
}
StartComboBox.Items.Add("异常库位3066");
}
// 确认按钮点击事件
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
{
string startCode = StartComboBox.SelectedItem?.ToString();
string BoxCode = BoxTextbox.Text .ToString();
if(SqlSugarClient == null)
{
MessageBox.Show("SqlSugarClient为空");
return;
}
if (string.IsNullOrEmpty(startCode))
{
MessageBox.Show("请输入入库库位");
return;
}
if (startCode == BoxCode)
{
MessageBox.Show("请检查格式!");
return;
}
if (startCode == "异常库位3066")
{
startCode = "3066";
}
WmsBaseLocation? startLocation = SqlSugarClient.Queryable<WmsBaseLocation>().Where(it => it.LocationCode == startCode).First();
WmsPalletInfo? wmsPalletInfo = SqlSugarClient.Queryable<WmsPalletInfo>().InnerJoin<WmsBaseLocation>((x,y) => x.Amount == 0 && y.LocationCode == startCode).First();
if (wmsPalletInfo == null) {
MessageBox.Show("起点库位托盘未清空,无法入库!请检查!");
return;
}
try
{
SqlSugarClient.AsTenant().BeginTran();
//锁定库位
startLocation.LocationStatus = 0;
startLocation.ContainerCode = BoxCode;
SqlSugarClient.Updateable(startLocation).ExecuteCommand();
SqlSugarClient.AsTenant().CommitTran();
//workShop3Plc.writeBoolByAddress("DB100.DBX120.0", false);
MessageBox.Show($"库位{startCode},入库{BoxCode}");
}
catch (Exception ex)
{
MessageBox.Show($"生成入库任务提交事务异常:{ex.Message}");
SqlSugarClient.AsTenant().RollbackTran();
}
this.Close();
}
}
}

@ -68,6 +68,20 @@ ToolTip="Resource name: MaterialDesignPaperLightButton">
<TextBlock Text="创建移库任务" />
</StackPanel>
</Button>
<Button Grid.Row="1" Grid.Column="4" Height="50" Width="220" FontSize="22" Margin="10"
Background="YellowGreen" Foreground="White" Command="{Binding CreateResignBoxCommand}"
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
Style="{StaticResource MaterialDesignPaperLightButton}"
ToolTip="Resource name: MaterialDesignPaperLightButton">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<materialDesign:PackIcon Kind="Magnify" Width="23" Height="23" Margin="5" />
<TextBlock Text="手动入库任务" />
</StackPanel>
</Button>
</Grid>
<Grid Grid.Row="1">
<Border BorderBrush="#0288d1" BorderThickness="0" CornerRadius="2" Background="Transparent">

@ -56,6 +56,13 @@ namespace SlnMesnac.WPF.ViewModel
window.ShowDialog();
}
[RelayCommand]
private void CreateResignBox()
{
MannulResignBoxWindow window = new MannulResignBoxWindow();
window.ShowDialog();
}
/// <summary>
/// 获取任务列表
/// </summary>

Loading…
Cancel
Save