2 years ago
parent 325255d5c9
commit 512b4d6d17

@ -11,7 +11,7 @@ namespace Khd.Core.Domain.Models
[Column("inventory_check_detail_id")]
public long InventoryCheckDetailId { get; set; }
[Column("inventory_check_id")]
public long InventoryCheckId { get; set; }
public long? InventoryCheckId { get; set; }
[Column("material_id")]
public long? MaterialId { get; set; }
[Column("location_code")]

@ -10,6 +10,7 @@ namespace Khd.Core.EntityFramework
public DefaultDbContext(DbContextOptions<DefaultDbContext> options) : base(options)
{
}
public DbSet<SysUser> SysUser { get; set; }
public DbSet<SysRole> SysRole { get; set; }
public DbSet<SysMenu> SysMenu { get; set; }

@ -1077,15 +1077,19 @@ namespace Khd.Core.Wcs.Wcs
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 21);
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.objid == 10);
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(baseEquip.endStationCode) && baseEquip.ud3 == "1")
{
var wmsRawReturn = dbContext.WmsRawReturn
.Where(t => t.auditStatus == "1")
.Where(t => t.executeStatus == "0")
.Where(t => t.endStationCode == baseEquip.endStationCode)
.FirstOrDefault();
if (wmsRawReturn != null)
{
@ -1122,7 +1126,8 @@ namespace Khd.Core.Wcs.Wcs
fromFloorNo = 5,
//materialNo = wmsRawReturn.materialBatch,
};
wmsRawReturn.executeStatus = "1";
baseEquip.ud3 = null;
dbContext.Update(baseEquip);
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
@ -1132,6 +1137,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
}
catch (Exception ex)
{
_logger.Error(ex.Message + "\n" + ex.StackTrace);
@ -1664,7 +1670,12 @@ namespace Khd.Core.Wcs.Wcs
//if (taskCount == 0 && wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
if (taskCount == 0)
{
foreach (var wcs in wcsTaskManuals.Take(6))
List<WcsTaskManual> list = wcsTaskManuals.Where(t => t.taskType == 100).ToList();
if (list.Count == 0)
{
list = wcsTaskManuals.Where(t => t.taskType == 30).ToList();
}
foreach (var wcs in list.Take(6))
{
WcsTask wcsTask = CoreMapper.Map<WcsTask>(wcs);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
@ -1821,7 +1832,7 @@ namespace Khd.Core.Wcs.Wcs
if (endEquip.equipType == 10)//CTU出库到装配区
{
BaseEquip endStationCodeEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(endStationCodeEquip.endStationCode) )
if (!string.IsNullOrEmpty(endStationCodeEquip.endStationCode) && endStationCodeEquip.ud3 != "1")
//if (!string.IsNullOrEmpty(endStationCodeEquip.endStationCode) && endStationCodeEquip.IsOut == 1)
{
if (item.endStationCode != endStationCodeEquip.endStationCode)

@ -330,6 +330,9 @@ namespace Khd.Core.Wcs.Wcs
dbContext.SaveChanges();
}
else
{
hasTask = wcsTasks.Where(t => t.containerNo == RFID001Value).Any();
if (!hasTask)
{
//根据托盘号获取物料码
var material = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == RFID001Value).FirstOrDefault();
@ -419,6 +422,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
}
else
{
if (string.IsNullOrEmpty(task.containerNo))//人工调出

@ -191,6 +191,16 @@ namespace Khd.Core.Wcs.Wcs
}
else if (task.taskType == 100)
{
WmsInventoryCheck? wmsInventoryCheck = dbContext.WmsInventoryCheck.Where(t => t.InventoryCheckId == task.orderId).FirstOrDefault();
if (wmsInventoryCheck != null)
{
wmsInventoryCheck.InventoryingAmount = wmsInventoryCheck.InventoryingAmount > 0 ? wmsInventoryCheck.InventoryingAmount - 1 : 0;
wmsInventoryCheck.InventoriedAmount++;
if (wmsInventoryCheck.InventoriedAmount >= wmsInventoryCheck.LocationAmount)
{
wmsInventoryCheck.CheckStatus = "2";
wmsInventoryCheck.EndTime = DateTime.Now;
}
dbContext.WcsTask.Where(t => t.objid == task.objid).Delete();
//根据rfid找到库位
//生成入库任务
@ -218,6 +228,7 @@ namespace Khd.Core.Wcs.Wcs
createBy = FloorNo + "楼CTU",
createTime = DateTime.Now,
};
dbContext.Update(wmsInventoryCheck);
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.updateTime = DateTime.Now;
dbContext.Update(wmsBaseLocation);
@ -231,6 +242,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
}
else if (Convert.ToInt32(receiveMaterial) == 1 && Convert.ToInt32(isArrive) == 1 && string.IsNullOrEmpty(rfid))
{
if (!Convert.ToBoolean(waring))

@ -1776,7 +1776,7 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="搜索" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="SelectInventoryButton_Click"/>
<Button Content="添加盘库任务" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="SelectInventoryButton_Click"/>
<Button Content="添加盘库任务" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="AddInventoryButton_Click"/>
<Button Content="库存盘点" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="150" Margin="20,0,0,0" Click="InventoryTaskButton_Click"/>
</StackPanel>
<DataGrid
@ -1882,8 +1882,8 @@
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="开始盘点" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="StartInventory"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="开始盘点" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
@ -2051,12 +2051,6 @@
ElementStyle="{StaticResource dgCell}"
Width="2*"
/>
<DataGridTextColumn
Header="是否出完"
Binding="{Binding isSendOver}"
Width="2*"
ElementStyle="{StaticResource dgCell}"
/>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
@ -2105,8 +2099,7 @@
<Image Source="..\Resources\cancel.png"/>
</Button>
</Grid>
<!--<Button Content="选择退库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="20,0,0,0" Height="100" Width="250" Click="SelectOutBtn_Click"/>-->
<Button Content="继续退库" Visibility="Collapsed" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="20,0,0,0" Height="100" Width="250" Click="ContineOutBtn_Click"/>
<Button Content="选择退库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="100,0,0,0" Height="100" Width="400" Click="SelectReturnBtn_Click"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="6">
<TextBlock Text="扫描条码号:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>

@ -169,6 +169,12 @@ namespace Khd.Core.Wpf.Form
};
OutOrderThread.Start();
Thread ReturnOrderThread = new Thread(ReturnOrderTimer)
{
IsBackground = true
};
ReturnOrderThread.Start();
//Thread ddjThread = new Thread(ddjTimer);
//ddjThread.Start();
//LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;");
@ -281,6 +287,86 @@ namespace Khd.Core.Wpf.Form
}
}
private void ReturnOrderTimer(object? obj)
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
List<BaseEquip> baseEquips = dbContext.BaseEquip.Where(t => t.equipType == 10).ToList();
var endStationCodes = baseEquips.Select(t => t.agvPositionCode).ToList();
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
List<WmsRawReturn> wmsRawReturns = dbContext.WmsRawReturn.Where(t => endStationCodes.Contains(t.endStationCode))
.Where(t => t.auditStatus == "1")
.Where(t => t.executeStatus == "0" || t.executeStatus == "1")
.Where(t => t.returnAmount > t.planAmount)
.ToList();
List<string> list = wmsRawReturns.Select(t => t.endStationCode).ToList();
Dispatcher.Invoke(() =>
{
this.ReturnOrder.Text = "待退库单:\n" + list.Distinct().Join("\n");
});
var baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(baseEquip.endStationCode) && baseEquip.ud3 != "1")
{
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).ToList();
List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => containerNos.Contains(t.palletInfoCode)).ToList();
var thisOutList = wmsRawStocks.GroupBy(t => new { t.materialId, t.saleOrderId })
.Select(t => new
{
materialId = t.Key.materialId,
saleOrderId = t.Key.saleOrderId,
thisOutAmount = t.Sum(x => x.totalAmount) - t.Sum(x => x.frozenAmount)
});
List<WmsRawReturn> endStationCodeOutRaw = wmsRawReturns.Where(t => t.endStationCode == baseEquip.endStationCode).ToList();
List<long?> materialIds = endStationCodeOutRaw.Select(t => t.materialId).ToList();
List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => materialIds.Contains(t.MaterialId)).ToList();
var bill = endStationCodeOutRaw.GroupBy(t => new { t.materialId })
.Select(t => new
{
materialId = t.Key.materialId,
outstockAmount = t.Sum(x => x.returnAmount),
realOutstockAmount = t.Sum(x => x.planAmount),
});
var orderNumber = from a in bill
from b in thisOutList
from c in mesBaseMaterialInfos
where a.materialId == b.materialId
select new
{
materialBatch = c.MaterialCode,
saleOrderId = b.saleOrderId,
outstockAmount = a.outstockAmount,
materialSpec = c.MaterialSpec,
realOutstockAmount = a.realOutstockAmount,
thisOutAmount = b.thisOutAmount,
};
Dispatcher.Invoke(() =>
{
this.ReturnTaskNumber.ItemsSource = orderNumber;
this.ReturnTaskNumber.Items.Refresh();
});
}
else
{
Dispatcher.Invoke(() =>
{
this.ReturnTaskNumber.ItemsSource = null;
this.ReturnTaskNumber.Items.Refresh();
});
}
}
catch
{
}
}
}
private void OutOrderTimer(object? obj)
{
using var scope = _host.Services.CreateScope();
@ -304,7 +390,7 @@ namespace Khd.Core.Wpf.Form
});
var baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
if (!string.IsNullOrEmpty(baseEquip.endStationCode))
if (!string.IsNullOrEmpty(baseEquip.endStationCode) && baseEquip.ud3 != "1")
{
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 30).ToList();
List<string> containerNos = wcsTasks.Select(t => t.containerNo).ToList();
@ -1157,6 +1243,7 @@ namespace Khd.Core.Wpf.Form
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
baseEquip.endStationCode = string.Empty;
baseEquip.ud3 = null;
dbContext.Update(baseEquip);
var wcsCmd = dbContext.WcsTask
.Where(t => t.taskStatus == 6 || t.taskStatus == 3)
@ -2235,18 +2322,37 @@ namespace Khd.Core.Wpf.Form
{
GetInvertoryData();
}
/// <summary>
/// 开始盘点
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void StartInventory(object sender, RoutedEventArgs e)
{
dynamic wmsInventoryCheck = this.InventoryMaterial.SelectedItem;
long inventoryCheckId = wmsInventoryCheck.InventoryCheckId;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var InventoryCheck = dbContext.WmsInventoryCheck.Where(t => t.InventoryCheckId == inventoryCheckId).FirstOrDefault();
var InventoryCheck = dbContext.WmsInventoryCheck
.Where(t=>t.CheckStatus=="0"||t.CheckStatus=="1")
.Where(t => t.InventoryCheckId == inventoryCheckId).FirstOrDefault();
BaseEquip agvEquip = SystemData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = SystemData.BaseEquip.First(t => t.objid == 20);
if (InventoryCheck != null)
{
if(InventoryCheck.InventoryingAmount != 0)
{
bool hasTask = dbContext.WcsTask.Where(t => t.taskType == 100).Any();
if (!hasTask)
{
hasTask = dbContext.WcsTaskManual.Where(t => t.taskType == 100).Any();
if (!hasTask)
{
InventoryCheck.InventoriedAmount+= InventoryCheck.InventoryingAmount;
InventoryCheck.InventoryingAmount = 0;
}
}
}
if (InventoryCheck.InventoryingAmount == 0)
{
bool hasTask = dbContext.WcsTask.Where(t => t.taskType == 100).Any();
@ -2258,7 +2364,6 @@ namespace Khd.Core.Wpf.Form
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.ContainerStatus == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.activeFlag == "1")
.OrderBy(t => t.locRow)
.ThenBy(t => t.locColumn)
.ToList();
@ -2387,8 +2492,17 @@ namespace Khd.Core.Wpf.Form
HandyControl.Controls.MessageBox.Info("当前有盘点任务正在出库");
}
}
else
{
HandyControl.Controls.MessageBox.Info("盘点中,请等待本次盘点完成!");
}
}
else
{
HandyControl.Controls.MessageBox.Error("当前盘点点不可用!");
}
GetInvertoryData();
}
/// <summary>
/// 叫空料箱
@ -3254,6 +3368,75 @@ namespace Khd.Core.Wpf.Form
GetInvertoryData();
}
/// <summary>
/// 添加盘库任务
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddInventoryButton_Click(object sender, RoutedEventArgs e)
{
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var Orders = dbContext.WmsInventoryCheck.Where(t => t.CheckStatus == "0" || t.CheckStatus == "1").ToList();
if (Orders != null && Orders.Count > 0)
{
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("已经有盘库任务是否重新开始一个盘库任务?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
Orders.ForEach(t =>
{
t.CheckStatus = "2";
});
dbContext.UpdateRange(Orders);
int locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
CheckStatus = "0",
LocationAmount= locationCount,
InventoriedAmount=0,
InventoryingAmount=0,
WarehouseId=512,
CreateBy="WCS"
});
dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!");
}
else
{
return;
}
}
else
{
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("是否创建一个盘库任务?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
int locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).Count();
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
CheckStatus = "0",
LocationAmount = locationCount,
InventoriedAmount = 0,
InventoryingAmount = 0,
WarehouseId = 512,
CreateBy = "WCS"
});
dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!");
}
}
}
catch
{
}
GetInvertoryData();
}
private void GetInvertoryData()
{
using var scope = _host.Services.CreateScope();
@ -3303,10 +3486,15 @@ namespace Khd.Core.Wpf.Form
//选择出库
private void SelectOutBtn_Click(object sender, RoutedEventArgs e)
{
SelectOutRawForm selectOutRawForm = new SelectOutRawForm(this._host);
SelectOutRawForm selectOutRawForm = new SelectOutRawForm(this._host, "");
selectOutRawForm.ShowDialog();
}
//选择退库
private void SelectReturnBtn_Click(object sender, RoutedEventArgs e)
{
SelectOutRawForm selectOutRawForm = new SelectOutRawForm(this._host, "1");
selectOutRawForm.ShowDialog();
}
private void ContineOutBtn_Click(object sender, RoutedEventArgs e)
{
try

@ -33,7 +33,7 @@
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="用户登录" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Background="#1f1c31" VerticalContentAlignment="Center" VerticalAlignment="Stretch" FontSize="35" FontWeight="Bold" Foreground="White" MouseLeftButtonDown="ShuBiaoShuangJi" />
<Label Grid.Row="0" Content="用户登录" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" Background="#1f1c31" VerticalContentAlignment="Center" FontSize="35" FontWeight="Bold" Foreground="White" MouseLeftButtonDown="ShuBiaoShuangJi" />
<Grid Grid.Row="2" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
@ -63,7 +63,7 @@
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Focusable="False" Foreground="#FFFFFFFF" x:Name="btnSubmit" TabIndex="0" Content="提交" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#385492" Width="129" Height="40"/>
<Button Grid.Row="0" Grid.Column="0" Focusable="False" Foreground="#FFFFFFFF" x:Name="btnSubmit" TabIndex="0" Content="提交" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#385492" Width="129" Height="40" Click="btnSubmit_Click"/>
<Button Grid.Row="0" Grid.Column="1" Foreground="#FFFFFFFF" Content="取消" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#385492" Width="121" Height="40" Click="Button_Click_1"/>
</Grid>
</Grid>

@ -77,5 +77,10 @@ namespace Khd.Core.Wpf
services.AddDbContext<DefaultDbContext>(options =>
options.UseMySql(ConnectionStrings.ConnectionString, new MySqlServerVersion(new Version(8, 0, 31))));
});
private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
using var s
}
}
}

