|
|
|
|
|
using Khd.Core.Domain.Models;
|
|
|
|
|
|
using Khd.Core.EntityFramework;
|
|
|
|
|
|
using Khd.Core.Plc.S7.Types;
|
|
|
|
|
|
using Masuit.Tools.Logging;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
using Microsoft.Win32;
|
|
|
|
|
|
using OfficeOpenXml;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
|
using Thrift.Protocol;
|
|
|
|
|
|
using Thrift.Server;
|
|
|
|
|
|
using Thrift.Transport;
|
|
|
|
|
|
using ThriftService;
|
|
|
|
|
|
using Z.EntityFramework.Plus;
|
|
|
|
|
|
using Jc.SnowId;
|
|
|
|
|
|
using Masuit.Tools;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Khd.Core.Wpf.Form
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// FormBoardT.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class FormBoardT : Window
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IHost _host;
|
|
|
|
|
|
private Khd.Core.Plc.S7.Plc _plc;
|
|
|
|
|
|
private DispatcherTimer ShowTimer;//刷新时间
|
|
|
|
|
|
private DispatcherTimer PLCMessage;//呈现PLC机柜信息
|
|
|
|
|
|
private DispatcherTimer UPMessageTimer;//刷新上件记录
|
|
|
|
|
|
private DispatcherTimer ShowOrderMessage;//呈现PLC机柜信息
|
|
|
|
|
|
private object order_code;
|
|
|
|
|
|
private int UpState;//对应上件站点的状态,0为良好 1为损坏
|
|
|
|
|
|
List<BasePlcpoint> basePlcpoints = new List<BasePlcpoint>();
|
|
|
|
|
|
object timerjilu;
|
|
|
|
|
|
public class barcodeinfo
|
|
|
|
|
|
{
|
|
|
|
|
|
public string barcode { get; set; }
|
|
|
|
|
|
public long? materialId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public decimal? qty { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<barcodeinfo> barcodeLsit = new List<barcodeinfo>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string selectedId;
|
|
|
|
|
|
//FormShowSelect formSelect;
|
|
|
|
|
|
// public static int WeekNo = CommonHelper.WeekOfYear(DateTime.Now, new System.Globalization.CultureInfo("zh-CN"));
|
|
|
|
|
|
public FormBoardT(IHost host)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
this._host = host;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 页面加载事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void FormBoard_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;");
|
|
|
|
|
|
//设置显示任务栏
|
|
|
|
|
|
if (WindowState == WindowState.Normal)
|
|
|
|
|
|
{
|
|
|
|
|
|
MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
|
|
|
|
|
|
WindowState = WindowState.Maximized;
|
|
|
|
|
|
}
|
|
|
|
|
|
//加载dategrid信息
|
|
|
|
|
|
//LoadMaterial_GetMessage("");
|
|
|
|
|
|
//连接PLC判断
|
|
|
|
|
|
// var plc = new Khd.Core.Plc.S7.Plc((CpuType)PlcConfig.CpuType, PlcConfig.IP, PlcConfig.Port,
|
|
|
|
|
|
// PlcConfig.Rack, PlcConfig.Slot);
|
|
|
|
|
|
// //plc.Open();
|
|
|
|
|
|
// //if (!plc.IsConnected)
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // MessageBox.Show("PLC连接失败,重新连接");
|
|
|
|
|
|
// //}
|
|
|
|
|
|
// //else
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // this._plc = plc;
|
|
|
|
|
|
// //}
|
|
|
|
|
|
|
|
|
|
|
|
// using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
// using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
// basePlcpoints = dbContext.BasePlcpoint.Where(t => t.isDelete == 0).ToList();
|
|
|
|
|
|
// //var baseMaterials = dbContext.BaseMaterial.Where(t => t.IsDelete == 0).ToList();
|
|
|
|
|
|
////
|
|
|
|
|
|
|
|
|
|
|
|
// PLCMessage = new DispatcherTimer();
|
|
|
|
|
|
// PLCMessage.Tick += new EventHandler(PLCmessage); //委托获取点位方法
|
|
|
|
|
|
// PLCMessage.Interval = new TimeSpan(0, 0, 0, 0, 1000);
|
|
|
|
|
|
// PLCMessage.Start();
|
|
|
|
|
|
|
|
|
|
|
|
// UPMessageTimer = new DispatcherTimer();
|
|
|
|
|
|
// UPMessageTimer.Tick += new EventHandler(UpMessage); //委托刷新上件记录
|
|
|
|
|
|
// UPMessageTimer.Interval = new TimeSpan(0, 0, 0, 0, 2000);
|
|
|
|
|
|
// UPMessageTimer.Start();
|
|
|
|
|
|
// Button_Click_1(null, null);
|
|
|
|
|
|
// SetTime();
|
|
|
|
|
|
// List<string> list = new List<string>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// "101上件点",
|
|
|
|
|
|
// "102上件点",
|
|
|
|
|
|
// "103上件点"
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 显示序号事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
|
|
|
|
|
|
{ e.Row.Header = e.Row.GetIndex() + 1; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点击退出按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnExit_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Environment.Exit(System.Environment.ExitCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void Close(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Environment.Exit(System.Environment.ExitCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
public int i = 0;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询任务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnGetTask_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
GetTask();
|
|
|
|
|
|
}
|
|
|
|
|
|
private void GetTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
var equipCode = lba_ThrifTtitle1.Text;
|
|
|
|
|
|
var palletNo = lba_ThrifTtitle2.Text;
|
|
|
|
|
|
var data = dbContext.WcsTask.Where(t => t.useFlag == 1 && t.containerNo.Contains(palletNo) && t.equipmentNo.Contains(equipCode)).ToList();
|
|
|
|
|
|
this.LoadMaterial0.ItemsSource = null;
|
|
|
|
|
|
this.LoadMaterial0.ItemsSource = data;
|
|
|
|
|
|
this.LoadMaterial0.Items.Refresh();
|
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除任务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnDelTask_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LoadMaterial0.SelectedIndex == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请选择要删除的任务!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var Currentselected = LoadMaterial0.SelectedItem as WcsTask;
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
Currentselected.useFlag = 0;
|
|
|
|
|
|
dbContext.WcsTask.Update(Currentselected);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
GetTask();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 完成任务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnFinishTask_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LoadMaterial0.SelectedIndex == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请选择要完成的任务!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var Currentselected = LoadMaterial0.SelectedItem as WcsTask;
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
Currentselected.taskStatus = 5;
|
|
|
|
|
|
dbContext.WcsTask.Update(Currentselected);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
GetTask();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询设备信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnGetEquip_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
var equipCode = lba_ThrifTtitle3.Text;
|
|
|
|
|
|
var data = dbContext.BaseEquip.Where(t => t.useFlag == 1 && t.equipNo.Contains(equipCode)).ToList();
|
|
|
|
|
|
this.LoadMaterial3.ItemsSource = null;
|
|
|
|
|
|
this.LoadMaterial3.ItemsSource = data;
|
|
|
|
|
|
this.LoadMaterial3.Items.Refresh();
|
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询库存信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnGetStocK_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
var locationCode = lba_ThrifTtitle6.Text;
|
|
|
|
|
|
var materialCode = lba_ThrifTtitle5.Text;
|
|
|
|
|
|
var data = dbContext.WcsStock.Where(t => t.useFlag == 1 && t.materialCode.Contains(materialCode) && t.locationCode.Contains(locationCode)).ToList();
|
|
|
|
|
|
this.LoadMaterial1.ItemsSource = null;
|
|
|
|
|
|
this.LoadMaterial1.ItemsSource = data;
|
|
|
|
|
|
this.LoadMaterial1.Items.Refresh();
|
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询指令信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnGetWcsCmd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
GetWcsCmd();
|
|
|
|
|
|
}
|
|
|
|
|
|
private void GetWcsCmd()
|
|
|
|
|
|
{
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
var equipCode = txtEquipNo.Text;
|
|
|
|
|
|
var ContainNo = txtContainNo.Text;
|
|
|
|
|
|
var data = dbContext.WcsCmd.Where(t => t.useFlag == 1 && t.containerNo.Contains(ContainNo) && t.equipmentNo.Contains(equipCode)).ToList();
|
|
|
|
|
|
this.LoadMaterial.ItemsSource = null;
|
|
|
|
|
|
this.LoadMaterial.ItemsSource = data;
|
|
|
|
|
|
this.LoadMaterial.Items.Refresh();
|
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("未查询到数据");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除指令
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnDelCmd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LoadMaterial.SelectedIndex == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请选择要删除的指令!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var Currentselected = LoadMaterial.SelectedItem as WcsCmd;
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
Currentselected.useFlag = 0;
|
|
|
|
|
|
dbContext.WcsCmd.Update(Currentselected);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
GetWcsCmd();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重发指令
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnReSendCmd_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LoadMaterial.SelectedIndex == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请选择要重发的指令!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var Currentselected = LoadMaterial.SelectedItem as WcsCmd;
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
Currentselected.sendFlag = 0;
|
|
|
|
|
|
dbContext.WcsCmd.Update(Currentselected);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
GetWcsCmd();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 呼叫料箱
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnCallBox_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
|
|
|
|
|
|
if (int.TryParse(txtNum.Text, out int num))
|
|
|
|
|
|
{
|
|
|
|
|
|
//目的地
|
|
|
|
|
|
var endEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault();
|
|
|
|
|
|
//所有辅料库位
|
|
|
|
|
|
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 5).ToList(); //五楼辅料库
|
|
|
|
|
|
//有库存的库位
|
|
|
|
|
|
var wmsStock = dbContext.WcsStock.Where(t => t.useFlag == 1).Select(t => t.locationCode).ToList();
|
|
|
|
|
|
var EmptyBox = wmsBaseLocation.Where(t => !t.locationCode.Contains(wmsStock)).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var wcsTask = new WcsTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
objid = Global.SnowId.NextId(),
|
|
|
|
|
|
startPointId = EmptyBox[i].locationId,
|
|
|
|
|
|
startPointNo = EmptyBox[i].agvPositionCode,
|
|
|
|
|
|
currPointId = EmptyBox[i].locationId,
|
|
|
|
|
|
currPointNo = EmptyBox[i].agvPositionCode,
|
|
|
|
|
|
nextPointId = endEquip.objid,
|
|
|
|
|
|
nextPointNo = endEquip.equipNo,
|
|
|
|
|
|
endPointId = endEquip.objid,
|
|
|
|
|
|
endPointNo = endEquip.equipNo,
|
|
|
|
|
|
taskType = 13,
|
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
|
floorNo = 5,
|
|
|
|
|
|
containerNo = EmptyBox[i].containerCode,
|
|
|
|
|
|
equipmentNo = endEquip.equipNo,
|
|
|
|
|
|
createBy = "5楼呼叫料箱任务",
|
|
|
|
|
|
createTime = System.DateTime.Now,
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请输入有效的数字");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 料箱扫描
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void txtBox_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtBarCode.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 条码扫描
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void txtBarCode_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Key == Key.Enter)
|
|
|
|
|
|
{
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
var mesInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == txtBarCode.Text).FirstOrDefault();
|
|
|
|
|
|
if (mesInfo == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("请扫描正确的条码");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
barcodeinfo barcodeinfo = new barcodeinfo();
|
|
|
|
|
|
barcodeinfo.barcode = txtBarCode.Text;
|
|
|
|
|
|
barcodeinfo.materialId = mesInfo.materialId;
|
|
|
|
|
|
barcodeinfo.qty = mesInfo.amount;
|
|
|
|
|
|
barcodeLsit.Add(barcodeinfo);
|
|
|
|
|
|
txtBarCode.SelectAll();
|
|
|
|
|
|
txtBarCode.Focus();
|
|
|
|
|
|
txtScan.Text = $"已扫描{barcodeLsit.Count}个";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 确认
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void btnConfirmBox_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var box = txtBox.Text;
|
|
|
|
|
|
if (string.IsNullOrEmpty(box))
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("容器号不能为空!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (barcodeLsit.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("未扫描条码!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
|
if (cbxType.Text == "入库")
|
|
|
|
|
|
{
|
|
|
|
|
|
//写入wms_raw_instock
|
|
|
|
|
|
var wmsRawInstock = new WmsRawInstock()
|
|
|
|
|
|
{
|
|
|
|
|
|
rawInstockId = Global.SnowId.NextId(),
|
|
|
|
|
|
warehouseId = 5,
|
|
|
|
|
|
operationType = "3",
|
|
|
|
|
|
instockType = "9",
|
|
|
|
|
|
materialId = barcodeLsit.FirstOrDefault().materialId,
|
|
|
|
|
|
palletInfoCode = txtBox.Text,
|
|
|
|
|
|
instockAmount = barcodeLsit.Sum(t => t.qty),
|
|
|
|
|
|
executeStatus = "0",
|
|
|
|
|
|
applyBy = "扫描入库",
|
|
|
|
|
|
applyDate = System.DateTime.Now
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.WmsRawInstock.Add(wmsRawInstock);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
var startEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault();
|
|
|
|
|
|
var warehouse = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == 5).FirstOrDefault();
|
|
|
|
|
|
//写入wcs任务
|
|
|
|
|
|
var wcsTask = new WcsTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
objid = Global.SnowId.NextId(),
|
|
|
|
|
|
startPointId = startEquip.objid,
|
|
|
|
|
|
startPointNo = startEquip.agvPositionCode,
|
|
|
|
|
|
currPointId = startEquip.objid,
|
|
|
|
|
|
currPointNo = startEquip.agvPositionCode,
|
|
|
|
|
|
nextPointId = warehouse.warehouseId,
|
|
|
|
|
|
nextPointNo = warehouse.warehouseCode,
|
|
|
|
|
|
endPointId = warehouse.warehouseId,
|
|
|
|
|
|
endPointNo = warehouse.warehouseCode,
|
|
|
|
|
|
taskType = 4,
|
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
|
floorNo = 5,
|
|
|
|
|
|
containerNo = txtBox.Text,
|
|
|
|
|
|
equipmentNo = startEquip.equipNo,
|
|
|
|
|
|
createBy = "5楼入库任务",
|
|
|
|
|
|
createTime = System.DateTime.Now,
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (cbxType.Text == "出库")
|
|
|
|
|
|
{
|
|
|
|
|
|
//从料箱里拿出来
|
|
|
|
|
|
}
|
|
|
|
|
|
if (cbxType.Text == "回库")
|
|
|
|
|
|
{
|
|
|
|
|
|
//写入wms_raw_instock
|
|
|
|
|
|
var wmsRawInstock = new WmsRawInstock()
|
|
|
|
|
|
{
|
|
|
|
|
|
rawInstockId = Global.SnowId.NextId(),
|
|
|
|
|
|
warehouseId = 5,
|
|
|
|
|
|
operationType = "3",
|
|
|
|
|
|
instockType = "9",
|
|
|
|
|
|
materialId = barcodeLsit.FirstOrDefault().materialId,
|
|
|
|
|
|
palletInfoCode = txtBox.Text,
|
|
|
|
|
|
instockAmount = barcodeLsit.Sum(t => t.qty),
|
|
|
|
|
|
executeStatus = "0",
|
|
|
|
|
|
applyBy = "扫描回库",
|
|
|
|
|
|
applyDate = System.DateTime.Now
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.WmsRawInstock.Add(wmsRawInstock);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
var startEquip = dbContext.BaseEquip.Where(t => t.equipNo == "FL05").FirstOrDefault();
|
|
|
|
|
|
var warehouse = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == 5).FirstOrDefault();
|
|
|
|
|
|
//写入wcs任务
|
|
|
|
|
|
var wcsTask = new WcsTask()
|
|
|
|
|
|
{
|
|
|
|
|
|
objid = Global.SnowId.NextId(),
|
|
|
|
|
|
startPointId = startEquip.objid,
|
|
|
|
|
|
startPointNo = startEquip.agvPositionCode,
|
|
|
|
|
|
currPointId = startEquip.objid,
|
|
|
|
|
|
currPointNo = startEquip.agvPositionCode,
|
|
|
|
|
|
nextPointId = warehouse.warehouseId,
|
|
|
|
|
|
nextPointNo = warehouse.warehouseCode,
|
|
|
|
|
|
endPointId = warehouse.warehouseId,
|
|
|
|
|
|
endPointNo = warehouse.warehouseCode,
|
|
|
|
|
|
taskType = 4,
|
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
|
floorNo = 5,
|
|
|
|
|
|
containerNo = txtBox.Text,
|
|
|
|
|
|
equipmentNo = startEquip.equipNo,
|
|
|
|
|
|
createBy = "5楼回库任务",
|
|
|
|
|
|
createTime = System.DateTime.Now,
|
|
|
|
|
|
};
|
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|