1 year ago
parent 580702fa49
commit d6d5ac3b80

@ -1,5 +1,7 @@
using Admin.Core.IService;
using Admin.Core.Model;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Admin.Core.IService
{
@ -8,5 +10,13 @@ namespace Admin.Core.IService
/// </summary>
public interface IBaseBomInfoServices : IBaseServices<BaseBomInfo>
{
/// <summary>
/// 根据成品物料码获取自己BOM信息
/// </summary>
/// <param name="materialCode"></param>
/// <param name="materialType"></param>
/// <returns></returns>
Task<BaseBomInfo> GetChildenBomInfoByMaterialCode(string materialCode, string materialType);
}
}

@ -2,16 +2,68 @@
using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using log4net;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.IdentityModel.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Admin.Core.Service
{
public class BaseBomInfoServices : BaseServices<BaseBomInfo>, IBaseBomInfoServices
{
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseBomInfoServices));
private readonly IBaseRepository<BaseBomInfo> _dal;
public BaseBomInfoServices(IBaseRepository<BaseBomInfo> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
public async Task<BaseBomInfo> GetChildenBomInfoByMaterialCode(string materialCode, string materialType)
{
BaseBomInfo bomInfo = null;
try
{
var info =await GetChildenByParentId(materialCode);
if (info.Count > 0)
{
bomInfo = info.FirstOrDefault(x => x.MaterialType == materialType);
}
}
catch (Exception ex)
{
logHelper.Error("获取BOM集合异常", ex);
}
return bomInfo;
}
private async Task<List<BaseBomInfo>> GetChildenByParentId(string parentId, List<BaseBomInfo> result = null)
{
if (result == null)
{
result = new List<BaseBomInfo>();
}
try
{
var info =await _dal.QueryAsync(x => x.ParentId == parentId);
if (info.Count > 0)
{
foreach (var item in info)
{
result.Add(item);
var childInfos = GetChildenByParentId(item.MaterialCode, result);
}
}
}
catch (Exception ex)
{
logHelper.Error("获取BOM集合异常", ex);
}
return result;
}
}
}

@ -15,7 +15,7 @@ using StackExchange.Profiling.Internal;
/// </summary>
namespace Admin.Core.Tasks
{
public class Job_PQInStoreTask_Quartz : JobBase, IJob
public class Job_BoxFoamInStoreTask_Quartz : JobBase, IJob
{
#region 事件
@ -66,7 +66,7 @@ namespace Admin.Core.Tasks
private readonly IBaseStoreInfoServices _baseStoreInfoServices;
private readonly IBaseSpaceDetailServices _baseSpaceDetailServices;
public Job_PQInStoreTask_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
public Job_BoxFoamInStoreTask_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
IBaseSpaceInfoServices baseSpaceInfoServices, IRealTaskInfoServices realTaskInfoService,
IProductPlanInfoServices productPlanInfoServices, IRecordInstoreServices recordInstoreServices,
IBaseStoreInfoServices baseStoreInfoServices, IBaseSpaceDetailServices IBaseSpaceDetailServices)

@ -0,0 +1,138 @@
using Admin.Core.Common;
using Admin.Core.IService;
using Admin.Core.IService.ISys;
using Admin.Core.Model;
using Admin.Core.Service;
using Aucma.Core.PLc;
using log4net;
using Quartz;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
/// <summary>
/// 这里要注意下,命名空间和程序集是一样的,不然反射不到
/// </summary>
namespace Admin.Core.Tasks
{
public class Job_BoxFoamOutStore_Quartz : JobBase, IJob
{
#region 初始化出库任务
/// <summary>
/// 初始化出库任务
/// </summary>
/// <param name="message"></param>
public delegate void RefreshOutStoreTask(RealTaskInfo taskInfos);
public event RefreshOutStoreTask RefreshOutStoreTaskEvent;
#endregion
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(Job_BoxFoamOutStore_Quartz));
protected readonly IBaseOrderInfoServices _baseOrderInfoServices;
protected readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
protected readonly IBaseBomInfoServices _baseBomInfoServices;
protected readonly IRealTaskInfoServices _realTaskInfoServices;
protected readonly IExecutePlanInfoServices _executePlanInfoServices;
public Job_BoxFoamOutStore_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
IBaseOrderInfoServices baseOrderInfoServices, IBaseSpaceInfoServices baseSpaceInfoServices,
IRealTaskInfoServices realTaskInfoServices,IBaseBomInfoServices baseBomInfoServices, IExecutePlanInfoServices executePlanInfoServices)
{
_SysTasksQzService = SysTasksQzService;
_sysJobLogService = sysJobLogService;
_baseOrderInfoServices = baseOrderInfoServices;
_baseSpaceInfoServices = baseSpaceInfoServices;
_baseBomInfoServices = baseBomInfoServices;
_realTaskInfoServices = realTaskInfoServices;
_executePlanInfoServices = executePlanInfoServices;
}
public async Task Execute(IJobExecutionContext context)
{
await ExecuteJob(context, async () => await Run(context));
}
public async Task Run(IJobExecutionContext context)
{
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("泡前库"));
if (obj.IsConnect)
{
var val = obj.plc.ReadBool("M100");
if (val)
{
//查询库存情况、获取发泡夹类型
var planInfo = await _executePlanInfoServices.FirstAsync();
await PlanHandle(planInfo);
}
}
}
private async Task PlanHandle(ExecutePlanInfo planInfo)
{
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//读取泡前库标识
if (planInfo != null)
{
var boxBomInfo = await _baseBomInfoServices.GetChildenBomInfoByMaterialCode(planInfo.MaterialCode, storeCode);
OutStore(storeCode, boxBomInfo, planInfo.ExecutePlanCode);
}
}
private async void OutStore(string storeCode, BaseBomInfo bomInfo, string planCode)
{
try
{
log.Info($"收到出库计划,物料码:{bomInfo.MaterialCode}");
BaseSpaceInfo spaceInfo = await _baseSpaceInfoServices.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.MaterialCode);
if (spaceInfo != null)
{
log.Info($"匹配货道:{spaceInfo.SpaceName}");
// RefreshScanMateriaCodeEvent?.Invoke(materiaclCode, materialType, spaceInfo.spaceName, storeCode); //刷新界面扫码信息
CreateOutStoreTask(spaceInfo, bomInfo, planCode); //创建出库任务
}
else
{
//报警停线
}
}
catch (Exception ex)
{
log.Info($"出库业务异常:{ex.Message}");
}
}
#region 创建出库任务
/// <summary>
/// 创建出库任务
/// </summary>
/// <param name="spaceInfo"></param>
private async void CreateOutStoreTask(BaseSpaceInfo spaceInfo, BaseBomInfo bomInfo, string planCode)
{
//生成出库任务依次下发至PLC
RealTaskInfo realTaskInfo = new RealTaskInfo();
realTaskInfo.PlanCode = planCode;
realTaskInfo.TaskType = 2;
realTaskInfo.TaskCode = System.Guid.NewGuid().ToString("N").Substring(0, 6);
realTaskInfo.StoreCode = spaceInfo.StoreCode;
realTaskInfo.SpaceCode = spaceInfo.SpaceCode;
realTaskInfo.SpaceName = spaceInfo.SpaceName;
realTaskInfo.MaterialType = bomInfo.MaterialName;
realTaskInfo.MaterialCode = bomInfo.MaterialCode;
realTaskInfo.PlanAmount = 1;
realTaskInfo.TaskStatus = 1;
realTaskInfo.CreateTime = DateTime.Now;
int result = await _realTaskInfoServices.AddAsync(realTaskInfo);
if (result > 0)
{
log.Info("出库任务创建成功");
RefreshOutStoreTaskEvent?.Invoke(realTaskInfo);
}
else
{
log.Error("出库任务创建失败");
}
}
#endregion
}
}

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

