You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.6 KiB
C#

2 years ago
using Khd.Core.EntityFramework;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
2 years ago
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// SelectOutRawForm.xaml 的交互逻辑
/// </summary>
public partial class SelectOutRawForm : Window
{
private readonly IHost _host;
public SelectOutRawForm(IHost host)
{
InitializeComponent();
_host = host;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
2 years ago
if (this.endStationCode.SelectedItem == null)
{
MessageBox.Show("请选择出库站点!");
}
else
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = dbContext.BaseEquip.Where(t => t.objid == 10).First();
baseEquip.endStationCode = this.endStationCode.SelectedItem.ToString();
dbContext.BaseEquip.Update(baseEquip);
dbContext.SaveChanges();
MessageBox.Show("保存成功!");
}
}
2 years ago
2 years ago
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<string> endStationCodes = SystemData.BaseEquip.Where(t => t.equipType == 10).Select(t => t.agvPositionCode).ToList();
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11 && t.taskType == 30).Any();
if (!hasTask)
{
var wmsRawOutstocks = dbContext.WmsRawOutstock
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.outstockAmount > t.realOutstockAmount)
.ToList();
List<string> list = wmsRawOutstocks.Select(t => t.endStationCode).Distinct().ToList();
this.endStationCode.ItemsSource = list;
}
else
{
MessageBox.Show("您有未完成的出库任务,请先完成后再进行此操作!");
this.Close();
}
2 years ago
}
}
}