1.出库界面展示当前正在进行出库的单据

2.后台退出了入库模式 通知前台扫码枪退出入库
3.对接盟讯公司登录Mes接口
4.接口记录增加本地日志排查问题
This commit is contained in:
hehaibing-1996
2024-05-30 15:48:44 +08:00
parent aecc1dc4db
commit 46321e340b
19 changed files with 243 additions and 43 deletions

View File

@ -98,6 +98,12 @@ namespace WCS.BLL.DbModels
/// </summary>
[SugarColumn(IsIgnore = true)]
public int RowNumber { get; set; }
/// <summary>
/// 返回当前是否正在进行出库
/// </summary>
[SugarColumn(IsIgnore = true)]
public bool IsOuting { get; set; } = false;
}
}

View File

@ -291,6 +291,21 @@ namespace WCS.BLL.HardWare
}
//报警灯熄灭
WarningLight.CloseLight(TcpCleint);
//通知前台货架已结束入库
Task.Run(() =>
{
var warningModel = new WebSocketMessageModel()
{
IsWarning = false,
WarningType = WarningTypeEnum.,
StoreId = 0,
StoreCode = "",
ShelfCode = ShelfCode,
ShelfId = ShelfId,
ClientIp = WebSocketIpAddress,
};
WarningManager.SendWarning(warningModel);
});
}
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)

View File

@ -145,8 +145,8 @@ namespace WCS.BLL.Manager
.ToList();
foreach (var shelf in outStoreShelf)
{
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时5min未退出出库模式系统后台自动退出出库单[{shelf.OrderNumber}]");
shelf.GoOutOutstore();
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时5min未退出出库模式系统后台自动退出");
}
#endregion
@ -156,14 +156,14 @@ namespace WCS.BLL.Manager
.ToList();
foreach (var shelf in stockTakingShelf)
{
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时5min未退出盘点模式系统后台自动退出盘点单[{shelf.OrderNumber}]");
shelf.GoOutStocktaking();
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时5min未退出盘点模式系统后台自动退出");
}
#endregion
}
catch (Exception e)
{
Logs.Write("【定时任务:定时退出模式】" + e.Message,LogsType.Info);
Logs.Write("【定时任务:定时退出模式】" + e.Message, LogsType.Info);
}
}
});

View File

@ -474,23 +474,30 @@ namespace WCS.BLL.Services.Service
var recordsQueryable = DbHelp.db.Queryable<OutOrder>()
.Where(t => request.OrderExeStatus.Contains(t.OutOrderExeStatus))
.WhereIF(request.IsMXPD != null, t => t.IsMXPD == request.IsMXPD)
.WhereIF(LocalFile.Config.IsMx, t => t.CreateTime > DateTime.Now.AddDays(-3));
.WhereIF(LocalFile.Config.IsMx, t => t.CreateTime > DateTime.Now.AddDays(-3))
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.GroupName == LocalFile.Config.GroupName);
var totalCount = await recordsQueryable.CountAsync();
var records = await recordsQueryable
.OrderByDescending(t => t.CreateTime)
//.Take(request.PageSize)
.ToListAsync();
//获取后台当前正在进行出库的订单 将出库状态反馈给前端
var outingOrderNumbers = ShelfManager.Shelves
.Where(t => t.CurrentMode == HardWare.Mode.).Select(t => t.OrderNumber)
.ToList();
foreach (var record in records)
{
if (outingOrderNumbers.Contains(record.OrderNumber))
record.IsOuting = true;
}
return new PageQueryResponse<OutOrder>()
{
Code = 200,
Message = $"success",
Data = new PageQueryResponseData<OutOrder>()
{
//TotalCount = totalCount,
//MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
//Count = records.Count,
Lists = records.ToList()
}
};

View File

