diff --git a/.vs/HighWayIot/v16/.suo b/.vs/HighWayIot/v16/.suo index ea83a7da..61ed3bab 100644 Binary files a/.vs/HighWayIot/v16/.suo and b/.vs/HighWayIot/v16/.suo differ diff --git a/Aucma.Scada.Business/Aucma.Scada.Business.csproj b/Aucma.Scada.Business/Aucma.Scada.Business.csproj index 99162aae..62ddc3db 100644 --- a/Aucma.Scada.Business/Aucma.Scada.Business.csproj +++ b/Aucma.Scada.Business/Aucma.Scada.Business.csproj @@ -43,6 +43,7 @@ + diff --git a/Aucma.Scada.Business/OutStoreBusiness.cs b/Aucma.Scada.Business/OutStoreBusiness.cs new file mode 100644 index 00000000..634736e1 --- /dev/null +++ b/Aucma.Scada.Business/OutStoreBusiness.cs @@ -0,0 +1,175 @@ +using HighWayIot.Log4net; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using HighWayIot.Repository.service.Impl; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Scada.Business +{ + public class OutStoreBusiness + { + private static readonly Lazy lazy = new Lazy(() => new OutStoreBusiness()); + public static OutStoreBusiness Instance + { + get + { + return lazy.Value; + } + } + + private LogHelper logHelper = LogHelper.Instance; + + private IBaseSpaceInfoService _spaceInfoService = new BaseSpaceInfoServiceImpl(); + + private IRealTaskInfoService _taskInfoService = new RealTaskInfoServiceImpl(); + + /// + /// 初始化出库任务 + /// + /// + public delegate void RefreshOutStoreTask(RealTaskInfo taskInfos); + public event RefreshOutStoreTask RefreshOutStoreTaskEvent; + + /// + /// 扫码信息刷新 + /// + /// + /// + /// + /// + public delegate void RefreshScanMateriaCode(string materialCode, string materialName, string spaceName, string materialType); + public event RefreshScanMateriaCode RefreshScanMateriaCodeEvent; + + /// + /// 日志信息刷新 + /// + /// + public delegate void RefreshLogMessage(string message); + public event RefreshLogMessage RefreshLogMessageEvent; + + public OutStoreBusiness() + { + System.Timers.Timer timer = new System.Timers.Timer(interval: 3000); + timer.Elapsed += (sender, e) => HandleTimer(); + timer.Start(); + } + + private void HandleTimer() + { + OutStore("X-001", "SC232"); + } + + private void OutStore(string storeCode, string materiaclCode) + { + try + { + PrintLogInfoMessage($"扫码成功,物料码:{materiaclCode}"); + string materialType = materiaclCode; + BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialType(storeCode, materialType); + if (spaceInfo != null) + { + PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); + RefreshScanMateriaCodeEvent?.Invoke(materiaclCode, materialType, spaceInfo.spaceName, storeCode); //刷新界面扫码信息 + CreateOutStoreTask(spaceInfo,materiaclCode); //创建出库任务 + } + else + { + //报警停线 + } + } + catch (Exception ex) + { + PrintLogErrorMessage("出库业务异常", ex); + } + } + + /// + /// 创建出库任务 + /// + /// + private void CreateOutStoreTask(BaseSpaceInfo spaceInfo, string materialCode) + { + //生成入库任务依次下发至PLC + RealTaskInfo realTaskInfo = new RealTaskInfo(); + realTaskInfo.taskType = 2; + realTaskInfo.taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 6); + realTaskInfo.storeCode = spaceInfo.storeCode; + realTaskInfo.spaceCode = spaceInfo.spaceCode; + realTaskInfo.materialType = spaceInfo.materialType; + realTaskInfo.materialCode = System.Guid.NewGuid().ToString("N").Substring(0, 6); ; + realTaskInfo.planAmount = 1; + realTaskInfo.taskStatus = 1; + realTaskInfo.createTime = DateTime.Now; + bool result = _taskInfoService.AddTaskInfo(realTaskInfo); + if (result) + { + PrintLogInfoMessage("出库任务创建成功"); + + RefreshOutStoreTaskEvent?.Invoke(realTaskInfo); + } + else + { + PrintLogInfoMessage("出库任务创建失败"); + } + } + + /// + /// 出库完成 + /// + /// + /// + /// + private void OutStoreFinish(string taskCode) + { + try + { + var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode); + if (taskInfo != null) + { + var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode); + + if (spaceInfo != null) + { + //读取PLC获取货道信息:存放数量、在途数量 + spaceInfo.materialType = taskInfo.materialType; + _spaceInfoService.UpdateSpaceInfo(spaceInfo); + + //读取PLC获取物料类型进行绑定 + } + //清除任务信息 + _taskInfoService.DeleteTaskInfo(taskCode); + } + + } + catch (Exception ex) + { + PrintLogErrorMessage("出库完成逻辑处理异常", ex); + } + } + + /// + /// 日志输出,界面刷新同时记录文件 + /// + /// + private void PrintLogInfoMessage(string message) + { + RefreshLogMessageEvent?.Invoke(message); + logHelper.Info(message); + } + + /// + /// 异常日志输出 + /// + /// + /// + private void PrintLogErrorMessage(string message, Exception ex = null) + { + RefreshLogMessageEvent?.Invoke(message); + logHelper.Error(message, ex); + } + } +} diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll index a5b88e8f..5de9bf27 100644 Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll differ diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb index 155df9db..e24dbaca 100644 Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb differ diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache index f5e894ae..10b08d28 100644 Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache differ diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.CoreCompileInputs.cache b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.CoreCompileInputs.cache index 3bd8e073..72de9c6a 100644 --- a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.CoreCompileInputs.cache +++ b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -fc1a04eef14a69e48b92915238b5510a42d5e748 +585b703e892749261afc6d72c39583dd105aab41 diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll index a5b88e8f..5de9bf27 100644 Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll differ diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb index 155df9db..e24dbaca 100644 Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb differ diff --git a/Aucma.Scada.UI/Aucma.Scada.UI.csproj b/Aucma.Scada.UI/Aucma.Scada.UI.csproj index 3c6fbc07..dc63c7b5 100644 --- a/Aucma.Scada.UI/Aucma.Scada.UI.csproj +++ b/Aucma.Scada.UI/Aucma.Scada.UI.csproj @@ -129,6 +129,7 @@ + diff --git a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml index f627657d..dad01840 100644 --- a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml +++ b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml @@ -17,95 +17,108 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - + + - - - - - - - + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -115,63 +128,127 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - -