diff --git a/Application/WcsTaskApplication.cs b/Application/WcsTaskApplication.cs
index 1e98f5e..2f3ae35 100644
--- a/Application/WcsTaskApplication.cs
+++ b/Application/WcsTaskApplication.cs
@@ -341,24 +341,24 @@ namespace Application
///pad获取所有机台库存列表信息
///
///
- //public PadResponse GetAllMachineInfos()
- //{
- // PadResponse padResponse = new PadResponse();
- // try
- // {
- // List list = sqlSugarClient.Queryable().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 list = sqlSugarClient.Queryable().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;
+ }
///
///指定机台优先级接口:加急/不加急
diff --git a/SlnMesnac.WCS/WCS/BearAgv.cs b/SlnMesnac.WCS/WCS/BearAgv.cs
index fdeef4f..a41a253 100644
--- a/SlnMesnac.WCS/WCS/BearAgv.cs
+++ b/SlnMesnac.WCS/WCS/BearAgv.cs
@@ -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
}
}
}
diff --git a/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml
new file mode 100644
index 0000000..1b345b2
--- /dev/null
+++ b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml.cs b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml.cs
new file mode 100644
index 0000000..f0ec205
--- /dev/null
+++ b/SlnMesnac.WPF/Page/MannulResignBoxWindow.xaml.cs
@@ -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
+{
+ ///
+ /// CreateMoveWindow.xaml 的交互逻辑
+ ///
+ public partial class MannulResignBoxWindow : Window
+ {
+ private ISqlSugarClient? SqlSugarClient;
+ public readonly PlcAbsractFactory workShop3Plc;
+
+ public MannulResignBoxWindow()
+ {
+ InitializeComponent();
+ SqlSugarClient = App.ServiceProvider.GetService();
+ //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().Where(it => it.LocationCode == startCode).First();
+ WmsPalletInfo? wmsPalletInfo = SqlSugarClient.Queryable().InnerJoin((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();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SlnMesnac.WPF/Page/TaskHistoryControl.xaml b/SlnMesnac.WPF/Page/TaskHistoryControl.xaml
index 00742dd..5834431 100644
--- a/SlnMesnac.WPF/Page/TaskHistoryControl.xaml
+++ b/SlnMesnac.WPF/Page/TaskHistoryControl.xaml
@@ -68,6 +68,20 @@ ToolTip="Resource name: MaterialDesignPaperLightButton">
+
+
diff --git a/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs b/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs
index 8a21c80..4d45930 100644
--- a/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs
+++ b/SlnMesnac.WPF/ViewModel/TaskHistoryViewModel.cs
@@ -56,6 +56,13 @@ namespace SlnMesnac.WPF.ViewModel
window.ShowDialog();
}
+ [RelayCommand]
+ private void CreateResignBox()
+ {
+ MannulResignBoxWindow window = new MannulResignBoxWindow();
+ window.ShowDialog();
+ }
+
///
/// 获取任务列表
///