93 lines
3.3 KiB
C#
93 lines
3.3 KiB
C#
using JSMachine.WMS.App.Dto;
|
|||
|
|
using JSMachine.WMS.App.Dto.Enum;
|
||
|
|
using JSMachine.WMS.App.IService;
|
||
|
|
using JSMachine.WMS.Business.RcsCallBack.IService.StaePattern;
|
||
|
|
using JSMachine.WMS.Business.SSE;
|
||
|
|
using JSMachine.WMS.Infrastructure.Helper;
|
||
|
|
using JSMachine.WMS.RPC.RcsRPC.Dto.In;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace JSMachine.WMS.Business.RcsCallBack.ServiceImpl.StatePattern
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// agv取货完成处理器
|
||
|
|
/// </summary>
|
||
|
|
public class PickupCompletedStateHandler : IAgvTaskStateHandler
|
||
|
|
{
|
||
|
|
private readonly IStorageRackService _storageRackService;
|
||
|
|
private readonly IAGVTaskService _agvTaskService;
|
||
|
|
|
||
|
|
public PickupCompletedStateHandler(IStorageRackService storageRackService, IAGVTaskService agvTaskService)
|
||
|
|
{
|
||
|
|
_storageRackService = storageRackService;
|
||
|
|
_agvTaskService = agvTaskService;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<bool> HandleAsync(AgvExcutionInfo agvExcutionInfo, AGVTaskDto agvTask, StorageRackDto destWarehouse)
|
||
|
|
{
|
||
|
|
// 清空出库库位上的物料、解锁库位
|
||
|
|
await ClearMateriaInfo(agvTask);
|
||
|
|
|
||
|
|
//更新AgvTask的状态为 取货完成
|
||
|
|
agvTask.TaskStatus = TaskStatusEnum.PickupCompleted;
|
||
|
|
return await _agvTaskService.UpdateAgvTaskStatus(agvTask);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 清空起点库位上的物料信息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="agvTask"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
private async Task<bool> ClearMateriaInfo(AGVTaskDto agvTask)
|
||
|
|
{
|
||
|
|
var clearResult = false;
|
||
|
|
var typeMsg = "";
|
||
|
|
if (agvTask.TaskType == TaskTypeEnum.SaleOut)
|
||
|
|
{
|
||
|
|
typeMsg = "销售出库,";
|
||
|
|
}
|
||
|
|
else if (agvTask.TaskType == TaskTypeEnum.Carry)
|
||
|
|
{
|
||
|
|
typeMsg = "搬运物料,";
|
||
|
|
}
|
||
|
|
|
||
|
|
var clearWarehouse = await _storageRackService.GetSingalByExpression(p => p.StorageRackNo == agvTask.StartPositionCode);
|
||
|
|
if (clearWarehouse != null)
|
||
|
|
{
|
||
|
|
clearWarehouse.MateriaBatch = "";
|
||
|
|
clearWarehouse.MateriaNum = 0;
|
||
|
|
|
||
|
|
clearWarehouse.OrderNo = "";
|
||
|
|
clearWarehouse.MateriaName = "";
|
||
|
|
clearWarehouse.MateriaType = "";
|
||
|
|
clearWarehouse.MateriaCode = "";
|
||
|
|
clearWarehouse.BarCode = "";
|
||
|
|
clearWarehouse.IsLock = false;
|
||
|
|
|
||
|
|
clearResult = await _storageRackService.EditSingal(clearWarehouse);
|
||
|
|
if (!clearResult)
|
||
|
|
{
|
||
|
|
LogHelper.Error($"{typeMsg}清空库位{clearWarehouse.StorageRackNo}上的物料信息{clearWarehouse.MateriaCode}失败");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
LogHelper.Info($"{typeMsg}清空库位{clearWarehouse.StorageRackNo}上的物料信息{clearWarehouse.MateriaCode}成功");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
LogHelper.Error($"{typeMsg}清空库位时,未查询到库位{agvTask.StartPositionCode}上的物料信息");
|
||
|
|
}
|
||
|
|
|
||
|
|
//发送广播通知前端网站刷新页面
|
||
|
|
SseEngine.BrodCast(agvTask.Floor.ToString());
|
||
|
|
|
||
|
|
return clearResult;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|