@ -65,8 +65,7 @@
<RepeatButton x:Name="ScanButton" Content="添加" Style="{StaticResource RepeatButtonPrimary}" Width="100" Margin="20,0,0,0" Click="ScanButton_Click" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Grid.Row="2">
<TextBlock Text="数量:" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20,0,0,0"/>
<TextBox x:Name="NewCount" Width="200" FontSize="20" hc:InfoElement.Placeholder="请输入数量" Style="{StaticResource TextBoxExtend}" />
<TextBox x:Name="NewCount" Width="200" FontSize="20" Margin="5" hc:InfoElement.Placeholder="请输入数量" Style="{StaticResource TextBoxExtend}" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="3" Margin="0,10,0,0">
<GroupBox Height="250" Header="确认" Padding="10">
@ -82,7 +81,7 @@
</Grid.ColumnDefinitions>
<TextBlock Text="条码" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="数量" Grid.Column="1" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="BarCodeList" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="BarCodeList" Grid.Column="0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="CountList" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</Border>

@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Masuit.Tools;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
@ -41,7 +42,9 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
this.MaterialSpec.Text = _materialName;
using var scope = this._host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wmsRawStocks = dbContext.WmsRawStock.Where(t => t.palletInfoCode == _containerNo && t.materialId == _materialId).ToList();
var wmsRawStocks = dbContext.WmsRawStock.Where(t => t.palletInfoCode == _containerNo)
.WhereIf(_materialId!=0, t => t.materialId == _materialId)
.ToList();
if (wmsRawStocks.Count == 0)
{
this.BarCode.Text = "空";
@ -55,7 +58,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
catch
{
MessageBox.Show("加载数据失败,请重试");
HandyControl.Controls.MessageBox.Error("加载数据失败,请重试");
this.Close();
}
}
@ -88,7 +91,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
catch
{
MessageBoxResult messageBoxResult = MessageBox.Show("该条码已经添加过,是否更新该条码?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("该条码已经添加过,是否更新该条码?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
string[] barCodes = this.BarCodeList.Text.Split('\n');
@ -106,13 +109,10 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
}
}
this.BarCodeList.Text += mesBaseBarcodeInfo.barcodeInfo + "\n";
this.CountList.Text += this.NewCount.Text + "\n";
this.NewBarCode.Text = "";
}
else
{
MessageBox.Show("条码不存在,请重新扫码");
HandyControl.Controls.MessageBox.Show("条码不存在,请重新扫码");
this.NewBarCode.Text = "";
}
}
@ -125,7 +125,10 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
List<string> newList = this.BarCodeList.Text.Split('\n').ToList();
newList.RemoveAll(t => string.IsNullOrEmpty(t));
List<string> list = this.BarCode.Text.Split('\n').ToList();
list.RemoveAll(t => string.IsNullOrEmpty(t));
List<string> countList = CountList.Text.Split("\n").ToList();
StringBuilder addStr = new();
List<string> addList = newList.Where(t => !list.Contains(t)).ToList();
if (addList.Count > 0)
@ -142,7 +145,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
if (addStr.Length > 0 || removeStr.Length > 0)
{
MessageBoxResult messageBoxResult = MessageBox.Show(addStr.ToString() + "\n" + removeStr.ToString(), "提示", MessageBoxButton.OK, MessageBoxImage.Information);
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show(addStr.ToString() + "\n" + removeStr.ToString(), "提示", MessageBoxButton.OK, MessageBoxImage.Information);
if (messageBoxResult == MessageBoxResult.OK)
{
using var scope = this._host.Services.CreateScope();
@ -158,7 +161,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
{
message = t.locationCode + ":" + t.instockBatch
}));
MessageBoxResult result = MessageBox.Show("条码已经在其他料箱中" + waring + "确认移动到当前料箱吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
MessageBoxResult result = HandyControl.Controls.MessageBox.Show("条码已经在其他料箱中" + waring + "确认移动到当前料箱吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.OK)
{
foreach (var wmsRawStock in wmsRawStocks)
@ -177,18 +180,29 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
if (addList.Count > 0)
{
List<WmsRawStock> newWmsRawStocks = new List<WmsRawStock>();
List<WmsRawStock> newWmsRawStocks = dbContext.WmsRawStock
.WhereIf(_materialId != 0, t => t.materialId == _materialId)
.Where(t => t.palletInfoCode == _containerNo).ToList();
var mesBaseBarcodeInfos = dbContext.MesBaseBarcodeInfo.Where(t => addList.Contains(t.barcodeInfo)).ToList();
foreach (var barcode in addList)
for (int i = 0; i < addList.Count; i++)
{
var barcode = addList[i];
var count = countList[i];
var mesBaseBarcodeInfo = mesBaseBarcodeInfos.FirstOrDefault(t => t.barcodeInfo == barcode);
if (mesBaseBarcodeInfo != null)
{
if (wmsRawStocks.Where(t => t.materialId == mesBaseBarcodeInfo.materialId).Any())
{
WmsRawStock wmsRawStock = wmsRawStocks.First(t => t.materialId == mesBaseBarcodeInfo.materialId);
wmsRawStock.totalAmount = decimal.Parse(count);
}
else
{
newWmsRawStocks.Add(new WmsRawStock
{
palletInfoCode = _containerNo,
materialId = _materialId,
instockBatch = barcode,
materialId = mesBaseBarcodeInfo.materialId,
instockBatch = mesBaseBarcodeInfo.barcodeInfo,
safeFlag = mesBaseBarcodeInfo.safeFlag,
stockType = "1",
activeFlag = "1",
@ -199,7 +213,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
qualityStatus = "0",
rawStockId = Global.SnowId.NextId(),
occupyAmount = 0,
totalAmount = mesBaseBarcodeInfo.batchFlag == "1" ? mesBaseBarcodeInfo.amount : 1,
totalAmount = mesBaseBarcodeInfo.batchFlag == "1" ? decimal.Parse(count) : 1,
warehouseFloor = 5,
warehouseId = 512,
saleOrderId = mesBaseBarcodeInfo.saleOrderId == null ? 0 : mesBaseBarcodeInfo.saleOrderId,
@ -210,15 +224,61 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
updateDate = DateTime.Now,
});
}
}
else
{
MessageBox.Show($"{barcode}条码信息不存在,无法入库");
HandyControl.Controls.MessageBox.Show($"{barcode}条码信息不存在,无法入库");
return;
}
}
if (newWmsRawStocks.Count > 0)
{
WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.containerNo == _containerNo).FirstOrDefault();
if (wcsTask != null)
{
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == wcsTask.orderId && t.LocationCode == wcsTask.currPointNo).ToList();
List<long?> hasMaterialId = newWmsRawStocks.Select(t => t.materialId).ToList();
var hasDetails = wmsInventoryCheckDetails
.Where(t => hasMaterialId.Contains(t.MaterialId) && t.LocationCode == wcsTask.currPointNo)
.ToList();
foreach (var item in hasDetails)
{
var wmsRawStock = newWmsRawStocks.Where(t => t.materialId == item.ErpAmount).First();
item.RealAmount = wmsRawStock.totalAmount;
item.InventoryCount++;
item.UpdateBy = "WCS";
item.UpdateTime = DateTime.Now;
}
newWmsRawStocks.Where(t => !wmsInventoryCheckDetails.Select(y => y.MaterialId).Contains(t.materialId)).ToList();
List<WmsInventoryCheckDetail> addDetailList = new List<WmsInventoryCheckDetail>();
foreach (var item in newWmsRawStocks)
{
addDetailList.Add(new WmsInventoryCheckDetail
{
InventoryCheckDetailId = Global.SnowId.NextId(),
InventoryCheckId = wcsTask.orderId,
CheckStatus = "1",
CreateBy = "WCS",
CreateTime = DateTime.Now,
StockAmount = 0,
RealAmount = item.totalAmount,
InventoryCount = 1,
LocationCode = item.locationCode,
StockId = 1,
StockType = "1",
MaterialId = item.materialId,
ErpStatus = "0",
ErpAmount = 0,
});
}
if (addDetailList.Count > 0)
dbContext.AddRange(addDetailList);
if (hasDetails.Count > 0)
dbContext.UpdateRange(hasDetails);
dbContext.AddRange(newWmsRawStocks);
dbContext.SaveChanges();
}
}
}
}
@ -226,7 +286,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
{
}
MessageBox.Show("保存成功");
HandyControl.Controls.MessageBox.Show("保存成功");
}
else
{
@ -235,7 +295,7 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
}
else
{
MessageBox.Show("条码未变动");
HandyControl.Controls.MessageBox.Show("条码未变动");
}
this.Close();
}
@ -243,6 +303,8 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
private void NewBarCode_LostFocus(object sender, RoutedEventArgs e)
{
try
{
if (!string.IsNullOrEmpty(this.NewBarCode.Text))
{
using var scope = this._host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
@ -250,12 +312,14 @@ namespace Khd.Core.Wpf.TaskForm.Inventory
if (mesBaseBarcodeInfo != null)
{
this.NewCount.Text = mesBaseBarcodeInfo.batchFlag == "1" ? mesBaseBarcodeInfo.amount.ToString() : "1";
this.NewCount.IsReadOnly = mesBaseBarcodeInfo.batchFlag != "1";
}
else
{
MessageBox.Show("条码不存在,请重新扫码");
HandyControl.Controls.MessageBox.Show("条码不存在,请重新扫码");
this.NewBarCode.Text = "";
this.NewCount.Text = string.Empty;
}
}
}
catch

@ -33,8 +33,9 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="请选择容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<ComboBox x:Name="ContainerCodeBox" IsEditable="True" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />
<ComboBox x:Name="ContainerCodeBox" IsEditable="True" DisplayMemberPath="containerNo" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />
<Button x:Name="SearchBtn" Content="搜索" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="SearchBtn_Click"/>
<Button Content="编辑" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="EditBtn_Click"/>
</StackPanel>
<DataGrid
Style="{StaticResource DataGridStyle}"

@ -4,8 +4,10 @@ using Khd.Core.Wpf.TaskForm.Inventory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Media.Media3D;
namespace Khd.Core.Wpf.TaskForm
{
@ -31,11 +33,11 @@ namespace Khd.Core.Wpf.TaskForm
var wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 100 && t.taskStatus == 6).ToList();
if (wcsTasks.Count > 0)
{
this.ContainerCodeBox.ItemsSource = wcsTasks.Select(t => t.containerNo).Distinct();
this.ContainerCodeBox.ItemsSource = wcsTasks.Distinct();
}
else
{
MessageBox.Show("未找到盘库已完成的小车任务!");
HandyControl.Controls.MessageBox.Show("未找到盘库已完成的小车任务!");
this.Close();
}
}
@ -47,13 +49,13 @@ namespace Khd.Core.Wpf.TaskForm
private void GetData()
{
if (this.ContainerCodeBox.SelectedItem != null)
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTask = dbContext.WcsTask
.Where(t => t.taskType == 100)
.Where(t => t.containerNo == this.ContainerCodeBox.Text).FirstOrDefault();
.Where(t => t.containerNo == task.containerNo).FirstOrDefault();
if (wcsTask != null)
{
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
@ -76,13 +78,13 @@ namespace Khd.Core.Wpf.TaskForm
this.InventoryDataGrid.Items.Refresh();
if (wmsInventoryCheckDetails.Count == 0)
{
MessageBox.Show("该料箱为空料箱");
HandyControl.Controls.MessageBox.Show("该料箱为空料箱");
}
}
}
else
{
MessageBox.Show("请先选择料箱号!");
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
}
}
@ -92,6 +94,8 @@ namespace Khd.Core.Wpf.TaskForm
}
private void EditBtn_Click(object sender, RoutedEventArgs e)
{
if(this.InventoryDataGrid.SelectedItem!= null)
{
dynamic item = this.InventoryDataGrid.SelectedItem;
long materialId = item.MaterialId;
@ -103,6 +107,20 @@ namespace Khd.Core.Wpf.TaskForm
editForm.ShowDialog();
GetData();
}
else
{
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, task.containerNo, "", task.currPointNo, this);
this.Hide();
editForm.ShowDialog();
GetData();
}
else
{
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
}
}
}
}
}

@ -13,10 +13,12 @@ namespace Khd.Core.Wpf.TaskForm
public partial class SelectOutRawForm : Window
{
private readonly IHost _host;
public SelectOutRawForm(IHost host)
private readonly string _ud3;
public SelectOutRawForm(IHost host,string ud3)
{
InitializeComponent();
_host = host;
_ud3 = ud3;
}
private void Button_Click_1(object sender, RoutedEventArgs e)
@ -36,6 +38,7 @@ namespace Khd.Core.Wpf.TaskForm
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = dbContext.BaseEquip.Where(t => t.objid == 10).First();
baseEquip.endStationCode = this.endStationCode.SelectedItem.ToString();
baseEquip.ud3 = _ud3;
dbContext.BaseEquip.Update(baseEquip);
dbContext.SaveChanges();
MessageBox.Show("保存成功!");

@ -4,8 +4,8 @@
//"DefaultConnection": "server=106.12.13.113;port=3306;database=khd_jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
//khd
//"DefaultConnection": "server=172.16.12.100;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khdrkjy2024...;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
//"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
//"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
},
"PlcConfigs": [
{

Loading…
Cancel
Save