pry 2 years ago
parent
commit
031da113f0
14 changed files with 153 additions and 45 deletions
  1. +54
    -12
      BPASmartClient.AGV/AGVHelper.cs
  2. +2
    -2
      BPASmartClient.AgvApi/Factory.cs
  3. +3
    -0
      BPASmartClient.AgvApi/PersonHub.cs
  4. +1
    -1
      BPASmartClient.AgvApi/Program.cs
  5. +2
    -2
      BPASmartClient.CustomResource/Pages/Model/AlarmInfo.cs
  6. +1
    -0
      BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
  7. +5
    -3
      BPASmartClient.HubHelper/HubHelper.cs
  8. +1
    -1
      FryPot_DosingSystem/App.xaml.cs
  9. +1
    -1
      FryPot_DosingSystem/Model/RecipeModel.cs
  10. +15
    -5
      FryPot_DosingSystem/View/NewRecipeView.xaml
  11. +2
    -1
      FryPot_DosingSystem/View/RecipeSendDownView.xaml
  12. +42
    -13
      FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs
  13. +22
    -2
      FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs
  14. +2
    -2
      TestDemo/Form1.cs

+ 54
- 12
BPASmartClient.AGV/AGVHelper.cs View File

@@ -8,6 +8,7 @@ using System.Web;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Http; using System.Net.Http;
using System.Configuration; using System.Configuration;
using System.Security.Cryptography;