@ -5,12 +5,16 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TouchSocket.Core;
using WCS.BLL.Config;
using WCS.BLL.DbModels;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.BLL.Tool;
using WCS.DAL;
using WCS.DAL.Db.AuthDb;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.MXBackgroundThread;
using WCS.Model.ApiModel.User;
namespace WCS.BLL.Services.Service
@ -394,15 +398,67 @@ namespace WCS.BLL.Services.Service
}
else//登录模式需要校验密码
{
user = await AuthDbHelp.db.Queryable<UserBase>()
.Where(t => t.LoginName == request.UserName)
.FirstAsync();
#region
if (LocalFile.Config.IsMx)
{
#region
try
{
var body = new
{
uername = request.UserName,
password = request.PassWord,
};
var Result = ApiHelp.GetDataFromHttpShortTime<MXResponse>("http://192.168.2.23:9213/integrate/login/queryGenerLogin", body, "POST", true);
//账号密码验证成功
if (Result != null && Result.code == 200)
{
//判断系统中是否有对应用户
user = await AuthDbHelp.db.Queryable<UserBase>()
.Where(t => t.LoginName == request.UserName)
.FirstAsync();
//Mes登录成功后wcs这边也添加一个用户
if (user == null)
{
user = new UserBase()
{
LoginName = request.UserName,
Password = request.PassWord,
RoleIds = new List<int>() { 2 },
IsAdmin = false,
Time = DateTime.Now,
};
await AuthDbHelp.db.Insertable(user).ExecuteCommandAsync();
}
else if (user.Password != request.PassWord)
{
user.Password = request.PassWord;
await AuthDbHelp.db.Updateable(user).ExecuteCommandAsync();
}
}
//账号密码验证失败
else
{
}
}
catch (Exception e)
{
}
#endregion
}
#endregion
if (user == null)
user = await AuthDbHelp.db.Queryable<UserBase>()
.Where(t => t.LoginName == request.UserName)
.FirstAsync();
if (user == null)
{
return new ResponseCommon<UserBase>()
{
Code = 201,
Message = $"登录失败:用户名[{request.UserName}]不存在!",
Message = $"登录失败:用户名[{request.UserName}]不存在或密码输入错误",
Data = null
};
}

View File

@ -312,5 +312,47 @@ namespace WCS.BLL.Tool
return default(T);
}
}
public static T GetDataFromHttpShortTime<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
{
Guid guid = Guid.NewGuid();
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
try
{
if (isSaveLog)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}", LogsType.Api);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";
request.Timeout = 2000;
if (!string.IsNullOrEmpty(data))
{
string strContent = data; //参数data
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
dataStream.Write(strContent);
dataStream.Close();
}
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
if (isSaveLog)
Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}", LogsType.Api);
return JsonConvert.DeserializeObject<T>(retString);
}
catch (Exception ex)
{
Logs.Write($"【{guid}】请求调用遇到异常 异常信息为{ex.Message}");
return default(T);
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class MXResponse
{
public int code { get; set; }
public string msg { get; set; }
public object data { get; set; }
}
}

View File

@ -34,6 +34,7 @@ namespace WCS.Model.ApiModel.OutStore
}
public bool isSelected;
public int RowNumber { get; set; }
public bool IsOuting { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)

View File

@ -21,6 +21,10 @@ namespace WCS.Model.WebSocketModel
/// </summary>
public string ClientIp { get; set; }
public DateTime LastSendTime { get; set; }
/// <summary>
/// 消息创建时间 跟消息时效性有关
/// </summary>
public DateTime CreateTime { get; set; } = DateTime.Now;
public bool ClientIsReceived { get; set; }
//恢复正常需要消除的报警guid
@ -57,5 +61,6 @@ namespace WCS.Model.WebSocketModel
= 51,
= 52,
= 53,
= 54,
}
}

View File

