change-人工叫料修改

dev
liuwf 1 week ago
parent c7c6c10937
commit 1197e71c9d

@ -72,82 +72,82 @@ namespace SlnMesnac.Business
public void Init() public void Init()
{ {
EmptyPalletHandle(); // EmptyPalletHandle();
} }
/// <summary> ///// <summary>
/// 空托盘进入码垛位处理 ///// 空托盘进入码垛位处理
/// </summary> ///// </summary>
private void EmptyPalletHandle() //private void EmptyPalletHandle()
{ //{
//读取PLC空托盘流转信号 // //读取PLC空托盘流转信号
while (true) // while (true)
{ // {
try // try
{ // {
var plc = base.GetPlcByKey("plc"); // var plc = base.GetPlcByKey("plc");
if (plc == null) // if (plc == null)
{ // {
_logger.LogInformation("读取PLC空托盘流转信号,PLC连接信息为空......"); // _logger.LogInformation("读取PLC空托盘流转信号,PLC连接信息为空......");
Thread.Sleep(3000); // Thread.Sleep(3000);
continue; // continue;
} // }
if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("空托到位"))) // if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("空托到位")))
{ // {
// _logger.LogInformation("等待空托盘到位信号触发......"); // // _logger.LogInformation("等待空托盘到位信号触发......");
Thread.Sleep(5000); // Thread.Sleep(5000);
continue; // continue;
} // }
//读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定 // //读取RFID、获取当前正在执行的计划、将当前计划、工单等信息与托盘绑定
RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息"); // RefreshMessage("空托盘到位信号触发成功,读取托盘RFID信息");
ReadEpcStrByRfidKey("test", out string epcStr); // ReadEpcStrByRfidKey("test", out string epcStr);
if (string.IsNullOrEmpty(epcStr)) // if (string.IsNullOrEmpty(epcStr))
{ // {
throw new ArgumentException($"托盘信息读取失败"); // 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) // if (productPlanDto == null)
{ // {
throw new ArgumentException($"未获取到正在执行的生产计划"); // throw new ArgumentException($"未获取到正在执行的生产计划");
} // }
plc.writeInt16ByAddress(GetPlcAddressByConfigKey("空托到位"), 0); // plc.writeInt16ByAddress(GetPlcAddressByConfigKey("空托到位"), 0);
//绑定信息存入wms_product_instock // //绑定信息存入wms_product_instock
_msInstockService.Insert(new WmsInstock() // _msInstockService.Insert(new WmsInstock()
{ // {
PalletInfoCode = epcStr, // PalletInfoCode = epcStr,
PlanCode = productPlanDto.PlanCode, // PlanCode = productPlanDto.PlanCode,
SaleorderCode = productPlanDto.SaleorderCode, // SaleorderCode = productPlanDto.SaleorderCode,
SaleOrderId = productPlanDto.SaleOrderId, // SaleOrderId = productPlanDto.SaleOrderId,
}); // });
RefreshMessage($"绑定托盘信息,托盘:{epcStr};计划:{productPlanDto.PlanCode};工单:{productPlanDto.SaleorderCode}"); // RefreshMessage($"绑定托盘信息,托盘:{epcStr};计划:{productPlanDto.PlanCode};工单:{productPlanDto.SaleorderCode}");
_realPalletTaskService.InsertPalletTask(new RealPalletTask() { PalletCode = epcStr,RecordTime = DateTime.Now }); // _realPalletTaskService.InsertPalletTask(new RealPalletTask() { PalletCode = epcStr,RecordTime = DateTime.Now });
// RefreshPalletTaskListEvent?.Invoke(_palletTasks); // // RefreshPalletTaskListEvent?.Invoke(_palletTasks);
} // }
catch (Exception e) // catch (Exception e)
{ // {
RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}"); // RefreshMessage($"空托盘进入码垛位处理异常:{e.Message}");
} // }
Thread.Sleep(5000); // Thread.Sleep(5000);
} // }
} //}
public void RemovePalletInfo(string palletCode) public void RemovePalletInfo(string palletCode)
{ {

@ -217,8 +217,8 @@ namespace SlnMesnac.Business
continue; continue;
} }
MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
if (prodPlan == null || productPlanDto == null) if (productPlanDto == null)
{ {
//throw new ArgumentException($"未获取到需要执行的生产计划"); //throw new ArgumentException($"未获取到需要执行的生产计划");
RefreshMessage($"3F未获取到需要执行的生产计划"); RefreshMessage($"3F未获取到需要执行的生产计划");
@ -253,26 +253,24 @@ namespace SlnMesnac.Business
RefreshMessage("3F设备要料信号触发成功"); RefreshMessage("3F设备要料信号触发成功");
RefreshProdPlanExecEvent?.Invoke(prodPlan); // RefreshProdPlanExecEvent?.Invoke(prodPlan);
// string palletCode = GetPalletInfoByTask(); // 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的主键 //查询下发agv的主键
WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(prodPlan.PlanCode); WmsRawOutstock wmsRaw = _wmsOutStockService.GetProdPlanByPlanCode(productPlanDto.PlanCode);
if (wmsRaw == null) if (wmsRaw == null && debugConfig.ProductMode != "1") //不是手动模式,没有申请单
{ {
RefreshMessage("查询不到该计划......"); RefreshMessage("自动模式,查询不到该计划出库申请单,请先创建...");
Thread.Sleep(5000); Thread.Sleep(5000);
continue; continue;
} }
//进行叫料 //进行叫料
if (ApplyDeliveryHandle(wmsRaw.rawOutstockId.ToString())) if (ApplyDeliveryHandle(wmsRaw))
{ {
RefreshMessage("3F根据计划自动申请叫料成功"); RefreshMessage("3F根据计划自动申请叫料成功");
#region 本地创建一个叫料任务 #region 本地创建一个叫料任务
//BaseRealTask realTask = new BaseRealTask(); //BaseRealTask realTask = new BaseRealTask();
@ -315,7 +313,7 @@ namespace SlnMesnac.Business
while (true) while (true)
{ {
//mes计划 //mes计划
MesProductPlan prodPlan = null; // MesProductPlan prodPlan = null;
//本地叫料任务 //本地叫料任务
// BaseRealTask localPlan = null; // BaseRealTask localPlan = null;
try try
@ -374,9 +372,9 @@ namespace SlnMesnac.Business
} }
//TODO根据本地叫料计划查询对应的mes计划完成 //TODO根据本地叫料计划查询对应的mes计划完成
prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto);
if (productPlanDto == null || prodPlan == null) if (productPlanDto == null)
{ {
RefreshMessage($"3F收到物料到位信号,未获取到正在执行的生产计划,请开始执行计划"); RefreshMessage($"3F收到物料到位信号,未获取到正在执行的生产计划,请开始执行计划");
@ -416,7 +414,7 @@ namespace SlnMesnac.Business
//} //}
#endregion #endregion
if (prodPlan != null) if (productPlanDto != null)
{ {
// 下发翻转信号 // 下发翻转信号
plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), true); plc.writeBoolByAddress(GetPlcAddressByConfigKey("设备投料"), true);
@ -518,7 +516,7 @@ namespace SlnMesnac.Business
/// <param name="materialCode"></param> /// <param name="materialCode"></param>
/// <param name="result"></param> /// <param name="result"></param>
/// <exception cref="InvalidOperationException"></exception> /// <exception cref="InvalidOperationException"></exception>
public bool ApplyDeliveryHandle(String taskId) public bool ApplyDeliveryHandle(WmsRawOutstock wmsRaw)
{ {
bool result = false; bool result = false;
try try
@ -539,12 +537,16 @@ namespace SlnMesnac.Business
targetLocationCode = PreferredOut.LocationCode; targetLocationCode = PreferredOut.LocationCode;
} }
} }
//if (debugConfig.ProductMode == "1")
//{ //标记手工叫料
// taskId = "-1";
//}
var content = new var content = new
{ {
rawOutstockId = taskId, rawOutstockId = wmsRaw==null?"-1": wmsRaw.rawOutstockId.ToString(),
locationCode = targetLocationCode, locationCode = targetLocationCode,
}; };
string message = JsonConvert.SerializeObject(content); string message = JsonConvert.SerializeObject(content);
//询问小车是否离开接口 0已经离开 //询问小车是否离开接口 0已经离开

@ -205,7 +205,6 @@ namespace SlnMesnac.Business.@base
var rfidEquip = GetRfidByKey(rfidKey); var rfidEquip = GetRfidByKey(rfidKey);
if(rfidEquip == null) if(rfidEquip == null)
{ {
return null; return null;
} }
List<TagInfo> tagInfoList =await rfidEquip.GetRFIDAsync(); List<TagInfo> tagInfoList =await rfidEquip.GetRFIDAsync();

@ -89,7 +89,10 @@ namespace SlnMesnac.Repository.service.Impl
productPlanDto = base._rep.AsQueryable() productPlanDto = base._rep.AsQueryable()
.LeftJoin<MesProductOrder>((plan, order) => plan.ProductOrderId == order.ProductOrderId) .LeftJoin<MesProductOrder>((plan, order) => plan.ProductOrderId == order.ProductOrderId)
.LeftJoin<BaseMaterialInfo>((plan, order, material) => plan.MaterialId == material.MaterialId) .LeftJoin<BaseMaterialInfo>((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 .Select((plan, order, material) => new MesProductPlanDto
{ {
PlanId = plan.PlanId, PlanId = plan.PlanId,
@ -116,8 +119,8 @@ namespace SlnMesnac.Repository.service.Impl
MaterialUnitId = material.MaterialUnitId, MaterialUnitId = material.MaterialUnitId,
}).First(); }).First();
return base._rep.GetFirst(x => x.StationId == _appConfig.stationId && x.PlanStatus == PlanStatusEnum.); //不使用return值使用out MesProductPlanDto productPlanDto
return null;
} }
catch (Exception e) catch (Exception e)
{ {

@ -505,7 +505,7 @@ namespace SlnMesnac.WPF.ViewModel
{ {
await Task.Run(() => await Task.Run(() =>
{ {
ProductionHourList = new List<string>() { "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<string>() { "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<MesBaseBarcodeInfo> list = _mesBaseBarcodeInfoService.Query(x => x.bindTime != null && x.bindTime >= DateTime.Now.Date && x.bindTime <= DateTime.Now.AddDays(1)).ToList(); List<MesBaseBarcodeInfo> 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) if (list != null && list.Count > 0)
{ {

Loading…
Cancel
Save