|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Aucma.Scada.UI.Common;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库业务逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class OutStoreBusiness
|
|
|
|
|
{
|
|
|
|
|
#region 单例实现
|
|
|
|
|
//private static readonly OutStoreBusiness lazy = new OutStoreBusiness();
|
|
|
|
|
//public static OutStoreBusiness Instance
|
|
|
|
|
//{
|
|
|
|
|
// get
|
|
|
|
|
// {
|
|
|
|
|
// return lazy;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 对象引用
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(OutStoreBusiness));
|
|
|
|
|
private AppConfig appConfig = new AppConfig();//AppConfig.Instance;
|
|
|
|
|
|
|
|
|
|
private AssemblyPlanBusiness assemblyPlanBusiness = new AssemblyPlanBusiness();// AssemblyPlanBusiness.Instance;
|
|
|
|
|
//注释所有实时信息
|
|
|
|
|
// private OutStoreTaskHandle taskHandleBusiness = OutStoreTaskHandle.Instance;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 接口引用
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 货道信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IBaseSpaceInfoServices _spaceInfoService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 实时任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IRealTaskInfoServices _taskInfoService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// BOM信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IBaseBomInfoServices _bomInfoService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
private IBaseSpaceDetailServices _spaceDetailService;
|
|
|
|
|
|
|
|
|
|
private IExecutePlanInfoServices _executePlanInfoService;
|
|
|
|
|
|
|
|
|
|
private IProductPlanInfoServices _productPlanInfoService;
|
|
|
|
|
|
|
|
|
|
private IRecordOutStoreServices _recordOutStoreService;
|
|
|
|
|
|
|
|
|
|
private IRecordProductFinishServices _recordProductfinishService;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 委托事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化出库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
public delegate void RefreshOutStoreTask(RealTaskInfo taskInfos);
|
|
|
|
|
public event RefreshOutStoreTask RefreshOutStoreTaskEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码信息刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialCode"></param>
|
|
|
|
|
/// <param name="materialName"></param>
|
|
|
|
|
/// <param name="spaceName"></param>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
public delegate void RefreshScanMateriaCode(string materialCode, string materialName, string spaceName, string storeCode);
|
|
|
|
|
public event RefreshScanMateriaCode RefreshScanMateriaCodeEvent;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志信息刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
public delegate void RefreshLogMessage(string message);
|
|
|
|
|
public event RefreshLogMessage RefreshLogMessageEvent;
|
|
|
|
|
|
|
|
|
|
public delegate void RefreshAssemblyPlanInit();
|
|
|
|
|
public event RefreshAssemblyPlanInit RefreshAssemblyPlanInitEvent;
|
|
|
|
|
|
|
|
|
|
public delegate void RefreshStoreStock();
|
|
|
|
|
public event RefreshStoreStock RefreshStoreStockEvent;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public OutStoreBusiness()
|
|
|
|
|
{
|
|
|
|
|
_spaceInfoService = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
|
|
|
|
|
_taskInfoService = App.ServiceProvider.GetService<IRealTaskInfoServices>();
|
|
|
|
|
_bomInfoService = App.ServiceProvider.GetService<IBaseBomInfoServices>();
|
|
|
|
|
_spaceDetailService = App.ServiceProvider.GetService<IBaseSpaceDetailServices>();
|
|
|
|
|
_executePlanInfoService = App.ServiceProvider.GetService<IExecutePlanInfoServices>();
|
|
|
|
|
_productPlanInfoService = App.ServiceProvider.GetService<IProductPlanInfoServices>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle;
|
|
|
|
|
//taskHandleBusiness.OutStoreAnswerEvent += OutStoreAnswer;
|
|
|
|
|
//taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish;
|
|
|
|
|
StartPassDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 接收下达的组装计划,根据BOM获取需要出库的箱壳、内胆物料信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planInfo"></param>
|
|
|
|
|
private void PlanHandle(ExecutePlanInfo planInfo)
|
|
|
|
|
{
|
|
|
|
|
lock (string.Empty)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
if (planInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var shellBomInfo =await _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.MaterialCode, appConfig.shellMaterialType);
|
|
|
|
|
var linerBomInfo =await _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.MaterialCode, appConfig.linerMaterialType);
|
|
|
|
|
|
|
|
|
|
if (shellBomInfo != null && linerBomInfo != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < planInfo.PlanAmount - planInfo.CompleteAmount; i++)
|
|
|
|
|
{
|
|
|
|
|
string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 10);
|
|
|
|
|
OutStore(appConfig.shellStoreCode, shellBomInfo, planInfo.ExecutePlanCode, taskCode);
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
OutStore(appConfig.linerStoreCode, linerBomInfo, planInfo.ExecutePlanCode, taskCode);
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"物料:{planInfo.MaterialCode};获取Bom信息为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 解析计划创建出库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="bomInfo"></param>
|
|
|
|
|
/// <param name="planCode"></param>
|
|
|
|
|
private async void OutStore(string storeCode, BaseBomInfo bomInfo, string planCode, string taskCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.MaterialCode}");
|
|
|
|
|
#region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量,改为通过PLC获取货道信息
|
|
|
|
|
//BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode);
|
|
|
|
|
#endregion
|
|
|
|
|
BaseSpaceInfo spaceInfo =await GetSpaceInfoByMaterialType(storeCode, bomInfo.MaterialCode);
|
|
|
|
|
if (spaceInfo != null)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"匹配货道:{spaceInfo.SpaceName}");
|
|
|
|
|
// RefreshScanMateriaCodeEvent?.Invoke(materiaclCode, materialType, spaceInfo.spaceName, storeCode); //刷新界面扫码信息
|
|
|
|
|
bool result =await CreateOutStoreTask(spaceInfo, planCode, taskCode); //创建出库任务
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("出库任务创建成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("出库任务创建失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//报警停线
|
|
|
|
|
PrintLogInfoMessage($"{storeCode};仓库内未获取到{bomInfo.MaterialCode}相匹配的物料及货道");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("出库业务异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建出库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceInfo"></param>
|
|
|
|
|
private async Task<bool> CreateOutStoreTask(BaseSpaceInfo spaceInfo, string planCode, string taksCode, int taskModel = 0)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//获取出库的货道明细物料信息
|
|
|
|
|
BaseSpaceDetail spaceDetail =await GetSpaceDetailFirstOrderByCreatTime(spaceInfo);
|
|
|
|
|
if (spaceDetail != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region 出库任务赋值
|
|
|
|
|
RealTaskInfo realTaskInfo = new RealTaskInfo();
|
|
|
|
|
realTaskInfo.PlanCode = planCode;
|
|
|
|
|
realTaskInfo.TaskType = 2;
|
|
|
|
|
realTaskInfo.TaskCode = taksCode;
|
|
|
|
|
realTaskInfo.TaskModel = taskModel;
|
|
|
|
|
realTaskInfo.StoreCode = spaceInfo.StoreCode;
|
|
|
|
|
realTaskInfo.SpaceCode = spaceInfo.SpaceCode;
|
|
|
|
|
realTaskInfo.SpaceName = spaceInfo.SpaceName;
|
|
|
|
|
realTaskInfo.MaterialType = spaceDetail.MaterialType;
|
|
|
|
|
realTaskInfo.MaterialCode = spaceDetail.MaterialCode;
|
|
|
|
|
realTaskInfo.PlanAmount = 1;
|
|
|
|
|
realTaskInfo.TaskStatus = 1;
|
|
|
|
|
realTaskInfo.CreateTime = DateTime.Now;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
result =await _taskInfoService.AddTaskInfo(realTaskInfo);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("出库任务创建成功");
|
|
|
|
|
|
|
|
|
|
RefreshOutStoreTaskEvent?.Invoke(realTaskInfo);
|
|
|
|
|
|
|
|
|
|
UpdateSpaceAndDetial(spaceInfo, spaceDetail);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("出库任务创建失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("出库任务创建异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据创建时间获取第一个货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task<BaseSpaceDetail> GetSpaceDetailFirstOrderByCreatTime(BaseSpaceInfo spaceInfo)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceDetail spaceDetail = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<BaseSpaceDetail> spaceDetails =await _spaceDetailService.GetSpaceDetailsBySpaceCode(spaceInfo.StoreCode, spaceInfo.SpaceCode);
|
|
|
|
|
if (spaceDetails.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
spaceDetails = spaceDetails.Where(x => x.IsFlag != 1).ToList();
|
|
|
|
|
if (spaceDetails.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
spaceDetail = spaceDetails.OrderBy(x => x.CreatedTime).First();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("获取货道明细信息异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return spaceDetail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 任务创建完成后修改货道信息及货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceInfo"></param>
|
|
|
|
|
/// <param name="spaceDetail"></param>
|
|
|
|
|
private void UpdateSpaceAndDetial(BaseSpaceInfo spaceInfo, BaseSpaceDetail spaceDetail, int detailIsFlag = 1, bool stockFlag = true)
|
|
|
|
|
{
|
|
|
|
|
//任务创建完成后修改货道库存、货道明细修改物料标识物料不可用
|
|
|
|
|
spaceDetail.IsFlag = detailIsFlag;
|
|
|
|
|
var result = _spaceDetailService.UpdateSpaceDetail(spaceDetail);
|
|
|
|
|
|
|
|
|
|
//if (stockFlag)
|
|
|
|
|
//{
|
|
|
|
|
// spaceInfo.spaceStock = spaceInfo.spaceStock > 0 ? spaceInfo.spaceStock - 1 : 0;
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
|
|
|
|
|
//}
|
|
|
|
|
spaceInfo.OutRouteAmount += 1;
|
|
|
|
|
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 轮询获取出库任务下发至PLC,等待PLC执行反馈,完成后再次下发
|
|
|
|
|
|
|
|
|
|
private SemaphoreSlim semaphore = new SemaphoreSlim(0);
|
|
|
|
|
private int completedTasks = 0;
|
|
|
|
|
|
|
|
|
|
private int taskAmount = 2;
|
|
|
|
|
|
|
|
|
|
private SemaphoreSlim shellSemaphore = new SemaphoreSlim(0);
|
|
|
|
|
|
|
|
|
|
private SemaphoreSlim linerSemaphore = new SemaphoreSlim(0);
|
|
|
|
|
|
|
|
|
|
private void StartPassDown()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
PassDownShellTask();
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
PassDownLinerTask();
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下传箱壳出库任务至PLC
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void PassDownShellTask()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//获取箱壳出库任务
|
|
|
|
|
RealTaskInfo taskInfo =await _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, appConfig.outstoreTaskType);
|
|
|
|
|
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发箱壳出库任务:{taskInfo.TaskCode};仓库{taskInfo.StoreCode};货道:{taskInfo.SpaceCode}");
|
|
|
|
|
|
|
|
|
|
// if (taskHandleBusiness.SendShellTask_OutStore(taskInfo))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"箱壳出库任务:{taskInfo.TaskCode};下发成功,等待PLC执行反馈");
|
|
|
|
|
|
|
|
|
|
shellSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage($"箱壳入库任务:{taskInfo.TaskCode};开始执行");
|
|
|
|
|
|
|
|
|
|
taskInfo.TaskStatus = 2;
|
|
|
|
|
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshScanMateriaCodeEvent?.Invoke(taskInfo.MaterialCode, taskInfo.MaterialType, taskInfo.SpaceName, taskInfo.StoreCode);
|
|
|
|
|
}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// PrintLogInfoMessage($"箱壳出库任务:{taskInfo.TaskCode};下发失败,请排除PLC连接");
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到需要下发的箱壳出库任务");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("下传箱壳出库任务逻辑处理异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 依次获取内胆任务队列进行下发
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async void PassDownLinerTask()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo taskInfo =await _taskInfoService.GetTaskInfoByStoreCode(appConfig.linerStoreCode, appConfig.outstoreTaskType);
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发内胆出库任务:{taskInfo.TaskCode};仓库{taskInfo.StoreCode};货道:{taskInfo.SpaceCode}");
|
|
|
|
|
|
|
|
|
|
// if (taskHandleBusiness.SendLinerTask_OutStore(taskInfo))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"内胆出库任务:{taskInfo.TaskCode};下发成功,等待PLC执行反馈");
|
|
|
|
|
|
|
|
|
|
linerSemaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage($"内胆出库任务:{taskInfo.TaskCode};开始执行");
|
|
|
|
|
|
|
|
|
|
taskInfo.TaskStatus = 2;
|
|
|
|
|
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(taskInfo);
|
|
|
|
|
|
|
|
|
|
RefreshScanMateriaCodeEvent?.Invoke(taskInfo.MaterialCode, taskInfo.MaterialType, taskInfo.SpaceName, taskInfo.StoreCode);
|
|
|
|
|
}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// PrintLogInfoMessage($"内胆出库任务:{taskInfo.TaskCode};下发失败,请排除PLC连接");
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到需要下发的内胆出库任务");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("下传内胆出库任务逻辑处理异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 原任务下发逻辑 Delete By wenjy 2023-11-09 10:20:00 箱壳、内胆任务改为分别下发处理,PLC应答后继续下发新任务
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 依次获取任务队列进行下发
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="source"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
/*private void PassDownTaskInfo()
|
|
|
|
|
{
|
|
|
|
|
string shellCode = string.Empty;
|
|
|
|
|
string linerCode = string.Empty;
|
|
|
|
|
string taskCode = string.Empty;
|
|
|
|
|
string executePlanCode = string.Empty;
|
|
|
|
|
int iFlag = 0;
|
|
|
|
|
completedTasks = 0;
|
|
|
|
|
|
|
|
|
|
//获取待执行的出库任务下发至PLC,并将任务状态改为执行中
|
|
|
|
|
var taskInfoList = GetAwaitSendTask();
|
|
|
|
|
|
|
|
|
|
if (taskInfoList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
taskAmount = taskInfoList.Count; //下发的任务数量,默认2(箱壳、内胆),箱壳、内胆均执行完成后才会释放信号量
|
|
|
|
|
|
|
|
|
|
foreach (var item in taskInfoList)
|
|
|
|
|
{
|
|
|
|
|
taskCode = item.taskCode;
|
|
|
|
|
executePlanCode = item.planCode;
|
|
|
|
|
if (item.storeCode == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
if (taskHandleBusiness.SendShellTask_OutStore(item))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发箱壳出库任务:{item.taskCode};仓库{item.storeCode};货道:{item.spaceCode};等待PLC执行反馈");
|
|
|
|
|
item.taskStatus = 2;
|
|
|
|
|
iFlag++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"箱壳出库任务:{item.taskCode};下发失败,请排除PLC连接");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
shellCode = item.materialCode;
|
|
|
|
|
}
|
|
|
|
|
else if (item.storeCode == appConfig.linerStoreCode)
|
|
|
|
|
{
|
|
|
|
|
if (taskHandleBusiness.SendLinerTask_OutStore(item))
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"下发内胆出库任务:{item.taskCode};仓库{item.storeCode};货道:{item.spaceCode};等待PLC执行反馈");
|
|
|
|
|
item.taskStatus = 2;
|
|
|
|
|
iFlag++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"内胆出库任务:{item.taskCode};下发失败,请排除PLC连接");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
linerCode = item.materialCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_taskInfoService.UpdateTaskInfo(item);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iFlag == taskInfoList.Count)
|
|
|
|
|
{
|
|
|
|
|
semaphore.Wait(); //一直堵塞直到信号量释放
|
|
|
|
|
|
|
|
|
|
//PrintLogInfoMessage($"出库任务:{taskCode};应答成功,继续下发新任务");
|
|
|
|
|
|
|
|
|
|
var item = taskInfoList.First();
|
|
|
|
|
RefreshScanMateriaCodeEvent?.Invoke(item.materialCode, item.materialType, item.spaceName, item.storeCode);
|
|
|
|
|
|
|
|
|
|
//UpdatePlanInfo(executePlanCode);
|
|
|
|
|
|
|
|
|
|
//RefreshStoreStockEvent?.Invoke();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到需要下发的出库任务");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取待执行的出库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/*private List<RealTaskInfo> GetAwaitSendTask()
|
|
|
|
|
{
|
|
|
|
|
List<RealTaskInfo> taskInfos = new List<RealTaskInfo>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo shellTaskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.shellStoreCode, appConfig.outstoreTaskType);
|
|
|
|
|
|
|
|
|
|
if (shellTaskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
taskInfos.Add(shellTaskInfo);
|
|
|
|
|
//获取与箱壳任务匹配的内胆任务
|
|
|
|
|
RealTaskInfo linerTaskInfo = _taskInfoService.GetTaskInfoByTaskCode(shellTaskInfo.taskCode, appConfig.linerStoreCode);
|
|
|
|
|
if (linerTaskInfo != null) taskInfos.Add(linerTaskInfo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RealTaskInfo linerInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.linerStoreCode, appConfig.outstoreTaskType);
|
|
|
|
|
if (linerInfo != null) taskInfos.Add(linerInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if(taskInfos.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// taskInfos.ForEach(x => x.taskStatus = 2);
|
|
|
|
|
// _taskInfoService.UpdateRangeTaskInfo(taskInfos);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("获取待执行的出库任务异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return taskInfos;
|
|
|
|
|
}*/
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region PLC应答反馈
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库应答
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
private void OutStoreAnswer(string storeCode, string taskCode)
|
|
|
|
|
{
|
|
|
|
|
if (storeCode == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
//Interlocked.Increment(ref completedTasks);
|
|
|
|
|
|
|
|
|
|
//CheckCompletedTasks();
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage("箱壳应答成功,自动释放信号量,进行下发新任务");
|
|
|
|
|
|
|
|
|
|
shellSemaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Interlocked.Increment(ref completedTasks);
|
|
|
|
|
|
|
|
|
|
//CheckCompletedTasks();
|
|
|
|
|
|
|
|
|
|
PrintLogInfoMessage("内胆应答成功,自动释放信号量,进行下发新任务");
|
|
|
|
|
|
|
|
|
|
linerSemaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
private void OutStoreFinish(string storeCode, string taskCode)
|
|
|
|
|
{
|
|
|
|
|
if (storeCode == appConfig.shellStoreCode)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"箱壳任务:{taskCode};执行完成");
|
|
|
|
|
OutStoreFinishHandle(taskCode, appConfig.shellStoreCode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"内胆任务:{taskCode};执行完成");
|
|
|
|
|
OutStoreFinishHandle(taskCode, appConfig.linerStoreCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 信号量释放,根据任务完成数量,执行完成后进行释放
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void CheckCompletedTasks()
|
|
|
|
|
{
|
|
|
|
|
if (completedTasks == taskAmount)
|
|
|
|
|
{
|
|
|
|
|
// 释放信号量
|
|
|
|
|
semaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库完成
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
private async void OutStoreFinishHandle(string taskCode, string storeCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var taskInfo =await _taskInfoService.GetTaskInfoByTaskCode(taskCode, storeCode);
|
|
|
|
|
if (taskInfo != null)
|
|
|
|
|
{
|
|
|
|
|
var spaceInfo =await _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.StoreCode, taskInfo.SpaceCode);
|
|
|
|
|
|
|
|
|
|
if (spaceInfo != null)
|
|
|
|
|
{
|
|
|
|
|
// taskHandleBusiness.WritePlc(spaceInfo.StoreCode, spaceInfo.SpaceCode);
|
|
|
|
|
//读取PLC获取货道信息:存放数量、在途数量
|
|
|
|
|
|
|
|
|
|
spaceInfo.SpaceStock -= 1;
|
|
|
|
|
spaceInfo.OutRouteAmount -= 1;
|
|
|
|
|
|
|
|
|
|
#region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息 2023-11-26
|
|
|
|
|
//var item = taskHandleBusiness.ReadSpaceInfoByPlc(spaceInfo);
|
|
|
|
|
//spaceInfo.SpaceStock = item.spaceStock;
|
|
|
|
|
//spaceInfo.OnRouteAmount = item.onRouteAmount;
|
|
|
|
|
//spaceInfo.SpaceStatus = item.spaceStatus;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (spaceInfo.SpaceStock == 0)
|
|
|
|
|
{
|
|
|
|
|
spaceInfo.MaterialType = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
await _spaceInfoService.UpdateSpaceInfo(spaceInfo);
|
|
|
|
|
|
|
|
|
|
#region 添加出库记录
|
|
|
|
|
RecordOutStore recordOutstore = new RecordOutStore();
|
|
|
|
|
recordOutstore.StoreCode = taskInfo.StoreCode;
|
|
|
|
|
recordOutstore.SpaceCode = taskInfo.SpaceCode;
|
|
|
|
|
recordOutstore.MaterialCode = taskInfo.MaterialCode;
|
|
|
|
|
recordOutstore.MaterialType = taskInfo.MaterialType;
|
|
|
|
|
recordOutstore.MaterialName =await GetMaterialName(taskInfo.MaterialType);
|
|
|
|
|
recordOutstore.OutStoreAmount = 1;
|
|
|
|
|
recordOutstore.OutStoreTime = DateTime.Now;
|
|
|
|
|
_recordOutStoreService.InsertReocrdOutStoreService(recordOutstore);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新计划信息
|
|
|
|
|
UpdatePlanInfo(taskInfo.PlanCode);
|
|
|
|
|
|
|
|
|
|
RefreshStoreStockEvent?.Invoke();
|
|
|
|
|
|
|
|
|
|
//清除任务信息
|
|
|
|
|
await _taskInfoService.DeleteTaskInfo(taskCode, storeCode);
|
|
|
|
|
|
|
|
|
|
await _spaceDetailService.DeleteSpaceDetailByMaterialCode(taskInfo.MaterialCode);
|
|
|
|
|
|
|
|
|
|
//刷新界面
|
|
|
|
|
RefreshScanMateriaCodeEvent?.Invoke(string.Empty, string.Empty, string.Empty, taskInfo.StoreCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("出库完成逻辑处理异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新计划信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planCode"></param>
|
|
|
|
|
private async void UpdatePlanInfo(string planCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var executeInfo =await _executePlanInfoService.GetExecutePlanInfoByPlanCode(planCode);
|
|
|
|
|
if (executeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
executeInfo.CompleteAmount += 1;
|
|
|
|
|
|
|
|
|
|
if (executeInfo.CompleteAmount == executeInfo.PlanAmount)
|
|
|
|
|
{
|
|
|
|
|
executeInfo.ExecuteStatus = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _executePlanInfoService.UpdateExecutePlanInfo(executeInfo);
|
|
|
|
|
|
|
|
|
|
var productInfo =await _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.ProductPlanCode);
|
|
|
|
|
if (productInfo != null)
|
|
|
|
|
{
|
|
|
|
|
productInfo.CompleteAmount += 1;
|
|
|
|
|
if (productInfo.CompleteAmount == productInfo.PlanAmount)
|
|
|
|
|
{
|
|
|
|
|
productInfo.EndTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _productPlanInfoService.UpdateProductPlanInfo(productInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 添加完成记录
|
|
|
|
|
RecordProductFinish productfinish = new RecordProductFinish();
|
|
|
|
|
productfinish.PlanCode = executeInfo.ExecutePlanCode;
|
|
|
|
|
productfinish.ProductlineCode = appConfig.stationCode;
|
|
|
|
|
productfinish.MaterialCode = executeInfo.MaterialCode;
|
|
|
|
|
productfinish.CompleteAmount = 1; //目前一个箱体一个任务下发给plc
|
|
|
|
|
productfinish.RecordTime = DateTime.Now;
|
|
|
|
|
_recordProductfinishService.InsertRecordProductfinish(productfinish);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RefreshAssemblyPlanInitEvent?.Invoke();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("计划信息更新异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取出库任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<RealTaskInfo>> GetOutStoreTask()
|
|
|
|
|
{
|
|
|
|
|
var taskInfos =await _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.shellStoreCode, appConfig.linerStoreCode }, appConfig.outstoreTaskType);
|
|
|
|
|
return taskInfos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过任务编号删除任务
|
|
|
|
|
///
|
|
|
|
|
/// 任务删除后是否需要还原库存,如果出库完成后减少库存则不需要
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> DeleteTaskInfoByTaskCode(string taskCode)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
var info = await _taskInfoService.GetTaskInfosByTaskCode(taskCode);
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var taskInfo in info)
|
|
|
|
|
{
|
|
|
|
|
if (taskInfo.TaskStatus == 2)
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("任务正在执行中不运行删除");
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
result =await _taskInfoService.DeleteTaskInfoById(taskInfo.ObjId);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
var spaceDetailInfo =await _spaceDetailService.GetSpaceDetailByMaterialCode(taskInfo.MaterialCode);
|
|
|
|
|
if (spaceDetailInfo != null)
|
|
|
|
|
{
|
|
|
|
|
spaceDetailInfo.IsFlag = 0;
|
|
|
|
|
await _spaceDetailService.UpdateSpaceDetail(spaceDetailInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据货道手动出一个
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> OutOnlyOneBySpaceCode(string storeCode, string spaceCode)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceInfo spaceInfo =await _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
|
|
|
|
|
if (spaceInfo.SpaceStock > 0)
|
|
|
|
|
{
|
|
|
|
|
result =await this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N"), DateTime.Now.ToString("HH:mm:ss"), 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage($"仓库:{storeCode};货道:{spaceCode};出一个失败:库存不足");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("根据货道出一个异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 手动释放信号量
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sph"></param>
|
|
|
|
|
private void GetAllRelese(Semaphore sph)
|
|
|
|
|
{
|
|
|
|
|
bool res = sph.WaitOne(1, false);
|
|
|
|
|
if (res)
|
|
|
|
|
{
|
|
|
|
|
GetAllRelese(sph);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过BOM获取物料名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<string> GetMaterialName(string materialType)
|
|
|
|
|
{
|
|
|
|
|
string materialName = string.Empty;
|
|
|
|
|
var info =await _bomInfoService.GetBomInfoByMaterialCode(materialType);
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
materialName = info.MaterialName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return materialName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 通过PLC读取货道信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过PLC读取货道信息(在库数量、货道状态)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private async Task<BaseSpaceInfo> GetSpaceInfoByMaterialType(string storeCode, string materialType)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceInfo result = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<BaseSpaceInfo> info = await _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, materialType);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
if (info.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//2023-11-26 注释
|
|
|
|
|
//foreach (BaseSpaceInfo item in info)
|
|
|
|
|
//{
|
|
|
|
|
// var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item);
|
|
|
|
|
// item.SpaceStock = spaceInfo.spaceStock;
|
|
|
|
|
// item.OnRouteAmount = spaceInfo.onRouteAmount;
|
|
|
|
|
// item.SpaceStatus = spaceInfo.spaceStatus;
|
|
|
|
|
// PrintLogInfoMessage($"通过PLC读取货道信息,货道:{spaceInfo.spaceName};在库数量:{item.SpaceStock};货道状态:{item.SpaceStatus}");
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//result = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).OrderBy(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
|
|
|
|
|
|
|
|
|
|
var list = info.Where(x => x.SpaceStatus == 1 && x.SpaceStock > 0).ToList();
|
|
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
result = info.OrderBy(x => x.SpaceStock).OrderBy(x => x.SpaceCode).First();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrintLogInfoMessage("未获取到匹配的货道,请排查货道库存及货道状态是否可用");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
PrintLogErrorMessage("货道信息读取异常", ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 日志输出
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志输出,界面刷新同时记录文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintLogInfoMessage(string message)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Info(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 异常日志输出
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
/// <param name="ex"></param>
|
|
|
|
|
private void PrintLogErrorMessage(string message, Exception ex = null)
|
|
|
|
|
{
|
|
|
|
|
RefreshLogMessageEvent?.Invoke(message);
|
|
|
|
|
logHelper.Error(message, ex);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|