| | |
| | | using Mapster; |
| | | using System.Collections.Generic; |
| | | using WIDESEA_DTO.MOM; |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IStoragIntegrationServices; |
| | | using WIDESEA_StoragIntegrationServices; |
| | | namespace WIDESEA_StorageOutTaskServices; |
| | | |
| | | public class Dt_TaskService : ServiceBase<Dt_Task, IDt_TaskRepository>, IDt_TaskService |
| | |
| | | private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository; |
| | | private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository; |
| | | private readonly IBoxingInfoRepository _boxingInfoRepository; |
| | | private readonly ICellStateService _cellStateService; |
| | | private readonly IProcessApplyService _processApplyService; |
| | | |
| | | public Dt_TaskService(IDt_TaskRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | IPointStackerRelationRepository pointStackerRelationRepository, |
| | | ITaskExecuteDetailRepository taskExecuteDetailRepository, |
| | | ILocationStatusChangeRecordRepository locationStatusChangeRecordRepository, |
| | | IBoxingInfoRepository boxingInfoRepository) : base(BaseDal) |
| | | IBoxingInfoRepository boxingInfoRepository, |
| | | ICellStateService cellStateService, |
| | | IProcessApplyService processApplyService) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _outOrderRepository = outOrderRepository; |
| | |
| | | _taskExecuteDetailRepository = taskExecuteDetailRepository; |
| | | _locationStatusChangeRecordRepository = locationStatusChangeRecordRepository; |
| | | _boxingInfoRepository = boxingInfoRepository; |
| | | _cellStateService = cellStateService; |
| | | _processApplyService = processApplyService |
| | | } |
| | | |
| | | #region 外部接口方法 |
| | |
| | | }); |
| | | |
| | | // 更新任务状态 |
| | | task.TaskState = OutTaskStatusEnum.SC_OutFinish.ObjToInt(); |
| | | task.TaskState = TaskOutStatusEnum.SC_OutFinish.ObjToInt(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = task.TargetAddress; |
| | | |
| | |
| | | if (task.TaskType == (int)TaskTypeEnum.Outbound) |
| | | { |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "出库任务", ""); |
| | | if (task.TaskState == OutTaskStatusEnum.SC_OutExecuting.ObjToInt()) |
| | | if (task.TaskState == TaskOutStatusEnum.SC_OutExecuting.ObjToInt()) |
| | | { |
| | | LogFactory.GetLog("任务完成").InfoFormat(true, "堆垛机出库完成", ""); |
| | | return await CompleteStackTaskAsync(task, stock); |
| | |
| | | try |
| | | { |
| | | // 根据托盘获取库存信息 |
| | | var stockInfo = await _stockInfoRepository.QueryFirstAsync(x => x.PalletCode == input.PalletCode); |
| | | //var stockInfo = await _stockInfoRepository.QueryFirstAsync(x => x.PalletCode == input.PalletCode); |
| | | TrayCellsStatusDto trayCells = new TrayCellsStatusDto() |
| | | { |
| | | TrayBarcode = input.PalletCode |
| | | }; |
| | | content = await _cellStateService.GetTrayCellStatusAsync(trayCells); |
| | | if (content.Status) |
| | | { |
| | | ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString()); |
| | | |
| | | ProcessApplyDto process = new ProcessApplyDto() |
| | | { |
| | | WipOrderNo = result.BindCode, |
| | | SerialNos = result.SerialNos.Select(item => new SerialNos |
| | | { |
| | | SerialNo = item.SerialNo |
| | | }).ToList() |
| | | }; |
| | | content = await _processApplyService.GetProcessApplyAsync(process); |
| | | if (content.Status) |
| | | { |
| | | var X = SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>().Where(x => x.EquipmentType == "CH").ToList(); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 获取仓库区域信息 |
| | | var areaInfo = await _wareAreaInfoRepository.QueryFirstAsync(x => x.WareAreaCode == input.AreaCode); |
| | |
| | | private Dt_Task_Hty CreateHistoricalTask(Dt_Task task) |
| | | { |
| | | // 更新任务状态 |
| | | task.TaskState = OutTaskStatusEnum.OutFinish.ObjToInt(); |
| | | task.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | |
| | | // 创建历史任务 |
| | |
| | | taskHty.TaskId = 0; |
| | | taskHty.OperateType = (int)OperateTypeEnum.自动完成; |
| | | taskHty.SourceId = task.TaskId; |
| | | taskHty.TaskState = OutTaskStatusEnum.OutFinish.ObjToInt(); |
| | | taskHty.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt(); |
| | | return taskHty; |
| | | } |
| | | |
| | |
| | | { |
| | | // 处理出库任务 |
| | | toAddress = await GetRoadWayAsync(areaId, task.Roadway, input.Direction, input.Area, input.Type); |
| | | taskState = (int)OutTaskStatusEnum.SC_OutFinish; |
| | | taskState = (int)TaskOutStatusEnum.SC_OutFinish; |
| | | } |
| | | else |
| | | { |
| | | // 处理入库任务 |
| | | location = await GetLocationDistributeAsync(areaId, task.Roadway); |
| | | toAddress = location.LocationCode; |
| | | taskState = (int)InTaskStatusEnum.Line_InFinish; |
| | | taskState = (int)TaskInStatusEnum.Line_InFinish; |
| | | beforeStatus = location.LocationStatus; |
| | | |
| | | // 更新货位信息 |
| | |
| | | |
| | | // 尝试更新任务 |
| | | bool isResult = await BaseDal.UpdateDataAsync(task); |
| | | bool isTaskDetail = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(task.PalletCode, original, input.Position, InTaskStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc())); |
| | | bool isTaskDetail = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(task.PalletCode, original, input.Position, TaskInStatusEnum.Line_InFinish.GetIntegralRuleTypeEnumDesc())); |
| | | if (input.Type != (int)TaskTypeEnum.Outbound) |
| | | { |
| | | // 创建LocationChangeRecordDto对象 |
| | |
| | | OrderNo = null, |
| | | PalletCode = input.PalletCode, |
| | | SourceAddress = input.Position, |
| | | TaskState = (int)InTaskStatusEnum.InNew, |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | TaskType = (int)TaskTypeEnum.Inbound, |
| | | TaskNum = await BaseDal.GetTaskNo(), |
| | | Creater = "Systeam" |
| | |
| | | if (isResult) |
| | | { |
| | | task.TaskId = taskId; |
| | | isResult = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(input.PalletCode, input.Position, ToAddress, InTaskStatusEnum.InNew.GetIntegralRuleTypeEnumDesc())); |
| | | isResult = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(input.PalletCode, input.Position, ToAddress, TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc())); |
| | | if (isResult) |
| | | content.OK(data: task); |
| | | { |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = 0, |
| | | Grade = 1, |
| | | PalletCode = DateTime.Now.ToString("MMddHHmmss"), |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = "001-001-001", |
| | | TargetAddress = task.Roadway, |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound, |
| | | }; |
| | | content.OK(data: taskDTO); |
| | | } |
| | | else |
| | | content.Error("添加任务失败"); |
| | | } |