namespace BPASmartClient.AGV namespace BPASmartClient.AGV
{ {
@@ -15,10 +16,10 @@ namespace BPASmartClient.AGV
{ {
public static AGVHelper _Instance { get; set; } public static AGVHelper _Instance { get; set; }
public static AGVHelper GetInstance => _Instance ?? (_Instance = new AGVHelper()); public static AGVHelper GetInstance => _Instance ?? (_Instance = new AGVHelper());
public AGVHelper()
public AGVHelper()
{ {
} }
/// <summary> /// <summary>
/// 获取配置文件信息 /// 获取配置文件信息
@@ -39,7 +40,7 @@ namespace BPASmartClient.AGV
return null; return null;
} }
public string HttpRequest(string url, string head, string body) public string HttpRequest(string url, string head, string body)
{
{
return PostData(url, head, body); return PostData(url, head, body);
} }
public string PostData(string url, string head, string body) public string PostData(string url, string head, string body)
@@ -71,10 +72,28 @@ namespace BPASmartClient.AGV
return retString;//返回响应报文 return retString;//返回响应报文
} }
/// <summary> /// <summary>
/// MD5哈希摘要转16进制
/// </summary>
/// <param name="body"></param>
/// <returns></returns>
public string MD5Deal(string body)
{
//如果启用签名 用MD5 哈希摘要 再转16进制
MD5 md5 = MD5.Create();
byte[] bte = md5.ComputeHash(Encoding.UTF8.GetBytes(body));
StringBuilder build = new StringBuilder();
for (int i = 0; i < bte.Length; i++)
{
build.Append(bte[i].ToString("X"));
}
return build.ToString();
}
/// <summary>
/// AGV去1号线体装桶 /// AGV去1号线体装桶
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string AgvToLineOneLoadRoller(string robotJobId)
public string AgvToLineOneLoadRoller(string robotJobId)
{ {
//string url = AGVRequestUrl.GetInstance.TaskSendUrl; //string url = AGVRequestUrl.GetInstance.TaskSendUrl;
////请求报文头 ////请求报文头
@@ -85,7 +104,7 @@ namespace BPASmartClient.AGV
//HttpRequestHeaderModel.GetInstance.version = "2.8"; //HttpRequestHeaderModel.GetInstance.version = "2.8";
//string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance);
////请求报文体 ////请求报文体
//AGVModel.GetInstance.robotJobId =robotJobId ;//上游提供
//AGVModel.GetInstance.robotJobId = robotJobId;//上游提供
//AGVModel.GetInstance.warehouseId = 123; //仓库编号 //AGVModel.GetInstance.warehouseId = 123; //仓库编号
//AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级
//AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行
@@ -100,7 +119,8 @@ namespace BPASmartClient.AGV
//AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互
//AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance;
//string body = JsonConvert.SerializeObject(AGVModel.GetInstance); //string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
//// string newBody = String.Join(",\r\n", bodyData.Split(','));//格式处理,看需求
//// string newBody = String.Join(",\r\n", body.Split(','));//格式处理,看需求

////货位到货位 ////货位到货位
////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号
////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号
@@ -110,6 +130,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -157,6 +179,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data= HttpRequest(url, head, body); //string data= HttpRequest(url, head, body);
//object objData= JsonConvert.DeserializeObject(data); //object objData= JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -204,6 +228,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -251,6 +277,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -298,6 +326,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -345,6 +375,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -392,6 +424,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -439,6 +473,8 @@ namespace BPASmartClient.AGV
////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互
////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance;
////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance);
////启用签名
////url = url + "?sign=" + MD5Deal(body);
//string data = HttpRequest(url, head, body); //string data = HttpRequest(url, head, body);
//object objData = JsonConvert.DeserializeObject(data); //object objData = JsonConvert.DeserializeObject(data);
//if (objData != null && objData is HttpResponseModel response) //if (objData != null && objData is HttpResponseModel response)
@@ -465,6 +501,8 @@ namespace BPASmartClient.AGV
AGVTaskCancelModel.GetInstance.robotJobId = robotJobId; AGVTaskCancelModel.GetInstance.robotJobId = robotJobId;
AGVTaskCancelModel.GetInstance.warehouseId = 123;//仓库编号 AGVTaskCancelModel.GetInstance.warehouseId = 123;//仓库编号
string body = JsonConvert.SerializeObject(AGVTaskCancelModel.GetInstance); string body = JsonConvert.SerializeObject(AGVTaskCancelModel.GetInstance);
//启用签名
//url = url + "?sign=" + MD5Deal(body);
string data = HttpRequest(url, head, body); string data = HttpRequest(url, head, body);
object objData = JsonConvert.DeserializeObject(data); object objData = JsonConvert.DeserializeObject(data);
if (objData != null && objData is HttpResponseModel response) if (objData != null && objData is HttpResponseModel response)
@@ -490,7 +528,9 @@ namespace BPASmartClient.AGV
//请求报文体 //请求报文体
AGVTaskCompleteNotifyModel.GetInstance.robotJobId = robotJobId; AGVTaskCompleteNotifyModel.GetInstance.robotJobId = robotJobId;
AGVTaskCompleteNotifyModel.GetInstance.warehouseId = 123;//仓库编号 AGVTaskCompleteNotifyModel.GetInstance.warehouseId = 123;//仓库编号
string body=JsonConvert.SerializeObject(AGVTaskCompleteNotifyModel.GetInstance);
string body = JsonConvert.SerializeObject(AGVTaskCompleteNotifyModel.GetInstance);
//启用签名
//url = url + "?sign=" + MD5Deal(body);
string data = HttpRequest(url, head, body); string data = HttpRequest(url, head, body);
object objData = JsonConvert.DeserializeObject(data); object objData = JsonConvert.DeserializeObject(data);
if (objData != null && objData is HttpResponseModel response) if (objData != null && objData is HttpResponseModel response)
@@ -506,7 +546,7 @@ namespace BPASmartClient.AGV
/// <param name="jobId">任务编号</param> /// <param name="jobId">任务编号</param>
/// <param name="msgId">消息编号</param> /// <param name="msgId">消息编号</param>
/// <returns></returns> /// <returns></returns>
public string UpDownFeedBack(string agvCode,string jobId,string msgId)
public string UpDownFeedBack(string agvCode, string jobId, string msgId)
{ {
string url = AGVRequestUrl.GetInstance.TaskCompleteUrl; string url = AGVRequestUrl.GetInstance.TaskCompleteUrl;
//请求报文头 //请求报文头
@@ -518,9 +558,11 @@ namespace BPASmartClient.AGV
string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance);
//请求报文体 //请求报文体
AGVLoadInteracteModel.GetInstance.agvCode = agvCode; AGVLoadInteracteModel.GetInstance.agvCode = agvCode;
AGVLoadInteracteModel.GetInstance.jobId = jobId;
AGVLoadInteracteModel.GetInstance.msgId= msgId;
string body=JsonConvert.SerializeObject(AGVLoadInteracteModel.GetInstance);
AGVLoadInteracteModel.GetInstance.jobId = jobId;
AGVLoadInteracteModel.GetInstance.msgId = msgId;
string body = JsonConvert.SerializeObject(AGVLoadInteracteModel.GetInstance);
//启用签名
//url = url + "?sign=" + MD5Deal(body);
string data = HttpRequest(url, head, body); string data = HttpRequest(url, head, body);
object objData = JsonConvert.DeserializeObject(data); object objData = JsonConvert.DeserializeObject(data);
if (objData != null && objData is HttpResponseModel response) if (objData != null && objData is HttpResponseModel response)


+ 2
- 2
BPASmartClient.AgvApi/Factory.cs View File

@@ -13,12 +13,12 @@ namespace BPASmartClient.AgvApi


public Task SendReport(object obj) public Task SendReport(object obj)
{ {
return HubCallerClient?.Caller.SendAsync("Report", obj);
return HubCallerClient?.Caller.SendAsync("Report", obj);//Invoke客户端Report名称的方法
} }


public Task SendUpstreamrequest(object obj) public Task SendUpstreamrequest(object obj)
{ {
return HubCallerClient?.Caller.SendAsync("Upstreamrequest", obj);
return HubCallerClient?.Caller.SendAsync("Upstreamrequest", obj);//Invoke客户端Upstreamrequest名称的方法
} }


} }


+ 3
- 0
BPASmartClient.AgvApi/PersonHub.cs View File

@@ -2,6 +2,9 @@


namespace BPASmartClient.AgvApi namespace BPASmartClient.AgvApi
{ {
/// <summary>
/// 服务端
/// </summary>
public class PersonHub : Hub public class PersonHub : Hub
{ {




+ 1
- 1
BPASmartClient.AgvApi/Program.cs View File

@@ -11,7 +11,7 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddSignalR();
builder.Services.AddSignalR();//×¢²áSignalR×é¼þ
var app = builder.Build(); var app = builder.Build();


// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.


+ 2
- 2
BPASmartClient.CustomResource/Pages/Model/AlarmInfo.cs View File

@@ -9,8 +9,8 @@ namespace BPASmartClient.CustomResource.Pages.Model
public class AlarmInfo public class AlarmInfo
{ {
public AlarmInfo() public AlarmInfo()
{
{
} }
/// <summary> /// <summary>
/// 1 号滚筒线故障 /// 1 号滚筒线故障


+ 1
- 0
BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs View File

@@ -44,6 +44,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel


private void DoNavChanged(object obj) private void DoNavChanged(object obj)
{ {
ActionManage.GetInstance.Send("RecipeIsChange");
for (int i = 0; i < menuModels.Count; i++) for (int i = 0; i < menuModels.Count; i++)
{ {
var res = menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.ToggleWindowPath == obj.ToString()); var res = menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.ToggleWindowPath == obj.ToString());


+ 5
- 3
BPASmartClient.HubHelper/HubHelper.cs View File

@@ -2,6 +2,9 @@


namespace BPASmartClient.HubHelper namespace BPASmartClient.HubHelper
{ {
/// <summary>
/// 客户端
/// </summary>
public class HubHelper public class HubHelper
{ {
private volatile static HubHelper _Instance; private volatile static HubHelper _Instance;
@@ -17,10 +20,9 @@ namespace BPASmartClient.HubHelper
{ {
hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接 hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接


hubConnection.On<object>("Report", (s) => { Report?.Invoke(s); });

hubConnection.On<object>("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); });
hubConnection.On<object>("Report", (s) => { Report?.Invoke(s); });//客户端注册方法


hubConnection.On<object>("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); });//客户端注册方法
try try
{ {
hubConnection.StartAsync(); hubConnection.StartAsync();


+ 1
- 1
FryPot_DosingSystem/App.xaml.cs View File

@@ -38,7 +38,7 @@ namespace FryPot_DosingSystem
mv.Show(); mv.Show();
DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取 DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序 DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
HubHelper.GetInstance.Connect("192.168.1.130", 8089);
HubHelper.GetInstance.Connect("192.168.1.14", 8089);
AlarmHelper<AlarmInfo>.Init(); AlarmHelper<AlarmInfo>.Init();
} }
else else


+ 1
- 1
FryPot_DosingSystem/Model/RecipeModel.cs View File

@@ -25,7 +25,7 @@ namespace FryPot_DosingSystem.Model
/// 配方下发状况信息 /// 配方下发状况信息
/// </summary> /// </summary>
private string _recipeSetInfo; private string _recipeSetInfo;
public string RecipeSetInfo { get { return _recipeSetInfo; } set { _recipeSetInfo = value; OnPropertyChanged(); } }
public string RecipeSetInfo { get { return _recipeSetInfo; } set { _recipeSetInfo = value; OnPropertyChanged(); } }


public ObservableCollection<MaterialType> materialCollection { get; set; } = new ObservableCollection<MaterialType>(); public ObservableCollection<MaterialType> materialCollection { get; set; } = new ObservableCollection<MaterialType>();
} }


+ 15
- 5
FryPot_DosingSystem/View/NewRecipeView.xaml View File

@@ -211,11 +211,21 @@
BorderBrush="Aqua" VerticalAlignment="Center" FontSize="16" TextChanged="TextBox_TextChanged"></TextBox> BorderBrush="Aqua" VerticalAlignment="Center" FontSize="16" TextChanged="TextBox_TextChanged"></TextBox>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="添加原料" Width="150" Margin="10" Height="30" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Cursor="Hand" Command="{Binding AddRecipe}" ></Button>
<Button Content="确认" Height="30" Width="100" Margin="5,10" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Command="{Binding Comfirm}"></Button>
<Button Click="Button_Click" Content="取消" Height="30" FontSize="20" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Width="100" Margin="8,10" Cursor="Hand"></Button>
</StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="添加原料" Width="180" Margin="0,0,10,0" Height="30" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Cursor="Hand" Command="{Binding AddRecipe}" ></Button>
<Button Content="确认更新" Height="30" Width="180" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Command="{Binding Comfirm}"></Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
<Button Content="另存为" Height="30" Width="180" Margin="0,0,10,0" Command="{Binding SaveAs}" Cursor="Hand"/>
<Button Click="Button_Click" Content="取消" Height="30" FontSize="20" Background="Transparent" BorderBrush="Aqua" Foreground="Aqua" Width="180" Cursor="Hand"></Button>
</StackPanel>
</Grid>
</UniformGrid> </UniformGrid>
<Grid Grid.Row="2" Background="Cyan" Margin="0,0,0,10"> <Grid Grid.Row="2" Background="Cyan" Margin="0,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>


+ 2
- 1
FryPot_DosingSystem/View/RecipeSendDownView.xaml View File

@@ -19,6 +19,7 @@
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -109,7 +110,7 @@
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Line StrokeThickness="3" Grid.Column="0" HorizontalAlignment="Left" Stroke="LawnGreen" X1="0" Y1="5" X2="0" Y2="110"></Line> <Line StrokeThickness="3" Grid.Column="0" HorizontalAlignment="Left" Stroke="LawnGreen" X1="0" Y1="5" X2="0" Y2="110"></Line>
<TextBlock Grid.Column="1" FontSize="16" Text="{Binding RecipeSetInfo}" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<TextBlock Grid.Column="1" FontSize="16" Text="{Binding RecipeSetInfo}" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</Grid> </Grid>
</Grid> </Grid>




+ 42
- 13
FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -37,6 +37,7 @@ namespace FryPot_DosingSystem.ViewModel
public RelayCommand AddRecipe { get; set; } public RelayCommand AddRecipe { get; set; }
public RelayCommand<string> RemoveRecipe { get; set; } public RelayCommand<string> RemoveRecipe { get; set; }
public RelayCommand Comfirm { get; set; } public RelayCommand Comfirm { get; set; }
public RelayCommand SaveAs { get; set; }
public NewRecipeViewModel() public NewRecipeViewModel()
{ {
Json<MaterialNames>.Read(); Json<MaterialNames>.Read();
@@ -59,23 +60,24 @@ namespace FryPot_DosingSystem.ViewModel
} }
} }
}), "EditRecipe"); }), "EditRecipe");
AddRecipe = new RelayCommand(() => AddRecipe = new RelayCommand(() =>
{ {
for (int i = 0; i < RecipeRollerNum; i++)
for (int i = 0; i < RecipeRollerNum; i++)
{
pr1:
string materialCode = Guid.NewGuid().ToString();//原料唯一ID ,后期需要根据实际要求更改
var res = materials.FirstOrDefault(p => p.MaterialCode == materialCode);
if (res == null)
{ {
pr1:
string materialCode = Guid.NewGuid().ToString();//原料唯一ID ,后期需要根据实际要求更改
var res = materials.FirstOrDefault(p => p.MaterialCode == materialCode);
if (res == null)
{
materials.Add(new MaterialType() { MaterialCode = materialCode });
}
else
{
goto pr1;
}
materials.Add(new MaterialType() { MaterialCode = materialCode });
}
else
{
goto pr1;
} }
}

}); });
RemoveRecipe = new RelayCommand<string>(code => RemoveRecipe = new RelayCommand<string>(code =>
{ {
@@ -116,7 +118,34 @@ namespace FryPot_DosingSystem.ViewModel
ActionManage.GetInstance.Send("CloseNewRecipeView"); ActionManage.GetInstance.Send("CloseNewRecipeView");
} }
}); });
SaveAs = new RelayCommand(() =>
{
var bom = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
if (bom == null)//配方名称更改
{
if (RecipeRollerNum != 0)
{
prop: string recipeID = Guid.NewGuid().ToString();//配方唯一ID,后期根据实际要求更改
var res = Json<RecipeManage>.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID);
if (res == null)
{
Json<RecipeManage>.Data.Recipes.Add(new NewRecipeModel { RecipeId = recipeID, RecipeName = RecipeName, materialCollection = materials });//配方添加


}
else
{
goto prop;
}
MessageLog.GetInstance.ShowUserLog("新建配方成功");
}
else
{
MessageLog.GetInstance.ShowUserLog("新建配方无效【配方中没有添加原料】");
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
}
ActionManage.GetInstance.Send("CloseNewRecipeView");
});
} }
} }
} }