@ -72,28 +72,45 @@ namespace WCS.WebApi.Controllers
finally
{
var guid = Guid.NewGuid();
//TO DO如何将记日志的 和不记日志的分开 解耦
if (!context.Request.Path.ToString().Contains("getInterfaceRecord"))
{
try
{
Logs.Write($"[记录接口日志]{guid},开始记录{context.Request.Path.ToString()}", LogsType.Api);
var logRecord = new SystemApiLogRecord()
{
DeviceIp = context?.Connection?.RemoteIpAddress?.ToString(),
RequestUrl = context.Request.Path,
RequestUrl = context.Request?.Path,
RequestBody = requestBody,
QueryString = context.Request.QueryString.ToString(),
QueryString = context.Request?.QueryString.ToString(),
IsResponse = true,
ResponseJson = responseBody,
RequestTime = requestTime,
ResponseTime = DateTime.Now,
ExecutionTime = stopwatch.ElapsedMilliseconds
};
await DbHelp.dbLog.Insertable(logRecord).ExecuteCommandAsync();
Task.Run(() =>
{
try
{
DbHelp.dbLog.Insertable(logRecord).ExecuteCommand();
}
catch (Exception ex)
{
Logs.Write($"[记录接口日志]{guid}保存数据失败!发生异常:" + ex.Message, LogsType.Api);
}
});
}
catch (Exception e)
{
//TO DO txt记录失败的日志和响应实体
Logs.Write($"[记录接口日志]{guid}失败!发生异常:" + e.Message, LogsType.Api);
}
}
else
Logs.Write($"[记录接口日志]{guid}不记录getInterfaceRecord", LogsType.Api);
}
}
}

View File

@ -45,7 +45,7 @@ namespace WebApi
{
MXBackgroundThread.InitBackgroundThread();
var str = string.Empty;
//MXBackgroundThread.SendDingDingMsg("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", new List<string> { "104379" }, ref str);
MXBackgroundThread.SendDingDingMsg("<22><>̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", new List<string> { "104379" }, ref str);
}

View File

@ -71,6 +71,8 @@ namespace 货架标准上位机
/// 是否在入库模式中
/// </summary>
public bool IsInstoreMode { get; set; }
public DateTime IsInstoreModeTime { get; set; } = DateTime.MinValue;
/// <summary>
/// 串口号
/// </summary>

View File

@ -184,6 +184,7 @@ namespace 货架标准上位机.ViewModel
{
Logs.Write($"扫码模组{scanner.TempCode},进入入库模式成功!", LogsType.Scanner);
scanner.IsInstoreMode = true;
scanner.IsInstoreModeTime = DateTime.Now;
scanner.ShelfCode = Result.Data.ShelfCode;
scanner.ModulesStr = Result.Data.ModulesStr;
@ -233,7 +234,6 @@ namespace 货架标准上位机.ViewModel
scanner.IsInstoreMode = false;
scanner.ShelfCode = string.Empty;
scanner.ModulesStr = string.Empty;
}
}
catch (Exception ex)

View File

@ -159,7 +159,7 @@ namespace 货架标准上位机.ViewModel
if (Result != null && Result.Code == 200)
{
Growl.Warning("已成功开始出库!");
RefreshDataGridItemSource();
RefreshOutOrderList(SelectedOutOrderNumber);
}
else if (Result != null)
{
@ -203,7 +203,8 @@ namespace 货架标准上位机.ViewModel
if (Result != null && Result.Code == 200)
{
Growl.Warning("已成功结束出库!");
RefreshDataGridItemSource();
RefreshOutOrderList(SelectedOutOrderNumber);
//RefreshDataGridItemSource();
}
else if (Result != null)
{

View File

@ -52,8 +52,8 @@
</WrapPanel>
</Border>
<StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Margin="5" FontWeight="Bold" FontSize="24" Text="停止入库码"></TextBlock>
<Image Margin="5" Width="120" Height="120" Source="/Resources/goOutInstore.png"></Image>
<TextBlock Margin="5" FontWeight="Bold" FontSize="24" Text="停止入库码"></TextBlock>
<Image Margin="5" Width="125" Height="125" Source="/Resources/goOutInstore.png"></Image>
</StackPanel>
<!--<GroupBox Grid.Column="1" Header="停止入库码" Padding="10">-->
<!--<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">-->

View File

@ -94,7 +94,6 @@
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible">
<ListView FontSize="18" ItemsSource="{Binding OutOrderList}" SelectedItem="{Binding SelectedOutOrder,Mode=TwoWay}" PreviewMouseWheel="ListView_PreviewMouseWheel">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
@ -104,6 +103,30 @@
<GridViewColumn DisplayMemberBinding="{Binding OrderNumber}"/>
</GridView>
</ListView.View>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource ListViewItemBaseStyle}">
<Style.Triggers>
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="Background" Value="CadetBlue"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ListBoxItem.IsSelected" Value="true" />
<Condition Property="Selector.IsSelectionActive" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="CadetBlue"/>
</MultiTrigger>
<DataTrigger Binding="{Binding IsOuting}" Value="True">
<!--<Setter Property="Background" Value="Green"/>-->
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding IsOuting}" Value="False">
<!--<Setter Property="Background" Value="White"/>-->
<Setter Property="Foreground" Value="Black" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</ScrollViewer>
</Border>
@ -112,17 +135,9 @@
<Border CornerRadius="3" Margin="1" Grid.Row="0" Grid.Column="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5">
<Grid>
<Grid.RowDefinitions>
<!--<RowDefinition Height="1*"></RowDefinition>-->
<RowDefinition Height="12*"></RowDefinition>
</Grid.RowDefinitions>
<!--<StackPanel VerticalAlignment="Center" Orientation="Horizontal" >
<TextBlock FontSize="24">
</TextBlock>
<TextBlock Text="{Binding SelectedOutOrderNumber}" FontSize="24">
</TextBlock>
</StackPanel>-->
<DataGrid Grid.Row="0"
SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}"
@ -164,6 +179,10 @@
<ColumnDefinition Width="5*"></ColumnDefinition>
<ColumnDefinition Width="5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0">
<Rectangle Width="12" Height="12" Fill="Red"></Rectangle>
<TextBlock Text="列表中红色字体表示单据正在发料" FontSize="14"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1">
<TextBlock Text="当前状态:" FontSize="22">
</TextBlock>

