change-泡前库入库多种型号,发泡机状态

dev
liuwf 1 year ago
parent 3f2d4e9312
commit b14f8ad298

@ -37,7 +37,7 @@ namespace Admin.Core.Service
#region 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 #region 入库通过物料类型获取指定货道,如果没有对应类型的货道停住
/// <summary> /// <summary>
/// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 /// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道
/// </summary> /// </summary>
@ -50,15 +50,12 @@ namespace Admin.Core.Service
List<BaseSpaceInfo> spaceInfos = null; List<BaseSpaceInfo> spaceInfos = null;
try try
{ {
spaceInfos = await _baseSpaceInfoRepository.QueryAsync(x => x.StoreCode == store && x.MaterialType == materialType && x.SpaceStatus == 1); spaceInfos = await _baseSpaceInfoRepository.QueryAsync(x => x.StoreCode == store && (x.MaterialType == materialType || x.typeCodeB == materialType || x.typeCodeC == materialType ) && x.SpaceStatus == 1);
if (spaceInfos==null || spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配 if (spaceInfos == null || spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配
spaceInfos = await GetEmptySpaceInfo(store); return null;
logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{spaceInfos.ToJson()}"); logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{spaceInfos.ToJson()}");
//spaceInfo = InStoreFilter(spaceInfos);
//logHelper.Info($"仓库{store};物料:{materialType};匹配的入库货道信息:{spaceInfo.ToJson()}");
//spaceInfo.MaterialType = materialType;
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules = build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Tasks build_property.RootNamespace = Admin.Core.Tasks
build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Tasks\ build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Tasks\

@ -11,6 +11,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -68,6 +69,7 @@ namespace Aucma.Core.BoxFoam.Business
semaphore.WaitOne(); semaphore.WaitOne();
try try
{ {
Thread.Sleep(3000); Thread.Sleep(3000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamMachinePlc")); var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamMachinePlc"));
if (obj != null) if (obj != null)
@ -79,6 +81,7 @@ namespace Aucma.Core.BoxFoam.Business
ReadGunData(obj, "DB50.1084", gunKeys, "B1"); //B1枪数据 ReadGunData(obj, "DB50.1084", gunKeys, "B1"); //B1枪数据
ReadGunData(obj, "DB50.1272", gunKeys, "A2"); //A2枪数据 ReadGunData(obj, "DB50.1272", gunKeys, "A2"); //A2枪数据
ReadGunData(obj, "DB50.1460", gunKeys, "B2"); //A2枪数据 ReadGunData(obj, "DB50.1460", gunKeys, "B2"); //A2枪数据
RefreshSystemDataDelegateEvent?.Invoke(systemKeys); RefreshSystemDataDelegateEvent?.Invoke(systemKeys);
RefreshGunDataDelegateEvent?.Invoke(gunKeys); RefreshGunDataDelegateEvent?.Invoke(gunKeys);
@ -99,6 +102,7 @@ namespace Aucma.Core.BoxFoam.Business
} }
tempKeys.Add(kvPair.Key, record); tempKeys.Add(kvPair.Key, record);
} }
//有变化更新记录所有信息
if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff)) if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff))
{ {
kvPair.Value.ProductLineCode = "CX_02"; kvPair.Value.ProductLineCode = "CX_02";
@ -107,6 +111,17 @@ namespace Aucma.Core.BoxFoam.Business
int b = _lastShotRecordServices.AddAsync(kvPair.Value).Result; int b = _lastShotRecordServices.AddAsync(kvPair.Value).Result;
RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value); RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value);
} }
// 设备状态变化,更新设备状态
if (kvPair.Value.SystemStatus!= tempKeys[kvPair.Key].SystemStatus)
{
BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System.Equals(kvPair.Value.System) && x.ProductLineCode.Equals(kvPair.Value.ProductLineCode) && x.GunCode.Equals(kvPair.Value.GunCode)).OrderByDescending(x => x.CreateTime).FirstOrDefault();
if (record != null)
{
record.SystemStatus = kvPair.Value.SystemStatus;
bool flag = _lastShotRecordServices.UpdateAsync(record).Result;
}
}
} }
@ -210,6 +225,8 @@ namespace Aucma.Core.BoxFoam.Business
BoxLastShotRecord lastShotRecord = new BoxLastShotRecord(); BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
lastShotRecord.System = gunCode.Substring(1, 1); lastShotRecord.System = gunCode.Substring(1, 1);
lastShotRecord.GunCode = gunCode; lastShotRecord.GunCode = gunCode;
// 系统状态
if(lastShotRecord.System == "1") if(lastShotRecord.System == "1")
{ {
if(obj.plc.ReadBool("DB50.388.0")) if(obj.plc.ReadBool("DB50.388.0"))

@ -111,11 +111,11 @@ namespace Aucma.Core.BoxFoam.Business
spaceAddresses.Add(spaceConfig.GetSpaceAddress(storeCode, space.SpaceCode)); spaceAddresses.Add(spaceConfig.GetSpaceAddress(storeCode, space.SpaceCode));
} }
// 模拟入库 // 模拟入库
//Task.Run(() => Task.Run(() =>
//{ {
// Thread.Sleep(2000); Thread.Sleep(5000);
// InStore("B24010181060282920011"); InStore("B24010183025024860011");
//}); });
//实时监测入库任务下发和入库任务完成 //实时监测入库任务下发和入库任务完成
StartPassDownAndRealInstoreFinish(); StartPassDownAndRealInstoreFinish();
} }
@ -272,6 +272,7 @@ namespace Aucma.Core.BoxFoam.Business
BaseSpaceInfo spaceInfo = await GetSpaceInfoByMaterialType(storeCode, materialType); BaseSpaceInfo spaceInfo = await GetSpaceInfoByMaterialType(storeCode, materialType);
if (spaceInfo != null) if (spaceInfo != null)
{ {
logHelper.Info($"匹配货道:{spaceInfo.ToJson()}"); logHelper.Info($"匹配货道:{spaceInfo.ToJson()}");
LogDelegateEvent?.Invoke($"匹配货道:{spaceInfo.ToJson()}"); LogDelegateEvent?.Invoke($"匹配货道:{spaceInfo.ToJson()}");
@ -298,6 +299,8 @@ namespace Aucma.Core.BoxFoam.Business
else else
{ {
//报警停线 //报警停线
LogDelegateEvent?.Invoke($"未匹配到货道,请设置货道型号!");
} }
} }
catch (Exception ex) catch (Exception ex)
@ -364,18 +367,37 @@ namespace Aucma.Core.BoxFoam.Business
BaseSpaceInfo result = null; BaseSpaceInfo result = null;
try try
{ {
// List<BaseSpaceInfo> info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType);
List<BaseSpaceInfo> info = await _baseSpaceInfoServices.InStoreGetSpaceInfoByMaterialType(storeCode, materialType); List<BaseSpaceInfo> info = await _baseSpaceInfoServices.InStoreGetSpaceInfoByMaterialType(storeCode, materialType);
if (info != null) if (info != null)
{ {
if (info.Count > 0) if (info.Count > 0)
{ {
// 更新货道库存
foreach (BaseSpaceInfo item in info) foreach (BaseSpaceInfo item in info)
{ {
var spaceInfo = ReadSpaceInfoByPlc(item); var spaceInfo = ReadSpaceInfoByPlc(item);
item.SpaceStock = spaceInfo.SpaceStock; item.SpaceStock = spaceInfo.SpaceStock;
// item.OnRouteAmount = spaceInfo.OnRouteAmount;
// item.SpaceStatus = spaceInfo.SpaceStatus; if(item.typeCodeB.Equals(materialType) && (item.SpaceStock+item.OnRouteAmount)==0)
{
string str1 = item.typeCodeB;
string str2 = item.typeNameB;
item.typeCodeB = item.MaterialType;
item.typeNameB = item.typeNameA;
item.MaterialType = str1;
item.typeNameA = str2;
}
// 对调C型号和主型号
else if(spaceInfo.typeCodeC.Equals(materialType) && (item.SpaceStock + item.OnRouteAmount) == 0)
{
string str1 = item.typeCodeC;
string str2 = item.typeNameC;
item.typeCodeC = item.MaterialType;
item.typeNameC = item.typeNameA;
item.MaterialType = str1;
item.typeNameA = str2;
}
} }
info = info.Where(x => x.SpaceStatus == 1 && x.SpaceCapacity > (x.SpaceStock + x.OnRouteAmount)).ToList(); info = info.Where(x => x.SpaceStatus == 1 && x.SpaceCapacity > (x.SpaceStock + x.OnRouteAmount)).ToList();
@ -407,8 +429,7 @@ namespace Aucma.Core.BoxFoam.Business
{ {
SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.StoreCode, spaceInfo.SpaceCode); SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.StoreCode, spaceInfo.SpaceCode);
spaceInfo.SpaceStock = obj.plc.ReadInt16(spaceAddress.onStore); spaceInfo.SpaceStock = obj.plc.ReadInt16(spaceAddress.onStore);
// spaceInfo.OnRouteAmount = obj.plc.ReadInt32(spaceAddress.onRoute);
// spaceInfo.SpaceStatus = obj.plc.ReadInt32(spaceAddress.spaceStatus);
} }
return spaceInfo; return spaceInfo;
} }
@ -551,12 +572,15 @@ namespace Aucma.Core.BoxFoam.Business
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息 #region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
var item = ReadSpaceInfoByPlc(spaceInfo); var item = ReadSpaceInfoByPlc(spaceInfo);
spaceInfo.SpaceStock = item.SpaceStock; spaceInfo.SpaceStock = item.SpaceStock;
if (spaceInfo.OnRouteAmount>0)
{
// 入库完成在途减1 // 入库完成在途减1
spaceInfo.OnRouteAmount -= 1; spaceInfo.OnRouteAmount -= 1;
}
#endregion #endregion
await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
#region 添加货道明细 不控制出库,暂时未添加明细 #region 添加货道明细 不控制出库,暂时未添加明细
BaseSpaceDetail spaceDetail = new BaseSpaceDetail(); BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
@ -580,10 +604,15 @@ namespace Aucma.Core.BoxFoam.Business
recordInstore.InStoreTime = DateTime.Now; recordInstore.InStoreTime = DateTime.Now;
recordInstore.BarCodeCode = taskInfo.MaterialCode; recordInstore.BarCodeCode = taskInfo.MaterialCode;
#endregion #endregion
bool result = await _recordInstoreServices.SaveRecordToDb(recordInstore, taskInfo, spaceInfo, spaceDetail);
await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
_ = _recordInstoreServices.AddAsync(recordInstore).Result;
bool result = _realTaskInfoService.DeleteAsync(taskInfo).Result;
// bool result = await _recordInstoreServices.SaveRecordToDb(recordInstore, taskInfo, spaceInfo, spaceDetail);
if (result) if (result)
{ {
LogDelegateEvent?.Invoke($"入库完成,更新数据库成功"); LogDelegateEvent?.Invoke($"入库完成,更新数据库成功");
RefreshDataGridDelegateEvent?.Invoke();//刷新datagrid 列表
} }
else else
{ {

@ -42,6 +42,10 @@ namespace Aucma.Core.BoxFoam.Models
/// </summary> /// </summary>
public string typeCodeB { get; set; } public string typeCodeB { get; set; }
/// <summary> /// <summary>
/// 物料型号C
/// </summary>
public string typeCodeC { get; set; }
/// <summary>
/// 入库状态 /// 入库状态
/// </summary> /// </summary>
public string inStoreFlag { get; set; } public string inStoreFlag { get; set; }

@ -32,6 +32,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
// 设置型号 // 设置型号
SubmitCommand = new RelayCommand<string>(obj => SubmitCommandExecute(obj)); SubmitCommand = new RelayCommand<string>(obj => SubmitCommandExecute(obj));
SubmitCommand2 = new RelayCommand<string>(obj => SubmitCommandExecute2(obj)); SubmitCommand2 = new RelayCommand<string>(obj => SubmitCommandExecute2(obj));
SubmitCommand3 = new RelayCommand<string>(obj => SubmitCommandExecute3(obj));
_baseSpaceDetailServices = App.ServiceProvider.GetService<IBaseSpaceDetailServices>(); _baseSpaceDetailServices = App.ServiceProvider.GetService<IBaseSpaceDetailServices>();
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>(); _baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
SelectTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync; SelectTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync;
@ -59,6 +60,16 @@ namespace Aucma.Core.BoxFoam.ViewModels
SelectType type = new SelectType(2, spaceCode); SelectType type = new SelectType(2, spaceCode);
type.ShowDialog(); type.ShowDialog();
}
public RelayCommand<string> SubmitCommand3 { get; set; }
private void SubmitCommandExecute3(string spaceCode)
{
SelectType type = new SelectType(3, spaceCode);
type.ShowDialog();
} }
#endregion #endregion
@ -83,6 +94,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
model.totalAmount = item.SpaceStock + item.OnRouteAmount; model.totalAmount = item.SpaceStock + item.OnRouteAmount;
model.materialType = item.MaterialType; model.materialType = item.MaterialType;
model.typeCodeB = item.typeCodeB; model.typeCodeB = item.typeCodeB;
model.typeCodeC = item.typeCodeC;
model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White"; model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White";
if (item.SpaceStatus == 2) if (item.SpaceStatus == 2)
{ {

@ -81,6 +81,8 @@ namespace Aucma.Core.BoxFoam.ViewModels
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private Task InitEveryDayMethod() private Task InitEveryDayMethod()
{
try
{ {
ProductionHourList = new List<string>(); ProductionHourList = new List<string>();
List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result; List<WorkTime> listTime = _baseBomInfoServices.getWorkTime().Result;
@ -90,14 +92,15 @@ namespace Aucma.Core.BoxFoam.ViewModels
} }
// 货道列表 // 货道列表
List<BoxFoamData> list = _boxFoamDataServices.QueryAsync(x=>x.ProductLineCode.Equals("CX_02") && x.StationCode=="1005").Result; List<BoxFoamData> list = _boxFoamDataServices.QueryAsync(x => x.ProductLineCode.Equals("CX_02") && x.StationCode == "1005").Result;
if(list != null) if (list != null)
{ {
ChartValues<double> achievement = new ChartValues<double>(); ChartValues<double> achievement = new ChartValues<double>();
//Achievement.Clear(); //Achievement.Clear();
#region 按时间统计 #region 按时间统计
if(list.Count > 0) { if (list.Count > 0)
{
achievement.Add(list.Sum(x => x.AnHour)); achievement.Add(list.Sum(x => x.AnHour));
achievement.Add(list.Sum(x => x.TwoHour)); achievement.Add(list.Sum(x => x.TwoHour));
achievement.Add(list.Sum(x => x.ThreeHour)); achievement.Add(list.Sum(x => x.ThreeHour));
@ -120,7 +123,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
// Achievement.Add(column); // Achievement.Add(column);
if (Achievement.Count > 0) if (Achievement.Count > 0)
{ {
for(int i = 0; i < achievement.Count; i++) for (int i = 0; i < achievement.Count; i++)
{ {
Achievement.FirstOrDefault().Values[i] = achievement[i]; Achievement.FirstOrDefault().Values[i] = achievement[i];
} }
@ -157,7 +160,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
// ModelStatistics.Add(column2); // ModelStatistics.Add(column2);
if (ModelStatistics.Count > 0) if (ModelStatistics.Count > 0)
{ {
for(int i=0;i< achievement2.Count; i++) for (int i = 0; i < achievement2.Count; i++)
{ {
ModelStatistics.FirstOrDefault().Values[i] = achievement2[i]; ModelStatistics.FirstOrDefault().Values[i] = achievement2[i];
} }
@ -170,7 +173,13 @@ namespace Aucma.Core.BoxFoam.ViewModels
#endregion #endregion
} }
//await InitExecMethod();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
}
return Task.CompletedTask; return Task.CompletedTask;
} }

@ -106,7 +106,7 @@
<Grid Margin="3,3"> <Grid Margin="3,3">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="2*"/> <RowDefinition Height="3*"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Grid.Row="0"> <Border Grid.Row="0">
@ -148,7 +148,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition/> <RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/> <ColumnDefinition Width="1.5*"/>
@ -170,14 +170,14 @@
<TextBlock Text="{Binding typeCodeB}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" /> <TextBlock Text="{Binding typeCodeB}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
</Border> </Border>
<!--<Border Grid.Column="0" Grid.Row="2" BorderBrush="White" BorderThickness="1" > <Border Grid.Column="0" Grid.Row="2" BorderBrush="White" BorderThickness="1" >
<TextBlock Text="型号3" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="型号3" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border> </Border>
<Border Grid.Column="1" Grid.Row="2" BorderBrush="White" BorderThickness="1"> <Border Grid.Column="1" Grid.Row="2" BorderBrush="White" BorderThickness="1">
<Button Command="{Binding DataContext.SubmitCommand3, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent"> <Button Command="{Binding DataContext.SubmitCommand3, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding Text, ElementName=spaceCodeText}" Background="Transparent">
<TextBlock Text="{Binding typeCodeC}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" /> <TextBlock Text="{Binding typeCodeC}" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
</Border>--> </Border>
</Grid> </Grid>
</Border> </Border>

@ -179,7 +179,7 @@
<TextBlock Text="选择型号: " FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" /> <TextBlock Text="选择型号: " FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<RadioButton Content="型号1" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" /> <RadioButton Content="型号1" GroupName="Direction" IsChecked="{Binding IsSelectedOptionA, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" />
<RadioButton Content="型号2" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" /> <RadioButton Content="型号2" GroupName="Direction" IsChecked="{Binding IsSelectedOptionB, Mode=TwoWay}" Foreground="white" BorderBrush="White" Margin="15 0 0 0 " FontSize="18" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" />
<!--<RadioButton Content="型号3" GroupName="Direction" IsChecked="{Binding IsSelectedOptionC, Mode=TwoWay}" Margin="10 0 0 0"/>--> <RadioButton Content="型号3" GroupName="Direction" IsChecked="{Binding IsSelectedOptionC, Mode=TwoWay}" Margin="10 0 0 0"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">

Loading…
Cancel
Save