+ 22
- 2
FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs View File

@@ -10,6 +10,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;


namespace FryPot_DosingSystem.ViewModel namespace FryPot_DosingSystem.ViewModel
{ {
@@ -44,14 +45,32 @@ namespace FryPot_DosingSystem.ViewModel
{ {
Json<RecipeManage>.Read(); Json<RecipeManage>.Read();
recipeModels = Json<RecipeManage>.Data.Recipes; recipeModels = Json<RecipeManage>.Data.Recipes;
int count = recipeModels.Count;
ActionManage.GetInstance.CancelRegister("RecipeIsChange");
ActionManage.GetInstance.Register(new Action(() =>
{
bool b = Json<RecipeManage>.Data.Recipes.Count==count ? true : false;
if (!b)
{
MessageBoxResult result = MessageBox.Show("配方数据未保存,是否保存", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information);
if (result == MessageBoxResult.OK)
{
Json<RecipeManage>.Save();//保存配方
count = recipeModels.Count;
}
}

}), "RecipeIsChange");
NewRecipe = new Action(() => NewRecipe = new Action(() =>
{ {
NewRecipeView nrv = new NewRecipeView(); NewRecipeView nrv = new NewRecipeView();
nrv.ShowDialog(); nrv.ShowDialog();
MessageLog.GetInstance.Show("新建配方"); MessageLog.GetInstance.Show("新建配方");
}); });
SaveRecipe = new Action(() => {
SaveRecipe = new Action(() =>
{
Json<RecipeManage>.Save(); Json<RecipeManage>.Save();
count = recipeModels.Count;
}); });
EditRecipeCommand = new RelayCommand<object>((Id) => EditRecipeCommand = new RelayCommand<object>((Id) =>
{ {
@@ -67,11 +86,12 @@ namespace FryPot_DosingSystem.ViewModel
{ {
if (Id != null && Id is String strId) if (Id != null && Id is String strId)
{ {
var res= recipeModels.FirstOrDefault(p => p.RecipeId == strId);
var res = recipeModels.FirstOrDefault(p => p.RecipeId == strId);
if (res != null && res is NewRecipeModel nes) if (res != null && res is NewRecipeModel nes)
{ {
recipeModels.Remove(res);//删除配方 recipeModels.Remove(res);//删除配方
Json<RecipeManage>.Save();//保存配方 Json<RecipeManage>.Save();//保存配方
count = recipeModels.Count;
} }
} }
}); });


+ 2
- 2
TestDemo/Form1.cs View File

@@ -16,7 +16,7 @@ namespace TestDemo
{ {
AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); AGVToUpSystem aGVToUpSystem = new AGVToUpSystem();
string value = JsonConvert.SerializeObject(aGVToUpSystem); string value = JsonConvert.SerializeObject(aGVToUpSystem);
string url = $"http://192.168.1.130:8089/apicallback/quicktron/robotjob/report?sign={value}";
string url = $"http://192.168.1.14:8089/apicallback/quicktron/robotjob/report?sign={value}";
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST);
} }


@@ -25,7 +25,7 @@ namespace TestDemo


Upstreamrequest aGVToUpSystem = new Upstreamrequest(); Upstreamrequest aGVToUpSystem = new Upstreamrequest();
string value = JsonConvert.SerializeObject(aGVToUpSystem); string value = JsonConvert.SerializeObject(aGVToUpSystem);
string url = $"http://192.168.1.130:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}";
string url = $"http://192.168.1.14:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}";
var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST);
} }
} }

Loading…
Cancel
Save