diff --git a/Admin.Core.Repository/Repository_New/RecordInstoreRepository.cs b/Admin.Core.Repository/Repository_New/RecordInstoreRepository.cs index 5f8c2670..6ba432ae 100644 --- a/Admin.Core.Repository/Repository_New/RecordInstoreRepository.cs +++ b/Admin.Core.Repository/Repository_New/RecordInstoreRepository.cs @@ -24,7 +24,8 @@ namespace Admin.Core.Repository Db.Deleteable(realTask).ExecuteCommand(); Db.Updateable(baseSpaceInfo).ExecuteCommand(); Db.Insertable(store).ExecuteCommand(); - Db.Insertable(baseDetail).ExecuteCommand(); + // 不控制出库,没必要添加货道明细 + // Db.Insertable(baseDetail).ExecuteCommand(); Db.Ado.CommitTran(); return true; } diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index 8de827e2..203259d5 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -83,11 +83,6 @@ namespace Aucma.Core.BoxFoam.Business #endregion - /// - /// 入库出库完成信号定时器 - /// - System.Timers.Timer timer = new System.Timers.Timer(1000); - private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(InStoreBusiness)); private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices = App.ServiceProvider.GetService(); private readonly IRealTaskInfoServices? _realTaskInfoService = App.ServiceProvider.GetService(); @@ -111,42 +106,22 @@ namespace Aucma.Core.BoxFoam.Business public void init() { - allSpaces = _baseSpaceInfoServices.Query(x => x.StoreCode == storeCode); + allSpaces = _baseSpaceInfoServices.Query(x => x.StoreCode == storeCode); foreach (var space in allSpaces) { spaceAddresses.Add(spaceConfig.GetSpaceAddress(storeCode, space.SpaceCode)); } - Task.Run(() => - { - Thread.Sleep(5000); - - // test(); - // 获取任务下发plc - // StartPassDown(); - // InStore("B23600083025024860011"); - }); - // startTimer(); + + //实时监测入库任务下发和入库任务完成 + StartPassDownAndRealInstoreFinish(); + } - public async void test() - { - // InStoreFinish("PB01_001"); - } - /// - /// 入库出库完成信号定时器 - /// - public void startTimer() - { - timer.Elapsed += new System.Timers.ElapsedEventHandler(RealInstoreFinish); //到达时间的时候执行事件; - timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true); - timer.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它, - timer.Start();//timer.Start()的内部原理还是设置timer.Enabled = true; - } /// /// 定时器实时监测入库出库完成信号 /// /// - public void RealInstoreFinish(object? sender, ElapsedEventArgs e) + public void RealInstoreFinish() { var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); if (obj != null && obj.plc.IsConnected) @@ -163,25 +138,37 @@ namespace Aucma.Core.BoxFoam.Business if (obj.plc.ReadInt16(spaceAddress.outStoreFinish) == 1) { obj.plc.WriteInt16(spaceAddress.outStoreFinish, "0"); - // 减货道明细 + // 系统不控制出库,暂时未使用出库完成信号 } } } } - - public async void StartPassDown() + /// + ///实时监测入库任务下发和入库任务完成 + /// + public async void StartPassDownAndRealInstoreFinish() { Task.Run(() => { + Thread.Sleep(3000); while (true) { PassDown(); - Thread.Sleep(200000); + Thread.Sleep(1000); } }); - - + Task.Run(() => + { + Thread.Sleep(3000); + while (true) + { + RealInstoreFinish(); + Thread.Sleep(1000); + } + }); + + } @@ -523,104 +510,7 @@ namespace Aucma.Core.BoxFoam.Business } } - //#region 监测PLC在途数量变化,完成入库任务 - - ///// - ///// 读取箱壳已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成 - ///// - //private void RealReadPlcSpace() - //{ - // if (TaskInfos != null) - // { - // List spaceCodes = TaskInfos.Select(x => x.SpaceCode).Distinct().ToList(); - - // for (int i = 0; i < spaceCodes.Count; i++) - // { - // string spaceCode = spaceCodes[i]; - - // BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { StoreCode = storeCode, SpaceCode = spaceCode }; - - // spaceInfo = ReadSpaceInfoByPlc(spaceInfo); - - // if (KeyValuePairs.ContainsKey(spaceInfo.SpaceCode)) - // { - // KeyValuePairs.TryGetValue(spaceInfo.SpaceCode, out int value); - // //判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成 - // //如果前次数据不大于当前数据则更新字典中存放的数据 - // if (value > spaceInfo.OnRouteAmount) - // { - // //筛选任务 - // var list = TaskInfos.Where(x => x.SpaceCode == spaceInfo.SpaceCode).ToList(); - // if (list.Count > 0) - // { - // RealTaskInfo taskInfo = list.OrderBy(x => x.CreateTime).First(); - // InStoreFinish(taskInfo.TaskCode); - - // TaskInfos.Remove(taskInfo); - // } - // KeyValuePairs.Remove(spaceInfo.SpaceCode); - // } - // else - // { - // KeyValuePairs[spaceInfo.SpaceCode] = spaceInfo.OnRouteAmount; - // } - - // } - // else - // { - // KeyValuePairs.Add(spaceInfo.SpaceCode, spaceInfo.OnRouteAmount); - // } - // } - - // } - //} - - - //#endregion - - - /// - /// 读取泡后入库完成 - /// - //private void ReadShellFinish_InStore(string taskCode) - //{ - // lock (string.Empty) - // { - // bool isFlag = true; - // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); - - // try - // { - // Task.Run(() => - // { - // if (obj != null && obj.plc.IsConnected) - // { - // do - // { - // //读取PLC入库任务完成 - // if (obj.plc.ReadInt16("D220") == 1) - // { - // obj.plc.WriteInt16("D220", "0"); - // FoamTaskFeedback(taskCode); - // isFlag = false; - // } - // Thread.Sleep(1000); - // } while (isFlag); - // } - // else - // { - // logHelper.Info("PLC未连接"); - // } - // }); - // } - // catch (Exception ex) - // { - // logHelper.Error("读取泡后入库完成异常", ex); - // } - // } - //} - - + /// /// 泡前库执行反馈 /// @@ -664,7 +554,7 @@ namespace Aucma.Core.BoxFoam.Business await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo); - #region 添加货道明细 + #region 添加货道明细 不控制出库,暂时未添加明细 BaseSpaceDetail spaceDetail = new BaseSpaceDetail(); spaceDetail.MaterialType = taskInfo.MaterialType; spaceDetail.MaterialCode = taskInfo.MaterialCode;