@ -25,10 +25,10 @@ namespace Aucma.Core.BoxFoam.ViewModels
public IndexPageViewModel()
{
_recordInstoreServices = App.ServiceProvider.GetService<IRecordInstoreServices>();
Job_PQInStoreTask_Quartz.RefreshDataGridDelegateEvent += LoadData;//刷新底部列表
Job_BoxFoamInStoreTask_Quartz.RefreshDataGridDelegateEvent += LoadData;//刷新底部列表
Job_TestTask_Quartz.DataGridDelegateEvent += ExecMethod;//刷新日志
Job_PQInStoreTask_Quartz.RefreshScanMateriaCodeEvent += RefreshScanInfo;//扫码信息刷新
Job_PQInStoreTask_Quartz.LogDelegateEvent += PrintMessageToListBox;//入库日志事件
Job_BoxFoamInStoreTask_Quartz.RefreshScanMateriaCodeEvent += RefreshScanInfo;//扫码信息刷新
Job_BoxFoamInStoreTask_Quartz.LogDelegateEvent += PrintMessageToListBox;//入库日志事件
}
public async Task ExecMethod()

@ -64,7 +64,7 @@
<StackPanel Grid.Row="1" Height="50" Orientation="Horizontal" Margin="5 0" HorizontalAlignment="Left">
<Button Content="实时监控" x:Name="FirstPage" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=FirstPage}" Margin="5 0" />
<Button Content="实时库存" x:Name="RealTimeInventoryPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=RealTimeInventoryPage}" />
<!--<Button Content="任务监控" x:Name="MonitorPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=MonitorPage}" />-->
<Button Content="任务监控" x:Name="MonitorPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=MonitorPage}" />
<Button Content="入库统计" x:Name="StatisticsPage" Margin="5 0" Command="{Binding SwitchPagesCommand}" CommandParameter="{Binding Name,ElementName=StatisticsPage}" />
<Button Content="键盘" x:Name="TabTip" Margin="5 0" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=TabTip}" />
<Button Content="最小化" x:Name="Minimized" Command="{Binding FormControlCommand}" CommandParameter="{Binding Name,ElementName=Minimized}" Width="100" Height="30" Background="#FF9900" BorderBrush="#FF9900" Margin="0,0,10,0"/>

Loading…
Cancel
Save