View File

@ -55,11 +55,12 @@ namespace 货架标准上位机
HandyControl.Controls.MessageBox.Warning("请输入账号!", "提示");
return;
}
if (string.IsNullOrEmpty(pass))
{
HandyControl.Controls.MessageBox.Warning("请输入密码!", "提示");
return;
}
if (!LocalFile.Config.IsMx)
if (string.IsNullOrEmpty(pass))
{
HandyControl.Controls.MessageBox.Warning("请输入密码!", "提示");
return;
}
try
{
@ -73,9 +74,11 @@ namespace 货架标准上位机
PassWord = pass,
IsNoLogin = false,
};
if (LocalFile.Config.IsMx)
body.IsNoLogin = true;
var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "user/userLogin",
body, "POST");
if (Result!= null && Result.Code != 200)
if (Result != null && Result.Code != 200)
{
HandyControl.Controls.MessageBox.Warning(Result.Message, "提示");
return;

View File

@ -13,6 +13,7 @@ using TouchSocket.Core;
using TouchSocket.Http.WebSockets;
using TouchSocket.Sockets;
using WCS.Model.WebSocketModel;
using .Views.Controls;
namespace
{
@ -121,6 +122,18 @@ namespace 货架标准上位机
TextBoxLog.AddLog(warning.WarningMessage, "InstoreLog", DateTime.Now);
client.Send(e.DataFrame.ToText());
break;
case WarningTypeEnum.:
var scanner = ScannerManager.Scanners.Where(t => t.IsInstoreMode && t.ShelfCode == warning.ShelfCode && t.IsInstoreModeTime < warning.CreateTime)
.FirstOrDefault();
if (scanner != null)
{
scanner.IsInstoreMode = false;
scanner.ShelfCode = string.Empty;
scanner.ModulesStr = string.Empty;
scanner.ScannerDisplayControl.RefreshValues(string.Empty, string.Empty);
}
break;
default: break;
}
return;

View File

@ -2,9 +2,9 @@
//连接不上加SslMode=none;
"MySql": "server=localhost;Database=db1;Uid=root;Pwd=123456;Convert Zero Datetime=True",
//货架服务器的IP和端口号
"ApiIpHost": "http://127.0.0.1:8888/",
"ApiIpHost": "http://192.168.9.183:8888/",
//WebSocket的地址
"WebSocketUrl": "ws://127.0.0.1:7789/ws",
"WebSocketUrl": "ws://192.168.9.183:7789/ws",
//货架分区
"GroupName": [ "C0"],
//设备类型 可以配置为每个电脑不一样