diff --git a/SlnMesnac.Business/PalletStowBusiness.cs b/SlnMesnac.Business/PalletStowBusiness.cs index 0cb6b2b..2c93231 100644 --- a/SlnMesnac.Business/PalletStowBusiness.cs +++ b/SlnMesnac.Business/PalletStowBusiness.cs @@ -72,82 +72,82 @@ namespace SlnMesnac.Business public void Init() { - EmptyPalletHandle(); + // EmptyPalletHandle(); } - /// - /// 空托盘进入码垛位处理 - /// - private void EmptyPalletHandle() - { - //读取PLC空托盘流转信号 - while (true) - { - try - { - var plc = base.GetPlcByKey("plc"); + ///// + ///// 空托盘进入码垛位处理 + ///// + //private void EmptyPalletHandle() + //{ + // //读取PLC空托盘流转信号 + // while (true) + // { + // try + // { + // var plc = base.GetPlcByKey("plc"); - if (plc == null) - { - _logger.LogInformation("读取PLC空托盘流转信号,PLC连接信息为空......"); - Thread.Sleep(3000); - continue; - } + // if (plc == null) + // { + // _logger.LogInformation("读取PLC空托盘流转信号,PLC连接信息为空......"); + // Thread.Sleep(3000); + // continue; + // } - if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("空托到位"))) - { - // _logger.LogInformation("等待空托盘到位信号触发......"); - Thread.Sleep(5000); - continue; - } + // if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("空托到位"))) + // { + // // _logger.LogInformation("等待空托盘到位信号触发......"); + // Thread.Sleep(5000); + // continue; + // } - //读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定 - RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息"); + // //读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定 + // RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息"); - ReadEpcStrByRfidKey("test", out string epcStr); + // ReadEpcStrByRfidKey("test", out string epcStr); - if (string.IsNullOrEmpty(epcStr)) - { - throw new ArgumentException($"托盘信息读取失败"); - } + // if (string.IsNullOrEmpty(epcStr)) + // { + // throw new ArgumentException($"托盘信息读取失败"); + // } - RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}"); + // RefreshMessage($"空托盘RFID信息读取成功,标签信息:{epcStr}"); - Thread.Sleep(1000); + // Thread.Sleep(1000); - _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + // _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); - if (productPlanDto == null) - { - throw new ArgumentException($"未获取到正在执行的生产计划"); - } + // if (productPlanDto == null) + // { + // throw new ArgumentException($"未获取到正在执行的生产计划"); + // } - plc.writeInt16ByAddress(GetPlcAddressByConfigKey("空托到位"), 0); + // plc.writeInt16ByAddress(GetPlcAddressByConfigKey("空托到位"), 0); - //绑定信息存入wms_product_instock - _msInstockService.Insert(new WmsInstock() - { - PalletInfoCode = epcStr, - PlanCode = productPlanDto.PlanCode, - SaleorderCode = productPlanDto.SaleorderCode, - SaleOrderId = productPlanDto.SaleOrderId, - }); - RefreshMessage($"绑定托盘信息,托盘:{epcStr};计划:{productPlanDto.PlanCode};工单:{productPlanDto.SaleorderCode}"); - - _realPalletTaskService.InsertPalletTask(new RealPalletTask() { PalletCode = epcStr,RecordTime = DateTime.Now }); - - // RefreshPalletTaskListEvent?.Invoke(_palletTasks); - - } - catch (Exception e) - { - RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}"); - } - Thread.Sleep(5000); - } - } + // //绑定信息存入wms_product_instock + // _msInstockService.Insert(new WmsInstock() + // { + // PalletInfoCode = epcStr, + // PlanCode = productPlanDto.PlanCode, + // SaleorderCode = productPlanDto.SaleorderCode, + // SaleOrderId = productPlanDto.SaleOrderId, + // }); + // RefreshMessage($"绑定托盘信息,托盘:{epcStr};计划:{productPlanDto.PlanCode};工单:{productPlanDto.SaleorderCode}"); + + // _realPalletTaskService.InsertPalletTask(new RealPalletTask() { PalletCode = epcStr,RecordTime = DateTime.Now }); + + // // RefreshPalletTaskListEvent?.Invoke(_palletTasks); + + // } + // catch (Exception e) + // { + // RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}"); + // } + // Thread.Sleep(5000); + // } + //} public void RemovePalletInfo(string palletCode) { diff --git a/SlnMesnac.Business/ProdMgmtBusiness.cs b/SlnMesnac.Business/ProdMgmtBusiness.cs index 1f8ecaf..195e8fa 100644 --- a/SlnMesnac.Business/ProdMgmtBusiness.cs +++ b/SlnMesnac.Business/ProdMgmtBusiness.cs @@ -217,8 +217,8 @@ namespace SlnMesnac.Business continue; } - MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); - if (prodPlan == null || productPlanDto == null) + _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + if (productPlanDto == null) { //throw new ArgumentException($"未获取到需要执行的生产计划"); RefreshMessage($"3F未获取到需要执行的生产计划"); @@ -253,26 +253,24 @@ namespace SlnMesnac.Business RefreshMessage("3F设备要料信号触发成功"); - RefreshProdPlanExecEvent?.Invoke(prodPlan); + // RefreshProdPlanExecEvent?.Invoke(prodPlan); // string palletCode = GetPalletInfoByTask(); - RefreshMessage($"执行计划:{prodPlan.PlanCode};计划数量:{Math.Round(prodPlan.PlanAmount, 2)};完成数量:{Math.Round(prodPlan.CompleteAmount, 2)};发起叫料申请"); + RefreshMessage($"执行计划:{productPlanDto.PlanCode};计划数量:{Math.Round(productPlanDto.PlanAmount, 2)};完成数量:{Math.Round(productPlanDto.CompleteAmount, 2)};发起叫料申请"); //查询下发agv的主键 - WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(prodPlan.PlanCode); - if (wmsRaw == null) + WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(productPlanDto.PlanCode); + if (wmsRaw == null && debugConfig.ProductMode != "1") //不是手动模式,没有申请单 { - RefreshMessage("查询不到该计划......"); + RefreshMessage("自动模式,查询不到该计划出库申请单,请先创建..."); Thread.Sleep(5000); - continue; } //进行叫料 - if (ApplyDeliveryHandle(wmsRaw.rawOutstockId.ToString())) + if (ApplyDeliveryHandle(wmsRaw)) { - RefreshMessage("3F根据计划自动申请叫料成功"); #region 本地创建一个叫料任务 //BaseRealTask realTask = new BaseRealTask(); @@ -315,7 +313,7 @@ namespace SlnMesnac.Business while (true) { //mes计划 - MesProductPlan prodPlan = null; + // MesProductPlan prodPlan = null; //本地叫料任务 // BaseRealTask localPlan = null; try @@ -374,9 +372,9 @@ namespace SlnMesnac.Business } //TODO根据本地叫料计划查询对应的mes计划,完成 - prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); - if (productPlanDto == null || prodPlan == null) + if (productPlanDto == null) { RefreshMessage($"3F收到物料到位信号,未获取到正在执行的生产计划,请开始执行计划"); @@ -416,7 +414,7 @@ namespace SlnMesnac.Business //} #endregion - if (prodPlan != null) + if (productPlanDto != null) { // 下发翻转信号 plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), true); @@ -518,7 +516,7 @@ namespace SlnMesnac.Business /// /// /// - public bool ApplyDeliveryHandle(String taskId) + public bool ApplyDeliveryHandle(WmsRawOutstock wmsRaw) { bool result = false; try @@ -539,12 +537,16 @@ namespace SlnMesnac.Business targetLocationCode = PreferredOut.LocationCode; } } - + //if (debugConfig.ProductMode == "1") + //{ //标记手工叫料 + // taskId = "-1"; + //} var content = new { - rawOutstockId = taskId, + rawOutstockId = wmsRaw==null?"-1": wmsRaw.rawOutstockId.ToString(), locationCode = targetLocationCode, }; + string message = JsonConvert.SerializeObject(content); //询问小车是否离开接口 0已经离开 diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs index b38a3ac..223c387 100644 --- a/SlnMesnac.Business/base/BaseBusiness.cs +++ b/SlnMesnac.Business/base/BaseBusiness.cs @@ -205,7 +205,6 @@ namespace SlnMesnac.Business.@base var rfidEquip = GetRfidByKey(rfidKey); if(rfidEquip == null) { - return null; } List tagInfoList =await rfidEquip.GetRFIDAsync(); diff --git a/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs b/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs index 5886dc3..ee3a9c0 100644 --- a/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/MesProductPlanServiceImpl.cs @@ -89,7 +89,10 @@ namespace SlnMesnac.Repository.service.Impl productPlanDto = base._rep.AsQueryable() .LeftJoin((plan, order) => plan.ProductOrderId == order.ProductOrderId) .LeftJoin((plan, order, material) => plan.MaterialId == material.MaterialId) - .Where(plan => plan.StationId == _appConfig.stationId && plan.PlanStatus == PlanStatusEnum.已开始) + .Where((plan,order) => + plan.PlanStatus == PlanStatusEnum.已开始 && + (order.DispatchId == 2) + ) .Select((plan, order, material) => new MesProductPlanDto { PlanId = plan.PlanId, @@ -116,8 +119,8 @@ namespace SlnMesnac.Repository.service.Impl MaterialUnitId = material.MaterialUnitId, }).First(); - return base._rep.GetFirst(x => x.StationId == _appConfig.stationId && x.PlanStatus == PlanStatusEnum.已开始); - + //不使用return值,使用out MesProductPlanDto productPlanDto + return null; } catch (Exception e) { diff --git a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs index 2d5c8f0..2ee5e8c 100644 --- a/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/ProdMgmtViewModel.cs @@ -505,7 +505,7 @@ namespace SlnMesnac.WPF.ViewModel { await Task.Run(() => { - ProductionHourList = new List() { "8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "20:00" }; + ProductionHourList = new List() { "8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00" }; List list = _mesBaseBarcodeInfoService.Query(x => x.bindTime != null && x.bindTime >= DateTime.Now.Date && x.bindTime <= DateTime.Now.AddDays(1)).ToList(); if (list != null && list.Count > 0) {